terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 1 | /* |
| 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 Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 11 | #include <stdio.h> |
| 12 | #include <string.h> |
Jonas Olsson | 5b2eda4 | 2019-06-11 14:29:40 +0200 | [diff] [blame] | 13 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 14 | #include <iostream> |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 15 | #include <map> |
| 16 | #include <memory> |
| 17 | #include <string> |
| 18 | #include <utility> |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 19 | #include <vector> |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 20 | |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 21 | #include "absl/algorithm/container.h" |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 22 | #include "absl/flags/flag.h" |
| 23 | #include "absl/flags/parse.h" |
Mirko Bonadei | f2d97b8 | 2019-07-24 15:29:47 +0200 | [diff] [blame] | 24 | #include "absl/flags/usage.h" |
| 25 | #include "absl/flags/usage_config.h" |
| 26 | #include "absl/strings/match.h" |
Ivo Creusen | 3ce44a3 | 2019-10-31 14:38:11 +0100 | [diff] [blame^] | 27 | #include "api/neteq/neteq.h" |
Danil Chapovalov | 83bbe91 | 2019-08-07 12:24:53 +0200 | [diff] [blame] | 28 | #include "api/rtc_event_log/rtc_event_log.h" |
Sebastian Jansson | b290a6d | 2019-01-03 14:46:23 +0100 | [diff] [blame] | 29 | #include "logging/rtc_event_log/rtc_event_log_parser.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 30 | #include "modules/rtp_rtcp/source/rtcp_packet/report_block.h" |
| 31 | #include "rtc_base/checks.h" |
Mirko Bonadei | 575998c | 2019-07-25 13:57:41 +0200 | [diff] [blame] | 32 | #include "rtc_tools/rtc_event_log_visualizer/analyzer.h" |
| 33 | #include "rtc_tools/rtc_event_log_visualizer/plot_base.h" |
| 34 | #include "rtc_tools/rtc_event_log_visualizer/plot_protobuf.h" |
| 35 | #include "rtc_tools/rtc_event_log_visualizer/plot_python.h" |
Mirko Bonadei | 17f4878 | 2018-09-28 08:51:10 +0200 | [diff] [blame] | 36 | #include "system_wrappers/include/field_trial.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 37 | #include "test/field_trial.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 38 | #include "test/testsupport/file_utils.h" |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 39 | |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 40 | ABSL_FLAG(std::string, |
| 41 | plot, |
| 42 | "default", |
Mirko Bonadei | f2d97b8 | 2019-07-24 15:29:47 +0200 | [diff] [blame] | 43 | "A comma separated list of plot names. See --list_plots for valid " |
| 44 | "options."); |
Bjorn Terelius | 1edfff9 | 2017-10-11 13:15:19 +0200 | [diff] [blame] | 45 | |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 46 | ABSL_FLAG( |
| 47 | std::string, |
stefan | 985d280 | 2016-11-15 06:54:09 -0800 | [diff] [blame] | 48 | force_fieldtrials, |
| 49 | "", |
| 50 | "Field trials control experimental feature code which can be forced. " |
| 51 | "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enabled/" |
| 52 | " will assign the group Enabled to field trial WebRTC-FooFeature. Multiple " |
| 53 | "trials are separated by \"/\""); |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 54 | ABSL_FLAG(std::string, |
| 55 | wav_filename, |
| 56 | "", |
| 57 | "Path to wav file used for simulation of jitter buffer"); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 58 | |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 59 | ABSL_FLAG(bool, |
| 60 | show_detector_state, |
| 61 | false, |
| 62 | "Show the state of the delay based BWE detector on the total " |
| 63 | "bitrate graph"); |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 64 | |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 65 | ABSL_FLAG(bool, |
| 66 | show_alr_state, |
| 67 | false, |
| 68 | "Show the state ALR state on the total bitrate graph"); |
Ilya Nikolaevskiy | a4259f6 | 2017-12-05 13:19:45 +0100 | [diff] [blame] | 69 | |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 70 | ABSL_FLAG(bool, |
| 71 | parse_unconfigured_header_extensions, |
| 72 | true, |
| 73 | "Attempt to parse unconfigured header extensions using the default " |
| 74 | "WebRTC mapping. This can give very misleading results if the " |
| 75 | "application negotiates a different mapping."); |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 76 | |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 77 | ABSL_FLAG(bool, |
| 78 | print_triage_alerts, |
| 79 | false, |
| 80 | "Print triage alerts, i.e. a list of potential problems."); |
Bjorn Terelius | 2eb3188 | 2017-11-30 15:15:25 +0100 | [diff] [blame] | 81 | |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 82 | ABSL_FLAG(bool, |
| 83 | normalize_time, |
| 84 | true, |
| 85 | "Normalize the log timestamps so that the call starts at time 0."); |
Stefan Holmer | 1d4a227 | 2018-05-24 13:48:09 +0200 | [diff] [blame] | 86 | |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 87 | ABSL_FLAG(bool, |
| 88 | shared_xaxis, |
| 89 | false, |
| 90 | "Share x-axis between all plots so that zooming in one plot " |
| 91 | "updates all the others too. A downside is that certain " |
| 92 | "operations like panning become much slower."); |
Bjorn Terelius | ff8cce3 | 2019-04-11 18:34:01 +0200 | [diff] [blame] | 93 | |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 94 | ABSL_FLAG(bool, |
| 95 | protobuf_output, |
| 96 | false, |
| 97 | "Output charts as protobuf instead of python code."); |
Bjorn Terelius | ef73f59 | 2018-09-10 20:11:49 +0200 | [diff] [blame] | 98 | |
Mirko Bonadei | f2d97b8 | 2019-07-24 15:29:47 +0200 | [diff] [blame] | 99 | ABSL_FLAG(bool, |
| 100 | list_plots, |
| 101 | false, |
| 102 | "List of registered plots (for use with the --plot flag)"); |
| 103 | |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 104 | using webrtc::Plot; |
| 105 | |
| 106 | namespace { |
| 107 | std::vector<std::string> StrSplit(const std::string& s, |
| 108 | const std::string& delimiter) { |
| 109 | std::vector<std::string> v; |
| 110 | size_t pos = 0; |
| 111 | while (pos < s.length()) { |
| 112 | const std::string token = s.substr(pos, s.find(delimiter, pos) - pos); |
| 113 | pos += token.length() + delimiter.length(); |
| 114 | v.push_back(token); |
| 115 | } |
| 116 | return v; |
| 117 | } |
| 118 | |
| 119 | struct PlotDeclaration { |
| 120 | PlotDeclaration(const std::string& label, std::function<void(Plot*)> f) |
| 121 | : label(label), enabled(false), plot_func(f) {} |
| 122 | const std::string label; |
| 123 | bool enabled; |
| 124 | // TODO(terelius): Add a help text/explanation. |
| 125 | const std::function<void(Plot*)> plot_func; |
| 126 | }; |
| 127 | |
| 128 | class PlotMap { |
| 129 | public: |
| 130 | void RegisterPlot(const std::string& label, std::function<void(Plot*)> f) { |
| 131 | for (const auto& plot : plots_) { |
| 132 | RTC_DCHECK(plot.label != label) |
| 133 | << "Can't use the same label for multiple plots"; |
| 134 | } |
| 135 | plots_.push_back({label, f}); |
| 136 | } |
| 137 | |
| 138 | bool EnablePlotsByFlags( |
| 139 | const std::vector<std::string>& flags, |
| 140 | const std::map<std::string, std::vector<std::string>>& flag_aliases) { |
| 141 | bool status = true; |
| 142 | for (const std::string& flag : flags) { |
| 143 | auto alias_it = flag_aliases.find(flag); |
| 144 | if (alias_it != flag_aliases.end()) { |
| 145 | const auto& replacements = alias_it->second; |
| 146 | for (const auto& replacement : replacements) { |
| 147 | status &= EnablePlotByFlag(replacement); |
| 148 | } |
| 149 | } else { |
| 150 | status &= EnablePlotByFlag(flag); |
| 151 | } |
| 152 | } |
| 153 | return status; |
| 154 | } |
| 155 | |
| 156 | void EnableAllPlots() { |
| 157 | for (auto& plot : plots_) { |
| 158 | plot.enabled = true; |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | std::vector<PlotDeclaration>::iterator begin() { return plots_.begin(); } |
| 163 | std::vector<PlotDeclaration>::iterator end() { return plots_.end(); } |
| 164 | |
| 165 | private: |
| 166 | bool EnablePlotByFlag(const std::string& flag) { |
| 167 | for (auto& plot : plots_) { |
| 168 | if (plot.label == flag) { |
| 169 | plot.enabled = true; |
| 170 | return true; |
| 171 | } |
| 172 | } |
| 173 | if (flag == "simulated_neteq_jitter_buffer_delay") { |
| 174 | // This flag is handled separately. |
| 175 | return true; |
| 176 | } |
| 177 | std::cerr << "Unrecognized plot name \'" << flag << "\'. Aborting." |
| 178 | << std::endl; |
| 179 | return false; |
| 180 | } |
| 181 | |
| 182 | std::vector<PlotDeclaration> plots_; |
| 183 | }; |
Mirko Bonadei | f2d97b8 | 2019-07-24 15:29:47 +0200 | [diff] [blame] | 184 | |
| 185 | bool ContainsHelppackageFlags(absl::string_view filename) { |
| 186 | return absl::EndsWith(filename, "main.cc"); |
| 187 | } |
| 188 | |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 189 | } // namespace |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 190 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 191 | int main(int argc, char* argv[]) { |
Mirko Bonadei | f2d97b8 | 2019-07-24 15:29:47 +0200 | [diff] [blame] | 192 | absl::SetProgramUsageMessage( |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 193 | "A tool for visualizing WebRTC event logs.\n" |
Mirko Bonadei | f2d97b8 | 2019-07-24 15:29:47 +0200 | [diff] [blame] | 194 | "Example usage:\n" |
| 195 | "./event_log_visualizer <logfile> | python\n"); |
| 196 | absl::FlagsUsageConfig config; |
| 197 | config.contains_help_flags = &ContainsHelppackageFlags; |
| 198 | absl::SetFlagsUsageConfig(config); |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 199 | std::vector<char*> args = absl::ParseCommandLine(argc, argv); |
| 200 | |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 201 | // Flag replacements |
| 202 | std::map<std::string, std::vector<std::string>> flag_aliases = { |
| 203 | {"default", |
| 204 | {"incoming_delay", "incoming_loss_rate", "incoming_bitrate", |
Bjorn Terelius | 873a7a9 | 2019-06-13 16:01:17 +0200 | [diff] [blame] | 205 | "outgoing_bitrate", "incoming_stream_bitrate", |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 206 | "outgoing_stream_bitrate", "network_delay_feedback", |
| 207 | "fraction_loss_feedback"}}, |
| 208 | {"sendside_bwe", |
| 209 | {"outgoing_packet_sizes", "outgoing_bitrate", "outgoing_stream_bitrate", |
| 210 | "simulated_sendside_bwe", "network_delay_feedback", |
| 211 | "fraction_loss_feedback"}}, |
| 212 | {"receiveside_bwe", |
| 213 | {"incoming_packet_sizes", "incoming_delay", "incoming_loss_rate", |
Bjorn Terelius | 873a7a9 | 2019-06-13 16:01:17 +0200 | [diff] [blame] | 214 | "incoming_bitrate", "incoming_stream_bitrate", |
| 215 | "simulated_receiveside_bwe"}}, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 216 | {"rtcp_details", |
| 217 | {"incoming_rtcp_fraction_lost", "outgoing_rtcp_fraction_lost", |
Bjorn Terelius | 873a7a9 | 2019-06-13 16:01:17 +0200 | [diff] [blame] | 218 | "incoming_rtcp_cumulative_lost", "outgoing_rtcp_cumulative_lost", |
| 219 | "incoming_rtcp_highest_seq_number", "outgoing_rtcp_highest_seq_number", |
| 220 | "incoming_rtcp_delay_since_last_sr", |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 221 | "outgoing_rtcp_delay_since_last_sr"}}, |
| 222 | {"simulated_neteq_stats", |
| 223 | {"simulated_neteq_jitter_buffer_delay", |
Bjorn Terelius | 873a7a9 | 2019-06-13 16:01:17 +0200 | [diff] [blame] | 224 | "simulated_neteq_preferred_buffer_size", |
| 225 | "simulated_neteq_concealment_events", |
| 226 | "simulated_neteq_packet_loss_rate", "simulated_neteq_preemptive_rate", |
| 227 | "simulated_neteq_accelerate_rate", "simulated_neteq_speech_expand_rate", |
| 228 | "simulated_neteq_expand_rate"}}}; |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 229 | |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 230 | std::vector<std::string> plot_flags = |
| 231 | StrSplit(absl::GetFlag(FLAGS_plot), ","); |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 232 | |
Bjorn Terelius | edab301 | 2018-01-31 17:23:40 +0100 | [diff] [blame] | 233 | // InitFieldTrialsFromString stores the char*, so the char array must outlive |
| 234 | // the application. |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 235 | const std::string field_trials = absl::GetFlag(FLAGS_force_fieldtrials); |
| 236 | webrtc::field_trial::InitFieldTrialsFromString(field_trials.c_str()); |
stefan | 985d280 | 2016-11-15 06:54:09 -0800 | [diff] [blame] | 237 | |
Sebastian Jansson | b290a6d | 2019-01-03 14:46:23 +0100 | [diff] [blame] | 238 | webrtc::ParsedRtcEventLog::UnconfiguredHeaderExtensions header_extensions = |
| 239 | webrtc::ParsedRtcEventLog::UnconfiguredHeaderExtensions::kDontParse; |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 240 | if (absl::GetFlag(FLAGS_parse_unconfigured_header_extensions)) { |
Sebastian Jansson | b290a6d | 2019-01-03 14:46:23 +0100 | [diff] [blame] | 241 | header_extensions = webrtc::ParsedRtcEventLog:: |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 242 | UnconfiguredHeaderExtensions::kAttemptWebrtcDefaultConfig; |
| 243 | } |
Sebastian Jansson | b290a6d | 2019-01-03 14:46:23 +0100 | [diff] [blame] | 244 | webrtc::ParsedRtcEventLog parsed_log(header_extensions); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 245 | |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 246 | if (args.size() == 2) { |
| 247 | std::string filename = args[1]; |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 248 | if (!parsed_log.ParseFile(filename)) { |
| 249 | std::cerr << "Could not parse the entire log file." << std::endl; |
| 250 | std::cerr << "Only the parsable events will be analyzed." << std::endl; |
| 251 | } |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 252 | } |
| 253 | |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 254 | webrtc::EventLogAnalyzer analyzer(parsed_log, |
| 255 | absl::GetFlag(FLAGS_normalize_time)); |
Bjorn Terelius | ef73f59 | 2018-09-10 20:11:49 +0200 | [diff] [blame] | 256 | std::unique_ptr<webrtc::PlotCollection> collection; |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 257 | if (absl::GetFlag(FLAGS_protobuf_output)) { |
Bjorn Terelius | ef73f59 | 2018-09-10 20:11:49 +0200 | [diff] [blame] | 258 | collection.reset(new webrtc::ProtobufPlotCollection()); |
| 259 | } else { |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 260 | collection.reset( |
| 261 | new webrtc::PythonPlotCollection(absl::GetFlag(FLAGS_shared_xaxis))); |
Bjorn Terelius | ef73f59 | 2018-09-10 20:11:49 +0200 | [diff] [blame] | 262 | } |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 263 | |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 264 | PlotMap plots; |
| 265 | plots.RegisterPlot("incoming_packet_sizes", [&](Plot* plot) { |
| 266 | analyzer.CreatePacketGraph(webrtc::kIncomingPacket, plot); |
| 267 | }); |
| 268 | |
| 269 | plots.RegisterPlot("outgoing_packet_sizes", [&](Plot* plot) { |
| 270 | analyzer.CreatePacketGraph(webrtc::kOutgoingPacket, plot); |
| 271 | }); |
| 272 | plots.RegisterPlot("incoming_rtcp_types", [&](Plot* plot) { |
| 273 | analyzer.CreateRtcpTypeGraph(webrtc::kIncomingPacket, plot); |
| 274 | }); |
| 275 | plots.RegisterPlot("outgoing_rtcp_types", [&](Plot* plot) { |
| 276 | analyzer.CreateRtcpTypeGraph(webrtc::kOutgoingPacket, plot); |
| 277 | }); |
| 278 | plots.RegisterPlot("incoming_packet_count", [&](Plot* plot) { |
| 279 | analyzer.CreateAccumulatedPacketsGraph(webrtc::kIncomingPacket, plot); |
| 280 | }); |
| 281 | plots.RegisterPlot("outgoing_packet_count", [&](Plot* plot) { |
| 282 | analyzer.CreateAccumulatedPacketsGraph(webrtc::kOutgoingPacket, plot); |
| 283 | }); |
| 284 | plots.RegisterPlot("audio_playout", |
| 285 | [&](Plot* plot) { analyzer.CreatePlayoutGraph(plot); }); |
| 286 | plots.RegisterPlot("incoming_audio_level", [&](Plot* plot) { |
| 287 | analyzer.CreateAudioLevelGraph(webrtc::kIncomingPacket, plot); |
| 288 | }); |
| 289 | plots.RegisterPlot("outgoing_audio_level", [&](Plot* plot) { |
| 290 | analyzer.CreateAudioLevelGraph(webrtc::kOutgoingPacket, plot); |
| 291 | }); |
| 292 | plots.RegisterPlot("incoming_sequence_number_delta", [&](Plot* plot) { |
| 293 | analyzer.CreateSequenceNumberGraph(plot); |
| 294 | }); |
| 295 | plots.RegisterPlot("incoming_delay", [&](Plot* plot) { |
| 296 | analyzer.CreateIncomingDelayGraph(plot); |
| 297 | }); |
| 298 | plots.RegisterPlot("incoming_loss_rate", [&](Plot* plot) { |
| 299 | analyzer.CreateIncomingPacketLossGraph(plot); |
| 300 | }); |
| 301 | plots.RegisterPlot("incoming_bitrate", [&](Plot* plot) { |
| 302 | analyzer.CreateTotalIncomingBitrateGraph(plot); |
| 303 | }); |
| 304 | plots.RegisterPlot("outgoing_bitrate", [&](Plot* plot) { |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 305 | analyzer.CreateTotalOutgoingBitrateGraph( |
| 306 | plot, absl::GetFlag(FLAGS_show_detector_state), |
| 307 | absl::GetFlag(FLAGS_show_alr_state)); |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 308 | }); |
| 309 | plots.RegisterPlot("incoming_stream_bitrate", [&](Plot* plot) { |
| 310 | analyzer.CreateStreamBitrateGraph(webrtc::kIncomingPacket, plot); |
| 311 | }); |
| 312 | plots.RegisterPlot("outgoing_stream_bitrate", [&](Plot* plot) { |
| 313 | analyzer.CreateStreamBitrateGraph(webrtc::kOutgoingPacket, plot); |
| 314 | }); |
| 315 | plots.RegisterPlot("incoming_layer_bitrate_allocation", [&](Plot* plot) { |
| 316 | analyzer.CreateBitrateAllocationGraph(webrtc::kIncomingPacket, plot); |
| 317 | }); |
| 318 | plots.RegisterPlot("outgoing_layer_bitrate_allocation", [&](Plot* plot) { |
| 319 | analyzer.CreateBitrateAllocationGraph(webrtc::kOutgoingPacket, plot); |
| 320 | }); |
| 321 | plots.RegisterPlot("simulated_receiveside_bwe", [&](Plot* plot) { |
| 322 | analyzer.CreateReceiveSideBweSimulationGraph(plot); |
| 323 | }); |
| 324 | plots.RegisterPlot("simulated_sendside_bwe", [&](Plot* plot) { |
| 325 | analyzer.CreateSendSideBweSimulationGraph(plot); |
| 326 | }); |
| 327 | plots.RegisterPlot("simulated_goog_cc", [&](Plot* plot) { |
| 328 | analyzer.CreateGoogCcSimulationGraph(plot); |
| 329 | }); |
| 330 | plots.RegisterPlot("network_delay_feedback", [&](Plot* plot) { |
| 331 | analyzer.CreateNetworkDelayFeedbackGraph(plot); |
| 332 | }); |
| 333 | plots.RegisterPlot("fraction_loss_feedback", [&](Plot* plot) { |
| 334 | analyzer.CreateFractionLossGraph(plot); |
| 335 | }); |
| 336 | plots.RegisterPlot("incoming_timestamps", [&](Plot* plot) { |
| 337 | analyzer.CreateTimestampGraph(webrtc::kIncomingPacket, plot); |
| 338 | }); |
| 339 | plots.RegisterPlot("outgoing_timestamps", [&](Plot* plot) { |
| 340 | analyzer.CreateTimestampGraph(webrtc::kOutgoingPacket, plot); |
| 341 | }); |
| 342 | |
| 343 | auto GetFractionLost = [](const webrtc::rtcp::ReportBlock& block) -> float { |
| 344 | return static_cast<double>(block.fraction_lost()) / 256 * 100; |
| 345 | }; |
| 346 | plots.RegisterPlot("incoming_rtcp_fraction_lost", [&](Plot* plot) { |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 347 | analyzer.CreateSenderAndReceiverReportPlot( |
| 348 | webrtc::kIncomingPacket, GetFractionLost, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 349 | "Fraction lost (incoming RTCP)", "Loss rate (percent)", plot); |
| 350 | }); |
| 351 | plots.RegisterPlot("outgoing_rtcp_fraction_lost", [&](Plot* plot) { |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 352 | analyzer.CreateSenderAndReceiverReportPlot( |
| 353 | webrtc::kOutgoingPacket, GetFractionLost, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 354 | "Fraction lost (outgoing RTCP)", "Loss rate (percent)", plot); |
| 355 | }); |
| 356 | auto GetCumulativeLost = [](const webrtc::rtcp::ReportBlock& block) -> float { |
| 357 | return block.cumulative_lost_signed(); |
| 358 | }; |
| 359 | plots.RegisterPlot("incoming_rtcp_cumulative_lost", [&](Plot* plot) { |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 360 | analyzer.CreateSenderAndReceiverReportPlot( |
| 361 | webrtc::kIncomingPacket, GetCumulativeLost, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 362 | "Cumulative lost packets (incoming RTCP)", "Packets", plot); |
| 363 | }); |
| 364 | plots.RegisterPlot("outgoing_rtcp_cumulative_lost", [&](Plot* plot) { |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 365 | analyzer.CreateSenderAndReceiverReportPlot( |
| 366 | webrtc::kOutgoingPacket, GetCumulativeLost, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 367 | "Cumulative lost packets (outgoing RTCP)", "Packets", plot); |
| 368 | }); |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 369 | |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 370 | auto GetHighestSeqNumber = |
| 371 | [](const webrtc::rtcp::ReportBlock& block) -> float { |
| 372 | return block.extended_high_seq_num(); |
| 373 | }; |
| 374 | plots.RegisterPlot("incoming_rtcp_highest_seq_number", [&](Plot* plot) { |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 375 | analyzer.CreateSenderAndReceiverReportPlot( |
| 376 | webrtc::kIncomingPacket, GetHighestSeqNumber, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 377 | "Highest sequence number (incoming RTCP)", "Sequence number", plot); |
| 378 | }); |
| 379 | plots.RegisterPlot("outgoing_rtcp_highest_seq_number", [&](Plot* plot) { |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 380 | analyzer.CreateSenderAndReceiverReportPlot( |
| 381 | webrtc::kOutgoingPacket, GetHighestSeqNumber, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 382 | "Highest sequence number (outgoing RTCP)", "Sequence number", plot); |
| 383 | }); |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 384 | |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 385 | auto DelaySinceLastSr = [](const webrtc::rtcp::ReportBlock& block) -> float { |
| 386 | return static_cast<double>(block.delay_since_last_sr()) / 65536; |
| 387 | }; |
| 388 | plots.RegisterPlot("incoming_rtcp_delay_since_last_sr", [&](Plot* plot) { |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 389 | analyzer.CreateSenderAndReceiverReportPlot( |
| 390 | webrtc::kIncomingPacket, DelaySinceLastSr, |
| 391 | "Delay since last received sender report (incoming RTCP)", "Time (s)", |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 392 | plot); |
| 393 | }); |
| 394 | plots.RegisterPlot("outgoing_rtcp_delay_since_last_sr", [&](Plot* plot) { |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 395 | analyzer.CreateSenderAndReceiverReportPlot( |
| 396 | webrtc::kOutgoingPacket, DelaySinceLastSr, |
| 397 | "Delay since last received sender report (outgoing RTCP)", "Time (s)", |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 398 | plot); |
| 399 | }); |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 400 | |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 401 | plots.RegisterPlot("pacer_delay", |
| 402 | [&](Plot* plot) { analyzer.CreatePacerDelayGraph(plot); }); |
| 403 | plots.RegisterPlot("audio_encoder_bitrate", [&](Plot* plot) { |
| 404 | analyzer.CreateAudioEncoderTargetBitrateGraph(plot); |
| 405 | }); |
| 406 | plots.RegisterPlot("audio_encoder_frame_length", [&](Plot* plot) { |
| 407 | analyzer.CreateAudioEncoderFrameLengthGraph(plot); |
| 408 | }); |
| 409 | plots.RegisterPlot("audio_encoder_packet_loss", [&](Plot* plot) { |
| 410 | analyzer.CreateAudioEncoderPacketLossGraph(plot); |
| 411 | }); |
| 412 | plots.RegisterPlot("audio_encoder_fec", [&](Plot* plot) { |
| 413 | analyzer.CreateAudioEncoderEnableFecGraph(plot); |
| 414 | }); |
| 415 | plots.RegisterPlot("audio_encoder_dtx", [&](Plot* plot) { |
| 416 | analyzer.CreateAudioEncoderEnableDtxGraph(plot); |
| 417 | }); |
| 418 | plots.RegisterPlot("audio_encoder_num_channels", [&](Plot* plot) { |
| 419 | analyzer.CreateAudioEncoderNumChannelsGraph(plot); |
| 420 | }); |
| 421 | |
| 422 | plots.RegisterPlot("ice_candidate_pair_config", [&](Plot* plot) { |
| 423 | analyzer.CreateIceCandidatePairConfigGraph(plot); |
| 424 | }); |
| 425 | plots.RegisterPlot("ice_connectivity_check", [&](Plot* plot) { |
| 426 | analyzer.CreateIceConnectivityCheckGraph(plot); |
| 427 | }); |
| 428 | plots.RegisterPlot("dtls_transport_state", [&](Plot* plot) { |
| 429 | analyzer.CreateDtlsTransportStateGraph(plot); |
| 430 | }); |
| 431 | plots.RegisterPlot("dtls_writable_state", [&](Plot* plot) { |
| 432 | analyzer.CreateDtlsWritableStateGraph(plot); |
| 433 | }); |
| 434 | |
| 435 | std::string wav_path; |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 436 | if (!absl::GetFlag(FLAGS_wav_filename).empty()) { |
| 437 | wav_path = absl::GetFlag(FLAGS_wav_filename); |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 438 | } else { |
| 439 | wav_path = webrtc::test::ResourcePath( |
| 440 | "audio_processing/conversational_speech/EN_script2_F_sp2_B1", "wav"); |
Bjorn Terelius | 0295a96 | 2017-10-25 17:42:41 +0200 | [diff] [blame] | 441 | } |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 442 | absl::optional<webrtc::EventLogAnalyzer::NetEqStatsGetterMap> neteq_stats; |
| 443 | |
| 444 | plots.RegisterPlot("simulated_neteq_expand_rate", [&](Plot* plot) { |
| 445 | if (!neteq_stats) { |
| 446 | neteq_stats = analyzer.SimulateNetEq(wav_path, 48000); |
Minyue Li | 45fc6df | 2018-06-21 11:47:14 +0200 | [diff] [blame] | 447 | } |
Minyue Li | c9ac93f | 2018-06-26 13:01:32 +0200 | [diff] [blame] | 448 | analyzer.CreateNetEqNetworkStatsGraph( |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 449 | *neteq_stats, |
Minyue Li | 27e2b7d | 2018-05-07 15:20:24 +0200 | [diff] [blame] | 450 | [](const webrtc::NetEqNetworkStatistics& stats) { |
| 451 | return stats.expand_rate / 16384.f; |
| 452 | }, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 453 | "Expand rate", plot); |
| 454 | }); |
| 455 | |
| 456 | plots.RegisterPlot("simulated_neteq_speech_expand_rate", [&](Plot* plot) { |
| 457 | if (!neteq_stats) { |
| 458 | neteq_stats = analyzer.SimulateNetEq(wav_path, 48000); |
| 459 | } |
Minyue Li | c9ac93f | 2018-06-26 13:01:32 +0200 | [diff] [blame] | 460 | analyzer.CreateNetEqNetworkStatsGraph( |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 461 | *neteq_stats, |
Minyue Li | 27e2b7d | 2018-05-07 15:20:24 +0200 | [diff] [blame] | 462 | [](const webrtc::NetEqNetworkStatistics& stats) { |
| 463 | return stats.speech_expand_rate / 16384.f; |
| 464 | }, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 465 | "Speech expand rate", plot); |
| 466 | }); |
| 467 | |
| 468 | plots.RegisterPlot("simulated_neteq_accelerate_rate", [&](Plot* plot) { |
| 469 | if (!neteq_stats) { |
| 470 | neteq_stats = analyzer.SimulateNetEq(wav_path, 48000); |
| 471 | } |
Minyue Li | c9ac93f | 2018-06-26 13:01:32 +0200 | [diff] [blame] | 472 | analyzer.CreateNetEqNetworkStatsGraph( |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 473 | *neteq_stats, |
Minyue Li | 27e2b7d | 2018-05-07 15:20:24 +0200 | [diff] [blame] | 474 | [](const webrtc::NetEqNetworkStatistics& stats) { |
| 475 | return stats.accelerate_rate / 16384.f; |
| 476 | }, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 477 | "Accelerate rate", plot); |
| 478 | }); |
| 479 | |
| 480 | plots.RegisterPlot("simulated_neteq_preemptive_rate", [&](Plot* plot) { |
| 481 | if (!neteq_stats) { |
| 482 | neteq_stats = analyzer.SimulateNetEq(wav_path, 48000); |
| 483 | } |
Minyue Li | c9ac93f | 2018-06-26 13:01:32 +0200 | [diff] [blame] | 484 | analyzer.CreateNetEqNetworkStatsGraph( |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 485 | *neteq_stats, |
Minyue Li | 27e2b7d | 2018-05-07 15:20:24 +0200 | [diff] [blame] | 486 | [](const webrtc::NetEqNetworkStatistics& stats) { |
Jakob Ivarsson | 21f6fd7 | 2019-04-04 10:15:02 +0200 | [diff] [blame] | 487 | return stats.preemptive_rate / 16384.f; |
| 488 | }, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 489 | "Preemptive rate", plot); |
| 490 | }); |
| 491 | |
| 492 | plots.RegisterPlot("simulated_neteq_packet_loss_rate", [&](Plot* plot) { |
| 493 | if (!neteq_stats) { |
| 494 | neteq_stats = analyzer.SimulateNetEq(wav_path, 48000); |
| 495 | } |
Jakob Ivarsson | 21f6fd7 | 2019-04-04 10:15:02 +0200 | [diff] [blame] | 496 | analyzer.CreateNetEqNetworkStatsGraph( |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 497 | *neteq_stats, |
Jakob Ivarsson | 21f6fd7 | 2019-04-04 10:15:02 +0200 | [diff] [blame] | 498 | [](const webrtc::NetEqNetworkStatistics& stats) { |
Minyue Li | 27e2b7d | 2018-05-07 15:20:24 +0200 | [diff] [blame] | 499 | return stats.packet_loss_rate / 16384.f; |
| 500 | }, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 501 | "Packet loss rate", plot); |
| 502 | }); |
| 503 | |
| 504 | plots.RegisterPlot("simulated_neteq_concealment_events", [&](Plot* plot) { |
| 505 | if (!neteq_stats) { |
| 506 | neteq_stats = analyzer.SimulateNetEq(wav_path, 48000); |
| 507 | } |
Minyue Li | c9ac93f | 2018-06-26 13:01:32 +0200 | [diff] [blame] | 508 | analyzer.CreateNetEqLifetimeStatsGraph( |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 509 | *neteq_stats, |
Minyue Li | c9ac93f | 2018-06-26 13:01:32 +0200 | [diff] [blame] | 510 | [](const webrtc::NetEqLifetimeStatistics& stats) { |
| 511 | return static_cast<float>(stats.concealment_events); |
| 512 | }, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 513 | "Concealment events", plot); |
| 514 | }); |
| 515 | |
| 516 | plots.RegisterPlot("simulated_neteq_preferred_buffer_size", [&](Plot* plot) { |
| 517 | if (!neteq_stats) { |
| 518 | neteq_stats = analyzer.SimulateNetEq(wav_path, 48000); |
| 519 | } |
Jakob Ivarsson | 21f6fd7 | 2019-04-04 10:15:02 +0200 | [diff] [blame] | 520 | analyzer.CreateNetEqNetworkStatsGraph( |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 521 | *neteq_stats, |
Jakob Ivarsson | 21f6fd7 | 2019-04-04 10:15:02 +0200 | [diff] [blame] | 522 | [](const webrtc::NetEqNetworkStatistics& stats) { |
| 523 | return stats.preferred_buffer_size_ms; |
| 524 | }, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 525 | "Preferred buffer size (ms)", plot); |
| 526 | }); |
| 527 | |
| 528 | if (absl::c_find(plot_flags, "all") != plot_flags.end()) { |
| 529 | plots.EnableAllPlots(); |
| 530 | // Treated separately since it isn't registered like the other plots. |
| 531 | plot_flags.push_back("simulated_neteq_jitter_buffer_delay"); |
| 532 | } else { |
| 533 | bool success = plots.EnablePlotsByFlags(plot_flags, flag_aliases); |
| 534 | if (!success) { |
| 535 | return 1; |
| 536 | } |
henrik.lundin | 3c938fc | 2017-06-14 06:09:58 -0700 | [diff] [blame] | 537 | } |
| 538 | |
Mirko Bonadei | f2d97b8 | 2019-07-24 15:29:47 +0200 | [diff] [blame] | 539 | if (absl::GetFlag(FLAGS_list_plots)) { |
| 540 | std::cerr << "List of registered plots (for use with the --plot flag):" |
| 541 | << std::endl; |
| 542 | for (const auto& plot : plots) { |
| 543 | // TODO(terelius): Also print a help text. |
| 544 | std::cerr << " " << plot.label << std::endl; |
| 545 | } |
| 546 | // The following flag doesn't fit the model used for the other plots. |
| 547 | std::cerr << "simulated_neteq_jitter_buffer_delay" << std::endl; |
| 548 | std::cerr << "List of plot aliases (for use with the --plot flag):" |
| 549 | << std::endl; |
| 550 | std::cerr << " all = every registered plot" << std::endl; |
| 551 | for (const auto& alias : flag_aliases) { |
| 552 | std::cerr << " " << alias.first << " = "; |
| 553 | for (const auto& replacement : alias.second) { |
| 554 | std::cerr << replacement << ","; |
| 555 | } |
| 556 | std::cerr << std::endl; |
| 557 | } |
| 558 | return 0; |
| 559 | } |
| 560 | if (args.size() != 2) { |
| 561 | // Print usage information. |
| 562 | std::cerr << absl::ProgramUsageMessage(); |
| 563 | return 1; |
| 564 | } |
Qingsi Wang | 8eca1ff | 2018-02-02 11:49:44 -0800 | [diff] [blame] | 565 | |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 566 | for (const auto& plot : plots) { |
| 567 | if (plot.enabled) { |
| 568 | Plot* output = collection->AppendNewPlot(); |
| 569 | plot.plot_func(output); |
| 570 | output->SetId(plot.label); |
| 571 | } |
Zach Stein | 10a5801 | 2018-12-07 12:26:28 -0800 | [diff] [blame] | 572 | } |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 573 | |
| 574 | // The model we use for registering plots assumes that the each plot label |
| 575 | // can be mapped to a lambda that will produce exactly one plot. The |
| 576 | // simulated_neteq_jitter_buffer_delay plot doesn't fit this model since it |
| 577 | // creates multiple plots, and would need some state kept between the lambda |
| 578 | // calls. |
| 579 | if (absl::c_find(plot_flags, "simulated_neteq_jitter_buffer_delay") != |
| 580 | plot_flags.end()) { |
| 581 | if (!neteq_stats) { |
| 582 | neteq_stats = analyzer.SimulateNetEq(wav_path, 48000); |
| 583 | } |
| 584 | for (webrtc::EventLogAnalyzer::NetEqStatsGetterMap::const_iterator it = |
| 585 | neteq_stats->cbegin(); |
| 586 | it != neteq_stats->cend(); ++it) { |
| 587 | analyzer.CreateAudioJitterBufferGraph(it->first, it->second.get(), |
| 588 | collection->AppendNewPlot()); |
| 589 | } |
Zach Stein | 10a5801 | 2018-12-07 12:26:28 -0800 | [diff] [blame] | 590 | } |
| 591 | |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 592 | collection->Draw(); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 593 | |
Mirko Bonadei | 4b091f4 | 2019-07-16 11:55:08 +0200 | [diff] [blame] | 594 | if (absl::GetFlag(FLAGS_print_triage_alerts)) { |
Bjorn Terelius | 2eb3188 | 2017-11-30 15:15:25 +0100 | [diff] [blame] | 595 | analyzer.CreateTriageNotifications(); |
| 596 | analyzer.PrintNotifications(stderr); |
| 597 | } |
| 598 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 599 | return 0; |
| 600 | } |