blob: d27e0cc203544ae3499360ad924c2d1078dcf60b [file] [log] [blame]
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +01001/*
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>
Jonas Olsson5b2eda42019-06-11 14:29:40 +020012
Yves Gerey3e707812018-11-28 16:47:49 +010013#include <memory>
14#include <string>
15#include <vector>
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +010016
Mirko Bonadei2ab97f62019-07-18 13:44:12 +020017#include "absl/flags/flag.h"
18#include "absl/flags/parse.h"
Yves Gerey3e707812018-11-28 16:47:49 +010019#include "absl/memory/memory.h"
20#include "absl/types/optional.h"
21#include "api/bitrate_constraints.h"
22#include "api/test/simulated_network.h"
23#include "api/test/video_quality_test_fixture.h"
24#include "api/video_codecs/video_codec.h"
25#include "rtc_base/checks.h"
Mirko Bonadei45a4c412018-07-31 15:07:28 +020026#include "rtc_base/logging.h"
Steve Anton10542f22019-01-11 09:11:00 -080027#include "rtc_base/string_encode.h"
Mirko Bonadei17f48782018-09-28 08:51:10 +020028#include "system_wrappers/include/field_trial.h"
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +010029#include "test/field_trial.h"
30#include "test/gtest.h"
31#include "test/run_test.h"
32#include "video/video_quality_test.h"
33
Mirko Bonadei2ab97f62019-07-18 13:44:12 +020034// Flags for video.
35ABSL_FLAG(int, vwidth, 640, "Video width.");
36
37ABSL_FLAG(int, vheight, 480, "Video height.");
38
39ABSL_FLAG(int, vfps, 30, "Video frames per second.");
40
41ABSL_FLAG(int,
42 capture_device_index,
43 0,
44 "Capture device to select for video stream");
45
46ABSL_FLAG(int, vtarget_bitrate, 400, "Video stream target bitrate in kbps.");
47
48ABSL_FLAG(int, vmin_bitrate, 100, "Video stream min bitrate in kbps.");
49
50ABSL_FLAG(int, vmax_bitrate, 2000, "Video stream max bitrate in kbps.");
51
52ABSL_FLAG(bool,
53 suspend_below_min_bitrate,
54 false,
55 "Suspends video below the configured min bitrate.");
56
57ABSL_FLAG(int,
58 vnum_temporal_layers,
59 1,
60 "Number of temporal layers for video. Set to 1-4 to override.");
61
62ABSL_FLAG(int, vnum_streams, 0, "Number of video streams to show or analyze.");
63
64ABSL_FLAG(int,
65 vnum_spatial_layers,
66 1,
67 "Number of video spatial layers to use.");
68
69ABSL_FLAG(int,
70 vinter_layer_pred,
71 2,
72 "Video inter-layer prediction mode. "
73 "0 - enabled, 1 - disabled, 2 - enabled only for key pictures.");
74
75ABSL_FLAG(std::string,
76 vstream0,
77 "",
78 "Comma separated values describing VideoStream for video stream #0.");
79
80ABSL_FLAG(std::string,
81 vstream1,
82 "",
83 "Comma separated values describing VideoStream for video stream #1.");
84
85ABSL_FLAG(std::string,
86 vsl0,
87 "",
88 "Comma separated values describing SpatialLayer for video layer #0.");
89
90ABSL_FLAG(std::string,
91 vsl1,
92 "",
93 "Comma separated values describing SpatialLayer for video layer #1.");
94
95ABSL_FLAG(int,
96 vselected_tl,
97 -1,
98 "Temporal layer to show or analyze for screenshare. -1 to disable "
99 "filtering.");
100
101ABSL_FLAG(int,
102 vselected_stream,
103 0,
104 "ID of the stream to show or analyze for screenshare."
105 "Set to the number of streams to show them all.");
106
107ABSL_FLAG(int,
108 vselected_sl,
109 -1,
110 "Spatial layer to show or analyze for screenshare. -1 to disable "
111 "filtering.");
112
113// Flags for screenshare.
114ABSL_FLAG(int,
115 min_transmit_bitrate,
116 400,
117 "Min transmit bitrate incl. padding for screenshare.");
118
119ABSL_FLAG(int, swidth, 1850, "Screenshare width (crops source).");
120
121ABSL_FLAG(int, sheight, 1110, "Screenshare height (crops source).");
122
123ABSL_FLAG(int, sfps, 5, "Frames per second for screenshare.");
124
125ABSL_FLAG(int,
126 starget_bitrate,
127 100,
128 "Screenshare stream target bitrate in kbps.");
129
130ABSL_FLAG(int, smin_bitrate, 100, "Screenshare stream min bitrate in kbps.");
131
132ABSL_FLAG(int, smax_bitrate, 2000, "Screenshare stream max bitrate in kbps.");
133
134ABSL_FLAG(int,
135 snum_temporal_layers,
136 2,
137 "Number of temporal layers to use in screenshare.");
138
139ABSL_FLAG(int,
140 snum_streams,
141 0,
142 "Number of screenshare streams to show or analyze.");
143
144ABSL_FLAG(int,
145 snum_spatial_layers,
146 1,
147 "Number of screenshare spatial layers to use.");
148
149ABSL_FLAG(int,
150 sinter_layer_pred,
151 0,
152 "Screenshare inter-layer prediction mode. "
153 "0 - enabled, 1 - disabled, 2 - enabled only for key pictures.");
154
155ABSL_FLAG(
156 std::string,
157 sstream0,
158 "",
159 "Comma separated values describing VideoStream for screenshare stream #0.");
160
161ABSL_FLAG(
162 std::string,
163 sstream1,
164 "",
165 "Comma separated values describing VideoStream for screenshare stream #1.");
166
167ABSL_FLAG(
168 std::string,
169 ssl0,
170 "",
171 "Comma separated values describing SpatialLayer for screenshare layer #0.");
172
173ABSL_FLAG(
174 std::string,
175 ssl1,
176 "",
177 "Comma separated values describing SpatialLayer for screenshare layer #1.");
178
179ABSL_FLAG(int,
180 sselected_tl,
181 -1,
182 "Temporal layer to show or analyze for screenshare. -1 to disable "
183 "filtering.");
184
185ABSL_FLAG(int,
186 sselected_stream,
187 0,
188 "ID of the stream to show or analyze for screenshare."
189 "Set to the number of streams to show them all.");
190
191ABSL_FLAG(int,
192 sselected_sl,
193 -1,
194 "Spatial layer to show or analyze for screenshare. -1 to disable "
195 "filtering.");
196
197ABSL_FLAG(bool,
198 generate_slides,
199 false,
200 "Whether to use randomly generated slides or read them from files.");
201
202ABSL_FLAG(int,
203 slide_change_interval,
204 10,
205 "Interval (in seconds) between simulated slide changes.");
206
207ABSL_FLAG(
208 int,
209 scroll_duration,
210 0,
211 "Duration (in seconds) during which a slide will be scrolled into place.");
212
213ABSL_FLAG(std::string,
214 slides,
215 "",
216 "Comma-separated list of *.yuv files to display as slides.");
217
218// Flags common with screenshare and video loopback, with equal default values.
219ABSL_FLAG(int, start_bitrate, 600, "Call start bitrate in kbps.");
220
221ABSL_FLAG(std::string, codec, "VP8", "Video codec to use.");
222
223ABSL_FLAG(bool,
224 analyze_video,
225 false,
226 "Analyze video stream (if --duration is present)");
227
228ABSL_FLAG(bool,
229 analyze_screenshare,
230 false,
231 "Analyze screenshare stream (if --duration is present)");
232
233ABSL_FLAG(
234 int,
235 duration,
236 0,
237 "Duration of the test in seconds. If 0, rendered will be shown instead.");
238
239ABSL_FLAG(std::string, output_filename, "", "Target graph data filename.");
240
241ABSL_FLAG(std::string,
242 graph_title,
243 "",
244 "If empty, title will be generated automatically.");
245
246ABSL_FLAG(int, loss_percent, 0, "Percentage of packets randomly lost.");
247
248ABSL_FLAG(int,
249 avg_burst_loss_length,
250 -1,
251 "Average burst length of lost packets.");
252
253ABSL_FLAG(int,
254 link_capacity,
255 0,
256 "Capacity (kbps) of the fake link. 0 means infinite.");
257
258ABSL_FLAG(int, queue_size, 0, "Size of the bottleneck link queue in packets.");
259
260ABSL_FLAG(int,
261 avg_propagation_delay_ms,
262 0,
263 "Average link propagation delay in ms.");
264
265ABSL_FLAG(std::string,
266 rtc_event_log_name,
267 "",
268 "Filename for rtc event log. Two files "
269 "with \"_send\" and \"_recv\" suffixes will be created. "
270 "Works only when --duration is set.");
271
272ABSL_FLAG(std::string,
273 rtp_dump_name,
274 "",
275 "Filename for dumped received RTP stream.");
276
277ABSL_FLAG(int,
278 std_propagation_delay_ms,
279 0,
280 "Link propagation delay standard deviation in ms.");
281
282ABSL_FLAG(std::string,
283 encoded_frame_path,
284 "",
285 "The base path for encoded frame logs. Created files will have "
286 "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf");
287
288ABSL_FLAG(bool, logs, false, "print logs to stderr");
289
290ABSL_FLAG(bool, send_side_bwe, true, "Use send-side bandwidth estimation");
291
292ABSL_FLAG(bool, generic_descriptor, false, "Use the generic frame descriptor.");
293
294ABSL_FLAG(bool, allow_reordering, false, "Allow packet reordering to occur");
295
296ABSL_FLAG(bool, use_ulpfec, false, "Use RED+ULPFEC forward error correction.");
297
298ABSL_FLAG(bool, use_flexfec, false, "Use FlexFEC forward error correction.");
299
300ABSL_FLAG(bool, audio, false, "Add audio stream");
301
302ABSL_FLAG(bool,
303 audio_video_sync,
304 false,
305 "Sync audio and video stream (no effect if"
306 " audio is false)");
307
308ABSL_FLAG(bool,
309 audio_dtx,
310 false,
311 "Enable audio DTX (no effect if audio is false)");
312
313ABSL_FLAG(bool, video, true, "Add video stream");
314
315ABSL_FLAG(
316 std::string,
317 force_fieldtrials,
318 "",
319 "Field trials control experimental feature code which can be forced. "
320 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
321 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple "
322 "trials are separated by \"/\"");
323
324// Video-specific flags.
325ABSL_FLAG(std::string,
326 vclip,
327 "",
328 "Name of the clip to show. If empty, the camera is used. Use "
329 "\"Generator\" for chroma generator.");
330
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100331namespace webrtc {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200332namespace {
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100333
Sergey Silkin57027362018-05-15 09:12:05 +0200334InterLayerPredMode IntToInterLayerPredMode(int inter_layer_pred) {
335 if (inter_layer_pred == 0) {
336 return InterLayerPredMode::kOn;
337 } else if (inter_layer_pred == 1) {
338 return InterLayerPredMode::kOff;
339 } else {
340 RTC_DCHECK_EQ(inter_layer_pred, 2);
341 return InterLayerPredMode::kOnKeyPic;
342 }
343}
344
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100345size_t VideoWidth() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200346 return static_cast<size_t>(absl::GetFlag(FLAGS_vwidth));
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100347}
348
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100349size_t VideoHeight() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200350 return static_cast<size_t>(absl::GetFlag(FLAGS_vheight));
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100351}
352
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100353int VideoFps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200354 return absl::GetFlag(FLAGS_vfps);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100355}
356
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100357size_t GetCaptureDevice() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200358 return static_cast<size_t>(absl::GetFlag(FLAGS_capture_device_index));
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100359}
360
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100361int VideoTargetBitrateKbps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200362 return absl::GetFlag(FLAGS_vtarget_bitrate);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100363}
364
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100365int VideoMinBitrateKbps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200366 return absl::GetFlag(FLAGS_vmin_bitrate);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100367}
368
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100369int VideoMaxBitrateKbps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200370 return absl::GetFlag(FLAGS_vmax_bitrate);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100371}
372
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100373int VideoNumTemporalLayers() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200374 return absl::GetFlag(FLAGS_vnum_temporal_layers);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100375}
376
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100377int VideoNumStreams() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200378 return absl::GetFlag(FLAGS_vnum_streams);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100379}
380
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100381int VideoNumSpatialLayers() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200382 return absl::GetFlag(FLAGS_vnum_spatial_layers);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100383}
384
Sergey Silkin57027362018-05-15 09:12:05 +0200385InterLayerPredMode VideoInterLayerPred() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200386 return IntToInterLayerPredMode(absl::GetFlag(FLAGS_vinter_layer_pred));
Sergey Silkin57027362018-05-15 09:12:05 +0200387}
388
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100389std::string VideoStream0() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200390 return absl::GetFlag(FLAGS_vstream0);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100391}
392
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100393std::string VideoStream1() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200394 return absl::GetFlag(FLAGS_vstream1);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100395}
396
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100397std::string VideoSL0() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200398 return absl::GetFlag(FLAGS_vsl0);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100399}
400
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100401std::string VideoSL1() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200402 return absl::GetFlag(FLAGS_vsl1);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100403}
404
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100405int VideoSelectedTL() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200406 return absl::GetFlag(FLAGS_vselected_tl);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100407}
408
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100409int VideoSelectedStream() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200410 return absl::GetFlag(FLAGS_vselected_stream);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100411}
412
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100413int VideoSelectedSL() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200414 return absl::GetFlag(FLAGS_vselected_sl);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100415}
416
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100417int ScreenshareMinTransmitBitrateKbps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200418 return absl::GetFlag(FLAGS_min_transmit_bitrate);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100419}
420
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100421size_t ScreenshareWidth() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200422 return static_cast<size_t>(absl::GetFlag(FLAGS_swidth));
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100423}
424
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100425size_t ScreenshareHeight() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200426 return static_cast<size_t>(absl::GetFlag(FLAGS_sheight));
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100427}
428
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100429int ScreenshareFps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200430 return absl::GetFlag(FLAGS_sfps);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100431}
432
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100433int ScreenshareTargetBitrateKbps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200434 return absl::GetFlag(FLAGS_starget_bitrate);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100435}
436
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100437int ScreenshareMinBitrateKbps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200438 return absl::GetFlag(FLAGS_smin_bitrate);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100439}
440
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100441int ScreenshareMaxBitrateKbps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200442 return absl::GetFlag(FLAGS_smax_bitrate);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100443}
444
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100445int ScreenshareNumTemporalLayers() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200446 return absl::GetFlag(FLAGS_snum_temporal_layers);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100447}
448
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100449int ScreenshareNumStreams() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200450 return absl::GetFlag(FLAGS_snum_streams);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100451}
452
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100453int ScreenshareNumSpatialLayers() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200454 return absl::GetFlag(FLAGS_snum_spatial_layers);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100455}
456
Sergey Silkin57027362018-05-15 09:12:05 +0200457InterLayerPredMode ScreenshareInterLayerPred() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200458 return IntToInterLayerPredMode(absl::GetFlag(FLAGS_sinter_layer_pred));
Sergey Silkin57027362018-05-15 09:12:05 +0200459}
460
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100461std::string ScreenshareStream0() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200462 return absl::GetFlag(FLAGS_sstream0);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100463}
464
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100465std::string ScreenshareStream1() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200466 return absl::GetFlag(FLAGS_sstream1);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100467}
468
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100469std::string ScreenshareSL0() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200470 return absl::GetFlag(FLAGS_ssl0);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100471}
472
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100473std::string ScreenshareSL1() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200474 return absl::GetFlag(FLAGS_ssl1);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100475}
476
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100477int ScreenshareSelectedTL() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200478 return absl::GetFlag(FLAGS_sselected_tl);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100479}
480
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100481int ScreenshareSelectedStream() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200482 return absl::GetFlag(FLAGS_sselected_stream);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100483}
484
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100485int ScreenshareSelectedSL() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200486 return absl::GetFlag(FLAGS_sselected_sl);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100487}
488
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100489bool GenerateSlides() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200490 return absl::GetFlag(FLAGS_generate_slides);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100491}
492
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100493int SlideChangeInterval() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200494 return absl::GetFlag(FLAGS_slide_change_interval);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100495}
496
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100497int ScrollDuration() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200498 return absl::GetFlag(FLAGS_scroll_duration);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100499}
500
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100501std::vector<std::string> Slides() {
502 std::vector<std::string> slides;
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200503 std::string slides_list = absl::GetFlag(FLAGS_slides);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100504 rtc::tokenize(slides_list, ',', &slides);
505 return slides;
506}
507
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100508int StartBitrateKbps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200509 return absl::GetFlag(FLAGS_start_bitrate);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100510}
511
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100512std::string Codec() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200513 return absl::GetFlag(FLAGS_codec);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100514}
515
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100516bool AnalyzeVideo() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200517 return absl::GetFlag(FLAGS_analyze_video);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100518}
519
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100520bool AnalyzeScreenshare() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200521 return absl::GetFlag(FLAGS_analyze_screenshare);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100522}
523
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100524int DurationSecs() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200525 return absl::GetFlag(FLAGS_duration);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100526}
527
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100528std::string OutputFilename() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200529 return absl::GetFlag(FLAGS_output_filename);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100530}
531
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100532std::string GraphTitle() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200533 return absl::GetFlag(FLAGS_graph_title);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100534}
535
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100536int LossPercent() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200537 return absl::GetFlag(FLAGS_loss_percent);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100538}
539
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100540int AvgBurstLossLength() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200541 return absl::GetFlag(FLAGS_avg_burst_loss_length);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100542}
543
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100544int LinkCapacityKbps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200545 return absl::GetFlag(FLAGS_link_capacity);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100546}
547
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100548int QueueSize() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200549 return absl::GetFlag(FLAGS_queue_size);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100550}
551
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100552int AvgPropagationDelayMs() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200553 return absl::GetFlag(FLAGS_avg_propagation_delay_ms);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100554}
555
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100556std::string RtcEventLogName() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200557 return absl::GetFlag(FLAGS_rtc_event_log_name);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100558}
559
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100560std::string RtpDumpName() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200561 return absl::GetFlag(FLAGS_rtp_dump_name);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100562}
563
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100564int StdPropagationDelayMs() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200565 return absl::GetFlag(FLAGS_std_propagation_delay_ms);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100566}
567
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100568std::string EncodedFramePath() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200569 return absl::GetFlag(FLAGS_encoded_frame_path);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100570}
571
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100572std::string VideoClip() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200573 return absl::GetFlag(FLAGS_vclip);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100574}
575
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200576} // namespace
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100577
578void Loopback() {
579 int camera_idx, screenshare_idx;
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200580 RTC_CHECK(!(AnalyzeScreenshare() && AnalyzeVideo()))
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100581 << "Select only one of video or screenshare.";
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200582 RTC_CHECK(!DurationSecs() || AnalyzeScreenshare() || AnalyzeVideo())
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100583 << "If duration is set, exactly one of analyze_* flags should be set.";
584 // Default: camera feed first, if nothing selected.
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200585 if (AnalyzeVideo() || !AnalyzeScreenshare()) {
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100586 camera_idx = 0;
587 screenshare_idx = 1;
588 } else {
589 camera_idx = 1;
590 screenshare_idx = 0;
591 }
592
Artem Titov75e36472018-10-08 12:28:56 +0200593 BuiltInNetworkBehaviorConfig pipe_config;
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200594 pipe_config.loss_percent = LossPercent();
595 pipe_config.avg_burst_loss_length = AvgBurstLossLength();
596 pipe_config.link_capacity_kbps = LinkCapacityKbps();
597 pipe_config.queue_length_packets = QueueSize();
598 pipe_config.queue_delay_ms = AvgPropagationDelayMs();
599 pipe_config.delay_standard_deviation_ms = StdPropagationDelayMs();
600 pipe_config.allow_reordering = absl::GetFlag(FLAGS_allow_reordering);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100601
Sebastian Janssonfc8d26b2018-02-21 09:52:06 +0100602 BitrateConstraints call_bitrate_config;
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100603 call_bitrate_config.min_bitrate_bps =
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200604 (ScreenshareMinBitrateKbps() + VideoMinBitrateKbps()) * 1000;
605 call_bitrate_config.start_bitrate_bps = StartBitrateKbps() * 1000;
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100606 call_bitrate_config.max_bitrate_bps =
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200607 (ScreenshareMaxBitrateKbps() + VideoMaxBitrateKbps()) * 1000;
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100608
609 VideoQualityTest::Params params, camera_params, screenshare_params;
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200610 params.call = {absl::GetFlag(FLAGS_send_side_bwe),
611 absl::GetFlag(FLAGS_generic_descriptor), call_bitrate_config,
612 0};
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100613 params.call.dual_video = true;
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200614 params.video[screenshare_idx] = {true,
615 ScreenshareWidth(),
616 ScreenshareHeight(),
617 ScreenshareFps(),
618 ScreenshareMinBitrateKbps() * 1000,
619 ScreenshareTargetBitrateKbps() * 1000,
620 ScreenshareMaxBitrateKbps() * 1000,
621 false,
622 Codec(),
623 ScreenshareNumTemporalLayers(),
624 ScreenshareSelectedTL(),
625 ScreenshareMinTransmitBitrateKbps() * 1000,
626 false, // ULPFEC disabled.
627 false, // FlexFEC disabled.
628 false, // Automatic scaling disabled
629 ""};
630 params.video[camera_idx] = {absl::GetFlag(FLAGS_video),
631 VideoWidth(),
632 VideoHeight(),
633 VideoFps(),
634 VideoMinBitrateKbps() * 1000,
635 VideoTargetBitrateKbps() * 1000,
636 VideoMaxBitrateKbps() * 1000,
637 absl::GetFlag(FLAGS_suspend_below_min_bitrate),
638 Codec(),
639 VideoNumTemporalLayers(),
640 VideoSelectedTL(),
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100641 0, // No min transmit bitrate.
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200642 absl::GetFlag(FLAGS_use_ulpfec),
643 absl::GetFlag(FLAGS_use_flexfec),
Niels Möller6aa415e2018-06-07 11:14:13 +0200644 false,
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200645 VideoClip(),
646 GetCaptureDevice()};
647 params.audio = {absl::GetFlag(FLAGS_audio),
648 absl::GetFlag(FLAGS_audio_video_sync),
649 absl::GetFlag(FLAGS_audio_dtx)};
650 params.logging = {RtcEventLogName(), RtpDumpName(), EncodedFramePath()};
651 params.analyzer = {"dual_streams", 0.0, 0.0, DurationSecs(),
652 OutputFilename(), GraphTitle()};
Artem Titovf18b3522018-08-28 16:54:24 +0200653 params.config = pipe_config;
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100654
655 params.screenshare[camera_idx].enabled = false;
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200656 params.screenshare[screenshare_idx] = {true, GenerateSlides(),
657 SlideChangeInterval(),
658 ScrollDuration(), Slides()};
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100659
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200660 if (VideoNumStreams() > 1 && VideoStream0().empty() &&
661 VideoStream1().empty()) {
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100662 params.ss[camera_idx].infer_streams = true;
663 }
664
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200665 if (ScreenshareNumStreams() > 1 && ScreenshareStream0().empty() &&
666 ScreenshareStream1().empty()) {
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100667 params.ss[screenshare_idx].infer_streams = true;
668 }
669
670 std::vector<std::string> stream_descriptors;
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200671 stream_descriptors.push_back(ScreenshareStream0());
672 stream_descriptors.push_back(ScreenshareStream1());
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100673 std::vector<std::string> SL_descriptors;
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200674 SL_descriptors.push_back(ScreenshareSL0());
675 SL_descriptors.push_back(ScreenshareSL1());
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100676 VideoQualityTest::FillScalabilitySettings(
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200677 &params, screenshare_idx, stream_descriptors, ScreenshareNumStreams(),
678 ScreenshareSelectedStream(), ScreenshareNumSpatialLayers(),
679 ScreenshareSelectedSL(), ScreenshareInterLayerPred(), SL_descriptors);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100680
681 stream_descriptors.clear();
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200682 stream_descriptors.push_back(VideoStream0());
683 stream_descriptors.push_back(VideoStream1());
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100684 SL_descriptors.clear();
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200685 SL_descriptors.push_back(VideoSL0());
686 SL_descriptors.push_back(VideoSL1());
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100687 VideoQualityTest::FillScalabilitySettings(
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200688 &params, camera_idx, stream_descriptors, VideoNumStreams(),
689 VideoSelectedStream(), VideoNumSpatialLayers(), VideoSelectedSL(),
690 VideoInterLayerPred(), SL_descriptors);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100691
Karl Wiberg918f50c2018-07-05 11:40:33 +0200692 auto fixture = absl::make_unique<VideoQualityTest>(nullptr);
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200693 if (DurationSecs()) {
Patrik Höglundb6b29e02018-06-21 16:58:01 +0200694 fixture->RunWithAnalyzer(params);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100695 } else {
Patrik Höglundb6b29e02018-06-21 16:58:01 +0200696 fixture->RunWithRenderers(params);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100697 }
698}
699} // namespace webrtc
700
701int main(int argc, char* argv[]) {
702 ::testing::InitGoogleTest(&argc, argv);
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200703 absl::ParseCommandLine(argc, argv);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100704
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200705 rtc::LogMessage::SetLogToStderr(absl::GetFlag(FLAGS_logs));
Mirko Bonadei45a4c412018-07-31 15:07:28 +0200706
Bjorn Tereliusedab3012018-01-31 17:23:40 +0100707 // InitFieldTrialsFromString stores the char*, so the char array must outlive
708 // the application.
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200709 const std::string field_trials = absl::GetFlag(FLAGS_force_fieldtrials);
710 webrtc::field_trial::InitFieldTrialsFromString(field_trials.c_str());
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100711
712 webrtc::test::RunTest(webrtc::Loopback);
713 return 0;
714}