blob: c08b71b658f085909eebe6bb8a3fedde5faf6cc8 [file] [log] [blame]
terelius54ce6802016-07-13 06:44:41 -07001/*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Yves Gerey3e707812018-11-28 16:47:49 +010011#include <stdio.h>
12#include <string.h>
terelius54ce6802016-07-13 06:44:41 -070013#include <iostream>
Yves Gerey3e707812018-11-28 16:47:49 +010014#include <map>
15#include <memory>
16#include <string>
17#include <utility>
terelius54ce6802016-07-13 06:44:41 -070018
Yves Gerey3e707812018-11-28 16:47:49 +010019#include "logging/rtc_event_log/rtc_event_log.h"
Sebastian Janssonb290a6d2019-01-03 14:46:23 +010020#include "logging/rtc_event_log/rtc_event_log_parser.h"
Yves Gerey3e707812018-11-28 16:47:49 +010021#include "modules/audio_coding/neteq/include/neteq.h"
22#include "modules/rtp_rtcp/source/rtcp_packet/report_block.h"
23#include "rtc_base/checks.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020024#include "rtc_base/flags.h"
25#include "rtc_tools/event_log_visualizer/analyzer.h"
26#include "rtc_tools/event_log_visualizer/plot_base.h"
Bjorn Tereliusef73f592018-09-10 20:11:49 +020027#include "rtc_tools/event_log_visualizer/plot_protobuf.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020028#include "rtc_tools/event_log_visualizer/plot_python.h"
Mirko Bonadei17f48782018-09-28 08:51:10 +020029#include "system_wrappers/include/field_trial.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020030#include "test/field_trial.h"
Steve Anton10542f22019-01-11 09:11:00 -080031#include "test/testsupport/file_utils.h"
terelius54ce6802016-07-13 06:44:41 -070032
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020033WEBRTC_DEFINE_string(
34 plot_profile,
35 "default",
36 "A profile that selects a certain subset of the plots. Currently "
37 "defined profiles are \"all\", \"none\", \"sendside_bwe\","
38 "\"receiveside_bwe\" and \"default\"");
terelius2ee076d2017-08-15 02:04:02 -070039
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020040WEBRTC_DEFINE_bool(plot_incoming_packet_sizes,
41 false,
42 "Plot bar graph showing the size of each incoming packet.");
43WEBRTC_DEFINE_bool(plot_outgoing_packet_sizes,
44 false,
45 "Plot bar graph showing the size of each outgoing packet.");
Bjorn Terelius7c974e62019-02-15 17:20:12 +010046WEBRTC_DEFINE_bool(plot_incoming_rtcp_types,
47 false,
48 "Plot the RTCP block types for incoming RTCP packets.");
49WEBRTC_DEFINE_bool(plot_outgoing_rtcp_types,
50 false,
51 "Plot the RTCP block types for outgoing RTCP packets.");
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020052WEBRTC_DEFINE_bool(
53 plot_incoming_packet_count,
54 false,
55 "Plot the accumulated number of packets for each incoming stream.");
56WEBRTC_DEFINE_bool(
57 plot_outgoing_packet_count,
58 false,
59 "Plot the accumulated number of packets for each outgoing stream.");
60WEBRTC_DEFINE_bool(
61 plot_audio_playout,
62 false,
63 "Plot bar graph showing the time between each audio playout.");
64WEBRTC_DEFINE_bool(
65 plot_audio_level,
66 false,
67 "Plot line graph showing the audio level of incoming audio.");
68WEBRTC_DEFINE_bool(
69 plot_incoming_sequence_number_delta,
70 false,
71 "Plot the sequence number difference between consecutive incoming "
72 "packets.");
73WEBRTC_DEFINE_bool(
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020074 plot_incoming_delay,
75 true,
76 "Plot the 1-way path delay for incoming packets, normalized so "
77 "that the first packet has delay 0.");
78WEBRTC_DEFINE_bool(
79 plot_incoming_loss_rate,
80 true,
81 "Compute the loss rate for incoming packets using a method that's "
82 "similar to the one used for RTCP SR and RR fraction lost. Note "
83 "that the loss rate can be negative if packets are duplicated or "
84 "reordered.");
85WEBRTC_DEFINE_bool(plot_incoming_bitrate,
86 true,
87 "Plot the total bitrate used by all incoming streams.");
88WEBRTC_DEFINE_bool(plot_outgoing_bitrate,
89 true,
90 "Plot the total bitrate used by all outgoing streams.");
91WEBRTC_DEFINE_bool(plot_incoming_stream_bitrate,
92 true,
93 "Plot the bitrate used by each incoming stream.");
94WEBRTC_DEFINE_bool(plot_outgoing_stream_bitrate,
95 true,
96 "Plot the bitrate used by each outgoing stream.");
97WEBRTC_DEFINE_bool(
98 plot_simulated_receiveside_bwe,
99 false,
100 "Run the receive-side bandwidth estimator with the incoming rtp "
101 "packets and plot the resulting estimate.");
102WEBRTC_DEFINE_bool(
103 plot_simulated_sendside_bwe,
104 false,
105 "Run the send-side bandwidth estimator with the outgoing rtp and "
106 "incoming rtcp and plot the resulting estimate.");
107WEBRTC_DEFINE_bool(
108 plot_network_delay_feedback,
109 true,
110 "Compute network delay based on sent packets and the received "
111 "transport feedback.");
112WEBRTC_DEFINE_bool(
113 plot_fraction_loss_feedback,
114 true,
115 "Plot packet loss in percent for outgoing packets (as perceived by "
116 "the send-side bandwidth estimator).");
117WEBRTC_DEFINE_bool(
118 plot_pacer_delay,
119 false,
120 "Plot the time each sent packet has spent in the pacer (based on "
121 "the difference between the RTP timestamp and the send "
122 "timestamp).");
123WEBRTC_DEFINE_bool(
124 plot_timestamps,
125 false,
126 "Plot the rtp timestamps of all rtp and rtcp packets over time.");
127WEBRTC_DEFINE_bool(
128 plot_rtcp_details,
129 false,
130 "Plot the contents of all report blocks in all sender and receiver "
131 "reports. This includes fraction lost, cumulative number of lost "
132 "packets, extended highest sequence number and time since last "
133 "received SR.");
134WEBRTC_DEFINE_bool(plot_audio_encoder_bitrate_bps,
135 false,
136 "Plot the audio encoder target bitrate.");
137WEBRTC_DEFINE_bool(plot_audio_encoder_frame_length_ms,
138 false,
139 "Plot the audio encoder frame length.");
140WEBRTC_DEFINE_bool(
terelius2ee076d2017-08-15 02:04:02 -0700141 plot_audio_encoder_packet_loss,
michaelt6e5b2192017-02-22 07:33:27 -0800142 false,
terelius2ee076d2017-08-15 02:04:02 -0700143 "Plot the uplink packet loss fraction which is sent to the audio encoder.");
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200144WEBRTC_DEFINE_bool(plot_audio_encoder_fec,
145 false,
146 "Plot the audio encoder FEC.");
147WEBRTC_DEFINE_bool(plot_audio_encoder_dtx,
148 false,
149 "Plot the audio encoder DTX.");
150WEBRTC_DEFINE_bool(plot_audio_encoder_num_channels,
151 false,
152 "Plot the audio encoder number of channels.");
153WEBRTC_DEFINE_bool(plot_neteq_stats, false, "Plot the NetEq statistics.");
154WEBRTC_DEFINE_bool(plot_ice_candidate_pair_config,
155 false,
156 "Plot the ICE candidate pair config events.");
157WEBRTC_DEFINE_bool(plot_ice_connectivity_check,
158 false,
159 "Plot the ICE candidate pair connectivity checks.");
Zach Stein10a58012018-12-07 12:26:28 -0800160WEBRTC_DEFINE_bool(plot_dtls_transport_state,
161 false,
162 "Plot DTLS transport state changes.");
163WEBRTC_DEFINE_bool(plot_dtls_writable_state,
164 false,
165 "Plot DTLS writable state changes.");
Bjorn Terelius1edfff92017-10-11 13:15:19 +0200166
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200167WEBRTC_DEFINE_string(
stefan985d2802016-11-15 06:54:09 -0800168 force_fieldtrials,
169 "",
170 "Field trials control experimental feature code which can be forced. "
171 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enabled/"
172 " will assign the group Enabled to field trial WebRTC-FooFeature. Multiple "
173 "trials are separated by \"/\"");
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200174WEBRTC_DEFINE_string(wav_filename,
175 "",
176 "Path to wav file used for simulation of jitter buffer");
177WEBRTC_DEFINE_bool(help, false, "prints this message");
terelius54ce6802016-07-13 06:44:41 -0700178
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200179WEBRTC_DEFINE_bool(
180 show_detector_state,
181 false,
182 "Show the state of the delay based BWE detector on the total "
183 "bitrate graph");
terelius2ee076d2017-08-15 02:04:02 -0700184
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200185WEBRTC_DEFINE_bool(show_alr_state,
186 false,
187 "Show the state ALR state on the total bitrate graph");
Ilya Nikolaevskiya4259f62017-12-05 13:19:45 +0100188
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200189WEBRTC_DEFINE_bool(
190 parse_unconfigured_header_extensions,
191 true,
192 "Attempt to parse unconfigured header extensions using the default "
193 "WebRTC mapping. This can give very misleading results if the "
194 "application negotiates a different mapping.");
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200195
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200196WEBRTC_DEFINE_bool(print_triage_alerts,
197 false,
198 "Print triage alerts, i.e. a list of potential problems.");
Bjorn Terelius2eb31882017-11-30 15:15:25 +0100199
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200200WEBRTC_DEFINE_bool(
201 normalize_time,
202 true,
203 "Normalize the log timestamps so that the call starts at time 0.");
Stefan Holmer1d4a2272018-05-24 13:48:09 +0200204
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200205WEBRTC_DEFINE_bool(protobuf_output,
206 false,
207 "Output charts as protobuf instead of python code.");
Bjorn Tereliusef73f592018-09-10 20:11:49 +0200208
terelius2ee076d2017-08-15 02:04:02 -0700209void SetAllPlotFlags(bool setting);
210
terelius54ce6802016-07-13 06:44:41 -0700211int main(int argc, char* argv[]) {
212 std::string program_name = argv[0];
213 std::string usage =
214 "A tool for visualizing WebRTC event logs.\n"
215 "Example usage:\n" +
216 program_name + " <logfile> | python\n" + "Run " + program_name +
217 " --help for a list of command line options\n";
terelius2ee076d2017-08-15 02:04:02 -0700218
219 // Parse command line flags without removing them. We're only interested in
220 // the |plot_profile| flag.
221 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, false);
222 if (strcmp(FLAG_plot_profile, "all") == 0) {
223 SetAllPlotFlags(true);
224 } else if (strcmp(FLAG_plot_profile, "none") == 0) {
225 SetAllPlotFlags(false);
Bjorn Terelius1edfff92017-10-11 13:15:19 +0200226 } else if (strcmp(FLAG_plot_profile, "sendside_bwe") == 0) {
227 SetAllPlotFlags(false);
228 FLAG_plot_outgoing_packet_sizes = true;
229 FLAG_plot_outgoing_bitrate = true;
230 FLAG_plot_outgoing_stream_bitrate = true;
231 FLAG_plot_simulated_sendside_bwe = true;
232 FLAG_plot_network_delay_feedback = true;
233 FLAG_plot_fraction_loss_feedback = true;
234 } else if (strcmp(FLAG_plot_profile, "receiveside_bwe") == 0) {
235 SetAllPlotFlags(false);
236 FLAG_plot_incoming_packet_sizes = true;
Bjorn Terelius1edfff92017-10-11 13:15:19 +0200237 FLAG_plot_incoming_delay = true;
238 FLAG_plot_incoming_loss_rate = true;
239 FLAG_plot_incoming_bitrate = true;
240 FLAG_plot_incoming_stream_bitrate = true;
241 FLAG_plot_simulated_receiveside_bwe = true;
terelius2ee076d2017-08-15 02:04:02 -0700242 } else if (strcmp(FLAG_plot_profile, "default") == 0) {
243 // Do nothing.
244 } else {
245 rtc::Flag* plot_profile_flag = rtc::FlagList::Lookup("plot_profile");
246 RTC_CHECK(plot_profile_flag);
247 plot_profile_flag->Print(false);
248 }
249 // Parse the remaining flags. They are applied relative to the chosen profile.
kjellander4fa5be42017-05-16 00:01:23 -0700250 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
terelius2ee076d2017-08-15 02:04:02 -0700251
tereliusc4a5c142017-07-20 08:05:09 -0700252 if (argc != 2 || FLAG_help) {
kjellander4fa5be42017-05-16 00:01:23 -0700253 // Print usage information.
254 std::cout << usage;
tereliusc4a5c142017-07-20 08:05:09 -0700255 if (FLAG_help)
256 rtc::FlagList::Print(nullptr, false);
kjellander4fa5be42017-05-16 00:01:23 -0700257 return 0;
258 }
259
Bjorn Tereliusedab3012018-01-31 17:23:40 +0100260 webrtc::test::ValidateFieldTrialsStringOrDie(FLAG_force_fieldtrials);
261 // InitFieldTrialsFromString stores the char*, so the char array must outlive
262 // the application.
263 webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials);
stefan985d2802016-11-15 06:54:09 -0800264
terelius54ce6802016-07-13 06:44:41 -0700265 std::string filename = argv[1];
266
Sebastian Janssonb290a6d2019-01-03 14:46:23 +0100267 webrtc::ParsedRtcEventLog::UnconfiguredHeaderExtensions header_extensions =
268 webrtc::ParsedRtcEventLog::UnconfiguredHeaderExtensions::kDontParse;
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200269 if (FLAG_parse_unconfigured_header_extensions) {
Sebastian Janssonb290a6d2019-01-03 14:46:23 +0100270 header_extensions = webrtc::ParsedRtcEventLog::
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200271 UnconfiguredHeaderExtensions::kAttemptWebrtcDefaultConfig;
272 }
Sebastian Janssonb290a6d2019-01-03 14:46:23 +0100273 webrtc::ParsedRtcEventLog parsed_log(header_extensions);
terelius54ce6802016-07-13 06:44:41 -0700274
275 if (!parsed_log.ParseFile(filename)) {
276 std::cerr << "Could not parse the entire log file." << std::endl;
Bjorn Tereliusfdc635d2018-11-14 13:40:13 +0100277 std::cerr << "Only the parsable events will be analyzed." << std::endl;
terelius54ce6802016-07-13 06:44:41 -0700278 }
279
Stefan Holmer1d4a2272018-05-24 13:48:09 +0200280 webrtc::EventLogAnalyzer analyzer(parsed_log, FLAG_normalize_time);
Bjorn Tereliusef73f592018-09-10 20:11:49 +0200281 std::unique_ptr<webrtc::PlotCollection> collection;
282 if (FLAG_protobuf_output) {
283 collection.reset(new webrtc::ProtobufPlotCollection());
284 } else {
285 collection.reset(new webrtc::PythonPlotCollection());
286 }
terelius54ce6802016-07-13 06:44:41 -0700287
terelius2ee076d2017-08-15 02:04:02 -0700288 if (FLAG_plot_incoming_packet_sizes) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200289 analyzer.CreatePacketGraph(webrtc::kIncomingPacket,
terelius2ee076d2017-08-15 02:04:02 -0700290 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700291 }
terelius2ee076d2017-08-15 02:04:02 -0700292 if (FLAG_plot_outgoing_packet_sizes) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200293 analyzer.CreatePacketGraph(webrtc::kOutgoingPacket,
terelius2ee076d2017-08-15 02:04:02 -0700294 collection->AppendNewPlot());
295 }
Bjorn Terelius7c974e62019-02-15 17:20:12 +0100296 if (FLAG_plot_incoming_rtcp_types) {
297 analyzer.CreateRtcpTypeGraph(webrtc::kIncomingPacket,
298 collection->AppendNewPlot());
299 }
300 if (FLAG_plot_outgoing_rtcp_types) {
301 analyzer.CreateRtcpTypeGraph(webrtc::kOutgoingPacket,
302 collection->AppendNewPlot());
303 }
terelius2ee076d2017-08-15 02:04:02 -0700304 if (FLAG_plot_incoming_packet_count) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200305 analyzer.CreateAccumulatedPacketsGraph(webrtc::kIncomingPacket,
306 collection->AppendNewPlot());
terelius2ee076d2017-08-15 02:04:02 -0700307 }
308 if (FLAG_plot_outgoing_packet_count) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200309 analyzer.CreateAccumulatedPacketsGraph(webrtc::kOutgoingPacket,
310 collection->AppendNewPlot());
terelius2ee076d2017-08-15 02:04:02 -0700311 }
312 if (FLAG_plot_audio_playout) {
tereliusdc35dcd2016-08-01 12:03:27 -0700313 analyzer.CreatePlayoutGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700314 }
terelius2ee076d2017-08-15 02:04:02 -0700315 if (FLAG_plot_audio_level) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200316 analyzer.CreateAudioLevelGraph(webrtc::kIncomingPacket,
317 collection->AppendNewPlot());
318 analyzer.CreateAudioLevelGraph(webrtc::kOutgoingPacket,
319 collection->AppendNewPlot());
ivocaac9d6f2016-09-22 07:01:47 -0700320 }
terelius2ee076d2017-08-15 02:04:02 -0700321 if (FLAG_plot_incoming_sequence_number_delta) {
322 analyzer.CreateSequenceNumberGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700323 }
terelius2ee076d2017-08-15 02:04:02 -0700324 if (FLAG_plot_incoming_delay) {
325 analyzer.CreateIncomingDelayGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700326 }
terelius2ee076d2017-08-15 02:04:02 -0700327 if (FLAG_plot_incoming_loss_rate) {
Stefan Holmer99f8e082016-09-09 13:37:50 +0200328 analyzer.CreateIncomingPacketLossGraph(collection->AppendNewPlot());
tereliusf736d232016-08-04 10:00:11 -0700329 }
terelius2ee076d2017-08-15 02:04:02 -0700330 if (FLAG_plot_incoming_bitrate) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200331 analyzer.CreateTotalIncomingBitrateGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700332 }
terelius2ee076d2017-08-15 02:04:02 -0700333 if (FLAG_plot_outgoing_bitrate) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200334 analyzer.CreateTotalOutgoingBitrateGraph(collection->AppendNewPlot(),
335 FLAG_show_detector_state,
336 FLAG_show_alr_state);
terelius54ce6802016-07-13 06:44:41 -0700337 }
terelius2ee076d2017-08-15 02:04:02 -0700338 if (FLAG_plot_incoming_stream_bitrate) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200339 analyzer.CreateStreamBitrateGraph(webrtc::kIncomingPacket,
terelius2ee076d2017-08-15 02:04:02 -0700340 collection->AppendNewPlot());
341 }
342 if (FLAG_plot_outgoing_stream_bitrate) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200343 analyzer.CreateStreamBitrateGraph(webrtc::kOutgoingPacket,
terelius2ee076d2017-08-15 02:04:02 -0700344 collection->AppendNewPlot());
345 }
Bjorn Terelius28db2662017-10-04 14:22:43 +0200346 if (FLAG_plot_simulated_receiveside_bwe) {
347 analyzer.CreateReceiveSideBweSimulationGraph(collection->AppendNewPlot());
348 }
terelius2ee076d2017-08-15 02:04:02 -0700349 if (FLAG_plot_simulated_sendside_bwe) {
Bjorn Terelius28db2662017-10-04 14:22:43 +0200350 analyzer.CreateSendSideBweSimulationGraph(collection->AppendNewPlot());
Stefan Holmer13181032016-07-29 14:48:54 +0200351 }
terelius2ee076d2017-08-15 02:04:02 -0700352 if (FLAG_plot_network_delay_feedback) {
tereliuse34c19c2016-08-15 08:47:14 -0700353 analyzer.CreateNetworkDelayFeedbackGraph(collection->AppendNewPlot());
stefanc3de0332016-08-02 07:22:17 -0700354 }
terelius2ee076d2017-08-15 02:04:02 -0700355 if (FLAG_plot_fraction_loss_feedback) {
356 analyzer.CreateFractionLossGraph(collection->AppendNewPlot());
357 }
358 if (FLAG_plot_timestamps) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200359 analyzer.CreateTimestampGraph(webrtc::kIncomingPacket,
360 collection->AppendNewPlot());
361 analyzer.CreateTimestampGraph(webrtc::kOutgoingPacket,
362 collection->AppendNewPlot());
stefane372d3c2017-02-02 08:04:18 -0800363 }
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200364 if (FLAG_plot_rtcp_details) {
365 auto GetFractionLost = [](const webrtc::rtcp::ReportBlock& block) -> float {
366 return static_cast<double>(block.fraction_lost()) / 256 * 100;
367 };
368 analyzer.CreateSenderAndReceiverReportPlot(
369 webrtc::kIncomingPacket, GetFractionLost,
370 "Fraction lost (incoming RTCP)", "Loss rate (percent)",
371 collection->AppendNewPlot());
372 analyzer.CreateSenderAndReceiverReportPlot(
373 webrtc::kOutgoingPacket, GetFractionLost,
374 "Fraction lost (outgoing RTCP)", "Loss rate (percent)",
375 collection->AppendNewPlot());
376
377 auto GetCumulativeLost =
378 [](const webrtc::rtcp::ReportBlock& block) -> float {
379 return block.cumulative_lost_signed();
380 };
381 analyzer.CreateSenderAndReceiverReportPlot(
382 webrtc::kIncomingPacket, GetCumulativeLost,
383 "Cumulative lost packets (incoming RTCP)", "Packets",
384 collection->AppendNewPlot());
385 analyzer.CreateSenderAndReceiverReportPlot(
386 webrtc::kOutgoingPacket, GetCumulativeLost,
387 "Cumulative lost packets (outgoing RTCP)", "Packets",
388 collection->AppendNewPlot());
389
390 auto GetHighestSeqNumber =
391 [](const webrtc::rtcp::ReportBlock& block) -> float {
392 return block.extended_high_seq_num();
393 };
394 analyzer.CreateSenderAndReceiverReportPlot(
395 webrtc::kIncomingPacket, GetHighestSeqNumber,
Bjorn Tereliusef73f592018-09-10 20:11:49 +0200396 "Highest sequence number (incoming RTCP)", "Sequence number",
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200397 collection->AppendNewPlot());
398 analyzer.CreateSenderAndReceiverReportPlot(
399 webrtc::kOutgoingPacket, GetHighestSeqNumber,
Bjorn Tereliusef73f592018-09-10 20:11:49 +0200400 "Highest sequence number (outgoing RTCP)", "Sequence number",
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200401 collection->AppendNewPlot());
402
403 auto DelaySinceLastSr =
404 [](const webrtc::rtcp::ReportBlock& block) -> float {
405 return static_cast<double>(block.delay_since_last_sr()) / 65536;
406 };
407 analyzer.CreateSenderAndReceiverReportPlot(
408 webrtc::kIncomingPacket, DelaySinceLastSr,
409 "Delay since last received sender report (incoming RTCP)", "Time (s)",
410 collection->AppendNewPlot());
411 analyzer.CreateSenderAndReceiverReportPlot(
412 webrtc::kOutgoingPacket, DelaySinceLastSr,
413 "Delay since last received sender report (outgoing RTCP)", "Time (s)",
414 collection->AppendNewPlot());
415 }
416
Bjorn Terelius0295a962017-10-25 17:42:41 +0200417 if (FLAG_plot_pacer_delay) {
418 analyzer.CreatePacerDelayGraph(collection->AppendNewPlot());
419 }
terelius2ee076d2017-08-15 02:04:02 -0700420 if (FLAG_plot_audio_encoder_bitrate_bps) {
michaelt6e5b2192017-02-22 07:33:27 -0800421 analyzer.CreateAudioEncoderTargetBitrateGraph(collection->AppendNewPlot());
422 }
terelius2ee076d2017-08-15 02:04:02 -0700423 if (FLAG_plot_audio_encoder_frame_length_ms) {
michaelt6e5b2192017-02-22 07:33:27 -0800424 analyzer.CreateAudioEncoderFrameLengthGraph(collection->AppendNewPlot());
425 }
terelius2ee076d2017-08-15 02:04:02 -0700426 if (FLAG_plot_audio_encoder_packet_loss) {
427 analyzer.CreateAudioEncoderPacketLossGraph(collection->AppendNewPlot());
michaelt6e5b2192017-02-22 07:33:27 -0800428 }
terelius2ee076d2017-08-15 02:04:02 -0700429 if (FLAG_plot_audio_encoder_fec) {
michaelt6e5b2192017-02-22 07:33:27 -0800430 analyzer.CreateAudioEncoderEnableFecGraph(collection->AppendNewPlot());
431 }
terelius2ee076d2017-08-15 02:04:02 -0700432 if (FLAG_plot_audio_encoder_dtx) {
michaelt6e5b2192017-02-22 07:33:27 -0800433 analyzer.CreateAudioEncoderEnableDtxGraph(collection->AppendNewPlot());
434 }
terelius2ee076d2017-08-15 02:04:02 -0700435 if (FLAG_plot_audio_encoder_num_channels) {
michaelt6e5b2192017-02-22 07:33:27 -0800436 analyzer.CreateAudioEncoderNumChannelsGraph(collection->AppendNewPlot());
437 }
Minyue Li27e2b7d2018-05-07 15:20:24 +0200438 if (FLAG_plot_neteq_stats) {
owb7fbeb0b2017-08-16 02:48:33 -0700439 std::string wav_path;
440 if (FLAG_wav_filename[0] != '\0') {
441 wav_path = FLAG_wav_filename;
442 } else {
443 wav_path = webrtc::test::ResourcePath(
444 "audio_processing/conversational_speech/EN_script2_F_sp2_B1", "wav");
445 }
Minyue Lic6ff7572018-05-04 09:46:44 +0200446 auto neteq_stats = analyzer.SimulateNetEq(wav_path, 48000);
Minyue Li01d2a672018-06-21 21:17:19 +0200447 for (webrtc::EventLogAnalyzer::NetEqStatsGetterMap::const_iterator it =
448 neteq_stats.cbegin();
449 it != neteq_stats.cend(); ++it) {
450 analyzer.CreateAudioJitterBufferGraph(it->first, it->second.get(),
Minyue Li45fc6df2018-06-21 11:47:14 +0200451 collection->AppendNewPlot());
452 }
Minyue Lic9ac93f2018-06-26 13:01:32 +0200453 analyzer.CreateNetEqNetworkStatsGraph(
Minyue Li27e2b7d2018-05-07 15:20:24 +0200454 neteq_stats,
455 [](const webrtc::NetEqNetworkStatistics& stats) {
456 return stats.expand_rate / 16384.f;
457 },
458 "Expand rate", collection->AppendNewPlot());
Minyue Lic9ac93f2018-06-26 13:01:32 +0200459 analyzer.CreateNetEqNetworkStatsGraph(
Minyue Li27e2b7d2018-05-07 15:20:24 +0200460 neteq_stats,
461 [](const webrtc::NetEqNetworkStatistics& stats) {
462 return stats.speech_expand_rate / 16384.f;
463 },
464 "Speech expand rate", collection->AppendNewPlot());
Minyue Lic9ac93f2018-06-26 13:01:32 +0200465 analyzer.CreateNetEqNetworkStatsGraph(
Minyue Li27e2b7d2018-05-07 15:20:24 +0200466 neteq_stats,
467 [](const webrtc::NetEqNetworkStatistics& stats) {
468 return stats.accelerate_rate / 16384.f;
469 },
470 "Accelerate rate", collection->AppendNewPlot());
Minyue Lic9ac93f2018-06-26 13:01:32 +0200471 analyzer.CreateNetEqNetworkStatsGraph(
Minyue Li27e2b7d2018-05-07 15:20:24 +0200472 neteq_stats,
473 [](const webrtc::NetEqNetworkStatistics& stats) {
474 return stats.packet_loss_rate / 16384.f;
475 },
476 "Packet loss rate", collection->AppendNewPlot());
Minyue Lic9ac93f2018-06-26 13:01:32 +0200477 analyzer.CreateNetEqLifetimeStatsGraph(
478 neteq_stats,
479 [](const webrtc::NetEqLifetimeStatistics& stats) {
480 return static_cast<float>(stats.concealment_events);
481 },
482 "Concealment events", collection->AppendNewPlot());
henrik.lundin3c938fc2017-06-14 06:09:58 -0700483 }
484
Qingsi Wang8eca1ff2018-02-02 11:49:44 -0800485 if (FLAG_plot_ice_candidate_pair_config) {
486 analyzer.CreateIceCandidatePairConfigGraph(collection->AppendNewPlot());
487 }
488 if (FLAG_plot_ice_connectivity_check) {
489 analyzer.CreateIceConnectivityCheckGraph(collection->AppendNewPlot());
490 }
491
Zach Stein10a58012018-12-07 12:26:28 -0800492 if (FLAG_plot_dtls_transport_state) {
493 analyzer.CreateDtlsTransportStateGraph(collection->AppendNewPlot());
494 }
495 if (FLAG_plot_dtls_writable_state) {
496 analyzer.CreateDtlsWritableStateGraph(collection->AppendNewPlot());
497 }
498
tereliusdc35dcd2016-08-01 12:03:27 -0700499 collection->Draw();
terelius54ce6802016-07-13 06:44:41 -0700500
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200501 if (FLAG_print_triage_alerts) {
Bjorn Terelius2eb31882017-11-30 15:15:25 +0100502 analyzer.CreateTriageNotifications();
503 analyzer.PrintNotifications(stderr);
504 }
505
terelius54ce6802016-07-13 06:44:41 -0700506 return 0;
507}
terelius2ee076d2017-08-15 02:04:02 -0700508
terelius2ee076d2017-08-15 02:04:02 -0700509void SetAllPlotFlags(bool setting) {
510 FLAG_plot_incoming_packet_sizes = setting;
511 FLAG_plot_outgoing_packet_sizes = setting;
Bjorn Terelius7c974e62019-02-15 17:20:12 +0100512 FLAG_plot_incoming_rtcp_types = setting;
513 FLAG_plot_outgoing_rtcp_types = setting;
terelius2ee076d2017-08-15 02:04:02 -0700514 FLAG_plot_incoming_packet_count = setting;
515 FLAG_plot_outgoing_packet_count = setting;
516 FLAG_plot_audio_playout = setting;
517 FLAG_plot_audio_level = setting;
518 FLAG_plot_incoming_sequence_number_delta = setting;
terelius2ee076d2017-08-15 02:04:02 -0700519 FLAG_plot_incoming_delay = setting;
520 FLAG_plot_incoming_loss_rate = setting;
521 FLAG_plot_incoming_bitrate = setting;
522 FLAG_plot_outgoing_bitrate = setting;
523 FLAG_plot_incoming_stream_bitrate = setting;
524 FLAG_plot_outgoing_stream_bitrate = setting;
Bjorn Terelius28db2662017-10-04 14:22:43 +0200525 FLAG_plot_simulated_receiveside_bwe = setting;
terelius2ee076d2017-08-15 02:04:02 -0700526 FLAG_plot_simulated_sendside_bwe = setting;
527 FLAG_plot_network_delay_feedback = setting;
528 FLAG_plot_fraction_loss_feedback = setting;
529 FLAG_plot_timestamps = setting;
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200530 FLAG_plot_rtcp_details = setting;
terelius2ee076d2017-08-15 02:04:02 -0700531 FLAG_plot_audio_encoder_bitrate_bps = setting;
532 FLAG_plot_audio_encoder_frame_length_ms = setting;
533 FLAG_plot_audio_encoder_packet_loss = setting;
534 FLAG_plot_audio_encoder_fec = setting;
535 FLAG_plot_audio_encoder_dtx = setting;
536 FLAG_plot_audio_encoder_num_channels = setting;
Minyue Li27e2b7d2018-05-07 15:20:24 +0200537 FLAG_plot_neteq_stats = setting;
Qingsi Wang8eca1ff2018-02-02 11:49:44 -0800538 FLAG_plot_ice_candidate_pair_config = setting;
539 FLAG_plot_ice_connectivity_check = setting;
terelius2ee076d2017-08-15 02:04:02 -0700540}