• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include <stdio.h>
12 
13 #include <memory>
14 #include <string>
15 #include <vector>
16 
17 #include "absl/flags/flag.h"
18 #include "absl/flags/parse.h"
19 #include "absl/types/optional.h"
20 #include "api/test/simulated_network.h"
21 #include "api/test/video_quality_test_fixture.h"
22 #include "api/transport/bitrate_settings.h"
23 #include "api/video_codecs/video_codec.h"
24 #include "rtc_base/checks.h"
25 #include "rtc_base/logging.h"
26 #include "rtc_base/string_encode.h"
27 #include "system_wrappers/include/field_trial.h"
28 #include "test/field_trial.h"
29 #include "test/gtest.h"
30 #include "test/run_test.h"
31 #include "video/video_quality_test.h"
32 
33 // Flags for video.
34 ABSL_FLAG(int, vwidth, 640, "Video width.");
35 
36 ABSL_FLAG(int, vheight, 480, "Video height.");
37 
38 ABSL_FLAG(int, vfps, 30, "Video frames per second.");
39 
40 ABSL_FLAG(int,
41           capture_device_index,
42           0,
43           "Capture device to select for video stream");
44 
45 ABSL_FLAG(int, vtarget_bitrate, 400, "Video stream target bitrate in kbps.");
46 
47 ABSL_FLAG(int, vmin_bitrate, 100, "Video stream min bitrate in kbps.");
48 
49 ABSL_FLAG(int, vmax_bitrate, 2000, "Video stream max bitrate in kbps.");
50 
51 ABSL_FLAG(bool,
52           suspend_below_min_bitrate,
53           false,
54           "Suspends video below the configured min bitrate.");
55 
56 ABSL_FLAG(int,
57           vnum_temporal_layers,
58           1,
59           "Number of temporal layers for video. Set to 1-4 to override.");
60 
61 ABSL_FLAG(int, vnum_streams, 0, "Number of video streams to show or analyze.");
62 
63 ABSL_FLAG(int,
64           vnum_spatial_layers,
65           1,
66           "Number of video spatial layers to use.");
67 
68 ABSL_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 
74 ABSL_FLAG(std::string,
75           vstream0,
76           "",
77           "Comma separated values describing VideoStream for video stream #0.");
78 
79 ABSL_FLAG(std::string,
80           vstream1,
81           "",
82           "Comma separated values describing VideoStream for video stream #1.");
83 
84 ABSL_FLAG(std::string,
85           vsl0,
86           "",
87           "Comma separated values describing SpatialLayer for video layer #0.");
88 
89 ABSL_FLAG(std::string,
90           vsl1,
91           "",
92           "Comma separated values describing SpatialLayer for video layer #1.");
93 
94 ABSL_FLAG(int,
95           vselected_tl,
96           -1,
97           "Temporal layer to show or analyze for screenshare. -1 to disable "
98           "filtering.");
99 
100 ABSL_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 
106 ABSL_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.
113 ABSL_FLAG(int,
114           min_transmit_bitrate,
115           400,
116           "Min transmit bitrate incl. padding for screenshare.");
117 
118 ABSL_FLAG(int, swidth, 1850, "Screenshare width (crops source).");
119 
120 ABSL_FLAG(int, sheight, 1110, "Screenshare height (crops source).");
121 
122 ABSL_FLAG(int, sfps, 5, "Frames per second for screenshare.");
123 
124 ABSL_FLAG(int,
125           starget_bitrate,
126           100,
127           "Screenshare stream target bitrate in kbps.");
128 
129 ABSL_FLAG(int, smin_bitrate, 100, "Screenshare stream min bitrate in kbps.");
130 
131 ABSL_FLAG(int, smax_bitrate, 2000, "Screenshare stream max bitrate in kbps.");
132 
133 ABSL_FLAG(int,
134           snum_temporal_layers,
135           2,
136           "Number of temporal layers to use in screenshare.");
137 
138 ABSL_FLAG(int,
139           snum_streams,
140           0,
141           "Number of screenshare streams to show or analyze.");
142 
143 ABSL_FLAG(int,
144           snum_spatial_layers,
145           1,
146           "Number of screenshare spatial layers to use.");
147 
148 ABSL_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 
154 ABSL_FLAG(
155     std::string,
156     sstream0,
157     "",
158     "Comma separated values describing VideoStream for screenshare stream #0.");
159 
160 ABSL_FLAG(
161     std::string,
162     sstream1,
163     "",
164     "Comma separated values describing VideoStream for screenshare stream #1.");
165 
166 ABSL_FLAG(
167     std::string,
168     ssl0,
169     "",
170     "Comma separated values describing SpatialLayer for screenshare layer #0.");
171 
172 ABSL_FLAG(
173     std::string,
174     ssl1,
175     "",
176     "Comma separated values describing SpatialLayer for screenshare layer #1.");
177 
178 ABSL_FLAG(int,
179           sselected_tl,
180           -1,
181           "Temporal layer to show or analyze for screenshare. -1 to disable "
182           "filtering.");
183 
184 ABSL_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 
190 ABSL_FLAG(int,
191           sselected_sl,
192           -1,
193           "Spatial layer to show or analyze for screenshare. -1 to disable "
194           "filtering.");
195 
196 ABSL_FLAG(bool,
197           generate_slides,
198           false,
199           "Whether to use randomly generated slides or read them from files.");
200 
201 ABSL_FLAG(int,
202           slide_change_interval,
203           10,
204           "Interval (in seconds) between simulated slide changes.");
205 
206 ABSL_FLAG(
207     int,
208     scroll_duration,
209     0,
210     "Duration (in seconds) during which a slide will be scrolled into place.");
211 
212 ABSL_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.
218 ABSL_FLAG(int, start_bitrate, 600, "Call start bitrate in kbps.");
219 
220 ABSL_FLAG(std::string, codec, "VP8", "Video codec to use.");
221 
222 ABSL_FLAG(bool,
223           analyze_video,
224           false,
225           "Analyze video stream (if --duration is present)");
226 
227 ABSL_FLAG(bool,
228           analyze_screenshare,
229           false,
230           "Analyze screenshare stream (if --duration is present)");
231 
232 ABSL_FLAG(
233     int,
234     duration,
235     0,
236     "Duration of the test in seconds. If 0, rendered will be shown instead.");
237 
238 ABSL_FLAG(std::string, output_filename, "", "Target graph data filename.");
239 
240 ABSL_FLAG(std::string,
241           graph_title,
242           "",
243           "If empty, title will be generated automatically.");
244 
245 ABSL_FLAG(int, loss_percent, 0, "Percentage of packets randomly lost.");
246 
247 ABSL_FLAG(int,
248           avg_burst_loss_length,
249           -1,
250           "Average burst length of lost packets.");
251 
252 ABSL_FLAG(int,
253           link_capacity,
254           0,
255           "Capacity (kbps) of the fake link. 0 means infinite.");
256 
257 ABSL_FLAG(int, queue_size, 0, "Size of the bottleneck link queue in packets.");
258 
259 ABSL_FLAG(int,
260           avg_propagation_delay_ms,
261           0,
262           "Average link propagation delay in ms.");
263 
264 ABSL_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 
271 ABSL_FLAG(std::string,
272           rtp_dump_name,
273           "",
274           "Filename for dumped received RTP stream.");
275 
276 ABSL_FLAG(int,
277           std_propagation_delay_ms,
278           0,
279           "Link propagation delay standard deviation in ms.");
280 
281 ABSL_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 
287 ABSL_FLAG(bool, logs, false, "print logs to stderr");
288 
289 ABSL_FLAG(bool, send_side_bwe, true, "Use send-side bandwidth estimation");
290 
291 ABSL_FLAG(bool, generic_descriptor, false, "Use the generic frame descriptor.");
292 
293 ABSL_FLAG(bool, allow_reordering, false, "Allow packet reordering to occur");
294 
295 ABSL_FLAG(bool, use_ulpfec, false, "Use RED+ULPFEC forward error correction.");
296 
297 ABSL_FLAG(bool, use_flexfec, false, "Use FlexFEC forward error correction.");
298 
299 ABSL_FLAG(bool, audio, false, "Add audio stream");
300 
301 ABSL_FLAG(bool,
302           audio_video_sync,
303           false,
304           "Sync audio and video stream (no effect if"
305           " audio is false)");
306 
307 ABSL_FLAG(bool,
308           audio_dtx,
309           false,
310           "Enable audio DTX (no effect if audio is false)");
311 
312 ABSL_FLAG(bool, video, true, "Add video stream");
313 
314 ABSL_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.
324 ABSL_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 
330 namespace webrtc {
331 namespace {
332 
IntToInterLayerPredMode(int inter_layer_pred)333 InterLayerPredMode 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 
VideoWidth()344 size_t VideoWidth() {
345   return static_cast<size_t>(absl::GetFlag(FLAGS_vwidth));
346 }
347 
VideoHeight()348 size_t VideoHeight() {
349   return static_cast<size_t>(absl::GetFlag(FLAGS_vheight));
350 }
351 
VideoFps()352 int VideoFps() {
353   return absl::GetFlag(FLAGS_vfps);
354 }
355 
GetCaptureDevice()356 size_t GetCaptureDevice() {
357   return static_cast<size_t>(absl::GetFlag(FLAGS_capture_device_index));
358 }
359 
VideoTargetBitrateKbps()360 int VideoTargetBitrateKbps() {
361   return absl::GetFlag(FLAGS_vtarget_bitrate);
362 }
363 
VideoMinBitrateKbps()364 int VideoMinBitrateKbps() {
365   return absl::GetFlag(FLAGS_vmin_bitrate);
366 }
367 
VideoMaxBitrateKbps()368 int VideoMaxBitrateKbps() {
369   return absl::GetFlag(FLAGS_vmax_bitrate);
370 }
371 
VideoNumTemporalLayers()372 int VideoNumTemporalLayers() {
373   return absl::GetFlag(FLAGS_vnum_temporal_layers);
374 }
375 
VideoNumStreams()376 int VideoNumStreams() {
377   return absl::GetFlag(FLAGS_vnum_streams);
378 }
379 
VideoNumSpatialLayers()380 int VideoNumSpatialLayers() {
381   return absl::GetFlag(FLAGS_vnum_spatial_layers);
382 }
383 
VideoInterLayerPred()384 InterLayerPredMode VideoInterLayerPred() {
385   return IntToInterLayerPredMode(absl::GetFlag(FLAGS_vinter_layer_pred));
386 }
387 
VideoStream0()388 std::string VideoStream0() {
389   return absl::GetFlag(FLAGS_vstream0);
390 }
391 
VideoStream1()392 std::string VideoStream1() {
393   return absl::GetFlag(FLAGS_vstream1);
394 }
395 
VideoSL0()396 std::string VideoSL0() {
397   return absl::GetFlag(FLAGS_vsl0);
398 }
399 
VideoSL1()400 std::string VideoSL1() {
401   return absl::GetFlag(FLAGS_vsl1);
402 }
403 
VideoSelectedTL()404 int VideoSelectedTL() {
405   return absl::GetFlag(FLAGS_vselected_tl);
406 }
407 
VideoSelectedStream()408 int VideoSelectedStream() {
409   return absl::GetFlag(FLAGS_vselected_stream);
410 }
411 
VideoSelectedSL()412 int VideoSelectedSL() {
413   return absl::GetFlag(FLAGS_vselected_sl);
414 }
415 
ScreenshareMinTransmitBitrateKbps()416 int ScreenshareMinTransmitBitrateKbps() {
417   return absl::GetFlag(FLAGS_min_transmit_bitrate);
418 }
419 
ScreenshareWidth()420 size_t ScreenshareWidth() {
421   return static_cast<size_t>(absl::GetFlag(FLAGS_swidth));
422 }
423 
ScreenshareHeight()424 size_t ScreenshareHeight() {
425   return static_cast<size_t>(absl::GetFlag(FLAGS_sheight));
426 }
427 
ScreenshareFps()428 int ScreenshareFps() {
429   return absl::GetFlag(FLAGS_sfps);
430 }
431 
ScreenshareTargetBitrateKbps()432 int ScreenshareTargetBitrateKbps() {
433   return absl::GetFlag(FLAGS_starget_bitrate);
434 }
435 
ScreenshareMinBitrateKbps()436 int ScreenshareMinBitrateKbps() {
437   return absl::GetFlag(FLAGS_smin_bitrate);
438 }
439 
ScreenshareMaxBitrateKbps()440 int ScreenshareMaxBitrateKbps() {
441   return absl::GetFlag(FLAGS_smax_bitrate);
442 }
443 
ScreenshareNumTemporalLayers()444 int ScreenshareNumTemporalLayers() {
445   return absl::GetFlag(FLAGS_snum_temporal_layers);
446 }
447 
ScreenshareNumStreams()448 int ScreenshareNumStreams() {
449   return absl::GetFlag(FLAGS_snum_streams);
450 }
451 
ScreenshareNumSpatialLayers()452 int ScreenshareNumSpatialLayers() {
453   return absl::GetFlag(FLAGS_snum_spatial_layers);
454 }
455 
ScreenshareInterLayerPred()456 InterLayerPredMode ScreenshareInterLayerPred() {
457   return IntToInterLayerPredMode(absl::GetFlag(FLAGS_sinter_layer_pred));
458 }
459 
ScreenshareStream0()460 std::string ScreenshareStream0() {
461   return absl::GetFlag(FLAGS_sstream0);
462 }
463 
ScreenshareStream1()464 std::string ScreenshareStream1() {
465   return absl::GetFlag(FLAGS_sstream1);
466 }
467 
ScreenshareSL0()468 std::string ScreenshareSL0() {
469   return absl::GetFlag(FLAGS_ssl0);
470 }
471 
ScreenshareSL1()472 std::string ScreenshareSL1() {
473   return absl::GetFlag(FLAGS_ssl1);
474 }
475 
ScreenshareSelectedTL()476 int ScreenshareSelectedTL() {
477   return absl::GetFlag(FLAGS_sselected_tl);
478 }
479 
ScreenshareSelectedStream()480 int ScreenshareSelectedStream() {
481   return absl::GetFlag(FLAGS_sselected_stream);
482 }
483 
ScreenshareSelectedSL()484 int ScreenshareSelectedSL() {
485   return absl::GetFlag(FLAGS_sselected_sl);
486 }
487 
GenerateSlides()488 bool GenerateSlides() {
489   return absl::GetFlag(FLAGS_generate_slides);
490 }
491 
SlideChangeInterval()492 int SlideChangeInterval() {
493   return absl::GetFlag(FLAGS_slide_change_interval);
494 }
495 
ScrollDuration()496 int ScrollDuration() {
497   return absl::GetFlag(FLAGS_scroll_duration);
498 }
499 
Slides()500 std::vector<std::string> Slides() {
501   std::vector<std::string> slides;
502   std::string slides_list = absl::GetFlag(FLAGS_slides);
503   rtc::tokenize(slides_list, ',', &slides);
504   return slides;
505 }
506 
StartBitrateKbps()507 int StartBitrateKbps() {
508   return absl::GetFlag(FLAGS_start_bitrate);
509 }
510 
Codec()511 std::string Codec() {
512   return absl::GetFlag(FLAGS_codec);
513 }
514 
AnalyzeVideo()515 bool AnalyzeVideo() {
516   return absl::GetFlag(FLAGS_analyze_video);
517 }
518 
AnalyzeScreenshare()519 bool AnalyzeScreenshare() {
520   return absl::GetFlag(FLAGS_analyze_screenshare);
521 }
522 
DurationSecs()523 int DurationSecs() {
524   return absl::GetFlag(FLAGS_duration);
525 }
526 
OutputFilename()527 std::string OutputFilename() {
528   return absl::GetFlag(FLAGS_output_filename);
529 }
530 
GraphTitle()531 std::string GraphTitle() {
532   return absl::GetFlag(FLAGS_graph_title);
533 }
534 
LossPercent()535 int LossPercent() {
536   return absl::GetFlag(FLAGS_loss_percent);
537 }
538 
AvgBurstLossLength()539 int AvgBurstLossLength() {
540   return absl::GetFlag(FLAGS_avg_burst_loss_length);
541 }
542 
LinkCapacityKbps()543 int LinkCapacityKbps() {
544   return absl::GetFlag(FLAGS_link_capacity);
545 }
546 
QueueSize()547 int QueueSize() {
548   return absl::GetFlag(FLAGS_queue_size);
549 }
550 
AvgPropagationDelayMs()551 int AvgPropagationDelayMs() {
552   return absl::GetFlag(FLAGS_avg_propagation_delay_ms);
553 }
554 
RtcEventLogName()555 std::string RtcEventLogName() {
556   return absl::GetFlag(FLAGS_rtc_event_log_name);
557 }
558 
RtpDumpName()559 std::string RtpDumpName() {
560   return absl::GetFlag(FLAGS_rtp_dump_name);
561 }
562 
StdPropagationDelayMs()563 int StdPropagationDelayMs() {
564   return absl::GetFlag(FLAGS_std_propagation_delay_ms);
565 }
566 
EncodedFramePath()567 std::string EncodedFramePath() {
568   return absl::GetFlag(FLAGS_encoded_frame_path);
569 }
570 
VideoClip()571 std::string VideoClip() {
572   return absl::GetFlag(FLAGS_vclip);
573 }
574 
575 }  // namespace
576 
Loopback()577 void Loopback() {
578   int camera_idx, screenshare_idx;
579   RTC_CHECK(!(AnalyzeScreenshare() && AnalyzeVideo()))
580       << "Select only one of video or screenshare.";
581   RTC_CHECK(!DurationSecs() || AnalyzeScreenshare() || AnalyzeVideo())
582       << "If duration is set, exactly one of analyze_* flags should be set.";
583   // Default: camera feed first, if nothing selected.
584   if (AnalyzeVideo() || !AnalyzeScreenshare()) {
585     camera_idx = 0;
586     screenshare_idx = 1;
587   } else {
588     camera_idx = 1;
589     screenshare_idx = 0;
590   }
591 
592   BuiltInNetworkBehaviorConfig pipe_config;
593   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);
600 
601   BitrateConstraints call_bitrate_config;
602   call_bitrate_config.min_bitrate_bps =
603       (ScreenshareMinBitrateKbps() + VideoMinBitrateKbps()) * 1000;
604   call_bitrate_config.start_bitrate_bps = StartBitrateKbps() * 1000;
605   call_bitrate_config.max_bitrate_bps =
606       (ScreenshareMaxBitrateKbps() + VideoMaxBitrateKbps()) * 1000;
607 
608   VideoQualityTest::Params params;
609   params.call.send_side_bwe = absl::GetFlag(FLAGS_send_side_bwe);
610   params.call.generic_descriptor = absl::GetFlag(FLAGS_generic_descriptor);
611   params.call.call_bitrate_config = call_bitrate_config;
612   params.call.dual_video = true;
613   params.video[screenshare_idx].enabled = true;
614   params.video[screenshare_idx].width = ScreenshareWidth();
615   params.video[screenshare_idx].height = ScreenshareHeight();
616   params.video[screenshare_idx].fps = ScreenshareFps();
617   params.video[screenshare_idx].min_bitrate_bps =
618       ScreenshareMinBitrateKbps() * 1000;
619   params.video[screenshare_idx].target_bitrate_bps =
620       ScreenshareTargetBitrateKbps() * 1000;
621   params.video[screenshare_idx].max_bitrate_bps =
622       ScreenshareMaxBitrateKbps() * 1000;
623   params.video[screenshare_idx].codec = Codec();
624   params.video[screenshare_idx].num_temporal_layers =
625       ScreenshareNumTemporalLayers();
626   params.video[screenshare_idx].selected_tl = ScreenshareSelectedTL();
627   params.video[screenshare_idx].min_transmit_bps =
628       ScreenshareMinTransmitBitrateKbps() * 1000;
629   params.video[camera_idx].enabled = absl::GetFlag(FLAGS_video);
630   params.video[camera_idx].width = VideoWidth();
631   params.video[camera_idx].height = VideoHeight();
632   params.video[camera_idx].fps = VideoFps();
633   params.video[camera_idx].min_bitrate_bps = VideoMinBitrateKbps() * 1000;
634   params.video[camera_idx].target_bitrate_bps = VideoTargetBitrateKbps() * 1000;
635   params.video[camera_idx].max_bitrate_bps = VideoMaxBitrateKbps() * 1000;
636   params.video[camera_idx].suspend_below_min_bitrate =
637       absl::GetFlag(FLAGS_suspend_below_min_bitrate);
638   params.video[camera_idx].codec = Codec();
639   params.video[camera_idx].num_temporal_layers = VideoNumTemporalLayers();
640   params.video[camera_idx].selected_tl = VideoSelectedTL();
641   params.video[camera_idx].ulpfec = absl::GetFlag(FLAGS_use_ulpfec);
642   params.video[camera_idx].flexfec = absl::GetFlag(FLAGS_use_flexfec);
643   params.video[camera_idx].clip_path = VideoClip();
644   params.video[camera_idx].capture_device_index = GetCaptureDevice();
645   params.audio.enabled = absl::GetFlag(FLAGS_audio);
646   params.audio.sync_video = absl::GetFlag(FLAGS_audio_video_sync);
647   params.audio.dtx = absl::GetFlag(FLAGS_audio_dtx);
648   params.logging.rtc_event_log_name = RtcEventLogName();
649   params.logging.rtp_dump_name = RtpDumpName();
650   params.logging.encoded_frame_base_path = EncodedFramePath();
651   params.analyzer.test_label = "dual_streams";
652   params.analyzer.test_durations_secs = DurationSecs();
653   params.analyzer.graph_data_output_filename = OutputFilename();
654   params.analyzer.graph_title = GraphTitle();
655   params.config = pipe_config;
656 
657   params.screenshare[camera_idx].enabled = false;
658   params.screenshare[screenshare_idx].enabled = true;
659   params.screenshare[screenshare_idx].generate_slides = GenerateSlides();
660   params.screenshare[screenshare_idx].slide_change_interval =
661       SlideChangeInterval();
662   params.screenshare[screenshare_idx].scroll_duration = ScrollDuration();
663   params.screenshare[screenshare_idx].slides = Slides();
664 
665   if (VideoNumStreams() > 1 && VideoStream0().empty() &&
666       VideoStream1().empty()) {
667     params.ss[camera_idx].infer_streams = true;
668   }
669 
670   if (ScreenshareNumStreams() > 1 && ScreenshareStream0().empty() &&
671       ScreenshareStream1().empty()) {
672     params.ss[screenshare_idx].infer_streams = true;
673   }
674 
675   std::vector<std::string> stream_descriptors;
676   stream_descriptors.push_back(ScreenshareStream0());
677   stream_descriptors.push_back(ScreenshareStream1());
678   std::vector<std::string> SL_descriptors;
679   SL_descriptors.push_back(ScreenshareSL0());
680   SL_descriptors.push_back(ScreenshareSL1());
681   VideoQualityTest::FillScalabilitySettings(
682       &params, screenshare_idx, stream_descriptors, ScreenshareNumStreams(),
683       ScreenshareSelectedStream(), ScreenshareNumSpatialLayers(),
684       ScreenshareSelectedSL(), ScreenshareInterLayerPred(), SL_descriptors);
685 
686   stream_descriptors.clear();
687   stream_descriptors.push_back(VideoStream0());
688   stream_descriptors.push_back(VideoStream1());
689   SL_descriptors.clear();
690   SL_descriptors.push_back(VideoSL0());
691   SL_descriptors.push_back(VideoSL1());
692   VideoQualityTest::FillScalabilitySettings(
693       &params, camera_idx, stream_descriptors, VideoNumStreams(),
694       VideoSelectedStream(), VideoNumSpatialLayers(), VideoSelectedSL(),
695       VideoInterLayerPred(), SL_descriptors);
696 
697   auto fixture = std::make_unique<VideoQualityTest>(nullptr);
698   if (DurationSecs()) {
699     fixture->RunWithAnalyzer(params);
700   } else {
701     fixture->RunWithRenderers(params);
702   }
703 }
704 }  // namespace webrtc
705 
main(int argc,char * argv[])706 int main(int argc, char* argv[]) {
707   ::testing::InitGoogleTest(&argc, argv);
708   absl::ParseCommandLine(argc, argv);
709 
710   rtc::LogMessage::SetLogToStderr(absl::GetFlag(FLAGS_logs));
711 
712   // InitFieldTrialsFromString stores the char*, so the char array must outlive
713   // the application.
714   const std::string field_trials = absl::GetFlag(FLAGS_force_fieldtrials);
715   webrtc::field_trial::InitFieldTrialsFromString(field_trials.c_str());
716 
717   webrtc::test::RunTest(webrtc::Loopback);
718   return 0;
719 }
720