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 "gflags/gflags.h" | 13 #include "gflags/gflags.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 #include "webrtc/test/field_trial.h" | 16 #include "webrtc/test/field_trial.h" |
17 #include "webrtc/test/run_test.h" | 17 #include "webrtc/test/run_test.h" |
18 #include "webrtc/video/video_quality_test.h" | 18 #include "webrtc/video/video_quality_test.h" |
19 | 19 |
20 namespace webrtc { | 20 namespace webrtc { |
21 namespace flags { | 21 namespace flags { |
22 | 22 |
| 23 // Flags common with screenshare loopback, with different default values. |
23 DEFINE_int32(width, 640, "Video width."); | 24 DEFINE_int32(width, 640, "Video width."); |
24 size_t Width() { | 25 size_t Width() { |
25 return static_cast<size_t>(FLAGS_width); | 26 return static_cast<size_t>(FLAGS_width); |
26 } | 27 } |
27 | 28 |
28 DEFINE_int32(height, 480, "Video height."); | 29 DEFINE_int32(height, 480, "Video height."); |
29 size_t Height() { | 30 size_t Height() { |
30 return static_cast<size_t>(FLAGS_height); | 31 return static_cast<size_t>(FLAGS_height); |
31 } | 32 } |
32 | 33 |
(...skipping 15 matching lines...) Expand all Loading... |
48 DEFINE_int32(target_bitrate, 800, "Stream target bitrate in kbps."); | 49 DEFINE_int32(target_bitrate, 800, "Stream target bitrate in kbps."); |
49 int TargetBitrateKbps() { | 50 int TargetBitrateKbps() { |
50 return static_cast<int>(FLAGS_target_bitrate); | 51 return static_cast<int>(FLAGS_target_bitrate); |
51 } | 52 } |
52 | 53 |
53 DEFINE_int32(max_bitrate, 800, "Call and stream max bitrate in kbps."); | 54 DEFINE_int32(max_bitrate, 800, "Call and stream max bitrate in kbps."); |
54 int MaxBitrateKbps() { | 55 int MaxBitrateKbps() { |
55 return static_cast<int>(FLAGS_max_bitrate); | 56 return static_cast<int>(FLAGS_max_bitrate); |
56 } | 57 } |
57 | 58 |
| 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. |
58 DEFINE_string(codec, "VP8", "Video codec to use."); | 67 DEFINE_string(codec, "VP8", "Video codec to use."); |
59 std::string Codec() { | 68 std::string Codec() { |
60 return static_cast<std::string>(FLAGS_codec); | 69 return static_cast<std::string>(FLAGS_codec); |
61 } | 70 } |
62 | 71 |
| 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( |
| 93 graph_title, "", "If empty, title will be generated automatically."); |
| 94 std::string GraphTitle() { |
| 95 return static_cast<std::string>(FLAGS_graph_title); |
| 96 } |
| 97 |
63 DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost."); | 98 DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost."); |
64 int LossPercent() { | 99 int LossPercent() { |
65 return static_cast<int>(FLAGS_loss_percent); | 100 return static_cast<int>(FLAGS_loss_percent); |
66 } | 101 } |
67 | 102 |
68 DEFINE_int32(link_capacity, | 103 DEFINE_int32(link_capacity, |
69 0, | 104 0, |
70 "Capacity (kbps) of the fake link. 0 means infinite."); | 105 "Capacity (kbps) of the fake link. 0 means infinite."); |
71 int LinkCapacityKbps() { | 106 int LinkCapacityKbps() { |
72 return static_cast<int>(FLAGS_link_capacity); | 107 return static_cast<int>(FLAGS_link_capacity); |
(...skipping 11 matching lines...) Expand all Loading... |
84 return static_cast<int>(FLAGS_avg_propagation_delay_ms); | 119 return static_cast<int>(FLAGS_avg_propagation_delay_ms); |
85 } | 120 } |
86 | 121 |
87 DEFINE_int32(std_propagation_delay_ms, | 122 DEFINE_int32(std_propagation_delay_ms, |
88 0, | 123 0, |
89 "Link propagation delay standard deviation in ms."); | 124 "Link propagation delay standard deviation in ms."); |
90 int StdPropagationDelayMs() { | 125 int StdPropagationDelayMs() { |
91 return static_cast<int>(FLAGS_std_propagation_delay_ms); | 126 return static_cast<int>(FLAGS_std_propagation_delay_ms); |
92 } | 127 } |
93 | 128 |
| 129 DEFINE_int32(selected_stream, 0, "ID of the stream to show or analyze."); |
| 130 int SelectedStream() { |
| 131 return static_cast<int>(FLAGS_selected_stream); |
| 132 } |
| 133 |
| 134 DEFINE_int32(num_spatial_layers, 1, "Number of spatial layers to use."); |
| 135 int NumSpatialLayers() { |
| 136 return static_cast<int>(FLAGS_num_spatial_layers); |
| 137 } |
| 138 |
| 139 DEFINE_int32(selected_sl, |
| 140 -1, |
| 141 "Spatial layer to show or analyze. -1 to disable filtering."); |
| 142 int SelectedSL() { |
| 143 return static_cast<int>(FLAGS_selected_sl); |
| 144 } |
| 145 |
| 146 DEFINE_string(stream0, |
| 147 "", |
| 148 "Comma separated values describing VideoStream for stream #0."); |
| 149 std::string Stream0() { |
| 150 return static_cast<std::string>(FLAGS_stream0); |
| 151 } |
| 152 |
| 153 DEFINE_string(stream1, |
| 154 "", |
| 155 "Comma separated values describing VideoStream for stream #1."); |
| 156 std::string Stream1() { |
| 157 return static_cast<std::string>(FLAGS_stream1); |
| 158 } |
| 159 |
| 160 DEFINE_string( |
| 161 sl0, "", "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( |
| 167 sl1, "", "Comma separated values describing SpatialLayer for layer #1."); |
| 168 std::string SL1() { |
| 169 return static_cast<std::string>(FLAGS_sl1); |
| 170 } |
| 171 |
94 DEFINE_bool(logs, false, "print logs to stderr"); | 172 DEFINE_bool(logs, false, "print logs to stderr"); |
95 | 173 |
| 174 DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation"); |
| 175 |
96 DEFINE_string( | 176 DEFINE_string( |
97 force_fieldtrials, | 177 force_fieldtrials, |
98 "", | 178 "", |
99 "Field trials control experimental feature code which can be forced. " | 179 "Field trials control experimental feature code which can be forced. " |
100 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" | 180 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" |
101 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple " | 181 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple " |
102 "trials are separated by \"/\""); | 182 "trials are separated by \"/\""); |
103 | 183 |
104 DEFINE_int32(num_temporal_layers, | 184 // Video-specific flags. |
105 1, | |
106 "Number of temporal layers. Set to 1-4 to override."); | |
107 size_t NumTemporalLayers() { | |
108 return static_cast<size_t>(FLAGS_num_temporal_layers); | |
109 } | |
110 | |
111 DEFINE_int32( | |
112 tl_discard_threshold, | |
113 0, | |
114 "Discard TLs with id greater or equal the threshold. 0 to disable."); | |
115 size_t TLDiscardThreshold() { | |
116 return static_cast<size_t>(FLAGS_tl_discard_threshold); | |
117 } | |
118 | |
119 DEFINE_string(clip, | 185 DEFINE_string(clip, |
120 "", | 186 "", |
121 "Name of the clip to show. If empty, using chroma generator."); | 187 "Name of the clip to show. If empty, using chroma generator."); |
122 std::string Clip() { | 188 std::string Clip() { |
123 return static_cast<std::string>(FLAGS_clip); | 189 return static_cast<std::string>(FLAGS_clip); |
124 } | 190 } |
125 | 191 |
126 DEFINE_string( | |
127 output_filename, | |
128 "", | |
129 "Name of a target graph data file. If set, no preview will be shown."); | |
130 std::string OutputFilename() { | |
131 return static_cast<std::string>(FLAGS_output_filename); | |
132 } | |
133 | |
134 DEFINE_int32(duration, 60, "Duration of the test in seconds."); | |
135 int DurationSecs() { | |
136 return static_cast<int>(FLAGS_duration); | |
137 } | |
138 | |
139 DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation"); | |
140 | |
141 } // namespace flags | 192 } // namespace flags |
142 | 193 |
143 void Loopback() { | 194 void Loopback() { |
144 FakeNetworkPipe::Config pipe_config; | 195 FakeNetworkPipe::Config pipe_config; |
145 pipe_config.loss_percent = flags::LossPercent(); | 196 pipe_config.loss_percent = flags::LossPercent(); |
146 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps(); | 197 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps(); |
147 pipe_config.queue_length_packets = flags::QueueSize(); | 198 pipe_config.queue_length_packets = flags::QueueSize(); |
148 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs(); | 199 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs(); |
149 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs(); | 200 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs(); |
150 | 201 |
151 Call::Config::BitrateConfig call_bitrate_config; | 202 Call::Config::BitrateConfig call_bitrate_config; |
152 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000; | 203 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000; |
153 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000; | 204 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000; |
154 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000; | 205 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000; |
155 | 206 |
156 std::string clip = flags::Clip(); | |
157 std::string graph_title = clip.empty() ? "" : "video " + clip; | |
158 VideoQualityTest::Params params{ | 207 VideoQualityTest::Params params{ |
159 {flags::Width(), flags::Height(), flags::Fps(), | 208 {flags::Width(), flags::Height(), flags::Fps(), |
160 flags::MinBitrateKbps() * 1000, flags::TargetBitrateKbps() * 1000, | 209 flags::MinBitrateKbps() * 1000, flags::TargetBitrateKbps() * 1000, |
161 flags::MaxBitrateKbps() * 1000, flags::Codec(), | 210 flags::MaxBitrateKbps() * 1000, flags::Codec(), |
162 flags::NumTemporalLayers(), | 211 flags::NumTemporalLayers(), flags::SelectedTL(), |
163 0, // No min transmit bitrate. | 212 0, // No min transmit bitrate. |
164 call_bitrate_config, flags::TLDiscardThreshold(), | 213 call_bitrate_config, flags::FLAGS_send_side_bwe}, |
165 flags::FLAGS_send_side_bwe}, | 214 {flags::Clip()}, |
166 {clip}, | |
167 {}, // Screenshare specific. | 215 {}, // Screenshare specific. |
168 {graph_title, 0.0, 0.0, flags::DurationSecs(), flags::OutputFilename()}, | 216 {"video", 0.0, 0.0, flags::DurationSecs(), flags::OutputFilename(), |
| 217 flags::GraphTitle()}, |
169 pipe_config, | 218 pipe_config, |
170 flags::FLAGS_logs}; | 219 flags::FLAGS_logs}; |
171 | 220 |
| 221 std::vector<std::string> stream_descriptors; |
| 222 stream_descriptors.push_back(flags::Stream0()); |
| 223 stream_descriptors.push_back(flags::Stream1()); |
| 224 std::vector<std::string> SL_descriptors; |
| 225 SL_descriptors.push_back(flags::SL0()); |
| 226 SL_descriptors.push_back(flags::SL1()); |
| 227 VideoQualityTest::FillScalabilitySettings(¶ms, stream_descriptors, |
| 228 flags::SelectedStream(), flags::NumSpatialLayers(), flags::SelectedSL(), |
| 229 SL_descriptors); |
| 230 |
172 VideoQualityTest test; | 231 VideoQualityTest test; |
173 if (flags::OutputFilename().empty()) | 232 if (flags::DurationSecs()) |
| 233 test.RunWithAnalyzer(params); |
| 234 else |
174 test.RunWithVideoRenderer(params); | 235 test.RunWithVideoRenderer(params); |
175 else | |
176 test.RunWithAnalyzer(params); | |
177 } | 236 } |
178 } // namespace webrtc | 237 } // namespace webrtc |
179 | 238 |
180 int main(int argc, char* argv[]) { | 239 int main(int argc, char* argv[]) { |
181 ::testing::InitGoogleTest(&argc, argv); | 240 ::testing::InitGoogleTest(&argc, argv); |
182 google::ParseCommandLineFlags(&argc, &argv, true); | 241 google::ParseCommandLineFlags(&argc, &argv, true); |
183 webrtc::test::InitFieldTrialsFromString( | 242 webrtc::test::InitFieldTrialsFromString( |
184 webrtc::flags::FLAGS_force_fieldtrials); | 243 webrtc::flags::FLAGS_force_fieldtrials); |
185 webrtc::test::RunTest(webrtc::Loopback); | 244 webrtc::test::RunTest(webrtc::Loopback); |
186 return 0; | 245 return 0; |
187 } | 246 } |
OLD | NEW |