sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 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 | */ |
Kári Tristan Helgason | ede7cb2 | 2019-03-06 10:34:09 +0100 | [diff] [blame] | 10 | #include "video/video_loopback.h" |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 11 | |
| 12 | #include <stdio.h> |
Jonas Olsson | 5b2eda4 | 2019-06-11 14:29:40 +0200 | [diff] [blame] | 13 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 14 | #include <memory> |
| 15 | #include <string> |
| 16 | #include <vector> |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 17 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 18 | #include "absl/flags/flag.h" |
| 19 | #include "absl/flags/parse.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 20 | #include "absl/types/optional.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 21 | #include "api/test/simulated_network.h" |
| 22 | #include "api/test/video_quality_test_fixture.h" |
Mirko Bonadei | 738bfa7 | 2019-09-17 14:47:38 +0200 | [diff] [blame] | 23 | #include "api/transport/bitrate_settings.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 24 | #include "api/video_codecs/video_codec.h" |
| 25 | #include "rtc_base/checks.h" |
Mirko Bonadei | 45a4c41 | 2018-07-31 15:07:28 +0200 | [diff] [blame] | 26 | #include "rtc_base/logging.h" |
Mirko Bonadei | 17f4878 | 2018-09-28 08:51:10 +0200 | [diff] [blame] | 27 | #include "system_wrappers/include/field_trial.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 28 | #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.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 32 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 33 | // Flags common with screenshare loopback, with different default values. |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 34 | ABSL_FLAG(int, width, 640, "Video width."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 35 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 36 | ABSL_FLAG(int, height, 480, "Video height."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 37 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 38 | ABSL_FLAG(int, fps, 30, "Frames per second."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 39 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 40 | ABSL_FLAG(int, capture_device_index, 0, "Capture device to select"); |
Tarun Chawla | 8e857d1 | 2017-05-31 19:20:57 +0530 | [diff] [blame] | 41 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 42 | ABSL_FLAG(int, min_bitrate, 50, "Call and stream min bitrate in kbps."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 43 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 44 | ABSL_FLAG(int, start_bitrate, 300, "Call start bitrate in kbps."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 45 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 46 | ABSL_FLAG(int, target_bitrate, 800, "Stream target bitrate in kbps."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 47 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 48 | ABSL_FLAG(int, max_bitrate, 800, "Call and stream max bitrate in kbps."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 49 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 50 | ABSL_FLAG(bool, |
| 51 | suspend_below_min_bitrate, |
| 52 | false, |
| 53 | "Suspends video below the configured min bitrate."); |
mflodman | 48a4beb | 2016-07-01 13:03:59 +0200 | [diff] [blame] | 54 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 55 | ABSL_FLAG(int, |
| 56 | num_temporal_layers, |
| 57 | 1, |
| 58 | "Number of temporal layers. Set to 1-4 to override."); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 59 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 60 | ABSL_FLAG(int, |
| 61 | inter_layer_pred, |
| 62 | 2, |
| 63 | "Inter-layer prediction mode. " |
| 64 | "0 - enabled, 1 - disabled, 2 - enabled only for key pictures."); |
Sergey Silkin | 5702736 | 2018-05-15 09:12:05 +0200 | [diff] [blame] | 65 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 66 | // Flags common with screenshare loopback, with equal default values. |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 67 | ABSL_FLAG(std::string, codec, "VP8", "Video codec to use."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 68 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 69 | ABSL_FLAG(int, |
| 70 | selected_tl, |
| 71 | -1, |
| 72 | "Temporal layer to show or analyze. -1 to disable filtering."); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 73 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 74 | ABSL_FLAG( |
| 75 | int, |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 76 | duration, |
| 77 | 0, |
| 78 | "Duration of the test in seconds. If 0, rendered will be shown instead."); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 79 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 80 | ABSL_FLAG(std::string, output_filename, "", "Target graph data filename."); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 81 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 82 | ABSL_FLAG(std::string, |
| 83 | graph_title, |
| 84 | "", |
| 85 | "If empty, title will be generated automatically."); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 86 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 87 | ABSL_FLAG(int, loss_percent, 0, "Percentage of packets randomly lost."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 88 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 89 | ABSL_FLAG(int, |
| 90 | avg_burst_loss_length, |
| 91 | -1, |
| 92 | "Average burst length of lost packets."); |
philipel | 536378b | 2016-05-31 03:20:23 -0700 | [diff] [blame] | 93 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 94 | ABSL_FLAG(int, |
| 95 | link_capacity, |
| 96 | 0, |
| 97 | "Capacity (kbps) of the fake link. 0 means infinite."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 98 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 99 | ABSL_FLAG(int, queue_size, 0, "Size of the bottleneck link queue in packets."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 100 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 101 | ABSL_FLAG(int, |
| 102 | avg_propagation_delay_ms, |
| 103 | 0, |
| 104 | "Average link propagation delay in ms."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 105 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 106 | ABSL_FLAG(std::string, |
| 107 | rtc_event_log_name, |
| 108 | "", |
| 109 | "Filename for rtc event log. Two files " |
| 110 | "with \"_send\" and \"_recv\" suffixes will be created."); |
ilnik | 9843695 | 2017-07-13 00:47:03 -0700 | [diff] [blame] | 111 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 112 | ABSL_FLAG(std::string, |
| 113 | rtp_dump_name, |
| 114 | "", |
| 115 | "Filename for dumped received RTP stream."); |
ilnik | 9843695 | 2017-07-13 00:47:03 -0700 | [diff] [blame] | 116 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 117 | ABSL_FLAG(int, |
| 118 | std_propagation_delay_ms, |
| 119 | 0, |
| 120 | "Link propagation delay standard deviation in ms."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 121 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 122 | ABSL_FLAG(int, num_streams, 0, "Number of streams to show or analyze."); |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 123 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 124 | ABSL_FLAG(int, |
| 125 | selected_stream, |
| 126 | 0, |
| 127 | "ID of the stream to show or analyze. " |
| 128 | "Set to the number of streams to show them all."); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 129 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 130 | ABSL_FLAG(int, num_spatial_layers, 1, "Number of spatial layers to use."); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 131 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 132 | ABSL_FLAG(int, |
| 133 | selected_sl, |
| 134 | -1, |
| 135 | "Spatial layer to show or analyze. -1 to disable filtering."); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 136 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 137 | ABSL_FLAG(std::string, |
| 138 | stream0, |
| 139 | "", |
| 140 | "Comma separated values describing VideoStream for stream #0."); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 141 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 142 | ABSL_FLAG(std::string, |
| 143 | stream1, |
| 144 | "", |
| 145 | "Comma separated values describing VideoStream for stream #1."); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 146 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 147 | ABSL_FLAG(std::string, |
| 148 | sl0, |
| 149 | "", |
| 150 | "Comma separated values describing SpatialLayer for layer #0."); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 151 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 152 | ABSL_FLAG(std::string, |
| 153 | sl1, |
| 154 | "", |
| 155 | "Comma separated values describing SpatialLayer for layer #1."); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 156 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 157 | ABSL_FLAG(std::string, |
| 158 | sl2, |
| 159 | "", |
| 160 | "Comma separated values describing SpatialLayer for layer #2."); |
Sergey Silkin | a89800c | 2019-02-19 12:52:56 +0100 | [diff] [blame] | 161 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 162 | ABSL_FLAG(std::string, |
| 163 | encoded_frame_path, |
| 164 | "", |
| 165 | "The base path for encoded frame logs. Created files will have " |
| 166 | "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf"); |
palmkvist | e75f204 | 2016-09-28 06:19:48 -0700 | [diff] [blame] | 167 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 168 | ABSL_FLAG(bool, logs, false, "print logs to stderr"); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 169 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 170 | ABSL_FLAG(bool, send_side_bwe, true, "Use send-side bandwidth estimation"); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 171 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 172 | ABSL_FLAG(bool, generic_descriptor, false, "Use the generic frame descriptor."); |
philipel | 569397f | 2018-09-26 12:25:31 +0200 | [diff] [blame] | 173 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 174 | ABSL_FLAG(bool, allow_reordering, false, "Allow packet reordering to occur"); |
philipel | a2c5523 | 2016-01-26 08:41:53 -0800 | [diff] [blame] | 175 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 176 | ABSL_FLAG(bool, use_ulpfec, false, "Use RED+ULPFEC forward error correction."); |
brandtr | a62f582 | 2016-11-17 00:21:13 -0800 | [diff] [blame] | 177 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 178 | ABSL_FLAG(bool, use_flexfec, false, "Use FlexFEC forward error correction."); |
philipel | 274c1dc | 2016-05-04 06:21:01 -0700 | [diff] [blame] | 179 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 180 | ABSL_FLAG(bool, audio, false, "Add audio stream"); |
minyue | 7320866 | 2016-08-18 06:28:55 -0700 | [diff] [blame] | 181 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 182 | ABSL_FLAG(bool, |
| 183 | use_real_adm, |
| 184 | false, |
| 185 | "Use real ADM instead of fake (no effect if audio is false)"); |
henrika | 255750b | 2018-08-27 16:13:37 +0200 | [diff] [blame] | 186 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 187 | ABSL_FLAG(bool, |
| 188 | audio_video_sync, |
| 189 | false, |
| 190 | "Sync audio and video stream (no effect if" |
| 191 | " audio is false)"); |
minyue | 7320866 | 2016-08-18 06:28:55 -0700 | [diff] [blame] | 192 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 193 | ABSL_FLAG(bool, |
| 194 | audio_dtx, |
| 195 | false, |
| 196 | "Enable audio DTX (no effect if audio is false)"); |
minyue | 4c8b942 | 2017-03-21 04:11:43 -0700 | [diff] [blame] | 197 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 198 | ABSL_FLAG(bool, video, true, "Add video stream"); |
minyue | a27172d | 2016-11-01 05:59:29 -0700 | [diff] [blame] | 199 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 200 | ABSL_FLAG( |
| 201 | std::string, |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 202 | force_fieldtrials, |
| 203 | "", |
| 204 | "Field trials control experimental feature code which can be forced. " |
Elad Alon | 1e3ed16 | 2018-10-15 17:50:37 +0200 | [diff] [blame] | 205 | "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enabled/" |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 206 | " will assign the group Enable to field trial WebRTC-FooFeature. Multiple " |
| 207 | "trials are separated by \"/\""); |
pbos | 9874ee0 | 2015-06-22 04:44:26 -0700 | [diff] [blame] | 208 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 209 | // Video-specific flags. |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 210 | ABSL_FLAG(std::string, |
| 211 | clip, |
| 212 | "", |
| 213 | "Name of the clip to show. If empty, using chroma generator."); |
| 214 | |
| 215 | namespace webrtc { |
| 216 | namespace { |
| 217 | |
| 218 | size_t Width() { |
| 219 | return static_cast<size_t>(absl::GetFlag(FLAGS_width)); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 220 | } |
| 221 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 222 | size_t Height() { |
| 223 | return static_cast<size_t>(absl::GetFlag(FLAGS_height)); |
| 224 | } |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 225 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 226 | int Fps() { |
| 227 | return absl::GetFlag(FLAGS_fps); |
| 228 | } |
| 229 | |
| 230 | size_t GetCaptureDevice() { |
| 231 | return static_cast<size_t>(absl::GetFlag(FLAGS_capture_device_index)); |
| 232 | } |
| 233 | |
| 234 | int MinBitrateKbps() { |
| 235 | return absl::GetFlag(FLAGS_min_bitrate); |
| 236 | } |
| 237 | |
| 238 | int StartBitrateKbps() { |
| 239 | return absl::GetFlag(FLAGS_start_bitrate); |
| 240 | } |
| 241 | |
| 242 | int TargetBitrateKbps() { |
| 243 | return absl::GetFlag(FLAGS_target_bitrate); |
| 244 | } |
| 245 | |
| 246 | int MaxBitrateKbps() { |
| 247 | return absl::GetFlag(FLAGS_max_bitrate); |
| 248 | } |
| 249 | |
| 250 | int NumTemporalLayers() { |
| 251 | return absl::GetFlag(FLAGS_num_temporal_layers); |
| 252 | } |
| 253 | |
| 254 | InterLayerPredMode InterLayerPred() { |
| 255 | if (absl::GetFlag(FLAGS_inter_layer_pred) == 0) { |
| 256 | return InterLayerPredMode::kOn; |
| 257 | } else if (absl::GetFlag(FLAGS_inter_layer_pred) == 1) { |
| 258 | return InterLayerPredMode::kOff; |
| 259 | } else { |
| 260 | RTC_DCHECK_EQ(absl::GetFlag(FLAGS_inter_layer_pred), 2); |
| 261 | return InterLayerPredMode::kOnKeyPic; |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | std::string Codec() { |
| 266 | return absl::GetFlag(FLAGS_codec); |
| 267 | } |
| 268 | |
| 269 | int SelectedTL() { |
| 270 | return absl::GetFlag(FLAGS_selected_tl); |
| 271 | } |
| 272 | |
| 273 | int DurationSecs() { |
| 274 | return absl::GetFlag(FLAGS_duration); |
| 275 | } |
| 276 | |
| 277 | std::string OutputFilename() { |
| 278 | return absl::GetFlag(FLAGS_output_filename); |
| 279 | } |
| 280 | |
| 281 | std::string GraphTitle() { |
| 282 | return absl::GetFlag(FLAGS_graph_title); |
| 283 | } |
| 284 | |
| 285 | int LossPercent() { |
| 286 | return static_cast<int>(absl::GetFlag(FLAGS_loss_percent)); |
| 287 | } |
| 288 | |
| 289 | int AvgBurstLossLength() { |
| 290 | return static_cast<int>(absl::GetFlag(FLAGS_avg_burst_loss_length)); |
| 291 | } |
| 292 | |
| 293 | int LinkCapacityKbps() { |
| 294 | return static_cast<int>(absl::GetFlag(FLAGS_link_capacity)); |
| 295 | } |
| 296 | |
| 297 | int QueueSize() { |
| 298 | return static_cast<int>(absl::GetFlag(FLAGS_queue_size)); |
| 299 | } |
| 300 | |
| 301 | int AvgPropagationDelayMs() { |
| 302 | return static_cast<int>(absl::GetFlag(FLAGS_avg_propagation_delay_ms)); |
| 303 | } |
| 304 | |
| 305 | std::string RtcEventLogName() { |
| 306 | return absl::GetFlag(FLAGS_rtc_event_log_name); |
| 307 | } |
| 308 | |
| 309 | std::string RtpDumpName() { |
| 310 | return absl::GetFlag(FLAGS_rtp_dump_name); |
| 311 | } |
| 312 | |
| 313 | int StdPropagationDelayMs() { |
| 314 | return absl::GetFlag(FLAGS_std_propagation_delay_ms); |
| 315 | } |
| 316 | |
| 317 | int NumStreams() { |
| 318 | return absl::GetFlag(FLAGS_num_streams); |
| 319 | } |
| 320 | |
| 321 | int SelectedStream() { |
| 322 | return absl::GetFlag(FLAGS_selected_stream); |
| 323 | } |
| 324 | |
| 325 | int NumSpatialLayers() { |
| 326 | return absl::GetFlag(FLAGS_num_spatial_layers); |
| 327 | } |
| 328 | |
| 329 | int SelectedSL() { |
| 330 | return absl::GetFlag(FLAGS_selected_sl); |
| 331 | } |
| 332 | |
| 333 | std::string Stream0() { |
| 334 | return absl::GetFlag(FLAGS_stream0); |
| 335 | } |
| 336 | |
| 337 | std::string Stream1() { |
| 338 | return absl::GetFlag(FLAGS_stream1); |
| 339 | } |
| 340 | |
| 341 | std::string SL0() { |
| 342 | return absl::GetFlag(FLAGS_sl0); |
| 343 | } |
| 344 | |
| 345 | std::string SL1() { |
| 346 | return absl::GetFlag(FLAGS_sl1); |
| 347 | } |
| 348 | |
| 349 | std::string SL2() { |
| 350 | return absl::GetFlag(FLAGS_sl2); |
| 351 | } |
| 352 | |
| 353 | std::string EncodedFramePath() { |
| 354 | return absl::GetFlag(FLAGS_encoded_frame_path); |
| 355 | } |
| 356 | |
| 357 | std::string Clip() { |
| 358 | return absl::GetFlag(FLAGS_clip); |
| 359 | } |
| 360 | |
| 361 | } // namespace |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 362 | |
| 363 | void Loopback() { |
Artem Titov | 75e3647 | 2018-10-08 12:28:56 +0200 | [diff] [blame] | 364 | BuiltInNetworkBehaviorConfig pipe_config; |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 365 | pipe_config.loss_percent = LossPercent(); |
| 366 | pipe_config.avg_burst_loss_length = AvgBurstLossLength(); |
| 367 | pipe_config.link_capacity_kbps = LinkCapacityKbps(); |
| 368 | pipe_config.queue_length_packets = QueueSize(); |
| 369 | pipe_config.queue_delay_ms = AvgPropagationDelayMs(); |
| 370 | pipe_config.delay_standard_deviation_ms = StdPropagationDelayMs(); |
| 371 | pipe_config.allow_reordering = absl::GetFlag(FLAGS_allow_reordering); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 372 | |
Sebastian Jansson | fc8d26b | 2018-02-21 09:52:06 +0100 | [diff] [blame] | 373 | BitrateConstraints call_bitrate_config; |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 374 | call_bitrate_config.min_bitrate_bps = MinBitrateKbps() * 1000; |
| 375 | call_bitrate_config.start_bitrate_bps = StartBitrateKbps() * 1000; |
Erik Språng | 28bb391 | 2018-07-11 16:06:55 +0200 | [diff] [blame] | 376 | call_bitrate_config.max_bitrate_bps = -1; // Don't cap bandwidth estimate. |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 377 | |
minyue | 7320866 | 2016-08-18 06:28:55 -0700 | [diff] [blame] | 378 | VideoQualityTest::Params params; |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 379 | params.call = {absl::GetFlag(FLAGS_send_side_bwe), |
| 380 | absl::GetFlag(FLAGS_generic_descriptor), call_bitrate_config, |
| 381 | 0}; |
| 382 | params.video[0] = {absl::GetFlag(FLAGS_video), |
| 383 | Width(), |
| 384 | Height(), |
| 385 | Fps(), |
| 386 | MinBitrateKbps() * 1000, |
| 387 | TargetBitrateKbps() * 1000, |
| 388 | MaxBitrateKbps() * 1000, |
| 389 | absl::GetFlag(FLAGS_suspend_below_min_bitrate), |
| 390 | Codec(), |
| 391 | NumTemporalLayers(), |
| 392 | SelectedTL(), |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 393 | 0, // No min transmit bitrate. |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 394 | absl::GetFlag(FLAGS_use_ulpfec), |
| 395 | absl::GetFlag(FLAGS_use_flexfec), |
| 396 | NumStreams() < 2, // Automatic quality scaling. |
| 397 | Clip(), |
| 398 | GetCaptureDevice()}; |
| 399 | params.audio = { |
| 400 | absl::GetFlag(FLAGS_audio), absl::GetFlag(FLAGS_audio_video_sync), |
| 401 | absl::GetFlag(FLAGS_audio_dtx), absl::GetFlag(FLAGS_use_real_adm)}; |
| 402 | params.logging = {RtcEventLogName(), RtpDumpName(), EncodedFramePath()}; |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 403 | params.screenshare[0].enabled = false; |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 404 | params.analyzer = {"video", 0.0, 0.0, DurationSecs(), |
| 405 | OutputFilename(), GraphTitle()}; |
Artem Titov | f18b352 | 2018-08-28 16:54:24 +0200 | [diff] [blame] | 406 | params.config = pipe_config; |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 407 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 408 | if (NumStreams() > 1 && Stream0().empty() && Stream1().empty()) { |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 18:02:59 +0100 | [diff] [blame] | 409 | params.ss[0].infer_streams = true; |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 410 | } |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 411 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 412 | std::vector<std::string> stream_descriptors; |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 413 | stream_descriptors.push_back(Stream0()); |
| 414 | stream_descriptors.push_back(Stream1()); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 415 | std::vector<std::string> SL_descriptors; |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 416 | SL_descriptors.push_back(SL0()); |
| 417 | SL_descriptors.push_back(SL1()); |
| 418 | SL_descriptors.push_back(SL2()); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 419 | VideoQualityTest::FillScalabilitySettings( |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 420 | ¶ms, 0, stream_descriptors, NumStreams(), SelectedStream(), |
| 421 | NumSpatialLayers(), SelectedSL(), InterLayerPred(), SL_descriptors); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 422 | |
Mirko Bonadei | 317a1f0 | 2019-09-17 17:06:18 +0200 | [diff] [blame] | 423 | auto fixture = std::make_unique<VideoQualityTest>(nullptr); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 424 | if (DurationSecs()) { |
Patrik Höglund | b6b29e0 | 2018-06-21 16:58:01 +0200 | [diff] [blame] | 425 | fixture->RunWithAnalyzer(params); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 426 | } else { |
Patrik Höglund | b6b29e0 | 2018-06-21 16:58:01 +0200 | [diff] [blame] | 427 | fixture->RunWithRenderers(params); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 428 | } |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 429 | } |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 430 | |
Kári Tristan Helgason | ede7cb2 | 2019-03-06 10:34:09 +0100 | [diff] [blame] | 431 | int RunLoopbackTest(int argc, char* argv[]) { |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 432 | ::testing::InitGoogleTest(&argc, argv); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 433 | absl::ParseCommandLine(argc, argv); |
sprang | 1168fd4 | 2017-06-21 09:00:17 -0700 | [diff] [blame] | 434 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 435 | rtc::LogMessage::SetLogToStderr(absl::GetFlag(FLAGS_logs)); |
Mirko Bonadei | 45a4c41 | 2018-07-31 15:07:28 +0200 | [diff] [blame] | 436 | |
Bjorn Terelius | edab301 | 2018-01-31 17:23:40 +0100 | [diff] [blame] | 437 | // InitFieldTrialsFromString stores the char*, so the char array must outlive |
| 438 | // the application. |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 439 | const std::string field_trials = absl::GetFlag(FLAGS_force_fieldtrials); |
| 440 | webrtc::field_trial::InitFieldTrialsFromString(field_trials.c_str()); |
sprang | 89c4a7e | 2017-06-30 13:27:40 -0700 | [diff] [blame] | 441 | |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 442 | webrtc::test::RunTest(webrtc::Loopback); |
| 443 | return 0; |
| 444 | } |
Kári Tristan Helgason | ede7cb2 | 2019-03-06 10:34:09 +0100 | [diff] [blame] | 445 | } // namespace webrtc |