diff --git a/webrtc/tools/event_log_visualizer/analyzer.cc b/webrtc/tools/event_log_visualizer/analyzer.cc index cb8455c5fc..1f7973e376 100644 --- a/webrtc/tools/event_log_visualizer/analyzer.cc +++ b/webrtc/tools/event_log_visualizer/analyzer.cc @@ -100,23 +100,6 @@ constexpr float kTopMargin = 0.05f; } // namespace -bool EventLogAnalyzer::StreamId::operator<(const StreamId& other) const { - if (ssrc_ < other.ssrc_) { - return true; - } - if (ssrc_ == other.ssrc_) { - if (direction_ < other.direction_) { - return true; - } - } - return false; -} - -bool EventLogAnalyzer::StreamId::operator==(const StreamId& other) const { - return ssrc_ == other.ssrc_ && direction_ == other.direction_; -} - - EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log) : parsed_log_(log), window_duration_(250000), step_(10000) { uint64_t first_timestamp = std::numeric_limits::max(); @@ -151,10 +134,13 @@ EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log) StreamId stream(config.rtp.remote_ssrc, kIncomingPacket); RegisterHeaderExtensions(config.rtp.extensions, &extension_maps[stream]); + video_ssrcs_.insert(stream); for (auto kv : config.rtp.rtx) { StreamId rtx_stream(kv.second.ssrc, kIncomingPacket); RegisterHeaderExtensions(config.rtp.extensions, &extension_maps[rtx_stream]); + video_ssrcs_.insert(rtx_stream); + rtx_ssrcs_.insert(rtx_stream); } break; } @@ -165,11 +151,14 @@ EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log) StreamId stream(ssrc, kOutgoingPacket); RegisterHeaderExtensions(config.rtp.extensions, &extension_maps[stream]); + video_ssrcs_.insert(stream); } for (auto ssrc : config.rtp.rtx.ssrcs) { - StreamId stream(ssrc, kOutgoingPacket); + StreamId rtx_stream(ssrc, kOutgoingPacket); RegisterHeaderExtensions(config.rtp.extensions, - &extension_maps[stream]); + &extension_maps[rtx_stream]); + video_ssrcs_.insert(rtx_stream); + rtx_ssrcs_.insert(rtx_stream); } break; } @@ -303,6 +292,18 @@ class BitrateObserver : public CongestionController::Observer, bool bitrate_updated_; }; +bool EventLogAnalyzer::IsRtxSsrc(StreamId stream_id) { + return rtx_ssrcs_.count(stream_id) == 1; +} + +bool EventLogAnalyzer::IsVideoSsrc(StreamId stream_id) { + return video_ssrcs_.count(stream_id) == 1; +} + +bool EventLogAnalyzer::IsAudioSsrc(StreamId stream_id) { + return audio_ssrcs_.count(stream_id) == 1; +} + void EventLogAnalyzer::CreatePacketGraph(PacketDirection desired_direction, Plot* plot) { std::map time_series; diff --git a/webrtc/tools/event_log_visualizer/analyzer.h b/webrtc/tools/event_log_visualizer/analyzer.h index dc56c5fd16..ce2179f5fb 100644 --- a/webrtc/tools/event_log_visualizer/analyzer.h +++ b/webrtc/tools/event_log_visualizer/analyzer.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "webrtc/call/rtc_event_log_parser.h" @@ -56,8 +57,14 @@ class EventLogAnalyzer { public: StreamId(uint32_t ssrc, webrtc::PacketDirection direction) : ssrc_(ssrc), direction_(direction) {} - bool operator<(const StreamId& other) const; - bool operator==(const StreamId& other) const; + bool operator<(const StreamId& other) const { + return std::tie(ssrc_, direction_) < + std::tie(other.ssrc_, other.direction_); + } + bool operator==(const StreamId& other) const { + return std::tie(ssrc_, direction_) == + std::tie(other.ssrc_, other.direction_); + } uint32_t GetSsrc() const { return ssrc_; } webrtc::PacketDirection GetDirection() const { return direction_; } @@ -93,15 +100,30 @@ class EventLogAnalyzer { int32_t expected_packets; }; + bool IsRtxSsrc(StreamId stream_id); + + bool IsVideoSsrc(StreamId stream_id); + + bool IsAudioSsrc(StreamId stream_id); + const ParsedRtcEventLog& parsed_log_; // A list of SSRCs we are interested in analysing. // If left empty, all SSRCs will be considered relevant. std::vector desired_ssrc_; - // Maps a stream identifier consisting of ssrc, direction and MediaType - // to the parsed RTP headers in that stream. Header extensions are parsed - // if the stream has been configured. + // Tracks what each stream is configured for. Note that a single SSRC can be + // in several sets. For example, the SSRC used for sending video over RTX + // will appear in both video_ssrcs_ and rtx_ssrcs_. In the unlikely case that + // an SSRC is reconfigured to a different media type mid-call, it will also + // appear in multiple sets. + std::set rtx_ssrcs_; + std::set video_ssrcs_; + std::set audio_ssrcs_; + + // Maps a stream identifier consisting of ssrc and direction to the parsed + // RTP headers in that stream. Header extensions are parsed if the stream + // has been configured. std::map> rtp_packets_; std::map> rtcp_packets_;