blob: 91d599f2b31e481798f922e4a8c1dce416cd2063 [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
kjellander4fa5be42017-05-16 00:01:23 -070013#include "webrtc/base/flags.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"
henrik.lundin3c938fc2017-06-14 06:09:58 -070016#include "webrtc/test/testsupport/fileutils.h"
terelius54ce6802016-07-13 06:44:41 -070017#include "webrtc/tools/event_log_visualizer/analyzer.h"
18#include "webrtc/tools/event_log_visualizer/plot_base.h"
19#include "webrtc/tools/event_log_visualizer/plot_python.h"
20
21DEFINE_bool(incoming, true, "Plot statistics for incoming packets.");
22DEFINE_bool(outgoing, true, "Plot statistics for outgoing packets.");
23DEFINE_bool(plot_all, true, "Plot all different data types.");
24DEFINE_bool(plot_packets,
25 false,
26 "Plot bar graph showing the size of each packet.");
27DEFINE_bool(plot_audio_playout,
28 false,
29 "Plot bar graph showing the time between each audio playout.");
ivocaac9d6f2016-09-22 07:01:47 -070030DEFINE_bool(plot_audio_level,
31 false,
32 "Plot line graph showing the audio level.");
terelius54ce6802016-07-13 06:44:41 -070033DEFINE_bool(
34 plot_sequence_number,
35 false,
36 "Plot the difference in sequence number between consecutive packets.");
37DEFINE_bool(
38 plot_delay_change,
39 false,
40 "Plot the difference in 1-way path delay between consecutive packets.");
41DEFINE_bool(plot_accumulated_delay_change,
42 false,
43 "Plot the accumulated 1-way path delay change, or the path delay "
44 "change compared to the first packet.");
45DEFINE_bool(plot_total_bitrate,
46 false,
47 "Plot the total bitrate used by all streams.");
48DEFINE_bool(plot_stream_bitrate,
49 false,
50 "Plot the bitrate used by each stream.");
Stefan Holmer13181032016-07-29 14:48:54 +020051DEFINE_bool(plot_bwe,
52 false,
53 "Run the bandwidth estimator with the logged rtp and rtcp and plot "
54 "the output.");
stefanc3de0332016-08-02 07:22:17 -070055DEFINE_bool(plot_network_delay_feedback,
56 false,
57 "Compute network delay based on sent packets and the received "
58 "transport feedback.");
tereliusf736d232016-08-04 10:00:11 -070059DEFINE_bool(plot_fraction_loss,
60 false,
61 "Plot packet loss in percent for outgoing packets (as perceived by "
62 "the send-side bandwidth estimator).");
stefane372d3c2017-02-02 08:04:18 -080063DEFINE_bool(plot_timestamps,
64 false,
65 "Plot the rtp timestamps of all rtp and rtcp packets over time.");
michaelt6e5b2192017-02-22 07:33:27 -080066DEFINE_bool(audio_encoder_bitrate_bps,
67 false,
68 "Plot the audio encoder target bitrate.");
69DEFINE_bool(audio_encoder_frame_length_ms,
70 false,
71 "Plot the audio encoder frame length.");
72DEFINE_bool(
73 audio_encoder_uplink_packet_loss_fraction,
74 false,
75 "Plot the uplink packet loss fraction which is send to the audio encoder.");
76DEFINE_bool(audio_encoder_fec, false, "Plot the audio encoder FEC.");
77DEFINE_bool(audio_encoder_dtx, false, "Plot the audio encoder DTX.");
78DEFINE_bool(audio_encoder_num_channels,
79 false,
80 "Plot the audio encoder number of channels.");
henrik.lundin3c938fc2017-06-14 06:09:58 -070081DEFINE_bool(plot_audio_jitter_buffer,
82 false,
83 "Plot the audio jitter buffer delay profile.");
stefan985d2802016-11-15 06:54:09 -080084DEFINE_string(
85 force_fieldtrials,
86 "",
87 "Field trials control experimental feature code which can be forced. "
88 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enabled/"
89 " will assign the group Enabled to field trial WebRTC-FooFeature. Multiple "
90 "trials are separated by \"/\"");
kjellander4fa5be42017-05-16 00:01:23 -070091DEFINE_bool(help, false, "prints this message");
terelius54ce6802016-07-13 06:44:41 -070092
93int main(int argc, char* argv[]) {
94 std::string program_name = argv[0];
95 std::string usage =
96 "A tool for visualizing WebRTC event logs.\n"
97 "Example usage:\n" +
98 program_name + " <logfile> | python\n" + "Run " + program_name +
99 " --help for a list of command line options\n";
kjellander4fa5be42017-05-16 00:01:23 -0700100 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
101 if (FLAG_help) {
102 rtc::FlagList::Print(nullptr, false);
terelius54ce6802016-07-13 06:44:41 -0700103 return 0;
104 }
105
kjellander4fa5be42017-05-16 00:01:23 -0700106 if (argc != 2) {
107 // Print usage information.
108 std::cout << usage;
109 return 0;
110 }
111
henrik.lundin3c938fc2017-06-14 06:09:58 -0700112 webrtc::test::SetExecutablePath(argv[0]);
kjellander4fa5be42017-05-16 00:01:23 -0700113 webrtc::test::InitFieldTrialsFromString(FLAG_force_fieldtrials);
stefan985d2802016-11-15 06:54:09 -0800114
terelius54ce6802016-07-13 06:44:41 -0700115 std::string filename = argv[1];
116
117 webrtc::ParsedRtcEventLog parsed_log;
118
119 if (!parsed_log.ParseFile(filename)) {
120 std::cerr << "Could not parse the entire log file." << std::endl;
121 std::cerr << "Proceeding to analyze the first "
122 << parsed_log.GetNumberOfEvents() << " events in the file."
123 << std::endl;
124 }
125
126 webrtc::plotting::EventLogAnalyzer analyzer(parsed_log);
127 std::unique_ptr<webrtc::plotting::PlotCollection> collection(
128 new webrtc::plotting::PythonPlotCollection());
129
kjellander4fa5be42017-05-16 00:01:23 -0700130 if (FLAG_plot_all || FLAG_plot_packets) {
131 if (FLAG_incoming) {
terelius54ce6802016-07-13 06:44:41 -0700132 analyzer.CreatePacketGraph(webrtc::PacketDirection::kIncomingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700133 collection->AppendNewPlot());
philipelccd74892016-09-05 02:46:25 -0700134 analyzer.CreateAccumulatedPacketsGraph(
135 webrtc::PacketDirection::kIncomingPacket,
136 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700137 }
kjellander4fa5be42017-05-16 00:01:23 -0700138 if (FLAG_outgoing) {
terelius54ce6802016-07-13 06:44:41 -0700139 analyzer.CreatePacketGraph(webrtc::PacketDirection::kOutgoingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700140 collection->AppendNewPlot());
philipelccd74892016-09-05 02:46:25 -0700141 analyzer.CreateAccumulatedPacketsGraph(
142 webrtc::PacketDirection::kOutgoingPacket,
143 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700144 }
145 }
146
kjellander4fa5be42017-05-16 00:01:23 -0700147 if (FLAG_plot_all || FLAG_plot_audio_playout) {
tereliusdc35dcd2016-08-01 12:03:27 -0700148 analyzer.CreatePlayoutGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700149 }
150
kjellander4fa5be42017-05-16 00:01:23 -0700151 if (FLAG_plot_all || FLAG_plot_audio_level) {
ivocaac9d6f2016-09-22 07:01:47 -0700152 analyzer.CreateAudioLevelGraph(collection->AppendNewPlot());
153 }
154
kjellander4fa5be42017-05-16 00:01:23 -0700155 if (FLAG_plot_all || FLAG_plot_sequence_number) {
156 if (FLAG_incoming) {
tereliusdc35dcd2016-08-01 12:03:27 -0700157 analyzer.CreateSequenceNumberGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700158 }
159 }
160
kjellander4fa5be42017-05-16 00:01:23 -0700161 if (FLAG_plot_all || FLAG_plot_delay_change) {
162 if (FLAG_incoming) {
tereliusdc35dcd2016-08-01 12:03:27 -0700163 analyzer.CreateDelayChangeGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700164 }
165 }
166
kjellander4fa5be42017-05-16 00:01:23 -0700167 if (FLAG_plot_all || FLAG_plot_accumulated_delay_change) {
168 if (FLAG_incoming) {
tereliusdc35dcd2016-08-01 12:03:27 -0700169 analyzer.CreateAccumulatedDelayChangeGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700170 }
171 }
172
kjellander4fa5be42017-05-16 00:01:23 -0700173 if (FLAG_plot_all || FLAG_plot_fraction_loss) {
tereliusf736d232016-08-04 10:00:11 -0700174 analyzer.CreateFractionLossGraph(collection->AppendNewPlot());
Stefan Holmer99f8e082016-09-09 13:37:50 +0200175 analyzer.CreateIncomingPacketLossGraph(collection->AppendNewPlot());
tereliusf736d232016-08-04 10:00:11 -0700176 }
177
kjellander4fa5be42017-05-16 00:01:23 -0700178 if (FLAG_plot_all || FLAG_plot_total_bitrate) {
179 if (FLAG_incoming) {
terelius54ce6802016-07-13 06:44:41 -0700180 analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kIncomingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700181 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700182 }
kjellander4fa5be42017-05-16 00:01:23 -0700183 if (FLAG_outgoing) {
terelius54ce6802016-07-13 06:44:41 -0700184 analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kOutgoingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700185 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700186 }
187 }
188
kjellander4fa5be42017-05-16 00:01:23 -0700189 if (FLAG_plot_all || FLAG_plot_stream_bitrate) {
190 if (FLAG_incoming) {
terelius54ce6802016-07-13 06:44:41 -0700191 analyzer.CreateStreamBitrateGraph(
192 webrtc::PacketDirection::kIncomingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700193 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700194 }
kjellander4fa5be42017-05-16 00:01:23 -0700195 if (FLAG_outgoing) {
terelius54ce6802016-07-13 06:44:41 -0700196 analyzer.CreateStreamBitrateGraph(
197 webrtc::PacketDirection::kOutgoingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700198 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700199 }
200 }
201
kjellander4fa5be42017-05-16 00:01:23 -0700202 if (FLAG_plot_all || FLAG_plot_bwe) {
tereliuse34c19c2016-08-15 08:47:14 -0700203 analyzer.CreateBweSimulationGraph(collection->AppendNewPlot());
Stefan Holmer13181032016-07-29 14:48:54 +0200204 }
205
kjellander4fa5be42017-05-16 00:01:23 -0700206 if (FLAG_plot_all || FLAG_plot_network_delay_feedback) {
tereliuse34c19c2016-08-15 08:47:14 -0700207 analyzer.CreateNetworkDelayFeedbackGraph(collection->AppendNewPlot());
stefanc3de0332016-08-02 07:22:17 -0700208 }
209
kjellander4fa5be42017-05-16 00:01:23 -0700210 if (FLAG_plot_all || FLAG_plot_timestamps) {
stefane372d3c2017-02-02 08:04:18 -0800211 analyzer.CreateTimestampGraph(collection->AppendNewPlot());
212 }
213
kjellander4fa5be42017-05-16 00:01:23 -0700214 if (FLAG_plot_all || FLAG_audio_encoder_bitrate_bps) {
michaelt6e5b2192017-02-22 07:33:27 -0800215 analyzer.CreateAudioEncoderTargetBitrateGraph(collection->AppendNewPlot());
216 }
217
kjellander4fa5be42017-05-16 00:01:23 -0700218 if (FLAG_plot_all || FLAG_audio_encoder_frame_length_ms) {
michaelt6e5b2192017-02-22 07:33:27 -0800219 analyzer.CreateAudioEncoderFrameLengthGraph(collection->AppendNewPlot());
220 }
221
kjellander4fa5be42017-05-16 00:01:23 -0700222 if (FLAG_plot_all || FLAG_audio_encoder_uplink_packet_loss_fraction) {
michaelt6e5b2192017-02-22 07:33:27 -0800223 analyzer.CreateAudioEncoderUplinkPacketLossFractionGraph(
224 collection->AppendNewPlot());
225 }
226
kjellander4fa5be42017-05-16 00:01:23 -0700227 if (FLAG_plot_all || FLAG_audio_encoder_fec) {
michaelt6e5b2192017-02-22 07:33:27 -0800228 analyzer.CreateAudioEncoderEnableFecGraph(collection->AppendNewPlot());
229 }
230
kjellander4fa5be42017-05-16 00:01:23 -0700231 if (FLAG_plot_all || FLAG_audio_encoder_dtx) {
michaelt6e5b2192017-02-22 07:33:27 -0800232 analyzer.CreateAudioEncoderEnableDtxGraph(collection->AppendNewPlot());
233 }
234
kjellander4fa5be42017-05-16 00:01:23 -0700235 if (FLAG_plot_all || FLAG_audio_encoder_num_channels) {
michaelt6e5b2192017-02-22 07:33:27 -0800236 analyzer.CreateAudioEncoderNumChannelsGraph(collection->AppendNewPlot());
237 }
238
henrik.lundin3c938fc2017-06-14 06:09:58 -0700239 if (FLAG_plot_all || FLAG_plot_audio_jitter_buffer) {
240 analyzer.CreateAudioJitterBufferGraph(
241 webrtc::test::ResourcePath(
242 "audio_processing/conversational_speech/EN_script2_F_sp2_B1",
243 "wav"),
244 48000, collection->AppendNewPlot());
245 }
246
tereliusdc35dcd2016-08-01 12:03:27 -0700247 collection->Draw();
terelius54ce6802016-07-13 06:44:41 -0700248
249 return 0;
250}