blob: 7992b1c9aa248c27f49ca220c6c6b5f9a9fd814c [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.");
Bjorn Terelius9775a582019-02-15 17:29:58 +010097WEBRTC_DEFINE_bool(plot_incoming_layer_bitrate_allocation,
98 false,
99 "Plot the target bitrate for each incoming layer. Requires "
100 "incoming RTCP XR with target bitrate to be populated.");
101WEBRTC_DEFINE_bool(plot_outgoing_layer_bitrate_allocation,
102 false,
103 "Plot the target bitrate for each outgoing layer. Requires "
104 "outgoing RTCP XR with target bitrate to be populated.");
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200105WEBRTC_DEFINE_bool(
106 plot_simulated_receiveside_bwe,
107 false,
108 "Run the receive-side bandwidth estimator with the incoming rtp "
109 "packets and plot the resulting estimate.");
110WEBRTC_DEFINE_bool(
111 plot_simulated_sendside_bwe,
112 false,
113 "Run the send-side bandwidth estimator with the outgoing rtp and "
114 "incoming rtcp and plot the resulting estimate.");
Sebastian Jansson1175ae02019-03-13 08:56:58 +0100115WEBRTC_DEFINE_bool(plot_simulated_goog_cc,
116 false,
117 "Run the GoogCC congestion controller based on the logged "
118 "events and plot the target bitrate.");
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200119WEBRTC_DEFINE_bool(
120 plot_network_delay_feedback,
121 true,
122 "Compute network delay based on sent packets and the received "
123 "transport feedback.");
124WEBRTC_DEFINE_bool(
125 plot_fraction_loss_feedback,
126 true,
127 "Plot packet loss in percent for outgoing packets (as perceived by "
128 "the send-side bandwidth estimator).");
129WEBRTC_DEFINE_bool(
130 plot_pacer_delay,
131 false,
132 "Plot the time each sent packet has spent in the pacer (based on "
133 "the difference between the RTP timestamp and the send "
134 "timestamp).");
135WEBRTC_DEFINE_bool(
136 plot_timestamps,
137 false,
138 "Plot the rtp timestamps of all rtp and rtcp packets over time.");
139WEBRTC_DEFINE_bool(
140 plot_rtcp_details,
141 false,
142 "Plot the contents of all report blocks in all sender and receiver "
143 "reports. This includes fraction lost, cumulative number of lost "
144 "packets, extended highest sequence number and time since last "
145 "received SR.");
146WEBRTC_DEFINE_bool(plot_audio_encoder_bitrate_bps,
147 false,
148 "Plot the audio encoder target bitrate.");
149WEBRTC_DEFINE_bool(plot_audio_encoder_frame_length_ms,
150 false,
151 "Plot the audio encoder frame length.");
152WEBRTC_DEFINE_bool(
terelius2ee076d2017-08-15 02:04:02 -0700153 plot_audio_encoder_packet_loss,
michaelt6e5b2192017-02-22 07:33:27 -0800154 false,
terelius2ee076d2017-08-15 02:04:02 -0700155 "Plot the uplink packet loss fraction which is sent to the audio encoder.");
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200156WEBRTC_DEFINE_bool(plot_audio_encoder_fec,
157 false,
158 "Plot the audio encoder FEC.");
159WEBRTC_DEFINE_bool(plot_audio_encoder_dtx,
160 false,
161 "Plot the audio encoder DTX.");
162WEBRTC_DEFINE_bool(plot_audio_encoder_num_channels,
163 false,
164 "Plot the audio encoder number of channels.");
165WEBRTC_DEFINE_bool(plot_neteq_stats, false, "Plot the NetEq statistics.");
166WEBRTC_DEFINE_bool(plot_ice_candidate_pair_config,
167 false,
168 "Plot the ICE candidate pair config events.");
169WEBRTC_DEFINE_bool(plot_ice_connectivity_check,
170 false,
171 "Plot the ICE candidate pair connectivity checks.");
Zach Stein10a58012018-12-07 12:26:28 -0800172WEBRTC_DEFINE_bool(plot_dtls_transport_state,
173 false,
174 "Plot DTLS transport state changes.");
175WEBRTC_DEFINE_bool(plot_dtls_writable_state,
176 false,
177 "Plot DTLS writable state changes.");
Bjorn Terelius1edfff92017-10-11 13:15:19 +0200178
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200179WEBRTC_DEFINE_string(
stefan985d2802016-11-15 06:54:09 -0800180 force_fieldtrials,
181 "",
182 "Field trials control experimental feature code which can be forced. "
183 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enabled/"
184 " will assign the group Enabled to field trial WebRTC-FooFeature. Multiple "
185 "trials are separated by \"/\"");
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200186WEBRTC_DEFINE_string(wav_filename,
187 "",
188 "Path to wav file used for simulation of jitter buffer");
189WEBRTC_DEFINE_bool(help, false, "prints this message");
terelius54ce6802016-07-13 06:44:41 -0700190
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200191WEBRTC_DEFINE_bool(
192 show_detector_state,
193 false,
194 "Show the state of the delay based BWE detector on the total "
195 "bitrate graph");
terelius2ee076d2017-08-15 02:04:02 -0700196
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200197WEBRTC_DEFINE_bool(show_alr_state,
198 false,
199 "Show the state ALR state on the total bitrate graph");
Ilya Nikolaevskiya4259f62017-12-05 13:19:45 +0100200
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200201WEBRTC_DEFINE_bool(
202 parse_unconfigured_header_extensions,
203 true,
204 "Attempt to parse unconfigured header extensions using the default "
205 "WebRTC mapping. This can give very misleading results if the "
206 "application negotiates a different mapping.");
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200207
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200208WEBRTC_DEFINE_bool(print_triage_alerts,
209 false,
210 "Print triage alerts, i.e. a list of potential problems.");
Bjorn Terelius2eb31882017-11-30 15:15:25 +0100211
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200212WEBRTC_DEFINE_bool(
213 normalize_time,
214 true,
215 "Normalize the log timestamps so that the call starts at time 0.");
Stefan Holmer1d4a2272018-05-24 13:48:09 +0200216
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200217WEBRTC_DEFINE_bool(protobuf_output,
218 false,
219 "Output charts as protobuf instead of python code.");
Bjorn Tereliusef73f592018-09-10 20:11:49 +0200220
terelius2ee076d2017-08-15 02:04:02 -0700221void SetAllPlotFlags(bool setting);
222
terelius54ce6802016-07-13 06:44:41 -0700223int main(int argc, char* argv[]) {
224 std::string program_name = argv[0];
225 std::string usage =
226 "A tool for visualizing WebRTC event logs.\n"
227 "Example usage:\n" +
228 program_name + " <logfile> | python\n" + "Run " + program_name +
229 " --help for a list of command line options\n";
terelius2ee076d2017-08-15 02:04:02 -0700230
231 // Parse command line flags without removing them. We're only interested in
232 // the |plot_profile| flag.
233 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, false);
234 if (strcmp(FLAG_plot_profile, "all") == 0) {
235 SetAllPlotFlags(true);
236 } else if (strcmp(FLAG_plot_profile, "none") == 0) {
237 SetAllPlotFlags(false);
Bjorn Terelius1edfff92017-10-11 13:15:19 +0200238 } else if (strcmp(FLAG_plot_profile, "sendside_bwe") == 0) {
239 SetAllPlotFlags(false);
240 FLAG_plot_outgoing_packet_sizes = true;
241 FLAG_plot_outgoing_bitrate = true;
242 FLAG_plot_outgoing_stream_bitrate = true;
243 FLAG_plot_simulated_sendside_bwe = true;
244 FLAG_plot_network_delay_feedback = true;
245 FLAG_plot_fraction_loss_feedback = true;
246 } else if (strcmp(FLAG_plot_profile, "receiveside_bwe") == 0) {
247 SetAllPlotFlags(false);
248 FLAG_plot_incoming_packet_sizes = true;
Bjorn Terelius1edfff92017-10-11 13:15:19 +0200249 FLAG_plot_incoming_delay = true;
250 FLAG_plot_incoming_loss_rate = true;
251 FLAG_plot_incoming_bitrate = true;
252 FLAG_plot_incoming_stream_bitrate = true;
253 FLAG_plot_simulated_receiveside_bwe = true;
terelius2ee076d2017-08-15 02:04:02 -0700254 } else if (strcmp(FLAG_plot_profile, "default") == 0) {
255 // Do nothing.
256 } else {
257 rtc::Flag* plot_profile_flag = rtc::FlagList::Lookup("plot_profile");
258 RTC_CHECK(plot_profile_flag);
259 plot_profile_flag->Print(false);
260 }
261 // Parse the remaining flags. They are applied relative to the chosen profile.
kjellander4fa5be42017-05-16 00:01:23 -0700262 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
terelius2ee076d2017-08-15 02:04:02 -0700263
tereliusc4a5c142017-07-20 08:05:09 -0700264 if (argc != 2 || FLAG_help) {
kjellander4fa5be42017-05-16 00:01:23 -0700265 // Print usage information.
266 std::cout << usage;
tereliusc4a5c142017-07-20 08:05:09 -0700267 if (FLAG_help)
268 rtc::FlagList::Print(nullptr, false);
kjellander4fa5be42017-05-16 00:01:23 -0700269 return 0;
270 }
271
Bjorn Tereliusedab3012018-01-31 17:23:40 +0100272 webrtc::test::ValidateFieldTrialsStringOrDie(FLAG_force_fieldtrials);
273 // InitFieldTrialsFromString stores the char*, so the char array must outlive
274 // the application.
275 webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials);
stefan985d2802016-11-15 06:54:09 -0800276
terelius54ce6802016-07-13 06:44:41 -0700277 std::string filename = argv[1];
278
Sebastian Janssonb290a6d2019-01-03 14:46:23 +0100279 webrtc::ParsedRtcEventLog::UnconfiguredHeaderExtensions header_extensions =
280 webrtc::ParsedRtcEventLog::UnconfiguredHeaderExtensions::kDontParse;
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200281 if (FLAG_parse_unconfigured_header_extensions) {
Sebastian Janssonb290a6d2019-01-03 14:46:23 +0100282 header_extensions = webrtc::ParsedRtcEventLog::
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200283 UnconfiguredHeaderExtensions::kAttemptWebrtcDefaultConfig;
284 }
Sebastian Janssonb290a6d2019-01-03 14:46:23 +0100285 webrtc::ParsedRtcEventLog parsed_log(header_extensions);
terelius54ce6802016-07-13 06:44:41 -0700286
287 if (!parsed_log.ParseFile(filename)) {
288 std::cerr << "Could not parse the entire log file." << std::endl;
Bjorn Tereliusfdc635d2018-11-14 13:40:13 +0100289 std::cerr << "Only the parsable events will be analyzed." << std::endl;
terelius54ce6802016-07-13 06:44:41 -0700290 }
291
Stefan Holmer1d4a2272018-05-24 13:48:09 +0200292 webrtc::EventLogAnalyzer analyzer(parsed_log, FLAG_normalize_time);
Bjorn Tereliusef73f592018-09-10 20:11:49 +0200293 std::unique_ptr<webrtc::PlotCollection> collection;
294 if (FLAG_protobuf_output) {
295 collection.reset(new webrtc::ProtobufPlotCollection());
296 } else {
297 collection.reset(new webrtc::PythonPlotCollection());
298 }
terelius54ce6802016-07-13 06:44:41 -0700299
terelius2ee076d2017-08-15 02:04:02 -0700300 if (FLAG_plot_incoming_packet_sizes) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200301 analyzer.CreatePacketGraph(webrtc::kIncomingPacket,
terelius2ee076d2017-08-15 02:04:02 -0700302 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700303 }
terelius2ee076d2017-08-15 02:04:02 -0700304 if (FLAG_plot_outgoing_packet_sizes) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200305 analyzer.CreatePacketGraph(webrtc::kOutgoingPacket,
terelius2ee076d2017-08-15 02:04:02 -0700306 collection->AppendNewPlot());
307 }
Bjorn Terelius7c974e62019-02-15 17:20:12 +0100308 if (FLAG_plot_incoming_rtcp_types) {
309 analyzer.CreateRtcpTypeGraph(webrtc::kIncomingPacket,
310 collection->AppendNewPlot());
311 }
312 if (FLAG_plot_outgoing_rtcp_types) {
313 analyzer.CreateRtcpTypeGraph(webrtc::kOutgoingPacket,
314 collection->AppendNewPlot());
315 }
terelius2ee076d2017-08-15 02:04:02 -0700316 if (FLAG_plot_incoming_packet_count) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200317 analyzer.CreateAccumulatedPacketsGraph(webrtc::kIncomingPacket,
318 collection->AppendNewPlot());
terelius2ee076d2017-08-15 02:04:02 -0700319 }
320 if (FLAG_plot_outgoing_packet_count) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200321 analyzer.CreateAccumulatedPacketsGraph(webrtc::kOutgoingPacket,
322 collection->AppendNewPlot());
terelius2ee076d2017-08-15 02:04:02 -0700323 }
324 if (FLAG_plot_audio_playout) {
tereliusdc35dcd2016-08-01 12:03:27 -0700325 analyzer.CreatePlayoutGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700326 }
terelius2ee076d2017-08-15 02:04:02 -0700327 if (FLAG_plot_audio_level) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200328 analyzer.CreateAudioLevelGraph(webrtc::kIncomingPacket,
329 collection->AppendNewPlot());
330 analyzer.CreateAudioLevelGraph(webrtc::kOutgoingPacket,
331 collection->AppendNewPlot());
ivocaac9d6f2016-09-22 07:01:47 -0700332 }
terelius2ee076d2017-08-15 02:04:02 -0700333 if (FLAG_plot_incoming_sequence_number_delta) {
334 analyzer.CreateSequenceNumberGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700335 }
terelius2ee076d2017-08-15 02:04:02 -0700336 if (FLAG_plot_incoming_delay) {
337 analyzer.CreateIncomingDelayGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700338 }
terelius2ee076d2017-08-15 02:04:02 -0700339 if (FLAG_plot_incoming_loss_rate) {
Stefan Holmer99f8e082016-09-09 13:37:50 +0200340 analyzer.CreateIncomingPacketLossGraph(collection->AppendNewPlot());
tereliusf736d232016-08-04 10:00:11 -0700341 }
terelius2ee076d2017-08-15 02:04:02 -0700342 if (FLAG_plot_incoming_bitrate) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200343 analyzer.CreateTotalIncomingBitrateGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700344 }
terelius2ee076d2017-08-15 02:04:02 -0700345 if (FLAG_plot_outgoing_bitrate) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200346 analyzer.CreateTotalOutgoingBitrateGraph(collection->AppendNewPlot(),
347 FLAG_show_detector_state,
348 FLAG_show_alr_state);
terelius54ce6802016-07-13 06:44:41 -0700349 }
terelius2ee076d2017-08-15 02:04:02 -0700350 if (FLAG_plot_incoming_stream_bitrate) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200351 analyzer.CreateStreamBitrateGraph(webrtc::kIncomingPacket,
terelius2ee076d2017-08-15 02:04:02 -0700352 collection->AppendNewPlot());
353 }
354 if (FLAG_plot_outgoing_stream_bitrate) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200355 analyzer.CreateStreamBitrateGraph(webrtc::kOutgoingPacket,
terelius2ee076d2017-08-15 02:04:02 -0700356 collection->AppendNewPlot());
357 }
Bjorn Terelius9775a582019-02-15 17:29:58 +0100358 if (FLAG_plot_incoming_layer_bitrate_allocation) {
359 analyzer.CreateBitrateAllocationGraph(webrtc::kIncomingPacket,
360 collection->AppendNewPlot());
361 }
362 if (FLAG_plot_outgoing_layer_bitrate_allocation) {
363 analyzer.CreateBitrateAllocationGraph(webrtc::kOutgoingPacket,
364 collection->AppendNewPlot());
365 }
Bjorn Terelius28db2662017-10-04 14:22:43 +0200366 if (FLAG_plot_simulated_receiveside_bwe) {
367 analyzer.CreateReceiveSideBweSimulationGraph(collection->AppendNewPlot());
368 }
terelius2ee076d2017-08-15 02:04:02 -0700369 if (FLAG_plot_simulated_sendside_bwe) {
Bjorn Terelius28db2662017-10-04 14:22:43 +0200370 analyzer.CreateSendSideBweSimulationGraph(collection->AppendNewPlot());
Stefan Holmer13181032016-07-29 14:48:54 +0200371 }
Sebastian Jansson1175ae02019-03-13 08:56:58 +0100372 if (FLAG_plot_simulated_goog_cc) {
373 analyzer.CreateGoogCcSimulationGraph(collection->AppendNewPlot());
374 }
terelius2ee076d2017-08-15 02:04:02 -0700375 if (FLAG_plot_network_delay_feedback) {
tereliuse34c19c2016-08-15 08:47:14 -0700376 analyzer.CreateNetworkDelayFeedbackGraph(collection->AppendNewPlot());
stefanc3de0332016-08-02 07:22:17 -0700377 }
terelius2ee076d2017-08-15 02:04:02 -0700378 if (FLAG_plot_fraction_loss_feedback) {
379 analyzer.CreateFractionLossGraph(collection->AppendNewPlot());
380 }
381 if (FLAG_plot_timestamps) {
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200382 analyzer.CreateTimestampGraph(webrtc::kIncomingPacket,
383 collection->AppendNewPlot());
384 analyzer.CreateTimestampGraph(webrtc::kOutgoingPacket,
385 collection->AppendNewPlot());
stefane372d3c2017-02-02 08:04:18 -0800386 }
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200387 if (FLAG_plot_rtcp_details) {
388 auto GetFractionLost = [](const webrtc::rtcp::ReportBlock& block) -> float {
389 return static_cast<double>(block.fraction_lost()) / 256 * 100;
390 };
391 analyzer.CreateSenderAndReceiverReportPlot(
392 webrtc::kIncomingPacket, GetFractionLost,
393 "Fraction lost (incoming RTCP)", "Loss rate (percent)",
394 collection->AppendNewPlot());
395 analyzer.CreateSenderAndReceiverReportPlot(
396 webrtc::kOutgoingPacket, GetFractionLost,
397 "Fraction lost (outgoing RTCP)", "Loss rate (percent)",
398 collection->AppendNewPlot());
399
400 auto GetCumulativeLost =
401 [](const webrtc::rtcp::ReportBlock& block) -> float {
402 return block.cumulative_lost_signed();
403 };
404 analyzer.CreateSenderAndReceiverReportPlot(
405 webrtc::kIncomingPacket, GetCumulativeLost,
406 "Cumulative lost packets (incoming RTCP)", "Packets",
407 collection->AppendNewPlot());
408 analyzer.CreateSenderAndReceiverReportPlot(
409 webrtc::kOutgoingPacket, GetCumulativeLost,
410 "Cumulative lost packets (outgoing RTCP)", "Packets",
411 collection->AppendNewPlot());
412
413 auto GetHighestSeqNumber =
414 [](const webrtc::rtcp::ReportBlock& block) -> float {
415 return block.extended_high_seq_num();
416 };
417 analyzer.CreateSenderAndReceiverReportPlot(
418 webrtc::kIncomingPacket, GetHighestSeqNumber,
Bjorn Tereliusef73f592018-09-10 20:11:49 +0200419 "Highest sequence number (incoming RTCP)", "Sequence number",
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200420 collection->AppendNewPlot());
421 analyzer.CreateSenderAndReceiverReportPlot(
422 webrtc::kOutgoingPacket, GetHighestSeqNumber,
Bjorn Tereliusef73f592018-09-10 20:11:49 +0200423 "Highest sequence number (outgoing RTCP)", "Sequence number",
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200424 collection->AppendNewPlot());
425
426 auto DelaySinceLastSr =
427 [](const webrtc::rtcp::ReportBlock& block) -> float {
428 return static_cast<double>(block.delay_since_last_sr()) / 65536;
429 };
430 analyzer.CreateSenderAndReceiverReportPlot(
431 webrtc::kIncomingPacket, DelaySinceLastSr,
432 "Delay since last received sender report (incoming RTCP)", "Time (s)",
433 collection->AppendNewPlot());
434 analyzer.CreateSenderAndReceiverReportPlot(
435 webrtc::kOutgoingPacket, DelaySinceLastSr,
436 "Delay since last received sender report (outgoing RTCP)", "Time (s)",
437 collection->AppendNewPlot());
438 }
439
Bjorn Terelius0295a962017-10-25 17:42:41 +0200440 if (FLAG_plot_pacer_delay) {
441 analyzer.CreatePacerDelayGraph(collection->AppendNewPlot());
442 }
terelius2ee076d2017-08-15 02:04:02 -0700443 if (FLAG_plot_audio_encoder_bitrate_bps) {
michaelt6e5b2192017-02-22 07:33:27 -0800444 analyzer.CreateAudioEncoderTargetBitrateGraph(collection->AppendNewPlot());
445 }
terelius2ee076d2017-08-15 02:04:02 -0700446 if (FLAG_plot_audio_encoder_frame_length_ms) {
michaelt6e5b2192017-02-22 07:33:27 -0800447 analyzer.CreateAudioEncoderFrameLengthGraph(collection->AppendNewPlot());
448 }
terelius2ee076d2017-08-15 02:04:02 -0700449 if (FLAG_plot_audio_encoder_packet_loss) {
450 analyzer.CreateAudioEncoderPacketLossGraph(collection->AppendNewPlot());
michaelt6e5b2192017-02-22 07:33:27 -0800451 }
terelius2ee076d2017-08-15 02:04:02 -0700452 if (FLAG_plot_audio_encoder_fec) {
michaelt6e5b2192017-02-22 07:33:27 -0800453 analyzer.CreateAudioEncoderEnableFecGraph(collection->AppendNewPlot());
454 }
terelius2ee076d2017-08-15 02:04:02 -0700455 if (FLAG_plot_audio_encoder_dtx) {
michaelt6e5b2192017-02-22 07:33:27 -0800456 analyzer.CreateAudioEncoderEnableDtxGraph(collection->AppendNewPlot());
457 }
terelius2ee076d2017-08-15 02:04:02 -0700458 if (FLAG_plot_audio_encoder_num_channels) {
michaelt6e5b2192017-02-22 07:33:27 -0800459 analyzer.CreateAudioEncoderNumChannelsGraph(collection->AppendNewPlot());
460 }
Minyue Li27e2b7d2018-05-07 15:20:24 +0200461 if (FLAG_plot_neteq_stats) {
owb7fbeb0b2017-08-16 02:48:33 -0700462 std::string wav_path;
463 if (FLAG_wav_filename[0] != '\0') {
464 wav_path = FLAG_wav_filename;
465 } else {
466 wav_path = webrtc::test::ResourcePath(
467 "audio_processing/conversational_speech/EN_script2_F_sp2_B1", "wav");
468 }
Minyue Lic6ff7572018-05-04 09:46:44 +0200469 auto neteq_stats = analyzer.SimulateNetEq(wav_path, 48000);
Minyue Li01d2a672018-06-21 21:17:19 +0200470 for (webrtc::EventLogAnalyzer::NetEqStatsGetterMap::const_iterator it =
471 neteq_stats.cbegin();
472 it != neteq_stats.cend(); ++it) {
473 analyzer.CreateAudioJitterBufferGraph(it->first, it->second.get(),
Minyue Li45fc6df2018-06-21 11:47:14 +0200474 collection->AppendNewPlot());
475 }
Minyue Lic9ac93f2018-06-26 13:01:32 +0200476 analyzer.CreateNetEqNetworkStatsGraph(
Minyue Li27e2b7d2018-05-07 15:20:24 +0200477 neteq_stats,
478 [](const webrtc::NetEqNetworkStatistics& stats) {
479 return stats.expand_rate / 16384.f;
480 },
481 "Expand rate", collection->AppendNewPlot());
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.speech_expand_rate / 16384.f;
486 },
487 "Speech 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.accelerate_rate / 16384.f;
492 },
493 "Accelerate 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) {
Jakob Ivarsson21f6fd72019-04-04 10:15:02 +0200497 return stats.preemptive_rate / 16384.f;
498 },
499 "Preemptive rate", collection->AppendNewPlot());
500 analyzer.CreateNetEqNetworkStatsGraph(
501 neteq_stats,
502 [](const webrtc::NetEqNetworkStatistics& stats) {
Minyue Li27e2b7d2018-05-07 15:20:24 +0200503 return stats.packet_loss_rate / 16384.f;
504 },
505 "Packet loss rate", collection->AppendNewPlot());
Minyue Lic9ac93f2018-06-26 13:01:32 +0200506 analyzer.CreateNetEqLifetimeStatsGraph(
507 neteq_stats,
508 [](const webrtc::NetEqLifetimeStatistics& stats) {
509 return static_cast<float>(stats.concealment_events);
510 },
511 "Concealment events", collection->AppendNewPlot());
Jakob Ivarsson21f6fd72019-04-04 10:15:02 +0200512 analyzer.CreateNetEqNetworkStatsGraph(
513 neteq_stats,
514 [](const webrtc::NetEqNetworkStatistics& stats) {
515 return stats.preferred_buffer_size_ms;
516 },
517 "Preferred buffer size (ms)", collection->AppendNewPlot());
henrik.lundin3c938fc2017-06-14 06:09:58 -0700518 }
519
Qingsi Wang8eca1ff2018-02-02 11:49:44 -0800520 if (FLAG_plot_ice_candidate_pair_config) {
521 analyzer.CreateIceCandidatePairConfigGraph(collection->AppendNewPlot());
522 }
523 if (FLAG_plot_ice_connectivity_check) {
524 analyzer.CreateIceConnectivityCheckGraph(collection->AppendNewPlot());
525 }
526
Zach Stein10a58012018-12-07 12:26:28 -0800527 if (FLAG_plot_dtls_transport_state) {
528 analyzer.CreateDtlsTransportStateGraph(collection->AppendNewPlot());
529 }
530 if (FLAG_plot_dtls_writable_state) {
531 analyzer.CreateDtlsWritableStateGraph(collection->AppendNewPlot());
532 }
533
tereliusdc35dcd2016-08-01 12:03:27 -0700534 collection->Draw();
terelius54ce6802016-07-13 06:44:41 -0700535
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200536 if (FLAG_print_triage_alerts) {
Bjorn Terelius2eb31882017-11-30 15:15:25 +0100537 analyzer.CreateTriageNotifications();
538 analyzer.PrintNotifications(stderr);
539 }
540
terelius54ce6802016-07-13 06:44:41 -0700541 return 0;
542}
terelius2ee076d2017-08-15 02:04:02 -0700543
terelius2ee076d2017-08-15 02:04:02 -0700544void SetAllPlotFlags(bool setting) {
545 FLAG_plot_incoming_packet_sizes = setting;
546 FLAG_plot_outgoing_packet_sizes = setting;
Bjorn Terelius7c974e62019-02-15 17:20:12 +0100547 FLAG_plot_incoming_rtcp_types = setting;
548 FLAG_plot_outgoing_rtcp_types = setting;
terelius2ee076d2017-08-15 02:04:02 -0700549 FLAG_plot_incoming_packet_count = setting;
550 FLAG_plot_outgoing_packet_count = setting;
551 FLAG_plot_audio_playout = setting;
552 FLAG_plot_audio_level = setting;
553 FLAG_plot_incoming_sequence_number_delta = setting;
terelius2ee076d2017-08-15 02:04:02 -0700554 FLAG_plot_incoming_delay = setting;
555 FLAG_plot_incoming_loss_rate = setting;
556 FLAG_plot_incoming_bitrate = setting;
557 FLAG_plot_outgoing_bitrate = setting;
558 FLAG_plot_incoming_stream_bitrate = setting;
559 FLAG_plot_outgoing_stream_bitrate = setting;
Bjorn Terelius9775a582019-02-15 17:29:58 +0100560 FLAG_plot_incoming_layer_bitrate_allocation = setting;
561 FLAG_plot_outgoing_layer_bitrate_allocation = setting;
Bjorn Terelius28db2662017-10-04 14:22:43 +0200562 FLAG_plot_simulated_receiveside_bwe = setting;
terelius2ee076d2017-08-15 02:04:02 -0700563 FLAG_plot_simulated_sendside_bwe = setting;
Sebastian Jansson1175ae02019-03-13 08:56:58 +0100564 FLAG_plot_simulated_goog_cc = setting;
terelius2ee076d2017-08-15 02:04:02 -0700565 FLAG_plot_network_delay_feedback = setting;
566 FLAG_plot_fraction_loss_feedback = setting;
567 FLAG_plot_timestamps = setting;
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200568 FLAG_plot_rtcp_details = setting;
terelius2ee076d2017-08-15 02:04:02 -0700569 FLAG_plot_audio_encoder_bitrate_bps = setting;
570 FLAG_plot_audio_encoder_frame_length_ms = setting;
571 FLAG_plot_audio_encoder_packet_loss = setting;
572 FLAG_plot_audio_encoder_fec = setting;
573 FLAG_plot_audio_encoder_dtx = setting;
574 FLAG_plot_audio_encoder_num_channels = setting;
Minyue Li27e2b7d2018-05-07 15:20:24 +0200575 FLAG_plot_neteq_stats = setting;
Qingsi Wang8eca1ff2018-02-02 11:49:44 -0800576 FLAG_plot_ice_candidate_pair_config = setting;
577 FLAG_plot_ice_connectivity_check = setting;
Konrad Hofbauerca3c8012019-02-15 20:52:19 +0100578 FLAG_plot_pacer_delay = setting;
terelius2ee076d2017-08-15 02:04:02 -0700579}