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