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