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> |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 13 | #include <iostream> |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 14 | #include <map> |
| 15 | #include <memory> |
| 16 | #include <string> |
| 17 | #include <utility> |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 18 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 19 | #include "logging/rtc_event_log/rtc_event_log.h" |
Sebastian Jansson | b290a6d | 2019-01-03 14:46:23 +0100 | [diff] [blame] | 20 | #include "logging/rtc_event_log/rtc_event_log_parser.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 21 | #include "modules/audio_coding/neteq/include/neteq.h" |
| 22 | #include "modules/rtp_rtcp/source/rtcp_packet/report_block.h" |
| 23 | #include "rtc_base/checks.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 24 | #include "rtc_base/flags.h" |
| 25 | #include "rtc_tools/event_log_visualizer/analyzer.h" |
| 26 | #include "rtc_tools/event_log_visualizer/plot_base.h" |
Bjorn Terelius | ef73f59 | 2018-09-10 20:11:49 +0200 | [diff] [blame] | 27 | #include "rtc_tools/event_log_visualizer/plot_protobuf.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 28 | #include "rtc_tools/event_log_visualizer/plot_python.h" |
Mirko Bonadei | 17f4878 | 2018-09-28 08:51:10 +0200 | [diff] [blame] | 29 | #include "system_wrappers/include/field_trial.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 30 | #include "test/field_trial.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame^] | 31 | #include "test/testsupport/file_utils.h" |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 32 | |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 33 | WEBRTC_DEFINE_string( |
| 34 | plot_profile, |
| 35 | "default", |
| 36 | "A profile that selects a certain subset of the plots. Currently " |
| 37 | "defined profiles are \"all\", \"none\", \"sendside_bwe\"," |
| 38 | "\"receiveside_bwe\" and \"default\""); |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 39 | |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 40 | WEBRTC_DEFINE_bool(plot_incoming_packet_sizes, |
| 41 | false, |
| 42 | "Plot bar graph showing the size of each incoming packet."); |
| 43 | WEBRTC_DEFINE_bool(plot_outgoing_packet_sizes, |
| 44 | false, |
| 45 | "Plot bar graph showing the size of each outgoing packet."); |
| 46 | WEBRTC_DEFINE_bool( |
| 47 | plot_incoming_packet_count, |
| 48 | false, |
| 49 | "Plot the accumulated number of packets for each incoming stream."); |
| 50 | WEBRTC_DEFINE_bool( |
| 51 | plot_outgoing_packet_count, |
| 52 | false, |
| 53 | "Plot the accumulated number of packets for each outgoing stream."); |
| 54 | WEBRTC_DEFINE_bool( |
| 55 | plot_audio_playout, |
| 56 | false, |
| 57 | "Plot bar graph showing the time between each audio playout."); |
| 58 | WEBRTC_DEFINE_bool( |
| 59 | plot_audio_level, |
| 60 | false, |
| 61 | "Plot line graph showing the audio level of incoming audio."); |
| 62 | WEBRTC_DEFINE_bool( |
| 63 | plot_incoming_sequence_number_delta, |
| 64 | false, |
| 65 | "Plot the sequence number difference between consecutive incoming " |
| 66 | "packets."); |
| 67 | WEBRTC_DEFINE_bool( |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 68 | plot_incoming_delay, |
| 69 | true, |
| 70 | "Plot the 1-way path delay for incoming packets, normalized so " |
| 71 | "that the first packet has delay 0."); |
| 72 | WEBRTC_DEFINE_bool( |
| 73 | plot_incoming_loss_rate, |
| 74 | true, |
| 75 | "Compute the loss rate for incoming packets using a method that's " |
| 76 | "similar to the one used for RTCP SR and RR fraction lost. Note " |
| 77 | "that the loss rate can be negative if packets are duplicated or " |
| 78 | "reordered."); |
| 79 | WEBRTC_DEFINE_bool(plot_incoming_bitrate, |
| 80 | true, |
| 81 | "Plot the total bitrate used by all incoming streams."); |
| 82 | WEBRTC_DEFINE_bool(plot_outgoing_bitrate, |
| 83 | true, |
| 84 | "Plot the total bitrate used by all outgoing streams."); |
| 85 | WEBRTC_DEFINE_bool(plot_incoming_stream_bitrate, |
| 86 | true, |
| 87 | "Plot the bitrate used by each incoming stream."); |
| 88 | WEBRTC_DEFINE_bool(plot_outgoing_stream_bitrate, |
| 89 | true, |
| 90 | "Plot the bitrate used by each outgoing stream."); |
| 91 | WEBRTC_DEFINE_bool( |
| 92 | plot_simulated_receiveside_bwe, |
| 93 | false, |
| 94 | "Run the receive-side bandwidth estimator with the incoming rtp " |
| 95 | "packets and plot the resulting estimate."); |
| 96 | WEBRTC_DEFINE_bool( |
| 97 | plot_simulated_sendside_bwe, |
| 98 | false, |
| 99 | "Run the send-side bandwidth estimator with the outgoing rtp and " |
| 100 | "incoming rtcp and plot the resulting estimate."); |
| 101 | WEBRTC_DEFINE_bool( |
| 102 | plot_network_delay_feedback, |
| 103 | true, |
| 104 | "Compute network delay based on sent packets and the received " |
| 105 | "transport feedback."); |
| 106 | WEBRTC_DEFINE_bool( |
| 107 | plot_fraction_loss_feedback, |
| 108 | true, |
| 109 | "Plot packet loss in percent for outgoing packets (as perceived by " |
| 110 | "the send-side bandwidth estimator)."); |
| 111 | WEBRTC_DEFINE_bool( |
| 112 | plot_pacer_delay, |
| 113 | false, |
| 114 | "Plot the time each sent packet has spent in the pacer (based on " |
| 115 | "the difference between the RTP timestamp and the send " |
| 116 | "timestamp)."); |
| 117 | WEBRTC_DEFINE_bool( |
| 118 | plot_timestamps, |
| 119 | false, |
| 120 | "Plot the rtp timestamps of all rtp and rtcp packets over time."); |
| 121 | WEBRTC_DEFINE_bool( |
| 122 | plot_rtcp_details, |
| 123 | false, |
| 124 | "Plot the contents of all report blocks in all sender and receiver " |
| 125 | "reports. This includes fraction lost, cumulative number of lost " |
| 126 | "packets, extended highest sequence number and time since last " |
| 127 | "received SR."); |
| 128 | WEBRTC_DEFINE_bool(plot_audio_encoder_bitrate_bps, |
| 129 | false, |
| 130 | "Plot the audio encoder target bitrate."); |
| 131 | WEBRTC_DEFINE_bool(plot_audio_encoder_frame_length_ms, |
| 132 | false, |
| 133 | "Plot the audio encoder frame length."); |
| 134 | WEBRTC_DEFINE_bool( |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 135 | plot_audio_encoder_packet_loss, |
michaelt | 6e5b219 | 2017-02-22 07:33:27 -0800 | [diff] [blame] | 136 | false, |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 137 | "Plot the uplink packet loss fraction which is sent to the audio encoder."); |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 138 | WEBRTC_DEFINE_bool(plot_audio_encoder_fec, |
| 139 | false, |
| 140 | "Plot the audio encoder FEC."); |
| 141 | WEBRTC_DEFINE_bool(plot_audio_encoder_dtx, |
| 142 | false, |
| 143 | "Plot the audio encoder DTX."); |
| 144 | WEBRTC_DEFINE_bool(plot_audio_encoder_num_channels, |
| 145 | false, |
| 146 | "Plot the audio encoder number of channels."); |
| 147 | WEBRTC_DEFINE_bool(plot_neteq_stats, false, "Plot the NetEq statistics."); |
| 148 | WEBRTC_DEFINE_bool(plot_ice_candidate_pair_config, |
| 149 | false, |
| 150 | "Plot the ICE candidate pair config events."); |
| 151 | WEBRTC_DEFINE_bool(plot_ice_connectivity_check, |
| 152 | false, |
| 153 | "Plot the ICE candidate pair connectivity checks."); |
Zach Stein | 10a5801 | 2018-12-07 12:26:28 -0800 | [diff] [blame] | 154 | WEBRTC_DEFINE_bool(plot_dtls_transport_state, |
| 155 | false, |
| 156 | "Plot DTLS transport state changes."); |
| 157 | WEBRTC_DEFINE_bool(plot_dtls_writable_state, |
| 158 | false, |
| 159 | "Plot DTLS writable state changes."); |
Bjorn Terelius | 1edfff9 | 2017-10-11 13:15:19 +0200 | [diff] [blame] | 160 | |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 161 | WEBRTC_DEFINE_string( |
stefan | 985d280 | 2016-11-15 06:54:09 -0800 | [diff] [blame] | 162 | force_fieldtrials, |
| 163 | "", |
| 164 | "Field trials control experimental feature code which can be forced. " |
| 165 | "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enabled/" |
| 166 | " will assign the group Enabled to field trial WebRTC-FooFeature. Multiple " |
| 167 | "trials are separated by \"/\""); |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 168 | WEBRTC_DEFINE_string(wav_filename, |
| 169 | "", |
| 170 | "Path to wav file used for simulation of jitter buffer"); |
| 171 | WEBRTC_DEFINE_bool(help, false, "prints this message"); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 172 | |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 173 | WEBRTC_DEFINE_bool( |
| 174 | show_detector_state, |
| 175 | false, |
| 176 | "Show the state of the delay based BWE detector on the total " |
| 177 | "bitrate graph"); |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 178 | |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 179 | WEBRTC_DEFINE_bool(show_alr_state, |
| 180 | false, |
| 181 | "Show the state ALR state on the total bitrate graph"); |
Ilya Nikolaevskiy | a4259f6 | 2017-12-05 13:19:45 +0100 | [diff] [blame] | 182 | |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 183 | WEBRTC_DEFINE_bool( |
| 184 | parse_unconfigured_header_extensions, |
| 185 | true, |
| 186 | "Attempt to parse unconfigured header extensions using the default " |
| 187 | "WebRTC mapping. This can give very misleading results if the " |
| 188 | "application negotiates a different mapping."); |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 189 | |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 190 | WEBRTC_DEFINE_bool(print_triage_alerts, |
| 191 | false, |
| 192 | "Print triage alerts, i.e. a list of potential problems."); |
Bjorn Terelius | 2eb3188 | 2017-11-30 15:15:25 +0100 | [diff] [blame] | 193 | |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 194 | WEBRTC_DEFINE_bool( |
| 195 | normalize_time, |
| 196 | true, |
| 197 | "Normalize the log timestamps so that the call starts at time 0."); |
Stefan Holmer | 1d4a227 | 2018-05-24 13:48:09 +0200 | [diff] [blame] | 198 | |
Mirko Bonadei | 2dfa998 | 2018-10-18 11:35:32 +0200 | [diff] [blame] | 199 | WEBRTC_DEFINE_bool(protobuf_output, |
| 200 | false, |
| 201 | "Output charts as protobuf instead of python code."); |
Bjorn Terelius | ef73f59 | 2018-09-10 20:11:49 +0200 | [diff] [blame] | 202 | |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 203 | void SetAllPlotFlags(bool setting); |
| 204 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 205 | int main(int argc, char* argv[]) { |
| 206 | std::string program_name = argv[0]; |
| 207 | std::string usage = |
| 208 | "A tool for visualizing WebRTC event logs.\n" |
| 209 | "Example usage:\n" + |
| 210 | program_name + " <logfile> | python\n" + "Run " + program_name + |
| 211 | " --help for a list of command line options\n"; |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 212 | |
| 213 | // Parse command line flags without removing them. We're only interested in |
| 214 | // the |plot_profile| flag. |
| 215 | rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, false); |
| 216 | if (strcmp(FLAG_plot_profile, "all") == 0) { |
| 217 | SetAllPlotFlags(true); |
| 218 | } else if (strcmp(FLAG_plot_profile, "none") == 0) { |
| 219 | SetAllPlotFlags(false); |
Bjorn Terelius | 1edfff9 | 2017-10-11 13:15:19 +0200 | [diff] [blame] | 220 | } else if (strcmp(FLAG_plot_profile, "sendside_bwe") == 0) { |
| 221 | SetAllPlotFlags(false); |
| 222 | FLAG_plot_outgoing_packet_sizes = true; |
| 223 | FLAG_plot_outgoing_bitrate = true; |
| 224 | FLAG_plot_outgoing_stream_bitrate = true; |
| 225 | FLAG_plot_simulated_sendside_bwe = true; |
| 226 | FLAG_plot_network_delay_feedback = true; |
| 227 | FLAG_plot_fraction_loss_feedback = true; |
| 228 | } else if (strcmp(FLAG_plot_profile, "receiveside_bwe") == 0) { |
| 229 | SetAllPlotFlags(false); |
| 230 | FLAG_plot_incoming_packet_sizes = true; |
Bjorn Terelius | 1edfff9 | 2017-10-11 13:15:19 +0200 | [diff] [blame] | 231 | FLAG_plot_incoming_delay = true; |
| 232 | FLAG_plot_incoming_loss_rate = true; |
| 233 | FLAG_plot_incoming_bitrate = true; |
| 234 | FLAG_plot_incoming_stream_bitrate = true; |
| 235 | FLAG_plot_simulated_receiveside_bwe = true; |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 236 | } else if (strcmp(FLAG_plot_profile, "default") == 0) { |
| 237 | // Do nothing. |
| 238 | } else { |
| 239 | rtc::Flag* plot_profile_flag = rtc::FlagList::Lookup("plot_profile"); |
| 240 | RTC_CHECK(plot_profile_flag); |
| 241 | plot_profile_flag->Print(false); |
| 242 | } |
| 243 | // Parse the remaining flags. They are applied relative to the chosen profile. |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 244 | rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true); |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 245 | |
terelius | c4a5c14 | 2017-07-20 08:05:09 -0700 | [diff] [blame] | 246 | if (argc != 2 || FLAG_help) { |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 247 | // Print usage information. |
| 248 | std::cout << usage; |
terelius | c4a5c14 | 2017-07-20 08:05:09 -0700 | [diff] [blame] | 249 | if (FLAG_help) |
| 250 | rtc::FlagList::Print(nullptr, false); |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 251 | return 0; |
| 252 | } |
| 253 | |
Bjorn Terelius | edab301 | 2018-01-31 17:23:40 +0100 | [diff] [blame] | 254 | webrtc::test::ValidateFieldTrialsStringOrDie(FLAG_force_fieldtrials); |
| 255 | // InitFieldTrialsFromString stores the char*, so the char array must outlive |
| 256 | // the application. |
| 257 | webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials); |
stefan | 985d280 | 2016-11-15 06:54:09 -0800 | [diff] [blame] | 258 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 259 | std::string filename = argv[1]; |
| 260 | |
Sebastian Jansson | b290a6d | 2019-01-03 14:46:23 +0100 | [diff] [blame] | 261 | webrtc::ParsedRtcEventLog::UnconfiguredHeaderExtensions header_extensions = |
| 262 | webrtc::ParsedRtcEventLog::UnconfiguredHeaderExtensions::kDontParse; |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 263 | if (FLAG_parse_unconfigured_header_extensions) { |
Sebastian Jansson | b290a6d | 2019-01-03 14:46:23 +0100 | [diff] [blame] | 264 | header_extensions = webrtc::ParsedRtcEventLog:: |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 265 | UnconfiguredHeaderExtensions::kAttemptWebrtcDefaultConfig; |
| 266 | } |
Sebastian Jansson | b290a6d | 2019-01-03 14:46:23 +0100 | [diff] [blame] | 267 | webrtc::ParsedRtcEventLog parsed_log(header_extensions); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 268 | |
| 269 | if (!parsed_log.ParseFile(filename)) { |
| 270 | std::cerr << "Could not parse the entire log file." << std::endl; |
Bjorn Terelius | fdc635d | 2018-11-14 13:40:13 +0100 | [diff] [blame] | 271 | std::cerr << "Only the parsable events will be analyzed." << std::endl; |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 272 | } |
| 273 | |
Stefan Holmer | 1d4a227 | 2018-05-24 13:48:09 +0200 | [diff] [blame] | 274 | webrtc::EventLogAnalyzer analyzer(parsed_log, FLAG_normalize_time); |
Bjorn Terelius | ef73f59 | 2018-09-10 20:11:49 +0200 | [diff] [blame] | 275 | std::unique_ptr<webrtc::PlotCollection> collection; |
| 276 | if (FLAG_protobuf_output) { |
| 277 | collection.reset(new webrtc::ProtobufPlotCollection()); |
| 278 | } else { |
| 279 | collection.reset(new webrtc::PythonPlotCollection()); |
| 280 | } |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 281 | |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 282 | if (FLAG_plot_incoming_packet_sizes) { |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 283 | analyzer.CreatePacketGraph(webrtc::kIncomingPacket, |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 284 | collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 285 | } |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 286 | if (FLAG_plot_outgoing_packet_sizes) { |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 287 | analyzer.CreatePacketGraph(webrtc::kOutgoingPacket, |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 288 | collection->AppendNewPlot()); |
| 289 | } |
| 290 | if (FLAG_plot_incoming_packet_count) { |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 291 | analyzer.CreateAccumulatedPacketsGraph(webrtc::kIncomingPacket, |
| 292 | collection->AppendNewPlot()); |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 293 | } |
| 294 | if (FLAG_plot_outgoing_packet_count) { |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 295 | analyzer.CreateAccumulatedPacketsGraph(webrtc::kOutgoingPacket, |
| 296 | collection->AppendNewPlot()); |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 297 | } |
| 298 | if (FLAG_plot_audio_playout) { |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 299 | analyzer.CreatePlayoutGraph(collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 300 | } |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 301 | if (FLAG_plot_audio_level) { |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 302 | analyzer.CreateAudioLevelGraph(webrtc::kIncomingPacket, |
| 303 | collection->AppendNewPlot()); |
| 304 | analyzer.CreateAudioLevelGraph(webrtc::kOutgoingPacket, |
| 305 | collection->AppendNewPlot()); |
ivoc | aac9d6f | 2016-09-22 07:01:47 -0700 | [diff] [blame] | 306 | } |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 307 | if (FLAG_plot_incoming_sequence_number_delta) { |
| 308 | analyzer.CreateSequenceNumberGraph(collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 309 | } |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 310 | if (FLAG_plot_incoming_delay) { |
| 311 | analyzer.CreateIncomingDelayGraph(collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 312 | } |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 313 | if (FLAG_plot_incoming_loss_rate) { |
Stefan Holmer | 99f8e08 | 2016-09-09 13:37:50 +0200 | [diff] [blame] | 314 | analyzer.CreateIncomingPacketLossGraph(collection->AppendNewPlot()); |
terelius | f736d23 | 2016-08-04 10:00:11 -0700 | [diff] [blame] | 315 | } |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 316 | if (FLAG_plot_incoming_bitrate) { |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 317 | analyzer.CreateTotalIncomingBitrateGraph(collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 318 | } |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 319 | if (FLAG_plot_outgoing_bitrate) { |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 320 | analyzer.CreateTotalOutgoingBitrateGraph(collection->AppendNewPlot(), |
| 321 | FLAG_show_detector_state, |
| 322 | FLAG_show_alr_state); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 323 | } |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 324 | if (FLAG_plot_incoming_stream_bitrate) { |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 325 | analyzer.CreateStreamBitrateGraph(webrtc::kIncomingPacket, |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 326 | collection->AppendNewPlot()); |
| 327 | } |
| 328 | if (FLAG_plot_outgoing_stream_bitrate) { |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 329 | analyzer.CreateStreamBitrateGraph(webrtc::kOutgoingPacket, |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 330 | collection->AppendNewPlot()); |
| 331 | } |
Bjorn Terelius | 28db266 | 2017-10-04 14:22:43 +0200 | [diff] [blame] | 332 | if (FLAG_plot_simulated_receiveside_bwe) { |
| 333 | analyzer.CreateReceiveSideBweSimulationGraph(collection->AppendNewPlot()); |
| 334 | } |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 335 | if (FLAG_plot_simulated_sendside_bwe) { |
Bjorn Terelius | 28db266 | 2017-10-04 14:22:43 +0200 | [diff] [blame] | 336 | analyzer.CreateSendSideBweSimulationGraph(collection->AppendNewPlot()); |
Stefan Holmer | 1318103 | 2016-07-29 14:48:54 +0200 | [diff] [blame] | 337 | } |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 338 | if (FLAG_plot_network_delay_feedback) { |
terelius | e34c19c | 2016-08-15 08:47:14 -0700 | [diff] [blame] | 339 | analyzer.CreateNetworkDelayFeedbackGraph(collection->AppendNewPlot()); |
stefan | c3de033 | 2016-08-02 07:22:17 -0700 | [diff] [blame] | 340 | } |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 341 | if (FLAG_plot_fraction_loss_feedback) { |
| 342 | analyzer.CreateFractionLossGraph(collection->AppendNewPlot()); |
| 343 | } |
| 344 | if (FLAG_plot_timestamps) { |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 345 | analyzer.CreateTimestampGraph(webrtc::kIncomingPacket, |
| 346 | collection->AppendNewPlot()); |
| 347 | analyzer.CreateTimestampGraph(webrtc::kOutgoingPacket, |
| 348 | collection->AppendNewPlot()); |
stefan | e372d3c | 2017-02-02 08:04:18 -0800 | [diff] [blame] | 349 | } |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 350 | if (FLAG_plot_rtcp_details) { |
| 351 | auto GetFractionLost = [](const webrtc::rtcp::ReportBlock& block) -> float { |
| 352 | return static_cast<double>(block.fraction_lost()) / 256 * 100; |
| 353 | }; |
| 354 | analyzer.CreateSenderAndReceiverReportPlot( |
| 355 | webrtc::kIncomingPacket, GetFractionLost, |
| 356 | "Fraction lost (incoming RTCP)", "Loss rate (percent)", |
| 357 | collection->AppendNewPlot()); |
| 358 | analyzer.CreateSenderAndReceiverReportPlot( |
| 359 | webrtc::kOutgoingPacket, GetFractionLost, |
| 360 | "Fraction lost (outgoing RTCP)", "Loss rate (percent)", |
| 361 | collection->AppendNewPlot()); |
| 362 | |
| 363 | auto GetCumulativeLost = |
| 364 | [](const webrtc::rtcp::ReportBlock& block) -> float { |
| 365 | return block.cumulative_lost_signed(); |
| 366 | }; |
| 367 | analyzer.CreateSenderAndReceiverReportPlot( |
| 368 | webrtc::kIncomingPacket, GetCumulativeLost, |
| 369 | "Cumulative lost packets (incoming RTCP)", "Packets", |
| 370 | collection->AppendNewPlot()); |
| 371 | analyzer.CreateSenderAndReceiverReportPlot( |
| 372 | webrtc::kOutgoingPacket, GetCumulativeLost, |
| 373 | "Cumulative lost packets (outgoing RTCP)", "Packets", |
| 374 | collection->AppendNewPlot()); |
| 375 | |
| 376 | auto GetHighestSeqNumber = |
| 377 | [](const webrtc::rtcp::ReportBlock& block) -> float { |
| 378 | return block.extended_high_seq_num(); |
| 379 | }; |
| 380 | analyzer.CreateSenderAndReceiverReportPlot( |
| 381 | webrtc::kIncomingPacket, GetHighestSeqNumber, |
Bjorn Terelius | ef73f59 | 2018-09-10 20:11:49 +0200 | [diff] [blame] | 382 | "Highest sequence number (incoming RTCP)", "Sequence number", |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 383 | collection->AppendNewPlot()); |
| 384 | analyzer.CreateSenderAndReceiverReportPlot( |
| 385 | webrtc::kOutgoingPacket, GetHighestSeqNumber, |
Bjorn Terelius | ef73f59 | 2018-09-10 20:11:49 +0200 | [diff] [blame] | 386 | "Highest sequence number (outgoing RTCP)", "Sequence number", |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 387 | collection->AppendNewPlot()); |
| 388 | |
| 389 | auto DelaySinceLastSr = |
| 390 | [](const webrtc::rtcp::ReportBlock& block) -> float { |
| 391 | return static_cast<double>(block.delay_since_last_sr()) / 65536; |
| 392 | }; |
| 393 | analyzer.CreateSenderAndReceiverReportPlot( |
| 394 | webrtc::kIncomingPacket, DelaySinceLastSr, |
| 395 | "Delay since last received sender report (incoming RTCP)", "Time (s)", |
| 396 | collection->AppendNewPlot()); |
| 397 | analyzer.CreateSenderAndReceiverReportPlot( |
| 398 | webrtc::kOutgoingPacket, DelaySinceLastSr, |
| 399 | "Delay since last received sender report (outgoing RTCP)", "Time (s)", |
| 400 | collection->AppendNewPlot()); |
| 401 | } |
| 402 | |
Bjorn Terelius | 0295a96 | 2017-10-25 17:42:41 +0200 | [diff] [blame] | 403 | if (FLAG_plot_pacer_delay) { |
| 404 | analyzer.CreatePacerDelayGraph(collection->AppendNewPlot()); |
| 405 | } |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 406 | if (FLAG_plot_audio_encoder_bitrate_bps) { |
michaelt | 6e5b219 | 2017-02-22 07:33:27 -0800 | [diff] [blame] | 407 | analyzer.CreateAudioEncoderTargetBitrateGraph(collection->AppendNewPlot()); |
| 408 | } |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 409 | if (FLAG_plot_audio_encoder_frame_length_ms) { |
michaelt | 6e5b219 | 2017-02-22 07:33:27 -0800 | [diff] [blame] | 410 | analyzer.CreateAudioEncoderFrameLengthGraph(collection->AppendNewPlot()); |
| 411 | } |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 412 | if (FLAG_plot_audio_encoder_packet_loss) { |
| 413 | analyzer.CreateAudioEncoderPacketLossGraph(collection->AppendNewPlot()); |
michaelt | 6e5b219 | 2017-02-22 07:33:27 -0800 | [diff] [blame] | 414 | } |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 415 | if (FLAG_plot_audio_encoder_fec) { |
michaelt | 6e5b219 | 2017-02-22 07:33:27 -0800 | [diff] [blame] | 416 | analyzer.CreateAudioEncoderEnableFecGraph(collection->AppendNewPlot()); |
| 417 | } |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 418 | if (FLAG_plot_audio_encoder_dtx) { |
michaelt | 6e5b219 | 2017-02-22 07:33:27 -0800 | [diff] [blame] | 419 | analyzer.CreateAudioEncoderEnableDtxGraph(collection->AppendNewPlot()); |
| 420 | } |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 421 | if (FLAG_plot_audio_encoder_num_channels) { |
michaelt | 6e5b219 | 2017-02-22 07:33:27 -0800 | [diff] [blame] | 422 | analyzer.CreateAudioEncoderNumChannelsGraph(collection->AppendNewPlot()); |
| 423 | } |
Minyue Li | 27e2b7d | 2018-05-07 15:20:24 +0200 | [diff] [blame] | 424 | if (FLAG_plot_neteq_stats) { |
owb | 7fbeb0b | 2017-08-16 02:48:33 -0700 | [diff] [blame] | 425 | std::string wav_path; |
| 426 | if (FLAG_wav_filename[0] != '\0') { |
| 427 | wav_path = FLAG_wav_filename; |
| 428 | } else { |
| 429 | wav_path = webrtc::test::ResourcePath( |
| 430 | "audio_processing/conversational_speech/EN_script2_F_sp2_B1", "wav"); |
| 431 | } |
Minyue Li | c6ff757 | 2018-05-04 09:46:44 +0200 | [diff] [blame] | 432 | auto neteq_stats = analyzer.SimulateNetEq(wav_path, 48000); |
Minyue Li | 01d2a67 | 2018-06-21 21:17:19 +0200 | [diff] [blame] | 433 | for (webrtc::EventLogAnalyzer::NetEqStatsGetterMap::const_iterator it = |
| 434 | neteq_stats.cbegin(); |
| 435 | it != neteq_stats.cend(); ++it) { |
| 436 | analyzer.CreateAudioJitterBufferGraph(it->first, it->second.get(), |
Minyue Li | 45fc6df | 2018-06-21 11:47:14 +0200 | [diff] [blame] | 437 | collection->AppendNewPlot()); |
| 438 | } |
Minyue Li | c9ac93f | 2018-06-26 13:01:32 +0200 | [diff] [blame] | 439 | analyzer.CreateNetEqNetworkStatsGraph( |
Minyue Li | 27e2b7d | 2018-05-07 15:20:24 +0200 | [diff] [blame] | 440 | neteq_stats, |
| 441 | [](const webrtc::NetEqNetworkStatistics& stats) { |
| 442 | return stats.expand_rate / 16384.f; |
| 443 | }, |
| 444 | "Expand rate", collection->AppendNewPlot()); |
Minyue Li | c9ac93f | 2018-06-26 13:01:32 +0200 | [diff] [blame] | 445 | analyzer.CreateNetEqNetworkStatsGraph( |
Minyue Li | 27e2b7d | 2018-05-07 15:20:24 +0200 | [diff] [blame] | 446 | neteq_stats, |
| 447 | [](const webrtc::NetEqNetworkStatistics& stats) { |
| 448 | return stats.speech_expand_rate / 16384.f; |
| 449 | }, |
| 450 | "Speech expand rate", collection->AppendNewPlot()); |
Minyue Li | c9ac93f | 2018-06-26 13:01:32 +0200 | [diff] [blame] | 451 | analyzer.CreateNetEqNetworkStatsGraph( |
Minyue Li | 27e2b7d | 2018-05-07 15:20:24 +0200 | [diff] [blame] | 452 | neteq_stats, |
| 453 | [](const webrtc::NetEqNetworkStatistics& stats) { |
| 454 | return stats.accelerate_rate / 16384.f; |
| 455 | }, |
| 456 | "Accelerate rate", collection->AppendNewPlot()); |
Minyue Li | c9ac93f | 2018-06-26 13:01:32 +0200 | [diff] [blame] | 457 | analyzer.CreateNetEqNetworkStatsGraph( |
Minyue Li | 27e2b7d | 2018-05-07 15:20:24 +0200 | [diff] [blame] | 458 | neteq_stats, |
| 459 | [](const webrtc::NetEqNetworkStatistics& stats) { |
| 460 | return stats.packet_loss_rate / 16384.f; |
| 461 | }, |
| 462 | "Packet loss rate", collection->AppendNewPlot()); |
Minyue Li | c9ac93f | 2018-06-26 13:01:32 +0200 | [diff] [blame] | 463 | analyzer.CreateNetEqLifetimeStatsGraph( |
| 464 | neteq_stats, |
| 465 | [](const webrtc::NetEqLifetimeStatistics& stats) { |
| 466 | return static_cast<float>(stats.concealment_events); |
| 467 | }, |
| 468 | "Concealment events", collection->AppendNewPlot()); |
henrik.lundin | 3c938fc | 2017-06-14 06:09:58 -0700 | [diff] [blame] | 469 | } |
| 470 | |
Qingsi Wang | 8eca1ff | 2018-02-02 11:49:44 -0800 | [diff] [blame] | 471 | if (FLAG_plot_ice_candidate_pair_config) { |
| 472 | analyzer.CreateIceCandidatePairConfigGraph(collection->AppendNewPlot()); |
| 473 | } |
| 474 | if (FLAG_plot_ice_connectivity_check) { |
| 475 | analyzer.CreateIceConnectivityCheckGraph(collection->AppendNewPlot()); |
| 476 | } |
| 477 | |
Zach Stein | 10a5801 | 2018-12-07 12:26:28 -0800 | [diff] [blame] | 478 | if (FLAG_plot_dtls_transport_state) { |
| 479 | analyzer.CreateDtlsTransportStateGraph(collection->AppendNewPlot()); |
| 480 | } |
| 481 | if (FLAG_plot_dtls_writable_state) { |
| 482 | analyzer.CreateDtlsWritableStateGraph(collection->AppendNewPlot()); |
| 483 | } |
| 484 | |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 485 | collection->Draw(); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 486 | |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame] | 487 | if (FLAG_print_triage_alerts) { |
Bjorn Terelius | 2eb3188 | 2017-11-30 15:15:25 +0100 | [diff] [blame] | 488 | analyzer.CreateTriageNotifications(); |
| 489 | analyzer.PrintNotifications(stderr); |
| 490 | } |
| 491 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 492 | return 0; |
| 493 | } |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 494 | |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 495 | void SetAllPlotFlags(bool setting) { |
| 496 | FLAG_plot_incoming_packet_sizes = setting; |
| 497 | FLAG_plot_outgoing_packet_sizes = setting; |
| 498 | FLAG_plot_incoming_packet_count = setting; |
| 499 | FLAG_plot_outgoing_packet_count = setting; |
| 500 | FLAG_plot_audio_playout = setting; |
| 501 | FLAG_plot_audio_level = setting; |
| 502 | FLAG_plot_incoming_sequence_number_delta = setting; |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 503 | FLAG_plot_incoming_delay = setting; |
| 504 | FLAG_plot_incoming_loss_rate = setting; |
| 505 | FLAG_plot_incoming_bitrate = setting; |
| 506 | FLAG_plot_outgoing_bitrate = setting; |
| 507 | FLAG_plot_incoming_stream_bitrate = setting; |
| 508 | FLAG_plot_outgoing_stream_bitrate = setting; |
Bjorn Terelius | 28db266 | 2017-10-04 14:22:43 +0200 | [diff] [blame] | 509 | FLAG_plot_simulated_receiveside_bwe = setting; |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 510 | FLAG_plot_simulated_sendside_bwe = setting; |
| 511 | FLAG_plot_network_delay_feedback = setting; |
| 512 | FLAG_plot_fraction_loss_feedback = setting; |
| 513 | FLAG_plot_timestamps = setting; |
Bjorn Terelius | b1222c2 | 2018-07-24 13:45:31 +0200 | [diff] [blame] | 514 | FLAG_plot_rtcp_details = setting; |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 515 | FLAG_plot_audio_encoder_bitrate_bps = setting; |
| 516 | FLAG_plot_audio_encoder_frame_length_ms = setting; |
| 517 | FLAG_plot_audio_encoder_packet_loss = setting; |
| 518 | FLAG_plot_audio_encoder_fec = setting; |
| 519 | FLAG_plot_audio_encoder_dtx = setting; |
| 520 | FLAG_plot_audio_encoder_num_channels = setting; |
Minyue Li | 27e2b7d | 2018-05-07 15:20:24 +0200 | [diff] [blame] | 521 | FLAG_plot_neteq_stats = setting; |
Qingsi Wang | 8eca1ff | 2018-02-02 11:49:44 -0800 | [diff] [blame] | 522 | FLAG_plot_ice_candidate_pair_config = setting; |
| 523 | FLAG_plot_ice_connectivity_check = setting; |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 524 | } |