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

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

Issue 2888643003: Remove gflags dependency for screenshare_loopback (Closed)
Patch Set: Created 3 years, 7 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/BUILD.gn ('k') | no next file » | 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/base/stringencode.h" 14 #include "webrtc/base/stringencode.h"
15 #include "webrtc/test/field_trial.h" 15 #include "webrtc/test/field_trial.h"
16 #include "webrtc/test/gtest.h" 16 #include "webrtc/test/gtest.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. 23 // Flags common with video loopback, with different default values.
24 DEFINE_int32(width, 1850, "Video width (crops source)."); 24 DEFINE_int(width, 1850, "Video width (crops source).");
25 size_t Width() { 25 size_t Width() {
26 return static_cast<size_t>(FLAGS_width); 26 return static_cast<size_t>(FLAG_width);
27 } 27 }
28 28
29 DEFINE_int32(height, 1110, "Video height (crops source)."); 29 DEFINE_int(height, 1110, "Video height (crops source).");
30 size_t Height() { 30 size_t Height() {
31 return static_cast<size_t>(FLAGS_height); 31 return static_cast<size_t>(FLAG_height);
32 } 32 }
33 33
34 DEFINE_int32(fps, 5, "Frames per second."); 34 DEFINE_int(fps, 5, "Frames per second.");
35 int Fps() { 35 int Fps() {
36 return static_cast<int>(FLAGS_fps); 36 return static_cast<int>(FLAG_fps);
37 } 37 }
38 38
39 DEFINE_int32(min_bitrate, 50, "Call and stream min bitrate in kbps."); 39 DEFINE_int(min_bitrate, 50, "Call and stream min bitrate in kbps.");
40 int MinBitrateKbps() { 40 int MinBitrateKbps() {
41 return static_cast<int>(FLAGS_min_bitrate); 41 return static_cast<int>(FLAG_min_bitrate);
42 } 42 }
43 43
44 DEFINE_int32(start_bitrate, 44 DEFINE_int(start_bitrate,
45 Call::Config::kDefaultStartBitrateBps / 1000, 45 Call::Config::kDefaultStartBitrateBps / 1000,
46 "Call start bitrate in kbps."); 46 "Call start bitrate in kbps.");
47 int StartBitrateKbps() { 47 int StartBitrateKbps() {
48 return static_cast<int>(FLAGS_start_bitrate); 48 return static_cast<int>(FLAG_start_bitrate);
49 } 49 }
50 50
51 DEFINE_int32(target_bitrate, 200, "Stream target bitrate in kbps."); 51 DEFINE_int(target_bitrate, 200, "Stream target bitrate in kbps.");
52 int TargetBitrateKbps() { 52 int TargetBitrateKbps() {
53 return static_cast<int>(FLAGS_target_bitrate); 53 return static_cast<int>(FLAG_target_bitrate);
54 } 54 }
55 55
56 DEFINE_int32(max_bitrate, 2000, "Call and stream max bitrate in kbps."); 56 DEFINE_int(max_bitrate, 2000, "Call and stream max bitrate in kbps.");
57 int MaxBitrateKbps() { 57 int MaxBitrateKbps() {
58 return static_cast<int>(FLAGS_max_bitrate); 58 return static_cast<int>(FLAG_max_bitrate);
59 } 59 }
60 60
61 DEFINE_int32(num_temporal_layers, 2, "Number of temporal layers to use."); 61 DEFINE_int(num_temporal_layers, 2, "Number of temporal layers to use.");
62 int NumTemporalLayers() { 62 int NumTemporalLayers() {
63 return static_cast<int>(FLAGS_num_temporal_layers); 63 return static_cast<int>(FLAG_num_temporal_layers);
64 } 64 }
65 65
66 // Flags common with video loopback, with equal default values. 66 // Flags common with video loopback, with equal default values.
67 DEFINE_string(codec, "VP8", "Video codec to use."); 67 DEFINE_string(codec, "VP8", "Video codec to use.");
68 std::string Codec() { 68 std::string Codec() {
69 return static_cast<std::string>(FLAGS_codec); 69 return static_cast<std::string>(FLAG_codec);
70 } 70 }
71 71
72 DEFINE_int32(selected_tl, 72 DEFINE_int(selected_tl,
73 -1, 73 -1,
74 "Temporal layer to show or analyze. -1 to disable filtering."); 74 "Temporal layer to show or analyze. -1 to disable filtering.");
75 int SelectedTL() { 75 int SelectedTL() {
76 return static_cast<int>(FLAGS_selected_tl); 76 return static_cast<int>(FLAG_selected_tl);
77 } 77 }
78 78
79 DEFINE_int32( 79 DEFINE_int(
80 duration, 80 duration,
81 0, 81 0,
82 "Duration of the test in seconds. If 0, rendered will be shown instead."); 82 "Duration of the test in seconds. If 0, rendered will be shown instead.");
83 int DurationSecs() { 83 int DurationSecs() {
84 return static_cast<int>(FLAGS_duration); 84 return static_cast<int>(FLAG_duration);
85 } 85 }
86 86
87 DEFINE_string(output_filename, "", "Target graph data filename."); 87 DEFINE_string(output_filename, "", "Target graph data filename.");
88 std::string OutputFilename() { 88 std::string OutputFilename() {
89 return static_cast<std::string>(FLAGS_output_filename); 89 return static_cast<std::string>(FLAG_output_filename);
90 } 90 }
91 91
92 DEFINE_string(graph_title, 92 DEFINE_string(graph_title,
93 "", 93 "",
94 "If empty, title will be generated automatically."); 94 "If empty, title will be generated automatically.");
95 std::string GraphTitle() { 95 std::string GraphTitle() {
96 return static_cast<std::string>(FLAGS_graph_title); 96 return static_cast<std::string>(FLAG_graph_title);
97 } 97 }
98 98
99 DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost."); 99 DEFINE_int(loss_percent, 0, "Percentage of packets randomly lost.");
100 int LossPercent() { 100 int LossPercent() {
101 return static_cast<int>(FLAGS_loss_percent); 101 return static_cast<int>(FLAG_loss_percent);
102 } 102 }
103 103
104 DEFINE_int32(link_capacity, 104 DEFINE_int(link_capacity,
105 0, 105 0,
106 "Capacity (kbps) of the fake link. 0 means infinite."); 106 "Capacity (kbps) of the fake link. 0 means infinite.");
107 int LinkCapacityKbps() { 107 int LinkCapacityKbps() {
108 return static_cast<int>(FLAGS_link_capacity); 108 return static_cast<int>(FLAG_link_capacity);
109 } 109 }
110 110
111 DEFINE_int32(queue_size, 0, "Size of the bottleneck link queue in packets."); 111 DEFINE_int(queue_size, 0, "Size of the bottleneck link queue in packets.");
112 int QueueSize() { 112 int QueueSize() {
113 return static_cast<int>(FLAGS_queue_size); 113 return static_cast<int>(FLAG_queue_size);
114 } 114 }
115 115
116 DEFINE_int32(avg_propagation_delay_ms, 116 DEFINE_int(avg_propagation_delay_ms,
117 0, 117 0,
118 "Average link propagation delay in ms."); 118 "Average link propagation delay in ms.");
119 int AvgPropagationDelayMs() { 119 int AvgPropagationDelayMs() {
120 return static_cast<int>(FLAGS_avg_propagation_delay_ms); 120 return static_cast<int>(FLAG_avg_propagation_delay_ms);
121 } 121 }
122 122
123 DEFINE_int32(std_propagation_delay_ms, 123 DEFINE_int(std_propagation_delay_ms,
124 0, 124 0,
125 "Link propagation delay standard deviation in ms."); 125 "Link propagation delay standard deviation in ms.");
126 int StdPropagationDelayMs() { 126 int StdPropagationDelayMs() {
127 return static_cast<int>(FLAGS_std_propagation_delay_ms); 127 return static_cast<int>(FLAG_std_propagation_delay_ms);
128 } 128 }
129 129
130 DEFINE_int32(selected_stream, 0, "ID of the stream to show or analyze."); 130 DEFINE_int(selected_stream, 0, "ID of the stream to show or analyze.");
131 int SelectedStream() { 131 int SelectedStream() {
132 return static_cast<int>(FLAGS_selected_stream); 132 return static_cast<int>(FLAG_selected_stream);
133 } 133 }
134 134
135 DEFINE_int32(num_spatial_layers, 1, "Number of spatial layers to use."); 135 DEFINE_int(num_spatial_layers, 1, "Number of spatial layers to use.");
136 int NumSpatialLayers() { 136 int NumSpatialLayers() {
137 return static_cast<int>(FLAGS_num_spatial_layers); 137 return static_cast<int>(FLAG_num_spatial_layers);
138 } 138 }
139 139
140 DEFINE_int32(selected_sl, 140 DEFINE_int(selected_sl,
141 -1, 141 -1,
142 "Spatial layer to show or analyze. -1 to disable filtering."); 142 "Spatial layer to show or analyze. -1 to disable filtering.");
143 int SelectedSL() { 143 int SelectedSL() {
144 return static_cast<int>(FLAGS_selected_sl); 144 return static_cast<int>(FLAG_selected_sl);
145 } 145 }
146 146
147 DEFINE_string(stream0, 147 DEFINE_string(stream0,
148 "", 148 "",
149 "Comma separated values describing VideoStream for stream #0."); 149 "Comma separated values describing VideoStream for stream #0.");
150 std::string Stream0() { 150 std::string Stream0() {
151 return static_cast<std::string>(FLAGS_stream0); 151 return static_cast<std::string>(FLAG_stream0);
152 } 152 }
153 153
154 DEFINE_string(stream1, 154 DEFINE_string(stream1,
155 "", 155 "",
156 "Comma separated values describing VideoStream for stream #1."); 156 "Comma separated values describing VideoStream for stream #1.");
157 std::string Stream1() { 157 std::string Stream1() {
158 return static_cast<std::string>(FLAGS_stream1); 158 return static_cast<std::string>(FLAG_stream1);
159 } 159 }
160 160
161 DEFINE_string(sl0, 161 DEFINE_string(sl0,
162 "", 162 "",
163 "Comma separated values describing SpatialLayer for layer #0."); 163 "Comma separated values describing SpatialLayer for layer #0.");
164 std::string SL0() { 164 std::string SL0() {
165 return static_cast<std::string>(FLAGS_sl0); 165 return static_cast<std::string>(FLAG_sl0);
166 } 166 }
167 167
168 DEFINE_string(sl1, 168 DEFINE_string(sl1,
169 "", 169 "",
170 "Comma separated values describing SpatialLayer for layer #1."); 170 "Comma separated values describing SpatialLayer for layer #1.");
171 std::string SL1() { 171 std::string SL1() {
172 return static_cast<std::string>(FLAGS_sl1); 172 return static_cast<std::string>(FLAG_sl1);
173 } 173 }
174 174
175 DEFINE_string(encoded_frame_path, 175 DEFINE_string(encoded_frame_path,
176 "", 176 "",
177 "The base path for encoded frame logs. Created files will have " 177 "The base path for encoded frame logs. Created files will have "
178 "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf"); 178 "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf");
179 std::string EncodedFramePath() { 179 std::string EncodedFramePath() {
180 return static_cast<std::string>(FLAGS_encoded_frame_path); 180 return static_cast<std::string>(FLAG_encoded_frame_path);
181 } 181 }
182 182
183 DEFINE_bool(logs, false, "print logs to stderr"); 183 DEFINE_bool(logs, false, "print logs to stderr");
184 184
185 DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation"); 185 DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation");
186 186
187 DEFINE_bool(allow_reordering, false, "Allow packet reordering to occur"); 187 DEFINE_bool(allow_reordering, false, "Allow packet reordering to occur");
188 188
189 DEFINE_string( 189 DEFINE_string(
190 force_fieldtrials, 190 force_fieldtrials,
191 "", 191 "",
192 "Field trials control experimental feature code which can be forced. " 192 "Field trials control experimental feature code which can be forced. "
193 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" 193 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
194 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple " 194 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple "
195 "trials are separated by \"/\""); 195 "trials are separated by \"/\"");
196 196
197 // Screenshare-specific flags. 197 // Screenshare-specific flags.
198 DEFINE_int32(min_transmit_bitrate, 400, "Min transmit bitrate incl. padding."); 198 DEFINE_int(min_transmit_bitrate, 400, "Min transmit bitrate incl. padding.");
199 int MinTransmitBitrateKbps() { 199 int MinTransmitBitrateKbps() {
200 return FLAGS_min_transmit_bitrate; 200 return FLAG_min_transmit_bitrate;
201 } 201 }
202 202
203 DEFINE_int32(slide_change_interval, 203 DEFINE_int(slide_change_interval,
204 10, 204 10,
205 "Interval (in seconds) between simulated slide changes."); 205 "Interval (in seconds) between simulated slide changes.");
206 int SlideChangeInterval() { 206 int SlideChangeInterval() {
207 return static_cast<int>(FLAGS_slide_change_interval); 207 return static_cast<int>(FLAG_slide_change_interval);
208 } 208 }
209 209
210 DEFINE_int32( 210 DEFINE_int(
211 scroll_duration, 211 scroll_duration,
212 0, 212 0,
213 "Duration (in seconds) during which a slide will be scrolled into place."); 213 "Duration (in seconds) during which a slide will be scrolled into place.");
214 int ScrollDuration() { 214 int ScrollDuration() {
215 return static_cast<int>(FLAGS_scroll_duration); 215 return static_cast<int>(FLAG_scroll_duration);
216 } 216 }
217 217
218 DEFINE_string(slides, 218 DEFINE_string(slides,
219 "", 219 "",
220 "Comma-separated list of *.yuv files to display as slides."); 220 "Comma-separated list of *.yuv files to display as slides.");
221 std::vector<std::string> Slides() { 221 std::vector<std::string> Slides() {
222 std::vector<std::string> slides; 222 std::vector<std::string> slides;
223 std::string slides_list = FLAGS_slides; 223 std::string slides_list = FLAG_slides;
224 rtc::tokenize(slides_list, ',', &slides); 224 rtc::tokenize(slides_list, ',', &slides);
225 return slides; 225 return slides;
226 } 226 }
227 227
228 DEFINE_bool(help, false, "prints this message");
229
228 } // namespace flags 230 } // namespace flags
229 231
230 void Loopback() { 232 void Loopback() {
231 FakeNetworkPipe::Config pipe_config; 233 FakeNetworkPipe::Config pipe_config;
232 pipe_config.loss_percent = flags::LossPercent(); 234 pipe_config.loss_percent = flags::LossPercent();
233 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps(); 235 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps();
234 pipe_config.queue_length_packets = flags::QueueSize(); 236 pipe_config.queue_length_packets = flags::QueueSize();
235 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs(); 237 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs();
236 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs(); 238 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs();
237 pipe_config.allow_reordering = flags::FLAGS_allow_reordering; 239 pipe_config.allow_reordering = flags::FLAG_allow_reordering;
238 240
239 Call::Config::BitrateConfig call_bitrate_config; 241 Call::Config::BitrateConfig call_bitrate_config;
240 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000; 242 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000;
241 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000; 243 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000;
242 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000; 244 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000;
243 245
244 VideoQualityTest::Params params; 246 VideoQualityTest::Params params;
245 params.call = {flags::FLAGS_send_side_bwe, call_bitrate_config}; 247 params.call = {flags::FLAG_send_side_bwe, call_bitrate_config};
246 params.video = {true, 248 params.video = {true,
247 flags::Width(), 249 flags::Width(),
248 flags::Height(), 250 flags::Height(),
249 flags::Fps(), 251 flags::Fps(),
250 flags::MinBitrateKbps() * 1000, 252 flags::MinBitrateKbps() * 1000,
251 flags::TargetBitrateKbps() * 1000, 253 flags::TargetBitrateKbps() * 1000,
252 flags::MaxBitrateKbps() * 1000, 254 flags::MaxBitrateKbps() * 1000,
253 false, 255 false,
254 flags::Codec(), 256 flags::Codec(),
255 flags::NumTemporalLayers(), 257 flags::NumTemporalLayers(),
256 flags::SelectedTL(), 258 flags::SelectedTL(),
257 flags::MinTransmitBitrateKbps() * 1000, 259 flags::MinTransmitBitrateKbps() * 1000,
258 false, // ULPFEC disabled. 260 false, // ULPFEC disabled.
259 false, // FlexFEC disabled. 261 false, // FlexFEC disabled.
260 flags::EncodedFramePath(), 262 flags::EncodedFramePath(),
261 ""}; 263 ""};
262 params.screenshare = {true, flags::SlideChangeInterval(), 264 params.screenshare = {true, flags::SlideChangeInterval(),
263 flags::ScrollDuration(), flags::Slides()}; 265 flags::ScrollDuration(), flags::Slides()};
264 params.analyzer = {"screenshare", 0.0, 0.0, flags::DurationSecs(), 266 params.analyzer = {"screenshare", 0.0, 0.0, flags::DurationSecs(),
265 flags::OutputFilename(), flags::GraphTitle()}; 267 flags::OutputFilename(), flags::GraphTitle()};
266 params.pipe = pipe_config; 268 params.pipe = pipe_config;
267 params.logs = flags::FLAGS_logs; 269 params.logs = flags::FLAG_logs;
268 270
269 std::vector<std::string> stream_descriptors; 271 std::vector<std::string> stream_descriptors;
270 stream_descriptors.push_back(flags::Stream0()); 272 stream_descriptors.push_back(flags::Stream0());
271 stream_descriptors.push_back(flags::Stream1()); 273 stream_descriptors.push_back(flags::Stream1());
272 std::vector<std::string> SL_descriptors; 274 std::vector<std::string> SL_descriptors;
273 SL_descriptors.push_back(flags::SL0()); 275 SL_descriptors.push_back(flags::SL0());
274 SL_descriptors.push_back(flags::SL1()); 276 SL_descriptors.push_back(flags::SL1());
275 VideoQualityTest::FillScalabilitySettings( 277 VideoQualityTest::FillScalabilitySettings(
276 &params, stream_descriptors, flags::SelectedStream(), 278 &params, stream_descriptors, flags::SelectedStream(),
277 flags::NumSpatialLayers(), flags::SelectedSL(), SL_descriptors); 279 flags::NumSpatialLayers(), flags::SelectedSL(), SL_descriptors);
278 280
279 VideoQualityTest test; 281 VideoQualityTest test;
280 if (flags::DurationSecs()) { 282 if (flags::DurationSecs()) {
281 test.RunWithAnalyzer(params); 283 test.RunWithAnalyzer(params);
282 } else { 284 } else {
283 test.RunWithRenderers(params); 285 test.RunWithRenderers(params);
284 } 286 }
285 } 287 }
286 } // namespace webrtc 288 } // namespace webrtc
287 289
288 int main(int argc, char* argv[]) { 290 int main(int argc, char* argv[]) {
289 ::testing::InitGoogleTest(&argc, argv); 291 ::testing::InitGoogleTest(&argc, argv);
290 google::ParseCommandLineFlags(&argc, &argv, true); 292 rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
293 if (webrtc::flags::FLAG_help) {
294 rtc::FlagList::Print(nullptr, false);
295 return 0;
296 }
297
291 webrtc::test::InitFieldTrialsFromString( 298 webrtc::test::InitFieldTrialsFromString(
292 webrtc::flags::FLAGS_force_fieldtrials); 299 webrtc::flags::FLAG_force_fieldtrials);
293 webrtc::test::RunTest(webrtc::Loopback); 300 webrtc::test::RunTest(webrtc::Loopback);
294 return 0; 301 return 0;
295 } 302 }
OLDNEW
« no previous file with comments | « webrtc/video/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698