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 | |
| 13 | #include "gflags/gflags.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."); |
stefan | 985d280 | 2016-11-15 06:54:09 -0800 | [diff] [blame] | 65 | DEFINE_string( |
| 66 | force_fieldtrials, |
| 67 | "", |
| 68 | "Field trials control experimental feature code which can be forced. " |
| 69 | "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enabled/" |
| 70 | " will assign the group Enabled to field trial WebRTC-FooFeature. Multiple " |
| 71 | "trials are separated by \"/\""); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 72 | |
| 73 | int main(int argc, char* argv[]) { |
| 74 | std::string program_name = argv[0]; |
| 75 | std::string usage = |
| 76 | "A tool for visualizing WebRTC event logs.\n" |
| 77 | "Example usage:\n" + |
| 78 | program_name + " <logfile> | python\n" + "Run " + program_name + |
| 79 | " --help for a list of command line options\n"; |
| 80 | google::SetUsageMessage(usage); |
| 81 | google::ParseCommandLineFlags(&argc, &argv, true); |
| 82 | |
| 83 | if (argc != 2) { |
| 84 | // Print usage information. |
| 85 | std::cout << google::ProgramUsage(); |
| 86 | return 0; |
| 87 | } |
| 88 | |
stefan | 985d280 | 2016-11-15 06:54:09 -0800 | [diff] [blame] | 89 | webrtc::test::InitFieldTrialsFromString(FLAGS_force_fieldtrials); |
| 90 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 91 | std::string filename = argv[1]; |
| 92 | |
| 93 | webrtc::ParsedRtcEventLog parsed_log; |
| 94 | |
| 95 | if (!parsed_log.ParseFile(filename)) { |
| 96 | std::cerr << "Could not parse the entire log file." << std::endl; |
| 97 | std::cerr << "Proceeding to analyze the first " |
| 98 | << parsed_log.GetNumberOfEvents() << " events in the file." |
| 99 | << std::endl; |
| 100 | } |
| 101 | |
| 102 | webrtc::plotting::EventLogAnalyzer analyzer(parsed_log); |
| 103 | std::unique_ptr<webrtc::plotting::PlotCollection> collection( |
| 104 | new webrtc::plotting::PythonPlotCollection()); |
| 105 | |
| 106 | if (FLAGS_plot_all || FLAGS_plot_packets) { |
| 107 | if (FLAGS_incoming) { |
| 108 | analyzer.CreatePacketGraph(webrtc::PacketDirection::kIncomingPacket, |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 109 | collection->AppendNewPlot()); |
philipel | ccd7489 | 2016-09-05 02:46:25 -0700 | [diff] [blame] | 110 | analyzer.CreateAccumulatedPacketsGraph( |
| 111 | webrtc::PacketDirection::kIncomingPacket, |
| 112 | collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 113 | } |
| 114 | if (FLAGS_outgoing) { |
| 115 | analyzer.CreatePacketGraph(webrtc::PacketDirection::kOutgoingPacket, |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 116 | collection->AppendNewPlot()); |
philipel | ccd7489 | 2016-09-05 02:46:25 -0700 | [diff] [blame] | 117 | analyzer.CreateAccumulatedPacketsGraph( |
| 118 | webrtc::PacketDirection::kOutgoingPacket, |
| 119 | collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 120 | } |
| 121 | } |
| 122 | |
| 123 | if (FLAGS_plot_all || FLAGS_plot_audio_playout) { |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 124 | analyzer.CreatePlayoutGraph(collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 125 | } |
| 126 | |
ivoc | aac9d6f | 2016-09-22 07:01:47 -0700 | [diff] [blame] | 127 | if (FLAGS_plot_all || FLAGS_plot_audio_level) { |
| 128 | analyzer.CreateAudioLevelGraph(collection->AppendNewPlot()); |
| 129 | } |
| 130 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 131 | if (FLAGS_plot_all || FLAGS_plot_sequence_number) { |
| 132 | if (FLAGS_incoming) { |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 133 | analyzer.CreateSequenceNumberGraph(collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 134 | } |
| 135 | } |
| 136 | |
| 137 | if (FLAGS_plot_all || FLAGS_plot_delay_change) { |
| 138 | if (FLAGS_incoming) { |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 139 | analyzer.CreateDelayChangeGraph(collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 140 | } |
| 141 | } |
| 142 | |
| 143 | if (FLAGS_plot_all || FLAGS_plot_accumulated_delay_change) { |
| 144 | if (FLAGS_incoming) { |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 145 | analyzer.CreateAccumulatedDelayChangeGraph(collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 146 | } |
| 147 | } |
| 148 | |
terelius | f736d23 | 2016-08-04 10:00:11 -0700 | [diff] [blame] | 149 | if (FLAGS_plot_all || FLAGS_plot_fraction_loss) { |
| 150 | analyzer.CreateFractionLossGraph(collection->AppendNewPlot()); |
Stefan Holmer | 99f8e08 | 2016-09-09 13:37:50 +0200 | [diff] [blame] | 151 | analyzer.CreateIncomingPacketLossGraph(collection->AppendNewPlot()); |
terelius | f736d23 | 2016-08-04 10:00:11 -0700 | [diff] [blame] | 152 | } |
| 153 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 154 | if (FLAGS_plot_all || FLAGS_plot_total_bitrate) { |
| 155 | if (FLAGS_incoming) { |
| 156 | analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kIncomingPacket, |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 157 | collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 158 | } |
| 159 | if (FLAGS_outgoing) { |
| 160 | analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kOutgoingPacket, |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 161 | collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 162 | } |
| 163 | } |
| 164 | |
| 165 | if (FLAGS_plot_all || FLAGS_plot_stream_bitrate) { |
| 166 | if (FLAGS_incoming) { |
| 167 | analyzer.CreateStreamBitrateGraph( |
| 168 | webrtc::PacketDirection::kIncomingPacket, |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 169 | collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 170 | } |
| 171 | if (FLAGS_outgoing) { |
| 172 | analyzer.CreateStreamBitrateGraph( |
| 173 | webrtc::PacketDirection::kOutgoingPacket, |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 174 | collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 175 | } |
| 176 | } |
| 177 | |
Stefan Holmer | 1318103 | 2016-07-29 14:48:54 +0200 | [diff] [blame] | 178 | if (FLAGS_plot_all || FLAGS_plot_bwe) { |
terelius | e34c19c | 2016-08-15 08:47:14 -0700 | [diff] [blame] | 179 | analyzer.CreateBweSimulationGraph(collection->AppendNewPlot()); |
Stefan Holmer | 1318103 | 2016-07-29 14:48:54 +0200 | [diff] [blame] | 180 | } |
| 181 | |
stefan | c3de033 | 2016-08-02 07:22:17 -0700 | [diff] [blame] | 182 | if (FLAGS_plot_all || FLAGS_plot_network_delay_feedback) { |
terelius | e34c19c | 2016-08-15 08:47:14 -0700 | [diff] [blame] | 183 | analyzer.CreateNetworkDelayFeedbackGraph(collection->AppendNewPlot()); |
stefan | c3de033 | 2016-08-02 07:22:17 -0700 | [diff] [blame] | 184 | } |
| 185 | |
stefan | e372d3c | 2017-02-02 08:04:18 -0800 | [diff] [blame] | 186 | if (FLAGS_plot_all || FLAGS_plot_timestamps) { |
| 187 | analyzer.CreateTimestampGraph(collection->AppendNewPlot()); |
| 188 | } |
| 189 | |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 190 | collection->Draw(); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 191 | |
| 192 | return 0; |
| 193 | } |