sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [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 | */ |
| 10 | |
| 11 | #include <stdio.h> |
Jonas Olsson | 5b2eda4 | 2019-06-11 12:29:40 | [diff] [blame] | 12 | |
Yves Gerey | 3e70781 | 2018-11-28 15:47:49 | [diff] [blame] | 13 | #include <memory> |
| 14 | #include <string> |
| 15 | #include <vector> |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 16 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 17 | #include "absl/flags/flag.h" |
| 18 | #include "absl/flags/parse.h" |
Yves Gerey | 3e70781 | 2018-11-28 15:47:49 | [diff] [blame] | 19 | #include "absl/types/optional.h" |
Yves Gerey | 3e70781 | 2018-11-28 15:47:49 | [diff] [blame] | 20 | #include "api/test/simulated_network.h" |
| 21 | #include "api/test/video_quality_test_fixture.h" |
Mirko Bonadei | 738bfa7 | 2019-09-17 12:47:38 | [diff] [blame] | 22 | #include "api/transport/bitrate_settings.h" |
Yves Gerey | 3e70781 | 2018-11-28 15:47:49 | [diff] [blame] | 23 | #include "api/video_codecs/video_codec.h" |
| 24 | #include "rtc_base/checks.h" |
Mirko Bonadei | 45a4c41 | 2018-07-31 13:07:28 | [diff] [blame] | 25 | #include "rtc_base/logging.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 26 | #include "rtc_base/string_encode.h" |
Mirko Bonadei | 17f4878 | 2018-09-28 06:51:10 | [diff] [blame] | 27 | #include "system_wrappers/include/field_trial.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [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 | [diff] [blame] | 32 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 33 | using ::webrtc::BitrateConstraints; |
| 34 | using ::webrtc::BuiltInNetworkBehaviorConfig; |
| 35 | using ::webrtc::InterLayerPredMode; |
| 36 | using ::webrtc::SdpVideoFormat; |
| 37 | using ::webrtc::VideoQualityTest; |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 38 | |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 39 | // Flags common with video loopback, with different default values. |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 40 | ABSL_FLAG(int, width, 1850, "Video width (crops source)."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 41 | size_t Width() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 42 | return static_cast<size_t>(absl::GetFlag(FLAGS_width)); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 43 | } |
sprang | d635895 | 2015-07-29 14:58:13 | [diff] [blame] | 44 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 45 | ABSL_FLAG(int, height, 1110, "Video height (crops source)."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 46 | size_t Height() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 47 | return static_cast<size_t>(absl::GetFlag(FLAGS_height)); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 48 | } |
| 49 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 50 | ABSL_FLAG(int, fps, 5, "Frames per second."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 51 | int Fps() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 52 | return absl::GetFlag(FLAGS_fps); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 53 | } |
| 54 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 55 | ABSL_FLAG(int, min_bitrate, 50, "Call and stream min bitrate in kbps."); |
ivica | 5d6a06c | 2015-09-17 12:30:24 | [diff] [blame] | 56 | int MinBitrateKbps() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 57 | return absl::GetFlag(FLAGS_min_bitrate); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 58 | } |
| 59 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 60 | ABSL_FLAG(int, start_bitrate, 300, "Call start bitrate in kbps."); |
ivica | 5d6a06c | 2015-09-17 12:30:24 | [diff] [blame] | 61 | int StartBitrateKbps() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 62 | return absl::GetFlag(FLAGS_start_bitrate); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 63 | } |
| 64 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 65 | ABSL_FLAG(int, target_bitrate, 200, "Stream target bitrate in kbps."); |
ivica | 5d6a06c | 2015-09-17 12:30:24 | [diff] [blame] | 66 | int TargetBitrateKbps() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 67 | return absl::GetFlag(FLAGS_target_bitrate); |
ivica | 5d6a06c | 2015-09-17 12:30:24 | [diff] [blame] | 68 | } |
| 69 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 70 | ABSL_FLAG(int, max_bitrate, 1000, "Call and stream max bitrate in kbps."); |
ivica | 5d6a06c | 2015-09-17 12:30:24 | [diff] [blame] | 71 | int MaxBitrateKbps() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 72 | return absl::GetFlag(FLAGS_max_bitrate); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 73 | } |
| 74 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 75 | ABSL_FLAG(int, num_temporal_layers, 2, "Number of temporal layers to use."); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 76 | int NumTemporalLayers() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 77 | return absl::GetFlag(FLAGS_num_temporal_layers); |
ivica | 87f83a9 | 2015-10-08 12:13:32 | [diff] [blame] | 78 | } |
| 79 | |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 80 | // Flags common with video loopback, with equal default values. |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 81 | ABSL_FLAG(std::string, codec, "VP8", "Video codec to use."); |
sprang | 7a975f7 | 2015-10-12 13:33:21 | [diff] [blame] | 82 | std::string Codec() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 83 | return absl::GetFlag(FLAGS_codec); |
ivica | 87f83a9 | 2015-10-08 12:13:32 | [diff] [blame] | 84 | } |
| 85 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 86 | ABSL_FLAG(std::string, |
| 87 | rtc_event_log_name, |
| 88 | "", |
| 89 | "Filename for rtc event log. Two files " |
| 90 | "with \"_send\" and \"_recv\" suffixes will be created."); |
ilnik | 9843695 | 2017-07-13 07:47:03 | [diff] [blame] | 91 | std::string RtcEventLogName() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 92 | return absl::GetFlag(FLAGS_rtc_event_log_name); |
ilnik | 9843695 | 2017-07-13 07:47:03 | [diff] [blame] | 93 | } |
| 94 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 95 | ABSL_FLAG(std::string, |
| 96 | rtp_dump_name, |
| 97 | "", |
| 98 | "Filename for dumped received RTP stream."); |
ilnik | 9843695 | 2017-07-13 07:47:03 | [diff] [blame] | 99 | std::string RtpDumpName() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 100 | return absl::GetFlag(FLAGS_rtp_dump_name); |
ilnik | 9843695 | 2017-07-13 07:47:03 | [diff] [blame] | 101 | } |
| 102 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 103 | ABSL_FLAG(int, |
| 104 | selected_tl, |
| 105 | -1, |
| 106 | "Temporal layer to show or analyze. -1 to disable filtering."); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 107 | int SelectedTL() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 108 | return absl::GetFlag(FLAGS_selected_tl); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 109 | } |
| 110 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 111 | ABSL_FLAG( |
| 112 | int, |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 113 | duration, |
| 114 | 0, |
| 115 | "Duration of the test in seconds. If 0, rendered will be shown instead."); |
| 116 | int DurationSecs() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 117 | return absl::GetFlag(FLAGS_duration); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 118 | } |
| 119 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 120 | ABSL_FLAG(std::string, output_filename, "", "Target graph data filename."); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 121 | std::string OutputFilename() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 122 | return absl::GetFlag(FLAGS_output_filename); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 123 | } |
| 124 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 125 | ABSL_FLAG(std::string, |
| 126 | graph_title, |
| 127 | "", |
| 128 | "If empty, title will be generated automatically."); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 129 | std::string GraphTitle() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 130 | return absl::GetFlag(FLAGS_graph_title); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 131 | } |
| 132 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 133 | ABSL_FLAG(int, loss_percent, 0, "Percentage of packets randomly lost."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 134 | int LossPercent() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 135 | return absl::GetFlag(FLAGS_loss_percent); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 136 | } |
| 137 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 138 | ABSL_FLAG(int, |
| 139 | link_capacity, |
| 140 | 0, |
| 141 | "Capacity (kbps) of the fake link. 0 means infinite."); |
ivica | 5d6a06c | 2015-09-17 12:30:24 | [diff] [blame] | 142 | int LinkCapacityKbps() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 143 | return absl::GetFlag(FLAGS_link_capacity); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 144 | } |
| 145 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 146 | ABSL_FLAG(int, queue_size, 0, "Size of the bottleneck link queue in packets."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 147 | int QueueSize() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 148 | return absl::GetFlag(FLAGS_queue_size); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 149 | } |
| 150 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 151 | ABSL_FLAG(int, |
| 152 | avg_propagation_delay_ms, |
| 153 | 0, |
| 154 | "Average link propagation delay in ms."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 155 | int AvgPropagationDelayMs() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 156 | return absl::GetFlag(FLAGS_avg_propagation_delay_ms); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 157 | } |
| 158 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 159 | ABSL_FLAG(int, |
| 160 | std_propagation_delay_ms, |
| 161 | 0, |
| 162 | "Link propagation delay standard deviation in ms."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 163 | int StdPropagationDelayMs() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 164 | return absl::GetFlag(FLAGS_std_propagation_delay_ms); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 165 | } |
| 166 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 167 | ABSL_FLAG(int, num_streams, 0, "Number of streams to show or analyze."); |
sprang | 1168fd4 | 2017-06-21 16:00:17 | [diff] [blame] | 168 | int NumStreams() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 169 | return absl::GetFlag(FLAGS_num_streams); |
sprang | 1168fd4 | 2017-06-21 16:00:17 | [diff] [blame] | 170 | } |
| 171 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 172 | ABSL_FLAG(int, |
| 173 | selected_stream, |
| 174 | 0, |
| 175 | "ID of the stream to show or analyze. " |
| 176 | "Set to the number of streams to show them all."); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 177 | int SelectedStream() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 178 | return absl::GetFlag(FLAGS_selected_stream); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 179 | } |
| 180 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 181 | ABSL_FLAG(int, num_spatial_layers, 1, "Number of spatial layers to use."); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 182 | int NumSpatialLayers() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 183 | return absl::GetFlag(FLAGS_num_spatial_layers); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 184 | } |
| 185 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 186 | ABSL_FLAG(int, |
| 187 | inter_layer_pred, |
| 188 | 0, |
| 189 | "Inter-layer prediction mode. " |
| 190 | "0 - enabled, 1 - disabled, 2 - enabled only for key pictures."); |
Sergey Silkin | 5702736 | 2018-05-15 07:12:05 | [diff] [blame] | 191 | InterLayerPredMode InterLayerPred() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 192 | if (absl::GetFlag(FLAGS_inter_layer_pred) == 0) { |
| 193 | return webrtc::InterLayerPredMode::kOn; |
| 194 | } else if (absl::GetFlag(FLAGS_inter_layer_pred) == 1) { |
| 195 | return webrtc::InterLayerPredMode::kOff; |
Sergey Silkin | 5702736 | 2018-05-15 07:12:05 | [diff] [blame] | 196 | } else { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 197 | RTC_DCHECK_EQ(absl::GetFlag(FLAGS_inter_layer_pred), 2); |
| 198 | return webrtc::InterLayerPredMode::kOnKeyPic; |
Sergey Silkin | 5702736 | 2018-05-15 07:12:05 | [diff] [blame] | 199 | } |
| 200 | } |
| 201 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 202 | ABSL_FLAG(int, |
| 203 | selected_sl, |
| 204 | -1, |
| 205 | "Spatial layer to show or analyze. -1 to disable filtering."); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 206 | int SelectedSL() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 207 | return absl::GetFlag(FLAGS_selected_sl); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 208 | } |
| 209 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 210 | ABSL_FLAG(std::string, |
| 211 | stream0, |
| 212 | "", |
| 213 | "Comma separated values describing VideoStream for stream #0."); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 214 | std::string Stream0() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 215 | return absl::GetFlag(FLAGS_stream0); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 216 | } |
| 217 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 218 | ABSL_FLAG(std::string, |
| 219 | stream1, |
| 220 | "", |
| 221 | "Comma separated values describing VideoStream for stream #1."); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 222 | std::string Stream1() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 223 | return absl::GetFlag(FLAGS_stream1); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 224 | } |
| 225 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 226 | ABSL_FLAG(std::string, |
| 227 | sl0, |
| 228 | "", |
| 229 | "Comma separated values describing SpatialLayer for layer #0."); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 230 | std::string SL0() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 231 | return absl::GetFlag(FLAGS_sl0); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 232 | } |
| 233 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 234 | ABSL_FLAG(std::string, |
| 235 | sl1, |
| 236 | "", |
| 237 | "Comma separated values describing SpatialLayer for layer #1."); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 238 | std::string SL1() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 239 | return absl::GetFlag(FLAGS_sl1); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 240 | } |
| 241 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 242 | ABSL_FLAG(std::string, |
| 243 | encoded_frame_path, |
| 244 | "", |
| 245 | "The base path for encoded frame logs. Created files will have " |
| 246 | "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf"); |
palmkvist | e75f204 | 2016-09-28 13:19:48 | [diff] [blame] | 247 | std::string EncodedFramePath() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 248 | return absl::GetFlag(FLAGS_encoded_frame_path); |
palmkvist | e75f204 | 2016-09-28 13:19:48 | [diff] [blame] | 249 | } |
| 250 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 251 | ABSL_FLAG(bool, logs, false, "print logs to stderr"); |
ivica | 87f83a9 | 2015-10-08 12:13:32 | [diff] [blame] | 252 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 253 | ABSL_FLAG(bool, send_side_bwe, true, "Use send-side bandwidth estimation"); |
Erik Språng | 6b8d355 | 2015-09-24 13:06:57 | [diff] [blame] | 254 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 255 | ABSL_FLAG(bool, generic_descriptor, false, "Use the generic frame descriptor."); |
philipel | 569397f | 2018-09-26 10:25:31 | [diff] [blame] | 256 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 257 | ABSL_FLAG(bool, allow_reordering, false, "Allow packet reordering to occur"); |
philipel | a2c5523 | 2016-01-26 16:41:53 | [diff] [blame] | 258 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 259 | ABSL_FLAG( |
| 260 | std::string, |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 261 | force_fieldtrials, |
| 262 | "", |
| 263 | "Field trials control experimental feature code which can be forced. " |
| 264 | "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" |
| 265 | " will assign the group Enable to field trial WebRTC-FooFeature. Multiple " |
| 266 | "trials are separated by \"/\""); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 267 | |
| 268 | // Screenshare-specific flags. |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 269 | ABSL_FLAG(int, |
| 270 | min_transmit_bitrate, |
| 271 | 400, |
| 272 | "Min transmit bitrate incl. padding."); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 273 | int MinTransmitBitrateKbps() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 274 | return absl::GetFlag(FLAGS_min_transmit_bitrate); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 275 | } |
| 276 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 277 | ABSL_FLAG(bool, |
| 278 | generate_slides, |
| 279 | false, |
| 280 | "Whether to use randomly generated slides or read them from files."); |
erikvarga | 579de6f | 2017-08-29 16:12:57 | [diff] [blame] | 281 | bool GenerateSlides() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 282 | return absl::GetFlag(FLAGS_generate_slides); |
erikvarga | 579de6f | 2017-08-29 16:12:57 | [diff] [blame] | 283 | } |
| 284 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 285 | ABSL_FLAG(int, |
| 286 | slide_change_interval, |
| 287 | 10, |
| 288 | "Interval (in seconds) between simulated slide changes."); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 289 | int SlideChangeInterval() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 290 | return absl::GetFlag(FLAGS_slide_change_interval); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 291 | } |
| 292 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 293 | ABSL_FLAG( |
| 294 | int, |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 295 | scroll_duration, |
| 296 | 0, |
| 297 | "Duration (in seconds) during which a slide will be scrolled into place."); |
| 298 | int ScrollDuration() { |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 299 | return absl::GetFlag(FLAGS_scroll_duration); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 300 | } |
| 301 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 302 | ABSL_FLAG(std::string, |
| 303 | slides, |
| 304 | "", |
| 305 | "Comma-separated list of *.yuv files to display as slides."); |
ilnik | 8d8185c | 2017-04-12 11:52:55 | [diff] [blame] | 306 | std::vector<std::string> Slides() { |
| 307 | std::vector<std::string> slides; |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 308 | std::string slides_list = absl::GetFlag(FLAGS_slides); |
ilnik | 8d8185c | 2017-04-12 11:52:55 | [diff] [blame] | 309 | rtc::tokenize(slides_list, ',', &slides); |
| 310 | return slides; |
| 311 | } |
| 312 | |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 313 | void Loopback() { |
Artem Titov | 75e3647 | 2018-10-08 10:28:56 | [diff] [blame] | 314 | BuiltInNetworkBehaviorConfig pipe_config; |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 315 | pipe_config.loss_percent = LossPercent(); |
| 316 | pipe_config.link_capacity_kbps = LinkCapacityKbps(); |
| 317 | pipe_config.queue_length_packets = QueueSize(); |
| 318 | pipe_config.queue_delay_ms = AvgPropagationDelayMs(); |
| 319 | pipe_config.delay_standard_deviation_ms = StdPropagationDelayMs(); |
| 320 | pipe_config.allow_reordering = absl::GetFlag(FLAGS_allow_reordering); |
ivica | 5d6a06c | 2015-09-17 12:30:24 | [diff] [blame] | 321 | |
Sebastian Jansson | fc8d26b | 2018-02-21 08:52:06 | [diff] [blame] | 322 | BitrateConstraints call_bitrate_config; |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 323 | call_bitrate_config.min_bitrate_bps = MinBitrateKbps() * 1000; |
| 324 | call_bitrate_config.start_bitrate_bps = StartBitrateKbps() * 1000; |
Erik Språng | 28bb391 | 2018-07-11 14:06:55 | [diff] [blame] | 325 | call_bitrate_config.max_bitrate_bps = -1; // Don't cap bandwidth estimate. |
ivica | 5d6a06c | 2015-09-17 12:30:24 | [diff] [blame] | 326 | |
minyue | 7320866 | 2016-08-18 13:28:55 | [diff] [blame] | 327 | VideoQualityTest::Params params; |
Danil Chapovalov | 059f4f7 | 2020-07-07 12:16:47 | [diff] [blame] | 328 | params.call.send_side_bwe = absl::GetFlag(FLAGS_send_side_bwe); |
| 329 | params.call.generic_descriptor = absl::GetFlag(FLAGS_generic_descriptor); |
| 330 | params.call.call_bitrate_config = call_bitrate_config; |
| 331 | params.video[0].enabled = true; |
| 332 | params.video[0].width = Width(); |
| 333 | params.video[0].height = Height(); |
| 334 | params.video[0].fps = Fps(); |
| 335 | params.video[0].min_bitrate_bps = MinBitrateKbps() * 1000; |
| 336 | params.video[0].target_bitrate_bps = TargetBitrateKbps() * 1000; |
| 337 | params.video[0].max_bitrate_bps = MaxBitrateKbps() * 1000; |
| 338 | params.video[0].codec = Codec(); |
| 339 | params.video[0].num_temporal_layers = NumTemporalLayers(); |
| 340 | params.video[0].selected_tl = SelectedTL(); |
| 341 | params.video[0].min_transmit_bps = MinTransmitBitrateKbps() * 1000; |
| 342 | params.screenshare[0].enabled = true; |
| 343 | params.screenshare[0].generate_slides = GenerateSlides(); |
| 344 | params.screenshare[0].slide_change_interval = SlideChangeInterval(); |
| 345 | params.screenshare[0].scroll_duration = ScrollDuration(); |
| 346 | params.screenshare[0].slides = Slides(); |
Artem Titov | f18b352 | 2018-08-28 14:54:24 | [diff] [blame] | 347 | params.config = pipe_config; |
Danil Chapovalov | 059f4f7 | 2020-07-07 12:16:47 | [diff] [blame] | 348 | params.logging.rtc_event_log_name = RtcEventLogName(); |
| 349 | params.logging.rtp_dump_name = RtpDumpName(); |
| 350 | params.logging.encoded_frame_base_path = EncodedFramePath(); |
ivica | 5d6a06c | 2015-09-17 12:30:24 | [diff] [blame] | 351 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 352 | if (NumStreams() > 1 && Stream0().empty() && Stream1().empty()) { |
Ilya Nikolaevskiy | 255d1cd | 2017-12-21 17:02:59 | [diff] [blame] | 353 | params.ss[0].infer_streams = true; |
sprang | 1168fd4 | 2017-06-21 16:00:17 | [diff] [blame] | 354 | } |
| 355 | |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 356 | std::vector<std::string> stream_descriptors; |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 357 | stream_descriptors.push_back(Stream0()); |
| 358 | stream_descriptors.push_back(Stream1()); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 359 | std::vector<std::string> SL_descriptors; |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 360 | SL_descriptors.push_back(SL0()); |
| 361 | SL_descriptors.push_back(SL1()); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 362 | VideoQualityTest::FillScalabilitySettings( |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 363 | ¶ms, 0, stream_descriptors, NumStreams(), SelectedStream(), |
| 364 | NumSpatialLayers(), SelectedSL(), InterLayerPred(), SL_descriptors); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 365 | |
Mirko Bonadei | 317a1f0 | 2019-09-17 15:06:18 | [diff] [blame] | 366 | auto fixture = std::make_unique<VideoQualityTest>(nullptr); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 367 | if (DurationSecs()) { |
Patrik Höglund | b6b29e0 | 2018-06-21 14:58:01 | [diff] [blame] | 368 | fixture->RunWithAnalyzer(params); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 369 | } else { |
Patrik Höglund | b6b29e0 | 2018-06-21 14:58:01 | [diff] [blame] | 370 | fixture->RunWithRenderers(params); |
sprang | ce4aef1 | 2015-11-02 15:23:20 | [diff] [blame] | 371 | } |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 372 | } |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 373 | |
| 374 | int main(int argc, char* argv[]) { |
| 375 | ::testing::InitGoogleTest(&argc, argv); |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 376 | absl::ParseCommandLine(argc, argv); |
kjellander | 12fa8f4 | 2017-05-17 18:19:58 | [diff] [blame] | 377 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 378 | rtc::LogMessage::SetLogToStderr(absl::GetFlag(FLAGS_logs)); |
Mirko Bonadei | 45a4c41 | 2018-07-31 13:07:28 | [diff] [blame] | 379 | |
Bjorn Terelius | edab301 | 2018-01-31 16:23:40 | [diff] [blame] | 380 | // InitFieldTrialsFromString stores the char*, so the char array must outlive |
| 381 | // the application. |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 382 | const std::string field_trials = absl::GetFlag(FLAGS_force_fieldtrials); |
| 383 | webrtc::field_trial::InitFieldTrialsFromString(field_trials.c_str()); |
sprang | 89c4a7e | 2017-06-30 20:27:40 | [diff] [blame] | 384 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 11:44:12 | [diff] [blame] | 385 | webrtc::test::RunTest(Loopback); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 | [diff] [blame] | 386 | return 0; |
| 387 | } |