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_NEW_FORMAT_H_ 12 #define LOGGING_RTC_EVENT_LOG_ENCODER_RTC_EVENT_LOG_ENCODER_NEW_FORMAT_H_ 13 14 #include <deque> 15 #include <map> 16 #include <memory> 17 #include <string> 18 #include <vector> 19 20 #include "api/array_view.h" 21 #include "logging/rtc_event_log/encoder/rtc_event_log_encoder.h" 22 23 namespace webrtc { 24 25 namespace rtclog2 { 26 class EventStream; // Auto-generated from protobuf. 27 } // namespace rtclog2 28 29 class RtcEventAlrState; 30 class RtcEventRouteChange; 31 class RtcEventRemoteEstimate; 32 class RtcEventAudioNetworkAdaptation; 33 class RtcEventAudioPlayout; 34 class RtcEventAudioReceiveStreamConfig; 35 class RtcEventAudioSendStreamConfig; 36 class RtcEventBweUpdateDelayBased; 37 class RtcEventBweUpdateLossBased; 38 class RtcEventDtlsTransportState; 39 class RtcEventDtlsWritableState; 40 class RtcEventLoggingStarted; 41 class RtcEventLoggingStopped; 42 class RtcEventProbeClusterCreated; 43 class RtcEventProbeResultFailure; 44 class RtcEventProbeResultSuccess; 45 class RtcEventRtcpPacketIncoming; 46 class RtcEventRtcpPacketOutgoing; 47 class RtcEventRtpPacketIncoming; 48 class RtcEventRtpPacketOutgoing; 49 class RtcEventVideoReceiveStreamConfig; 50 class RtcEventVideoSendStreamConfig; 51 class RtcEventIceCandidatePairConfig; 52 class RtcEventIceCandidatePair; 53 class RtpPacket; 54 class RtcEventGenericAckReceived; 55 class RtcEventGenericPacketReceived; 56 class RtcEventGenericPacketSent; 57 58 class RtcEventLogEncoderNewFormat final : public RtcEventLogEncoder { 59 public: 60 ~RtcEventLogEncoderNewFormat() override = default; 61 62 std::string EncodeBatch( 63 std::deque<std::unique_ptr<RtcEvent>>::const_iterator begin, 64 std::deque<std::unique_ptr<RtcEvent>>::const_iterator end) override; 65 66 std::string EncodeLogStart(int64_t timestamp_us, 67 int64_t utc_time_us) override; 68 std::string EncodeLogEnd(int64_t timestamp_us) override; 69 70 private: 71 // Encoding entry-point for the various RtcEvent subclasses. 72 void EncodeAlrState(rtc::ArrayView<const RtcEventAlrState*> batch, 73 rtclog2::EventStream* event_stream); 74 void EncodeAudioNetworkAdaptation( 75 rtc::ArrayView<const RtcEventAudioNetworkAdaptation*> batch, 76 rtclog2::EventStream* event_stream); 77 void EncodeAudioPlayout(rtc::ArrayView<const RtcEventAudioPlayout*> batch, 78 rtclog2::EventStream* event_stream); 79 void EncodeAudioRecvStreamConfig( 80 rtc::ArrayView<const RtcEventAudioReceiveStreamConfig*> batch, 81 rtclog2::EventStream* event_stream); 82 void EncodeAudioSendStreamConfig( 83 rtc::ArrayView<const RtcEventAudioSendStreamConfig*> batch, 84 rtclog2::EventStream* event_stream); 85 void EncodeBweUpdateDelayBased( 86 rtc::ArrayView<const RtcEventBweUpdateDelayBased*> batch, 87 rtclog2::EventStream* event_stream); 88 void EncodeBweUpdateLossBased( 89 rtc::ArrayView<const RtcEventBweUpdateLossBased*> batch, 90 rtclog2::EventStream* event_stream); 91 void EncodeDtlsTransportState( 92 rtc::ArrayView<const RtcEventDtlsTransportState*> batch, 93 rtclog2::EventStream* event_stream); 94 void EncodeDtlsWritableState( 95 rtc::ArrayView<const RtcEventDtlsWritableState*> batch, 96 rtclog2::EventStream* event_stream); 97 void EncodeGenericAcksReceived( 98 rtc::ArrayView<const RtcEventGenericAckReceived*> batch, 99 rtclog2::EventStream* event_stream); 100 void EncodeGenericPacketsReceived( 101 rtc::ArrayView<const RtcEventGenericPacketReceived*> batch, 102 rtclog2::EventStream* event_stream); 103 void EncodeGenericPacketsSent( 104 rtc::ArrayView<const RtcEventGenericPacketSent*> batch, 105 rtclog2::EventStream* event_stream); 106 void EncodeIceCandidatePairConfig( 107 rtc::ArrayView<const RtcEventIceCandidatePairConfig*> batch, 108 rtclog2::EventStream* event_stream); 109 void EncodeIceCandidatePairEvent( 110 rtc::ArrayView<const RtcEventIceCandidatePair*> batch, 111 rtclog2::EventStream* event_stream); 112 void EncodeLoggingStarted(rtc::ArrayView<const RtcEventLoggingStarted*> batch, 113 rtclog2::EventStream* event_stream); 114 void EncodeLoggingStopped(rtc::ArrayView<const RtcEventLoggingStopped*> batch, 115 rtclog2::EventStream* event_stream); 116 void EncodeProbeClusterCreated( 117 rtc::ArrayView<const RtcEventProbeClusterCreated*> batch, 118 rtclog2::EventStream* event_stream); 119 void EncodeProbeResultFailure( 120 rtc::ArrayView<const RtcEventProbeResultFailure*> batch, 121 rtclog2::EventStream* event_stream); 122 void EncodeProbeResultSuccess( 123 rtc::ArrayView<const RtcEventProbeResultSuccess*> batch, 124 rtclog2::EventStream* event_stream); 125 void EncodeRouteChange(rtc::ArrayView<const RtcEventRouteChange*> batch, 126 rtclog2::EventStream* event_stream); 127 void EncodeRemoteEstimate(rtc::ArrayView<const RtcEventRemoteEstimate*> batch, 128 rtclog2::EventStream* event_stream); 129 void EncodeRtcpPacketIncoming( 130 rtc::ArrayView<const RtcEventRtcpPacketIncoming*> batch, 131 rtclog2::EventStream* event_stream); 132 void EncodeRtcpPacketOutgoing( 133 rtc::ArrayView<const RtcEventRtcpPacketOutgoing*> batch, 134 rtclog2::EventStream* event_stream); 135 void EncodeRtpPacketIncoming( 136 const std::map<uint32_t, std::vector<const RtcEventRtpPacketIncoming*>>& 137 batch, 138 rtclog2::EventStream* event_stream); 139 void EncodeRtpPacketOutgoing( 140 const std::map<uint32_t, std::vector<const RtcEventRtpPacketOutgoing*>>& 141 batch, 142 rtclog2::EventStream* event_stream); 143 void EncodeVideoRecvStreamConfig( 144 rtc::ArrayView<const RtcEventVideoReceiveStreamConfig*> batch, 145 rtclog2::EventStream* event_stream); 146 void EncodeVideoSendStreamConfig( 147 rtc::ArrayView<const RtcEventVideoSendStreamConfig*> batch, 148 rtclog2::EventStream* event_stream); 149 }; 150 151 } // namespace webrtc 152 153 #endif // LOGGING_RTC_EVENT_LOG_ENCODER_RTC_EVENT_LOG_ENCODER_NEW_FORMAT_H_ 154