rtc_event.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  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. #ifndef API_RTC_EVENT_LOG_RTC_EVENT_H_
  11. #define API_RTC_EVENT_LOG_RTC_EVENT_H_
  12. #include <cstdint>
  13. namespace webrtc {
  14. // This class allows us to store unencoded RTC events. Subclasses of this class
  15. // store the actual information. This allows us to keep all unencoded events,
  16. // even when their type and associated information differ, in the same buffer.
  17. // Additionally, it prevents dependency leaking - a module that only logs
  18. // events of type RtcEvent_A doesn't need to know about anything associated
  19. // with events of type RtcEvent_B.
  20. class RtcEvent {
  21. public:
  22. // Subclasses of this class have to associate themselves with a unique value
  23. // of Type. This leaks the information of existing subclasses into the
  24. // superclass, but the *actual* information - rtclog::StreamConfig, etc. -
  25. // is kept separate.
  26. enum class Type {
  27. AlrStateEvent,
  28. RouteChangeEvent,
  29. RemoteEstimateEvent,
  30. AudioNetworkAdaptation,
  31. AudioPlayout,
  32. AudioReceiveStreamConfig,
  33. AudioSendStreamConfig,
  34. BweUpdateDelayBased,
  35. BweUpdateLossBased,
  36. DtlsTransportState,
  37. DtlsWritableState,
  38. IceCandidatePairConfig,
  39. IceCandidatePairEvent,
  40. ProbeClusterCreated,
  41. ProbeResultFailure,
  42. ProbeResultSuccess,
  43. RtcpPacketIncoming,
  44. RtcpPacketOutgoing,
  45. RtpPacketIncoming,
  46. RtpPacketOutgoing,
  47. VideoReceiveStreamConfig,
  48. VideoSendStreamConfig,
  49. GenericPacketSent,
  50. GenericPacketReceived,
  51. GenericAckReceived,
  52. FrameDecoded
  53. };
  54. RtcEvent();
  55. virtual ~RtcEvent() = default;
  56. virtual Type GetType() const = 0;
  57. virtual bool IsConfigEvent() const = 0;
  58. int64_t timestamp_ms() const { return timestamp_us_ / 1000; }
  59. int64_t timestamp_us() const { return timestamp_us_; }
  60. protected:
  61. explicit RtcEvent(int64_t timestamp_us) : timestamp_us_(timestamp_us) {}
  62. const int64_t timestamp_us_;
  63. };
  64. } // namespace webrtc
  65. #endif // API_RTC_EVENT_LOG_RTC_EVENT_H_