blob: ce8feeafefca5df3258e752d5953cb7743c3d631 [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"
skvladcc91d282016-10-03 18:31:22 -070014#include "webrtc/logging/rtc_event_log/rtc_event_log_parser.h"
stefan985d2802016-11-15 06:54:09 -080015#include "webrtc/test/field_trial.h"
terelius54ce6802016-07-13 06:44:41 -070016#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
20DEFINE_bool(incoming, true, "Plot statistics for incoming packets.");
21DEFINE_bool(outgoing, true, "Plot statistics for outgoing packets.");
22DEFINE_bool(plot_all, true, "Plot all different data types.");
23DEFINE_bool(plot_packets,
24 false,
25 "Plot bar graph showing the size of each packet.");
26DEFINE_bool(plot_audio_playout,
27 false,
28 "Plot bar graph showing the time between each audio playout.");
ivocaac9d6f2016-09-22 07:01:47 -070029DEFINE_bool(plot_audio_level,
30 false,
31 "Plot line graph showing the audio level.");
terelius54ce6802016-07-13 06:44:41 -070032DEFINE_bool(
33 plot_sequence_number,
34 false,
35 "Plot the difference in sequence number between consecutive packets.");
36DEFINE_bool(
37 plot_delay_change,
38 false,
39 "Plot the difference in 1-way path delay between consecutive packets.");
40DEFINE_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.");
44DEFINE_bool(plot_total_bitrate,
45 false,
46 "Plot the total bitrate used by all streams.");
47DEFINE_bool(plot_stream_bitrate,
48 false,
49 "Plot the bitrate used by each stream.");
Stefan Holmer13181032016-07-29 14:48:54 +020050DEFINE_bool(plot_bwe,
51 false,
52 "Run the bandwidth estimator with the logged rtp and rtcp and plot "
53 "the output.");
stefanc3de0332016-08-02 07:22:17 -070054DEFINE_bool(plot_network_delay_feedback,
55 false,
56 "Compute network delay based on sent packets and the received "
57 "transport feedback.");
tereliusf736d232016-08-04 10:00:11 -070058DEFINE_bool(plot_fraction_loss,
59 false,
60 "Plot packet loss in percent for outgoing packets (as perceived by "
61 "the send-side bandwidth estimator).");
stefan985d2802016-11-15 06:54:09 -080062DEFINE_string(
63 force_fieldtrials,
64 "",
65 "Field trials control experimental feature code which can be forced. "
66 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enabled/"
67 " will assign the group Enabled to field trial WebRTC-FooFeature. Multiple "
68 "trials are separated by \"/\"");
terelius54ce6802016-07-13 06:44:41 -070069
70int main(int argc, char* argv[]) {
71 std::string program_name = argv[0];
72 std::string usage =
73 "A tool for visualizing WebRTC event logs.\n"
74 "Example usage:\n" +
75 program_name + " <logfile> | python\n" + "Run " + program_name +
76 " --help for a list of command line options\n";
77 google::SetUsageMessage(usage);
78 google::ParseCommandLineFlags(&argc, &argv, true);
79
80 if (argc != 2) {
81 // Print usage information.
82 std::cout << google::ProgramUsage();
83 return 0;
84 }
85
stefan985d2802016-11-15 06:54:09 -080086 webrtc::test::InitFieldTrialsFromString(FLAGS_force_fieldtrials);
87
terelius54ce6802016-07-13 06:44:41 -070088 std::string filename = argv[1];
89
90 webrtc::ParsedRtcEventLog parsed_log;
91
92 if (!parsed_log.ParseFile(filename)) {
93 std::cerr << "Could not parse the entire log file." << std::endl;
94 std::cerr << "Proceeding to analyze the first "
95 << parsed_log.GetNumberOfEvents() << " events in the file."
96 << std::endl;
97 }
98
99 webrtc::plotting::EventLogAnalyzer analyzer(parsed_log);
100 std::unique_ptr<webrtc::plotting::PlotCollection> collection(
101 new webrtc::plotting::PythonPlotCollection());
102
103 if (FLAGS_plot_all || FLAGS_plot_packets) {
104 if (FLAGS_incoming) {
105 analyzer.CreatePacketGraph(webrtc::PacketDirection::kIncomingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700106 collection->AppendNewPlot());
philipelccd74892016-09-05 02:46:25 -0700107 analyzer.CreateAccumulatedPacketsGraph(
108 webrtc::PacketDirection::kIncomingPacket,
109 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700110 }
111 if (FLAGS_outgoing) {
112 analyzer.CreatePacketGraph(webrtc::PacketDirection::kOutgoingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700113 collection->AppendNewPlot());
philipelccd74892016-09-05 02:46:25 -0700114 analyzer.CreateAccumulatedPacketsGraph(
115 webrtc::PacketDirection::kOutgoingPacket,
116 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700117 }
118 }
119
120 if (FLAGS_plot_all || FLAGS_plot_audio_playout) {
tereliusdc35dcd2016-08-01 12:03:27 -0700121 analyzer.CreatePlayoutGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700122 }
123
ivocaac9d6f2016-09-22 07:01:47 -0700124 if (FLAGS_plot_all || FLAGS_plot_audio_level) {
125 analyzer.CreateAudioLevelGraph(collection->AppendNewPlot());
126 }
127
terelius54ce6802016-07-13 06:44:41 -0700128 if (FLAGS_plot_all || FLAGS_plot_sequence_number) {
129 if (FLAGS_incoming) {
tereliusdc35dcd2016-08-01 12:03:27 -0700130 analyzer.CreateSequenceNumberGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700131 }
132 }
133
134 if (FLAGS_plot_all || FLAGS_plot_delay_change) {
135 if (FLAGS_incoming) {
tereliusdc35dcd2016-08-01 12:03:27 -0700136 analyzer.CreateDelayChangeGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700137 }
138 }
139
140 if (FLAGS_plot_all || FLAGS_plot_accumulated_delay_change) {
141 if (FLAGS_incoming) {
tereliusdc35dcd2016-08-01 12:03:27 -0700142 analyzer.CreateAccumulatedDelayChangeGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700143 }
144 }
145
tereliusf736d232016-08-04 10:00:11 -0700146 if (FLAGS_plot_all || FLAGS_plot_fraction_loss) {
147 analyzer.CreateFractionLossGraph(collection->AppendNewPlot());
Stefan Holmer99f8e082016-09-09 13:37:50 +0200148 analyzer.CreateIncomingPacketLossGraph(collection->AppendNewPlot());
tereliusf736d232016-08-04 10:00:11 -0700149 }
150
terelius54ce6802016-07-13 06:44:41 -0700151 if (FLAGS_plot_all || FLAGS_plot_total_bitrate) {
152 if (FLAGS_incoming) {
153 analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kIncomingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700154 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700155 }
156 if (FLAGS_outgoing) {
157 analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kOutgoingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700158 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700159 }
160 }
161
162 if (FLAGS_plot_all || FLAGS_plot_stream_bitrate) {
163 if (FLAGS_incoming) {
164 analyzer.CreateStreamBitrateGraph(
165 webrtc::PacketDirection::kIncomingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700166 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700167 }
168 if (FLAGS_outgoing) {
169 analyzer.CreateStreamBitrateGraph(
170 webrtc::PacketDirection::kOutgoingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700171 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700172 }
173 }
174
Stefan Holmer13181032016-07-29 14:48:54 +0200175 if (FLAGS_plot_all || FLAGS_plot_bwe) {
tereliuse34c19c2016-08-15 08:47:14 -0700176 analyzer.CreateBweSimulationGraph(collection->AppendNewPlot());
Stefan Holmer13181032016-07-29 14:48:54 +0200177 }
178
stefanc3de0332016-08-02 07:22:17 -0700179 if (FLAGS_plot_all || FLAGS_plot_network_delay_feedback) {
tereliuse34c19c2016-08-15 08:47:14 -0700180 analyzer.CreateNetworkDelayFeedbackGraph(collection->AppendNewPlot());
stefanc3de0332016-08-02 07:22:17 -0700181 }
182
tereliusdc35dcd2016-08-01 12:03:27 -0700183 collection->Draw();
terelius54ce6802016-07-13 06:44:41 -0700184
185 return 0;
186}