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