blob: f4b2bfae3566733e70168a54f4fc130dcd795222 [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 */
Kári Tristan Helgasonede7cb22019-03-06 10:34:09 +010010#include "video/video_loopback.h"
sprang@webrtc.org131bea82015-02-18 12:46:06 +000011
12#include <stdio.h>
Jonas Olsson5b2eda42019-06-11 14:29:40 +020013
Yves Gerey3e707812018-11-28 16:47:49 +010014#include <memory>
15#include <string>
16#include <vector>
sprang@webrtc.org131bea82015-02-18 12:46:06 +000017
Yves Gerey3e707812018-11-28 16:47:49 +010018#include "absl/memory/memory.h"
19#include "absl/types/optional.h"
20#include "api/bitrate_constraints.h"
21#include "api/test/simulated_network.h"
22#include "api/test/video_quality_test_fixture.h"
23#include "api/video_codecs/video_codec.h"
24#include "rtc_base/checks.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020025#include "rtc_base/flags.h"
Mirko Bonadei45a4c412018-07-31 15:07:28 +020026#include "rtc_base/logging.h"
Mirko Bonadei17f48782018-09-28 08:51:10 +020027#include "system_wrappers/include/field_trial.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020028#include "test/field_trial.h"
29#include "test/gtest.h"
30#include "test/run_test.h"
31#include "video/video_quality_test.h"
sprang@webrtc.org131bea82015-02-18 12:46:06 +000032
33namespace webrtc {
sprang@webrtc.org131bea82015-02-18 12:46:06 +000034namespace flags {
35
sprangce4aef12015-11-02 07:23:20 -080036// Flags common with screenshare loopback, with different default values.
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020037WEBRTC_DEFINE_int(width, 640, "Video width.");
sprang@webrtc.org131bea82015-02-18 12:46:06 +000038size_t Width() {
sprang1168fd42017-06-21 09:00:17 -070039 return static_cast<size_t>(FLAG_width);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000040}
41
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020042WEBRTC_DEFINE_int(height, 480, "Video height.");
sprang@webrtc.org131bea82015-02-18 12:46:06 +000043size_t Height() {
sprang1168fd42017-06-21 09:00:17 -070044 return static_cast<size_t>(FLAG_height);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000045}
46
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020047WEBRTC_DEFINE_int(fps, 30, "Frames per second.");
sprang@webrtc.org131bea82015-02-18 12:46:06 +000048int Fps() {
sprang1168fd42017-06-21 09:00:17 -070049 return static_cast<int>(FLAG_fps);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000050}
51
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020052WEBRTC_DEFINE_int(capture_device_index, 0, "Capture device to select");
Tarun Chawla8e857d12017-05-31 19:20:57 +053053size_t GetCaptureDevice() {
sprang1168fd42017-06-21 09:00:17 -070054 return static_cast<size_t>(FLAG_capture_device_index);
Tarun Chawla8e857d12017-05-31 19:20:57 +053055}
56
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020057WEBRTC_DEFINE_int(min_bitrate, 50, "Call and stream min bitrate in kbps.");
ivica5d6a06c2015-09-17 05:30:24 -070058int MinBitrateKbps() {
sprang1168fd42017-06-21 09:00:17 -070059 return static_cast<int>(FLAG_min_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000060}
61
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020062WEBRTC_DEFINE_int(start_bitrate, 300, "Call start bitrate in kbps.");
ivica5d6a06c2015-09-17 05:30:24 -070063int StartBitrateKbps() {
sprang1168fd42017-06-21 09:00:17 -070064 return static_cast<int>(FLAG_start_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000065}
66
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020067WEBRTC_DEFINE_int(target_bitrate, 800, "Stream target bitrate in kbps.");
ivica5d6a06c2015-09-17 05:30:24 -070068int TargetBitrateKbps() {
sprang1168fd42017-06-21 09:00:17 -070069 return static_cast<int>(FLAG_target_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000070}
71
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020072WEBRTC_DEFINE_int(max_bitrate, 800, "Call and stream max bitrate in kbps.");
ivica5d6a06c2015-09-17 05:30:24 -070073int MaxBitrateKbps() {
sprang1168fd42017-06-21 09:00:17 -070074 return static_cast<int>(FLAG_max_bitrate);
ivica5d6a06c2015-09-17 05:30:24 -070075}
sprang@webrtc.org131bea82015-02-18 12:46:06 +000076
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020077WEBRTC_DEFINE_bool(suspend_below_min_bitrate,
78 false,
79 "Suspends video below the configured min bitrate.");
mflodman48a4beb2016-07-01 13:03:59 +020080
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020081WEBRTC_DEFINE_int(num_temporal_layers,
82 1,
83 "Number of temporal layers. Set to 1-4 to override.");
sprangce4aef12015-11-02 07:23:20 -080084int NumTemporalLayers() {
sprang1168fd42017-06-21 09:00:17 -070085 return static_cast<int>(FLAG_num_temporal_layers);
sprangce4aef12015-11-02 07:23:20 -080086}
87
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020088WEBRTC_DEFINE_int(
89 inter_layer_pred,
90 2,
91 "Inter-layer prediction mode. "
92 "0 - enabled, 1 - disabled, 2 - enabled only for key pictures.");
Sergey Silkin57027362018-05-15 09:12:05 +020093InterLayerPredMode InterLayerPred() {
94 if (FLAG_inter_layer_pred == 0) {
95 return InterLayerPredMode::kOn;
96 } else if (FLAG_inter_layer_pred == 1) {
97 return InterLayerPredMode::kOff;
98 } else {
99 RTC_DCHECK_EQ(FLAG_inter_layer_pred, 2);
100 return InterLayerPredMode::kOnKeyPic;
101 }
102}
103
sprangce4aef12015-11-02 07:23:20 -0800104// Flags common with screenshare loopback, with equal default values.
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200105WEBRTC_DEFINE_string(codec, "VP8", "Video codec to use.");
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000106std::string Codec() {
sprang1168fd42017-06-21 09:00:17 -0700107 return static_cast<std::string>(FLAG_codec);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000108}
109
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200110WEBRTC_DEFINE_int(
111 selected_tl,
112 -1,
113 "Temporal layer to show or analyze. -1 to disable filtering.");
sprangce4aef12015-11-02 07:23:20 -0800114int SelectedTL() {
sprang1168fd42017-06-21 09:00:17 -0700115 return static_cast<int>(FLAG_selected_tl);
sprangce4aef12015-11-02 07:23:20 -0800116}
117
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200118WEBRTC_DEFINE_int(
sprangce4aef12015-11-02 07:23:20 -0800119 duration,
120 0,
121 "Duration of the test in seconds. If 0, rendered will be shown instead.");
122int DurationSecs() {
sprang1168fd42017-06-21 09:00:17 -0700123 return static_cast<int>(FLAG_duration);
sprangce4aef12015-11-02 07:23:20 -0800124}
125
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200126WEBRTC_DEFINE_string(output_filename, "", "Target graph data filename.");
sprangce4aef12015-11-02 07:23:20 -0800127std::string OutputFilename() {
sprang1168fd42017-06-21 09:00:17 -0700128 return static_cast<std::string>(FLAG_output_filename);
sprangce4aef12015-11-02 07:23:20 -0800129}
130
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200131WEBRTC_DEFINE_string(graph_title,
132 "",
133 "If empty, title will be generated automatically.");
sprangce4aef12015-11-02 07:23:20 -0800134std::string GraphTitle() {
sprang1168fd42017-06-21 09:00:17 -0700135 return static_cast<std::string>(FLAG_graph_title);
sprangce4aef12015-11-02 07:23:20 -0800136}
137
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200138WEBRTC_DEFINE_int(loss_percent, 0, "Percentage of packets randomly lost.");
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000139int LossPercent() {
sprang1168fd42017-06-21 09:00:17 -0700140 return static_cast<int>(FLAG_loss_percent);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000141}
142
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200143WEBRTC_DEFINE_int(avg_burst_loss_length,
144 -1,
145 "Average burst length of lost packets.");
philipel536378b2016-05-31 03:20:23 -0700146int AvgBurstLossLength() {
sprang1168fd42017-06-21 09:00:17 -0700147 return static_cast<int>(FLAG_avg_burst_loss_length);
philipel536378b2016-05-31 03:20:23 -0700148}
149
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200150WEBRTC_DEFINE_int(link_capacity,
151 0,
152 "Capacity (kbps) of the fake link. 0 means infinite.");
ivica5d6a06c2015-09-17 05:30:24 -0700153int LinkCapacityKbps() {
sprang1168fd42017-06-21 09:00:17 -0700154 return static_cast<int>(FLAG_link_capacity);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000155}
156
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200157WEBRTC_DEFINE_int(queue_size,
158 0,
159 "Size of the bottleneck link queue in packets.");
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000160int QueueSize() {
sprang1168fd42017-06-21 09:00:17 -0700161 return static_cast<int>(FLAG_queue_size);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000162}
163
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200164WEBRTC_DEFINE_int(avg_propagation_delay_ms,
165 0,
166 "Average link propagation delay in ms.");
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000167int AvgPropagationDelayMs() {
sprang1168fd42017-06-21 09:00:17 -0700168 return static_cast<int>(FLAG_avg_propagation_delay_ms);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000169}
170
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200171WEBRTC_DEFINE_string(rtc_event_log_name,
172 "",
173 "Filename for rtc event log. Two files "
174 "with \"_send\" and \"_recv\" suffixes will be created.");
ilnik98436952017-07-13 00:47:03 -0700175std::string RtcEventLogName() {
176 return static_cast<std::string>(FLAG_rtc_event_log_name);
177}
178
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200179WEBRTC_DEFINE_string(rtp_dump_name,
180 "",
181 "Filename for dumped received RTP stream.");
ilnik98436952017-07-13 00:47:03 -0700182std::string RtpDumpName() {
183 return static_cast<std::string>(FLAG_rtp_dump_name);
184}
185
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200186WEBRTC_DEFINE_int(std_propagation_delay_ms,
187 0,
188 "Link propagation delay standard deviation in ms.");
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000189int StdPropagationDelayMs() {
sprang1168fd42017-06-21 09:00:17 -0700190 return static_cast<int>(FLAG_std_propagation_delay_ms);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000191}
192
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200193WEBRTC_DEFINE_int(num_streams, 0, "Number of streams to show or analyze.");
sprang1168fd42017-06-21 09:00:17 -0700194int NumStreams() {
195 return static_cast<int>(FLAG_num_streams);
196}
197
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200198WEBRTC_DEFINE_int(selected_stream,
199 0,
200 "ID of the stream to show or analyze. "
201 "Set to the number of streams to show them all.");
sprangce4aef12015-11-02 07:23:20 -0800202int SelectedStream() {
sprang1168fd42017-06-21 09:00:17 -0700203 return static_cast<int>(FLAG_selected_stream);
sprangce4aef12015-11-02 07:23:20 -0800204}
205
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200206WEBRTC_DEFINE_int(num_spatial_layers, 1, "Number of spatial layers to use.");
sprangce4aef12015-11-02 07:23:20 -0800207int NumSpatialLayers() {
sprang1168fd42017-06-21 09:00:17 -0700208 return static_cast<int>(FLAG_num_spatial_layers);
sprangce4aef12015-11-02 07:23:20 -0800209}
210
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200211WEBRTC_DEFINE_int(selected_sl,
212 -1,
213 "Spatial layer to show or analyze. -1 to disable filtering.");
sprangce4aef12015-11-02 07:23:20 -0800214int SelectedSL() {
sprang1168fd42017-06-21 09:00:17 -0700215 return static_cast<int>(FLAG_selected_sl);
sprangce4aef12015-11-02 07:23:20 -0800216}
217
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200218WEBRTC_DEFINE_string(
219 stream0,
220 "",
221 "Comma separated values describing VideoStream for stream #0.");
sprangce4aef12015-11-02 07:23:20 -0800222std::string Stream0() {
sprang1168fd42017-06-21 09:00:17 -0700223 return static_cast<std::string>(FLAG_stream0);
sprangce4aef12015-11-02 07:23:20 -0800224}
225
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200226WEBRTC_DEFINE_string(
227 stream1,
228 "",
229 "Comma separated values describing VideoStream for stream #1.");
sprangce4aef12015-11-02 07:23:20 -0800230std::string Stream1() {
sprang1168fd42017-06-21 09:00:17 -0700231 return static_cast<std::string>(FLAG_stream1);
sprangce4aef12015-11-02 07:23:20 -0800232}
233
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200234WEBRTC_DEFINE_string(
235 sl0,
236 "",
237 "Comma separated values describing SpatialLayer for layer #0.");
sprangce4aef12015-11-02 07:23:20 -0800238std::string SL0() {
sprang1168fd42017-06-21 09:00:17 -0700239 return static_cast<std::string>(FLAG_sl0);
sprangce4aef12015-11-02 07:23:20 -0800240}
241
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200242WEBRTC_DEFINE_string(
243 sl1,
244 "",
245 "Comma separated values describing SpatialLayer for layer #1.");
sprangce4aef12015-11-02 07:23:20 -0800246std::string SL1() {
sprang1168fd42017-06-21 09:00:17 -0700247 return static_cast<std::string>(FLAG_sl1);
sprangce4aef12015-11-02 07:23:20 -0800248}
249
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200250WEBRTC_DEFINE_string(
Sergey Silkina89800c2019-02-19 12:52:56 +0100251 sl2,
252 "",
253 "Comma separated values describing SpatialLayer for layer #2.");
254std::string SL2() {
255 return static_cast<std::string>(FLAG_sl2);
256}
257
258WEBRTC_DEFINE_string(
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200259 encoded_frame_path,
260 "",
261 "The base path for encoded frame logs. Created files will have "
262 "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf");
palmkviste75f2042016-09-28 06:19:48 -0700263std::string EncodedFramePath() {
sprang1168fd42017-06-21 09:00:17 -0700264 return static_cast<std::string>(FLAG_encoded_frame_path);
palmkviste75f2042016-09-28 06:19:48 -0700265}
266
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200267WEBRTC_DEFINE_bool(logs, false, "print logs to stderr");
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000268
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200269WEBRTC_DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation");
sprangce4aef12015-11-02 07:23:20 -0800270
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200271WEBRTC_DEFINE_bool(generic_descriptor,
272 false,
273 "Use the generic frame descriptor.");
philipel569397f2018-09-26 12:25:31 +0200274
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200275WEBRTC_DEFINE_bool(allow_reordering, false, "Allow packet reordering to occur");
philipela2c55232016-01-26 08:41:53 -0800276
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200277WEBRTC_DEFINE_bool(use_ulpfec,
278 false,
279 "Use RED+ULPFEC forward error correction.");
brandtra62f5822016-11-17 00:21:13 -0800280
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200281WEBRTC_DEFINE_bool(use_flexfec, false, "Use FlexFEC forward error correction.");
philipel274c1dc2016-05-04 06:21:01 -0700282
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200283WEBRTC_DEFINE_bool(audio, false, "Add audio stream");
minyue73208662016-08-18 06:28:55 -0700284
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200285WEBRTC_DEFINE_bool(
286 use_real_adm,
287 false,
288 "Use real ADM instead of fake (no effect if audio is false)");
henrika255750b2018-08-27 16:13:37 +0200289
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200290WEBRTC_DEFINE_bool(audio_video_sync,
291 false,
292 "Sync audio and video stream (no effect if"
293 " audio is false)");
minyue73208662016-08-18 06:28:55 -0700294
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200295WEBRTC_DEFINE_bool(audio_dtx,
296 false,
297 "Enable audio DTX (no effect if audio is false)");
minyue4c8b9422017-03-21 04:11:43 -0700298
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200299WEBRTC_DEFINE_bool(video, true, "Add video stream");
minyuea27172d2016-11-01 05:59:29 -0700300
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200301WEBRTC_DEFINE_string(
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000302 force_fieldtrials,
303 "",
304 "Field trials control experimental feature code which can be forced. "
Elad Alon1e3ed162018-10-15 17:50:37 +0200305 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enabled/"
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000306 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple "
307 "trials are separated by \"/\"");
pbos9874ee02015-06-22 04:44:26 -0700308
sprangce4aef12015-11-02 07:23:20 -0800309// Video-specific flags.
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200310WEBRTC_DEFINE_string(
311 clip,
312 "",
313 "Name of the clip to show. If empty, using chroma generator.");
ivica5d6a06c2015-09-17 05:30:24 -0700314std::string Clip() {
sprang1168fd42017-06-21 09:00:17 -0700315 return static_cast<std::string>(FLAG_clip);
ivica5d6a06c2015-09-17 05:30:24 -0700316}
317
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200318WEBRTC_DEFINE_bool(help, false, "prints this message");
sprang1168fd42017-06-21 09:00:17 -0700319
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000320} // namespace flags
321
322void Loopback() {
Artem Titov75e36472018-10-08 12:28:56 +0200323 BuiltInNetworkBehaviorConfig pipe_config;
ivica5d6a06c2015-09-17 05:30:24 -0700324 pipe_config.loss_percent = flags::LossPercent();
philipel536378b2016-05-31 03:20:23 -0700325 pipe_config.avg_burst_loss_length = flags::AvgBurstLossLength();
ivica5d6a06c2015-09-17 05:30:24 -0700326 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps();
327 pipe_config.queue_length_packets = flags::QueueSize();
328 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs();
329 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs();
sprang1168fd42017-06-21 09:00:17 -0700330 pipe_config.allow_reordering = flags::FLAG_allow_reordering;
ivica5d6a06c2015-09-17 05:30:24 -0700331
Sebastian Janssonfc8d26b2018-02-21 09:52:06 +0100332 BitrateConstraints call_bitrate_config;
ivica5d6a06c2015-09-17 05:30:24 -0700333 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000;
334 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000;
Erik Språng28bb3912018-07-11 16:06:55 +0200335 call_bitrate_config.max_bitrate_bps = -1; // Don't cap bandwidth estimate.
ivica5d6a06c2015-09-17 05:30:24 -0700336
minyue73208662016-08-18 06:28:55 -0700337 VideoQualityTest::Params params;
philipel569397f2018-09-26 12:25:31 +0200338 params.call = {flags::FLAG_send_side_bwe, flags::FLAG_generic_descriptor,
339 call_bitrate_config, 0};
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100340 params.video[0] = {flags::FLAG_video,
341 flags::Width(),
342 flags::Height(),
343 flags::Fps(),
344 flags::MinBitrateKbps() * 1000,
345 flags::TargetBitrateKbps() * 1000,
346 flags::MaxBitrateKbps() * 1000,
347 flags::FLAG_suspend_below_min_bitrate,
348 flags::Codec(),
349 flags::NumTemporalLayers(),
350 flags::SelectedTL(),
351 0, // No min transmit bitrate.
352 flags::FLAG_use_ulpfec,
353 flags::FLAG_use_flexfec,
philipel5affbf22019-01-24 15:49:40 +0100354 flags::NumStreams() < 2, // Automatic quality scaling.
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100355 flags::Clip(),
356 flags::GetCaptureDevice()};
sprang1168fd42017-06-21 09:00:17 -0700357 params.audio = {flags::FLAG_audio, flags::FLAG_audio_video_sync,
henrika255750b2018-08-27 16:13:37 +0200358 flags::FLAG_audio_dtx, flags::FLAG_use_real_adm};
Mirko Bonadei45a4c412018-07-31 15:07:28 +0200359 params.logging = {flags::FLAG_rtc_event_log_name, flags::FLAG_rtp_dump_name,
360 flags::FLAG_encoded_frame_path};
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100361 params.screenshare[0].enabled = false;
Yves Gerey665174f2018-06-19 15:03:05 +0200362 params.analyzer = {"video",
363 0.0,
364 0.0,
365 flags::DurationSecs(),
366 flags::OutputFilename(),
367 flags::GraphTitle()};
Artem Titovf18b3522018-08-28 16:54:24 +0200368 params.config = pipe_config;
sprang1168fd42017-06-21 09:00:17 -0700369
370 if (flags::NumStreams() > 1 && flags::Stream0().empty() &&
371 flags::Stream1().empty()) {
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100372 params.ss[0].infer_streams = true;
sprang1168fd42017-06-21 09:00:17 -0700373 }
ivica5d6a06c2015-09-17 05:30:24 -0700374
sprangce4aef12015-11-02 07:23:20 -0800375 std::vector<std::string> stream_descriptors;
376 stream_descriptors.push_back(flags::Stream0());
377 stream_descriptors.push_back(flags::Stream1());
378 std::vector<std::string> SL_descriptors;
379 SL_descriptors.push_back(flags::SL0());
380 SL_descriptors.push_back(flags::SL1());
Sergey Silkina89800c2019-02-19 12:52:56 +0100381 SL_descriptors.push_back(flags::SL2());
sprangce4aef12015-11-02 07:23:20 -0800382 VideoQualityTest::FillScalabilitySettings(
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100383 &params, 0, stream_descriptors, flags::NumStreams(),
384 flags::SelectedStream(), flags::NumSpatialLayers(), flags::SelectedSL(),
Sergey Silkin57027362018-05-15 09:12:05 +0200385 flags::InterLayerPred(), SL_descriptors);
sprangce4aef12015-11-02 07:23:20 -0800386
Karl Wiberg918f50c2018-07-05 11:40:33 +0200387 auto fixture = absl::make_unique<VideoQualityTest>(nullptr);
sprangce4aef12015-11-02 07:23:20 -0800388 if (flags::DurationSecs()) {
Patrik Höglundb6b29e02018-06-21 16:58:01 +0200389 fixture->RunWithAnalyzer(params);
sprangce4aef12015-11-02 07:23:20 -0800390 } else {
Patrik Höglundb6b29e02018-06-21 16:58:01 +0200391 fixture->RunWithRenderers(params);
sprangce4aef12015-11-02 07:23:20 -0800392 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000393}
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000394
Kári Tristan Helgasonede7cb22019-03-06 10:34:09 +0100395int RunLoopbackTest(int argc, char* argv[]) {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000396 ::testing::InitGoogleTest(&argc, argv);
sprang1168fd42017-06-21 09:00:17 -0700397 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
398 if (webrtc::flags::FLAG_help) {
399 rtc::FlagList::Print(nullptr, false);
400 return 0;
401 }
402
Mirko Bonadei45a4c412018-07-31 15:07:28 +0200403 rtc::LogMessage::SetLogToStderr(webrtc::flags::FLAG_logs);
404
Bjorn Tereliusedab3012018-01-31 17:23:40 +0100405 // InitFieldTrialsFromString stores the char*, so the char array must outlive
406 // the application.
407 webrtc::field_trial::InitFieldTrialsFromString(
408 webrtc::flags::FLAG_force_fieldtrials);
sprang89c4a7e2017-06-30 13:27:40 -0700409
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000410 webrtc::test::RunTest(webrtc::Loopback);
411 return 0;
412}
Kári Tristan Helgasonede7cb22019-03-06 10:34:09 +0100413} // namespace webrtc