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 | */ |
| 10 | |
| 11 | #include <stdio.h> |
| 12 | |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 13 | #include "gflags/gflags.h" |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 14 | #include "webrtc/test/field_trial.h" |
kwiberg | ac9f876 | 2016-09-30 22:29:43 -0700 | [diff] [blame] | 15 | #include "webrtc/test/gtest.h" |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 16 | #include "webrtc/test/run_test.h" |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 17 | #include "webrtc/video/video_quality_test.h" |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 20 | namespace flags { |
| 21 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 22 | // Flags common with screenshare loopback, with different default values. |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 23 | DEFINE_int32(width, 640, "Video width."); |
| 24 | size_t Width() { |
| 25 | return static_cast<size_t>(FLAGS_width); |
| 26 | } |
| 27 | |
| 28 | DEFINE_int32(height, 480, "Video height."); |
| 29 | size_t Height() { |
| 30 | return static_cast<size_t>(FLAGS_height); |
| 31 | } |
| 32 | |
| 33 | DEFINE_int32(fps, 30, "Frames per second."); |
| 34 | int Fps() { |
| 35 | return static_cast<int>(FLAGS_fps); |
| 36 | } |
| 37 | |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 38 | DEFINE_int32(min_bitrate, 50, "Call and stream min bitrate in kbps."); |
| 39 | int MinBitrateKbps() { |
| 40 | return static_cast<int>(FLAGS_min_bitrate); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 41 | } |
| 42 | |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 43 | DEFINE_int32(start_bitrate, 300, "Call start bitrate in kbps."); |
| 44 | int StartBitrateKbps() { |
| 45 | return static_cast<int>(FLAGS_start_bitrate); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 46 | } |
| 47 | |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 48 | DEFINE_int32(target_bitrate, 800, "Stream target bitrate in kbps."); |
| 49 | int TargetBitrateKbps() { |
| 50 | return static_cast<int>(FLAGS_target_bitrate); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 51 | } |
| 52 | |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 53 | DEFINE_int32(max_bitrate, 800, "Call and stream max bitrate in kbps."); |
| 54 | int MaxBitrateKbps() { |
| 55 | return static_cast<int>(FLAGS_max_bitrate); |
| 56 | } |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 57 | |
mflodman | 48a4beb | 2016-07-01 13:03:59 +0200 | [diff] [blame] | 58 | DEFINE_bool(suspend_below_min_bitrate, |
| 59 | false, |
| 60 | "Suspends video below the configured min bitrate."); |
| 61 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 62 | DEFINE_int32(num_temporal_layers, |
| 63 | 1, |
| 64 | "Number of temporal layers. Set to 1-4 to override."); |
| 65 | int NumTemporalLayers() { |
| 66 | return static_cast<int>(FLAGS_num_temporal_layers); |
| 67 | } |
| 68 | |
| 69 | // Flags common with screenshare loopback, with equal default values. |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 70 | DEFINE_string(codec, "VP8", "Video codec to use."); |
| 71 | std::string Codec() { |
| 72 | return static_cast<std::string>(FLAGS_codec); |
| 73 | } |
| 74 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 75 | DEFINE_int32(selected_tl, |
| 76 | -1, |
| 77 | "Temporal layer to show or analyze. -1 to disable filtering."); |
| 78 | int SelectedTL() { |
| 79 | return static_cast<int>(FLAGS_selected_tl); |
| 80 | } |
| 81 | |
| 82 | DEFINE_int32( |
| 83 | duration, |
| 84 | 0, |
| 85 | "Duration of the test in seconds. If 0, rendered will be shown instead."); |
| 86 | int DurationSecs() { |
| 87 | return static_cast<int>(FLAGS_duration); |
| 88 | } |
| 89 | |
| 90 | DEFINE_string(output_filename, "", "Target graph data filename."); |
| 91 | std::string OutputFilename() { |
| 92 | return static_cast<std::string>(FLAGS_output_filename); |
| 93 | } |
| 94 | |
| 95 | DEFINE_string(graph_title, |
| 96 | "", |
| 97 | "If empty, title will be generated automatically."); |
| 98 | std::string GraphTitle() { |
| 99 | return static_cast<std::string>(FLAGS_graph_title); |
| 100 | } |
| 101 | |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 102 | DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost."); |
| 103 | int LossPercent() { |
| 104 | return static_cast<int>(FLAGS_loss_percent); |
| 105 | } |
| 106 | |
philipel | cb7b449 | 2016-06-02 10:57:40 +0200 | [diff] [blame] | 107 | DEFINE_int32(avg_burst_loss_length, |
| 108 | -1, |
| 109 | "Average burst length of lost packets."); |
philipel | 536378b | 2016-05-31 03:20:23 -0700 | [diff] [blame] | 110 | int AvgBurstLossLength() { |
| 111 | return static_cast<int>(FLAGS_avg_burst_loss_length); |
| 112 | } |
| 113 | |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 114 | DEFINE_int32(link_capacity, |
| 115 | 0, |
| 116 | "Capacity (kbps) of the fake link. 0 means infinite."); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 117 | int LinkCapacityKbps() { |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 118 | return static_cast<int>(FLAGS_link_capacity); |
| 119 | } |
| 120 | |
| 121 | DEFINE_int32(queue_size, 0, "Size of the bottleneck link queue in packets."); |
| 122 | int QueueSize() { |
| 123 | return static_cast<int>(FLAGS_queue_size); |
| 124 | } |
| 125 | |
| 126 | DEFINE_int32(avg_propagation_delay_ms, |
| 127 | 0, |
| 128 | "Average link propagation delay in ms."); |
| 129 | int AvgPropagationDelayMs() { |
| 130 | return static_cast<int>(FLAGS_avg_propagation_delay_ms); |
| 131 | } |
| 132 | |
| 133 | DEFINE_int32(std_propagation_delay_ms, |
| 134 | 0, |
| 135 | "Link propagation delay standard deviation in ms."); |
| 136 | int StdPropagationDelayMs() { |
| 137 | return static_cast<int>(FLAGS_std_propagation_delay_ms); |
| 138 | } |
| 139 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 140 | DEFINE_int32(selected_stream, 0, "ID of the stream to show or analyze."); |
| 141 | int SelectedStream() { |
| 142 | return static_cast<int>(FLAGS_selected_stream); |
| 143 | } |
| 144 | |
| 145 | DEFINE_int32(num_spatial_layers, 1, "Number of spatial layers to use."); |
| 146 | int NumSpatialLayers() { |
| 147 | return static_cast<int>(FLAGS_num_spatial_layers); |
| 148 | } |
| 149 | |
| 150 | DEFINE_int32(selected_sl, |
| 151 | -1, |
| 152 | "Spatial layer to show or analyze. -1 to disable filtering."); |
| 153 | int SelectedSL() { |
| 154 | return static_cast<int>(FLAGS_selected_sl); |
| 155 | } |
| 156 | |
| 157 | DEFINE_string(stream0, |
| 158 | "", |
| 159 | "Comma separated values describing VideoStream for stream #0."); |
| 160 | std::string Stream0() { |
| 161 | return static_cast<std::string>(FLAGS_stream0); |
| 162 | } |
| 163 | |
| 164 | DEFINE_string(stream1, |
| 165 | "", |
| 166 | "Comma separated values describing VideoStream for stream #1."); |
| 167 | std::string Stream1() { |
| 168 | return static_cast<std::string>(FLAGS_stream1); |
| 169 | } |
| 170 | |
| 171 | DEFINE_string(sl0, |
| 172 | "", |
| 173 | "Comma separated values describing SpatialLayer for layer #0."); |
| 174 | std::string SL0() { |
| 175 | return static_cast<std::string>(FLAGS_sl0); |
| 176 | } |
| 177 | |
| 178 | DEFINE_string(sl1, |
| 179 | "", |
| 180 | "Comma separated values describing SpatialLayer for layer #1."); |
| 181 | std::string SL1() { |
| 182 | return static_cast<std::string>(FLAGS_sl1); |
| 183 | } |
| 184 | |
palmkvist | e75f204 | 2016-09-28 06:19:48 -0700 | [diff] [blame] | 185 | DEFINE_string(encoded_frame_path, |
| 186 | "", |
| 187 | "The base path for encoded frame logs. Created files will have " |
| 188 | "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf"); |
| 189 | std::string EncodedFramePath() { |
| 190 | return static_cast<std::string>(FLAGS_encoded_frame_path); |
| 191 | } |
| 192 | |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 193 | DEFINE_bool(logs, false, "print logs to stderr"); |
| 194 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 195 | DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation"); |
| 196 | |
philipel | a2c5523 | 2016-01-26 08:41:53 -0800 | [diff] [blame] | 197 | DEFINE_bool(allow_reordering, false, "Allow packet reordering to occur"); |
| 198 | |
brandtr | a62f582 | 2016-11-17 00:21:13 -0800 | [diff] [blame^] | 199 | DEFINE_bool(use_ulpfec, false, "Use RED+ULPFEC forward error correction."); |
| 200 | |
| 201 | DEFINE_bool(use_flexfec, false, "Use FlexFEC forward error correction."); |
philipel | 274c1dc | 2016-05-04 06:21:01 -0700 | [diff] [blame] | 202 | |
minyue | 7320866 | 2016-08-18 06:28:55 -0700 | [diff] [blame] | 203 | DEFINE_bool(audio, false, "Add audio stream"); |
| 204 | |
| 205 | DEFINE_bool(audio_video_sync, false, "Sync audio and video stream (no effect if" |
| 206 | " audio is false)"); |
| 207 | |
minyue | a27172d | 2016-11-01 05:59:29 -0700 | [diff] [blame] | 208 | DEFINE_bool(video, true, "Add video stream"); |
| 209 | |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 210 | DEFINE_string( |
| 211 | force_fieldtrials, |
| 212 | "", |
| 213 | "Field trials control experimental feature code which can be forced. " |
| 214 | "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" |
| 215 | " will assign the group Enable to field trial WebRTC-FooFeature. Multiple " |
| 216 | "trials are separated by \"/\""); |
pbos | 9874ee0 | 2015-06-22 04:44:26 -0700 | [diff] [blame] | 217 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 218 | // Video-specific flags. |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 219 | DEFINE_string(clip, |
| 220 | "", |
| 221 | "Name of the clip to show. If empty, using chroma generator."); |
| 222 | std::string Clip() { |
| 223 | return static_cast<std::string>(FLAGS_clip); |
| 224 | } |
| 225 | |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 226 | } // namespace flags |
| 227 | |
| 228 | void Loopback() { |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 229 | FakeNetworkPipe::Config pipe_config; |
| 230 | pipe_config.loss_percent = flags::LossPercent(); |
philipel | 536378b | 2016-05-31 03:20:23 -0700 | [diff] [blame] | 231 | pipe_config.avg_burst_loss_length = flags::AvgBurstLossLength(); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 232 | pipe_config.link_capacity_kbps = flags::LinkCapacityKbps(); |
| 233 | pipe_config.queue_length_packets = flags::QueueSize(); |
| 234 | pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs(); |
| 235 | pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs(); |
philipel | a2c5523 | 2016-01-26 08:41:53 -0800 | [diff] [blame] | 236 | pipe_config.allow_reordering = flags::FLAGS_allow_reordering; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 237 | |
| 238 | Call::Config::BitrateConfig call_bitrate_config; |
| 239 | call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000; |
| 240 | call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000; |
| 241 | call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000; |
| 242 | |
minyue | 7320866 | 2016-08-18 06:28:55 -0700 | [diff] [blame] | 243 | VideoQualityTest::Params params; |
minyue | 626bc95 | 2016-10-31 05:47:02 -0700 | [diff] [blame] | 244 | params.call = {flags::FLAGS_send_side_bwe, call_bitrate_config}; |
minyue | a27172d | 2016-11-01 05:59:29 -0700 | [diff] [blame] | 245 | params.video = {flags::FLAGS_video, |
minyue | 626bc95 | 2016-10-31 05:47:02 -0700 | [diff] [blame] | 246 | flags::Width(), |
| 247 | flags::Height(), |
| 248 | flags::Fps(), |
| 249 | flags::MinBitrateKbps() * 1000, |
| 250 | flags::TargetBitrateKbps() * 1000, |
| 251 | flags::MaxBitrateKbps() * 1000, |
| 252 | flags::FLAGS_suspend_below_min_bitrate, |
| 253 | flags::Codec(), |
| 254 | flags::NumTemporalLayers(), |
| 255 | flags::SelectedTL(), |
| 256 | 0, // No min transmit bitrate. |
brandtr | a62f582 | 2016-11-17 00:21:13 -0800 | [diff] [blame^] | 257 | flags::FLAGS_use_ulpfec, |
| 258 | flags::FLAGS_use_flexfec, |
minyue | 626bc95 | 2016-10-31 05:47:02 -0700 | [diff] [blame] | 259 | flags::EncodedFramePath(), |
| 260 | flags::Clip()}; |
| 261 | params.audio = {flags::FLAGS_audio, flags::FLAGS_audio_video_sync}; |
asapersson | 3ec3da6 | 2016-10-11 16:20:33 -0700 | [diff] [blame] | 262 | params.screenshare.enabled = false; |
minyue | 7320866 | 2016-08-18 06:28:55 -0700 | [diff] [blame] | 263 | params.analyzer = {"video", 0.0, 0.0, flags::DurationSecs(), |
| 264 | flags::OutputFilename(), flags::GraphTitle()}; |
| 265 | params.pipe = pipe_config; |
| 266 | params.logs = flags::FLAGS_logs; |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 267 | |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 268 | std::vector<std::string> stream_descriptors; |
| 269 | stream_descriptors.push_back(flags::Stream0()); |
| 270 | stream_descriptors.push_back(flags::Stream1()); |
| 271 | std::vector<std::string> SL_descriptors; |
| 272 | SL_descriptors.push_back(flags::SL0()); |
| 273 | SL_descriptors.push_back(flags::SL1()); |
| 274 | VideoQualityTest::FillScalabilitySettings( |
| 275 | ¶ms, stream_descriptors, flags::SelectedStream(), |
| 276 | flags::NumSpatialLayers(), flags::SelectedSL(), SL_descriptors); |
| 277 | |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame] | 278 | VideoQualityTest test; |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 279 | if (flags::DurationSecs()) { |
sprang | 7a975f7 | 2015-10-12 06:33:21 -0700 | [diff] [blame] | 280 | test.RunWithAnalyzer(params); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 281 | } else { |
minyue | 7320866 | 2016-08-18 06:28:55 -0700 | [diff] [blame] | 282 | test.RunWithRenderers(params); |
sprang | ce4aef1 | 2015-11-02 07:23:20 -0800 | [diff] [blame] | 283 | } |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 284 | } |
| 285 | } // namespace webrtc |
| 286 | |
| 287 | int main(int argc, char* argv[]) { |
| 288 | ::testing::InitGoogleTest(&argc, argv); |
| 289 | google::ParseCommandLineFlags(&argc, &argv, true); |
| 290 | webrtc::test::InitFieldTrialsFromString( |
| 291 | webrtc::flags::FLAGS_force_fieldtrials); |
| 292 | webrtc::test::RunTest(webrtc::Loopback); |
| 293 | return 0; |
| 294 | } |