blob: 65b51f77defcd887cfbd611895a9c91eef1e4cee [file] [log] [blame]
sprang@webrtc.org5fbd9402015-02-18 12:46:061/*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include <stdio.h>
12
sprang@webrtc.org5fbd9402015-02-18 12:46:0613#include "gflags/gflags.h"
sprang@webrtc.org5fbd9402015-02-18 12:46:0614#include "webrtc/test/field_trial.h"
kwiberg36a24792016-10-01 05:29:4315#include "webrtc/test/gtest.h"
sprang@webrtc.org5fbd9402015-02-18 12:46:0616#include "webrtc/test/run_test.h"
ivicada8e7c92015-09-17 12:30:2417#include "webrtc/video/video_quality_test.h"
sprang@webrtc.org5fbd9402015-02-18 12:46:0618
19namespace webrtc {
20namespace flags {
21
sprang0ba16d12015-11-02 15:23:2022// Flags common with video loopback, with different default values.
sprange3a63912015-07-29 14:58:1323DEFINE_int32(width, 1850, "Video width (crops source).");
sprang@webrtc.org5fbd9402015-02-18 12:46:0624size_t Width() {
sprange3a63912015-07-29 14:58:1325 return static_cast<size_t>(FLAGS_width);
sprang@webrtc.org5fbd9402015-02-18 12:46:0626}
sprange3a63912015-07-29 14:58:1327
28DEFINE_int32(height, 1110, "Video height (crops source).");
sprang@webrtc.org5fbd9402015-02-18 12:46:0629size_t Height() {
sprange3a63912015-07-29 14:58:1330 return static_cast<size_t>(FLAGS_height);
sprang@webrtc.org5fbd9402015-02-18 12:46:0631}
32
33DEFINE_int32(fps, 5, "Frames per second.");
34int Fps() {
35 return static_cast<int>(FLAGS_fps);
36}
37
ivicada8e7c92015-09-17 12:30:2438DEFINE_int32(min_bitrate, 50, "Call and stream min bitrate in kbps.");
39int MinBitrateKbps() {
40 return static_cast<int>(FLAGS_min_bitrate);
sprang@webrtc.org5fbd9402015-02-18 12:46:0641}
42
sprang4a2181e2016-04-22 10:48:5943DEFINE_int32(start_bitrate,
44 Call::Config::kDefaultStartBitrateBps / 1000,
45 "Call start bitrate in kbps.");
ivicada8e7c92015-09-17 12:30:2446int StartBitrateKbps() {
47 return static_cast<int>(FLAGS_start_bitrate);
sprang@webrtc.org5fbd9402015-02-18 12:46:0648}
49
sprang4a2181e2016-04-22 10:48:5950DEFINE_int32(target_bitrate, 200, "Stream target bitrate in kbps.");
ivicada8e7c92015-09-17 12:30:2451int TargetBitrateKbps() {
52 return static_cast<int>(FLAGS_target_bitrate);
53}
54
55DEFINE_int32(max_bitrate, 2000, "Call and stream max bitrate in kbps.");
56int MaxBitrateKbps() {
57 return static_cast<int>(FLAGS_max_bitrate);
sprang@webrtc.org5fbd9402015-02-18 12:46:0658}
59
sprang2a0ec552015-08-05 09:01:2960DEFINE_int32(num_temporal_layers, 2, "Number of temporal layers to use.");
sprang0ba16d12015-11-02 15:23:2061int NumTemporalLayers() {
62 return static_cast<int>(FLAGS_num_temporal_layers);
ivica3eea7522015-10-08 12:13:3263}
64
sprang0ba16d12015-11-02 15:23:2065// Flags common with video loopback, with equal default values.
sprang2d8a1b52015-10-12 13:33:2166DEFINE_string(codec, "VP8", "Video codec to use.");
67std::string Codec() {
68 return static_cast<std::string>(FLAGS_codec);
ivica3eea7522015-10-08 12:13:3269}
70
sprang0ba16d12015-11-02 15:23:2071DEFINE_int32(selected_tl,
72 -1,
73 "Temporal layer to show or analyze. -1 to disable filtering.");
74int SelectedTL() {
75 return static_cast<int>(FLAGS_selected_tl);
76}
77
78DEFINE_int32(
79 duration,
80 0,
81 "Duration of the test in seconds. If 0, rendered will be shown instead.");
82int DurationSecs() {
83 return static_cast<int>(FLAGS_duration);
84}
85
86DEFINE_string(output_filename, "", "Target graph data filename.");
87std::string OutputFilename() {
88 return static_cast<std::string>(FLAGS_output_filename);
89}
90
91DEFINE_string(graph_title,
92 "",
93 "If empty, title will be generated automatically.");
94std::string GraphTitle() {
95 return static_cast<std::string>(FLAGS_graph_title);
96}
97
sprang@webrtc.org5fbd9402015-02-18 12:46:0698DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost.");
99int LossPercent() {
100 return static_cast<int>(FLAGS_loss_percent);
101}
102
103DEFINE_int32(link_capacity,
104 0,
105 "Capacity (kbps) of the fake link. 0 means infinite.");
ivicada8e7c92015-09-17 12:30:24106int LinkCapacityKbps() {
sprang@webrtc.org5fbd9402015-02-18 12:46:06107 return static_cast<int>(FLAGS_link_capacity);
108}
109
110DEFINE_int32(queue_size, 0, "Size of the bottleneck link queue in packets.");
111int QueueSize() {
112 return static_cast<int>(FLAGS_queue_size);
113}
114
115DEFINE_int32(avg_propagation_delay_ms,
116 0,
117 "Average link propagation delay in ms.");
118int AvgPropagationDelayMs() {
119 return static_cast<int>(FLAGS_avg_propagation_delay_ms);
120}
121
122DEFINE_int32(std_propagation_delay_ms,
123 0,
124 "Link propagation delay standard deviation in ms.");
125int StdPropagationDelayMs() {
126 return static_cast<int>(FLAGS_std_propagation_delay_ms);
127}
128
sprang0ba16d12015-11-02 15:23:20129DEFINE_int32(selected_stream, 0, "ID of the stream to show or analyze.");
130int SelectedStream() {
131 return static_cast<int>(FLAGS_selected_stream);
132}
133
134DEFINE_int32(num_spatial_layers, 1, "Number of spatial layers to use.");
135int NumSpatialLayers() {
136 return static_cast<int>(FLAGS_num_spatial_layers);
137}
138
139DEFINE_int32(selected_sl,
140 -1,
141 "Spatial layer to show or analyze. -1 to disable filtering.");
142int SelectedSL() {
143 return static_cast<int>(FLAGS_selected_sl);
144}
145
146DEFINE_string(stream0,
147 "",
148 "Comma separated values describing VideoStream for stream #0.");
149std::string Stream0() {
150 return static_cast<std::string>(FLAGS_stream0);
151}
152
153DEFINE_string(stream1,
154 "",
155 "Comma separated values describing VideoStream for stream #1.");
156std::string Stream1() {
157 return static_cast<std::string>(FLAGS_stream1);
158}
159
160DEFINE_string(sl0,
161 "",
162 "Comma separated values describing SpatialLayer for layer #0.");
163std::string SL0() {
164 return static_cast<std::string>(FLAGS_sl0);
165}
166
167DEFINE_string(sl1,
168 "",
169 "Comma separated values describing SpatialLayer for layer #1.");
170std::string SL1() {
171 return static_cast<std::string>(FLAGS_sl1);
172}
173
palmkvista947bee2016-09-28 13:19:48174DEFINE_string(encoded_frame_path,
175 "",
176 "The base path for encoded frame logs. Created files will have "
177 "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf");
178std::string EncodedFramePath() {
179 return static_cast<std::string>(FLAGS_encoded_frame_path);
180}
181
ivica3eea7522015-10-08 12:13:32182DEFINE_bool(logs, false, "print logs to stderr");
183
Erik Språng489fd972015-09-24 13:06:57184DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation");
185
philipel781be9e2016-01-26 16:41:53186DEFINE_bool(allow_reordering, false, "Allow packet reordering to occur");
187
ivicada8e7c92015-09-17 12:30:24188DEFINE_string(
sprang@webrtc.org5fbd9402015-02-18 12:46:06189 force_fieldtrials,
190 "",
191 "Field trials control experimental feature code which can be forced. "
192 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
193 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple "
194 "trials are separated by \"/\"");
sprang0ba16d12015-11-02 15:23:20195
196// Screenshare-specific flags.
197DEFINE_int32(min_transmit_bitrate, 400, "Min transmit bitrate incl. padding.");
198int MinTransmitBitrateKbps() {
199 return FLAGS_min_transmit_bitrate;
200}
201
202DEFINE_int32(slide_change_interval,
203 10,
204 "Interval (in seconds) between simulated slide changes.");
205int SlideChangeInterval() {
206 return static_cast<int>(FLAGS_slide_change_interval);
207}
208
209DEFINE_int32(
210 scroll_duration,
211 0,
212 "Duration (in seconds) during which a slide will be scrolled into place.");
213int ScrollDuration() {
214 return static_cast<int>(FLAGS_scroll_duration);
215}
216
sprang@webrtc.org5fbd9402015-02-18 12:46:06217} // namespace flags
218
sprang@webrtc.org5fbd9402015-02-18 12:46:06219void Loopback() {
ivicada8e7c92015-09-17 12:30:24220 FakeNetworkPipe::Config pipe_config;
221 pipe_config.loss_percent = flags::LossPercent();
222 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps();
223 pipe_config.queue_length_packets = flags::QueueSize();
224 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs();
225 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs();
philipel781be9e2016-01-26 16:41:53226 pipe_config.allow_reordering = flags::FLAGS_allow_reordering;
ivicada8e7c92015-09-17 12:30:24227
228 Call::Config::BitrateConfig call_bitrate_config;
229 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000;
230 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000;
231 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000;
232
minyuef463c532016-08-18 13:28:55233 VideoQualityTest::Params params;
palmkvista947bee2016-09-28 13:19:48234 params.common = {flags::Width(),
235 flags::Height(),
236 flags::Fps(),
237 flags::MinBitrateKbps() * 1000,
238 flags::TargetBitrateKbps() * 1000,
239 flags::MaxBitrateKbps() * 1000,
240 false,
241 flags::Codec(),
242 flags::NumTemporalLayers(),
243 flags::SelectedTL(),
244 flags::MinTransmitBitrateKbps() * 1000,
245 flags::FLAGS_send_side_bwe,
246 false,
247 flags::EncodedFramePath(),
248 call_bitrate_config};
minyuef463c532016-08-18 13:28:55249 params.screenshare = {true, flags::SlideChangeInterval(),
250 flags::ScrollDuration()};
251 params.analyzer = {"screenshare", 0.0, 0.0, flags::DurationSecs(),
252 flags::OutputFilename(), flags::GraphTitle()};
253 params.pipe = pipe_config;
254 params.logs = flags::FLAGS_logs;
kjellander2853a4b2016-09-08 17:52:38255 params.audio = false;
256 params.audio_video_sync = false;
ivicada8e7c92015-09-17 12:30:24257
sprang0ba16d12015-11-02 15:23:20258 std::vector<std::string> stream_descriptors;
259 stream_descriptors.push_back(flags::Stream0());
260 stream_descriptors.push_back(flags::Stream1());
261 std::vector<std::string> SL_descriptors;
262 SL_descriptors.push_back(flags::SL0());
263 SL_descriptors.push_back(flags::SL1());
264 VideoQualityTest::FillScalabilitySettings(
265 &params, stream_descriptors, flags::SelectedStream(),
266 flags::NumSpatialLayers(), flags::SelectedSL(), SL_descriptors);
267
ivicada8e7c92015-09-17 12:30:24268 VideoQualityTest test;
sprang0ba16d12015-11-02 15:23:20269 if (flags::DurationSecs()) {
sprang2d8a1b52015-10-12 13:33:21270 test.RunWithAnalyzer(params);
sprang0ba16d12015-11-02 15:23:20271 } else {
minyuef463c532016-08-18 13:28:55272 test.RunWithRenderers(params);
sprang0ba16d12015-11-02 15:23:20273 }
sprang@webrtc.org5fbd9402015-02-18 12:46:06274}
275} // namespace webrtc
276
277int main(int argc, char* argv[]) {
278 ::testing::InitGoogleTest(&argc, argv);
279 google::ParseCommandLineFlags(&argc, &argv, true);
280 webrtc::test::InitFieldTrialsFromString(
281 webrtc::flags::FLAGS_force_fieldtrials);
282 webrtc::test::RunTest(webrtc::Loopback);
283 return 0;
284}