• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 LOGGING_RTC_EVENT_LOG_ENCODER_RTC_EVENT_LOG_ENCODER_LEGACY_H_
12 #define LOGGING_RTC_EVENT_LOG_ENCODER_RTC_EVENT_LOG_ENCODER_LEGACY_H_
13 
14 #include <deque>
15 #include <memory>
16 #include <string>
17 
18 #include "logging/rtc_event_log/encoder/rtc_event_log_encoder.h"
19 #include "rtc_base/buffer.h"
20 
21 namespace webrtc {
22 
23 namespace rtclog {
24 class Event;  // Auto-generated from protobuf.
25 }  // namespace rtclog
26 
27 class RtcEventAudioNetworkAdaptation;
28 class RtcEventAudioPlayout;
29 class RtcEventAudioReceiveStreamConfig;
30 class RtcEventAudioSendStreamConfig;
31 class RtcEventBweUpdateDelayBased;
32 class RtcEventBweUpdateLossBased;
33 class RtcEventIceCandidatePairConfig;
34 class RtcEventIceCandidatePair;
35 class RtcEventLoggingStarted;
36 class RtcEventLoggingStopped;
37 class RtcEventProbeClusterCreated;
38 class RtcEventProbeResultFailure;
39 class RtcEventProbeResultSuccess;
40 class RtcEventRtcpPacketIncoming;
41 class RtcEventRtcpPacketOutgoing;
42 class RtcEventRtpPacketIncoming;
43 class RtcEventRtpPacketOutgoing;
44 class RtcEventVideoReceiveStreamConfig;
45 class RtcEventVideoSendStreamConfig;
46 class RtcEventAlrState;
47 class RtpPacket;
48 
49 class RtcEventLogEncoderLegacy final : public RtcEventLogEncoder {
50  public:
51   ~RtcEventLogEncoderLegacy() override = default;
52 
53   std::string EncodeLogStart(int64_t timestamp_us,
54                              int64_t utc_time_us) override;
55   std::string EncodeLogEnd(int64_t timestamp_us) override;
56 
57   std::string EncodeBatch(
58       std::deque<std::unique_ptr<RtcEvent>>::const_iterator begin,
59       std::deque<std::unique_ptr<RtcEvent>>::const_iterator end) override;
60 
61  private:
62   std::string Encode(const RtcEvent& event);
63   // Encoding entry-point for the various RtcEvent subclasses.
64   std::string EncodeAlrState(const RtcEventAlrState& event);
65   std::string EncodeAudioNetworkAdaptation(
66       const RtcEventAudioNetworkAdaptation& event);
67   std::string EncodeAudioPlayout(const RtcEventAudioPlayout& event);
68   std::string EncodeAudioReceiveStreamConfig(
69       const RtcEventAudioReceiveStreamConfig& event);
70   std::string EncodeAudioSendStreamConfig(
71       const RtcEventAudioSendStreamConfig& event);
72   std::string EncodeBweUpdateDelayBased(
73       const RtcEventBweUpdateDelayBased& event);
74   std::string EncodeBweUpdateLossBased(const RtcEventBweUpdateLossBased& event);
75   std::string EncodeIceCandidatePairConfig(
76       const RtcEventIceCandidatePairConfig& event);
77   std::string EncodeIceCandidatePairEvent(
78       const RtcEventIceCandidatePair& event);
79   std::string EncodeProbeClusterCreated(
80       const RtcEventProbeClusterCreated& event);
81   std::string EncodeProbeResultFailure(const RtcEventProbeResultFailure& event);
82   std::string EncodeProbeResultSuccess(const RtcEventProbeResultSuccess&);
83   std::string EncodeRtcpPacketIncoming(const RtcEventRtcpPacketIncoming& event);
84   std::string EncodeRtcpPacketOutgoing(const RtcEventRtcpPacketOutgoing& event);
85   std::string EncodeRtpPacketIncoming(const RtcEventRtpPacketIncoming& event);
86   std::string EncodeRtpPacketOutgoing(const RtcEventRtpPacketOutgoing& event);
87   std::string EncodeVideoReceiveStreamConfig(
88       const RtcEventVideoReceiveStreamConfig& event);
89   std::string EncodeVideoSendStreamConfig(
90       const RtcEventVideoSendStreamConfig& event);
91 
92   // RTCP/RTP are handled similarly for incoming/outgoing.
93   std::string EncodeRtcpPacket(int64_t timestamp_us,
94                                const rtc::Buffer& packet,
95                                bool is_incoming);
96   std::string EncodeRtpPacket(int64_t timestamp_us,
97                               const RtpPacket& header,
98                               size_t packet_length,
99                               int probe_cluster_id,
100                               bool is_incoming);
101 
102   std::string Serialize(rtclog::Event* event);
103 };
104 
105 }  // namespace webrtc
106 
107 #endif  // LOGGING_RTC_EVENT_LOG_ENCODER_RTC_EVENT_LOG_ENCODER_LEGACY_H_
108