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