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" |
| 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 +0000 | [diff] [blame] | 17 | #include "webrtc/test/run_test.h" |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame^] | 18 | #include "webrtc/video/video_quality_test.h" |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
| 21 | namespace flags { |
| 22 | |
sprang | d635895 | 2015-07-29 07:58:13 -0700 | [diff] [blame] | 23 | DEFINE_int32(width, 1850, "Video width (crops source)."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 24 | size_t Width() { |
sprang | d635895 | 2015-07-29 07:58:13 -0700 | [diff] [blame] | 25 | return static_cast<size_t>(FLAGS_width); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 26 | } |
sprang | d635895 | 2015-07-29 07:58:13 -0700 | [diff] [blame] | 27 | |
| 28 | DEFINE_int32(height, 1110, "Video height (crops source)."); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 29 | size_t Height() { |
sprang | d635895 | 2015-07-29 07:58:13 -0700 | [diff] [blame] | 30 | return static_cast<size_t>(FLAGS_height); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | DEFINE_int32(fps, 5, "Frames per second."); |
| 34 | int Fps() { |
| 35 | return static_cast<int>(FLAGS_fps); |
| 36 | } |
| 37 | |
sprang | d635895 | 2015-07-29 07:58:13 -0700 | [diff] [blame] | 38 | DEFINE_int32(slide_change_interval, |
| 39 | 10, |
| 40 | "Interval (in seconds) between simulated slide changes."); |
| 41 | int SlideChangeInterval() { |
| 42 | return static_cast<int>(FLAGS_slide_change_interval); |
| 43 | } |
| 44 | |
| 45 | DEFINE_int32( |
| 46 | scroll_duration, |
| 47 | 0, |
| 48 | "Duration (in seconds) during which a slide will be scrolled into place."); |
| 49 | int ScrollDuration() { |
| 50 | return static_cast<int>(FLAGS_scroll_duration); |
| 51 | } |
| 52 | |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame^] | 53 | DEFINE_int32(min_bitrate, 50, "Call and stream min bitrate in kbps."); |
| 54 | int MinBitrateKbps() { |
| 55 | return static_cast<int>(FLAGS_min_bitrate); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 56 | } |
| 57 | |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame^] | 58 | DEFINE_int32(start_bitrate, 200, "Call start bitrate in kbps."); |
| 59 | int StartBitrateKbps() { |
| 60 | return static_cast<int>(FLAGS_start_bitrate); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 61 | } |
| 62 | |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame^] | 63 | DEFINE_int32(target_bitrate, 2000, "Stream target bitrate in kbps."); |
| 64 | int TargetBitrateKbps() { |
| 65 | return static_cast<int>(FLAGS_target_bitrate); |
| 66 | } |
| 67 | |
| 68 | DEFINE_int32(max_bitrate, 2000, "Call and stream max bitrate in kbps."); |
| 69 | int MaxBitrateKbps() { |
| 70 | return static_cast<int>(FLAGS_max_bitrate); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 71 | } |
| 72 | |
sprang | ef7228c | 2015-08-05 02:01:29 -0700 | [diff] [blame] | 73 | DEFINE_int32(num_temporal_layers, 2, "Number of temporal layers to use."); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame^] | 74 | size_t NumTemporalLayers() { |
| 75 | return static_cast<size_t>(FLAGS_num_temporal_layers); |
ivica | 7f6a6fc | 2015-09-08 02:40:29 -0700 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | DEFINE_int32( |
| 79 | tl_discard_threshold, |
| 80 | 0, |
| 81 | "Discard TLs with id greater or equal the threshold. 0 to disable."); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame^] | 82 | size_t TLDiscardThreshold() { |
| 83 | return static_cast<size_t>(FLAGS_tl_discard_threshold); |
ivica | 7f6a6fc | 2015-09-08 02:40:29 -0700 | [diff] [blame] | 84 | } |
| 85 | |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 86 | DEFINE_int32(min_transmit_bitrate, 400, "Min transmit bitrate incl. padding."); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame^] | 87 | int MinTransmitBitrateKbps() { |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 88 | return FLAGS_min_transmit_bitrate; |
| 89 | } |
| 90 | |
| 91 | DEFINE_string(codec, "VP8", "Video codec to use."); |
| 92 | std::string Codec() { |
| 93 | return static_cast<std::string>(FLAGS_codec); |
| 94 | } |
| 95 | |
| 96 | DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost."); |
| 97 | int LossPercent() { |
| 98 | return static_cast<int>(FLAGS_loss_percent); |
| 99 | } |
| 100 | |
| 101 | DEFINE_int32(link_capacity, |
| 102 | 0, |
| 103 | "Capacity (kbps) of the fake link. 0 means infinite."); |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame^] | 104 | int LinkCapacityKbps() { |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 105 | return static_cast<int>(FLAGS_link_capacity); |
| 106 | } |
| 107 | |
| 108 | DEFINE_int32(queue_size, 0, "Size of the bottleneck link queue in packets."); |
| 109 | int QueueSize() { |
| 110 | return static_cast<int>(FLAGS_queue_size); |
| 111 | } |
| 112 | |
| 113 | DEFINE_int32(avg_propagation_delay_ms, |
| 114 | 0, |
| 115 | "Average link propagation delay in ms."); |
| 116 | int AvgPropagationDelayMs() { |
| 117 | return static_cast<int>(FLAGS_avg_propagation_delay_ms); |
| 118 | } |
| 119 | |
| 120 | DEFINE_int32(std_propagation_delay_ms, |
| 121 | 0, |
| 122 | "Link propagation delay standard deviation in ms."); |
| 123 | int StdPropagationDelayMs() { |
| 124 | return static_cast<int>(FLAGS_std_propagation_delay_ms); |
| 125 | } |
| 126 | |
| 127 | DEFINE_bool(logs, false, "print logs to stderr"); |
| 128 | |
| 129 | DEFINE_string( |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame^] | 130 | output_filename, |
| 131 | "", |
| 132 | "Name of a target graph data file. If set, no preview will be shown."); |
| 133 | std::string OutputFilename() { |
| 134 | return static_cast<std::string>(FLAGS_output_filename); |
| 135 | } |
| 136 | |
| 137 | DEFINE_int32(duration, 60, "Duration of the test in seconds."); |
| 138 | int DurationSecs() { |
| 139 | return static_cast<int>(FLAGS_duration); |
| 140 | } |
| 141 | |
| 142 | DEFINE_string( |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 143 | force_fieldtrials, |
| 144 | "", |
| 145 | "Field trials control experimental feature code which can be forced. " |
| 146 | "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" |
| 147 | " will assign the group Enable to field trial WebRTC-FooFeature. Multiple " |
| 148 | "trials are separated by \"/\""); |
| 149 | } // namespace flags |
| 150 | |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 151 | void Loopback() { |
ivica | 5d6a06c | 2015-09-17 05:30:24 -0700 | [diff] [blame^] | 152 | FakeNetworkPipe::Config pipe_config; |
| 153 | pipe_config.loss_percent = flags::LossPercent(); |
| 154 | pipe_config.link_capacity_kbps = flags::LinkCapacityKbps(); |
| 155 | pipe_config.queue_length_packets = flags::QueueSize(); |
| 156 | pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs(); |
| 157 | pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs(); |
| 158 | |
| 159 | Call::Config::BitrateConfig call_bitrate_config; |
| 160 | call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000; |
| 161 | call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000; |
| 162 | call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000; |
| 163 | |
| 164 | VideoQualityTest::Params params{ |
| 165 | { |
| 166 | flags::Width(), |
| 167 | flags::Height(), |
| 168 | flags::Fps(), |
| 169 | flags::MinBitrateKbps() * 1000, |
| 170 | flags::TargetBitrateKbps() * 1000, |
| 171 | flags::MaxBitrateKbps() * 1000, |
| 172 | flags::Codec(), |
| 173 | flags::NumTemporalLayers(), |
| 174 | flags::MinTransmitBitrateKbps() * 1000, |
| 175 | call_bitrate_config, |
| 176 | flags::TLDiscardThreshold() |
| 177 | }, |
| 178 | {}, // Video specific. |
| 179 | {true, flags::SlideChangeInterval(), flags::ScrollDuration()}, |
| 180 | {"screenshare", 0.0, 0.0, flags::DurationSecs(), flags::OutputFilename()}, |
| 181 | pipe_config, |
| 182 | flags::FLAGS_logs}; |
| 183 | |
| 184 | VideoQualityTest test; |
| 185 | if (flags::OutputFilename().empty()) |
| 186 | test.RunWithVideoRenderer(params); |
| 187 | else |
| 188 | test.RunWithAnalyzer(params); |
sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame] | 189 | } |
| 190 | } // namespace webrtc |
| 191 | |
| 192 | int main(int argc, char* argv[]) { |
| 193 | ::testing::InitGoogleTest(&argc, argv); |
| 194 | google::ParseCommandLineFlags(&argc, &argv, true); |
| 195 | webrtc::test::InitFieldTrialsFromString( |
| 196 | webrtc::flags::FLAGS_force_fieldtrials); |
| 197 | webrtc::test::RunTest(webrtc::Loopback); |
| 198 | return 0; |
| 199 | } |