tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

rtc_event.h (2869B)


      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 
     11 #ifndef API_RTC_EVENT_LOG_RTC_EVENT_H_
     12 #define API_RTC_EVENT_LOG_RTC_EVENT_H_
     13 
     14 #include <cstdint>
     15 
     16 namespace 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.
     24 class 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 : uint32_t {
     31    AlrStateEvent,
     32    RouteChangeEvent,
     33    RemoteEstimateEvent,
     34    AudioNetworkAdaptation,
     35    AudioPlayout,
     36    AudioReceiveStreamConfig,
     37    AudioSendStreamConfig,
     38    BweUpdateDelayBased,
     39    BweUpdateLossBased,
     40    DtlsTransportState,
     41    DtlsWritableState,
     42    IceCandidatePairConfig,
     43    IceCandidatePairEvent,
     44    ProbeClusterCreated,
     45    ProbeResultFailure,
     46    ProbeResultSuccess,
     47    RtcpPacketIncoming,
     48    RtcpPacketOutgoing,
     49    RtpPacketIncoming,
     50    RtpPacketOutgoing,
     51    VideoReceiveStreamConfig,
     52    VideoSendStreamConfig,
     53    GenericPacketSent,
     54    GenericPacketReceived,
     55    FrameDecoded,
     56    NetEqSetMinimumDelay,
     57    BeginV3Log = 0x2501580,
     58    EndV3Log = 0x2501581,
     59    FakeEvent,  // For unit testing.
     60  };
     61 
     62  RtcEvent();
     63  RtcEvent(const RtcEvent&) = default;
     64  RtcEvent& operator=(const RtcEvent&) = delete;
     65  virtual ~RtcEvent() = default;
     66 
     67  virtual Type GetType() const = 0;
     68 
     69  virtual bool IsConfigEvent() const = 0;
     70 
     71  // Events are grouped by Type before being encoded.
     72  // Optionally, `GetGroupKey` can be overloaded to group the
     73  // events by a secondary key (in addition to the event type.)
     74  // This can, in some cases, improve compression efficiency
     75  // e.g. by grouping events by SSRC.
     76  virtual uint32_t GetGroupKey() const { return 0; }
     77 
     78  int64_t timestamp_ms() const { return timestamp_us_ / 1000; }
     79  int64_t timestamp_us() const { return timestamp_us_; }
     80 
     81 protected:
     82  explicit RtcEvent(int64_t timestamp_us) : timestamp_us_(timestamp_us) {}
     83 
     84 private:
     85  const int64_t timestamp_us_;
     86 };
     87 
     88 }  // namespace webrtc
     89 
     90 #endif  // API_RTC_EVENT_LOG_RTC_EVENT_H_