blob: 1b7fa5593a333b3fb6ee6749de8e3a94d2f250cc [file] [log] [blame]
Danil Chapovalovb32f2c72019-05-22 13:39:25 +02001/*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef API_RTC_EVENT_LOG_RTC_EVENT_H_
12#define API_RTC_EVENT_LOG_RTC_EVENT_H_
13
14#include <cstdint>
15
16namespace webrtc {
17
18// This class allows us to store unencoded RTC events. Subclasses of this class
19// store the actual information. This allows us to keep all unencoded events,
20// even when their type and associated information differ, in the same buffer.
21// Additionally, it prevents dependency leaking - a module that only logs
22// events of type RtcEvent_A doesn't need to know about anything associated
23// with events of type RtcEvent_B.
24class RtcEvent {
25 public:
26 // Subclasses of this class have to associate themselves with a unique value
27 // of Type. This leaks the information of existing subclasses into the
28 // superclass, but the *actual* information - rtclog::StreamConfig, etc. -
29 // is kept separate.
30 enum class Type {
31 AlrStateEvent,
32 RouteChangeEvent,
33 AudioNetworkAdaptation,
34 AudioPlayout,
35 AudioReceiveStreamConfig,
36 AudioSendStreamConfig,
37 BweUpdateDelayBased,
38 BweUpdateLossBased,
39 DtlsTransportState,
40 DtlsWritableState,
41 IceCandidatePairConfig,
42 IceCandidatePairEvent,
43 ProbeClusterCreated,
44 ProbeResultFailure,
45 ProbeResultSuccess,
46 RtcpPacketIncoming,
47 RtcpPacketOutgoing,
48 RtpPacketIncoming,
49 RtpPacketOutgoing,
50 VideoReceiveStreamConfig,
51 VideoSendStreamConfig,
52 GenericPacketSent,
53 GenericPacketReceived,
54 GenericAckReceived
55 };
56
57 RtcEvent();
58 virtual ~RtcEvent() = default;
59
60 virtual Type GetType() const = 0;
61
62 virtual bool IsConfigEvent() const = 0;
63
64 int64_t timestamp_ms() const { return timestamp_us_ / 1000; }
65 int64_t timestamp_us() const { return timestamp_us_; }
66
67 protected:
68 explicit RtcEvent(int64_t timestamp_us) : timestamp_us_(timestamp_us) {}
69
70 const int64_t timestamp_us_;
71};
72
73} // namespace webrtc
74
75#endif // API_RTC_EVENT_LOG_RTC_EVENT_H_