blob: 518129479f11374c13455aada4780b4fca091c00 [file] [log] [blame]
sprang@webrtc.org131bea82015-02-18 12:46:06 +00001/*
2 * Copyright (c) 2015 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 <stdio.h>
12
sprang@webrtc.org131bea82015-02-18 12:46:06 +000013#include "gflags/gflags.h"
14#include "testing/gtest/include/gtest/gtest.h"
15
16#include "webrtc/test/field_trial.h"
17#include "webrtc/test/run_test.h"
ivica5d6a06c2015-09-17 05:30:24 -070018#include "webrtc/video/video_quality_test.h"
sprang@webrtc.org131bea82015-02-18 12:46:06 +000019
20namespace webrtc {
sprang@webrtc.org131bea82015-02-18 12:46:06 +000021namespace flags {
22
sprangce4aef12015-11-02 07:23:20 -080023// Flags common with screenshare loopback, with different default values.
sprang@webrtc.org131bea82015-02-18 12:46:06 +000024DEFINE_int32(width, 640, "Video width.");
25size_t Width() {
26 return static_cast<size_t>(FLAGS_width);
27}
28
29DEFINE_int32(height, 480, "Video height.");
30size_t Height() {
31 return static_cast<size_t>(FLAGS_height);
32}
33
34DEFINE_int32(fps, 30, "Frames per second.");
35int Fps() {
36 return static_cast<int>(FLAGS_fps);
37}
38
ivica5d6a06c2015-09-17 05:30:24 -070039DEFINE_int32(min_bitrate, 50, "Call and stream min bitrate in kbps.");
40int MinBitrateKbps() {
41 return static_cast<int>(FLAGS_min_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000042}
43
ivica5d6a06c2015-09-17 05:30:24 -070044DEFINE_int32(start_bitrate, 300, "Call start bitrate in kbps.");
45int StartBitrateKbps() {
46 return static_cast<int>(FLAGS_start_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000047}
48
ivica5d6a06c2015-09-17 05:30:24 -070049DEFINE_int32(target_bitrate, 800, "Stream target bitrate in kbps.");
50int TargetBitrateKbps() {
51 return static_cast<int>(FLAGS_target_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000052}
53
ivica5d6a06c2015-09-17 05:30:24 -070054DEFINE_int32(max_bitrate, 800, "Call and stream max bitrate in kbps.");
55int MaxBitrateKbps() {
56 return static_cast<int>(FLAGS_max_bitrate);
57}
sprang@webrtc.org131bea82015-02-18 12:46:06 +000058
mflodman48a4beb2016-07-01 13:03:59 +020059DEFINE_bool(suspend_below_min_bitrate,
60 false,
61 "Suspends video below the configured min bitrate.");
62
sprangce4aef12015-11-02 07:23:20 -080063DEFINE_int32(num_temporal_layers,
64 1,
65 "Number of temporal layers. Set to 1-4 to override.");
66int NumTemporalLayers() {
67 return static_cast<int>(FLAGS_num_temporal_layers);
68}
69
70// Flags common with screenshare loopback, with equal default values.
sprang@webrtc.org131bea82015-02-18 12:46:06 +000071DEFINE_string(codec, "VP8", "Video codec to use.");
72std::string Codec() {
73 return static_cast<std::string>(FLAGS_codec);
74}
75
sprangce4aef12015-11-02 07:23:20 -080076DEFINE_int32(selected_tl,
77 -1,
78 "Temporal layer to show or analyze. -1 to disable filtering.");
79int SelectedTL() {
80 return static_cast<int>(FLAGS_selected_tl);
81}
82
83DEFINE_int32(
84 duration,
85 0,
86 "Duration of the test in seconds. If 0, rendered will be shown instead.");
87int DurationSecs() {
88 return static_cast<int>(FLAGS_duration);
89}
90
91DEFINE_string(output_filename, "", "Target graph data filename.");
92std::string OutputFilename() {
93 return static_cast<std::string>(FLAGS_output_filename);
94}
95
96DEFINE_string(graph_title,
97 "",
98 "If empty, title will be generated automatically.");
99std::string GraphTitle() {
100 return static_cast<std::string>(FLAGS_graph_title);
101}
102
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000103DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost.");
104int LossPercent() {
105 return static_cast<int>(FLAGS_loss_percent);
106}
107
philipelcb7b4492016-06-02 10:57:40 +0200108DEFINE_int32(avg_burst_loss_length,
109 -1,
110 "Average burst length of lost packets.");
philipel536378b2016-05-31 03:20:23 -0700111int AvgBurstLossLength() {
112 return static_cast<int>(FLAGS_avg_burst_loss_length);
113}
114
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000115DEFINE_int32(link_capacity,
116 0,
117 "Capacity (kbps) of the fake link. 0 means infinite.");
ivica5d6a06c2015-09-17 05:30:24 -0700118int LinkCapacityKbps() {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000119 return static_cast<int>(FLAGS_link_capacity);
120}
121
122DEFINE_int32(queue_size, 0, "Size of the bottleneck link queue in packets.");
123int QueueSize() {
124 return static_cast<int>(FLAGS_queue_size);
125}
126
127DEFINE_int32(avg_propagation_delay_ms,
128 0,
129 "Average link propagation delay in ms.");
130int AvgPropagationDelayMs() {
131 return static_cast<int>(FLAGS_avg_propagation_delay_ms);
132}
133
134DEFINE_int32(std_propagation_delay_ms,
135 0,
136 "Link propagation delay standard deviation in ms.");
137int StdPropagationDelayMs() {
138 return static_cast<int>(FLAGS_std_propagation_delay_ms);
139}
140
sprangce4aef12015-11-02 07:23:20 -0800141DEFINE_int32(selected_stream, 0, "ID of the stream to show or analyze.");
142int SelectedStream() {
143 return static_cast<int>(FLAGS_selected_stream);
144}
145
146DEFINE_int32(num_spatial_layers, 1, "Number of spatial layers to use.");
147int NumSpatialLayers() {
148 return static_cast<int>(FLAGS_num_spatial_layers);
149}
150
151DEFINE_int32(selected_sl,
152 -1,
153 "Spatial layer to show or analyze. -1 to disable filtering.");
154int SelectedSL() {
155 return static_cast<int>(FLAGS_selected_sl);
156}
157
158DEFINE_string(stream0,
159 "",
160 "Comma separated values describing VideoStream for stream #0.");
161std::string Stream0() {
162 return static_cast<std::string>(FLAGS_stream0);
163}
164
165DEFINE_string(stream1,
166 "",
167 "Comma separated values describing VideoStream for stream #1.");
168std::string Stream1() {
169 return static_cast<std::string>(FLAGS_stream1);
170}
171
172DEFINE_string(sl0,
173 "",
174 "Comma separated values describing SpatialLayer for layer #0.");
175std::string SL0() {
176 return static_cast<std::string>(FLAGS_sl0);
177}
178
179DEFINE_string(sl1,
180 "",
181 "Comma separated values describing SpatialLayer for layer #1.");
182std::string SL1() {
183 return static_cast<std::string>(FLAGS_sl1);
184}
185
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000186DEFINE_bool(logs, false, "print logs to stderr");
187
sprangce4aef12015-11-02 07:23:20 -0800188DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation");
189
philipela2c55232016-01-26 08:41:53 -0800190DEFINE_bool(allow_reordering, false, "Allow packet reordering to occur");
191
philipel274c1dc2016-05-04 06:21:01 -0700192DEFINE_bool(use_fec, false, "Use forward error correction.");
193
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000194DEFINE_string(
195 force_fieldtrials,
196 "",
197 "Field trials control experimental feature code which can be forced. "
198 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
199 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple "
200 "trials are separated by \"/\"");
pbos9874ee02015-06-22 04:44:26 -0700201
sprangce4aef12015-11-02 07:23:20 -0800202// Video-specific flags.
ivica5d6a06c2015-09-17 05:30:24 -0700203DEFINE_string(clip,
204 "",
205 "Name of the clip to show. If empty, using chroma generator.");
206std::string Clip() {
207 return static_cast<std::string>(FLAGS_clip);
208}
209
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000210} // namespace flags
211
212void Loopback() {
ivica5d6a06c2015-09-17 05:30:24 -0700213 FakeNetworkPipe::Config pipe_config;
214 pipe_config.loss_percent = flags::LossPercent();
philipel536378b2016-05-31 03:20:23 -0700215 pipe_config.avg_burst_loss_length = flags::AvgBurstLossLength();
ivica5d6a06c2015-09-17 05:30:24 -0700216 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps();
217 pipe_config.queue_length_packets = flags::QueueSize();
218 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs();
219 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs();
philipela2c55232016-01-26 08:41:53 -0800220 pipe_config.allow_reordering = flags::FLAGS_allow_reordering;
ivica5d6a06c2015-09-17 05:30:24 -0700221
222 Call::Config::BitrateConfig call_bitrate_config;
223 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000;
224 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000;
225 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000;
226
ivica5d6a06c2015-09-17 05:30:24 -0700227 VideoQualityTest::Params params{
Erik Språng6b8d3552015-09-24 15:06:57 +0200228 {flags::Width(), flags::Height(), flags::Fps(),
229 flags::MinBitrateKbps() * 1000, flags::TargetBitrateKbps() * 1000,
stefanb1797672016-08-11 07:00:57 -0700230 flags::MaxBitrateKbps() * 1000, flags::FLAGS_suspend_below_min_bitrate,
231 flags::Codec(), flags::NumTemporalLayers(), flags::SelectedTL(),
Erik Språng6b8d3552015-09-24 15:06:57 +0200232 0, // No min transmit bitrate.
stefanb1797672016-08-11 07:00:57 -0700233 flags::FLAGS_send_side_bwe, flags::FLAGS_use_fec, call_bitrate_config},
sprangce4aef12015-11-02 07:23:20 -0800234 {flags::Clip()},
ivica5d6a06c2015-09-17 05:30:24 -0700235 {}, // Screenshare specific.
sprangce4aef12015-11-02 07:23:20 -0800236 {"video", 0.0, 0.0, flags::DurationSecs(), flags::OutputFilename(),
237 flags::GraphTitle()},
ivica5d6a06c2015-09-17 05:30:24 -0700238 pipe_config,
239 flags::FLAGS_logs};
240
sprangce4aef12015-11-02 07:23:20 -0800241 std::vector<std::string> stream_descriptors;
242 stream_descriptors.push_back(flags::Stream0());
243 stream_descriptors.push_back(flags::Stream1());
244 std::vector<std::string> SL_descriptors;
245 SL_descriptors.push_back(flags::SL0());
246 SL_descriptors.push_back(flags::SL1());
247 VideoQualityTest::FillScalabilitySettings(
248 &params, stream_descriptors, flags::SelectedStream(),
249 flags::NumSpatialLayers(), flags::SelectedSL(), SL_descriptors);
250
ivica5d6a06c2015-09-17 05:30:24 -0700251 VideoQualityTest test;
sprangce4aef12015-11-02 07:23:20 -0800252 if (flags::DurationSecs()) {
sprang7a975f72015-10-12 06:33:21 -0700253 test.RunWithAnalyzer(params);
sprangce4aef12015-11-02 07:23:20 -0800254 } else {
255 test.RunWithVideoRenderer(params);
256 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000257}
258} // namespace webrtc
259
260int main(int argc, char* argv[]) {
261 ::testing::InitGoogleTest(&argc, argv);
262 google::ParseCommandLineFlags(&argc, &argv, true);
263 webrtc::test::InitFieldTrialsFromString(
264 webrtc::flags::FLAGS_force_fieldtrials);
265 webrtc::test::RunTest(webrtc::Loopback);
266 return 0;
267}