blob: 9ceb124ba196596ee3839663a7608dd8534ff95a [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>
Yves Gerey3e707812018-11-28 16:47:49 +010013#include <memory>
14#include <string>
15#include <vector>
sprang@webrtc.org131bea82015-02-18 12:46:06 +000016
Yves Gerey3e707812018-11-28 16:47:49 +010017#include "absl/memory/memory.h"
18#include "absl/types/optional.h"
19#include "api/bitrate_constraints.h"
20#include "api/test/simulated_network.h"
21#include "api/test/video_quality_test_fixture.h"
22#include "api/video_codecs/video_codec.h"
23#include "rtc_base/checks.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020024#include "rtc_base/flags.h"
Mirko Bonadei45a4c412018-07-31 15:07:28 +020025#include "rtc_base/logging.h"
Mirko Bonadei17f48782018-09-28 08:51:10 +020026#include "system_wrappers/include/field_trial.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020027#include "test/field_trial.h"
28#include "test/gtest.h"
29#include "test/run_test.h"
30#include "video/video_quality_test.h"
sprang@webrtc.org131bea82015-02-18 12:46:06 +000031
32namespace webrtc {
sprang@webrtc.org131bea82015-02-18 12:46:06 +000033namespace flags {
34
sprangce4aef12015-11-02 07:23:20 -080035// Flags common with screenshare loopback, with different default values.
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020036WEBRTC_DEFINE_int(width, 640, "Video width.");
sprang@webrtc.org131bea82015-02-18 12:46:06 +000037size_t Width() {
sprang1168fd42017-06-21 09:00:17 -070038 return static_cast<size_t>(FLAG_width);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000039}
40
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020041WEBRTC_DEFINE_int(height, 480, "Video height.");
sprang@webrtc.org131bea82015-02-18 12:46:06 +000042size_t Height() {
sprang1168fd42017-06-21 09:00:17 -070043 return static_cast<size_t>(FLAG_height);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000044}
45
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020046WEBRTC_DEFINE_int(fps, 30, "Frames per second.");
sprang@webrtc.org131bea82015-02-18 12:46:06 +000047int Fps() {
sprang1168fd42017-06-21 09:00:17 -070048 return static_cast<int>(FLAG_fps);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000049}
50
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020051WEBRTC_DEFINE_int(capture_device_index, 0, "Capture device to select");
Tarun Chawla8e857d12017-05-31 19:20:57 +053052size_t GetCaptureDevice() {
sprang1168fd42017-06-21 09:00:17 -070053 return static_cast<size_t>(FLAG_capture_device_index);
Tarun Chawla8e857d12017-05-31 19:20:57 +053054}
55
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020056WEBRTC_DEFINE_int(min_bitrate, 50, "Call and stream min bitrate in kbps.");
ivica5d6a06c2015-09-17 05:30:24 -070057int MinBitrateKbps() {
sprang1168fd42017-06-21 09:00:17 -070058 return static_cast<int>(FLAG_min_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000059}
60
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020061WEBRTC_DEFINE_int(start_bitrate, 300, "Call start bitrate in kbps.");
ivica5d6a06c2015-09-17 05:30:24 -070062int StartBitrateKbps() {
sprang1168fd42017-06-21 09:00:17 -070063 return static_cast<int>(FLAG_start_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000064}
65
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020066WEBRTC_DEFINE_int(target_bitrate, 800, "Stream target bitrate in kbps.");
ivica5d6a06c2015-09-17 05:30:24 -070067int TargetBitrateKbps() {
sprang1168fd42017-06-21 09:00:17 -070068 return static_cast<int>(FLAG_target_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000069}
70
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020071WEBRTC_DEFINE_int(max_bitrate, 800, "Call and stream max bitrate in kbps.");
ivica5d6a06c2015-09-17 05:30:24 -070072int MaxBitrateKbps() {
sprang1168fd42017-06-21 09:00:17 -070073 return static_cast<int>(FLAG_max_bitrate);
ivica5d6a06c2015-09-17 05:30:24 -070074}
sprang@webrtc.org131bea82015-02-18 12:46:06 +000075
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020076WEBRTC_DEFINE_bool(suspend_below_min_bitrate,
77 false,
78 "Suspends video below the configured min bitrate.");
mflodman48a4beb2016-07-01 13:03:59 +020079
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020080WEBRTC_DEFINE_int(num_temporal_layers,
81 1,
82 "Number of temporal layers. Set to 1-4 to override.");
sprangce4aef12015-11-02 07:23:20 -080083int NumTemporalLayers() {
sprang1168fd42017-06-21 09:00:17 -070084 return static_cast<int>(FLAG_num_temporal_layers);
sprangce4aef12015-11-02 07:23:20 -080085}
86
Mirko Bonadei2dfa9982018-10-18 11:35:32 +020087WEBRTC_DEFINE_int(
88 inter_layer_pred,
89 2,
90 "Inter-layer prediction mode. "
91 "0 - enabled, 1 - disabled, 2 - enabled only for key pictures.");
Sergey Silkin57027362018-05-15 09:12:05 +020092InterLayerPredMode InterLayerPred() {
93 if (FLAG_inter_layer_pred == 0) {
94 return InterLayerPredMode::kOn;
95 } else if (FLAG_inter_layer_pred == 1) {
96 return InterLayerPredMode::kOff;
97 } else {
98 RTC_DCHECK_EQ(FLAG_inter_layer_pred, 2);
99 return InterLayerPredMode::kOnKeyPic;
100 }
101}
102
sprangce4aef12015-11-02 07:23:20 -0800103// Flags common with screenshare loopback, with equal default values.
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200104WEBRTC_DEFINE_string(codec, "VP8", "Video codec to use.");
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000105std::string Codec() {
sprang1168fd42017-06-21 09:00:17 -0700106 return static_cast<std::string>(FLAG_codec);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000107}
108
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200109WEBRTC_DEFINE_int(
110 selected_tl,
111 -1,
112 "Temporal layer to show or analyze. -1 to disable filtering.");
sprangce4aef12015-11-02 07:23:20 -0800113int SelectedTL() {
sprang1168fd42017-06-21 09:00:17 -0700114 return static_cast<int>(FLAG_selected_tl);
sprangce4aef12015-11-02 07:23:20 -0800115}
116
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200117WEBRTC_DEFINE_int(
sprangce4aef12015-11-02 07:23:20 -0800118 duration,
119 0,
120 "Duration of the test in seconds. If 0, rendered will be shown instead.");
121int DurationSecs() {
sprang1168fd42017-06-21 09:00:17 -0700122 return static_cast<int>(FLAG_duration);
sprangce4aef12015-11-02 07:23:20 -0800123}
124
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200125WEBRTC_DEFINE_string(output_filename, "", "Target graph data filename.");
sprangce4aef12015-11-02 07:23:20 -0800126std::string OutputFilename() {
sprang1168fd42017-06-21 09:00:17 -0700127 return static_cast<std::string>(FLAG_output_filename);
sprangce4aef12015-11-02 07:23:20 -0800128}
129
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200130WEBRTC_DEFINE_string(graph_title,
131 "",
132 "If empty, title will be generated automatically.");
sprangce4aef12015-11-02 07:23:20 -0800133std::string GraphTitle() {
sprang1168fd42017-06-21 09:00:17 -0700134 return static_cast<std::string>(FLAG_graph_title);
sprangce4aef12015-11-02 07:23:20 -0800135}
136
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200137WEBRTC_DEFINE_int(loss_percent, 0, "Percentage of packets randomly lost.");
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000138int LossPercent() {
sprang1168fd42017-06-21 09:00:17 -0700139 return static_cast<int>(FLAG_loss_percent);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000140}
141
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200142WEBRTC_DEFINE_int(avg_burst_loss_length,
143 -1,
144 "Average burst length of lost packets.");
philipel536378b2016-05-31 03:20:23 -0700145int AvgBurstLossLength() {
sprang1168fd42017-06-21 09:00:17 -0700146 return static_cast<int>(FLAG_avg_burst_loss_length);
philipel536378b2016-05-31 03:20:23 -0700147}
148
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200149WEBRTC_DEFINE_int(link_capacity,
150 0,
151 "Capacity (kbps) of the fake link. 0 means infinite.");
ivica5d6a06c2015-09-17 05:30:24 -0700152int LinkCapacityKbps() {
sprang1168fd42017-06-21 09:00:17 -0700153 return static_cast<int>(FLAG_link_capacity);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000154}
155
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200156WEBRTC_DEFINE_int(queue_size,
157 0,
158 "Size of the bottleneck link queue in packets.");
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000159int QueueSize() {
sprang1168fd42017-06-21 09:00:17 -0700160 return static_cast<int>(FLAG_queue_size);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000161}
162
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200163WEBRTC_DEFINE_int(avg_propagation_delay_ms,
164 0,
165 "Average link propagation delay in ms.");
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000166int AvgPropagationDelayMs() {
sprang1168fd42017-06-21 09:00:17 -0700167 return static_cast<int>(FLAG_avg_propagation_delay_ms);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000168}
169
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200170WEBRTC_DEFINE_string(rtc_event_log_name,
171 "",
172 "Filename for rtc event log. Two files "
173 "with \"_send\" and \"_recv\" suffixes will be created.");
ilnik98436952017-07-13 00:47:03 -0700174std::string RtcEventLogName() {
175 return static_cast<std::string>(FLAG_rtc_event_log_name);
176}
177
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200178WEBRTC_DEFINE_string(rtp_dump_name,
179 "",
180 "Filename for dumped received RTP stream.");
ilnik98436952017-07-13 00:47:03 -0700181std::string RtpDumpName() {
182 return static_cast<std::string>(FLAG_rtp_dump_name);
183}
184
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200185WEBRTC_DEFINE_int(std_propagation_delay_ms,
186 0,
187 "Link propagation delay standard deviation in ms.");
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000188int StdPropagationDelayMs() {
sprang1168fd42017-06-21 09:00:17 -0700189 return static_cast<int>(FLAG_std_propagation_delay_ms);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000190}
191
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200192WEBRTC_DEFINE_int(num_streams, 0, "Number of streams to show or analyze.");
sprang1168fd42017-06-21 09:00:17 -0700193int NumStreams() {
194 return static_cast<int>(FLAG_num_streams);
195}
196
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200197WEBRTC_DEFINE_int(selected_stream,
198 0,
199 "ID of the stream to show or analyze. "
200 "Set to the number of streams to show them all.");
sprangce4aef12015-11-02 07:23:20 -0800201int SelectedStream() {
sprang1168fd42017-06-21 09:00:17 -0700202 return static_cast<int>(FLAG_selected_stream);
sprangce4aef12015-11-02 07:23:20 -0800203}
204
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200205WEBRTC_DEFINE_int(num_spatial_layers, 1, "Number of spatial layers to use.");
sprangce4aef12015-11-02 07:23:20 -0800206int NumSpatialLayers() {
sprang1168fd42017-06-21 09:00:17 -0700207 return static_cast<int>(FLAG_num_spatial_layers);
sprangce4aef12015-11-02 07:23:20 -0800208}
209
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200210WEBRTC_DEFINE_int(selected_sl,
211 -1,
212 "Spatial layer to show or analyze. -1 to disable filtering.");
sprangce4aef12015-11-02 07:23:20 -0800213int SelectedSL() {
sprang1168fd42017-06-21 09:00:17 -0700214 return static_cast<int>(FLAG_selected_sl);
sprangce4aef12015-11-02 07:23:20 -0800215}
216
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200217WEBRTC_DEFINE_string(
218 stream0,
219 "",
220 "Comma separated values describing VideoStream for stream #0.");
sprangce4aef12015-11-02 07:23:20 -0800221std::string Stream0() {
sprang1168fd42017-06-21 09:00:17 -0700222 return static_cast<std::string>(FLAG_stream0);
sprangce4aef12015-11-02 07:23:20 -0800223}
224
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200225WEBRTC_DEFINE_string(
226 stream1,
227 "",
228 "Comma separated values describing VideoStream for stream #1.");
sprangce4aef12015-11-02 07:23:20 -0800229std::string Stream1() {
sprang1168fd42017-06-21 09:00:17 -0700230 return static_cast<std::string>(FLAG_stream1);
sprangce4aef12015-11-02 07:23:20 -0800231}
232
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200233WEBRTC_DEFINE_string(
234 sl0,
235 "",
236 "Comma separated values describing SpatialLayer for layer #0.");
sprangce4aef12015-11-02 07:23:20 -0800237std::string SL0() {
sprang1168fd42017-06-21 09:00:17 -0700238 return static_cast<std::string>(FLAG_sl0);
sprangce4aef12015-11-02 07:23:20 -0800239}
240
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200241WEBRTC_DEFINE_string(
242 sl1,
243 "",
244 "Comma separated values describing SpatialLayer for layer #1.");
sprangce4aef12015-11-02 07:23:20 -0800245std::string SL1() {
sprang1168fd42017-06-21 09:00:17 -0700246 return static_cast<std::string>(FLAG_sl1);
sprangce4aef12015-11-02 07:23:20 -0800247}
248
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200249WEBRTC_DEFINE_string(
Sergey Silkina89800c2019-02-19 12:52:56 +0100250 sl2,
251 "",
252 "Comma separated values describing SpatialLayer for layer #2.");
253std::string SL2() {
254 return static_cast<std::string>(FLAG_sl2);
255}
256
257WEBRTC_DEFINE_string(
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200258 encoded_frame_path,
259 "",
260 "The base path for encoded frame logs. Created files will have "
261 "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf");
palmkviste75f2042016-09-28 06:19:48 -0700262std::string EncodedFramePath() {
sprang1168fd42017-06-21 09:00:17 -0700263 return static_cast<std::string>(FLAG_encoded_frame_path);
palmkviste75f2042016-09-28 06:19:48 -0700264}
265
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200266WEBRTC_DEFINE_bool(logs, false, "print logs to stderr");
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000267
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200268WEBRTC_DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation");
sprangce4aef12015-11-02 07:23:20 -0800269
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200270WEBRTC_DEFINE_bool(generic_descriptor,
271 false,
272 "Use the generic frame descriptor.");
philipel569397f2018-09-26 12:25:31 +0200273
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200274WEBRTC_DEFINE_bool(allow_reordering, false, "Allow packet reordering to occur");
philipela2c55232016-01-26 08:41:53 -0800275
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200276WEBRTC_DEFINE_bool(use_ulpfec,
277 false,
278 "Use RED+ULPFEC forward error correction.");
brandtra62f5822016-11-17 00:21:13 -0800279
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200280WEBRTC_DEFINE_bool(use_flexfec, false, "Use FlexFEC forward error correction.");
philipel274c1dc2016-05-04 06:21:01 -0700281
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200282WEBRTC_DEFINE_bool(audio, false, "Add audio stream");
minyue73208662016-08-18 06:28:55 -0700283
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200284WEBRTC_DEFINE_bool(
285 use_real_adm,
286 false,
287 "Use real ADM instead of fake (no effect if audio is false)");
henrika255750b2018-08-27 16:13:37 +0200288
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200289WEBRTC_DEFINE_bool(audio_video_sync,
290 false,
291 "Sync audio and video stream (no effect if"
292 " audio is false)");
minyue73208662016-08-18 06:28:55 -0700293
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200294WEBRTC_DEFINE_bool(audio_dtx,
295 false,
296 "Enable audio DTX (no effect if audio is false)");
minyue4c8b9422017-03-21 04:11:43 -0700297
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200298WEBRTC_DEFINE_bool(video, true, "Add video stream");
minyuea27172d2016-11-01 05:59:29 -0700299
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200300WEBRTC_DEFINE_string(
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000301 force_fieldtrials,
302 "",
303 "Field trials control experimental feature code which can be forced. "
Elad Alon1e3ed162018-10-15 17:50:37 +0200304 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enabled/"
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000305 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple "
306 "trials are separated by \"/\"");
pbos9874ee02015-06-22 04:44:26 -0700307
sprangce4aef12015-11-02 07:23:20 -0800308// Video-specific flags.
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200309WEBRTC_DEFINE_string(
310 clip,
311 "",
312 "Name of the clip to show. If empty, using chroma generator.");
ivica5d6a06c2015-09-17 05:30:24 -0700313std::string Clip() {
sprang1168fd42017-06-21 09:00:17 -0700314 return static_cast<std::string>(FLAG_clip);
ivica5d6a06c2015-09-17 05:30:24 -0700315}
316
Mirko Bonadei2dfa9982018-10-18 11:35:32 +0200317WEBRTC_DEFINE_bool(help, false, "prints this message");
sprang1168fd42017-06-21 09:00:17 -0700318
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000319} // namespace flags
320
321void Loopback() {
Artem Titov75e36472018-10-08 12:28:56 +0200322 BuiltInNetworkBehaviorConfig pipe_config;
ivica5d6a06c2015-09-17 05:30:24 -0700323 pipe_config.loss_percent = flags::LossPercent();
philipel536378b2016-05-31 03:20:23 -0700324 pipe_config.avg_burst_loss_length = flags::AvgBurstLossLength();
ivica5d6a06c2015-09-17 05:30:24 -0700325 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps();
326 pipe_config.queue_length_packets = flags::QueueSize();
327 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs();
328 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs();
sprang1168fd42017-06-21 09:00:17 -0700329 pipe_config.allow_reordering = flags::FLAG_allow_reordering;
ivica5d6a06c2015-09-17 05:30:24 -0700330
Sebastian Janssonfc8d26b2018-02-21 09:52:06 +0100331 BitrateConstraints call_bitrate_config;
ivica5d6a06c2015-09-17 05:30:24 -0700332 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000;
333 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000;
Erik Språng28bb3912018-07-11 16:06:55 +0200334 call_bitrate_config.max_bitrate_bps = -1; // Don't cap bandwidth estimate.
ivica5d6a06c2015-09-17 05:30:24 -0700335
minyue73208662016-08-18 06:28:55 -0700336 VideoQualityTest::Params params;
philipel569397f2018-09-26 12:25:31 +0200337 params.call = {flags::FLAG_send_side_bwe, flags::FLAG_generic_descriptor,
338 call_bitrate_config, 0};
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100339 params.video[0] = {flags::FLAG_video,
340 flags::Width(),
341 flags::Height(),
342 flags::Fps(),
343 flags::MinBitrateKbps() * 1000,
344 flags::TargetBitrateKbps() * 1000,
345 flags::MaxBitrateKbps() * 1000,
346 flags::FLAG_suspend_below_min_bitrate,
347 flags::Codec(),
348 flags::NumTemporalLayers(),
349 flags::SelectedTL(),
350 0, // No min transmit bitrate.
351 flags::FLAG_use_ulpfec,
352 flags::FLAG_use_flexfec,
philipel5affbf22019-01-24 15:49:40 +0100353 flags::NumStreams() < 2, // Automatic quality scaling.
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100354 flags::Clip(),
355 flags::GetCaptureDevice()};
sprang1168fd42017-06-21 09:00:17 -0700356 params.audio = {flags::FLAG_audio, flags::FLAG_audio_video_sync,
henrika255750b2018-08-27 16:13:37 +0200357 flags::FLAG_audio_dtx, flags::FLAG_use_real_adm};
Mirko Bonadei45a4c412018-07-31 15:07:28 +0200358 params.logging = {flags::FLAG_rtc_event_log_name, flags::FLAG_rtp_dump_name,
359 flags::FLAG_encoded_frame_path};
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100360 params.screenshare[0].enabled = false;
Yves Gerey665174f2018-06-19 15:03:05 +0200361 params.analyzer = {"video",
362 0.0,
363 0.0,
364 flags::DurationSecs(),
365 flags::OutputFilename(),
366 flags::GraphTitle()};
Artem Titovf18b3522018-08-28 16:54:24 +0200367 params.config = pipe_config;
sprang1168fd42017-06-21 09:00:17 -0700368
369 if (flags::NumStreams() > 1 && flags::Stream0().empty() &&
370 flags::Stream1().empty()) {
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100371 params.ss[0].infer_streams = true;
sprang1168fd42017-06-21 09:00:17 -0700372 }
ivica5d6a06c2015-09-17 05:30:24 -0700373
sprangce4aef12015-11-02 07:23:20 -0800374 std::vector<std::string> stream_descriptors;
375 stream_descriptors.push_back(flags::Stream0());
376 stream_descriptors.push_back(flags::Stream1());
377 std::vector<std::string> SL_descriptors;
378 SL_descriptors.push_back(flags::SL0());
379 SL_descriptors.push_back(flags::SL1());
Sergey Silkina89800c2019-02-19 12:52:56 +0100380 SL_descriptors.push_back(flags::SL2());
sprangce4aef12015-11-02 07:23:20 -0800381 VideoQualityTest::FillScalabilitySettings(
Ilya Nikolaevskiy255d1cd2017-12-21 18:02:59 +0100382 &params, 0, stream_descriptors, flags::NumStreams(),
383 flags::SelectedStream(), flags::NumSpatialLayers(), flags::SelectedSL(),
Sergey Silkin57027362018-05-15 09:12:05 +0200384 flags::InterLayerPred(), SL_descriptors);
sprangce4aef12015-11-02 07:23:20 -0800385
Karl Wiberg918f50c2018-07-05 11:40:33 +0200386 auto fixture = absl::make_unique<VideoQualityTest>(nullptr);
sprangce4aef12015-11-02 07:23:20 -0800387 if (flags::DurationSecs()) {
Patrik Höglundb6b29e02018-06-21 16:58:01 +0200388 fixture->RunWithAnalyzer(params);
sprangce4aef12015-11-02 07:23:20 -0800389 } else {
Patrik Höglundb6b29e02018-06-21 16:58:01 +0200390 fixture->RunWithRenderers(params);
sprangce4aef12015-11-02 07:23:20 -0800391 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000392}
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000393
Kári Tristan Helgasonede7cb22019-03-06 10:34:09 +0100394int RunLoopbackTest(int argc, char* argv[]) {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000395 ::testing::InitGoogleTest(&argc, argv);
sprang1168fd42017-06-21 09:00:17 -0700396 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
397 if (webrtc::flags::FLAG_help) {
398 rtc::FlagList::Print(nullptr, false);
399 return 0;
400 }
401
Mirko Bonadei45a4c412018-07-31 15:07:28 +0200402 rtc::LogMessage::SetLogToStderr(webrtc::flags::FLAG_logs);
403
Bjorn Tereliusedab3012018-01-31 17:23:40 +0100404 webrtc::test::ValidateFieldTrialsStringOrDie(
405 webrtc::flags::FLAG_force_fieldtrials);
406 // InitFieldTrialsFromString stores the char*, so the char array must outlive
407 // the application.
408 webrtc::field_trial::InitFieldTrialsFromString(
409 webrtc::flags::FLAG_force_fieldtrials);
sprang89c4a7e2017-06-30 13:27:40 -0700410
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000411 webrtc::test::RunTest(webrtc::Loopback);
412 return 0;
413}
Kári Tristan Helgasonede7cb22019-03-06 10:34:09 +0100414} // namespace webrtc