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. | |
24 DEFINE_int32(width, 640, "Video width."); | 23 DEFINE_int32(width, 640, "Video width."); |
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, 480, "Video height."); | 28 DEFINE_int32(height, 480, "Video height."); |
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 |
(...skipping 15 matching lines...) Expand all Loading... |
49 DEFINE_int32(target_bitrate, 800, "Stream target bitrate in kbps."); | 48 DEFINE_int32(target_bitrate, 800, "Stream target bitrate in kbps."); |
50 int TargetBitrateKbps() { | 49 int TargetBitrateKbps() { |
51 return static_cast<int>(FLAGS_target_bitrate); | 50 return static_cast<int>(FLAGS_target_bitrate); |
52 } | 51 } |
53 | 52 |
54 DEFINE_int32(max_bitrate, 800, "Call and stream max bitrate in kbps."); | 53 DEFINE_int32(max_bitrate, 800, "Call and stream max bitrate in kbps."); |
55 int MaxBitrateKbps() { | 54 int MaxBitrateKbps() { |
56 return static_cast<int>(FLAGS_max_bitrate); | 55 return static_cast<int>(FLAGS_max_bitrate); |
57 } | 56 } |
58 | 57 |
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. | |
67 DEFINE_string(codec, "VP8", "Video codec to use."); | 58 DEFINE_string(codec, "VP8", "Video codec to use."); |
68 std::string Codec() { | 59 std::string Codec() { |
69 return static_cast<std::string>(FLAGS_codec); | 60 return static_cast<std::string>(FLAGS_codec); |
70 } | 61 } |
71 | 62 |
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 | |
98 DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost."); | 63 DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost."); |
99 int LossPercent() { | 64 int LossPercent() { |
100 return static_cast<int>(FLAGS_loss_percent); | 65 return static_cast<int>(FLAGS_loss_percent); |
101 } | 66 } |
102 | 67 |
103 DEFINE_int32(link_capacity, | 68 DEFINE_int32(link_capacity, |
104 0, | 69 0, |
105 "Capacity (kbps) of the fake link. 0 means infinite."); | 70 "Capacity (kbps) of the fake link. 0 means infinite."); |
106 int LinkCapacityKbps() { | 71 int LinkCapacityKbps() { |
107 return static_cast<int>(FLAGS_link_capacity); | 72 return static_cast<int>(FLAGS_link_capacity); |
(...skipping 11 matching lines...) Expand all Loading... |
119 return static_cast<int>(FLAGS_avg_propagation_delay_ms); | 84 return static_cast<int>(FLAGS_avg_propagation_delay_ms); |
120 } | 85 } |
121 | 86 |
122 DEFINE_int32(std_propagation_delay_ms, | 87 DEFINE_int32(std_propagation_delay_ms, |
123 0, | 88 0, |
124 "Link propagation delay standard deviation in ms."); | 89 "Link propagation delay standard deviation in ms."); |
125 int StdPropagationDelayMs() { | 90 int StdPropagationDelayMs() { |
126 return static_cast<int>(FLAGS_std_propagation_delay_ms); | 91 return static_cast<int>(FLAGS_std_propagation_delay_ms); |
127 } | 92 } |
128 | 93 |
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 | |
172 DEFINE_bool(logs, false, "print logs to stderr"); | 94 DEFINE_bool(logs, false, "print logs to stderr"); |
173 | 95 |
174 DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation"); | |
175 | |
176 DEFINE_string( | 96 DEFINE_string( |
177 force_fieldtrials, | 97 force_fieldtrials, |
178 "", | 98 "", |
179 "Field trials control experimental feature code which can be forced. " | 99 "Field trials control experimental feature code which can be forced. " |
180 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" | 100 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" |
181 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple " | 101 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple " |
182 "trials are separated by \"/\""); | 102 "trials are separated by \"/\""); |
183 | 103 |
184 // Video-specific flags. | 104 DEFINE_int32(num_temporal_layers, |
| 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 |
185 DEFINE_string(clip, | 119 DEFINE_string(clip, |
186 "", | 120 "", |
187 "Name of the clip to show. If empty, using chroma generator."); | 121 "Name of the clip to show. If empty, using chroma generator."); |
188 std::string Clip() { | 122 std::string Clip() { |
189 return static_cast<std::string>(FLAGS_clip); | 123 return static_cast<std::string>(FLAGS_clip); |
190 } | 124 } |
191 | 125 |
| 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 |
192 } // namespace flags | 141 } // namespace flags |
193 | 142 |
194 void Loopback() { | 143 void Loopback() { |
195 FakeNetworkPipe::Config pipe_config; | 144 FakeNetworkPipe::Config pipe_config; |
196 pipe_config.loss_percent = flags::LossPercent(); | 145 pipe_config.loss_percent = flags::LossPercent(); |
197 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps(); | 146 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps(); |
198 pipe_config.queue_length_packets = flags::QueueSize(); | 147 pipe_config.queue_length_packets = flags::QueueSize(); |
199 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs(); | 148 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs(); |
200 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs(); | 149 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs(); |
201 | 150 |
202 Call::Config::BitrateConfig call_bitrate_config; | 151 Call::Config::BitrateConfig call_bitrate_config; |
203 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000; | 152 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000; |
204 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000; | 153 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000; |
205 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000; | 154 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000; |
206 | 155 |
| 156 std::string clip = flags::Clip(); |
| 157 std::string graph_title = clip.empty() ? "" : "video " + clip; |
207 VideoQualityTest::Params params{ | 158 VideoQualityTest::Params params{ |
208 {flags::Width(), flags::Height(), flags::Fps(), | 159 {flags::Width(), flags::Height(), flags::Fps(), |
209 flags::MinBitrateKbps() * 1000, flags::TargetBitrateKbps() * 1000, | 160 flags::MinBitrateKbps() * 1000, flags::TargetBitrateKbps() * 1000, |
210 flags::MaxBitrateKbps() * 1000, flags::Codec(), | 161 flags::MaxBitrateKbps() * 1000, flags::Codec(), |
211 flags::NumTemporalLayers(), flags::SelectedTL(), | 162 flags::NumTemporalLayers(), |
212 0, // No min transmit bitrate. | 163 0, // No min transmit bitrate. |
213 call_bitrate_config, flags::FLAGS_send_side_bwe}, | 164 call_bitrate_config, flags::TLDiscardThreshold(), |
214 {flags::Clip()}, | 165 flags::FLAGS_send_side_bwe}, |
| 166 {clip}, |
215 {}, // Screenshare specific. | 167 {}, // Screenshare specific. |
216 {"video", 0.0, 0.0, flags::DurationSecs(), flags::OutputFilename(), | 168 {graph_title, 0.0, 0.0, flags::DurationSecs(), flags::OutputFilename()}, |
217 flags::GraphTitle()}, | |
218 pipe_config, | 169 pipe_config, |
219 flags::FLAGS_logs}; | 170 flags::FLAGS_logs}; |
220 | 171 |
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 | |
231 VideoQualityTest test; | 172 VideoQualityTest test; |
232 if (flags::DurationSecs()) | 173 if (flags::OutputFilename().empty()) |
| 174 test.RunWithVideoRenderer(params); |
| 175 else |
233 test.RunWithAnalyzer(params); | 176 test.RunWithAnalyzer(params); |
234 else | |
235 test.RunWithVideoRenderer(params); | |
236 } | 177 } |
237 } // namespace webrtc | 178 } // namespace webrtc |
238 | 179 |
239 int main(int argc, char* argv[]) { | 180 int main(int argc, char* argv[]) { |
240 ::testing::InitGoogleTest(&argc, argv); | 181 ::testing::InitGoogleTest(&argc, argv); |
241 google::ParseCommandLineFlags(&argc, &argv, true); | 182 google::ParseCommandLineFlags(&argc, &argv, true); |
242 webrtc::test::InitFieldTrialsFromString( | 183 webrtc::test::InitFieldTrialsFromString( |
243 webrtc::flags::FLAGS_force_fieldtrials); | 184 webrtc::flags::FLAGS_force_fieldtrials); |
244 webrtc::test::RunTest(webrtc::Loopback); | 185 webrtc::test::RunTest(webrtc::Loopback); |
245 return 0; | 186 return 0; |
246 } | 187 } |
OLD | NEW |