From ccd74896615700ab3ada9c024a726b3491f23300 Mon Sep 17 00:00:00 2001 From: philipel Date: Mon, 5 Sep 2016 02:46:25 -0700 Subject: [PATCH] Plot accumelated packets over time. BUG= Review-Url: https://codereview.webrtc.org/2295063006 Cr-Commit-Position: refs/heads/master@{#14066} --- webrtc/tools/event_log_visualizer/analyzer.cc | 47 +++++++++++++++++++ webrtc/tools/event_log_visualizer/analyzer.h | 13 ++++- webrtc/tools/event_log_visualizer/main.cc | 6 +++ 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/webrtc/tools/event_log_visualizer/analyzer.cc b/webrtc/tools/event_log_visualizer/analyzer.cc index 2a23c94a7d..7db82ae478 100644 --- a/webrtc/tools/event_log_visualizer/analyzer.cc +++ b/webrtc/tools/event_log_visualizer/analyzer.cc @@ -498,6 +498,53 @@ void EventLogAnalyzer::CreatePacketGraph(PacketDirection desired_direction, } } +template +void EventLogAnalyzer::CreateAccumulatedPacketsTimeSeries( + PacketDirection desired_direction, + Plot* plot, + const std::map>& packets, + const std::string& label_prefix) { + for (auto& kv : packets) { + StreamId stream_id = kv.first; + const std::vector& packet_stream = kv.second; + // Filter on direction and SSRC. + if (stream_id.GetDirection() != desired_direction || + !MatchingSsrc(stream_id.GetSsrc(), desired_ssrc_)) { + continue; + } + + TimeSeries time_series; + time_series.label = label_prefix + " " + SsrcToString(stream_id.GetSsrc()); + time_series.style = LINE_GRAPH; + + for (size_t i = 0; i < packet_stream.size(); i++) { + float x = static_cast(packet_stream[i].timestamp - begin_time_) / + 1000000; + time_series.points.emplace_back(x, i); + time_series.points.emplace_back(x, i + 1); + } + + plot->series_list_.push_back(std::move(time_series)); + } +} + +void EventLogAnalyzer::CreateAccumulatedPacketsGraph( + PacketDirection desired_direction, + Plot* plot) { + CreateAccumulatedPacketsTimeSeries(desired_direction, plot, rtp_packets_, + "RTP"); + CreateAccumulatedPacketsTimeSeries(desired_direction, plot, rtcp_packets_, + "RTCP"); + + plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); + plot->SetSuggestedYAxis(0, 1, "Received Packets", kBottomMargin, kTopMargin); + if (desired_direction == webrtc::PacketDirection::kIncomingPacket) { + plot->SetTitle("Accumulated Incoming RTP/RTCP packets"); + } else if (desired_direction == webrtc::PacketDirection::kOutgoingPacket) { + plot->SetTitle("Accumulated Outgoing RTP/RTCP packets"); + } +} + // For each SSRC, plot the time between the consecutive playouts. void EventLogAnalyzer::CreatePlayoutGraph(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 6972b37f37..74c0ff0875 100644 --- a/webrtc/tools/event_log_visualizer/analyzer.h +++ b/webrtc/tools/event_log_visualizer/analyzer.h @@ -11,11 +11,12 @@ #ifndef WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_ANALYZER_H_ #define WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_ANALYZER_H_ -#include #include #include #include +#include #include +#include #include "webrtc/call/rtc_event_log_parser.h" #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" @@ -60,6 +61,9 @@ class EventLogAnalyzer { void CreatePacketGraph(PacketDirection desired_direction, Plot* plot); + void CreateAccumulatedPacketsGraph(PacketDirection desired_direction, + Plot* plot); + void CreatePlayoutGraph(Plot* plot); void CreateSequenceNumberGraph(Plot* plot); @@ -99,6 +103,13 @@ class EventLogAnalyzer { webrtc::PacketDirection direction_; }; + template + void CreateAccumulatedPacketsTimeSeries( + PacketDirection desired_direction, + Plot* plot, + const std::map>& packets, + const std::string& label_prefix); + bool IsRtxSsrc(StreamId stream_id); bool IsVideoSsrc(StreamId stream_id); diff --git a/webrtc/tools/event_log_visualizer/main.cc b/webrtc/tools/event_log_visualizer/main.cc index d8d9e25a26..a56947c484 100644 --- a/webrtc/tools/event_log_visualizer/main.cc +++ b/webrtc/tools/event_log_visualizer/main.cc @@ -91,10 +91,16 @@ int main(int argc, char* argv[]) { if (FLAGS_incoming) { analyzer.CreatePacketGraph(webrtc::PacketDirection::kIncomingPacket, collection->AppendNewPlot()); + analyzer.CreateAccumulatedPacketsGraph( + webrtc::PacketDirection::kIncomingPacket, + collection->AppendNewPlot()); } if (FLAGS_outgoing) { analyzer.CreatePacketGraph(webrtc::PacketDirection::kOutgoingPacket, collection->AppendNewPlot()); + analyzer.CreateAccumulatedPacketsGraph( + webrtc::PacketDirection::kOutgoingPacket, + collection->AppendNewPlot()); } }