blob: 273dcfa337224e6238d08731445e9d5b11911ea1 [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.");
28DEFINE_bool(
29 plot_sequence_number,
30 false,
31 "Plot the difference in sequence number between consecutive packets.");
32DEFINE_bool(
33 plot_delay_change,
34 false,
35 "Plot the difference in 1-way path delay between consecutive packets.");
36DEFINE_bool(plot_accumulated_delay_change,
37 false,
38 "Plot the accumulated 1-way path delay change, or the path delay "
39 "change compared to the first packet.");
40DEFINE_bool(plot_total_bitrate,
41 false,
42 "Plot the total bitrate used by all streams.");
43DEFINE_bool(plot_stream_bitrate,
44 false,
45 "Plot the bitrate used by each stream.");
Stefan Holmer13181032016-07-29 14:48:54 +020046DEFINE_bool(plot_bwe,
47 false,
48 "Run the bandwidth estimator with the logged rtp and rtcp and plot "
49 "the output.");
stefanc3de0332016-08-02 07:22:17 -070050DEFINE_bool(plot_network_delay_feedback,
51 false,
52 "Compute network delay based on sent packets and the received "
53 "transport feedback.");
terelius54ce6802016-07-13 06:44:41 -070054
55int main(int argc, char* argv[]) {
56 std::string program_name = argv[0];
57 std::string usage =
58 "A tool for visualizing WebRTC event logs.\n"
59 "Example usage:\n" +
60 program_name + " <logfile> | python\n" + "Run " + program_name +
61 " --help for a list of command line options\n";
62 google::SetUsageMessage(usage);
63 google::ParseCommandLineFlags(&argc, &argv, true);
64
65 if (argc != 2) {
66 // Print usage information.
67 std::cout << google::ProgramUsage();
68 return 0;
69 }
70
71 std::string filename = argv[1];
72
73 webrtc::ParsedRtcEventLog parsed_log;
74
75 if (!parsed_log.ParseFile(filename)) {
76 std::cerr << "Could not parse the entire log file." << std::endl;
77 std::cerr << "Proceeding to analyze the first "
78 << parsed_log.GetNumberOfEvents() << " events in the file."
79 << std::endl;
80 }
81
82 webrtc::plotting::EventLogAnalyzer analyzer(parsed_log);
83 std::unique_ptr<webrtc::plotting::PlotCollection> collection(
84 new webrtc::plotting::PythonPlotCollection());
85
86 if (FLAGS_plot_all || FLAGS_plot_packets) {
87 if (FLAGS_incoming) {
88 analyzer.CreatePacketGraph(webrtc::PacketDirection::kIncomingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -070089 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -070090 }
91 if (FLAGS_outgoing) {
92 analyzer.CreatePacketGraph(webrtc::PacketDirection::kOutgoingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -070093 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -070094 }
95 }
96
97 if (FLAGS_plot_all || FLAGS_plot_audio_playout) {
tereliusdc35dcd2016-08-01 12:03:27 -070098 analyzer.CreatePlayoutGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -070099 }
100
101 if (FLAGS_plot_all || FLAGS_plot_sequence_number) {
102 if (FLAGS_incoming) {
tereliusdc35dcd2016-08-01 12:03:27 -0700103 analyzer.CreateSequenceNumberGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700104 }
105 }
106
107 if (FLAGS_plot_all || FLAGS_plot_delay_change) {
108 if (FLAGS_incoming) {
tereliusdc35dcd2016-08-01 12:03:27 -0700109 analyzer.CreateDelayChangeGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700110 }
111 }
112
113 if (FLAGS_plot_all || FLAGS_plot_accumulated_delay_change) {
114 if (FLAGS_incoming) {
tereliusdc35dcd2016-08-01 12:03:27 -0700115 analyzer.CreateAccumulatedDelayChangeGraph(collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700116 }
117 }
118
119 if (FLAGS_plot_all || FLAGS_plot_total_bitrate) {
120 if (FLAGS_incoming) {
121 analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kIncomingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700122 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700123 }
124 if (FLAGS_outgoing) {
125 analyzer.CreateTotalBitrateGraph(webrtc::PacketDirection::kOutgoingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700126 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700127 }
128 }
129
130 if (FLAGS_plot_all || FLAGS_plot_stream_bitrate) {
131 if (FLAGS_incoming) {
132 analyzer.CreateStreamBitrateGraph(
133 webrtc::PacketDirection::kIncomingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700134 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700135 }
136 if (FLAGS_outgoing) {
137 analyzer.CreateStreamBitrateGraph(
138 webrtc::PacketDirection::kOutgoingPacket,
tereliusdc35dcd2016-08-01 12:03:27 -0700139 collection->AppendNewPlot());
terelius54ce6802016-07-13 06:44:41 -0700140 }
141 }
142
Stefan Holmer13181032016-07-29 14:48:54 +0200143 if (FLAGS_plot_all || FLAGS_plot_bwe) {
tereliusdc35dcd2016-08-01 12:03:27 -0700144 analyzer.CreateBweGraph(collection->AppendNewPlot());
Stefan Holmer13181032016-07-29 14:48:54 +0200145 }
146
stefanc3de0332016-08-02 07:22:17 -0700147 if (FLAGS_plot_all || FLAGS_plot_network_delay_feedback) {
148 analyzer.CreateNetworkDelayFeebackGraph(collection->AppendNewPlot());
149 }
150
tereliusdc35dcd2016-08-01 12:03:27 -0700151 collection->Draw();
terelius54ce6802016-07-13 06:44:41 -0700152
153 return 0;
154}