#include "logging/rtc_event_log/rtc_event_log_parser.h"
#include <stdint.h>
#include <string.h>
#include <algorithm>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "api/candidate.h"
#include "api/dtls_transport_interface.h"
#include "api/rtc_event_log/rtc_event.h"
#include "api/rtc_event_log/rtc_event_log.h"
#include "api/rtp_headers.h"
#include "api/rtp_parameters.h"
#include "api/transport/bandwidth_usage.h"
#include "api/units/data_rate.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "api/video/video_codec_type.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/encoder/var_int.h"
#include "logging/rtc_event_log/events/logged_rtp_rtcp.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_begin_log.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_end_log.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_log_parse_status.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_event_log.pb.h"
#include "logging/rtc_event_log/rtc_event_log2.pb.h"
#include "logging/rtc_event_log/rtc_event_processor.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/include/rtp_header_extension_map.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.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/fir.h"
#include "modules/rtp_rtcp/source/rtcp_packet/nack.h"
#include "modules/rtp_rtcp/source/rtcp_packet/pli.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/sender_report.h"
#include "modules/rtp_rtcp/source/rtp_dependency_descriptor_extension.h"
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
#include "rtc_base/checks.h"
#include "rtc_base/copy_on_write_buffer.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "rtc_base/numerics/sequence_number_unwrapper.h"
#include "rtc_base/protobuf_utils.h"
#include "rtc_base/system/file_wrapper.h"
ToSigned;
ToUnsigned;
namespace webrtc {
namespace {
constexpr size_t kMaxLogSize = …;
constexpr size_t kIpv4Overhead = …;
constexpr size_t kIpv6Overhead = …;
constexpr size_t kUdpOverhead = …;
constexpr size_t kSrtpOverhead = …;
constexpr size_t kStunOverhead = …;
constexpr uint16_t kDefaultOverhead = …;
constexpr char kIncompleteLogError[] = …;
struct MediaStreamInfo { … };
template <typename Iterable>
void AddRecvStreamInfos(std::map<uint32_t, MediaStreamInfo>* streams,
const Iterable configs,
LoggedMediaType media_type) { … }
template <typename Iterable>
void AddSendStreamInfos(std::map<uint32_t, MediaStreamInfo>* streams,
const Iterable configs,
LoggedMediaType media_type) { … }
struct OverheadChangeEvent { … };
std::vector<OverheadChangeEvent> GetOverheadChangingEvents(
const std::vector<InferredRouteChangeEvent>& route_changes,
PacketDirection direction) { … }
bool IdenticalRtcpContents(const std::vector<uint8_t>& last_rtcp,
absl::string_view new_rtcp) { … }
RtcpMode GetRuntimeRtcpMode(rtclog::VideoReceiveConfig::RtcpMode rtcp_mode) { … }
BandwidthUsage GetRuntimeDetectorState(
rtclog::DelayBasedBweUpdate::DetectorState detector_state) { … }
IceCandidatePairConfigType GetRuntimeIceCandidatePairConfigType(
rtclog::IceCandidatePairConfig::IceCandidatePairConfigType type) { … }
bool GetRuntimeIceCandidateType(
rtclog::IceCandidatePairConfig::IceCandidateType log_type,
IceCandidateType& parsed_type) { … }
IceCandidatePairProtocol GetRuntimeIceCandidatePairProtocol(
rtclog::IceCandidatePairConfig::Protocol protocol) { … }
IceCandidatePairAddressFamily GetRuntimeIceCandidatePairAddressFamily(
rtclog::IceCandidatePairConfig::AddressFamily address_family) { … }
IceCandidateNetworkType GetRuntimeIceCandidateNetworkType(
rtclog::IceCandidatePairConfig::NetworkType network_type) { … }
IceCandidatePairEventType GetRuntimeIceCandidatePairEventType(
rtclog::IceCandidatePairEvent::IceCandidatePairEventType type) { … }
VideoCodecType GetRuntimeCodecType(rtclog2::FrameDecodedEvents::Codec codec) { … }
ParsedRtcEventLog::ParseStatus GetHeaderExtensions(
std::vector<RtpExtension>* header_extensions,
const RepeatedPtrField<rtclog::RtpHeaderExtension>&
proto_header_extensions) { … }
template <typename ProtoType, typename LoggedType>
ParsedRtcEventLog::ParseStatus StoreRtpPackets(
const ProtoType& proto,
std::map<uint32_t, std::vector<LoggedType>>* rtp_packets_map) { … }
template <typename ProtoType, typename LoggedType>
ParsedRtcEventLog::ParseStatus StoreRtcpPackets(
const ProtoType& proto,
std::vector<LoggedType>* rtcp_packets,
bool remove_duplicates) { … }
ParsedRtcEventLog::ParseStatus StoreRtcpBlocks(
int64_t timestamp_us,
const uint8_t* packet_begin,
const uint8_t* packet_end,
std::vector<LoggedRtcpPacketSenderReport>* sr_list,
std::vector<LoggedRtcpPacketReceiverReport>* rr_list,
std::vector<LoggedRtcpPacketExtendedReports>* xr_list,
std::vector<LoggedRtcpPacketRemb>* remb_list,
std::vector<LoggedRtcpPacketNack>* nack_list,
std::vector<LoggedRtcpPacketFir>* fir_list,
std::vector<LoggedRtcpPacketPli>* pli_list,
std::vector<LoggedRtcpPacketBye>* bye_list,
std::vector<LoggedRtcpPacketTransportFeedback>* transport_feedback_list,
std::vector<LoggedRtcpPacketLossNotification>* loss_notification_list) { … }
}
BandwidthUsage GetRuntimeDetectorState(
rtclog2::DelayBasedBweUpdates::DetectorState detector_state) { … }
ProbeFailureReason GetRuntimeProbeFailureReason(
rtclog2::BweProbeResultFailure::FailureReason failure) { … }
DtlsTransportState GetRuntimeDtlsTransportState(
rtclog2::DtlsTransportStateEvent::DtlsTransportState state) { … }
IceCandidatePairConfigType GetRuntimeIceCandidatePairConfigType(
rtclog2::IceCandidatePairConfig::IceCandidatePairConfigType type) { … }
IceCandidateType GetRuntimeIceCandidateType(
rtclog2::IceCandidatePairConfig::IceCandidateType type) { … }
bool GetRuntimeIceCandidateType(
rtclog2::IceCandidatePairConfig::IceCandidateType log_type,
IceCandidateType& parsed_type) { … }
IceCandidatePairProtocol GetRuntimeIceCandidatePairProtocol(
rtclog2::IceCandidatePairConfig::Protocol protocol) { … }
IceCandidatePairAddressFamily GetRuntimeIceCandidatePairAddressFamily(
rtclog2::IceCandidatePairConfig::AddressFamily address_family) { … }
IceCandidateNetworkType GetRuntimeIceCandidateNetworkType(
rtclog2::IceCandidatePairConfig::NetworkType network_type) { … }
IceCandidatePairEventType GetRuntimeIceCandidatePairEventType(
rtclog2::IceCandidatePairEvent::IceCandidatePairEventType type) { … }
std::vector<RtpExtension> GetRuntimeRtpHeaderExtensionConfig(
const rtclog2::RtpHeaderExtensionConfig& proto_header_extensions) { … }
LoggedPacketInfo::LoggedPacketInfo(const LoggedRtpPacket& rtp,
LoggedMediaType media_type,
bool rtx,
Timestamp capture_time)
: … { … }
LoggedPacketInfo::LoggedPacketInfo(const LoggedPacketInfo&) = default;
LoggedPacketInfo::~LoggedPacketInfo() { … }
ParsedRtcEventLog::~ParsedRtcEventLog() = default;
ParsedRtcEventLog::LoggedRtpStreamIncoming::LoggedRtpStreamIncoming() = default;
ParsedRtcEventLog::LoggedRtpStreamIncoming::LoggedRtpStreamIncoming(
const LoggedRtpStreamIncoming& rhs) = default;
ParsedRtcEventLog::LoggedRtpStreamIncoming::~LoggedRtpStreamIncoming() =
default;
ParsedRtcEventLog::LoggedRtpStreamOutgoing::LoggedRtpStreamOutgoing() = default;
ParsedRtcEventLog::LoggedRtpStreamOutgoing::LoggedRtpStreamOutgoing(
const LoggedRtpStreamOutgoing& rhs) = default;
ParsedRtcEventLog::LoggedRtpStreamOutgoing::~LoggedRtpStreamOutgoing() =
default;
ParsedRtcEventLog::LoggedRtpStreamView::LoggedRtpStreamView(
uint32_t ssrc,
const std::vector<LoggedRtpPacketIncoming>& packets)
: … { … }
ParsedRtcEventLog::LoggedRtpStreamView::LoggedRtpStreamView(
uint32_t ssrc,
const std::vector<LoggedRtpPacketOutgoing>& packets)
: … { … }
ParsedRtcEventLog::LoggedRtpStreamView::LoggedRtpStreamView(
const LoggedRtpStreamView&) = default;
webrtc::RtpHeaderExtensionMap
ParsedRtcEventLog::GetDefaultHeaderExtensionMap() { … }
ParsedRtcEventLog::ParsedRtcEventLog(
UnconfiguredHeaderExtensions parse_unconfigured_header_extensions,
bool allow_incomplete_logs)
: … { … }
void ParsedRtcEventLog::Clear() { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::ParseFile(
absl::string_view filename) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::ParseString(
absl::string_view s) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::ParseStream(
absl::string_view s) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::ParseStreamInternal(
absl::string_view s) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::ParseStreamInternalV3(
absl::string_view s) { … }
template <typename T>
void ParsedRtcEventLog::StoreFirstAndLastTimestamp(const std::vector<T>& v) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreParsedLegacyEvent(
const rtclog::Event& event) { … }
const RtpHeaderExtensionMap* ParsedRtcEventLog::GetRtpHeaderExtensionMap(
bool incoming,
uint32_t ssrc) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::GetRtcpPacket(
const rtclog::Event& event,
PacketDirection* incoming,
std::vector<uint8_t>* packet) const { … }
ParsedRtcEventLog::ParseStatusOr<rtclog::StreamConfig>
ParsedRtcEventLog::GetVideoReceiveConfig(const rtclog::Event& event) const { … }
ParsedRtcEventLog::ParseStatusOr<rtclog::StreamConfig>
ParsedRtcEventLog::GetVideoSendConfig(const rtclog::Event& event) const { … }
ParsedRtcEventLog::ParseStatusOr<rtclog::StreamConfig>
ParsedRtcEventLog::GetAudioReceiveConfig(const rtclog::Event& event) const { … }
ParsedRtcEventLog::ParseStatusOr<rtclog::StreamConfig>
ParsedRtcEventLog::GetAudioSendConfig(const rtclog::Event& event) const { … }
ParsedRtcEventLog::ParseStatusOr<LoggedAudioPlayoutEvent>
ParsedRtcEventLog::GetAudioPlayout(const rtclog::Event& event) const { … }
ParsedRtcEventLog::ParseStatusOr<LoggedBweLossBasedUpdate>
ParsedRtcEventLog::GetLossBasedBweUpdate(const rtclog::Event& event) const { … }
ParsedRtcEventLog::ParseStatusOr<LoggedBweDelayBasedUpdate>
ParsedRtcEventLog::GetDelayBasedBweUpdate(const rtclog::Event& event) const { … }
ParsedRtcEventLog::ParseStatusOr<LoggedAudioNetworkAdaptationEvent>
ParsedRtcEventLog::GetAudioNetworkAdaptation(const rtclog::Event& event) const { … }
ParsedRtcEventLog::ParseStatusOr<LoggedBweProbeClusterCreatedEvent>
ParsedRtcEventLog::GetBweProbeClusterCreated(const rtclog::Event& event) const { … }
ParsedRtcEventLog::ParseStatusOr<LoggedBweProbeFailureEvent>
ParsedRtcEventLog::GetBweProbeFailure(const rtclog::Event& event) const { … }
ParsedRtcEventLog::ParseStatusOr<LoggedBweProbeSuccessEvent>
ParsedRtcEventLog::GetBweProbeSuccess(const rtclog::Event& event) const { … }
ParsedRtcEventLog::ParseStatusOr<LoggedAlrStateEvent>
ParsedRtcEventLog::GetAlrState(const rtclog::Event& event) const { … }
ParsedRtcEventLog::ParseStatusOr<LoggedIceCandidatePairConfig>
ParsedRtcEventLog::GetIceCandidatePairConfig(
const rtclog::Event& rtc_event) const { … }
ParsedRtcEventLog::ParseStatusOr<LoggedIceCandidatePairEvent>
ParsedRtcEventLog::GetIceCandidatePairEvent(
const rtclog::Event& rtc_event) const { … }
ParsedRtcEventLog::ParseStatusOr<LoggedRemoteEstimateEvent>
ParsedRtcEventLog::GetRemoteEstimateEvent(const rtclog::Event& event) const { … }
ParsedRtcEventLog::MediaType ParsedRtcEventLog::GetMediaType(
uint32_t ssrc,
PacketDirection direction) const { … }
std::vector<InferredRouteChangeEvent> ParsedRtcEventLog::GetRouteChanges()
const { … }
std::vector<LoggedPacketInfo> ParsedRtcEventLog::GetPacketInfos(
PacketDirection direction) const { … }
std::vector<LoggedIceCandidatePairConfig> ParsedRtcEventLog::GetIceCandidates()
const { … }
std::vector<LoggedIceEvent> ParsedRtcEventLog::GetIceEvents() const { … }
const std::vector<MatchedSendArrivalTimes> GetNetworkTrace(
const ParsedRtcEventLog& parsed_log) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreParsedNewFormatEvent(
const rtclog2::EventStream& stream) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreAlrStateEvent(
const rtclog2::AlrState& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreRouteChangeEvent(
const rtclog2::RouteChange& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreRemoteEstimateEvent(
const rtclog2::RemoteEstimates& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreAudioPlayoutEvent(
const rtclog2::AudioPlayoutEvents& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreNetEqSetMinimumDelay(
const rtclog2::NetEqSetMinimumDelay& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreIncomingRtpPackets(
const rtclog2::IncomingRtpPackets& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreOutgoingRtpPackets(
const rtclog2::OutgoingRtpPackets& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreIncomingRtcpPackets(
const rtclog2::IncomingRtcpPackets& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreOutgoingRtcpPackets(
const rtclog2::OutgoingRtcpPackets& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreStartEvent(
const rtclog2::BeginLogEvent& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreStopEvent(
const rtclog2::EndLogEvent& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreBweLossBasedUpdate(
const rtclog2::LossBasedBweUpdates& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreBweDelayBasedUpdate(
const rtclog2::DelayBasedBweUpdates& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreBweProbeClusterCreated(
const rtclog2::BweProbeCluster& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreBweProbeSuccessEvent(
const rtclog2::BweProbeResultSuccess& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreBweProbeFailureEvent(
const rtclog2::BweProbeResultFailure& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreFrameDecodedEvents(
const rtclog2::FrameDecodedEvents& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreGenericAckReceivedEvent(
const rtclog2::GenericAckReceived& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreGenericPacketSentEvent(
const rtclog2::GenericPacketSent& proto) { … }
ParsedRtcEventLog::ParseStatus
ParsedRtcEventLog::StoreGenericPacketReceivedEvent(
const rtclog2::GenericPacketReceived& proto) { … }
ParsedRtcEventLog::ParseStatus
ParsedRtcEventLog::StoreAudioNetworkAdaptationEvent(
const rtclog2::AudioNetworkAdaptations& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreDtlsTransportState(
const rtclog2::DtlsTransportStateEvent& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreDtlsWritableState(
const rtclog2::DtlsWritableState& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreIceCandidatePairConfig(
const rtclog2::IceCandidatePairConfig& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreIceCandidateEvent(
const rtclog2::IceCandidatePairEvent& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreVideoRecvConfig(
const rtclog2::VideoRecvStreamConfig& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreVideoSendConfig(
const rtclog2::VideoSendStreamConfig& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreAudioRecvConfig(
const rtclog2::AudioRecvStreamConfig& proto) { … }
ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreAudioSendConfig(
const rtclog2::AudioSendStreamConfig& proto) { … }
}