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> |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 19 | |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 20 | #include "absl/algorithm/container.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 21 | #include "logging/rtc_event_log/rtc_event_log.h" |
Sebastian Jansson | b290a6d | 2019-01-03 14:46:23 +0100 | [diff] [blame] | 22 | #include "logging/rtc_event_log/rtc_event_log_parser.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 23 | #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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 26 | #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 Terelius | ef73f59 | 2018-09-10 20:11:49 +0200 | [diff] [blame] | 29 | #include "rtc_tools/event_log_visualizer/plot_protobuf.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 30 | #include "rtc_tools/event_log_visualizer/plot_python.h" |
Mirko Bonadei | 17f4878 | 2018-09-28 08:51:10 +0200 | [diff] [blame] | 31 | #include "system_wrappers/include/field_trial.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 32 | #include "test/field_trial.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 33 | #include "test/testsupport/file_utils.h" |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 34 | |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 35 | WEBRTC_DEFINE_string( |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 36 | plot, |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 37 | "default", |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 38 | "A comma separated list of plot names. See below for valid options."); |
Bjorn Terelius | 1edfff9 | 2017-10-11 13:15:19 +0200 | [diff] [blame] | 39 | |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 40 | WEBRTC_DEFINE_string( |
stefan | 985d280 | 2016-11-15 06:54:09 -0800 | [diff] [blame] | 41 | 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 Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 47 | WEBRTC_DEFINE_string(wav_filename, |
| 48 | "", |
| 49 | "Path to wav file used for simulation of jitter buffer"); |
| 50 | WEBRTC_DEFINE_bool(help, false, "prints this message"); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 51 | |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 52 | WEBRTC_DEFINE_bool( |
| 53 | show_detector_state, |
| 54 | false, |
| 55 | "Show the state of the delay based BWE detector on the total " |
| 56 | "bitrate graph"); |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 57 | |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 58 | WEBRTC_DEFINE_bool(show_alr_state, |
| 59 | false, |
| 60 | "Show the state ALR state on the total bitrate graph"); |
Ilya Nikolaevskiy | a4259f6 | 2017-12-05 13:19:45 +0100 | [diff] [blame] | 61 | |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 62 | WEBRTC_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 Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 68 | |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 69 | WEBRTC_DEFINE_bool(print_triage_alerts, |
| 70 | false, |
| 71 | "Print triage alerts, i.e. a list of potential problems."); |
Bjorn Terelius | 2eb3188 | 2017-11-30 15:15:25 +0100 | [diff] [blame] | 72 | |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 73 | WEBRTC_DEFINE_bool( |
| 74 | normalize_time, |
| 75 | true, |
| 76 | "Normalize the log timestamps so that the call starts at time 0."); |
Stefan Holmer | 1d4a227 | 2018-05-24 13:48:09 +0200 | [diff] [blame] | 77 | |
Bjorn Terelius | ff8cce3 | 2019-04-11 18:34:01 +0200 | [diff] [blame] | 78 | WEBRTC_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 Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 84 | WEBRTC_DEFINE_bool(protobuf_output, |
| 85 | false, |
| 86 | "Output charts as protobuf instead of python code."); |
Bjorn Terelius | ef73f59 | 2018-09-10 20:11:49 +0200 | [diff] [blame] | 87 | |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 88 | using webrtc::Plot; |
| 89 | |
| 90 | namespace { |
| 91 | std::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 | |
| 103 | struct 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 | |
| 112 | class 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 |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 169 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 170 | int 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"; |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 177 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 178 | rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true); |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 179 | |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 180 | // Flag replacements |
| 181 | std::map<std::string, std::vector<std::string>> flag_aliases = { |
| 182 | {"default", |
| 183 | {"incoming_delay", "incoming_loss_rate", "incoming_bitrate", |
Bjorn Terelius | 873a7a9 | 2019-06-13 16:01:17 +0200 | [diff] [blame] | 184 | "outgoing_bitrate", "incoming_stream_bitrate", |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 185 | "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 Terelius | 873a7a9 | 2019-06-13 16:01:17 +0200 | [diff] [blame] | 193 | "incoming_bitrate", "incoming_stream_bitrate", |
| 194 | "simulated_receiveside_bwe"}}, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 195 | {"rtcp_details", |
| 196 | {"incoming_rtcp_fraction_lost", "outgoing_rtcp_fraction_lost", |
Bjorn Terelius | 873a7a9 | 2019-06-13 16:01:17 +0200 | [diff] [blame] | 197 | "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 Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 200 | "outgoing_rtcp_delay_since_last_sr"}}, |
| 201 | {"simulated_neteq_stats", |
| 202 | {"simulated_neteq_jitter_buffer_delay", |
Bjorn Terelius | 873a7a9 | 2019-06-13 16:01:17 +0200 | [diff] [blame] | 203 | "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 Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 208 | |
| 209 | std::vector<std::string> plot_flags = StrSplit(FLAG_plot, ","); |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 210 | |
Bjorn Terelius | edab301 | 2018-01-31 17:23:40 +0100 | [diff] [blame] | 211 | // InitFieldTrialsFromString stores the char*, so the char array must outlive |
| 212 | // the application. |
| 213 | webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials); |
stefan | 985d280 | 2016-11-15 06:54:09 -0800 | [diff] [blame] | 214 | |
Sebastian Jansson | b290a6d | 2019-01-03 14:46:23 +0100 | [diff] [blame] | 215 | webrtc::ParsedRtcEventLog::UnconfiguredHeaderExtensions header_extensions = |
| 216 | webrtc::ParsedRtcEventLog::UnconfiguredHeaderExtensions::kDontParse; |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 217 | if (FLAG_parse_unconfigured_header_extensions) { |
Sebastian Jansson | b290a6d | 2019-01-03 14:46:23 +0100 | [diff] [blame] | 218 | header_extensions = webrtc::ParsedRtcEventLog:: |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 219 | UnconfiguredHeaderExtensions::kAttemptWebrtcDefaultConfig; |
| 220 | } |
Sebastian Jansson | b290a6d | 2019-01-03 14:46:23 +0100 | [diff] [blame] | 221 | webrtc::ParsedRtcEventLog parsed_log(header_extensions); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 222 | |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 223 | 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 | } |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 229 | } |
| 230 | |
Stefan Holmer | 1d4a227 | 2018-05-24 13:48:09 +0200 | [diff] [blame] | 231 | webrtc::EventLogAnalyzer analyzer(parsed_log, FLAG_normalize_time); |
Bjorn Terelius | ef73f59 | 2018-09-10 20:11:49 +0200 | [diff] [blame] | 232 | std::unique_ptr<webrtc::PlotCollection> collection; |
| 233 | if (FLAG_protobuf_output) { |
| 234 | collection.reset(new webrtc::ProtobufPlotCollection()); |
| 235 | } else { |
Bjorn Terelius | ff8cce3 | 2019-04-11 18:34:01 +0200 | [diff] [blame] | 236 | collection.reset(new webrtc::PythonPlotCollection(FLAG_shared_xaxis)); |
Bjorn Terelius | ef73f59 | 2018-09-10 20:11:49 +0200 | [diff] [blame] | 237 | } |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 238 | |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 239 | 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 Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 281 | FLAG_show_alr_state); |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 282 | }); |
| 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 Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 321 | analyzer.CreateSenderAndReceiverReportPlot( |
| 322 | webrtc::kIncomingPacket, GetFractionLost, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 323 | "Fraction lost (incoming RTCP)", "Loss rate (percent)", plot); |
| 324 | }); |
| 325 | plots.RegisterPlot("outgoing_rtcp_fraction_lost", [&](Plot* plot) { |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 326 | analyzer.CreateSenderAndReceiverReportPlot( |
| 327 | webrtc::kOutgoingPacket, GetFractionLost, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 328 | "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 Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 334 | analyzer.CreateSenderAndReceiverReportPlot( |
| 335 | webrtc::kIncomingPacket, GetCumulativeLost, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 336 | "Cumulative lost packets (incoming RTCP)", "Packets", plot); |
| 337 | }); |
| 338 | plots.RegisterPlot("outgoing_rtcp_cumulative_lost", [&](Plot* plot) { |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 339 | analyzer.CreateSenderAndReceiverReportPlot( |
| 340 | webrtc::kOutgoingPacket, GetCumulativeLost, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 341 | "Cumulative lost packets (outgoing RTCP)", "Packets", plot); |
| 342 | }); |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 343 | |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 344 | 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 Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 349 | analyzer.CreateSenderAndReceiverReportPlot( |
| 350 | webrtc::kIncomingPacket, GetHighestSeqNumber, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 351 | "Highest sequence number (incoming RTCP)", "Sequence number", plot); |
| 352 | }); |
| 353 | plots.RegisterPlot("outgoing_rtcp_highest_seq_number", [&](Plot* plot) { |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 354 | analyzer.CreateSenderAndReceiverReportPlot( |
| 355 | webrtc::kOutgoingPacket, GetHighestSeqNumber, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 356 | "Highest sequence number (outgoing RTCP)", "Sequence number", plot); |
| 357 | }); |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 358 | |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 359 | 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 Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 363 | analyzer.CreateSenderAndReceiverReportPlot( |
| 364 | webrtc::kIncomingPacket, DelaySinceLastSr, |
| 365 | "Delay since last received sender report (incoming RTCP)", "Time (s)", |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 366 | plot); |
| 367 | }); |
| 368 | plots.RegisterPlot("outgoing_rtcp_delay_since_last_sr", [&](Plot* plot) { |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 369 | analyzer.CreateSenderAndReceiverReportPlot( |
| 370 | webrtc::kOutgoingPacket, DelaySinceLastSr, |
| 371 | "Delay since last received sender report (outgoing RTCP)", "Time (s)", |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 372 | plot); |
| 373 | }); |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 374 | |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 375 | 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 Terelius | 0295a96 | 2017-10-25 17:42:41 +0200 | [diff] [blame] | 415 | } |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 416 | 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 Li | 45fc6df | 2018-06-21 11:47:14 +0200 | [diff] [blame] | 421 | } |
Minyue Li | c9ac93f | 2018-06-26 13:01:32 +0200 | [diff] [blame] | 422 | analyzer.CreateNetEqNetworkStatsGraph( |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 423 | *neteq_stats, |
Minyue Li | 27e2b7d | 2018-05-07 15:20:24 +0200 | [diff] [blame] | 424 | [](const webrtc::NetEqNetworkStatistics& stats) { |
| 425 | return stats.expand_rate / 16384.f; |
| 426 | }, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 427 | "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 Li | c9ac93f | 2018-06-26 13:01:32 +0200 | [diff] [blame] | 434 | analyzer.CreateNetEqNetworkStatsGraph( |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 435 | *neteq_stats, |
Minyue Li | 27e2b7d | 2018-05-07 15:20:24 +0200 | [diff] [blame] | 436 | [](const webrtc::NetEqNetworkStatistics& stats) { |
| 437 | return stats.speech_expand_rate / 16384.f; |
| 438 | }, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 439 | "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 Li | c9ac93f | 2018-06-26 13:01:32 +0200 | [diff] [blame] | 446 | analyzer.CreateNetEqNetworkStatsGraph( |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 447 | *neteq_stats, |
Minyue Li | 27e2b7d | 2018-05-07 15:20:24 +0200 | [diff] [blame] | 448 | [](const webrtc::NetEqNetworkStatistics& stats) { |
| 449 | return stats.accelerate_rate / 16384.f; |
| 450 | }, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 451 | "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 Li | c9ac93f | 2018-06-26 13:01:32 +0200 | [diff] [blame] | 458 | analyzer.CreateNetEqNetworkStatsGraph( |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 459 | *neteq_stats, |
Minyue Li | 27e2b7d | 2018-05-07 15:20:24 +0200 | [diff] [blame] | 460 | [](const webrtc::NetEqNetworkStatistics& stats) { |
Jakob Ivarsson | 21f6fd7 | 2019-04-04 10:15:02 +0200 | [diff] [blame] | 461 | return stats.preemptive_rate / 16384.f; |
| 462 | }, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 463 | "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 Ivarsson | 21f6fd7 | 2019-04-04 10:15:02 +0200 | [diff] [blame] | 470 | analyzer.CreateNetEqNetworkStatsGraph( |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 471 | *neteq_stats, |
Jakob Ivarsson | 21f6fd7 | 2019-04-04 10:15:02 +0200 | [diff] [blame] | 472 | [](const webrtc::NetEqNetworkStatistics& stats) { |
Minyue Li | 27e2b7d | 2018-05-07 15:20:24 +0200 | [diff] [blame] | 473 | return stats.packet_loss_rate / 16384.f; |
| 474 | }, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 475 | "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 Li | c9ac93f | 2018-06-26 13:01:32 +0200 | [diff] [blame] | 482 | analyzer.CreateNetEqLifetimeStatsGraph( |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 483 | *neteq_stats, |
Minyue Li | c9ac93f | 2018-06-26 13:01:32 +0200 | [diff] [blame] | 484 | [](const webrtc::NetEqLifetimeStatistics& stats) { |
| 485 | return static_cast<float>(stats.concealment_events); |
| 486 | }, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 487 | "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 Ivarsson | 21f6fd7 | 2019-04-04 10:15:02 +0200 | [diff] [blame] | 494 | analyzer.CreateNetEqNetworkStatsGraph( |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 495 | *neteq_stats, |
Jakob Ivarsson | 21f6fd7 | 2019-04-04 10:15:02 +0200 | [diff] [blame] | 496 | [](const webrtc::NetEqNetworkStatistics& stats) { |
| 497 | return stats.preferred_buffer_size_ms; |
| 498 | }, |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 499 | "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.lundin | 3c938fc | 2017-06-14 06:09:58 -0700 | [diff] [blame] | 511 | } |
| 512 | |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 513 | 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 Terelius | 873a7a9 | 2019-06-13 16:01:17 +0200 | [diff] [blame] | 528 | std::cerr << " all = every registered plot" << std::endl; |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 529 | 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 Wang | 8eca1ff | 2018-02-02 11:49:44 -0800 | [diff] [blame] | 538 | } |
| 539 | |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 540 | 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 Stein | 10a5801 | 2018-12-07 12:26:28 -0800 | [diff] [blame] | 546 | } |
Bjorn Terelius | 1aa9ee9 | 2019-06-11 17:39:38 +0200 | [diff] [blame] | 547 | |
| 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 Stein | 10a5801 | 2018-12-07 12:26:28 -0800 | [diff] [blame] | 564 | } |
| 565 | |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 566 | collection->Draw(); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 567 | |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 568 | if (FLAG_print_triage_alerts) { |
Bjorn Terelius | 2eb3188 | 2017-11-30 15:15:25 +0100 | [diff] [blame] | 569 | analyzer.CreateTriageNotifications(); |
| 570 | analyzer.PrintNotifications(stderr); |
| 571 | } |
| 572 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 573 | return 0; |
| 574 | } |