blob: a4490aaeb5263aa39c26be2f09911952066c35a5 [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
skvladcc91d282016-10-03 18:31:22 -070013#include "webrtc/logging/rtc_event_log/rtc_event_log_parser.h"
Edward Lemurc20978e2017-07-06 19:44:34 +020014#include "webrtc/rtc_base/flags.h"
kjellanderd2b63cf2017-06-30 03:04:59 -070015#include "webrtc/rtc_tools/event_log_visualizer/analyzer.h"
16#include "webrtc/rtc_tools/event_log_visualizer/plot_base.h"
17#include "webrtc/rtc_tools/event_log_visualizer/plot_python.h"
stefan985d2802016-11-15 06:54:09 -080018#include "webrtc/test/field_trial.h"
henrik.lundin3c938fc2017-06-14 06:09:58 -070019#include "webrtc/test/testsupport/fileutils.h"
terelius54ce6802016-07-13 06:44:41 -070020
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
philipel23c7f252017-07-14 06:30:03 -070093DEFINE_bool(
94 show_detector_state,
95 false,
96 "Mark the delay based bwe detector state on the total bitrate graph");
97
terelius54ce6802016-07-13 06:44:41 -070098int main(int argc, char* argv[]) {
99 std::string program_name = argv[0];
100 std::string usage =
101 "A tool for visualizing WebRTC event logs.\n"
102 "Example usage:\n" +
103 program_name + " <logfile> | python\n" + "Run " + program_name +
104 " --help for a list of command line options\n";
kjellander4fa5be42017-05-16 00:01:23 -0700105 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
106 if (FLAG_help) {
107 rtc::FlagList::Print(nullptr, false);
terelius54ce6802016-07-13 06:44:41 -0700108 return 0;
109 }
110
kjellander4fa5be42017-05-16 00:01:23 -0700111 if (argc != 2) {
112 // Print usage information.
113 std::cout << usage;
114 return 0;
115 }
116
henrik.lundin3c938fc2017-06-14 06:09:58 -0700117 webrtc::test::SetExecutablePath(argv[0]);
kjellander4fa5be42017-05-16 00:01:23 -0700118 webrtc::test::InitFieldTrialsFromString(FLAG_force_fieldtrials);
stefan985d2802016-11-15 06:54:09 -0800119
terelius54ce6802016-07-13 06:44:41 -0700120 std::string filename = argv[1];
121
122 webrtc::ParsedRtcEventLog parsed_log;
123
124 if (!parsed_log.ParseFile(filename)) {
125 std::cerr << "Could not parse the entire log file." << std::endl;
126 std::cerr << "Proceeding to analyze the first "
127 << parsed_log.GetNumberOfEvents() << " events in the file."
128 << std::endl;
129 }
130
131 webrtc::plotting::EventLogAnalyzer analyzer(parsed_log);
132 std::unique_ptr<webrtc::plotting::PlotCollection> collection(
133 new webrtc::plotting::PythonPlotCollection());
134
kjellander4fa5be42017-05-16 00:01:23 -0700135 if (FLAG_plot_all || FLAG_plot_packets) {
136 if (FLAG_incoming) {
terelius54ce6802016-07-13 06:44:41 -0700137 analyzer.CreatePacketGraph(webrtc::PacketDirection::kIncomingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700138 collection->AppendNewPlot());
philipelccd74892016-09-05 02:46:25 -0700139 analyzer.CreateAccumulatedPacketsGraph(
140 webrtc::PacketDirection::kIncomingPacket,
141 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700142 }
kjellander4fa5be42017-05-16 00:01:23 -0700143 if (FLAG_outgoing) {
terelius54ce6802016-07-13 06:44:41 -0700144 analyzer.CreatePacketGraph(webrtc::PacketDirection::kOutgoingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700145 collection->AppendNewPlot());
philipelccd74892016-09-05 02:46:25 -0700146 analyzer.CreateAccumulatedPacketsGraph(
147 webrtc::PacketDirection::kOutgoingPacket,
148 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700149 }
150 }
151
kjellander4fa5be42017-05-16 00:01:23 -0700152 if (FLAG_plot_all || FLAG_plot_audio_playout) {
tereliusdc35dcd2016-08-01 12:03:27 -0700153 analyzer.CreatePlayoutGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700154 }
155
kjellander4fa5be42017-05-16 00:01:23 -0700156 if (FLAG_plot_all || FLAG_plot_audio_level) {
ivocaac9d6f2016-09-22 07:01:47 -0700157 analyzer.CreateAudioLevelGraph(collection->AppendNewPlot());
158 }
159
kjellander4fa5be42017-05-16 00:01:23 -0700160 if (FLAG_plot_all || FLAG_plot_sequence_number) {
161 if (FLAG_incoming) {
tereliusdc35dcd2016-08-01 12:03:27 -0700162 analyzer.CreateSequenceNumberGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700163 }
164 }
165
kjellander4fa5be42017-05-16 00:01:23 -0700166 if (FLAG_plot_all || FLAG_plot_delay_change) {
167 if (FLAG_incoming) {
tereliusdc35dcd2016-08-01 12:03:27 -0700168 analyzer.CreateDelayChangeGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700169 }
170 }
171
kjellander4fa5be42017-05-16 00:01:23 -0700172 if (FLAG_plot_all || FLAG_plot_accumulated_delay_change) {
173 if (FLAG_incoming) {
tereliusdc35dcd2016-08-01 12:03:27 -0700174 analyzer.CreateAccumulatedDelayChangeGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700175 }
176 }
177
kjellander4fa5be42017-05-16 00:01:23 -0700178 if (FLAG_plot_all || FLAG_plot_fraction_loss) {
tereliusf736d232016-08-04 10:00:11 -0700179 analyzer.CreateFractionLossGraph(collection->AppendNewPlot());
Stefan Holmer99f8e082016-09-09 13:37:50 +0200180 analyzer.CreateIncomingPacketLossGraph(collection->AppendNewPlot());
tereliusf736d232016-08-04 10:00:11 -0700181 }
182
kjellander4fa5be42017-05-16 00:01:23 -0700183 if (FLAG_plot_all || FLAG_plot_total_bitrate) {
184 if (FLAG_incoming) {
terelius54ce6802016-07-13 06:44:41 -0700185 analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kIncomingPacket,
philipel23c7f252017-07-14 06:30:03 -0700186 collection->AppendNewPlot(),
187 FLAG_show_detector_state);
terelius54ce6802016-07-13 06:44:41 -0700188 }
kjellander4fa5be42017-05-16 00:01:23 -0700189 if (FLAG_outgoing) {
terelius54ce6802016-07-13 06:44:41 -0700190 analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kOutgoingPacket,
philipel23c7f252017-07-14 06:30:03 -0700191 collection->AppendNewPlot(),
192 FLAG_show_detector_state);
terelius54ce6802016-07-13 06:44:41 -0700193 }
194 }
195
kjellander4fa5be42017-05-16 00:01:23 -0700196 if (FLAG_plot_all || FLAG_plot_stream_bitrate) {
197 if (FLAG_incoming) {
terelius54ce6802016-07-13 06:44:41 -0700198 analyzer.CreateStreamBitrateGraph(
199 webrtc::PacketDirection::kIncomingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700200 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700201 }
kjellander4fa5be42017-05-16 00:01:23 -0700202 if (FLAG_outgoing) {
terelius54ce6802016-07-13 06:44:41 -0700203 analyzer.CreateStreamBitrateGraph(
204 webrtc::PacketDirection::kOutgoingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700205 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700206 }
207 }
208
kjellander4fa5be42017-05-16 00:01:23 -0700209 if (FLAG_plot_all || FLAG_plot_bwe) {
tereliuse34c19c2016-08-15 08:47:14 -0700210 analyzer.CreateBweSimulationGraph(collection->AppendNewPlot());
Stefan Holmer13181032016-07-29 14:48:54 +0200211 }
212
kjellander4fa5be42017-05-16 00:01:23 -0700213 if (FLAG_plot_all || FLAG_plot_network_delay_feedback) {
tereliuse34c19c2016-08-15 08:47:14 -0700214 analyzer.CreateNetworkDelayFeedbackGraph(collection->AppendNewPlot());
stefanc3de0332016-08-02 07:22:17 -0700215 }
216
kjellander4fa5be42017-05-16 00:01:23 -0700217 if (FLAG_plot_all || FLAG_plot_timestamps) {
stefane372d3c2017-02-02 08:04:18 -0800218 analyzer.CreateTimestampGraph(collection->AppendNewPlot());
219 }
220
kjellander4fa5be42017-05-16 00:01:23 -0700221 if (FLAG_plot_all || FLAG_audio_encoder_bitrate_bps) {
michaelt6e5b2192017-02-22 07:33:27 -0800222 analyzer.CreateAudioEncoderTargetBitrateGraph(collection->AppendNewPlot());
223 }
224
kjellander4fa5be42017-05-16 00:01:23 -0700225 if (FLAG_plot_all || FLAG_audio_encoder_frame_length_ms) {
michaelt6e5b2192017-02-22 07:33:27 -0800226 analyzer.CreateAudioEncoderFrameLengthGraph(collection->AppendNewPlot());
227 }
228
kjellander4fa5be42017-05-16 00:01:23 -0700229 if (FLAG_plot_all || FLAG_audio_encoder_uplink_packet_loss_fraction) {
michaelt6e5b2192017-02-22 07:33:27 -0800230 analyzer.CreateAudioEncoderUplinkPacketLossFractionGraph(
231 collection->AppendNewPlot());
232 }
233
kjellander4fa5be42017-05-16 00:01:23 -0700234 if (FLAG_plot_all || FLAG_audio_encoder_fec) {
michaelt6e5b2192017-02-22 07:33:27 -0800235 analyzer.CreateAudioEncoderEnableFecGraph(collection->AppendNewPlot());
236 }
237
kjellander4fa5be42017-05-16 00:01:23 -0700238 if (FLAG_plot_all || FLAG_audio_encoder_dtx) {
michaelt6e5b2192017-02-22 07:33:27 -0800239 analyzer.CreateAudioEncoderEnableDtxGraph(collection->AppendNewPlot());
240 }
241
kjellander4fa5be42017-05-16 00:01:23 -0700242 if (FLAG_plot_all || FLAG_audio_encoder_num_channels) {
michaelt6e5b2192017-02-22 07:33:27 -0800243 analyzer.CreateAudioEncoderNumChannelsGraph(collection->AppendNewPlot());
244 }
245
henrik.lundin3c938fc2017-06-14 06:09:58 -0700246 if (FLAG_plot_all || FLAG_plot_audio_jitter_buffer) {
247 analyzer.CreateAudioJitterBufferGraph(
248 webrtc::test::ResourcePath(
249 "audio_processing/conversational_speech/EN_script2_F_sp2_B1",
250 "wav"),
251 48000, collection->AppendNewPlot());
252 }
253
tereliusdc35dcd2016-08-01 12:03:27 -0700254 collection->Draw();
terelius54ce6802016-07-13 06:44:41 -0700255
256 return 0;
257}