diff --git a/rtc_tools/rtc_event_log_visualizer/analyzer.cc b/rtc_tools/rtc_event_log_visualizer/analyzer.cc index 6a43388d08..eaf28bf6ba 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyzer.cc +++ b/rtc_tools/rtc_event_log_visualizer/analyzer.cc @@ -617,6 +617,43 @@ void EventLogAnalyzer::CreateAccumulatedPacketsGraph(PacketDirection direction, " RTP/RTCP packets"); } +void EventLogAnalyzer::CreatePacketRateGraph(PacketDirection direction, + Plot* plot) { + auto CountPackets = [](auto packet) { return 1.0; }; + for (const auto& stream : parsed_log_.rtp_packets_by_ssrc(direction)) { + // Filter on SSRC. + if (!MatchingSsrc(stream.ssrc, desired_ssrc_)) { + continue; + } + TimeSeries time_series( + std::string("RTP ") + GetStreamName(direction, stream.ssrc), + LineStyle::kLine); + MovingAverage(CountPackets, stream.packet_view, + config_, &time_series); + plot->AppendTimeSeries(std::move(time_series)); + } + TimeSeries time_series( + std::string("RTCP ") + "(" + GetDirectionAsShortString(direction) + ")", + LineStyle::kLine); + if (direction == kIncomingPacket) { + MovingAverage( + CountPackets, parsed_log_.incoming_rtcp_packets(), config_, + &time_series); + } else { + MovingAverage( + CountPackets, parsed_log_.outgoing_rtcp_packets(), config_, + &time_series); + } + plot->AppendTimeSeries(std::move(time_series)); + + plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(), + "Time (s)", kLeftMargin, kRightMargin); + plot->SetSuggestedYAxis(0, 1, "Packet Rate (packets/s)", kBottomMargin, + kTopMargin); + plot->SetTitle("Rate of " + GetDirectionAsString(direction) + + " RTP/RTCP packets"); +} + // For each SSRC, plot the time between the consecutive playouts. void EventLogAnalyzer::CreatePlayoutGraph(Plot* plot) { for (const auto& playout_stream : parsed_log_.audio_playout_events()) { diff --git a/rtc_tools/rtc_event_log_visualizer/analyzer.h b/rtc_tools/rtc_event_log_visualizer/analyzer.h index c4f722069b..e59e7b45ab 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyzer.h +++ b/rtc_tools/rtc_event_log_visualizer/analyzer.h @@ -63,6 +63,8 @@ class EventLogAnalyzer { void CreateAccumulatedPacketsGraph(PacketDirection direction, Plot* plot); + void CreatePacketRateGraph(PacketDirection direction, Plot* plot); + void CreatePlayoutGraph(Plot* plot); void CreateAudioLevelGraph(PacketDirection direction, Plot* plot); diff --git a/rtc_tools/rtc_event_log_visualizer/main.cc b/rtc_tools/rtc_event_log_visualizer/main.cc index cac0cb3fa0..623106831f 100644 --- a/rtc_tools/rtc_event_log_visualizer/main.cc +++ b/rtc_tools/rtc_event_log_visualizer/main.cc @@ -291,6 +291,12 @@ int main(int argc, char* argv[]) { plots.RegisterPlot("outgoing_packet_count", [&](Plot* plot) { analyzer.CreateAccumulatedPacketsGraph(webrtc::kOutgoingPacket, plot); }); + plots.RegisterPlot("incoming_packet_rate", [&](Plot* plot) { + analyzer.CreatePacketRateGraph(webrtc::kIncomingPacket, plot); + }); + plots.RegisterPlot("outgoing_packet_rate", [&](Plot* plot) { + analyzer.CreatePacketRateGraph(webrtc::kOutgoingPacket, plot); + }); plots.RegisterPlot("audio_playout", [&](Plot* plot) { analyzer.CreatePlayoutGraph(plot); }); plots.RegisterPlot("incoming_audio_level", [&](Plot* plot) {