blob: 12b55e6d24481bfde83d9dc32a2b12e8e210e416 [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
terelius2ee076d2017-08-15 02:04:02 -070021DEFINE_string(plot_profile,
22 "default",
23 "A profile that selects a certain subset of the plots. Currently "
24 "defined profiles are \"all\", \"none\" and \"default\"");
25
26DEFINE_bool(plot_incoming_packet_sizes,
terelius54ce6802016-07-13 06:44:41 -070027 false,
terelius2ee076d2017-08-15 02:04:02 -070028 "Plot bar graph showing the size of each incoming packet.");
29DEFINE_bool(plot_outgoing_packet_sizes,
30 false,
31 "Plot bar graph showing the size of each outgoing packet.");
32DEFINE_bool(plot_incoming_packet_count,
33 false,
34 "Plot the accumulated number of packets for each incoming stream.");
35DEFINE_bool(plot_outgoing_packet_count,
36 false,
37 "Plot the accumulated number of packets for each outgoing stream.");
terelius54ce6802016-07-13 06:44:41 -070038DEFINE_bool(plot_audio_playout,
39 false,
40 "Plot bar graph showing the time between each audio playout.");
ivocaac9d6f2016-09-22 07:01:47 -070041DEFINE_bool(plot_audio_level,
42 false,
terelius2ee076d2017-08-15 02:04:02 -070043 "Plot line graph showing the audio level of incoming audio.");
44DEFINE_bool(plot_incoming_sequence_number_delta,
45 false,
46 "Plot the sequence number difference between consecutive incoming "
47 "packets.");
terelius54ce6802016-07-13 06:44:41 -070048DEFINE_bool(
terelius2ee076d2017-08-15 02:04:02 -070049 plot_incoming_delay_delta,
terelius54ce6802016-07-13 06:44:41 -070050 false,
51 "Plot the difference in 1-way path delay between consecutive packets.");
terelius2ee076d2017-08-15 02:04:02 -070052DEFINE_bool(plot_incoming_delay,
53 true,
54 "Plot the 1-way path delay for incoming packets, normalized so "
55 "that the first packet has delay 0.");
56DEFINE_bool(plot_incoming_loss_rate,
57 true,
58 "Compute the loss rate for incoming packets using a method that's "
59 "similar to the one used for RTCP SR and RR fraction lost. Note "
60 "that the loss rate can be negative if packets are duplicated or "
61 "reordered.");
62DEFINE_bool(plot_incoming_bitrate,
63 true,
64 "Plot the total bitrate used by all incoming streams.");
65DEFINE_bool(plot_outgoing_bitrate,
66 true,
67 "Plot the total bitrate used by all outgoing streams.");
68DEFINE_bool(plot_incoming_stream_bitrate,
69 true,
70 "Plot the bitrate used by each incoming stream.");
71DEFINE_bool(plot_outgoing_stream_bitrate,
72 true,
73 "Plot the bitrate used by each outgoing stream.");
74DEFINE_bool(plot_simulated_sendside_bwe,
terelius54ce6802016-07-13 06:44:41 -070075 false,
terelius2ee076d2017-08-15 02:04:02 -070076 "Run the send-side bandwidth estimator with the outgoing rtp and "
77 "incoming rtcp and plot the resulting estimate.");
stefanc3de0332016-08-02 07:22:17 -070078DEFINE_bool(plot_network_delay_feedback,
terelius2ee076d2017-08-15 02:04:02 -070079 true,
stefanc3de0332016-08-02 07:22:17 -070080 "Compute network delay based on sent packets and the received "
81 "transport feedback.");
terelius2ee076d2017-08-15 02:04:02 -070082DEFINE_bool(plot_fraction_loss_feedback,
83 true,
tereliusf736d232016-08-04 10:00:11 -070084 "Plot packet loss in percent for outgoing packets (as perceived by "
85 "the send-side bandwidth estimator).");
stefane372d3c2017-02-02 08:04:18 -080086DEFINE_bool(plot_timestamps,
87 false,
88 "Plot the rtp timestamps of all rtp and rtcp packets over time.");
terelius2ee076d2017-08-15 02:04:02 -070089DEFINE_bool(plot_audio_encoder_bitrate_bps,
michaelt6e5b2192017-02-22 07:33:27 -080090 false,
91 "Plot the audio encoder target bitrate.");
terelius2ee076d2017-08-15 02:04:02 -070092DEFINE_bool(plot_audio_encoder_frame_length_ms,
michaelt6e5b2192017-02-22 07:33:27 -080093 false,
94 "Plot the audio encoder frame length.");
95DEFINE_bool(
terelius2ee076d2017-08-15 02:04:02 -070096 plot_audio_encoder_packet_loss,
michaelt6e5b2192017-02-22 07:33:27 -080097 false,
terelius2ee076d2017-08-15 02:04:02 -070098 "Plot the uplink packet loss fraction which is sent to the audio encoder.");
99DEFINE_bool(plot_audio_encoder_fec, false, "Plot the audio encoder FEC.");
100DEFINE_bool(plot_audio_encoder_dtx, false, "Plot the audio encoder DTX.");
101DEFINE_bool(plot_audio_encoder_num_channels,
michaelt6e5b2192017-02-22 07:33:27 -0800102 false,
103 "Plot the audio encoder number of channels.");
henrik.lundin3c938fc2017-06-14 06:09:58 -0700104DEFINE_bool(plot_audio_jitter_buffer,
105 false,
106 "Plot the audio jitter buffer delay profile.");
stefan985d2802016-11-15 06:54:09 -0800107DEFINE_string(
108 force_fieldtrials,
109 "",
110 "Field trials control experimental feature code which can be forced. "
111 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enabled/"
112 " will assign the group Enabled to field trial WebRTC-FooFeature. Multiple "
113 "trials are separated by \"/\"");
kjellander4fa5be42017-05-16 00:01:23 -0700114DEFINE_bool(help, false, "prints this message");
terelius54ce6802016-07-13 06:44:41 -0700115
terelius2ee076d2017-08-15 02:04:02 -0700116DEFINE_bool(show_detector_state,
117 false,
118 "Show the state of the delay based BWE detector on the total "
119 "bitrate graph");
120
121void SetAllPlotFlags(bool setting);
122
philipel23c7f252017-07-14 06:30:03 -0700123
terelius54ce6802016-07-13 06:44:41 -0700124int main(int argc, char* argv[]) {
125 std::string program_name = argv[0];
126 std::string usage =
127 "A tool for visualizing WebRTC event logs.\n"
128 "Example usage:\n" +
129 program_name + " <logfile> | python\n" + "Run " + program_name +
130 " --help for a list of command line options\n";
terelius2ee076d2017-08-15 02:04:02 -0700131
132 // Parse command line flags without removing them. We're only interested in
133 // the |plot_profile| flag.
134 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, false);
135 if (strcmp(FLAG_plot_profile, "all") == 0) {
136 SetAllPlotFlags(true);
137 } else if (strcmp(FLAG_plot_profile, "none") == 0) {
138 SetAllPlotFlags(false);
139 } else if (strcmp(FLAG_plot_profile, "default") == 0) {
140 // Do nothing.
141 } else {
142 rtc::Flag* plot_profile_flag = rtc::FlagList::Lookup("plot_profile");
143 RTC_CHECK(plot_profile_flag);
144 plot_profile_flag->Print(false);
145 }
146 // Parse the remaining flags. They are applied relative to the chosen profile.
kjellander4fa5be42017-05-16 00:01:23 -0700147 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
terelius2ee076d2017-08-15 02:04:02 -0700148
tereliusc4a5c142017-07-20 08:05:09 -0700149 if (argc != 2 || FLAG_help) {
kjellander4fa5be42017-05-16 00:01:23 -0700150 // Print usage information.
151 std::cout << usage;
tereliusc4a5c142017-07-20 08:05:09 -0700152 if (FLAG_help)
153 rtc::FlagList::Print(nullptr, false);
kjellander4fa5be42017-05-16 00:01:23 -0700154 return 0;
155 }
156
henrik.lundin3c938fc2017-06-14 06:09:58 -0700157 webrtc::test::SetExecutablePath(argv[0]);
kjellander4fa5be42017-05-16 00:01:23 -0700158 webrtc::test::InitFieldTrialsFromString(FLAG_force_fieldtrials);
stefan985d2802016-11-15 06:54:09 -0800159
terelius54ce6802016-07-13 06:44:41 -0700160 std::string filename = argv[1];
161
162 webrtc::ParsedRtcEventLog parsed_log;
163
164 if (!parsed_log.ParseFile(filename)) {
165 std::cerr << "Could not parse the entire log file." << std::endl;
166 std::cerr << "Proceeding to analyze the first "
167 << parsed_log.GetNumberOfEvents() << " events in the file."
168 << std::endl;
169 }
170
171 webrtc::plotting::EventLogAnalyzer analyzer(parsed_log);
172 std::unique_ptr<webrtc::plotting::PlotCollection> collection(
173 new webrtc::plotting::PythonPlotCollection());
174
terelius2ee076d2017-08-15 02:04:02 -0700175 if (FLAG_plot_incoming_packet_sizes) {
176 analyzer.CreatePacketGraph(webrtc::PacketDirection::kIncomingPacket,
177 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700178 }
terelius2ee076d2017-08-15 02:04:02 -0700179 if (FLAG_plot_outgoing_packet_sizes) {
180 analyzer.CreatePacketGraph(webrtc::PacketDirection::kOutgoingPacket,
181 collection->AppendNewPlot());
182 }
183 if (FLAG_plot_incoming_packet_count) {
184 analyzer.CreateAccumulatedPacketsGraph(
185 webrtc::PacketDirection::kIncomingPacket, collection->AppendNewPlot());
186 }
187 if (FLAG_plot_outgoing_packet_count) {
188 analyzer.CreateAccumulatedPacketsGraph(
189 webrtc::PacketDirection::kOutgoingPacket, collection->AppendNewPlot());
190 }
191 if (FLAG_plot_audio_playout) {
tereliusdc35dcd2016-08-01 12:03:27 -0700192 analyzer.CreatePlayoutGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700193 }
terelius2ee076d2017-08-15 02:04:02 -0700194 if (FLAG_plot_audio_level) {
ivocaac9d6f2016-09-22 07:01:47 -0700195 analyzer.CreateAudioLevelGraph(collection->AppendNewPlot());
196 }
terelius2ee076d2017-08-15 02:04:02 -0700197 if (FLAG_plot_incoming_sequence_number_delta) {
198 analyzer.CreateSequenceNumberGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700199 }
terelius2ee076d2017-08-15 02:04:02 -0700200 if (FLAG_plot_incoming_delay_delta) {
201 analyzer.CreateIncomingDelayDeltaGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700202 }
terelius2ee076d2017-08-15 02:04:02 -0700203 if (FLAG_plot_incoming_delay) {
204 analyzer.CreateIncomingDelayGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700205 }
terelius2ee076d2017-08-15 02:04:02 -0700206 if (FLAG_plot_incoming_loss_rate) {
Stefan Holmer99f8e082016-09-09 13:37:50 +0200207 analyzer.CreateIncomingPacketLossGraph(collection->AppendNewPlot());
tereliusf736d232016-08-04 10:00:11 -0700208 }
terelius2ee076d2017-08-15 02:04:02 -0700209 if (FLAG_plot_incoming_bitrate) {
210 analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kIncomingPacket,
211 collection->AppendNewPlot(),
212 FLAG_show_detector_state);
terelius54ce6802016-07-13 06:44:41 -0700213 }
terelius2ee076d2017-08-15 02:04:02 -0700214 if (FLAG_plot_outgoing_bitrate) {
215 analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kOutgoingPacket,
216 collection->AppendNewPlot(),
217 FLAG_show_detector_state);
terelius54ce6802016-07-13 06:44:41 -0700218 }
terelius2ee076d2017-08-15 02:04:02 -0700219 if (FLAG_plot_incoming_stream_bitrate) {
220 analyzer.CreateStreamBitrateGraph(webrtc::PacketDirection::kIncomingPacket,
221 collection->AppendNewPlot());
222 }
223 if (FLAG_plot_outgoing_stream_bitrate) {
224 analyzer.CreateStreamBitrateGraph(webrtc::PacketDirection::kOutgoingPacket,
225 collection->AppendNewPlot());
226 }
227 if (FLAG_plot_simulated_sendside_bwe) {
tereliuse34c19c2016-08-15 08:47:14 -0700228 analyzer.CreateBweSimulationGraph(collection->AppendNewPlot());
Stefan Holmer13181032016-07-29 14:48:54 +0200229 }
terelius2ee076d2017-08-15 02:04:02 -0700230 if (FLAG_plot_network_delay_feedback) {
tereliuse34c19c2016-08-15 08:47:14 -0700231 analyzer.CreateNetworkDelayFeedbackGraph(collection->AppendNewPlot());
stefanc3de0332016-08-02 07:22:17 -0700232 }
terelius2ee076d2017-08-15 02:04:02 -0700233 if (FLAG_plot_fraction_loss_feedback) {
234 analyzer.CreateFractionLossGraph(collection->AppendNewPlot());
235 }
236 if (FLAG_plot_timestamps) {
stefane372d3c2017-02-02 08:04:18 -0800237 analyzer.CreateTimestampGraph(collection->AppendNewPlot());
238 }
terelius2ee076d2017-08-15 02:04:02 -0700239 if (FLAG_plot_audio_encoder_bitrate_bps) {
michaelt6e5b2192017-02-22 07:33:27 -0800240 analyzer.CreateAudioEncoderTargetBitrateGraph(collection->AppendNewPlot());
241 }
terelius2ee076d2017-08-15 02:04:02 -0700242 if (FLAG_plot_audio_encoder_frame_length_ms) {
michaelt6e5b2192017-02-22 07:33:27 -0800243 analyzer.CreateAudioEncoderFrameLengthGraph(collection->AppendNewPlot());
244 }
terelius2ee076d2017-08-15 02:04:02 -0700245 if (FLAG_plot_audio_encoder_packet_loss) {
246 analyzer.CreateAudioEncoderPacketLossGraph(collection->AppendNewPlot());
michaelt6e5b2192017-02-22 07:33:27 -0800247 }
terelius2ee076d2017-08-15 02:04:02 -0700248 if (FLAG_plot_audio_encoder_fec) {
michaelt6e5b2192017-02-22 07:33:27 -0800249 analyzer.CreateAudioEncoderEnableFecGraph(collection->AppendNewPlot());
250 }
terelius2ee076d2017-08-15 02:04:02 -0700251 if (FLAG_plot_audio_encoder_dtx) {
michaelt6e5b2192017-02-22 07:33:27 -0800252 analyzer.CreateAudioEncoderEnableDtxGraph(collection->AppendNewPlot());
253 }
terelius2ee076d2017-08-15 02:04:02 -0700254 if (FLAG_plot_audio_encoder_num_channels) {
michaelt6e5b2192017-02-22 07:33:27 -0800255 analyzer.CreateAudioEncoderNumChannelsGraph(collection->AppendNewPlot());
256 }
terelius2ee076d2017-08-15 02:04:02 -0700257 if (FLAG_plot_audio_jitter_buffer) {
henrik.lundin3c938fc2017-06-14 06:09:58 -0700258 analyzer.CreateAudioJitterBufferGraph(
259 webrtc::test::ResourcePath(
260 "audio_processing/conversational_speech/EN_script2_F_sp2_B1",
261 "wav"),
262 48000, collection->AppendNewPlot());
263 }
264
tereliusdc35dcd2016-08-01 12:03:27 -0700265 collection->Draw();
terelius54ce6802016-07-13 06:44:41 -0700266
267 return 0;
268}
terelius2ee076d2017-08-15 02:04:02 -0700269
270
271void SetAllPlotFlags(bool setting) {
272 FLAG_plot_incoming_packet_sizes = setting;
273 FLAG_plot_outgoing_packet_sizes = setting;
274 FLAG_plot_incoming_packet_count = setting;
275 FLAG_plot_outgoing_packet_count = setting;
276 FLAG_plot_audio_playout = setting;
277 FLAG_plot_audio_level = setting;
278 FLAG_plot_incoming_sequence_number_delta = setting;
279 FLAG_plot_incoming_delay_delta = setting;
280 FLAG_plot_incoming_delay = setting;
281 FLAG_plot_incoming_loss_rate = setting;
282 FLAG_plot_incoming_bitrate = setting;
283 FLAG_plot_outgoing_bitrate = setting;
284 FLAG_plot_incoming_stream_bitrate = setting;
285 FLAG_plot_outgoing_stream_bitrate = setting;
286 FLAG_plot_simulated_sendside_bwe = setting;
287 FLAG_plot_network_delay_feedback = setting;
288 FLAG_plot_fraction_loss_feedback = setting;
289 FLAG_plot_timestamps = setting;
290 FLAG_plot_audio_encoder_bitrate_bps = setting;
291 FLAG_plot_audio_encoder_frame_length_ms = setting;
292 FLAG_plot_audio_encoder_packet_loss = setting;
293 FLAG_plot_audio_encoder_fec = setting;
294 FLAG_plot_audio_encoder_dtx = setting;
295 FLAG_plot_audio_encoder_num_channels = setting;
296 FLAG_plot_audio_jitter_buffer = setting;
297}