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 video loopback, with different default values. | |
24 DEFINE_int32(width, 1850, "Video width (crops source)."); | 23 DEFINE_int32(width, 1850, "Video width (crops source)."); |
25 size_t Width() { | 24 size_t Width() { |
26 return static_cast<size_t>(FLAGS_width); | 25 return static_cast<size_t>(FLAGS_width); |
27 } | 26 } |
28 | 27 |
29 DEFINE_int32(height, 1110, "Video height (crops source)."); | 28 DEFINE_int32(height, 1110, "Video height (crops source)."); |
30 size_t Height() { | 29 size_t Height() { |
31 return static_cast<size_t>(FLAGS_height); | 30 return static_cast<size_t>(FLAGS_height); |
32 } | 31 } |
33 | 32 |
34 DEFINE_int32(fps, 5, "Frames per second."); | 33 DEFINE_int32(fps, 5, "Frames per second."); |
35 int Fps() { | 34 int Fps() { |
36 return static_cast<int>(FLAGS_fps); | 35 return static_cast<int>(FLAGS_fps); |
37 } | 36 } |
38 | 37 |
| 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 |
39 DEFINE_int32(min_bitrate, 50, "Call and stream min bitrate in kbps."); | 53 DEFINE_int32(min_bitrate, 50, "Call and stream min bitrate in kbps."); |
40 int MinBitrateKbps() { | 54 int MinBitrateKbps() { |
41 return static_cast<int>(FLAGS_min_bitrate); | 55 return static_cast<int>(FLAGS_min_bitrate); |
42 } | 56 } |
43 | 57 |
44 DEFINE_int32(start_bitrate, 200, "Call start bitrate in kbps."); | 58 DEFINE_int32(start_bitrate, 200, "Call start bitrate in kbps."); |
45 int StartBitrateKbps() { | 59 int StartBitrateKbps() { |
46 return static_cast<int>(FLAGS_start_bitrate); | 60 return static_cast<int>(FLAGS_start_bitrate); |
47 } | 61 } |
48 | 62 |
49 DEFINE_int32(target_bitrate, 2000, "Stream target bitrate in kbps."); | 63 DEFINE_int32(target_bitrate, 2000, "Stream target bitrate in kbps."); |
50 int TargetBitrateKbps() { | 64 int TargetBitrateKbps() { |
51 return static_cast<int>(FLAGS_target_bitrate); | 65 return static_cast<int>(FLAGS_target_bitrate); |
52 } | 66 } |
53 | 67 |
54 DEFINE_int32(max_bitrate, 2000, "Call and stream max bitrate in kbps."); | 68 DEFINE_int32(max_bitrate, 2000, "Call and stream max bitrate in kbps."); |
55 int MaxBitrateKbps() { | 69 int MaxBitrateKbps() { |
56 return static_cast<int>(FLAGS_max_bitrate); | 70 return static_cast<int>(FLAGS_max_bitrate); |
57 } | 71 } |
58 | 72 |
59 DEFINE_int32(num_temporal_layers, 2, "Number of temporal layers to use."); | 73 DEFINE_int32(num_temporal_layers, 2, "Number of temporal layers to use."); |
60 int NumTemporalLayers() { | 74 size_t NumTemporalLayers() { |
61 return static_cast<int>(FLAGS_num_temporal_layers); | 75 return static_cast<size_t>(FLAGS_num_temporal_layers); |
62 } | 76 } |
63 | 77 |
64 // Flags common with video loopback, with equal default values. | 78 DEFINE_int32( |
| 79 tl_discard_threshold, |
| 80 0, |
| 81 "Discard TLs with id greater or equal the threshold. 0 to disable."); |
| 82 size_t TLDiscardThreshold() { |
| 83 return static_cast<size_t>(FLAGS_tl_discard_threshold); |
| 84 } |
| 85 |
| 86 DEFINE_int32(min_transmit_bitrate, 400, "Min transmit bitrate incl. padding."); |
| 87 int MinTransmitBitrateKbps() { |
| 88 return FLAGS_min_transmit_bitrate; |
| 89 } |
| 90 |
65 DEFINE_string(codec, "VP8", "Video codec to use."); | 91 DEFINE_string(codec, "VP8", "Video codec to use."); |
66 std::string Codec() { | 92 std::string Codec() { |
67 return static_cast<std::string>(FLAGS_codec); | 93 return static_cast<std::string>(FLAGS_codec); |
68 } | 94 } |
69 | 95 |
70 DEFINE_int32(selected_tl, | |
71 -1, | |
72 "Temporal layer to show or analyze. -1 to disable filtering."); | |
73 int SelectedTL() { | |
74 return static_cast<int>(FLAGS_selected_tl); | |
75 } | |
76 | |
77 DEFINE_int32( | |
78 duration, | |
79 0, | |
80 "Duration of the test in seconds. If 0, rendered will be shown instead."); | |
81 int DurationSecs() { | |
82 return static_cast<int>(FLAGS_duration); | |
83 } | |
84 | |
85 DEFINE_string(output_filename, "", "Target graph data filename."); | |
86 std::string OutputFilename() { | |
87 return static_cast<std::string>(FLAGS_output_filename); | |
88 } | |
89 | |
90 DEFINE_string( | |
91 graph_title, "", "If empty, title will be generated automatically."); | |
92 std::string GraphTitle() { | |
93 return static_cast<std::string>(FLAGS_graph_title); | |
94 } | |
95 | |
96 DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost."); | 96 DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost."); |
97 int LossPercent() { | 97 int LossPercent() { |
98 return static_cast<int>(FLAGS_loss_percent); | 98 return static_cast<int>(FLAGS_loss_percent); |
99 } | 99 } |
100 | 100 |
101 DEFINE_int32(link_capacity, | 101 DEFINE_int32(link_capacity, |
102 0, | 102 0, |
103 "Capacity (kbps) of the fake link. 0 means infinite."); | 103 "Capacity (kbps) of the fake link. 0 means infinite."); |
104 int LinkCapacityKbps() { | 104 int LinkCapacityKbps() { |
105 return static_cast<int>(FLAGS_link_capacity); | 105 return static_cast<int>(FLAGS_link_capacity); |
(...skipping 11 matching lines...) Expand all Loading... |
117 return static_cast<int>(FLAGS_avg_propagation_delay_ms); | 117 return static_cast<int>(FLAGS_avg_propagation_delay_ms); |
118 } | 118 } |
119 | 119 |
120 DEFINE_int32(std_propagation_delay_ms, | 120 DEFINE_int32(std_propagation_delay_ms, |
121 0, | 121 0, |
122 "Link propagation delay standard deviation in ms."); | 122 "Link propagation delay standard deviation in ms."); |
123 int StdPropagationDelayMs() { | 123 int StdPropagationDelayMs() { |
124 return static_cast<int>(FLAGS_std_propagation_delay_ms); | 124 return static_cast<int>(FLAGS_std_propagation_delay_ms); |
125 } | 125 } |
126 | 126 |
127 DEFINE_int32(selected_stream, 0, "ID of the stream to show or analyze."); | |
128 int SelectedStream() { | |
129 return static_cast<int>(FLAGS_selected_stream); | |
130 } | |
131 | |
132 DEFINE_int32(num_spatial_layers, 1, "Number of spatial layers to use."); | |
133 int NumSpatialLayers() { | |
134 return static_cast<int>(FLAGS_num_spatial_layers); | |
135 } | |
136 | |
137 DEFINE_int32(selected_sl, | |
138 -1, | |
139 "Spatial layer to show or analyze. -1 to disable filtering."); | |
140 int SelectedSL() { | |
141 return static_cast<int>(FLAGS_selected_sl); | |
142 } | |
143 | |
144 DEFINE_string(stream0, | |
145 "", | |
146 "Comma separated values describing VideoStream for stream #0."); | |
147 std::string Stream0() { | |
148 return static_cast<std::string>(FLAGS_stream0); | |
149 } | |
150 | |
151 DEFINE_string(stream1, | |
152 "", | |
153 "Comma separated values describing VideoStream for stream #1."); | |
154 std::string Stream1() { | |
155 return static_cast<std::string>(FLAGS_stream1); | |
156 } | |
157 | |
158 DEFINE_string( | |
159 sl0, "", "Comma separated values describing SpatialLayer for layer #0."); | |
160 std::string SL0() { | |
161 return static_cast<std::string>(FLAGS_sl0); | |
162 } | |
163 | |
164 DEFINE_string( | |
165 sl1, "", "Comma separated values describing SpatialLayer for layer #1."); | |
166 std::string SL1() { | |
167 return static_cast<std::string>(FLAGS_sl1); | |
168 } | |
169 | |
170 DEFINE_bool(logs, false, "print logs to stderr"); | 127 DEFINE_bool(logs, false, "print logs to stderr"); |
171 | 128 |
| 129 DEFINE_string( |
| 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 |
172 DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation"); | 142 DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation"); |
173 | 143 |
174 DEFINE_string( | 144 DEFINE_string( |
175 force_fieldtrials, | 145 force_fieldtrials, |
176 "", | 146 "", |
177 "Field trials control experimental feature code which can be forced. " | 147 "Field trials control experimental feature code which can be forced. " |
178 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" | 148 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" |
179 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple " | 149 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple " |
180 "trials are separated by \"/\""); | 150 "trials are separated by \"/\""); |
181 | |
182 // Screenshare-specific flags. | |
183 DEFINE_int32(min_transmit_bitrate, 400, "Min transmit bitrate incl. padding."); | |
184 int MinTransmitBitrateKbps() { | |
185 return FLAGS_min_transmit_bitrate; | |
186 } | |
187 | |
188 DEFINE_int32(slide_change_interval, | |
189 10, | |
190 "Interval (in seconds) between simulated slide changes."); | |
191 int SlideChangeInterval() { | |
192 return static_cast<int>(FLAGS_slide_change_interval); | |
193 } | |
194 | |
195 DEFINE_int32( | |
196 scroll_duration, | |
197 0, | |
198 "Duration (in seconds) during which a slide will be scrolled into place."); | |
199 int ScrollDuration() { | |
200 return static_cast<int>(FLAGS_scroll_duration); | |
201 } | |
202 | |
203 } // namespace flags | 151 } // namespace flags |
204 | 152 |
205 void Loopback() { | 153 void Loopback() { |
206 FakeNetworkPipe::Config pipe_config; | 154 FakeNetworkPipe::Config pipe_config; |
207 pipe_config.loss_percent = flags::LossPercent(); | 155 pipe_config.loss_percent = flags::LossPercent(); |
208 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps(); | 156 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps(); |
209 pipe_config.queue_length_packets = flags::QueueSize(); | 157 pipe_config.queue_length_packets = flags::QueueSize(); |
210 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs(); | 158 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs(); |
211 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs(); | 159 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs(); |
212 | 160 |
213 Call::Config::BitrateConfig call_bitrate_config; | 161 Call::Config::BitrateConfig call_bitrate_config; |
214 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000; | 162 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000; |
215 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000; | 163 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000; |
216 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000; | 164 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000; |
217 | 165 |
218 VideoQualityTest::Params params{ | 166 VideoQualityTest::Params params{ |
219 {flags::Width(), flags::Height(), flags::Fps(), | 167 {flags::Width(), flags::Height(), flags::Fps(), |
220 flags::MinBitrateKbps() * 1000, flags::TargetBitrateKbps() * 1000, | 168 flags::MinBitrateKbps() * 1000, flags::TargetBitrateKbps() * 1000, |
221 flags::MaxBitrateKbps() * 1000, flags::Codec(), | 169 flags::MaxBitrateKbps() * 1000, flags::Codec(), |
222 flags::NumTemporalLayers(), flags::SelectedTL(), | 170 flags::NumTemporalLayers(), flags::MinTransmitBitrateKbps() * 1000, |
223 flags::MinTransmitBitrateKbps() * 1000, call_bitrate_config, | 171 call_bitrate_config, flags::TLDiscardThreshold(), |
224 flags::FLAGS_send_side_bwe}, | 172 flags::FLAGS_send_side_bwe}, |
225 {}, // Video specific. | 173 {}, // Video specific. |
226 {true, flags::SlideChangeInterval(), flags::ScrollDuration()}, | 174 {true, flags::SlideChangeInterval(), flags::ScrollDuration()}, |
227 {"screenshare", 0.0, 0.0, flags::DurationSecs(), flags::OutputFilename(), | 175 {"screenshare", 0.0, 0.0, flags::DurationSecs(), flags::OutputFilename()}, |
228 flags::GraphTitle()}, | |
229 pipe_config, | 176 pipe_config, |
230 flags::FLAGS_logs}; | 177 flags::FLAGS_logs}; |
231 | 178 |
232 std::vector<std::string> stream_descriptors; | |
233 stream_descriptors.push_back(flags::Stream0()); | |
234 stream_descriptors.push_back(flags::Stream1()); | |
235 std::vector<std::string> SL_descriptors; | |
236 SL_descriptors.push_back(flags::SL0()); | |
237 SL_descriptors.push_back(flags::SL1()); | |
238 VideoQualityTest::FillScalabilitySettings(¶ms, stream_descriptors, | |
239 flags::SelectedStream(), flags::NumSpatialLayers(), flags::SelectedSL(), | |
240 SL_descriptors); | |
241 | |
242 VideoQualityTest test; | 179 VideoQualityTest test; |
243 if (flags::DurationSecs()) | 180 if (flags::OutputFilename().empty()) |
| 181 test.RunWithVideoRenderer(params); |
| 182 else |
244 test.RunWithAnalyzer(params); | 183 test.RunWithAnalyzer(params); |
245 else | |
246 test.RunWithVideoRenderer(params); | |
247 } | 184 } |
248 } // namespace webrtc | 185 } // namespace webrtc |
249 | 186 |
250 int main(int argc, char* argv[]) { | 187 int main(int argc, char* argv[]) { |
251 ::testing::InitGoogleTest(&argc, argv); | 188 ::testing::InitGoogleTest(&argc, argv); |
252 google::ParseCommandLineFlags(&argc, &argv, true); | 189 google::ParseCommandLineFlags(&argc, &argv, true); |
253 webrtc::test::InitFieldTrialsFromString( | 190 webrtc::test::InitFieldTrialsFromString( |
254 webrtc::flags::FLAGS_force_fieldtrials); | 191 webrtc::flags::FLAGS_force_fieldtrials); |
255 webrtc::test::RunTest(webrtc::Loopback); | 192 webrtc::test::RunTest(webrtc::Loopback); |
256 return 0; | 193 return 0; |
257 } | 194 } |
OLD | NEW |