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