blob: ec236d6e62b7623106ac28bdf93d0469a6fef617 [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/types/optional.h"
Yves Gerey3e707812018-11-28 16:47:49 +010020#include "api/test/simulated_network.h"
21#include "api/test/video_quality_test_fixture.h"
Mirko Bonadei738bfa72019-09-17 14:47:38 +020022#include "api/transport/bitrate_settings.h"
Yves Gerey3e707812018-11-28 16:47:49 +010023#include "api/video_codecs/video_codec.h"
24#include "rtc_base/checks.h"
Mirko Bonadei45a4c412018-07-31 15:07:28 +020025#include "rtc_base/logging.h"
Steve Anton10542f22019-01-11 09:11:00 -080026#include "rtc_base/string_encode.h"
Mirko Bonadei17f48782018-09-28 08:51:10 +020027#include "system_wrappers/include/field_trial.h"
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +010028#include "test/field_trial.h"
29#include "test/gtest.h"
30#include "test/run_test.h"
31#include "video/video_quality_test.h"
32
Mirko Bonadei2ab97f62019-07-18 13:44:12 +020033// Flags for video.
34ABSL_FLAG(int, vwidth, 640, "Video width.");
35
36ABSL_FLAG(int, vheight, 480, "Video height.");
37
38ABSL_FLAG(int, vfps, 30, "Video frames per second.");
39
40ABSL_FLAG(int,
41 capture_device_index,
42 0,
43 "Capture device to select for video stream");
44
45ABSL_FLAG(int, vtarget_bitrate, 400, "Video stream target bitrate in kbps.");
46
47ABSL_FLAG(int, vmin_bitrate, 100, "Video stream min bitrate in kbps.");
48
49ABSL_FLAG(int, vmax_bitrate, 2000, "Video stream max bitrate in kbps.");
50
51ABSL_FLAG(bool,
52 suspend_below_min_bitrate,
53 false,
54 "Suspends video below the configured min bitrate.");
55
56ABSL_FLAG(int,
57 vnum_temporal_layers,
58 1,
59 "Number of temporal layers for video. Set to 1-4 to override.");
60
61ABSL_FLAG(int, vnum_streams, 0, "Number of video streams to show or analyze.");
62
63ABSL_FLAG(int,
64 vnum_spatial_layers,
65 1,
66 "Number of video spatial layers to use.");
67
68ABSL_FLAG(int,
69 vinter_layer_pred,
70 2,
71 "Video inter-layer prediction mode. "
72 "0 - enabled, 1 - disabled, 2 - enabled only for key pictures.");
73
74ABSL_FLAG(std::string,
75 vstream0,
76 "",
77 "Comma separated values describing VideoStream for video stream #0.");
78
79ABSL_FLAG(std::string,
80 vstream1,
81 "",
82 "Comma separated values describing VideoStream for video stream #1.");
83
84ABSL_FLAG(std::string,
85 vsl0,
86 "",
87 "Comma separated values describing SpatialLayer for video layer #0.");
88
89ABSL_FLAG(std::string,
90 vsl1,
91 "",
92 "Comma separated values describing SpatialLayer for video layer #1.");
93
94ABSL_FLAG(int,
95 vselected_tl,
96 -1,
97 "Temporal layer to show or analyze for screenshare. -1 to disable "
98 "filtering.");
99
100ABSL_FLAG(int,
101 vselected_stream,
102 0,
103 "ID of the stream to show or analyze for screenshare."
104 "Set to the number of streams to show them all.");
105
106ABSL_FLAG(int,
107 vselected_sl,
108 -1,
109 "Spatial layer to show or analyze for screenshare. -1 to disable "
110 "filtering.");
111
112// Flags for screenshare.
113ABSL_FLAG(int,
114 min_transmit_bitrate,
115 400,
116 "Min transmit bitrate incl. padding for screenshare.");
117
118ABSL_FLAG(int, swidth, 1850, "Screenshare width (crops source).");
119
120ABSL_FLAG(int, sheight, 1110, "Screenshare height (crops source).");
121
122ABSL_FLAG(int, sfps, 5, "Frames per second for screenshare.");
123
124ABSL_FLAG(int,
125 starget_bitrate,
126 100,
127 "Screenshare stream target bitrate in kbps.");
128
129ABSL_FLAG(int, smin_bitrate, 100, "Screenshare stream min bitrate in kbps.");
130
131ABSL_FLAG(int, smax_bitrate, 2000, "Screenshare stream max bitrate in kbps.");
132
133ABSL_FLAG(int,
134 snum_temporal_layers,
135 2,
136 "Number of temporal layers to use in screenshare.");
137
138ABSL_FLAG(int,
139 snum_streams,
140 0,
141 "Number of screenshare streams to show or analyze.");
142
143ABSL_FLAG(int,
144 snum_spatial_layers,
145 1,
146 "Number of screenshare spatial layers to use.");
147
148ABSL_FLAG(int,
149 sinter_layer_pred,
150 0,
151 "Screenshare inter-layer prediction mode. "
152 "0 - enabled, 1 - disabled, 2 - enabled only for key pictures.");
153
154ABSL_FLAG(
155 std::string,
156 sstream0,
157 "",
158 "Comma separated values describing VideoStream for screenshare stream #0.");
159
160ABSL_FLAG(
161 std::string,
162 sstream1,
163 "",
164 "Comma separated values describing VideoStream for screenshare stream #1.");
165
166ABSL_FLAG(
167 std::string,
168 ssl0,
169 "",
170 "Comma separated values describing SpatialLayer for screenshare layer #0.");
171
172ABSL_FLAG(
173 std::string,
174 ssl1,
175 "",
176 "Comma separated values describing SpatialLayer for screenshare layer #1.");
177
178ABSL_FLAG(int,
179 sselected_tl,
180 -1,
181 "Temporal layer to show or analyze for screenshare. -1 to disable "
182 "filtering.");
183
184ABSL_FLAG(int,
185 sselected_stream,
186 0,
187 "ID of the stream to show or analyze for screenshare."
188 "Set to the number of streams to show them all.");
189
190ABSL_FLAG(int,
191 sselected_sl,
192 -1,
193 "Spatial layer to show or analyze for screenshare. -1 to disable "
194 "filtering.");
195
196ABSL_FLAG(bool,
197 generate_slides,
198 false,
199 "Whether to use randomly generated slides or read them from files.");
200
201ABSL_FLAG(int,
202 slide_change_interval,
203 10,
204 "Interval (in seconds) between simulated slide changes.");
205
206ABSL_FLAG(
207 int,
208 scroll_duration,
209 0,
210 "Duration (in seconds) during which a slide will be scrolled into place.");
211
212ABSL_FLAG(std::string,
213 slides,
214 "",
215 "Comma-separated list of *.yuv files to display as slides.");
216
217// Flags common with screenshare and video loopback, with equal default values.
218ABSL_FLAG(int, start_bitrate, 600, "Call start bitrate in kbps.");
219
220ABSL_FLAG(std::string, codec, "VP8", "Video codec to use.");
221
222ABSL_FLAG(bool,
223 analyze_video,
224 false,
225 "Analyze video stream (if --duration is present)");
226
227ABSL_FLAG(bool,
228 analyze_screenshare,
229 false,
230 "Analyze screenshare stream (if --duration is present)");
231
232ABSL_FLAG(
233 int,
234 duration,
235 0,
236 "Duration of the test in seconds. If 0, rendered will be shown instead.");
237
238ABSL_FLAG(std::string, output_filename, "", "Target graph data filename.");
239
240ABSL_FLAG(std::string,
241 graph_title,
242 "",
243 "If empty, title will be generated automatically.");
244
245ABSL_FLAG(int, loss_percent, 0, "Percentage of packets randomly lost.");
246
247ABSL_FLAG(int,
248 avg_burst_loss_length,
249 -1,
250 "Average burst length of lost packets.");
251
252ABSL_FLAG(int,
253 link_capacity,
254 0,
255 "Capacity (kbps) of the fake link. 0 means infinite.");
256
257ABSL_FLAG(int, queue_size, 0, "Size of the bottleneck link queue in packets.");
258
259ABSL_FLAG(int,
260 avg_propagation_delay_ms,
261 0,
262 "Average link propagation delay in ms.");
263
264ABSL_FLAG(std::string,
265 rtc_event_log_name,
266 "",
267 "Filename for rtc event log. Two files "
268 "with \"_send\" and \"_recv\" suffixes will be created. "
269 "Works only when --duration is set.");
270
271ABSL_FLAG(std::string,
272 rtp_dump_name,
273 "",
274 "Filename for dumped received RTP stream.");
275
276ABSL_FLAG(int,
277 std_propagation_delay_ms,
278 0,
279 "Link propagation delay standard deviation in ms.");
280
281ABSL_FLAG(std::string,
282 encoded_frame_path,
283 "",
284 "The base path for encoded frame logs. Created files will have "
285 "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf");
286
287ABSL_FLAG(bool, logs, false, "print logs to stderr");
288
289ABSL_FLAG(bool, send_side_bwe, true, "Use send-side bandwidth estimation");
290
291ABSL_FLAG(bool, generic_descriptor, false, "Use the generic frame descriptor.");
292
293ABSL_FLAG(bool, allow_reordering, false, "Allow packet reordering to occur");
294
295ABSL_FLAG(bool, use_ulpfec, false, "Use RED+ULPFEC forward error correction.");
296
297ABSL_FLAG(bool, use_flexfec, false, "Use FlexFEC forward error correction.");
298
299ABSL_FLAG(bool, audio, false, "Add audio stream");
300
301ABSL_FLAG(bool,
302 audio_video_sync,
303 false,
304 "Sync audio and video stream (no effect if"
305 " audio is false)");
306
307ABSL_FLAG(bool,
308 audio_dtx,
309 false,
310 "Enable audio DTX (no effect if audio is false)");
311
312ABSL_FLAG(bool, video, true, "Add video stream");
313
314ABSL_FLAG(
315 std::string,
316 force_fieldtrials,
317 "",
318 "Field trials control experimental feature code which can be forced. "
319 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
320 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple "
321 "trials are separated by \"/\"");
322
323// Video-specific flags.
324ABSL_FLAG(std::string,
325 vclip,
326 "",
327 "Name of the clip to show. If empty, the camera is used. Use "
328 "\"Generator\" for chroma generator.");
329
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100330namespace webrtc {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200331namespace {
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100332
Sergey Silkin57027362018-05-15 09:12:05 +0200333InterLayerPredMode IntToInterLayerPredMode(int inter_layer_pred) {
334 if (inter_layer_pred == 0) {
335 return InterLayerPredMode::kOn;
336 } else if (inter_layer_pred == 1) {
337 return InterLayerPredMode::kOff;
338 } else {
339 RTC_DCHECK_EQ(inter_layer_pred, 2);
340 return InterLayerPredMode::kOnKeyPic;
341 }
342}
343
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100344size_t VideoWidth() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200345 return static_cast<size_t>(absl::GetFlag(FLAGS_vwidth));
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100346}
347
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100348size_t VideoHeight() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200349 return static_cast<size_t>(absl::GetFlag(FLAGS_vheight));
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100350}
351
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100352int VideoFps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200353 return absl::GetFlag(FLAGS_vfps);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100354}
355
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100356size_t GetCaptureDevice() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200357 return static_cast<size_t>(absl::GetFlag(FLAGS_capture_device_index));
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100358}
359
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100360int VideoTargetBitrateKbps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200361 return absl::GetFlag(FLAGS_vtarget_bitrate);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100362}
363
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100364int VideoMinBitrateKbps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200365 return absl::GetFlag(FLAGS_vmin_bitrate);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100366}
367
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100368int VideoMaxBitrateKbps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200369 return absl::GetFlag(FLAGS_vmax_bitrate);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100370}
371
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100372int VideoNumTemporalLayers() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200373 return absl::GetFlag(FLAGS_vnum_temporal_layers);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100374}
375
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100376int VideoNumStreams() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200377 return absl::GetFlag(FLAGS_vnum_streams);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100378}
379
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100380int VideoNumSpatialLayers() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200381 return absl::GetFlag(FLAGS_vnum_spatial_layers);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100382}
383
Sergey Silkin57027362018-05-15 09:12:05 +0200384InterLayerPredMode VideoInterLayerPred() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200385 return IntToInterLayerPredMode(absl::GetFlag(FLAGS_vinter_layer_pred));
Sergey Silkin57027362018-05-15 09:12:05 +0200386}
387
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100388std::string VideoStream0() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200389 return absl::GetFlag(FLAGS_vstream0);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100390}
391
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100392std::string VideoStream1() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200393 return absl::GetFlag(FLAGS_vstream1);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100394}
395
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100396std::string VideoSL0() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200397 return absl::GetFlag(FLAGS_vsl0);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100398}
399
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100400std::string VideoSL1() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200401 return absl::GetFlag(FLAGS_vsl1);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100402}
403
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100404int VideoSelectedTL() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200405 return absl::GetFlag(FLAGS_vselected_tl);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100406}
407
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100408int VideoSelectedStream() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200409 return absl::GetFlag(FLAGS_vselected_stream);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100410}
411
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100412int VideoSelectedSL() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200413 return absl::GetFlag(FLAGS_vselected_sl);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100414}
415
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100416int ScreenshareMinTransmitBitrateKbps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200417 return absl::GetFlag(FLAGS_min_transmit_bitrate);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100418}
419
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100420size_t ScreenshareWidth() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200421 return static_cast<size_t>(absl::GetFlag(FLAGS_swidth));
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100422}
423
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100424size_t ScreenshareHeight() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200425 return static_cast<size_t>(absl::GetFlag(FLAGS_sheight));
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100426}
427
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100428int ScreenshareFps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200429 return absl::GetFlag(FLAGS_sfps);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100430}
431
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100432int ScreenshareTargetBitrateKbps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200433 return absl::GetFlag(FLAGS_starget_bitrate);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100434}
435
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100436int ScreenshareMinBitrateKbps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200437 return absl::GetFlag(FLAGS_smin_bitrate);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100438}
439
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100440int ScreenshareMaxBitrateKbps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200441 return absl::GetFlag(FLAGS_smax_bitrate);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100442}
443
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100444int ScreenshareNumTemporalLayers() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200445 return absl::GetFlag(FLAGS_snum_temporal_layers);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100446}
447
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100448int ScreenshareNumStreams() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200449 return absl::GetFlag(FLAGS_snum_streams);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100450}
451
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100452int ScreenshareNumSpatialLayers() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200453 return absl::GetFlag(FLAGS_snum_spatial_layers);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100454}
455
Sergey Silkin57027362018-05-15 09:12:05 +0200456InterLayerPredMode ScreenshareInterLayerPred() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200457 return IntToInterLayerPredMode(absl::GetFlag(FLAGS_sinter_layer_pred));
Sergey Silkin57027362018-05-15 09:12:05 +0200458}
459
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100460std::string ScreenshareStream0() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200461 return absl::GetFlag(FLAGS_sstream0);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100462}
463
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100464std::string ScreenshareStream1() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200465 return absl::GetFlag(FLAGS_sstream1);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100466}
467
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100468std::string ScreenshareSL0() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200469 return absl::GetFlag(FLAGS_ssl0);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100470}
471
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100472std::string ScreenshareSL1() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200473 return absl::GetFlag(FLAGS_ssl1);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100474}
475
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100476int ScreenshareSelectedTL() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200477 return absl::GetFlag(FLAGS_sselected_tl);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100478}
479
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100480int ScreenshareSelectedStream() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200481 return absl::GetFlag(FLAGS_sselected_stream);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100482}
483
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100484int ScreenshareSelectedSL() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200485 return absl::GetFlag(FLAGS_sselected_sl);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100486}
487
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100488bool GenerateSlides() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200489 return absl::GetFlag(FLAGS_generate_slides);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100490}
491
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100492int SlideChangeInterval() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200493 return absl::GetFlag(FLAGS_slide_change_interval);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100494}
495
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100496int ScrollDuration() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200497 return absl::GetFlag(FLAGS_scroll_duration);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100498}
499
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100500std::vector<std::string> Slides() {
501 std::vector<std::string> slides;
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200502 std::string slides_list = absl::GetFlag(FLAGS_slides);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100503 rtc::tokenize(slides_list, ',', &slides);
504 return slides;
505}
506
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100507int StartBitrateKbps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200508 return absl::GetFlag(FLAGS_start_bitrate);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100509}
510
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100511std::string Codec() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200512 return absl::GetFlag(FLAGS_codec);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100513}
514
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100515bool AnalyzeVideo() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200516 return absl::GetFlag(FLAGS_analyze_video);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100517}
518
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100519bool AnalyzeScreenshare() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200520 return absl::GetFlag(FLAGS_analyze_screenshare);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100521}
522
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100523int DurationSecs() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200524 return absl::GetFlag(FLAGS_duration);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100525}
526
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100527std::string OutputFilename() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200528 return absl::GetFlag(FLAGS_output_filename);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100529}
530
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100531std::string GraphTitle() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200532 return absl::GetFlag(FLAGS_graph_title);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100533}
534
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100535int LossPercent() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200536 return absl::GetFlag(FLAGS_loss_percent);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100537}
538
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100539int AvgBurstLossLength() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200540 return absl::GetFlag(FLAGS_avg_burst_loss_length);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100541}
542
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100543int LinkCapacityKbps() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200544 return absl::GetFlag(FLAGS_link_capacity);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100545}
546
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100547int QueueSize() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200548 return absl::GetFlag(FLAGS_queue_size);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100549}
550
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100551int AvgPropagationDelayMs() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200552 return absl::GetFlag(FLAGS_avg_propagation_delay_ms);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100553}
554
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100555std::string RtcEventLogName() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200556 return absl::GetFlag(FLAGS_rtc_event_log_name);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100557}
558
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100559std::string RtpDumpName() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200560 return absl::GetFlag(FLAGS_rtp_dump_name);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100561}
562
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100563int StdPropagationDelayMs() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200564 return absl::GetFlag(FLAGS_std_propagation_delay_ms);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100565}
566
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100567std::string EncodedFramePath() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200568 return absl::GetFlag(FLAGS_encoded_frame_path);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100569}
570
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100571std::string VideoClip() {
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200572 return absl::GetFlag(FLAGS_vclip);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100573}
574
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200575} // namespace
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100576
577void Loopback() {
578 int camera_idx, screenshare_idx;
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200579 RTC_CHECK(!(AnalyzeScreenshare() && AnalyzeVideo()))
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100580 << "Select only one of video or screenshare.";
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200581 RTC_CHECK(!DurationSecs() || AnalyzeScreenshare() || AnalyzeVideo())
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100582 << "If duration is set, exactly one of analyze_* flags should be set.";
583 // Default: camera feed first, if nothing selected.
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200584 if (AnalyzeVideo() || !AnalyzeScreenshare()) {
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100585 camera_idx = 0;
586 screenshare_idx = 1;
587 } else {
588 camera_idx = 1;
589 screenshare_idx = 0;
590 }
591
Artem Titov75e36472018-10-08 12:28:56 +0200592 BuiltInNetworkBehaviorConfig pipe_config;
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200593 pipe_config.loss_percent = LossPercent();
594 pipe_config.avg_burst_loss_length = AvgBurstLossLength();
595 pipe_config.link_capacity_kbps = LinkCapacityKbps();
596 pipe_config.queue_length_packets = QueueSize();
597 pipe_config.queue_delay_ms = AvgPropagationDelayMs();
598 pipe_config.delay_standard_deviation_ms = StdPropagationDelayMs();
599 pipe_config.allow_reordering = absl::GetFlag(FLAGS_allow_reordering);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100600
Sebastian Janssonfc8d26b2018-02-21 09:52:06 +0100601 BitrateConstraints call_bitrate_config;
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100602 call_bitrate_config.min_bitrate_bps =
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200603 (ScreenshareMinBitrateKbps() + VideoMinBitrateKbps()) * 1000;
604 call_bitrate_config.start_bitrate_bps = StartBitrateKbps() * 1000;
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100605 call_bitrate_config.max_bitrate_bps =
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200606 (ScreenshareMaxBitrateKbps() + VideoMaxBitrateKbps()) * 1000;
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100607
608 VideoQualityTest::Params params, camera_params, screenshare_params;
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200609 params.call = {absl::GetFlag(FLAGS_send_side_bwe),
610 absl::GetFlag(FLAGS_generic_descriptor), call_bitrate_config,
611 0};
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100612 params.call.dual_video = true;
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200613 params.video[screenshare_idx] = {true,
614 ScreenshareWidth(),
615 ScreenshareHeight(),
616 ScreenshareFps(),
617 ScreenshareMinBitrateKbps() * 1000,
618 ScreenshareTargetBitrateKbps() * 1000,
619 ScreenshareMaxBitrateKbps() * 1000,
620 false,
621 Codec(),
622 ScreenshareNumTemporalLayers(),
623 ScreenshareSelectedTL(),
624 ScreenshareMinTransmitBitrateKbps() * 1000,
625 false, // ULPFEC disabled.
626 false, // FlexFEC disabled.
627 false, // Automatic scaling disabled
628 ""};
629 params.video[camera_idx] = {absl::GetFlag(FLAGS_video),
630 VideoWidth(),
631 VideoHeight(),
632 VideoFps(),
633 VideoMinBitrateKbps() * 1000,
634 VideoTargetBitrateKbps() * 1000,
635 VideoMaxBitrateKbps() * 1000,
636 absl::GetFlag(FLAGS_suspend_below_min_bitrate),
637 Codec(),
638 VideoNumTemporalLayers(),
639 VideoSelectedTL(),
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100640 0, // No min transmit bitrate.
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200641 absl::GetFlag(FLAGS_use_ulpfec),
642 absl::GetFlag(FLAGS_use_flexfec),
Niels Möller6aa415e2018-06-07 11:14:13 +0200643 false,
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200644 VideoClip(),
645 GetCaptureDevice()};
646 params.audio = {absl::GetFlag(FLAGS_audio),
647 absl::GetFlag(FLAGS_audio_video_sync),
648 absl::GetFlag(FLAGS_audio_dtx)};
649 params.logging = {RtcEventLogName(), RtpDumpName(), EncodedFramePath()};
650 params.analyzer = {"dual_streams", 0.0, 0.0, DurationSecs(),
651 OutputFilename(), GraphTitle()};
Artem Titovf18b3522018-08-28 16:54:24 +0200652 params.config = pipe_config;
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100653
654 params.screenshare[camera_idx].enabled = false;
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200655 params.screenshare[screenshare_idx] = {true, GenerateSlides(),
656 SlideChangeInterval(),
657 ScrollDuration(), Slides()};
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100658
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200659 if (VideoNumStreams() > 1 && VideoStream0().empty() &&
660 VideoStream1().empty()) {
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100661 params.ss[camera_idx].infer_streams = true;
662 }
663
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200664 if (ScreenshareNumStreams() > 1 && ScreenshareStream0().empty() &&
665 ScreenshareStream1().empty()) {
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100666 params.ss[screenshare_idx].infer_streams = true;
667 }
668
669 std::vector<std::string> stream_descriptors;
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200670 stream_descriptors.push_back(ScreenshareStream0());
671 stream_descriptors.push_back(ScreenshareStream1());
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100672 std::vector<std::string> SL_descriptors;
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200673 SL_descriptors.push_back(ScreenshareSL0());
674 SL_descriptors.push_back(ScreenshareSL1());
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100675 VideoQualityTest::FillScalabilitySettings(
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200676 &params, screenshare_idx, stream_descriptors, ScreenshareNumStreams(),
677 ScreenshareSelectedStream(), ScreenshareNumSpatialLayers(),
678 ScreenshareSelectedSL(), ScreenshareInterLayerPred(), SL_descriptors);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100679
680 stream_descriptors.clear();
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200681 stream_descriptors.push_back(VideoStream0());
682 stream_descriptors.push_back(VideoStream1());
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100683 SL_descriptors.clear();
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200684 SL_descriptors.push_back(VideoSL0());
685 SL_descriptors.push_back(VideoSL1());
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100686 VideoQualityTest::FillScalabilitySettings(
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200687 &params, camera_idx, stream_descriptors, VideoNumStreams(),
688 VideoSelectedStream(), VideoNumSpatialLayers(), VideoSelectedSL(),
689 VideoInterLayerPred(), SL_descriptors);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100690
Mirko Bonadei317a1f02019-09-17 17:06:18 +0200691 auto fixture = std::make_unique<VideoQualityTest>(nullptr);
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200692 if (DurationSecs()) {
Patrik Höglundb6b29e02018-06-21 16:58:01 +0200693 fixture->RunWithAnalyzer(params);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100694 } else {
Patrik Höglundb6b29e02018-06-21 16:58:01 +0200695 fixture->RunWithRenderers(params);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100696 }
697}
698} // namespace webrtc
699
700int main(int argc, char* argv[]) {
701 ::testing::InitGoogleTest(&argc, argv);
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200702 absl::ParseCommandLine(argc, argv);
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100703
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200704 rtc::LogMessage::SetLogToStderr(absl::GetFlag(FLAGS_logs));
Mirko Bonadei45a4c412018-07-31 15:07:28 +0200705
Bjorn Tereliusedab3012018-01-31 17:23:40 +0100706 // InitFieldTrialsFromString stores the char*, so the char array must outlive
707 // the application.
Mirko Bonadei2ab97f62019-07-18 13:44:12 +0200708 const std::string field_trials = absl::GetFlag(FLAGS_force_fieldtrials);
709 webrtc::field_trial::InitFieldTrialsFromString(field_trials.c_str());
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100710
711 webrtc::test::RunTest(webrtc::Loopback);
712 return 0;
713}