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