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