blob: bde172a835d5beeeb41436fac728d525a3490966 [file] [log] [blame]
terelius54ce6802016-07-13 06:44:41 -07001/*
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
19DEFINE_bool(incoming, true, "Plot statistics for incoming packets.");
20DEFINE_bool(outgoing, true, "Plot statistics for outgoing packets.");
21DEFINE_bool(plot_all, true, "Plot all different data types.");
22DEFINE_bool(plot_packets,
23 false,
24 "Plot bar graph showing the size of each packet.");
25DEFINE_bool(plot_audio_playout,
26 false,
27 "Plot bar graph showing the time between each audio playout.");
ivocaac9d6f2016-09-22 07:01:47 -070028DEFINE_bool(plot_audio_level,
29 false,
30 "Plot line graph showing the audio level.");
terelius54ce6802016-07-13 06:44:41 -070031DEFINE_bool(
32 plot_sequence_number,
33 false,
34 "Plot the difference in sequence number between consecutive packets.");
35DEFINE_bool(
36 plot_delay_change,
37 false,
38 "Plot the difference in 1-way path delay between consecutive packets.");
39DEFINE_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.");
43DEFINE_bool(plot_total_bitrate,
44 false,
45 "Plot the total bitrate used by all streams.");
46DEFINE_bool(plot_stream_bitrate,
47 false,
48 "Plot the bitrate used by each stream.");
Stefan Holmer13181032016-07-29 14:48:54 +020049DEFINE_bool(plot_bwe,
50 false,
51 "Run the bandwidth estimator with the logged rtp and rtcp and plot "
52 "the output.");
stefanc3de0332016-08-02 07:22:17 -070053DEFINE_bool(plot_network_delay_feedback,
54 false,
55 "Compute network delay based on sent packets and the received "
56 "transport feedback.");
tereliusf736d232016-08-04 10:00:11 -070057DEFINE_bool(plot_fraction_loss,
58 false,
59 "Plot packet loss in percent for outgoing packets (as perceived by "
60 "the send-side bandwidth estimator).");
terelius54ce6802016-07-13 06:44:41 -070061
62int 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,
tereliusdc35dcd2016-08-01 12:03:27 -070096 collection->AppendNewPlot());
philipelccd74892016-09-05 02:46:25 -070097 analyzer.CreateAccumulatedPacketsGraph(
98 webrtc::PacketDirection::kIncomingPacket,
99 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700100 }
101 if (FLAGS_outgoing) {
102 analyzer.CreatePacketGraph(webrtc::PacketDirection::kOutgoingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700103 collection->AppendNewPlot());
philipelccd74892016-09-05 02:46:25 -0700104 analyzer.CreateAccumulatedPacketsGraph(
105 webrtc::PacketDirection::kOutgoingPacket,
106 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700107 }
108 }
109
110 if (FLAGS_plot_all || FLAGS_plot_audio_playout) {
tereliusdc35dcd2016-08-01 12:03:27 -0700111 analyzer.CreatePlayoutGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700112 }
113
ivocaac9d6f2016-09-22 07:01:47 -0700114 if (FLAGS_plot_all || FLAGS_plot_audio_level) {
115 analyzer.CreateAudioLevelGraph(collection->AppendNewPlot());
116 }
117
terelius54ce6802016-07-13 06:44:41 -0700118 if (FLAGS_plot_all || FLAGS_plot_sequence_number) {
119 if (FLAGS_incoming) {
tereliusdc35dcd2016-08-01 12:03:27 -0700120 analyzer.CreateSequenceNumberGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700121 }
122 }
123
124 if (FLAGS_plot_all || FLAGS_plot_delay_change) {
125 if (FLAGS_incoming) {
tereliusdc35dcd2016-08-01 12:03:27 -0700126 analyzer.CreateDelayChangeGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700127 }
128 }
129
130 if (FLAGS_plot_all || FLAGS_plot_accumulated_delay_change) {
131 if (FLAGS_incoming) {
tereliusdc35dcd2016-08-01 12:03:27 -0700132 analyzer.CreateAccumulatedDelayChangeGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700133 }
134 }
135
tereliusf736d232016-08-04 10:00:11 -0700136 if (FLAGS_plot_all || FLAGS_plot_fraction_loss) {
137 analyzer.CreateFractionLossGraph(collection->AppendNewPlot());
Stefan Holmer99f8e082016-09-09 13:37:50 +0200138 analyzer.CreateIncomingPacketLossGraph(collection->AppendNewPlot());
tereliusf736d232016-08-04 10:00:11 -0700139 }
140
terelius54ce6802016-07-13 06:44:41 -0700141 if (FLAGS_plot_all || FLAGS_plot_total_bitrate) {
142 if (FLAGS_incoming) {
143 analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kIncomingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700144 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700145 }
146 if (FLAGS_outgoing) {
147 analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kOutgoingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700148 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700149 }
150 }
151
152 if (FLAGS_plot_all || FLAGS_plot_stream_bitrate) {
153 if (FLAGS_incoming) {
154 analyzer.CreateStreamBitrateGraph(
155 webrtc::PacketDirection::kIncomingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700156 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700157 }
158 if (FLAGS_outgoing) {
159 analyzer.CreateStreamBitrateGraph(
160 webrtc::PacketDirection::kOutgoingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700161 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700162 }
163 }
164
Stefan Holmer13181032016-07-29 14:48:54 +0200165 if (FLAGS_plot_all || FLAGS_plot_bwe) {
tereliuse34c19c2016-08-15 08:47:14 -0700166 analyzer.CreateBweSimulationGraph(collection->AppendNewPlot());
Stefan Holmer13181032016-07-29 14:48:54 +0200167 }
168
stefanc3de0332016-08-02 07:22:17 -0700169 if (FLAGS_plot_all || FLAGS_plot_network_delay_feedback) {
tereliuse34c19c2016-08-15 08:47:14 -0700170 analyzer.CreateNetworkDelayFeedbackGraph(collection->AppendNewPlot());
stefanc3de0332016-08-02 07:22:17 -0700171 }
172
tereliusdc35dcd2016-08-01 12:03:27 -0700173 collection->Draw();
terelius54ce6802016-07-13 06:44:41 -0700174
175 return 0;
176}