#include "logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.h"
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <deque>
#include <map>
#include <memory>
#include <string>
#include <type_traits>
#include <vector>
#include "absl/types/optional.h"
#include "api/array_view.h"
#include "api/candidate.h"
#include "api/dtls_transport_interface.h"
#include "api/field_trials_view.h"
#include "api/rtc_event_log/rtc_event.h"
#include "api/rtp_headers.h"
#include "api/rtp_parameters.h"
#include "api/transport/bandwidth_usage.h"
#include "api/video/video_codec_type.h"
#include "api/video/video_rotation.h"
#include "logging/rtc_event_log/dependency_descriptor_encoder_decoder.h"
#include "logging/rtc_event_log/encoder/blob_encoding.h"
#include "logging/rtc_event_log/encoder/delta_encoding.h"
#include "logging/rtc_event_log/encoder/rtc_event_log_encoder_common.h"
#include "logging/rtc_event_log/events/rtc_event_alr_state.h"
#include "logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h"
#include "logging/rtc_event_log/events/rtc_event_audio_playout.h"
#include "logging/rtc_event_log/events/rtc_event_audio_receive_stream_config.h"
#include "logging/rtc_event_log/events/rtc_event_audio_send_stream_config.h"
#include "logging/rtc_event_log/events/rtc_event_bwe_update_delay_based.h"
#include "logging/rtc_event_log/events/rtc_event_bwe_update_loss_based.h"
#include "logging/rtc_event_log/events/rtc_event_dtls_transport_state.h"
#include "logging/rtc_event_log/events/rtc_event_dtls_writable_state.h"
#include "logging/rtc_event_log/events/rtc_event_frame_decoded.h"
#include "logging/rtc_event_log/events/rtc_event_generic_ack_received.h"
#include "logging/rtc_event_log/events/rtc_event_generic_packet_received.h"
#include "logging/rtc_event_log/events/rtc_event_generic_packet_sent.h"
#include "logging/rtc_event_log/events/rtc_event_ice_candidate_pair.h"
#include "logging/rtc_event_log/events/rtc_event_ice_candidate_pair_config.h"
#include "logging/rtc_event_log/events/rtc_event_neteq_set_minimum_delay.h"
#include "logging/rtc_event_log/events/rtc_event_probe_cluster_created.h"
#include "logging/rtc_event_log/events/rtc_event_probe_result_failure.h"
#include "logging/rtc_event_log/events/rtc_event_probe_result_success.h"
#include "logging/rtc_event_log/events/rtc_event_remote_estimate.h"
#include "logging/rtc_event_log/events/rtc_event_route_change.h"
#include "logging/rtc_event_log/events/rtc_event_rtcp_packet_incoming.h"
#include "logging/rtc_event_log/events/rtc_event_rtcp_packet_outgoing.h"
#include "logging/rtc_event_log/events/rtc_event_rtp_packet_incoming.h"
#include "logging/rtc_event_log/events/rtc_event_rtp_packet_outgoing.h"
#include "logging/rtc_event_log/events/rtc_event_video_receive_stream_config.h"
#include "logging/rtc_event_log/events/rtc_event_video_send_stream_config.h"
#include "logging/rtc_event_log/rtc_stream_config.h"
#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h"
#include "modules/rtp_rtcp/include/rtp_cvo.h"
#include "modules/rtp_rtcp/source/rtcp_packet/app.h"
#include "modules/rtp_rtcp/source/rtcp_packet/bye.h"
#include "modules/rtp_rtcp/source/rtcp_packet/common_header.h"
#include "modules/rtp_rtcp/source/rtcp_packet/extended_reports.h"
#include "modules/rtp_rtcp/source/rtcp_packet/psfb.h"
#include "modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
#include "modules/rtp_rtcp/source/rtcp_packet/rtpfb.h"
#include "modules/rtp_rtcp/source/rtcp_packet/sdes.h"
#include "modules/rtp_rtcp/source/rtcp_packet/sender_report.h"
#include "modules/rtp_rtcp/source/rtp_dependency_descriptor_extension.h"
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
#include "rtc_base/buffer.h"
#include "rtc_base/checks.h"
#ifdef WEBRTC_ANDROID_PLATFORM_BUILD
#include "external/webrtc/webrtc/logging/rtc_event_log/rtc_event_log2.pb.h"
#else
#include "logging/rtc_event_log/rtc_event_log2.pb.h"
#endif
ToUnsigned;
namespace webrtc {
namespace {
rtclog2::DelayBasedBweUpdates::DetectorState ConvertToProtoFormat(
BandwidthUsage state) { … }
rtclog2::FrameDecodedEvents::Codec ConvertToProtoFormat(VideoCodecType codec) { … }
rtclog2::BweProbeResultFailure::FailureReason ConvertToProtoFormat(
ProbeFailureReason failure_reason) { … }
bool ConvertToProtoFormat(const std::vector<RtpExtension>& extensions,
rtclog2::RtpHeaderExtensionConfig* proto_config) { … }
rtclog2::DtlsTransportStateEvent::DtlsTransportState ConvertToProtoFormat(
webrtc::DtlsTransportState state) { … }
rtclog2::IceCandidatePairConfig::IceCandidatePairConfigType
ConvertToProtoFormat(IceCandidatePairConfigType type) { … }
rtclog2::IceCandidatePairConfig::IceCandidateType ConvertToProtoFormat(
IceCandidateType type) { … }
rtclog2::IceCandidatePairConfig::Protocol ConvertToProtoFormat(
IceCandidatePairProtocol protocol) { … }
rtclog2::IceCandidatePairConfig::AddressFamily ConvertToProtoFormat(
IceCandidatePairAddressFamily address_family) { … }
rtclog2::IceCandidatePairConfig::NetworkType ConvertToProtoFormat(
IceCandidateNetworkType network_type) { … }
rtclog2::IceCandidatePairEvent::IceCandidatePairEventType ConvertToProtoFormat(
IceCandidatePairEventType type) { … }
size_t RemoveNonAllowlistedRtcpBlocks(const rtc::Buffer& packet,
uint8_t* buffer) { … }
template <typename EventType, typename ProtoType>
void EncodeRtcpPacket(rtc::ArrayView<const EventType*> batch,
ProtoType* proto_batch) { … }
}
template <typename Batch, typename ProtoType>
void RtcEventLogEncoderNewFormat::EncodeRtpPacket(const Batch& batch,
ProtoType* proto_batch) { … }
RtcEventLogEncoderNewFormat::RtcEventLogEncoderNewFormat(
const FieldTrialsView& field_trials)
: … { … }
std::string RtcEventLogEncoderNewFormat::EncodeLogStart(int64_t timestamp_us,
int64_t utc_time_us) { … }
std::string RtcEventLogEncoderNewFormat::EncodeLogEnd(int64_t timestamp_us) { … }
std::string RtcEventLogEncoderNewFormat::EncodeBatch(
std::deque<std::unique_ptr<RtcEvent>>::const_iterator begin,
std::deque<std::unique_ptr<RtcEvent>>::const_iterator end) { … }
void RtcEventLogEncoderNewFormat::EncodeAlrState(
rtc::ArrayView<const RtcEventAlrState*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeAudioNetworkAdaptation(
rtc::ArrayView<const RtcEventAudioNetworkAdaptation*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeAudioPlayout(
rtc::ArrayView<const RtcEventAudioPlayout*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeNetEqSetMinimumDelay(
rtc::ArrayView<const RtcEventNetEqSetMinimumDelay*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeAudioRecvStreamConfig(
rtc::ArrayView<const RtcEventAudioReceiveStreamConfig*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeAudioSendStreamConfig(
rtc::ArrayView<const RtcEventAudioSendStreamConfig*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeBweUpdateDelayBased(
rtc::ArrayView<const RtcEventBweUpdateDelayBased*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeBweUpdateLossBased(
rtc::ArrayView<const RtcEventBweUpdateLossBased*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeDtlsTransportState(
rtc::ArrayView<const RtcEventDtlsTransportState*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeDtlsWritableState(
rtc::ArrayView<const RtcEventDtlsWritableState*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeProbeClusterCreated(
rtc::ArrayView<const RtcEventProbeClusterCreated*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeProbeResultFailure(
rtc::ArrayView<const RtcEventProbeResultFailure*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeProbeResultSuccess(
rtc::ArrayView<const RtcEventProbeResultSuccess*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeRouteChange(
rtc::ArrayView<const RtcEventRouteChange*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeRemoteEstimate(
rtc::ArrayView<const RtcEventRemoteEstimate*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeRtcpPacketIncoming(
rtc::ArrayView<const RtcEventRtcpPacketIncoming*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeRtcpPacketOutgoing(
rtc::ArrayView<const RtcEventRtcpPacketOutgoing*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeRtpPacketIncoming(
const std::map<uint32_t, std::vector<const RtcEventRtpPacketIncoming*>>&
batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeFramesDecoded(
rtc::ArrayView<const RtcEventFrameDecoded* const> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeGenericPacketsSent(
rtc::ArrayView<const RtcEventGenericPacketSent*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeGenericPacketsReceived(
rtc::ArrayView<const RtcEventGenericPacketReceived*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeGenericAcksReceived(
rtc::ArrayView<const RtcEventGenericAckReceived*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeRtpPacketOutgoing(
const std::map<uint32_t, std::vector<const RtcEventRtpPacketOutgoing*>>&
batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeVideoRecvStreamConfig(
rtc::ArrayView<const RtcEventVideoReceiveStreamConfig*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeVideoSendStreamConfig(
rtc::ArrayView<const RtcEventVideoSendStreamConfig*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeIceCandidatePairConfig(
rtc::ArrayView<const RtcEventIceCandidatePairConfig*> batch,
rtclog2::EventStream* event_stream) { … }
void RtcEventLogEncoderNewFormat::EncodeIceCandidatePairEvent(
rtc::ArrayView<const RtcEventIceCandidatePair*> batch,
rtclog2::EventStream* event_stream) { … }
}