| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include <stdio.h> | 11 #include <stdio.h> |
| 12 | 12 |
| 13 #include <map> | 13 #include <map> |
| 14 | 14 |
| 15 #include "gflags/gflags.h" | 15 #include "gflags/gflags.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 17 |
| 18 #include "webrtc/test/field_trial.h" | 18 #include "webrtc/test/field_trial.h" |
| 19 #include "webrtc/test/run_test.h" | 19 #include "webrtc/test/run_test.h" |
| 20 #include "webrtc/typedefs.h" | 20 #include "webrtc/typedefs.h" |
| 21 #include "webrtc/video/loopback.h" | 21 #include "webrtc/video/video_quality_test.h" |
| 22 | 22 |
| 23 namespace webrtc { | 23 namespace webrtc { |
| 24 | 24 |
| 25 namespace flags { | 25 namespace flags { |
| 26 | 26 |
| 27 DEFINE_int32(width, 640, "Video width."); | 27 DEFINE_int32(width, 640, "Video width."); |
| 28 size_t Width() { | 28 size_t Width() { |
| 29 return static_cast<size_t>(FLAGS_width); | 29 return static_cast<size_t>(FLAGS_width); |
| 30 } | 30 } |
| 31 | 31 |
| 32 DEFINE_int32(height, 480, "Video height."); | 32 DEFINE_int32(height, 480, "Video height."); |
| 33 size_t Height() { | 33 size_t Height() { |
| 34 return static_cast<size_t>(FLAGS_height); | 34 return static_cast<size_t>(FLAGS_height); |
| 35 } | 35 } |
| 36 | 36 |
| 37 DEFINE_int32(fps, 30, "Frames per second."); | 37 DEFINE_int32(fps, 30, "Frames per second."); |
| 38 int Fps() { | 38 int Fps() { |
| 39 return static_cast<int>(FLAGS_fps); | 39 return static_cast<int>(FLAGS_fps); |
| 40 } | 40 } |
| 41 | 41 |
| 42 DEFINE_int32(min_bitrate, 50, "Minimum video bitrate."); | 42 DEFINE_int32(min_bitrate, 50, "Call and stream min bitrate in kbps."); |
| 43 size_t MinBitrate() { | 43 int MinBitrateKbps() { |
| 44 return static_cast<size_t>(FLAGS_min_bitrate); | 44 return static_cast<int>(FLAGS_min_bitrate); |
| 45 } | 45 } |
| 46 | 46 |
| 47 DEFINE_int32(start_bitrate, 300, "Video starting bitrate."); | 47 DEFINE_int32(start_bitrate, 300, "Call start bitrate in kbps."); |
| 48 size_t StartBitrate() { | 48 int StartBitrateKbps() { |
| 49 return static_cast<size_t>(FLAGS_start_bitrate); | 49 return static_cast<int>(FLAGS_start_bitrate); |
| 50 } | 50 } |
| 51 | 51 |
| 52 DEFINE_int32(max_bitrate, 800, "Maximum video bitrate."); | 52 DEFINE_int32(target_bitrate, 800, "Stream target bitrate in kbps."); |
| 53 size_t MaxBitrate() { | 53 int TargetBitrateKbps() { |
| 54 return static_cast<size_t>(FLAGS_max_bitrate); | 54 return static_cast<int>(FLAGS_target_bitrate); |
| 55 } | 55 } |
| 56 | 56 |
| 57 int MinTransmitBitrate() { | 57 DEFINE_int32(max_bitrate, 800, "Call and stream max bitrate in kbps."); |
| 58 return 0; | 58 int MaxBitrateKbps() { |
| 59 } // No min padding for regular video. | 59 return static_cast<int>(FLAGS_max_bitrate); |
| 60 } |
| 60 | 61 |
| 61 DEFINE_string(codec, "VP8", "Video codec to use."); | 62 DEFINE_string(codec, "VP8", "Video codec to use."); |
| 62 std::string Codec() { | 63 std::string Codec() { |
| 63 return static_cast<std::string>(FLAGS_codec); | 64 return static_cast<std::string>(FLAGS_codec); |
| 64 } | 65 } |
| 65 | 66 |
| 66 DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost."); | 67 DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost."); |
| 67 int LossPercent() { | 68 int LossPercent() { |
| 68 return static_cast<int>(FLAGS_loss_percent); | 69 return static_cast<int>(FLAGS_loss_percent); |
| 69 } | 70 } |
| 70 | 71 |
| 71 DEFINE_int32(link_capacity, | 72 DEFINE_int32(link_capacity, |
| 72 0, | 73 0, |
| 73 "Capacity (kbps) of the fake link. 0 means infinite."); | 74 "Capacity (kbps) of the fake link. 0 means infinite."); |
| 74 int LinkCapacity() { | 75 int LinkCapacityKbps() { |
| 75 return static_cast<int>(FLAGS_link_capacity); | 76 return static_cast<int>(FLAGS_link_capacity); |
| 76 } | 77 } |
| 77 | 78 |
| 78 DEFINE_int32(queue_size, 0, "Size of the bottleneck link queue in packets."); | 79 DEFINE_int32(queue_size, 0, "Size of the bottleneck link queue in packets."); |
| 79 int QueueSize() { | 80 int QueueSize() { |
| 80 return static_cast<int>(FLAGS_queue_size); | 81 return static_cast<int>(FLAGS_queue_size); |
| 81 } | 82 } |
| 82 | 83 |
| 83 DEFINE_int32(avg_propagation_delay_ms, | 84 DEFINE_int32(avg_propagation_delay_ms, |
| 84 0, | 85 0, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 98 | 99 |
| 99 DEFINE_string( | 100 DEFINE_string( |
| 100 force_fieldtrials, | 101 force_fieldtrials, |
| 101 "", | 102 "", |
| 102 "Field trials control experimental feature code which can be forced. " | 103 "Field trials control experimental feature code which can be forced. " |
| 103 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" | 104 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" |
| 104 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple " | 105 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple " |
| 105 "trials are separated by \"/\""); | 106 "trials are separated by \"/\""); |
| 106 | 107 |
| 107 DEFINE_int32(num_temporal_layers, | 108 DEFINE_int32(num_temporal_layers, |
| 108 0, | 109 1, |
| 109 "Number of temporal layers. Set to 1-4 to override."); | 110 "Number of temporal layers. Set to 1-4 to override."); |
| 110 | |
| 111 size_t NumTemporalLayers() { | 111 size_t NumTemporalLayers() { |
| 112 return static_cast<size_t>(FLAGS_num_temporal_layers); | 112 return static_cast<size_t>(FLAGS_num_temporal_layers); |
| 113 } | 113 } |
| 114 | 114 |
| 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 |
| 115 } // namespace flags | 143 } // namespace flags |
| 116 | 144 |
| 117 void Loopback() { | 145 void Loopback() { |
| 118 test::Loopback::Config config{flags::Width(), | 146 FakeNetworkPipe::Config pipe_config; |
| 119 flags::Height(), | 147 pipe_config.loss_percent = flags::LossPercent(); |
| 120 flags::Fps(), | 148 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps(); |
| 121 flags::MinBitrate(), | 149 pipe_config.queue_length_packets = flags::QueueSize(); |
| 122 flags::StartBitrate(), | 150 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs(); |
| 123 flags::MaxBitrate(), | 151 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs(); |
| 124 0, // No min transmit bitrate. | 152 |
| 125 flags::Codec(), | 153 Call::Config::BitrateConfig call_bitrate_config; |
| 126 flags::NumTemporalLayers(), | 154 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000; |
| 127 flags::LossPercent(), | 155 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000; |
| 128 flags::LinkCapacity(), | 156 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000; |
| 129 flags::QueueSize(), | 157 |
| 130 flags::AvgPropagationDelayMs(), | 158 std::string clip = flags::Clip(); |
| 131 flags::StdPropagationDelayMs(), | 159 std::string graph_title = clip.empty() ? "" : "video " + clip; |
| 132 flags::FLAGS_logs}; | 160 VideoQualityTest::Params params{ |
| 133 test::Loopback loopback(config); | 161 { |
| 134 loopback.Run(); | 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); |
| 135 } | 185 } |
| 136 } // namespace webrtc | 186 } // namespace webrtc |
| 137 | 187 |
| 138 int main(int argc, char* argv[]) { | 188 int main(int argc, char* argv[]) { |
| 139 ::testing::InitGoogleTest(&argc, argv); | 189 ::testing::InitGoogleTest(&argc, argv); |
| 140 google::ParseCommandLineFlags(&argc, &argv, true); | 190 google::ParseCommandLineFlags(&argc, &argv, true); |
| 141 webrtc::test::InitFieldTrialsFromString( | 191 webrtc::test::InitFieldTrialsFromString( |
| 142 webrtc::flags::FLAGS_force_fieldtrials); | 192 webrtc::flags::FLAGS_force_fieldtrials); |
| 143 webrtc::test::RunTest(webrtc::Loopback); | 193 webrtc::test::RunTest(webrtc::Loopback); |
| 144 return 0; | 194 return 0; |
| 145 } | 195 } |
| OLD | NEW |