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