blob: e7de7203157965aa652f82bb69d1f72f521570cb [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>
Jonas Olsson5b2eda42019-06-11 14:29:40 +020013
terelius54ce6802016-07-13 06:44:41 -070014#include <iostream>
Yves Gerey3e707812018-11-28 16:47:49 +010015#include <map>
16#include <memory>
17#include <string>
18#include <utility>
terelius54ce6802016-07-13 06:44:41 -070019
Yves Gerey3e707812018-11-28 16:47:49 +010020#include "logging/rtc_event_log/rtc_event_log.h"
Sebastian Janssonb290a6d2019-01-03 14:46:23 +010021#include "logging/rtc_event_log/rtc_event_log_parser.h"
Yves Gerey3e707812018-11-28 16:47:49 +010022#include "modules/audio_coding/neteq/include/neteq.h"
23#include "modules/rtp_rtcp/source/rtcp_packet/report_block.h"
24#include "rtc_base/checks.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020025#include "rtc_base/flags.h"
26#include "rtc_tools/event_log_visualizer/analyzer.h"
27#include "rtc_tools/event_log_visualizer/plot_base.h"
Bjorn Tereliusef73f592018-09-10 20:11:49 +020028#include "rtc_tools/event_log_visualizer/plot_protobuf.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020029#include "rtc_tools/event_log_visualizer/plot_python.h"
Mirko Bonadei17f48782018-09-28 08:51:10 +020030#include "system_wrappers/include/field_trial.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020031#include "test/field_trial.h"
Steve Anton10542f22019-01-11 09:11:00 -080032#include "test/testsupport/file_utils.h"
terelius54ce6802016-07-13 06:44:41 -070033
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020034WEBRTC_DEFINE_string(
35 plot_profile,
36 "default",
37 "A profile that selects a certain subset of the plots. Currently "
38 "defined profiles are \"all\", \"none\", \"sendside_bwe\","
39 "\"receiveside_bwe\" and \"default\"");
terelius2ee076d2017-08-15 02:04:02 -070040
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020041WEBRTC_DEFINE_bool(plot_incoming_packet_sizes,
42 false,
43 "Plot bar graph showing the size of each incoming packet.");
44WEBRTC_DEFINE_bool(plot_outgoing_packet_sizes,
45 false,
46 "Plot bar graph showing the size of each outgoing packet.");
Bjorn Terelius7c974e62019-02-15 17:20:12 +010047WEBRTC_DEFINE_bool(plot_incoming_rtcp_types,
48 false,
49 "Plot the RTCP block types for incoming RTCP packets.");
50WEBRTC_DEFINE_bool(plot_outgoing_rtcp_types,
51 false,
52 "Plot the RTCP block types for outgoing RTCP packets.");
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020053WEBRTC_DEFINE_bool(
54 plot_incoming_packet_count,
55 false,
56 "Plot the accumulated number of packets for each incoming stream.");
57WEBRTC_DEFINE_bool(
58 plot_outgoing_packet_count,
59 false,
60 "Plot the accumulated number of packets for each outgoing stream.");
61WEBRTC_DEFINE_bool(
62 plot_audio_playout,
63 false,
64 "Plot bar graph showing the time between each audio playout.");
65WEBRTC_DEFINE_bool(
66 plot_audio_level,
67 false,
68 "Plot line graph showing the audio level of incoming audio.");
69WEBRTC_DEFINE_bool(
70 plot_incoming_sequence_number_delta,
71 false,
72 "Plot the sequence number difference between consecutive incoming "
73 "packets.");
74WEBRTC_DEFINE_bool(
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020075 plot_incoming_delay,
76 true,
77 "Plot the 1-way path delay for incoming packets, normalized so "
78 "that the first packet has delay 0.");
79WEBRTC_DEFINE_bool(
80 plot_incoming_loss_rate,
81 true,
82 "Compute the loss rate for incoming packets using a method that's "
83 "similar to the one used for RTCP SR and RR fraction lost. Note "
84 "that the loss rate can be negative if packets are duplicated or "
85 "reordered.");
86WEBRTC_DEFINE_bool(plot_incoming_bitrate,
87 true,
88 "Plot the total bitrate used by all incoming streams.");
89WEBRTC_DEFINE_bool(plot_outgoing_bitrate,
90 true,
91 "Plot the total bitrate used by all outgoing streams.");
92WEBRTC_DEFINE_bool(plot_incoming_stream_bitrate,
93 true,
94 "Plot the bitrate used by each incoming stream.");
95WEBRTC_DEFINE_bool(plot_outgoing_stream_bitrate,
96 true,
97 "Plot the bitrate used by each outgoing stream.");
Bjorn Terelius9775a582019-02-15 17:29:58 +010098WEBRTC_DEFINE_bool(plot_incoming_layer_bitrate_allocation,
99 false,
100 "Plot the target bitrate for each incoming layer. Requires "
101 "incoming RTCP XR with target bitrate to be populated.");
102WEBRTC_DEFINE_bool(plot_outgoing_layer_bitrate_allocation,
103 false,
104 "Plot the target bitrate for each outgoing layer. Requires "
105 "outgoing RTCP XR with target bitrate to be populated.");
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200106WEBRTC_DEFINE_bool(
107 plot_simulated_receiveside_bwe,
108 false,
109 "Run the receive-side bandwidth estimator with the incoming rtp "
110 "packets and plot the resulting estimate.");
111WEBRTC_DEFINE_bool(
112 plot_simulated_sendside_bwe,
113 false,
114 "Run the send-side bandwidth estimator with the outgoing rtp and "
115 "incoming rtcp and plot the resulting estimate.");
Sebastian Jansson1175ae02019-03-13 08:56:58 +0100116WEBRTC_DEFINE_bool(plot_simulated_goog_cc,
117 false,
118 "Run the GoogCC congestion controller based on the logged "
119 "events and plot the target bitrate.");
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200120WEBRTC_DEFINE_bool(
121 plot_network_delay_feedback,
122 true,
123 "Compute network delay based on sent packets and the received "
124 "transport feedback.");
125WEBRTC_DEFINE_bool(
126 plot_fraction_loss_feedback,
127 true,
128 "Plot packet loss in percent for outgoing packets (as perceived by "
129 "the send-side bandwidth estimator).");
130WEBRTC_DEFINE_bool(
131 plot_pacer_delay,
132 false,
133 "Plot the time each sent packet has spent in the pacer (based on "
134 "the difference between the RTP timestamp and the send "
135 "timestamp).");
136WEBRTC_DEFINE_bool(
137 plot_timestamps,
138 false,
139 "Plot the rtp timestamps of all rtp and rtcp packets over time.");
140WEBRTC_DEFINE_bool(
141 plot_rtcp_details,
142 false,
143 "Plot the contents of all report blocks in all sender and receiver "
144 "reports. This includes fraction lost, cumulative number of lost "
145 "packets, extended highest sequence number and time since last "
146 "received SR.");
147WEBRTC_DEFINE_bool(plot_audio_encoder_bitrate_bps,
148 false,
149 "Plot the audio encoder target bitrate.");
150WEBRTC_DEFINE_bool(plot_audio_encoder_frame_length_ms,
151 false,
152 "Plot the audio encoder frame length.");
153WEBRTC_DEFINE_bool(
terelius2ee076d2017-08-15 02:04:02 -0700154 plot_audio_encoder_packet_loss,
michaelt6e5b2192017-02-22 07:33:27 -0800155 false,
terelius2ee076d2017-08-15 02:04:02 -0700156 "Plot the uplink packet loss fraction which is sent to the audio encoder.");
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200157WEBRTC_DEFINE_bool(plot_audio_encoder_fec,
158 false,
159 "Plot the audio encoder FEC.");
160WEBRTC_DEFINE_bool(plot_audio_encoder_dtx,
161 false,
162 "Plot the audio encoder DTX.");
163WEBRTC_DEFINE_bool(plot_audio_encoder_num_channels,
164 false,
165 "Plot the audio encoder number of channels.");
166WEBRTC_DEFINE_bool(plot_neteq_stats, false, "Plot the NetEq statistics.");
167WEBRTC_DEFINE_bool(plot_ice_candidate_pair_config,
168 false,
169 "Plot the ICE candidate pair config events.");
170WEBRTC_DEFINE_bool(plot_ice_connectivity_check,
171 false,
172 "Plot the ICE candidate pair connectivity checks.");
Zach Stein10a58012018-12-07 12:26:28 -0800173WEBRTC_DEFINE_bool(plot_dtls_transport_state,
174 false,
175 "Plot DTLS transport state changes.");
176WEBRTC_DEFINE_bool(plot_dtls_writable_state,
177 false,
178 "Plot DTLS writable state changes.");
Bjorn Terelius1edfff92017-10-11 13:15:19 +0200179
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200180WEBRTC_DEFINE_string(
stefan985d2802016-11-15 06:54:09 -0800181 force_fieldtrials,
182 "",
183 "Field trials control experimental feature code which can be forced. "
184 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enabled/"
185 " will assign the group Enabled to field trial WebRTC-FooFeature. Multiple "
186 "trials are separated by \"/\"");
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200187WEBRTC_DEFINE_string(wav_filename,
188 "",
189 "Path to wav file used for simulation of jitter buffer");
190WEBRTC_DEFINE_bool(help, false, "prints this message");
terelius54ce6802016-07-13 06:44:41 -0700191
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200192WEBRTC_DEFINE_bool(
193 show_detector_state,
194 false,
195 "Show the state of the delay based BWE detector on the total "
196 "bitrate graph");
terelius2ee076d2017-08-15 02:04:02 -0700197
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200198WEBRTC_DEFINE_bool(show_alr_state,
199 false,
200 "Show the state ALR state on the total bitrate graph");
Ilya Nikolaevskiya4259f62017-12-05 13:19:45 +0100201
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200202WEBRTC_DEFINE_bool(
203 parse_unconfigured_header_extensions,
204 true,
205 "Attempt to parse unconfigured header extensions using the default "
206 "WebRTC mapping. This can give very misleading results if the "
207 "application negotiates a different mapping.");
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200208
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200209WEBRTC_DEFINE_bool(print_triage_alerts,
210 false,
211 "Print triage alerts, i.e. a list of potential problems.");
Bjorn Terelius2eb31882017-11-30 15:15:25 +0100212
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200213WEBRTC_DEFINE_bool(
214 normalize_time,
215 true,
216 "Normalize the log timestamps so that the call starts at time 0.");
Stefan Holmer1d4a2272018-05-24 13:48:09 +0200217
Bjorn Tereliusff8cce32019-04-11 18:34:01 +0200218WEBRTC_DEFINE_bool(shared_xaxis,
219 false,
220 "Share x-axis between all plots so that zooming in one plot "
221 "updates all the others too. A downside is that certain "
222 "operations like panning become much slower.");
223
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200224WEBRTC_DEFINE_bool(protobuf_output,
225 false,
226 "Output charts as protobuf instead of python code.");
Bjorn Tereliusef73f592018-09-10 20:11:49 +0200227
terelius2ee076d2017-08-15 02:04:02 -0700228void SetAllPlotFlags(bool setting);
229
terelius54ce6802016-07-13 06:44:41 -0700230int main(int argc, char* argv[]) {
231 std::string program_name = argv[0];
232 std::string usage =
233 "A tool for visualizing WebRTC event logs.\n"
234 "Example usage:\n" +
235 program_name + " <logfile> | python\n" + "Run " + program_name +
236 " --help for a list of command line options\n";
terelius2ee076d2017-08-15 02:04:02 -0700237
238 // Parse command line flags without removing them. We're only interested in
239 // the |plot_profile| flag.
240 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, false);
241 if (strcmp(FLAG_plot_profile, "all") == 0) {
242 SetAllPlotFlags(true);
243 } else if (strcmp(FLAG_plot_profile, "none") == 0) {
244 SetAllPlotFlags(false);
Bjorn Terelius1edfff92017-10-11 13:15:19 +0200245 } else if (strcmp(FLAG_plot_profile, "sendside_bwe") == 0) {
246 SetAllPlotFlags(false);
247 FLAG_plot_outgoing_packet_sizes = true;
248 FLAG_plot_outgoing_bitrate = true;
249 FLAG_plot_outgoing_stream_bitrate = true;
250 FLAG_plot_simulated_sendside_bwe = true;
251 FLAG_plot_network_delay_feedback = true;
252 FLAG_plot_fraction_loss_feedback = true;
253 } else if (strcmp(FLAG_plot_profile, "receiveside_bwe") == 0) {
254 SetAllPlotFlags(false);
255 FLAG_plot_incoming_packet_sizes = true;
Bjorn Terelius1edfff92017-10-11 13:15:19 +0200256 FLAG_plot_incoming_delay = true;
257 FLAG_plot_incoming_loss_rate = true;
258 FLAG_plot_incoming_bitrate = true;
259 FLAG_plot_incoming_stream_bitrate = true;
260 FLAG_plot_simulated_receiveside_bwe = true;
terelius2ee076d2017-08-15 02:04:02 -0700261 } else if (strcmp(FLAG_plot_profile, "default") == 0) {
262 // Do nothing.
263 } else {
264 rtc::Flag* plot_profile_flag = rtc::FlagList::Lookup("plot_profile");
265 RTC_CHECK(plot_profile_flag);
266 plot_profile_flag->Print(false);
267 }
268 // Parse the remaining flags. They are applied relative to the chosen profile.
kjellander4fa5be42017-05-16 00:01:23 -0700269 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
terelius2ee076d2017-08-15 02:04:02 -0700270
tereliusc4a5c142017-07-20 08:05:09 -0700271 if (argc != 2 || FLAG_help) {
kjellander4fa5be42017-05-16 00:01:23 -0700272 // Print usage information.
273 std::cout << usage;
tereliusc4a5c142017-07-20 08:05:09 -0700274 if (FLAG_help)
275 rtc::FlagList::Print(nullptr, false);
kjellander4fa5be42017-05-16 00:01:23 -0700276 return 0;
277 }
278
Bjorn Tereliusedab3012018-01-31 17:23:40 +0100279 // InitFieldTrialsFromString stores the char*, so the char array must outlive
280 // the application.
281 webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials);
stefan985d2802016-11-15 06:54:09 -0800282
terelius54ce6802016-07-13 06:44:41 -0700283 std::string filename = argv[1];
284
Sebastian Janssonb290a6d2019-01-03 14:46:23 +0100285 webrtc::ParsedRtcEventLog::UnconfiguredHeaderExtensions header_extensions =
286 webrtc::ParsedRtcEventLog::UnconfiguredHeaderExtensions::kDontParse;
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200287 if (FLAG_parse_unconfigured_header_extensions) {
Sebastian Janssonb290a6d2019-01-03 14:46:23 +0100288 header_extensions = webrtc::ParsedRtcEventLog::
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200289 UnconfiguredHeaderExtensions::kAttemptWebrtcDefaultConfig;
290 }
Sebastian Janssonb290a6d2019-01-03 14:46:23 +0100291 webrtc::ParsedRtcEventLog parsed_log(header_extensions);
terelius54ce6802016-07-13 06:44:41 -0700292
293 if (!parsed_log.ParseFile(filename)) {
294 std::cerr << "Could not parse the entire log file." << std::endl;
Bjorn Tereliusfdc635d2018-11-14 13:40:13 +0100295 std::cerr << "Only the parsable events will be analyzed." << std::endl;
terelius54ce6802016-07-13 06:44:41 -0700296 }
297
Stefan Holmer1d4a2272018-05-24 13:48:09 +0200298 webrtc::EventLogAnalyzer analyzer(parsed_log, FLAG_normalize_time);
Bjorn Tereliusef73f592018-09-10 20:11:49 +0200299 std::unique_ptr<webrtc::PlotCollection> collection;
300 if (FLAG_protobuf_output) {
301 collection.reset(new webrtc::ProtobufPlotCollection());
302 } else {
Bjorn Tereliusff8cce32019-04-11 18:34:01 +0200303 collection.reset(new webrtc::PythonPlotCollection(FLAG_shared_xaxis));
Bjorn Tereliusef73f592018-09-10 20:11:49 +0200304 }
terelius54ce6802016-07-13 06:44:41 -0700305
terelius2ee076d2017-08-15 02:04:02 -0700306 if (FLAG_plot_incoming_packet_sizes) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200307 analyzer.CreatePacketGraph(webrtc::kIncomingPacket,
terelius2ee076d2017-08-15 02:04:02 -0700308 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700309 }
terelius2ee076d2017-08-15 02:04:02 -0700310 if (FLAG_plot_outgoing_packet_sizes) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200311 analyzer.CreatePacketGraph(webrtc::kOutgoingPacket,
terelius2ee076d2017-08-15 02:04:02 -0700312 collection->AppendNewPlot());
313 }
Bjorn Terelius7c974e62019-02-15 17:20:12 +0100314 if (FLAG_plot_incoming_rtcp_types) {
315 analyzer.CreateRtcpTypeGraph(webrtc::kIncomingPacket,
316 collection->AppendNewPlot());
317 }
318 if (FLAG_plot_outgoing_rtcp_types) {
319 analyzer.CreateRtcpTypeGraph(webrtc::kOutgoingPacket,
320 collection->AppendNewPlot());
321 }
terelius2ee076d2017-08-15 02:04:02 -0700322 if (FLAG_plot_incoming_packet_count) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200323 analyzer.CreateAccumulatedPacketsGraph(webrtc::kIncomingPacket,
324 collection->AppendNewPlot());
terelius2ee076d2017-08-15 02:04:02 -0700325 }
326 if (FLAG_plot_outgoing_packet_count) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200327 analyzer.CreateAccumulatedPacketsGraph(webrtc::kOutgoingPacket,
328 collection->AppendNewPlot());
terelius2ee076d2017-08-15 02:04:02 -0700329 }
330 if (FLAG_plot_audio_playout) {
tereliusdc35dcd2016-08-01 12:03:27 -0700331 analyzer.CreatePlayoutGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700332 }
terelius2ee076d2017-08-15 02:04:02 -0700333 if (FLAG_plot_audio_level) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200334 analyzer.CreateAudioLevelGraph(webrtc::kIncomingPacket,
335 collection->AppendNewPlot());
336 analyzer.CreateAudioLevelGraph(webrtc::kOutgoingPacket,
337 collection->AppendNewPlot());
ivocaac9d6f2016-09-22 07:01:47 -0700338 }
terelius2ee076d2017-08-15 02:04:02 -0700339 if (FLAG_plot_incoming_sequence_number_delta) {
340 analyzer.CreateSequenceNumberGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700341 }
terelius2ee076d2017-08-15 02:04:02 -0700342 if (FLAG_plot_incoming_delay) {
343 analyzer.CreateIncomingDelayGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700344 }
terelius2ee076d2017-08-15 02:04:02 -0700345 if (FLAG_plot_incoming_loss_rate) {
Stefan Holmer99f8e082016-09-09 13:37:50 +0200346 analyzer.CreateIncomingPacketLossGraph(collection->AppendNewPlot());
tereliusf736d232016-08-04 10:00:11 -0700347 }
terelius2ee076d2017-08-15 02:04:02 -0700348 if (FLAG_plot_incoming_bitrate) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200349 analyzer.CreateTotalIncomingBitrateGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700350 }
terelius2ee076d2017-08-15 02:04:02 -0700351 if (FLAG_plot_outgoing_bitrate) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200352 analyzer.CreateTotalOutgoingBitrateGraph(collection->AppendNewPlot(),
353 FLAG_show_detector_state,
354 FLAG_show_alr_state);
terelius54ce6802016-07-13 06:44:41 -0700355 }
terelius2ee076d2017-08-15 02:04:02 -0700356 if (FLAG_plot_incoming_stream_bitrate) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200357 analyzer.CreateStreamBitrateGraph(webrtc::kIncomingPacket,
terelius2ee076d2017-08-15 02:04:02 -0700358 collection->AppendNewPlot());
359 }
360 if (FLAG_plot_outgoing_stream_bitrate) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200361 analyzer.CreateStreamBitrateGraph(webrtc::kOutgoingPacket,
terelius2ee076d2017-08-15 02:04:02 -0700362 collection->AppendNewPlot());
363 }
Bjorn Terelius9775a582019-02-15 17:29:58 +0100364 if (FLAG_plot_incoming_layer_bitrate_allocation) {
365 analyzer.CreateBitrateAllocationGraph(webrtc::kIncomingPacket,
366 collection->AppendNewPlot());
367 }
368 if (FLAG_plot_outgoing_layer_bitrate_allocation) {
369 analyzer.CreateBitrateAllocationGraph(webrtc::kOutgoingPacket,
370 collection->AppendNewPlot());
371 }
Bjorn Terelius28db2662017-10-04 14:22:43 +0200372 if (FLAG_plot_simulated_receiveside_bwe) {
373 analyzer.CreateReceiveSideBweSimulationGraph(collection->AppendNewPlot());
374 }
terelius2ee076d2017-08-15 02:04:02 -0700375 if (FLAG_plot_simulated_sendside_bwe) {
Bjorn Terelius28db2662017-10-04 14:22:43 +0200376 analyzer.CreateSendSideBweSimulationGraph(collection->AppendNewPlot());
Stefan Holmer13181032016-07-29 14:48:54 +0200377 }
Sebastian Jansson1175ae02019-03-13 08:56:58 +0100378 if (FLAG_plot_simulated_goog_cc) {
379 analyzer.CreateGoogCcSimulationGraph(collection->AppendNewPlot());
380 }
terelius2ee076d2017-08-15 02:04:02 -0700381 if (FLAG_plot_network_delay_feedback) {
tereliuse34c19c2016-08-15 08:47:14 -0700382 analyzer.CreateNetworkDelayFeedbackGraph(collection->AppendNewPlot());
stefanc3de0332016-08-02 07:22:17 -0700383 }
terelius2ee076d2017-08-15 02:04:02 -0700384 if (FLAG_plot_fraction_loss_feedback) {
385 analyzer.CreateFractionLossGraph(collection->AppendNewPlot());
386 }
387 if (FLAG_plot_timestamps) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200388 analyzer.CreateTimestampGraph(webrtc::kIncomingPacket,
389 collection->AppendNewPlot());
390 analyzer.CreateTimestampGraph(webrtc::kOutgoingPacket,
391 collection->AppendNewPlot());
stefane372d3c2017-02-02 08:04:18 -0800392 }
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200393 if (FLAG_plot_rtcp_details) {
394 auto GetFractionLost = [](const webrtc::rtcp::ReportBlock& block) -> float {
395 return static_cast<double>(block.fraction_lost()) / 256 * 100;
396 };
397 analyzer.CreateSenderAndReceiverReportPlot(
398 webrtc::kIncomingPacket, GetFractionLost,
399 "Fraction lost (incoming RTCP)", "Loss rate (percent)",
400 collection->AppendNewPlot());
401 analyzer.CreateSenderAndReceiverReportPlot(
402 webrtc::kOutgoingPacket, GetFractionLost,
403 "Fraction lost (outgoing RTCP)", "Loss rate (percent)",
404 collection->AppendNewPlot());
405
406 auto GetCumulativeLost =
407 [](const webrtc::rtcp::ReportBlock& block) -> float {
408 return block.cumulative_lost_signed();
409 };
410 analyzer.CreateSenderAndReceiverReportPlot(
411 webrtc::kIncomingPacket, GetCumulativeLost,
412 "Cumulative lost packets (incoming RTCP)", "Packets",
413 collection->AppendNewPlot());
414 analyzer.CreateSenderAndReceiverReportPlot(
415 webrtc::kOutgoingPacket, GetCumulativeLost,
416 "Cumulative lost packets (outgoing RTCP)", "Packets",
417 collection->AppendNewPlot());
418
419 auto GetHighestSeqNumber =
420 [](const webrtc::rtcp::ReportBlock& block) -> float {
421 return block.extended_high_seq_num();
422 };
423 analyzer.CreateSenderAndReceiverReportPlot(
424 webrtc::kIncomingPacket, GetHighestSeqNumber,
Bjorn Tereliusef73f592018-09-10 20:11:49 +0200425 "Highest sequence number (incoming RTCP)", "Sequence number",
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200426 collection->AppendNewPlot());
427 analyzer.CreateSenderAndReceiverReportPlot(
428 webrtc::kOutgoingPacket, GetHighestSeqNumber,
Bjorn Tereliusef73f592018-09-10 20:11:49 +0200429 "Highest sequence number (outgoing RTCP)", "Sequence number",
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200430 collection->AppendNewPlot());
431
432 auto DelaySinceLastSr =
433 [](const webrtc::rtcp::ReportBlock& block) -> float {
434 return static_cast<double>(block.delay_since_last_sr()) / 65536;
435 };
436 analyzer.CreateSenderAndReceiverReportPlot(
437 webrtc::kIncomingPacket, DelaySinceLastSr,
438 "Delay since last received sender report (incoming RTCP)", "Time (s)",
439 collection->AppendNewPlot());
440 analyzer.CreateSenderAndReceiverReportPlot(
441 webrtc::kOutgoingPacket, DelaySinceLastSr,
442 "Delay since last received sender report (outgoing RTCP)", "Time (s)",
443 collection->AppendNewPlot());
444 }
445
Bjorn Terelius0295a962017-10-25 17:42:41 +0200446 if (FLAG_plot_pacer_delay) {
447 analyzer.CreatePacerDelayGraph(collection->AppendNewPlot());
448 }
terelius2ee076d2017-08-15 02:04:02 -0700449 if (FLAG_plot_audio_encoder_bitrate_bps) {
michaelt6e5b2192017-02-22 07:33:27 -0800450 analyzer.CreateAudioEncoderTargetBitrateGraph(collection->AppendNewPlot());
451 }
terelius2ee076d2017-08-15 02:04:02 -0700452 if (FLAG_plot_audio_encoder_frame_length_ms) {
michaelt6e5b2192017-02-22 07:33:27 -0800453 analyzer.CreateAudioEncoderFrameLengthGraph(collection->AppendNewPlot());
454 }
terelius2ee076d2017-08-15 02:04:02 -0700455 if (FLAG_plot_audio_encoder_packet_loss) {
456 analyzer.CreateAudioEncoderPacketLossGraph(collection->AppendNewPlot());
michaelt6e5b2192017-02-22 07:33:27 -0800457 }
terelius2ee076d2017-08-15 02:04:02 -0700458 if (FLAG_plot_audio_encoder_fec) {
michaelt6e5b2192017-02-22 07:33:27 -0800459 analyzer.CreateAudioEncoderEnableFecGraph(collection->AppendNewPlot());
460 }
terelius2ee076d2017-08-15 02:04:02 -0700461 if (FLAG_plot_audio_encoder_dtx) {
michaelt6e5b2192017-02-22 07:33:27 -0800462 analyzer.CreateAudioEncoderEnableDtxGraph(collection->AppendNewPlot());
463 }
terelius2ee076d2017-08-15 02:04:02 -0700464 if (FLAG_plot_audio_encoder_num_channels) {
michaelt6e5b2192017-02-22 07:33:27 -0800465 analyzer.CreateAudioEncoderNumChannelsGraph(collection->AppendNewPlot());
466 }
Minyue Li27e2b7d2018-05-07 15:20:24 +0200467 if (FLAG_plot_neteq_stats) {
owb7fbeb0b2017-08-16 02:48:33 -0700468 std::string wav_path;
469 if (FLAG_wav_filename[0] != '\0') {
470 wav_path = FLAG_wav_filename;
471 } else {
472 wav_path = webrtc::test::ResourcePath(
473 "audio_processing/conversational_speech/EN_script2_F_sp2_B1", "wav");
474 }
Minyue Lic6ff7572018-05-04 09:46:44 +0200475 auto neteq_stats = analyzer.SimulateNetEq(wav_path, 48000);
Minyue Li01d2a672018-06-21 21:17:19 +0200476 for (webrtc::EventLogAnalyzer::NetEqStatsGetterMap::const_iterator it =
477 neteq_stats.cbegin();
478 it != neteq_stats.cend(); ++it) {
479 analyzer.CreateAudioJitterBufferGraph(it->first, it->second.get(),
Minyue Li45fc6df2018-06-21 11:47:14 +0200480 collection->AppendNewPlot());
481 }
Minyue Lic9ac93f2018-06-26 13:01:32 +0200482 analyzer.CreateNetEqNetworkStatsGraph(
Minyue Li27e2b7d2018-05-07 15:20:24 +0200483 neteq_stats,
484 [](const webrtc::NetEqNetworkStatistics& stats) {
485 return stats.expand_rate / 16384.f;
486 },
487 "Expand rate", collection->AppendNewPlot());
Minyue Lic9ac93f2018-06-26 13:01:32 +0200488 analyzer.CreateNetEqNetworkStatsGraph(
Minyue Li27e2b7d2018-05-07 15:20:24 +0200489 neteq_stats,
490 [](const webrtc::NetEqNetworkStatistics& stats) {
491 return stats.speech_expand_rate / 16384.f;
492 },
493 "Speech expand rate", collection->AppendNewPlot());
Minyue Lic9ac93f2018-06-26 13:01:32 +0200494 analyzer.CreateNetEqNetworkStatsGraph(
Minyue Li27e2b7d2018-05-07 15:20:24 +0200495 neteq_stats,
496 [](const webrtc::NetEqNetworkStatistics& stats) {
497 return stats.accelerate_rate / 16384.f;
498 },
499 "Accelerate rate", collection->AppendNewPlot());
Minyue Lic9ac93f2018-06-26 13:01:32 +0200500 analyzer.CreateNetEqNetworkStatsGraph(
Minyue Li27e2b7d2018-05-07 15:20:24 +0200501 neteq_stats,
502 [](const webrtc::NetEqNetworkStatistics& stats) {
Jakob Ivarsson21f6fd72019-04-04 10:15:02 +0200503 return stats.preemptive_rate / 16384.f;
504 },
505 "Preemptive rate", collection->AppendNewPlot());
506 analyzer.CreateNetEqNetworkStatsGraph(
507 neteq_stats,
508 [](const webrtc::NetEqNetworkStatistics& stats) {
Minyue Li27e2b7d2018-05-07 15:20:24 +0200509 return stats.packet_loss_rate / 16384.f;
510 },
511 "Packet loss rate", collection->AppendNewPlot());
Minyue Lic9ac93f2018-06-26 13:01:32 +0200512 analyzer.CreateNetEqLifetimeStatsGraph(
513 neteq_stats,
514 [](const webrtc::NetEqLifetimeStatistics& stats) {
515 return static_cast<float>(stats.concealment_events);
516 },
517 "Concealment events", collection->AppendNewPlot());
Jakob Ivarsson21f6fd72019-04-04 10:15:02 +0200518 analyzer.CreateNetEqNetworkStatsGraph(
519 neteq_stats,
520 [](const webrtc::NetEqNetworkStatistics& stats) {
521 return stats.preferred_buffer_size_ms;
522 },
523 "Preferred buffer size (ms)", collection->AppendNewPlot());
henrik.lundin3c938fc2017-06-14 06:09:58 -0700524 }
525
Qingsi Wang8eca1ff2018-02-02 11:49:44 -0800526 if (FLAG_plot_ice_candidate_pair_config) {
527 analyzer.CreateIceCandidatePairConfigGraph(collection->AppendNewPlot());
528 }
529 if (FLAG_plot_ice_connectivity_check) {
530 analyzer.CreateIceConnectivityCheckGraph(collection->AppendNewPlot());
531 }
532
Zach Stein10a58012018-12-07 12:26:28 -0800533 if (FLAG_plot_dtls_transport_state) {
534 analyzer.CreateDtlsTransportStateGraph(collection->AppendNewPlot());
535 }
536 if (FLAG_plot_dtls_writable_state) {
537 analyzer.CreateDtlsWritableStateGraph(collection->AppendNewPlot());
538 }
539
tereliusdc35dcd2016-08-01 12:03:27 -0700540 collection->Draw();
terelius54ce6802016-07-13 06:44:41 -0700541
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200542 if (FLAG_print_triage_alerts) {
Bjorn Terelius2eb31882017-11-30 15:15:25 +0100543 analyzer.CreateTriageNotifications();
544 analyzer.PrintNotifications(stderr);
545 }
546
terelius54ce6802016-07-13 06:44:41 -0700547 return 0;
548}
terelius2ee076d2017-08-15 02:04:02 -0700549
terelius2ee076d2017-08-15 02:04:02 -0700550void SetAllPlotFlags(bool setting) {
551 FLAG_plot_incoming_packet_sizes = setting;
552 FLAG_plot_outgoing_packet_sizes = setting;
Bjorn Terelius7c974e62019-02-15 17:20:12 +0100553 FLAG_plot_incoming_rtcp_types = setting;
554 FLAG_plot_outgoing_rtcp_types = setting;
terelius2ee076d2017-08-15 02:04:02 -0700555 FLAG_plot_incoming_packet_count = setting;
556 FLAG_plot_outgoing_packet_count = setting;
557 FLAG_plot_audio_playout = setting;
558 FLAG_plot_audio_level = setting;
559 FLAG_plot_incoming_sequence_number_delta = setting;
terelius2ee076d2017-08-15 02:04:02 -0700560 FLAG_plot_incoming_delay = setting;
561 FLAG_plot_incoming_loss_rate = setting;
562 FLAG_plot_incoming_bitrate = setting;
563 FLAG_plot_outgoing_bitrate = setting;
564 FLAG_plot_incoming_stream_bitrate = setting;
565 FLAG_plot_outgoing_stream_bitrate = setting;
Bjorn Terelius9775a582019-02-15 17:29:58 +0100566 FLAG_plot_incoming_layer_bitrate_allocation = setting;
567 FLAG_plot_outgoing_layer_bitrate_allocation = setting;
Bjorn Terelius28db2662017-10-04 14:22:43 +0200568 FLAG_plot_simulated_receiveside_bwe = setting;
terelius2ee076d2017-08-15 02:04:02 -0700569 FLAG_plot_simulated_sendside_bwe = setting;
Sebastian Jansson1175ae02019-03-13 08:56:58 +0100570 FLAG_plot_simulated_goog_cc = setting;
terelius2ee076d2017-08-15 02:04:02 -0700571 FLAG_plot_network_delay_feedback = setting;
572 FLAG_plot_fraction_loss_feedback = setting;
573 FLAG_plot_timestamps = setting;
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200574 FLAG_plot_rtcp_details = setting;
terelius2ee076d2017-08-15 02:04:02 -0700575 FLAG_plot_audio_encoder_bitrate_bps = setting;
576 FLAG_plot_audio_encoder_frame_length_ms = setting;
577 FLAG_plot_audio_encoder_packet_loss = setting;
578 FLAG_plot_audio_encoder_fec = setting;
579 FLAG_plot_audio_encoder_dtx = setting;
580 FLAG_plot_audio_encoder_num_channels = setting;
Minyue Li27e2b7d2018-05-07 15:20:24 +0200581 FLAG_plot_neteq_stats = setting;
Qingsi Wang8eca1ff2018-02-02 11:49:44 -0800582 FLAG_plot_ice_candidate_pair_config = setting;
583 FLAG_plot_ice_connectivity_check = setting;
Konrad Hofbauerca3c8012019-02-15 20:52:19 +0100584 FLAG_plot_pacer_delay = setting;
terelius2ee076d2017-08-15 02:04:02 -0700585}