blob: f5ad86d532f08ff4ab7704e9e53456a44df67df1 [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
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +020020#include "absl/algorithm/container.h"
Yves Gerey3e707812018-11-28 16:47:49 +010021#include "logging/rtc_event_log/rtc_event_log.h"
Sebastian Janssonb290a6d2019-01-03 14:46:23 +010022#include "logging/rtc_event_log/rtc_event_log_parser.h"
Yves Gerey3e707812018-11-28 16:47:49 +010023#include "modules/audio_coding/neteq/include/neteq.h"
24#include "modules/rtp_rtcp/source/rtcp_packet/report_block.h"
25#include "rtc_base/checks.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020026#include "rtc_base/flags.h"
27#include "rtc_tools/event_log_visualizer/analyzer.h"
28#include "rtc_tools/event_log_visualizer/plot_base.h"
Bjorn Tereliusef73f592018-09-10 20:11:49 +020029#include "rtc_tools/event_log_visualizer/plot_protobuf.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020030#include "rtc_tools/event_log_visualizer/plot_python.h"
Mirko Bonadei17f48782018-09-28 08:51:10 +020031#include "system_wrappers/include/field_trial.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020032#include "test/field_trial.h"
Steve Anton10542f22019-01-11 09:11:00 -080033#include "test/testsupport/file_utils.h"
terelius54ce6802016-07-13 06:44:41 -070034
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020035WEBRTC_DEFINE_string(
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +020036 plot,
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020037 "default",
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +020038 "A comma separated list of plot names. See below for valid options.");
Bjorn Terelius1edfff92017-10-11 13:15:19 +020039
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020040WEBRTC_DEFINE_string(
stefan985d2802016-11-15 06:54:09 -080041 force_fieldtrials,
42 "",
43 "Field trials control experimental feature code which can be forced. "
44 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enabled/"
45 " will assign the group Enabled to field trial WebRTC-FooFeature. Multiple "
46 "trials are separated by \"/\"");
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020047WEBRTC_DEFINE_string(wav_filename,
48 "",
49 "Path to wav file used for simulation of jitter buffer");
50WEBRTC_DEFINE_bool(help, false, "prints this message");
terelius54ce6802016-07-13 06:44:41 -070051
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020052WEBRTC_DEFINE_bool(
53 show_detector_state,
54 false,
55 "Show the state of the delay based BWE detector on the total "
56 "bitrate graph");
terelius2ee076d2017-08-15 02:04:02 -070057
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020058WEBRTC_DEFINE_bool(show_alr_state,
59 false,
60 "Show the state ALR state on the total bitrate graph");
Ilya Nikolaevskiya4259f62017-12-05 13:19:45 +010061
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020062WEBRTC_DEFINE_bool(
63 parse_unconfigured_header_extensions,
64 true,
65 "Attempt to parse unconfigured header extensions using the default "
66 "WebRTC mapping. This can give very misleading results if the "
67 "application negotiates a different mapping.");
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +020068
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020069WEBRTC_DEFINE_bool(print_triage_alerts,
70 false,
71 "Print triage alerts, i.e. a list of potential problems.");
Bjorn Terelius2eb31882017-11-30 15:15:25 +010072
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020073WEBRTC_DEFINE_bool(
74 normalize_time,
75 true,
76 "Normalize the log timestamps so that the call starts at time 0.");
Stefan Holmer1d4a2272018-05-24 13:48:09 +020077
Bjorn Tereliusff8cce32019-04-11 18:34:01 +020078WEBRTC_DEFINE_bool(shared_xaxis,
79 false,
80 "Share x-axis between all plots so that zooming in one plot "
81 "updates all the others too. A downside is that certain "
82 "operations like panning become much slower.");
83
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020084WEBRTC_DEFINE_bool(protobuf_output,
85 false,
86 "Output charts as protobuf instead of python code.");
Bjorn Tereliusef73f592018-09-10 20:11:49 +020087
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +020088using webrtc::Plot;
89
90namespace {
91std::vector<std::string> StrSplit(const std::string& s,
92 const std::string& delimiter) {
93 std::vector<std::string> v;
94 size_t pos = 0;
95 while (pos < s.length()) {
96 const std::string token = s.substr(pos, s.find(delimiter, pos) - pos);
97 pos += token.length() + delimiter.length();
98 v.push_back(token);
99 }
100 return v;
101}
102
103struct PlotDeclaration {
104 PlotDeclaration(const std::string& label, std::function<void(Plot*)> f)
105 : label(label), enabled(false), plot_func(f) {}
106 const std::string label;
107 bool enabled;
108 // TODO(terelius): Add a help text/explanation.
109 const std::function<void(Plot*)> plot_func;
110};
111
112class PlotMap {
113 public:
114 void RegisterPlot(const std::string& label, std::function<void(Plot*)> f) {
115 for (const auto& plot : plots_) {
116 RTC_DCHECK(plot.label != label)
117 << "Can't use the same label for multiple plots";
118 }
119 plots_.push_back({label, f});
120 }
121
122 bool EnablePlotsByFlags(
123 const std::vector<std::string>& flags,
124 const std::map<std::string, std::vector<std::string>>& flag_aliases) {
125 bool status = true;
126 for (const std::string& flag : flags) {
127 auto alias_it = flag_aliases.find(flag);
128 if (alias_it != flag_aliases.end()) {
129 const auto& replacements = alias_it->second;
130 for (const auto& replacement : replacements) {
131 status &= EnablePlotByFlag(replacement);
132 }
133 } else {
134 status &= EnablePlotByFlag(flag);
135 }
136 }
137 return status;
138 }
139
140 void EnableAllPlots() {
141 for (auto& plot : plots_) {
142 plot.enabled = true;
143 }
144 }
145
146 std::vector<PlotDeclaration>::iterator begin() { return plots_.begin(); }
147 std::vector<PlotDeclaration>::iterator end() { return plots_.end(); }
148
149 private:
150 bool EnablePlotByFlag(const std::string& flag) {
151 for (auto& plot : plots_) {
152 if (plot.label == flag) {
153 plot.enabled = true;
154 return true;
155 }
156 }
157 if (flag == "simulated_neteq_jitter_buffer_delay") {
158 // This flag is handled separately.
159 return true;
160 }
161 std::cerr << "Unrecognized plot name \'" << flag << "\'. Aborting."
162 << std::endl;
163 return false;
164 }
165
166 std::vector<PlotDeclaration> plots_;
167};
168} // namespace
terelius2ee076d2017-08-15 02:04:02 -0700169
terelius54ce6802016-07-13 06:44:41 -0700170int main(int argc, char* argv[]) {
171 std::string program_name = argv[0];
172 std::string usage =
173 "A tool for visualizing WebRTC event logs.\n"
174 "Example usage:\n" +
175 program_name + " <logfile> | python\n" + "Run " + program_name +
176 " --help for a list of command line options\n";
terelius2ee076d2017-08-15 02:04:02 -0700177
kjellander4fa5be42017-05-16 00:01:23 -0700178 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
terelius2ee076d2017-08-15 02:04:02 -0700179
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200180 // Flag replacements
181 std::map<std::string, std::vector<std::string>> flag_aliases = {
182 {"default",
183 {"incoming_delay", "incoming_loss_rate", "incoming_bitrate",
Bjorn Terelius873a7a92019-06-13 16:01:17 +0200184 "outgoing_bitrate", "incoming_stream_bitrate",
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200185 "outgoing_stream_bitrate", "network_delay_feedback",
186 "fraction_loss_feedback"}},
187 {"sendside_bwe",
188 {"outgoing_packet_sizes", "outgoing_bitrate", "outgoing_stream_bitrate",
189 "simulated_sendside_bwe", "network_delay_feedback",
190 "fraction_loss_feedback"}},
191 {"receiveside_bwe",
192 {"incoming_packet_sizes", "incoming_delay", "incoming_loss_rate",
Bjorn Terelius873a7a92019-06-13 16:01:17 +0200193 "incoming_bitrate", "incoming_stream_bitrate",
194 "simulated_receiveside_bwe"}},
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200195 {"rtcp_details",
196 {"incoming_rtcp_fraction_lost", "outgoing_rtcp_fraction_lost",
Bjorn Terelius873a7a92019-06-13 16:01:17 +0200197 "incoming_rtcp_cumulative_lost", "outgoing_rtcp_cumulative_lost",
198 "incoming_rtcp_highest_seq_number", "outgoing_rtcp_highest_seq_number",
199 "incoming_rtcp_delay_since_last_sr",
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200200 "outgoing_rtcp_delay_since_last_sr"}},
201 {"simulated_neteq_stats",
202 {"simulated_neteq_jitter_buffer_delay",
Bjorn Terelius873a7a92019-06-13 16:01:17 +0200203 "simulated_neteq_preferred_buffer_size",
204 "simulated_neteq_concealment_events",
205 "simulated_neteq_packet_loss_rate", "simulated_neteq_preemptive_rate",
206 "simulated_neteq_accelerate_rate", "simulated_neteq_speech_expand_rate",
207 "simulated_neteq_expand_rate"}}};
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200208
209 std::vector<std::string> plot_flags = StrSplit(FLAG_plot, ",");
kjellander4fa5be42017-05-16 00:01:23 -0700210
Bjorn Tereliusedab3012018-01-31 17:23:40 +0100211 // InitFieldTrialsFromString stores the char*, so the char array must outlive
212 // the application.
213 webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials);
stefan985d2802016-11-15 06:54:09 -0800214
Sebastian Janssonb290a6d2019-01-03 14:46:23 +0100215 webrtc::ParsedRtcEventLog::UnconfiguredHeaderExtensions header_extensions =
216 webrtc::ParsedRtcEventLog::UnconfiguredHeaderExtensions::kDontParse;
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200217 if (FLAG_parse_unconfigured_header_extensions) {
Sebastian Janssonb290a6d2019-01-03 14:46:23 +0100218 header_extensions = webrtc::ParsedRtcEventLog::
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200219 UnconfiguredHeaderExtensions::kAttemptWebrtcDefaultConfig;
220 }
Sebastian Janssonb290a6d2019-01-03 14:46:23 +0100221 webrtc::ParsedRtcEventLog parsed_log(header_extensions);
terelius54ce6802016-07-13 06:44:41 -0700222
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200223 if (argc == 2) {
224 std::string filename = argv[1];
225 if (!parsed_log.ParseFile(filename)) {
226 std::cerr << "Could not parse the entire log file." << std::endl;
227 std::cerr << "Only the parsable events will be analyzed." << std::endl;
228 }
terelius54ce6802016-07-13 06:44:41 -0700229 }
230
Stefan Holmer1d4a2272018-05-24 13:48:09 +0200231 webrtc::EventLogAnalyzer analyzer(parsed_log, FLAG_normalize_time);
Bjorn Tereliusef73f592018-09-10 20:11:49 +0200232 std::unique_ptr<webrtc::PlotCollection> collection;
233 if (FLAG_protobuf_output) {
234 collection.reset(new webrtc::ProtobufPlotCollection());
235 } else {
Bjorn Tereliusff8cce32019-04-11 18:34:01 +0200236 collection.reset(new webrtc::PythonPlotCollection(FLAG_shared_xaxis));
Bjorn Tereliusef73f592018-09-10 20:11:49 +0200237 }
terelius54ce6802016-07-13 06:44:41 -0700238
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200239 PlotMap plots;
240 plots.RegisterPlot("incoming_packet_sizes", [&](Plot* plot) {
241 analyzer.CreatePacketGraph(webrtc::kIncomingPacket, plot);
242 });
243
244 plots.RegisterPlot("outgoing_packet_sizes", [&](Plot* plot) {
245 analyzer.CreatePacketGraph(webrtc::kOutgoingPacket, plot);
246 });
247 plots.RegisterPlot("incoming_rtcp_types", [&](Plot* plot) {
248 analyzer.CreateRtcpTypeGraph(webrtc::kIncomingPacket, plot);
249 });
250 plots.RegisterPlot("outgoing_rtcp_types", [&](Plot* plot) {
251 analyzer.CreateRtcpTypeGraph(webrtc::kOutgoingPacket, plot);
252 });
253 plots.RegisterPlot("incoming_packet_count", [&](Plot* plot) {
254 analyzer.CreateAccumulatedPacketsGraph(webrtc::kIncomingPacket, plot);
255 });
256 plots.RegisterPlot("outgoing_packet_count", [&](Plot* plot) {
257 analyzer.CreateAccumulatedPacketsGraph(webrtc::kOutgoingPacket, plot);
258 });
259 plots.RegisterPlot("audio_playout",
260 [&](Plot* plot) { analyzer.CreatePlayoutGraph(plot); });
261 plots.RegisterPlot("incoming_audio_level", [&](Plot* plot) {
262 analyzer.CreateAudioLevelGraph(webrtc::kIncomingPacket, plot);
263 });
264 plots.RegisterPlot("outgoing_audio_level", [&](Plot* plot) {
265 analyzer.CreateAudioLevelGraph(webrtc::kOutgoingPacket, plot);
266 });
267 plots.RegisterPlot("incoming_sequence_number_delta", [&](Plot* plot) {
268 analyzer.CreateSequenceNumberGraph(plot);
269 });
270 plots.RegisterPlot("incoming_delay", [&](Plot* plot) {
271 analyzer.CreateIncomingDelayGraph(plot);
272 });
273 plots.RegisterPlot("incoming_loss_rate", [&](Plot* plot) {
274 analyzer.CreateIncomingPacketLossGraph(plot);
275 });
276 plots.RegisterPlot("incoming_bitrate", [&](Plot* plot) {
277 analyzer.CreateTotalIncomingBitrateGraph(plot);
278 });
279 plots.RegisterPlot("outgoing_bitrate", [&](Plot* plot) {
280 analyzer.CreateTotalOutgoingBitrateGraph(plot, FLAG_show_detector_state,
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200281 FLAG_show_alr_state);
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200282 });
283 plots.RegisterPlot("incoming_stream_bitrate", [&](Plot* plot) {
284 analyzer.CreateStreamBitrateGraph(webrtc::kIncomingPacket, plot);
285 });
286 plots.RegisterPlot("outgoing_stream_bitrate", [&](Plot* plot) {
287 analyzer.CreateStreamBitrateGraph(webrtc::kOutgoingPacket, plot);
288 });
289 plots.RegisterPlot("incoming_layer_bitrate_allocation", [&](Plot* plot) {
290 analyzer.CreateBitrateAllocationGraph(webrtc::kIncomingPacket, plot);
291 });
292 plots.RegisterPlot("outgoing_layer_bitrate_allocation", [&](Plot* plot) {
293 analyzer.CreateBitrateAllocationGraph(webrtc::kOutgoingPacket, plot);
294 });
295 plots.RegisterPlot("simulated_receiveside_bwe", [&](Plot* plot) {
296 analyzer.CreateReceiveSideBweSimulationGraph(plot);
297 });
298 plots.RegisterPlot("simulated_sendside_bwe", [&](Plot* plot) {
299 analyzer.CreateSendSideBweSimulationGraph(plot);
300 });
301 plots.RegisterPlot("simulated_goog_cc", [&](Plot* plot) {
302 analyzer.CreateGoogCcSimulationGraph(plot);
303 });
304 plots.RegisterPlot("network_delay_feedback", [&](Plot* plot) {
305 analyzer.CreateNetworkDelayFeedbackGraph(plot);
306 });
307 plots.RegisterPlot("fraction_loss_feedback", [&](Plot* plot) {
308 analyzer.CreateFractionLossGraph(plot);
309 });
310 plots.RegisterPlot("incoming_timestamps", [&](Plot* plot) {
311 analyzer.CreateTimestampGraph(webrtc::kIncomingPacket, plot);
312 });
313 plots.RegisterPlot("outgoing_timestamps", [&](Plot* plot) {
314 analyzer.CreateTimestampGraph(webrtc::kOutgoingPacket, plot);
315 });
316
317 auto GetFractionLost = [](const webrtc::rtcp::ReportBlock& block) -> float {
318 return static_cast<double>(block.fraction_lost()) / 256 * 100;
319 };
320 plots.RegisterPlot("incoming_rtcp_fraction_lost", [&](Plot* plot) {
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200321 analyzer.CreateSenderAndReceiverReportPlot(
322 webrtc::kIncomingPacket, GetFractionLost,
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200323 "Fraction lost (incoming RTCP)", "Loss rate (percent)", plot);
324 });
325 plots.RegisterPlot("outgoing_rtcp_fraction_lost", [&](Plot* plot) {
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200326 analyzer.CreateSenderAndReceiverReportPlot(
327 webrtc::kOutgoingPacket, GetFractionLost,
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200328 "Fraction lost (outgoing RTCP)", "Loss rate (percent)", plot);
329 });
330 auto GetCumulativeLost = [](const webrtc::rtcp::ReportBlock& block) -> float {
331 return block.cumulative_lost_signed();
332 };
333 plots.RegisterPlot("incoming_rtcp_cumulative_lost", [&](Plot* plot) {
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200334 analyzer.CreateSenderAndReceiverReportPlot(
335 webrtc::kIncomingPacket, GetCumulativeLost,
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200336 "Cumulative lost packets (incoming RTCP)", "Packets", plot);
337 });
338 plots.RegisterPlot("outgoing_rtcp_cumulative_lost", [&](Plot* plot) {
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200339 analyzer.CreateSenderAndReceiverReportPlot(
340 webrtc::kOutgoingPacket, GetCumulativeLost,
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200341 "Cumulative lost packets (outgoing RTCP)", "Packets", plot);
342 });
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200343
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200344 auto GetHighestSeqNumber =
345 [](const webrtc::rtcp::ReportBlock& block) -> float {
346 return block.extended_high_seq_num();
347 };
348 plots.RegisterPlot("incoming_rtcp_highest_seq_number", [&](Plot* plot) {
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200349 analyzer.CreateSenderAndReceiverReportPlot(
350 webrtc::kIncomingPacket, GetHighestSeqNumber,
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200351 "Highest sequence number (incoming RTCP)", "Sequence number", plot);
352 });
353 plots.RegisterPlot("outgoing_rtcp_highest_seq_number", [&](Plot* plot) {
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200354 analyzer.CreateSenderAndReceiverReportPlot(
355 webrtc::kOutgoingPacket, GetHighestSeqNumber,
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200356 "Highest sequence number (outgoing RTCP)", "Sequence number", plot);
357 });
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200358
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200359 auto DelaySinceLastSr = [](const webrtc::rtcp::ReportBlock& block) -> float {
360 return static_cast<double>(block.delay_since_last_sr()) / 65536;
361 };
362 plots.RegisterPlot("incoming_rtcp_delay_since_last_sr", [&](Plot* plot) {
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200363 analyzer.CreateSenderAndReceiverReportPlot(
364 webrtc::kIncomingPacket, DelaySinceLastSr,
365 "Delay since last received sender report (incoming RTCP)", "Time (s)",
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200366 plot);
367 });
368 plots.RegisterPlot("outgoing_rtcp_delay_since_last_sr", [&](Plot* plot) {
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200369 analyzer.CreateSenderAndReceiverReportPlot(
370 webrtc::kOutgoingPacket, DelaySinceLastSr,
371 "Delay since last received sender report (outgoing RTCP)", "Time (s)",
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200372 plot);
373 });
Bjorn Tereliusb1222c22018-07-24 13:45:31 +0200374
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200375 plots.RegisterPlot("pacer_delay",
376 [&](Plot* plot) { analyzer.CreatePacerDelayGraph(plot); });
377 plots.RegisterPlot("audio_encoder_bitrate", [&](Plot* plot) {
378 analyzer.CreateAudioEncoderTargetBitrateGraph(plot);
379 });
380 plots.RegisterPlot("audio_encoder_frame_length", [&](Plot* plot) {
381 analyzer.CreateAudioEncoderFrameLengthGraph(plot);
382 });
383 plots.RegisterPlot("audio_encoder_packet_loss", [&](Plot* plot) {
384 analyzer.CreateAudioEncoderPacketLossGraph(plot);
385 });
386 plots.RegisterPlot("audio_encoder_fec", [&](Plot* plot) {
387 analyzer.CreateAudioEncoderEnableFecGraph(plot);
388 });
389 plots.RegisterPlot("audio_encoder_dtx", [&](Plot* plot) {
390 analyzer.CreateAudioEncoderEnableDtxGraph(plot);
391 });
392 plots.RegisterPlot("audio_encoder_num_channels", [&](Plot* plot) {
393 analyzer.CreateAudioEncoderNumChannelsGraph(plot);
394 });
395
396 plots.RegisterPlot("ice_candidate_pair_config", [&](Plot* plot) {
397 analyzer.CreateIceCandidatePairConfigGraph(plot);
398 });
399 plots.RegisterPlot("ice_connectivity_check", [&](Plot* plot) {
400 analyzer.CreateIceConnectivityCheckGraph(plot);
401 });
402 plots.RegisterPlot("dtls_transport_state", [&](Plot* plot) {
403 analyzer.CreateDtlsTransportStateGraph(plot);
404 });
405 plots.RegisterPlot("dtls_writable_state", [&](Plot* plot) {
406 analyzer.CreateDtlsWritableStateGraph(plot);
407 });
408
409 std::string wav_path;
410 if (FLAG_wav_filename[0] != '\0') {
411 wav_path = FLAG_wav_filename;
412 } else {
413 wav_path = webrtc::test::ResourcePath(
414 "audio_processing/conversational_speech/EN_script2_F_sp2_B1", "wav");
Bjorn Terelius0295a962017-10-25 17:42:41 +0200415 }
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200416 absl::optional<webrtc::EventLogAnalyzer::NetEqStatsGetterMap> neteq_stats;
417
418 plots.RegisterPlot("simulated_neteq_expand_rate", [&](Plot* plot) {
419 if (!neteq_stats) {
420 neteq_stats = analyzer.SimulateNetEq(wav_path, 48000);
Minyue Li45fc6df2018-06-21 11:47:14 +0200421 }
Minyue Lic9ac93f2018-06-26 13:01:32 +0200422 analyzer.CreateNetEqNetworkStatsGraph(
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200423 *neteq_stats,
Minyue Li27e2b7d2018-05-07 15:20:24 +0200424 [](const webrtc::NetEqNetworkStatistics& stats) {
425 return stats.expand_rate / 16384.f;
426 },
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200427 "Expand rate", plot);
428 });
429
430 plots.RegisterPlot("simulated_neteq_speech_expand_rate", [&](Plot* plot) {
431 if (!neteq_stats) {
432 neteq_stats = analyzer.SimulateNetEq(wav_path, 48000);
433 }
Minyue Lic9ac93f2018-06-26 13:01:32 +0200434 analyzer.CreateNetEqNetworkStatsGraph(
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200435 *neteq_stats,
Minyue Li27e2b7d2018-05-07 15:20:24 +0200436 [](const webrtc::NetEqNetworkStatistics& stats) {
437 return stats.speech_expand_rate / 16384.f;
438 },
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200439 "Speech expand rate", plot);
440 });
441
442 plots.RegisterPlot("simulated_neteq_accelerate_rate", [&](Plot* plot) {
443 if (!neteq_stats) {
444 neteq_stats = analyzer.SimulateNetEq(wav_path, 48000);
445 }
Minyue Lic9ac93f2018-06-26 13:01:32 +0200446 analyzer.CreateNetEqNetworkStatsGraph(
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200447 *neteq_stats,
Minyue Li27e2b7d2018-05-07 15:20:24 +0200448 [](const webrtc::NetEqNetworkStatistics& stats) {
449 return stats.accelerate_rate / 16384.f;
450 },
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200451 "Accelerate rate", plot);
452 });
453
454 plots.RegisterPlot("simulated_neteq_preemptive_rate", [&](Plot* plot) {
455 if (!neteq_stats) {
456 neteq_stats = analyzer.SimulateNetEq(wav_path, 48000);
457 }
Minyue Lic9ac93f2018-06-26 13:01:32 +0200458 analyzer.CreateNetEqNetworkStatsGraph(
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200459 *neteq_stats,
Minyue Li27e2b7d2018-05-07 15:20:24 +0200460 [](const webrtc::NetEqNetworkStatistics& stats) {
Jakob Ivarsson21f6fd72019-04-04 10:15:02 +0200461 return stats.preemptive_rate / 16384.f;
462 },
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200463 "Preemptive rate", plot);
464 });
465
466 plots.RegisterPlot("simulated_neteq_packet_loss_rate", [&](Plot* plot) {
467 if (!neteq_stats) {
468 neteq_stats = analyzer.SimulateNetEq(wav_path, 48000);
469 }
Jakob Ivarsson21f6fd72019-04-04 10:15:02 +0200470 analyzer.CreateNetEqNetworkStatsGraph(
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200471 *neteq_stats,
Jakob Ivarsson21f6fd72019-04-04 10:15:02 +0200472 [](const webrtc::NetEqNetworkStatistics& stats) {
Minyue Li27e2b7d2018-05-07 15:20:24 +0200473 return stats.packet_loss_rate / 16384.f;
474 },
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200475 "Packet loss rate", plot);
476 });
477
478 plots.RegisterPlot("simulated_neteq_concealment_events", [&](Plot* plot) {
479 if (!neteq_stats) {
480 neteq_stats = analyzer.SimulateNetEq(wav_path, 48000);
481 }
Minyue Lic9ac93f2018-06-26 13:01:32 +0200482 analyzer.CreateNetEqLifetimeStatsGraph(
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200483 *neteq_stats,
Minyue Lic9ac93f2018-06-26 13:01:32 +0200484 [](const webrtc::NetEqLifetimeStatistics& stats) {
485 return static_cast<float>(stats.concealment_events);
486 },
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200487 "Concealment events", plot);
488 });
489
490 plots.RegisterPlot("simulated_neteq_preferred_buffer_size", [&](Plot* plot) {
491 if (!neteq_stats) {
492 neteq_stats = analyzer.SimulateNetEq(wav_path, 48000);
493 }
Jakob Ivarsson21f6fd72019-04-04 10:15:02 +0200494 analyzer.CreateNetEqNetworkStatsGraph(
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200495 *neteq_stats,
Jakob Ivarsson21f6fd72019-04-04 10:15:02 +0200496 [](const webrtc::NetEqNetworkStatistics& stats) {
497 return stats.preferred_buffer_size_ms;
498 },
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200499 "Preferred buffer size (ms)", plot);
500 });
501
502 if (absl::c_find(plot_flags, "all") != plot_flags.end()) {
503 plots.EnableAllPlots();
504 // Treated separately since it isn't registered like the other plots.
505 plot_flags.push_back("simulated_neteq_jitter_buffer_delay");
506 } else {
507 bool success = plots.EnablePlotsByFlags(plot_flags, flag_aliases);
508 if (!success) {
509 return 1;
510 }
henrik.lundin3c938fc2017-06-14 06:09:58 -0700511 }
512
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200513 if (argc != 2 || FLAG_help) {
514 // Print usage information.
515 std::cerr << usage;
516 if (FLAG_help) {
517 rtc::FlagList::Print(nullptr, false);
518 std::cerr << "List of registered plots (for use with the --plot flag):"
519 << std::endl;
520 for (const auto& plot : plots) {
521 // TODO(terelius): Also print a help text.
522 std::cerr << " " << plot.label << std::endl;
523 }
524 // The following flag doesn't fit the model used for the other plots.
525 std::cerr << "simulated_neteq_jitter_buffer_delay" << std::endl;
526 std::cerr << "List of plot aliases (for use with the --plot flag):"
527 << std::endl;
Bjorn Terelius873a7a92019-06-13 16:01:17 +0200528 std::cerr << " all = every registered plot" << std::endl;
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200529 for (const auto& alias : flag_aliases) {
530 std::cerr << " " << alias.first << " = ";
531 for (const auto& replacement : alias.second) {
532 std::cerr << replacement << ",";
533 }
534 std::cerr << std::endl;
535 }
536 }
537 return 0;
Qingsi Wang8eca1ff2018-02-02 11:49:44 -0800538 }
539
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200540 for (const auto& plot : plots) {
541 if (plot.enabled) {
542 Plot* output = collection->AppendNewPlot();
543 plot.plot_func(output);
544 output->SetId(plot.label);
545 }
Zach Stein10a58012018-12-07 12:26:28 -0800546 }
Bjorn Terelius1aa9ee92019-06-11 17:39:38 +0200547
548 // The model we use for registering plots assumes that the each plot label
549 // can be mapped to a lambda that will produce exactly one plot. The
550 // simulated_neteq_jitter_buffer_delay plot doesn't fit this model since it
551 // creates multiple plots, and would need some state kept between the lambda
552 // calls.
553 if (absl::c_find(plot_flags, "simulated_neteq_jitter_buffer_delay") !=
554 plot_flags.end()) {
555 if (!neteq_stats) {
556 neteq_stats = analyzer.SimulateNetEq(wav_path, 48000);
557 }
558 for (webrtc::EventLogAnalyzer::NetEqStatsGetterMap::const_iterator it =
559 neteq_stats->cbegin();
560 it != neteq_stats->cend(); ++it) {
561 analyzer.CreateAudioJitterBufferGraph(it->first, it->second.get(),
562 collection->AppendNewPlot());
563 }
Zach Stein10a58012018-12-07 12:26:28 -0800564 }
565
tereliusdc35dcd2016-08-01 12:03:27 -0700566 collection->Draw();
terelius54ce6802016-07-13 06:44:41 -0700567
Bjorn Tereliusc4ca1d32018-04-27 14:33:34 +0200568 if (FLAG_print_triage_alerts) {
Bjorn Terelius2eb31882017-11-30 15:15:25 +0100569 analyzer.CreateTriageNotifications();
570 analyzer.PrintNotifications(stderr);
571 }
572
terelius54ce6802016-07-13 06:44:41 -0700573 return 0;
574}