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