Elad Alon | 1d87b0e | 2017-10-03 13:01:03 | [diff] [blame] | 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 | |
Bjorn Terelius | 5cab6f1 | 2017-12-14 18:06:41 | [diff] [blame] | 14 | #include <deque> |
Elad Alon | 1d87b0e | 2017-10-03 13:01:03 | [diff] [blame] | 15 | #include <memory> |
| 16 | #include <string> |
| 17 | |
Danil Chapovalov | 6e661f4 | 2021-05-10 15:19:50 | [diff] [blame] | 18 | #include "api/array_view.h" |
Elad Alon | 1d87b0e | 2017-10-03 13:01:03 | [diff] [blame] | 19 | #include "logging/rtc_event_log/encoder/rtc_event_log_encoder.h" |
| 20 | #include "rtc_base/buffer.h" |
| 21 | |
Elad Alon | 1d87b0e | 2017-10-03 13:01:03 | [diff] [blame] | 22 | namespace webrtc { |
| 23 | |
| 24 | namespace rtclog { |
| 25 | class Event; // Auto-generated from protobuf. |
| 26 | } // namespace rtclog |
| 27 | |
Björn Terelius | 12053ec | 2022-08-10 13:24:34 | [diff] [blame] | 28 | class RtcEventAlrState; |
Elad Alon | 1d87b0e | 2017-10-03 13:01:03 | [diff] [blame] | 29 | class RtcEventAudioNetworkAdaptation; |
| 30 | class RtcEventAudioPlayout; |
| 31 | class RtcEventAudioReceiveStreamConfig; |
| 32 | class RtcEventAudioSendStreamConfig; |
| 33 | class RtcEventBweUpdateDelayBased; |
| 34 | class RtcEventBweUpdateLossBased; |
Qingsi Wang | 8eca1ff | 2018-02-02 19:49:44 | [diff] [blame] | 35 | class RtcEventIceCandidatePairConfig; |
| 36 | class RtcEventIceCandidatePair; |
Elad Alon | 1d87b0e | 2017-10-03 13:01:03 | [diff] [blame] | 37 | class RtcEventLoggingStarted; |
| 38 | class RtcEventLoggingStopped; |
| 39 | class RtcEventProbeClusterCreated; |
| 40 | class RtcEventProbeResultFailure; |
| 41 | class RtcEventProbeResultSuccess; |
Björn Terelius | 12053ec | 2022-08-10 13:24:34 | [diff] [blame] | 42 | class RtcEventRemoteEstimate; |
Elad Alon | 1d87b0e | 2017-10-03 13:01:03 | [diff] [blame] | 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 | |
Bjorn Terelius | e78b465 | 2018-11-13 10:19:18 | [diff] [blame] | 55 | std::string EncodeLogStart(int64_t timestamp_us, |
| 56 | int64_t utc_time_us) override; |
Bjorn Terelius | 8e126fc | 2017-12-18 13:21:53 | [diff] [blame] | 57 | std::string EncodeLogEnd(int64_t timestamp_us) override; |
| 58 | |
Bjorn Terelius | 5cab6f1 | 2017-12-14 18:06:41 | [diff] [blame] | 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 | |
Elad Alon | 1d87b0e | 2017-10-03 13:01:03 | [diff] [blame] | 63 | private: |
Bjorn Terelius | 07b35bc | 2018-01-19 14:39:39 | [diff] [blame] | 64 | std::string Encode(const RtcEvent& event); |
Elad Alon | 1d87b0e | 2017-10-03 13:01:03 | [diff] [blame] | 65 | // Encoding entry-point for the various RtcEvent subclasses. |
Ilya Nikolaevskiy | a4259f6 | 2017-12-05 12:19:45 | [diff] [blame] | 66 | std::string EncodeAlrState(const RtcEventAlrState& event); |
Elad Alon | 1d87b0e | 2017-10-03 13:01:03 | [diff] [blame] | 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); |
Qingsi Wang | 8eca1ff | 2018-02-02 19:49:44 | [diff] [blame] | 77 | std::string EncodeIceCandidatePairConfig( |
| 78 | const RtcEventIceCandidatePairConfig& event); |
| 79 | std::string EncodeIceCandidatePairEvent( |
| 80 | const RtcEventIceCandidatePair& event); |
Elad Alon | 1d87b0e | 2017-10-03 13:01:03 | [diff] [blame] | 81 | std::string EncodeProbeClusterCreated( |
| 82 | const RtcEventProbeClusterCreated& event); |
| 83 | std::string EncodeProbeResultFailure(const RtcEventProbeResultFailure& event); |
| 84 | std::string EncodeProbeResultSuccess(const RtcEventProbeResultSuccess&); |
Björn Terelius | 12053ec | 2022-08-10 13:24:34 | [diff] [blame] | 85 | std::string EncodeRemoteEstimate(const RtcEventRemoteEstimate& event); |
Elad Alon | 1d87b0e | 2017-10-03 13:01:03 | [diff] [blame] | 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, |
Danil Chapovalov | 6e661f4 | 2021-05-10 15:19:50 | [diff] [blame] | 100 | rtc::ArrayView<const uint8_t> header, |
Elad Alon | 1d87b0e | 2017-10-03 13:01:03 | [diff] [blame] | 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 | |
Elad Alon | 1d87b0e | 2017-10-03 13:01:03 | [diff] [blame] | 110 | #endif // LOGGING_RTC_EVENT_LOG_ENCODER_RTC_EVENT_LOG_ENCODER_LEGACY_H_ |