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