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" |
| 14 | #include "webrtc/call/rtc_event_log_parser.h" |
| 15 | #include "webrtc/tools/event_log_visualizer/analyzer.h" |
| 16 | #include "webrtc/tools/event_log_visualizer/plot_base.h" |
| 17 | #include "webrtc/tools/event_log_visualizer/plot_python.h" |
| 18 | |
| 19 | DEFINE_bool(incoming, true, "Plot statistics for incoming packets."); |
| 20 | DEFINE_bool(outgoing, true, "Plot statistics for outgoing packets."); |
| 21 | DEFINE_bool(plot_all, true, "Plot all different data types."); |
| 22 | DEFINE_bool(plot_packets, |
| 23 | false, |
| 24 | "Plot bar graph showing the size of each packet."); |
| 25 | DEFINE_bool(plot_audio_playout, |
| 26 | false, |
| 27 | "Plot bar graph showing the time between each audio playout."); |
ivoc | aac9d6f | 2016-09-22 07:01:47 -0700 | [diff] [blame] | 28 | DEFINE_bool(plot_audio_level, |
| 29 | false, |
| 30 | "Plot line graph showing the audio level."); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 31 | DEFINE_bool( |
| 32 | plot_sequence_number, |
| 33 | false, |
| 34 | "Plot the difference in sequence number between consecutive packets."); |
| 35 | DEFINE_bool( |
| 36 | plot_delay_change, |
| 37 | false, |
| 38 | "Plot the difference in 1-way path delay between consecutive packets."); |
| 39 | DEFINE_bool(plot_accumulated_delay_change, |
| 40 | false, |
| 41 | "Plot the accumulated 1-way path delay change, or the path delay " |
| 42 | "change compared to the first packet."); |
| 43 | DEFINE_bool(plot_total_bitrate, |
| 44 | false, |
| 45 | "Plot the total bitrate used by all streams."); |
| 46 | DEFINE_bool(plot_stream_bitrate, |
| 47 | false, |
| 48 | "Plot the bitrate used by each stream."); |
Stefan Holmer | 1318103 | 2016-07-29 14:48:54 +0200 | [diff] [blame] | 49 | DEFINE_bool(plot_bwe, |
| 50 | false, |
| 51 | "Run the bandwidth estimator with the logged rtp and rtcp and plot " |
| 52 | "the output."); |
stefan | c3de033 | 2016-08-02 07:22:17 -0700 | [diff] [blame] | 53 | DEFINE_bool(plot_network_delay_feedback, |
| 54 | false, |
| 55 | "Compute network delay based on sent packets and the received " |
| 56 | "transport feedback."); |
terelius | f736d23 | 2016-08-04 10:00:11 -0700 | [diff] [blame] | 57 | DEFINE_bool(plot_fraction_loss, |
| 58 | false, |
| 59 | "Plot packet loss in percent for outgoing packets (as perceived by " |
| 60 | "the send-side bandwidth estimator)."); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 61 | |
| 62 | int main(int argc, char* argv[]) { |
| 63 | std::string program_name = argv[0]; |
| 64 | std::string usage = |
| 65 | "A tool for visualizing WebRTC event logs.\n" |
| 66 | "Example usage:\n" + |
| 67 | program_name + " <logfile> | python\n" + "Run " + program_name + |
| 68 | " --help for a list of command line options\n"; |
| 69 | google::SetUsageMessage(usage); |
| 70 | google::ParseCommandLineFlags(&argc, &argv, true); |
| 71 | |
| 72 | if (argc != 2) { |
| 73 | // Print usage information. |
| 74 | std::cout << google::ProgramUsage(); |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | std::string filename = argv[1]; |
| 79 | |
| 80 | webrtc::ParsedRtcEventLog parsed_log; |
| 81 | |
| 82 | if (!parsed_log.ParseFile(filename)) { |
| 83 | std::cerr << "Could not parse the entire log file." << std::endl; |
| 84 | std::cerr << "Proceeding to analyze the first " |
| 85 | << parsed_log.GetNumberOfEvents() << " events in the file." |
| 86 | << std::endl; |
| 87 | } |
| 88 | |
| 89 | webrtc::plotting::EventLogAnalyzer analyzer(parsed_log); |
| 90 | std::unique_ptr<webrtc::plotting::PlotCollection> collection( |
| 91 | new webrtc::plotting::PythonPlotCollection()); |
| 92 | |
| 93 | if (FLAGS_plot_all || FLAGS_plot_packets) { |
| 94 | if (FLAGS_incoming) { |
| 95 | analyzer.CreatePacketGraph(webrtc::PacketDirection::kIncomingPacket, |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 96 | collection->AppendNewPlot()); |
philipel | ccd7489 | 2016-09-05 02:46:25 -0700 | [diff] [blame] | 97 | analyzer.CreateAccumulatedPacketsGraph( |
| 98 | webrtc::PacketDirection::kIncomingPacket, |
| 99 | collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 100 | } |
| 101 | if (FLAGS_outgoing) { |
| 102 | analyzer.CreatePacketGraph(webrtc::PacketDirection::kOutgoingPacket, |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 103 | collection->AppendNewPlot()); |
philipel | ccd7489 | 2016-09-05 02:46:25 -0700 | [diff] [blame] | 104 | analyzer.CreateAccumulatedPacketsGraph( |
| 105 | webrtc::PacketDirection::kOutgoingPacket, |
| 106 | collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 107 | } |
| 108 | } |
| 109 | |
| 110 | if (FLAGS_plot_all || FLAGS_plot_audio_playout) { |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 111 | analyzer.CreatePlayoutGraph(collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 112 | } |
| 113 | |
ivoc | aac9d6f | 2016-09-22 07:01:47 -0700 | [diff] [blame] | 114 | if (FLAGS_plot_all || FLAGS_plot_audio_level) { |
| 115 | analyzer.CreateAudioLevelGraph(collection->AppendNewPlot()); |
| 116 | } |
| 117 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 118 | if (FLAGS_plot_all || FLAGS_plot_sequence_number) { |
| 119 | if (FLAGS_incoming) { |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 120 | analyzer.CreateSequenceNumberGraph(collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 121 | } |
| 122 | } |
| 123 | |
| 124 | if (FLAGS_plot_all || FLAGS_plot_delay_change) { |
| 125 | if (FLAGS_incoming) { |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 126 | analyzer.CreateDelayChangeGraph(collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 127 | } |
| 128 | } |
| 129 | |
| 130 | if (FLAGS_plot_all || FLAGS_plot_accumulated_delay_change) { |
| 131 | if (FLAGS_incoming) { |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 132 | analyzer.CreateAccumulatedDelayChangeGraph(collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 133 | } |
| 134 | } |
| 135 | |
terelius | f736d23 | 2016-08-04 10:00:11 -0700 | [diff] [blame] | 136 | if (FLAGS_plot_all || FLAGS_plot_fraction_loss) { |
| 137 | analyzer.CreateFractionLossGraph(collection->AppendNewPlot()); |
Stefan Holmer | 99f8e08 | 2016-09-09 13:37:50 +0200 | [diff] [blame] | 138 | analyzer.CreateIncomingPacketLossGraph(collection->AppendNewPlot()); |
terelius | f736d23 | 2016-08-04 10:00:11 -0700 | [diff] [blame] | 139 | } |
| 140 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 141 | if (FLAGS_plot_all || FLAGS_plot_total_bitrate) { |
| 142 | if (FLAGS_incoming) { |
| 143 | analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kIncomingPacket, |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 144 | collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 145 | } |
| 146 | if (FLAGS_outgoing) { |
| 147 | analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kOutgoingPacket, |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 148 | collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 149 | } |
| 150 | } |
| 151 | |
| 152 | if (FLAGS_plot_all || FLAGS_plot_stream_bitrate) { |
| 153 | if (FLAGS_incoming) { |
| 154 | analyzer.CreateStreamBitrateGraph( |
| 155 | webrtc::PacketDirection::kIncomingPacket, |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 156 | collection->AppendNewPlot()); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 157 | } |
| 158 | if (FLAGS_outgoing) { |
| 159 | analyzer.CreateStreamBitrateGraph( |
| 160 | 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 | |
Stefan Holmer | 1318103 | 2016-07-29 14:48:54 +0200 | [diff] [blame] | 165 | if (FLAGS_plot_all || FLAGS_plot_bwe) { |
terelius | e34c19c | 2016-08-15 08:47:14 -0700 | [diff] [blame] | 166 | analyzer.CreateBweSimulationGraph(collection->AppendNewPlot()); |
Stefan Holmer | 1318103 | 2016-07-29 14:48:54 +0200 | [diff] [blame] | 167 | } |
| 168 | |
stefan | c3de033 | 2016-08-02 07:22:17 -0700 | [diff] [blame] | 169 | if (FLAGS_plot_all || FLAGS_plot_network_delay_feedback) { |
terelius | e34c19c | 2016-08-15 08:47:14 -0700 | [diff] [blame] | 170 | analyzer.CreateNetworkDelayFeedbackGraph(collection->AppendNewPlot()); |
stefan | c3de033 | 2016-08-02 07:22:17 -0700 | [diff] [blame] | 171 | } |
| 172 | |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 173 | collection->Draw(); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 174 | |
| 175 | return 0; |
| 176 | } |