Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: webrtc/video/video_loopback.cc

Issue 2946893003: What can't loopback test be more like full stack test? (Closed)
Patch Set: Explicit cast to make win happy Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/screenshare_loopback.cc ('k') | webrtc/video/video_quality_test.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "webrtc/base/flags.h"
14 #include "webrtc/test/field_trial.h" 14 #include "webrtc/test/field_trial.h"
15 #include "webrtc/test/gtest.h" 15 #include "webrtc/test/gtest.h"
16 #include "webrtc/test/run_test.h" 16 #include "webrtc/test/run_test.h"
17 #include "webrtc/video/video_quality_test.h" 17 #include "webrtc/video/video_quality_test.h"
18 18
19 namespace webrtc { 19 namespace webrtc {
20 namespace flags { 20 namespace flags {
21 21
22 // Flags common with screenshare loopback, with different default values. 22 // Flags common with screenshare loopback, with different default values.
23 DEFINE_int32(width, 640, "Video width."); 23 DEFINE_int(width, 640, "Video width.");
24 size_t Width() { 24 size_t Width() {
25 return static_cast<size_t>(FLAGS_width); 25 return static_cast<size_t>(FLAG_width);
26 } 26 }
27 27
28 DEFINE_int32(height, 480, "Video height."); 28 DEFINE_int(height, 480, "Video height.");
29 size_t Height() { 29 size_t Height() {
30 return static_cast<size_t>(FLAGS_height); 30 return static_cast<size_t>(FLAG_height);
31 } 31 }
32 32
33 DEFINE_int32(fps, 30, "Frames per second."); 33 DEFINE_int(fps, 30, "Frames per second.");
34 int Fps() { 34 int Fps() {
35 return static_cast<int>(FLAGS_fps); 35 return static_cast<int>(FLAG_fps);
36 } 36 }
37 37
38 DEFINE_int32(capture_device_index, 0, "Capture device to select"); 38 DEFINE_int(capture_device_index, 0, "Capture device to select");
39 size_t GetCaptureDevice() { 39 size_t GetCaptureDevice() {
40 return static_cast<size_t>(FLAGS_capture_device_index); 40 return static_cast<size_t>(FLAG_capture_device_index);
41 } 41 }
42 42
43 DEFINE_int32(min_bitrate, 50, "Call and stream min bitrate in kbps."); 43 DEFINE_int(min_bitrate, 50, "Call and stream min bitrate in kbps.");
44 int MinBitrateKbps() { 44 int MinBitrateKbps() {
45 return static_cast<int>(FLAGS_min_bitrate); 45 return static_cast<int>(FLAG_min_bitrate);
46 } 46 }
47 47
48 DEFINE_int32(start_bitrate, 300, "Call start bitrate in kbps."); 48 DEFINE_int(start_bitrate, 300, "Call start bitrate in kbps.");
49 int StartBitrateKbps() { 49 int StartBitrateKbps() {
50 return static_cast<int>(FLAGS_start_bitrate); 50 return static_cast<int>(FLAG_start_bitrate);
51 } 51 }
52 52
53 DEFINE_int32(target_bitrate, 800, "Stream target bitrate in kbps."); 53 DEFINE_int(target_bitrate, 800, "Stream target bitrate in kbps.");
54 int TargetBitrateKbps() { 54 int TargetBitrateKbps() {
55 return static_cast<int>(FLAGS_target_bitrate); 55 return static_cast<int>(FLAG_target_bitrate);
56 } 56 }
57 57
58 DEFINE_int32(max_bitrate, 800, "Call and stream max bitrate in kbps."); 58 DEFINE_int(max_bitrate, 800, "Call and stream max bitrate in kbps.");
59 int MaxBitrateKbps() { 59 int MaxBitrateKbps() {
60 return static_cast<int>(FLAGS_max_bitrate); 60 return static_cast<int>(FLAG_max_bitrate);
61 } 61 }
62 62
63 DEFINE_bool(suspend_below_min_bitrate, 63 DEFINE_bool(suspend_below_min_bitrate,
64 false, 64 false,
65 "Suspends video below the configured min bitrate."); 65 "Suspends video below the configured min bitrate.");
66 66
67 DEFINE_int32(num_temporal_layers, 67 DEFINE_int(num_temporal_layers,
68 1, 68 1,
69 "Number of temporal layers. Set to 1-4 to override."); 69 "Number of temporal layers. Set to 1-4 to override.");
70 int NumTemporalLayers() { 70 int NumTemporalLayers() {
71 return static_cast<int>(FLAGS_num_temporal_layers); 71 return static_cast<int>(FLAG_num_temporal_layers);
72 } 72 }
73 73
74 // Flags common with screenshare loopback, with equal default values. 74 // Flags common with screenshare loopback, with equal default values.
75 DEFINE_string(codec, "VP8", "Video codec to use."); 75 DEFINE_string(codec, "VP8", "Video codec to use.");
76 std::string Codec() { 76 std::string Codec() {
77 return static_cast<std::string>(FLAGS_codec); 77 return static_cast<std::string>(FLAG_codec);
78 } 78 }
79 79
80 DEFINE_int32(selected_tl, 80 DEFINE_int(selected_tl,
81 -1, 81 -1,
82 "Temporal layer to show or analyze. -1 to disable filtering."); 82 "Temporal layer to show or analyze. -1 to disable filtering.");
83 int SelectedTL() { 83 int SelectedTL() {
84 return static_cast<int>(FLAGS_selected_tl); 84 return static_cast<int>(FLAG_selected_tl);
85 } 85 }
86 86
87 DEFINE_int32( 87 DEFINE_int(
88 duration, 88 duration,
89 0, 89 0,
90 "Duration of the test in seconds. If 0, rendered will be shown instead."); 90 "Duration of the test in seconds. If 0, rendered will be shown instead.");
91 int DurationSecs() { 91 int DurationSecs() {
92 return static_cast<int>(FLAGS_duration); 92 return static_cast<int>(FLAG_duration);
93 } 93 }
94 94
95 DEFINE_string(output_filename, "", "Target graph data filename."); 95 DEFINE_string(output_filename, "", "Target graph data filename.");
96 std::string OutputFilename() { 96 std::string OutputFilename() {
97 return static_cast<std::string>(FLAGS_output_filename); 97 return static_cast<std::string>(FLAG_output_filename);
98 } 98 }
99 99
100 DEFINE_string(graph_title, 100 DEFINE_string(graph_title,
101 "", 101 "",
102 "If empty, title will be generated automatically."); 102 "If empty, title will be generated automatically.");
103 std::string GraphTitle() { 103 std::string GraphTitle() {
104 return static_cast<std::string>(FLAGS_graph_title); 104 return static_cast<std::string>(FLAG_graph_title);
105 } 105 }
106 106
107 DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost."); 107 DEFINE_int(loss_percent, 0, "Percentage of packets randomly lost.");
108 int LossPercent() { 108 int LossPercent() {
109 return static_cast<int>(FLAGS_loss_percent); 109 return static_cast<int>(FLAG_loss_percent);
110 } 110 }
111 111
112 DEFINE_int32(avg_burst_loss_length, 112 DEFINE_int(avg_burst_loss_length, -1, "Average burst length of lost packets.");
113 -1,
114 "Average burst length of lost packets.");
115 int AvgBurstLossLength() { 113 int AvgBurstLossLength() {
116 return static_cast<int>(FLAGS_avg_burst_loss_length); 114 return static_cast<int>(FLAG_avg_burst_loss_length);
117 } 115 }
118 116
119 DEFINE_int32(link_capacity, 117 DEFINE_int(link_capacity,
120 0, 118 0,
121 "Capacity (kbps) of the fake link. 0 means infinite."); 119 "Capacity (kbps) of the fake link. 0 means infinite.");
122 int LinkCapacityKbps() { 120 int LinkCapacityKbps() {
123 return static_cast<int>(FLAGS_link_capacity); 121 return static_cast<int>(FLAG_link_capacity);
124 } 122 }
125 123
126 DEFINE_int32(queue_size, 0, "Size of the bottleneck link queue in packets."); 124 DEFINE_int(queue_size, 0, "Size of the bottleneck link queue in packets.");
127 int QueueSize() { 125 int QueueSize() {
128 return static_cast<int>(FLAGS_queue_size); 126 return static_cast<int>(FLAG_queue_size);
129 } 127 }
130 128
131 DEFINE_int32(avg_propagation_delay_ms, 129 DEFINE_int(avg_propagation_delay_ms,
132 0, 130 0,
133 "Average link propagation delay in ms."); 131 "Average link propagation delay in ms.");
134 int AvgPropagationDelayMs() { 132 int AvgPropagationDelayMs() {
135 return static_cast<int>(FLAGS_avg_propagation_delay_ms); 133 return static_cast<int>(FLAG_avg_propagation_delay_ms);
136 } 134 }
137 135
138 DEFINE_int32(std_propagation_delay_ms, 136 DEFINE_int(std_propagation_delay_ms,
139 0, 137 0,
140 "Link propagation delay standard deviation in ms."); 138 "Link propagation delay standard deviation in ms.");
141 int StdPropagationDelayMs() { 139 int StdPropagationDelayMs() {
142 return static_cast<int>(FLAGS_std_propagation_delay_ms); 140 return static_cast<int>(FLAG_std_propagation_delay_ms);
143 } 141 }
144 142
145 DEFINE_int32(selected_stream, 0, "ID of the stream to show or analyze."); 143 DEFINE_int(num_streams, 0, "Number of streams to show or analyze.");
146 int SelectedStream() { 144 int NumStreams() {
147 return static_cast<int>(FLAGS_selected_stream); 145 return static_cast<int>(FLAG_num_streams);
148 } 146 }
149 147
150 DEFINE_int32(num_spatial_layers, 1, "Number of spatial layers to use."); 148 DEFINE_int(selected_stream,
151 int NumSpatialLayers() { 149 0,
152 return static_cast<int>(FLAGS_num_spatial_layers); 150 "ID of the stream to show or analyze. "
151 "Set to the number of streams to show them all.");
152 int SelectedStream() {
153 return static_cast<int>(FLAG_selected_stream);
153 } 154 }
154 155
155 DEFINE_int32(selected_sl, 156 DEFINE_int(num_spatial_layers, 1, "Number of spatial layers to use.");
156 -1, 157 int NumSpatialLayers() {
157 "Spatial layer to show or analyze. -1 to disable filtering."); 158 return static_cast<int>(FLAG_num_spatial_layers);
159 }
160
161 DEFINE_int(selected_sl,
162 -1,
163 "Spatial layer to show or analyze. -1 to disable filtering.");
158 int SelectedSL() { 164 int SelectedSL() {
159 return static_cast<int>(FLAGS_selected_sl); 165 return static_cast<int>(FLAG_selected_sl);
160 } 166 }
161 167
162 DEFINE_string(stream0, 168 DEFINE_string(stream0,
163 "", 169 "",
164 "Comma separated values describing VideoStream for stream #0."); 170 "Comma separated values describing VideoStream for stream #0.");
165 std::string Stream0() { 171 std::string Stream0() {
166 return static_cast<std::string>(FLAGS_stream0); 172 return static_cast<std::string>(FLAG_stream0);
167 } 173 }
168 174
169 DEFINE_string(stream1, 175 DEFINE_string(stream1,
170 "", 176 "",
171 "Comma separated values describing VideoStream for stream #1."); 177 "Comma separated values describing VideoStream for stream #1.");
172 std::string Stream1() { 178 std::string Stream1() {
173 return static_cast<std::string>(FLAGS_stream1); 179 return static_cast<std::string>(FLAG_stream1);
174 } 180 }
175 181
176 DEFINE_string(sl0, 182 DEFINE_string(sl0,
177 "", 183 "",
178 "Comma separated values describing SpatialLayer for layer #0."); 184 "Comma separated values describing SpatialLayer for layer #0.");
179 std::string SL0() { 185 std::string SL0() {
180 return static_cast<std::string>(FLAGS_sl0); 186 return static_cast<std::string>(FLAG_sl0);
181 } 187 }
182 188
183 DEFINE_string(sl1, 189 DEFINE_string(sl1,
184 "", 190 "",
185 "Comma separated values describing SpatialLayer for layer #1."); 191 "Comma separated values describing SpatialLayer for layer #1.");
186 std::string SL1() { 192 std::string SL1() {
187 return static_cast<std::string>(FLAGS_sl1); 193 return static_cast<std::string>(FLAG_sl1);
188 } 194 }
189 195
190 DEFINE_string(encoded_frame_path, 196 DEFINE_string(encoded_frame_path,
191 "", 197 "",
192 "The base path for encoded frame logs. Created files will have " 198 "The base path for encoded frame logs. Created files will have "
193 "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf"); 199 "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf");
194 std::string EncodedFramePath() { 200 std::string EncodedFramePath() {
195 return static_cast<std::string>(FLAGS_encoded_frame_path); 201 return static_cast<std::string>(FLAG_encoded_frame_path);
196 } 202 }
197 203
198 DEFINE_bool(logs, false, "print logs to stderr"); 204 DEFINE_bool(logs, false, "print logs to stderr");
199 205
200 DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation"); 206 DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation");
201 207
202 DEFINE_bool(allow_reordering, false, "Allow packet reordering to occur"); 208 DEFINE_bool(allow_reordering, false, "Allow packet reordering to occur");
203 209
204 DEFINE_bool(use_ulpfec, false, "Use RED+ULPFEC forward error correction."); 210 DEFINE_bool(use_ulpfec, false, "Use RED+ULPFEC forward error correction.");
205 211
(...skipping 14 matching lines...) Expand all
220 "Field trials control experimental feature code which can be forced. " 226 "Field trials control experimental feature code which can be forced. "
221 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" 227 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
222 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple " 228 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple "
223 "trials are separated by \"/\""); 229 "trials are separated by \"/\"");
224 230
225 // Video-specific flags. 231 // Video-specific flags.
226 DEFINE_string(clip, 232 DEFINE_string(clip,
227 "", 233 "",
228 "Name of the clip to show. If empty, using chroma generator."); 234 "Name of the clip to show. If empty, using chroma generator.");
229 std::string Clip() { 235 std::string Clip() {
230 return static_cast<std::string>(FLAGS_clip); 236 return static_cast<std::string>(FLAG_clip);
231 } 237 }
232 238
239 DEFINE_bool(help, false, "prints this message");
240
233 } // namespace flags 241 } // namespace flags
234 242
235 void Loopback() { 243 void Loopback() {
236 FakeNetworkPipe::Config pipe_config; 244 FakeNetworkPipe::Config pipe_config;
237 pipe_config.loss_percent = flags::LossPercent(); 245 pipe_config.loss_percent = flags::LossPercent();
238 pipe_config.avg_burst_loss_length = flags::AvgBurstLossLength(); 246 pipe_config.avg_burst_loss_length = flags::AvgBurstLossLength();
239 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps(); 247 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps();
240 pipe_config.queue_length_packets = flags::QueueSize(); 248 pipe_config.queue_length_packets = flags::QueueSize();
241 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs(); 249 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs();
242 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs(); 250 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs();
243 pipe_config.allow_reordering = flags::FLAGS_allow_reordering; 251 pipe_config.allow_reordering = flags::FLAG_allow_reordering;
244 252
245 Call::Config::BitrateConfig call_bitrate_config; 253 Call::Config::BitrateConfig call_bitrate_config;
246 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000; 254 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000;
247 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000; 255 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000;
248 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000; 256 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000;
249 257
250 VideoQualityTest::Params params; 258 VideoQualityTest::Params params;
251 params.call = {flags::FLAGS_send_side_bwe, call_bitrate_config}; 259 params.call = {flags::FLAG_send_side_bwe, call_bitrate_config};
252 params.video = {flags::FLAGS_video, 260 params.video = {flags::FLAG_video,
253 flags::Width(), 261 flags::Width(),
254 flags::Height(), 262 flags::Height(),
255 flags::Fps(), 263 flags::Fps(),
256 flags::MinBitrateKbps() * 1000, 264 flags::MinBitrateKbps() * 1000,
257 flags::TargetBitrateKbps() * 1000, 265 flags::TargetBitrateKbps() * 1000,
258 flags::MaxBitrateKbps() * 1000, 266 flags::MaxBitrateKbps() * 1000,
259 flags::FLAGS_suspend_below_min_bitrate, 267 flags::FLAG_suspend_below_min_bitrate,
260 flags::Codec(), 268 flags::Codec(),
261 flags::NumTemporalLayers(), 269 flags::NumTemporalLayers(),
262 flags::SelectedTL(), 270 flags::SelectedTL(),
263 0, // No min transmit bitrate. 271 0, // No min transmit bitrate.
264 flags::FLAGS_use_ulpfec, 272 flags::FLAG_use_ulpfec,
265 flags::FLAGS_use_flexfec, 273 flags::FLAG_use_flexfec,
266 flags::EncodedFramePath(), 274 flags::EncodedFramePath(),
267 flags::Clip(), 275 flags::Clip(),
268 flags::GetCaptureDevice()}; 276 flags::GetCaptureDevice()};
269 params.audio = {flags::FLAGS_audio, flags::FLAGS_audio_video_sync, 277 params.audio = {flags::FLAG_audio, flags::FLAG_audio_video_sync,
270 flags::FLAGS_audio_dtx}; 278 flags::FLAG_audio_dtx};
271 params.screenshare.enabled = false; 279 params.screenshare.enabled = false;
272 params.analyzer = {"video", 0.0, 0.0, flags::DurationSecs(), 280 params.analyzer = {"video", 0.0, 0.0, flags::DurationSecs(),
273 flags::OutputFilename(), flags::GraphTitle()}; 281 flags::OutputFilename(), flags::GraphTitle()};
274 params.pipe = pipe_config; 282 params.pipe = pipe_config;
275 params.logs = flags::FLAGS_logs; 283 params.logs = flags::FLAG_logs;
284
285 if (flags::NumStreams() > 1 && flags::Stream0().empty() &&
286 flags::Stream1().empty()) {
287 params.ss.infer_streams = true;
288 }
276 289
277 std::vector<std::string> stream_descriptors; 290 std::vector<std::string> stream_descriptors;
278 stream_descriptors.push_back(flags::Stream0()); 291 stream_descriptors.push_back(flags::Stream0());
279 stream_descriptors.push_back(flags::Stream1()); 292 stream_descriptors.push_back(flags::Stream1());
280 std::vector<std::string> SL_descriptors; 293 std::vector<std::string> SL_descriptors;
281 SL_descriptors.push_back(flags::SL0()); 294 SL_descriptors.push_back(flags::SL0());
282 SL_descriptors.push_back(flags::SL1()); 295 SL_descriptors.push_back(flags::SL1());
283 VideoQualityTest::FillScalabilitySettings( 296 VideoQualityTest::FillScalabilitySettings(
284 &params, stream_descriptors, flags::SelectedStream(), 297 &params, stream_descriptors, flags::NumStreams(), flags::SelectedStream(),
285 flags::NumSpatialLayers(), flags::SelectedSL(), SL_descriptors); 298 flags::NumSpatialLayers(), flags::SelectedSL(), SL_descriptors);
286 299
287 VideoQualityTest test; 300 VideoQualityTest test;
288 if (flags::DurationSecs()) { 301 if (flags::DurationSecs()) {
289 test.RunWithAnalyzer(params); 302 test.RunWithAnalyzer(params);
290 } else { 303 } else {
291 test.RunWithRenderers(params); 304 test.RunWithRenderers(params);
292 } 305 }
293 } 306 }
294 } // namespace webrtc 307 } // namespace webrtc
295 308
296 int main(int argc, char* argv[]) { 309 int main(int argc, char* argv[]) {
297 ::testing::InitGoogleTest(&argc, argv); 310 ::testing::InitGoogleTest(&argc, argv);
298 google::ParseCommandLineFlags(&argc, &argv, true); 311 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
299 webrtc::test::InitFieldTrialsFromString( 312 if (webrtc::flags::FLAG_help) {
300 webrtc::flags::FLAGS_force_fieldtrials); 313 rtc::FlagList::Print(nullptr, false);
314 return 0;
315 }
316
317 // InitFieldTrialsFromString needs a reference to an std::string instance,
318 // with a scope that outlives the test.
319 std::string field_trials = webrtc::flags::FLAG_force_fieldtrials;
320 webrtc::test::InitFieldTrialsFromString(field_trials);
301 webrtc::test::RunTest(webrtc::Loopback); 321 webrtc::test::RunTest(webrtc::Loopback);
302 return 0; 322 return 0;
303 } 323 }
OLDNEW
« no previous file with comments | « webrtc/video/screenshare_loopback.cc ('k') | webrtc/video/video_quality_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698