aboutsummaryrefslogtreecommitdiff
path: root/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.h
blob: 3105dc1e68c6b938ea890c7d261b9f2766702bf7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
 *  Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#ifndef LOGGING_RTC_EVENT_LOG_ENCODER_RTC_EVENT_LOG_ENCODER_LEGACY_H_
#define LOGGING_RTC_EVENT_LOG_ENCODER_RTC_EVENT_LOG_ENCODER_LEGACY_H_

#include <deque>
#include <memory>
#include <string>

#include "logging/rtc_event_log/encoder/rtc_event_log_encoder.h"
#include "rtc_base/buffer.h"

namespace webrtc {

namespace rtclog {
class Event;  // Auto-generated from protobuf.
}  // namespace rtclog

class RtcEventAudioNetworkAdaptation;
class RtcEventAudioPlayout;
class RtcEventAudioReceiveStreamConfig;
class RtcEventAudioSendStreamConfig;
class RtcEventBweUpdateDelayBased;
class RtcEventBweUpdateLossBased;
class RtcEventIceCandidatePairConfig;
class RtcEventIceCandidatePair;
class RtcEventLoggingStarted;
class RtcEventLoggingStopped;
class RtcEventProbeClusterCreated;
class RtcEventProbeResultFailure;
class RtcEventProbeResultSuccess;
class RtcEventRtcpPacketIncoming;
class RtcEventRtcpPacketOutgoing;
class RtcEventRtpPacketIncoming;
class RtcEventRtpPacketOutgoing;
class RtcEventVideoReceiveStreamConfig;
class RtcEventVideoSendStreamConfig;
class RtcEventAlrState;
class RtpPacket;

class RtcEventLogEncoderLegacy final : public RtcEventLogEncoder {
 public:
  ~RtcEventLogEncoderLegacy() override = default;

  std::string EncodeLogStart(int64_t timestamp_us,
                             int64_t utc_time_us) override;
  std::string EncodeLogEnd(int64_t timestamp_us) override;

  std::string EncodeBatch(
      std::deque<std::unique_ptr<RtcEvent>>::const_iterator begin,
      std::deque<std::unique_ptr<RtcEvent>>::const_iterator end) override;

 private:
  std::string Encode(const RtcEvent& event);
  // Encoding entry-point for the various RtcEvent subclasses.
  std::string EncodeAlrState(const RtcEventAlrState& event);
  std::string EncodeAudioNetworkAdaptation(
      const RtcEventAudioNetworkAdaptation& event);
  std::string EncodeAudioPlayout(const RtcEventAudioPlayout& event);
  std::string EncodeAudioReceiveStreamConfig(
      const RtcEventAudioReceiveStreamConfig& event);
  std::string EncodeAudioSendStreamConfig(
      const RtcEventAudioSendStreamConfig& event);
  std::string EncodeBweUpdateDelayBased(
      const RtcEventBweUpdateDelayBased& event);
  std::string EncodeBweUpdateLossBased(const RtcEventBweUpdateLossBased& event);
  std::string EncodeIceCandidatePairConfig(
      const RtcEventIceCandidatePairConfig& event);
  std::string EncodeIceCandidatePairEvent(
      const RtcEventIceCandidatePair& event);
  std::string EncodeProbeClusterCreated(
      const RtcEventProbeClusterCreated& event);
  std::string EncodeProbeResultFailure(const RtcEventProbeResultFailure& event);
  std::string EncodeProbeResultSuccess(const RtcEventProbeResultSuccess&);
  std::string EncodeRtcpPacketIncoming(const RtcEventRtcpPacketIncoming& event);
  std::string EncodeRtcpPacketOutgoing(const RtcEventRtcpPacketOutgoing& event);
  std::string EncodeRtpPacketIncoming(const RtcEventRtpPacketIncoming& event);
  std::string EncodeRtpPacketOutgoing(const RtcEventRtpPacketOutgoing& event);
  std::string EncodeVideoReceiveStreamConfig(
      const RtcEventVideoReceiveStreamConfig& event);
  std::string EncodeVideoSendStreamConfig(
      const RtcEventVideoSendStreamConfig& event);

  // RTCP/RTP are handled similarly for incoming/outgoing.
  std::string EncodeRtcpPacket(int64_t timestamp_us,
                               const rtc::Buffer& packet,
                               bool is_incoming);
  std::string EncodeRtpPacket(int64_t timestamp_us,
                              const RtpPacket& header,
                              size_t packet_length,
                              int probe_cluster_id,
                              bool is_incoming);

  std::string Serialize(rtclog::Event* event);
};

}  // namespace webrtc

#endif  // LOGGING_RTC_EVENT_LOG_ENCODER_RTC_EVENT_LOG_ENCODER_LEGACY_H_