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 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 13 | #include "webrtc/base/flags.h" |
skvlad | cc91d28 | 2016-10-03 18:31:22 -0700 | [diff] [blame] | 14 | #include "webrtc/logging/rtc_event_log/rtc_event_log_parser.h" |
stefan | 985d280 | 2016-11-15 06:54:09 -0800 | [diff] [blame] | 15 | #include "webrtc/test/field_trial.h" |
henrik.lundin | 3c938fc | 2017-06-14 06:09:58 -0700 | [diff] [blame^] | 16 | #include "webrtc/test/testsupport/fileutils.h" |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 17 | #include "webrtc/tools/event_log_visualizer/analyzer.h" |
| 18 | #include "webrtc/tools/event_log_visualizer/plot_base.h" |
| 19 | #include "webrtc/tools/event_log_visualizer/plot_python.h" |
| 20 | |
| 21 | DEFINE_bool(incoming, true, "Plot statistics for incoming packets."); |
| 22 | DEFINE_bool(outgoing, true, "Plot statistics for outgoing packets."); |
| 23 | DEFINE_bool(plot_all, true, "Plot all different data types."); |
| 24 | DEFINE_bool(plot_packets, |
| 25 | false, |
| 26 | "Plot bar graph showing the size of each packet."); |
| 27 | DEFINE_bool(plot_audio_playout, |
| 28 | false, |
| 29 | "Plot bar graph showing the time between each audio playout."); |
ivoc | aac9d6f | 2016-09-22 07:01:47 -0700 | [diff] [blame] | 30 | DEFINE_bool(plot_audio_level, |
| 31 | false, |
| 32 | "Plot line graph showing the audio level."); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 33 | DEFINE_bool( |
| 34 | plot_sequence_number, |
| 35 | false, |
| 36 | "Plot the difference in sequence number between consecutive packets."); |
| 37 | DEFINE_bool( |
| 38 | plot_delay_change, |
| 39 | false, |
| 40 | "Plot the difference in 1-way path delay between consecutive packets."); |
| 41 | DEFINE_bool(plot_accumulated_delay_change, |
| 42 | false, |
| 43 | "Plot the accumulated 1-way path delay change, or the path delay " |
| 44 | "change compared to the first packet."); |
| 45 | DEFINE_bool(plot_total_bitrate, |
| 46 | false, |
| 47 | "Plot the total bitrate used by all streams."); |
| 48 | DEFINE_bool(plot_stream_bitrate, |
| 49 | false, |
| 50 | "Plot the bitrate used by each stream."); |
Stefan Holmer | 1318103 | 2016-07-29 14:48:54 +0200 | [diff] [blame] | 51 | DEFINE_bool(plot_bwe, |
| 52 | false, |
| 53 | "Run the bandwidth estimator with the logged rtp and rtcp and plot " |
| 54 | "the output."); |
stefan | c3de033 | 2016-08-02 07:22:17 -0700 | [diff] [blame] | 55 | DEFINE_bool(plot_network_delay_feedback, |
| 56 | false, |
| 57 | "Compute network delay based on sent packets and the received " |
| 58 | "transport feedback."); |
terelius | f736d23 | 2016-08-04 10:00:11 -0700 | [diff] [blame] | 59 | DEFINE_bool(plot_fraction_loss, |
| 60 | false, |
| 61 | "Plot packet loss in percent for outgoing packets (as perceived by " |
| 62 | "the send-side bandwidth estimator)."); |
stefan | e372d3c | 2017-02-02 08:04:18 -0800 | [diff] [blame] | 63 | DEFINE_bool(plot_timestamps, |
| 64 | false, |
| 65 | "Plot the rtp timestamps of all rtp and rtcp packets over time."); |
michaelt | 6e5b219 | 2017-02-22 07:33:27 -0800 | [diff] [blame] | 66 | DEFINE_bool(audio_encoder_bitrate_bps, |
| 67 | false, |
| 68 | "Plot the audio encoder target bitrate."); |
| 69 | DEFINE_bool(audio_encoder_frame_length_ms, |
| 70 | false, |
| 71 | "Plot the audio encoder frame length."); |
| 72 | DEFINE_bool( |
| 73 | audio_encoder_uplink_packet_loss_fraction, |
| 74 | false, |
| 75 | "Plot the uplink packet loss fraction which is send to the audio encoder."); |
| 76 | DEFINE_bool(audio_encoder_fec, false, "Plot the audio encoder FEC."); |
| 77 | DEFINE_bool(audio_encoder_dtx, false, "Plot the audio encoder DTX."); |
| 78 | DEFINE_bool(audio_encoder_num_channels, |
| 79 | false, |
| 80 | "Plot the audio encoder number of channels."); |
henrik.lundin | 3c938fc | 2017-06-14 06:09:58 -0700 | [diff] [blame^] | 81 | DEFINE_bool(plot_audio_jitter_buffer, |
| 82 | false, |
| 83 | "Plot the audio jitter buffer delay profile."); |
stefan | 985d280 | 2016-11-15 06:54:09 -0800 | [diff] [blame] | 84 | DEFINE_string( |
| 85 | force_fieldtrials, |
| 86 | "", |
| 87 | "Field trials control experimental feature code which can be forced. " |
| 88 | "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enabled/" |
| 89 | " will assign the group Enabled to field trial WebRTC-FooFeature. Multiple " |
| 90 | "trials are separated by \"/\""); |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 91 | DEFINE_bool(help, false, "prints this message"); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 92 | |
| 93 | int main(int argc, char* argv[]) { |
| 94 | std::string program_name = argv[0]; |
| 95 | std::string usage = |
| 96 | "A tool for visualizing WebRTC event logs.\n" |
| 97 | "Example usage:\n" + |
| 98 | program_name + " <logfile> | python\n" + "Run " + program_name + |
| 99 | " --help for a list of command line options\n"; |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 100 | rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true); |
| 101 | if (FLAG_help) { |
| 102 | rtc::FlagList::Print(nullptr, false); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 103 | return 0; |
| 104 | } |
| 105 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 106 | if (argc != 2) { |
| 107 | // Print usage information. |
| 108 | std::cout << usage; |
| 109 | return 0; |
| 110 | } |
| 111 | |
henrik.lundin | 3c938fc | 2017-06-14 06:09:58 -0700 | [diff] [blame^] | 112 | webrtc::test::SetExecutablePath(argv[0]); |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 113 | webrtc::test::InitFieldTrialsFromString(FLAG_force_fieldtrials); |
stefan | 985d280 | 2016-11-15 06:54:09 -0800 | [diff] [blame] | 114 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 115 | std::string filename = argv[1]; |
| 116 | |
| 117 | webrtc::ParsedRtcEventLog parsed_log; |
| 118 | |
| 119 | if (!parsed_log.ParseFile(filename)) { |
| 120 | std::cerr << "Could not parse the entire log file." << std::endl; |
| 121 | std::cerr << "Proceeding to analyze the first " |
| 122 | << parsed_log.GetNumberOfEvents() << " events in the file." |
| 123 | << std::endl; |
| 124 | } |
| 125 | |
| 126 | webrtc::plotting::EventLogAnalyzer analyzer(parsed_log); |
| 127 | std::unique_ptr<webrtc::plotting::PlotCollection> collection( |
| 128 | new webrtc::plotting::PythonPlotCollection()); |
| 129 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 130 | if (FLAG_plot_all || FLAG_plot_packets) { |
| 131 | if (FLAG_incoming) { |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 132 | analyzer.CreatePacketGraph(webrtc::PacketDirection::kIncomingPacket, |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 133 | collection->AppendNewPlot()); |
philipel | ccd7489 | 2016-09-05 02:46:25 -0700 | [diff] [blame] | 134 | analyzer.CreateAccumulatedPacketsGraph( |
| 135 | webrtc::PacketDirection::kIncomingPacket, |
| 136 | collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 137 | } |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 138 | if (FLAG_outgoing) { |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 139 | analyzer.CreatePacketGraph(webrtc::PacketDirection::kOutgoingPacket, |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 140 | collection->AppendNewPlot()); |
philipel | ccd7489 | 2016-09-05 02:46:25 -0700 | [diff] [blame] | 141 | analyzer.CreateAccumulatedPacketsGraph( |
| 142 | webrtc::PacketDirection::kOutgoingPacket, |
| 143 | collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 144 | } |
| 145 | } |
| 146 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 147 | if (FLAG_plot_all || FLAG_plot_audio_playout) { |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 148 | analyzer.CreatePlayoutGraph(collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 149 | } |
| 150 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 151 | if (FLAG_plot_all || FLAG_plot_audio_level) { |
ivoc | aac9d6f | 2016-09-22 07:01:47 -0700 | [diff] [blame] | 152 | analyzer.CreateAudioLevelGraph(collection->AppendNewPlot()); |
| 153 | } |
| 154 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 155 | if (FLAG_plot_all || FLAG_plot_sequence_number) { |
| 156 | if (FLAG_incoming) { |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 157 | analyzer.CreateSequenceNumberGraph(collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 158 | } |
| 159 | } |
| 160 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 161 | if (FLAG_plot_all || FLAG_plot_delay_change) { |
| 162 | if (FLAG_incoming) { |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 163 | analyzer.CreateDelayChangeGraph(collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 164 | } |
| 165 | } |
| 166 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 167 | if (FLAG_plot_all || FLAG_plot_accumulated_delay_change) { |
| 168 | if (FLAG_incoming) { |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 169 | analyzer.CreateAccumulatedDelayChangeGraph(collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 170 | } |
| 171 | } |
| 172 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 173 | if (FLAG_plot_all || FLAG_plot_fraction_loss) { |
terelius | f736d23 | 2016-08-04 10:00:11 -0700 | [diff] [blame] | 174 | analyzer.CreateFractionLossGraph(collection->AppendNewPlot()); |
Stefan Holmer | 99f8e08 | 2016-09-09 13:37:50 +0200 | [diff] [blame] | 175 | analyzer.CreateIncomingPacketLossGraph(collection->AppendNewPlot()); |
terelius | f736d23 | 2016-08-04 10:00:11 -0700 | [diff] [blame] | 176 | } |
| 177 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 178 | if (FLAG_plot_all || FLAG_plot_total_bitrate) { |
| 179 | if (FLAG_incoming) { |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 180 | analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kIncomingPacket, |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 181 | collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 182 | } |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 183 | if (FLAG_outgoing) { |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 184 | analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kOutgoingPacket, |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 185 | collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 186 | } |
| 187 | } |
| 188 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 189 | if (FLAG_plot_all || FLAG_plot_stream_bitrate) { |
| 190 | if (FLAG_incoming) { |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 191 | analyzer.CreateStreamBitrateGraph( |
| 192 | webrtc::PacketDirection::kIncomingPacket, |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 193 | collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 194 | } |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 195 | if (FLAG_outgoing) { |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 196 | analyzer.CreateStreamBitrateGraph( |
| 197 | webrtc::PacketDirection::kOutgoingPacket, |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 198 | collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 199 | } |
| 200 | } |
| 201 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 202 | if (FLAG_plot_all || FLAG_plot_bwe) { |
terelius | e34c19c | 2016-08-15 08:47:14 -0700 | [diff] [blame] | 203 | analyzer.CreateBweSimulationGraph(collection->AppendNewPlot()); |
Stefan Holmer | 1318103 | 2016-07-29 14:48:54 +0200 | [diff] [blame] | 204 | } |
| 205 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 206 | if (FLAG_plot_all || FLAG_plot_network_delay_feedback) { |
terelius | e34c19c | 2016-08-15 08:47:14 -0700 | [diff] [blame] | 207 | analyzer.CreateNetworkDelayFeedbackGraph(collection->AppendNewPlot()); |
stefan | c3de033 | 2016-08-02 07:22:17 -0700 | [diff] [blame] | 208 | } |
| 209 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 210 | if (FLAG_plot_all || FLAG_plot_timestamps) { |
stefan | e372d3c | 2017-02-02 08:04:18 -0800 | [diff] [blame] | 211 | analyzer.CreateTimestampGraph(collection->AppendNewPlot()); |
| 212 | } |
| 213 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 214 | if (FLAG_plot_all || FLAG_audio_encoder_bitrate_bps) { |
michaelt | 6e5b219 | 2017-02-22 07:33:27 -0800 | [diff] [blame] | 215 | analyzer.CreateAudioEncoderTargetBitrateGraph(collection->AppendNewPlot()); |
| 216 | } |
| 217 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 218 | if (FLAG_plot_all || FLAG_audio_encoder_frame_length_ms) { |
michaelt | 6e5b219 | 2017-02-22 07:33:27 -0800 | [diff] [blame] | 219 | analyzer.CreateAudioEncoderFrameLengthGraph(collection->AppendNewPlot()); |
| 220 | } |
| 221 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 222 | if (FLAG_plot_all || FLAG_audio_encoder_uplink_packet_loss_fraction) { |
michaelt | 6e5b219 | 2017-02-22 07:33:27 -0800 | [diff] [blame] | 223 | analyzer.CreateAudioEncoderUplinkPacketLossFractionGraph( |
| 224 | collection->AppendNewPlot()); |
| 225 | } |
| 226 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 227 | if (FLAG_plot_all || FLAG_audio_encoder_fec) { |
michaelt | 6e5b219 | 2017-02-22 07:33:27 -0800 | [diff] [blame] | 228 | analyzer.CreateAudioEncoderEnableFecGraph(collection->AppendNewPlot()); |
| 229 | } |
| 230 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 231 | if (FLAG_plot_all || FLAG_audio_encoder_dtx) { |
michaelt | 6e5b219 | 2017-02-22 07:33:27 -0800 | [diff] [blame] | 232 | analyzer.CreateAudioEncoderEnableDtxGraph(collection->AppendNewPlot()); |
| 233 | } |
| 234 | |
kjellander | 4fa5be4 | 2017-05-16 00:01:23 -0700 | [diff] [blame] | 235 | if (FLAG_plot_all || FLAG_audio_encoder_num_channels) { |
michaelt | 6e5b219 | 2017-02-22 07:33:27 -0800 | [diff] [blame] | 236 | analyzer.CreateAudioEncoderNumChannelsGraph(collection->AppendNewPlot()); |
| 237 | } |
| 238 | |
henrik.lundin | 3c938fc | 2017-06-14 06:09:58 -0700 | [diff] [blame^] | 239 | if (FLAG_plot_all || FLAG_plot_audio_jitter_buffer) { |
| 240 | analyzer.CreateAudioJitterBufferGraph( |
| 241 | webrtc::test::ResourcePath( |
| 242 | "audio_processing/conversational_speech/EN_script2_F_sp2_B1", |
| 243 | "wav"), |
| 244 | 48000, collection->AppendNewPlot()); |
| 245 | } |
| 246 | |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 247 | collection->Draw(); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 248 | |
| 249 | return 0; |
| 250 | } |