blob: f86078ec077017d9750f125aada09349280336ce [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"
sprang@webrtc.org131bea82015-02-18 12:46:06 +000014#include "webrtc/test/field_trial.h"
kwibergac9f8762016-09-30 22:29:43 -070015#include "webrtc/test/gtest.h"
sprang@webrtc.org131bea82015-02-18 12:46:06 +000016#include "webrtc/test/run_test.h"
ivica5d6a06c2015-09-17 05:30:24 -070017#include "webrtc/video/video_quality_test.h"
sprang@webrtc.org131bea82015-02-18 12:46:06 +000018
19namespace webrtc {
sprang@webrtc.org131bea82015-02-18 12:46:06 +000020namespace flags {
21
sprangce4aef12015-11-02 07:23:20 -080022// Flags common with screenshare loopback, with different default values.
sprang@webrtc.org131bea82015-02-18 12:46:06 +000023DEFINE_int32(width, 640, "Video width.");
24size_t Width() {
25 return static_cast<size_t>(FLAGS_width);
26}
27
28DEFINE_int32(height, 480, "Video height.");
29size_t Height() {
30 return static_cast<size_t>(FLAGS_height);
31}
32
33DEFINE_int32(fps, 30, "Frames per second.");
34int Fps() {
35 return static_cast<int>(FLAGS_fps);
36}
37
ivica5d6a06c2015-09-17 05:30:24 -070038DEFINE_int32(min_bitrate, 50, "Call and stream min bitrate in kbps.");
39int MinBitrateKbps() {
40 return static_cast<int>(FLAGS_min_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000041}
42
ivica5d6a06c2015-09-17 05:30:24 -070043DEFINE_int32(start_bitrate, 300, "Call start bitrate in kbps.");
44int StartBitrateKbps() {
45 return static_cast<int>(FLAGS_start_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000046}
47
ivica5d6a06c2015-09-17 05:30:24 -070048DEFINE_int32(target_bitrate, 800, "Stream target bitrate in kbps.");
49int TargetBitrateKbps() {
50 return static_cast<int>(FLAGS_target_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000051}
52
ivica5d6a06c2015-09-17 05:30:24 -070053DEFINE_int32(max_bitrate, 800, "Call and stream max bitrate in kbps.");
54int MaxBitrateKbps() {
55 return static_cast<int>(FLAGS_max_bitrate);
56}
sprang@webrtc.org131bea82015-02-18 12:46:06 +000057
mflodman48a4beb2016-07-01 13:03:59 +020058DEFINE_bool(suspend_below_min_bitrate,
59 false,
60 "Suspends video below the configured min bitrate.");
61
sprangce4aef12015-11-02 07:23:20 -080062DEFINE_int32(num_temporal_layers,
63 1,
64 "Number of temporal layers. Set to 1-4 to override.");
65int NumTemporalLayers() {
66 return static_cast<int>(FLAGS_num_temporal_layers);
67}
68
69// Flags common with screenshare loopback, with equal default values.
sprang@webrtc.org131bea82015-02-18 12:46:06 +000070DEFINE_string(codec, "VP8", "Video codec to use.");
71std::string Codec() {
72 return static_cast<std::string>(FLAGS_codec);
73}
74
sprangce4aef12015-11-02 07:23:20 -080075DEFINE_int32(selected_tl,
76 -1,
77 "Temporal layer to show or analyze. -1 to disable filtering.");
78int SelectedTL() {
79 return static_cast<int>(FLAGS_selected_tl);
80}
81
82DEFINE_int32(
83 duration,
84 0,
85 "Duration of the test in seconds. If 0, rendered will be shown instead.");
86int DurationSecs() {
87 return static_cast<int>(FLAGS_duration);
88}
89
90DEFINE_string(output_filename, "", "Target graph data filename.");
91std::string OutputFilename() {
92 return static_cast<std::string>(FLAGS_output_filename);
93}
94
95DEFINE_string(graph_title,
96 "",
97 "If empty, title will be generated automatically.");
98std::string GraphTitle() {
99 return static_cast<std::string>(FLAGS_graph_title);
100}
101
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000102DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost.");
103int LossPercent() {
104 return static_cast<int>(FLAGS_loss_percent);
105}
106
philipelcb7b4492016-06-02 10:57:40 +0200107DEFINE_int32(avg_burst_loss_length,
108 -1,
109 "Average burst length of lost packets.");
philipel536378b2016-05-31 03:20:23 -0700110int AvgBurstLossLength() {
111 return static_cast<int>(FLAGS_avg_burst_loss_length);
112}
113
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000114DEFINE_int32(link_capacity,
115 0,
116 "Capacity (kbps) of the fake link. 0 means infinite.");
ivica5d6a06c2015-09-17 05:30:24 -0700117int LinkCapacityKbps() {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000118 return static_cast<int>(FLAGS_link_capacity);
119}
120
121DEFINE_int32(queue_size, 0, "Size of the bottleneck link queue in packets.");
122int QueueSize() {
123 return static_cast<int>(FLAGS_queue_size);
124}
125
126DEFINE_int32(avg_propagation_delay_ms,
127 0,
128 "Average link propagation delay in ms.");
129int AvgPropagationDelayMs() {
130 return static_cast<int>(FLAGS_avg_propagation_delay_ms);
131}
132
133DEFINE_int32(std_propagation_delay_ms,
134 0,
135 "Link propagation delay standard deviation in ms.");
136int StdPropagationDelayMs() {
137 return static_cast<int>(FLAGS_std_propagation_delay_ms);
138}
139
sprangce4aef12015-11-02 07:23:20 -0800140DEFINE_int32(selected_stream, 0, "ID of the stream to show or analyze.");
141int SelectedStream() {
142 return static_cast<int>(FLAGS_selected_stream);
143}
144
145DEFINE_int32(num_spatial_layers, 1, "Number of spatial layers to use.");
146int NumSpatialLayers() {
147 return static_cast<int>(FLAGS_num_spatial_layers);
148}
149
150DEFINE_int32(selected_sl,
151 -1,
152 "Spatial layer to show or analyze. -1 to disable filtering.");
153int SelectedSL() {
154 return static_cast<int>(FLAGS_selected_sl);
155}
156
157DEFINE_string(stream0,
158 "",
159 "Comma separated values describing VideoStream for stream #0.");
160std::string Stream0() {
161 return static_cast<std::string>(FLAGS_stream0);
162}
163
164DEFINE_string(stream1,
165 "",
166 "Comma separated values describing VideoStream for stream #1.");
167std::string Stream1() {
168 return static_cast<std::string>(FLAGS_stream1);
169}
170
171DEFINE_string(sl0,
172 "",
173 "Comma separated values describing SpatialLayer for layer #0.");
174std::string SL0() {
175 return static_cast<std::string>(FLAGS_sl0);
176}
177
178DEFINE_string(sl1,
179 "",
180 "Comma separated values describing SpatialLayer for layer #1.");
181std::string SL1() {
182 return static_cast<std::string>(FLAGS_sl1);
183}
184
palmkviste75f2042016-09-28 06:19:48 -0700185DEFINE_string(encoded_frame_path,
186 "",
187 "The base path for encoded frame logs. Created files will have "
188 "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf");
189std::string EncodedFramePath() {
190 return static_cast<std::string>(FLAGS_encoded_frame_path);
191}
192
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000193DEFINE_bool(logs, false, "print logs to stderr");
194
sprangce4aef12015-11-02 07:23:20 -0800195DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation");
196
philipela2c55232016-01-26 08:41:53 -0800197DEFINE_bool(allow_reordering, false, "Allow packet reordering to occur");
198
brandtra62f5822016-11-17 00:21:13 -0800199DEFINE_bool(use_ulpfec, false, "Use RED+ULPFEC forward error correction.");
200
201DEFINE_bool(use_flexfec, false, "Use FlexFEC forward error correction.");
philipel274c1dc2016-05-04 06:21:01 -0700202
minyue73208662016-08-18 06:28:55 -0700203DEFINE_bool(audio, false, "Add audio stream");
204
205DEFINE_bool(audio_video_sync, false, "Sync audio and video stream (no effect if"
206 " audio is false)");
207
minyuea27172d2016-11-01 05:59:29 -0700208DEFINE_bool(video, true, "Add video stream");
209
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000210DEFINE_string(
211 force_fieldtrials,
212 "",
213 "Field trials control experimental feature code which can be forced. "
214 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
215 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple "
216 "trials are separated by \"/\"");
pbos9874ee02015-06-22 04:44:26 -0700217
sprangce4aef12015-11-02 07:23:20 -0800218// Video-specific flags.
ivica5d6a06c2015-09-17 05:30:24 -0700219DEFINE_string(clip,
220 "",
221 "Name of the clip to show. If empty, using chroma generator.");
222std::string Clip() {
223 return static_cast<std::string>(FLAGS_clip);
224}
225
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000226} // namespace flags
227
228void Loopback() {
ivica5d6a06c2015-09-17 05:30:24 -0700229 FakeNetworkPipe::Config pipe_config;
230 pipe_config.loss_percent = flags::LossPercent();
philipel536378b2016-05-31 03:20:23 -0700231 pipe_config.avg_burst_loss_length = flags::AvgBurstLossLength();
ivica5d6a06c2015-09-17 05:30:24 -0700232 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps();
233 pipe_config.queue_length_packets = flags::QueueSize();
234 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs();
235 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs();
philipela2c55232016-01-26 08:41:53 -0800236 pipe_config.allow_reordering = flags::FLAGS_allow_reordering;
ivica5d6a06c2015-09-17 05:30:24 -0700237
238 Call::Config::BitrateConfig call_bitrate_config;
239 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000;
240 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000;
241 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000;
242
minyue73208662016-08-18 06:28:55 -0700243 VideoQualityTest::Params params;
minyue626bc952016-10-31 05:47:02 -0700244 params.call = {flags::FLAGS_send_side_bwe, call_bitrate_config};
minyuea27172d2016-11-01 05:59:29 -0700245 params.video = {flags::FLAGS_video,
minyue626bc952016-10-31 05:47:02 -0700246 flags::Width(),
247 flags::Height(),
248 flags::Fps(),
249 flags::MinBitrateKbps() * 1000,
250 flags::TargetBitrateKbps() * 1000,
251 flags::MaxBitrateKbps() * 1000,
252 flags::FLAGS_suspend_below_min_bitrate,
253 flags::Codec(),
254 flags::NumTemporalLayers(),
255 flags::SelectedTL(),
256 0, // No min transmit bitrate.
brandtra62f5822016-11-17 00:21:13 -0800257 flags::FLAGS_use_ulpfec,
258 flags::FLAGS_use_flexfec,
minyue626bc952016-10-31 05:47:02 -0700259 flags::EncodedFramePath(),
260 flags::Clip()};
261 params.audio = {flags::FLAGS_audio, flags::FLAGS_audio_video_sync};
asapersson3ec3da62016-10-11 16:20:33 -0700262 params.screenshare.enabled = false;
minyue73208662016-08-18 06:28:55 -0700263 params.analyzer = {"video", 0.0, 0.0, flags::DurationSecs(),
264 flags::OutputFilename(), flags::GraphTitle()};
265 params.pipe = pipe_config;
266 params.logs = flags::FLAGS_logs;
ivica5d6a06c2015-09-17 05:30:24 -0700267
sprangce4aef12015-11-02 07:23:20 -0800268 std::vector<std::string> stream_descriptors;
269 stream_descriptors.push_back(flags::Stream0());
270 stream_descriptors.push_back(flags::Stream1());
271 std::vector<std::string> SL_descriptors;
272 SL_descriptors.push_back(flags::SL0());
273 SL_descriptors.push_back(flags::SL1());
274 VideoQualityTest::FillScalabilitySettings(
275 &params, stream_descriptors, flags::SelectedStream(),
276 flags::NumSpatialLayers(), flags::SelectedSL(), SL_descriptors);
277
ivica5d6a06c2015-09-17 05:30:24 -0700278 VideoQualityTest test;
sprangce4aef12015-11-02 07:23:20 -0800279 if (flags::DurationSecs()) {
sprang7a975f72015-10-12 06:33:21 -0700280 test.RunWithAnalyzer(params);
sprangce4aef12015-11-02 07:23:20 -0800281 } else {
minyue73208662016-08-18 06:28:55 -0700282 test.RunWithRenderers(params);
sprangce4aef12015-11-02 07:23:20 -0800283 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000284}
285} // namespace webrtc
286
287int main(int argc, char* argv[]) {
288 ::testing::InitGoogleTest(&argc, argv);
289 google::ParseCommandLineFlags(&argc, &argv, true);
290 webrtc::test::InitFieldTrialsFromString(
291 webrtc::flags::FLAGS_force_fieldtrials);
292 webrtc::test::RunTest(webrtc::Loopback);
293 return 0;
294}