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