blob: cfca27f22947438fb8446e2306c328fa698fdc8d [file] [log] [blame]
sprang@webrtc.org131bea82015-02-18 12:46:06 +00001/*
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.org131bea82015-02-18 12:46:06 +000013#include "gflags/gflags.h"
sprang@webrtc.org131bea82015-02-18 12:46:06 +000014#include "webrtc/test/field_trial.h"
kwibergac9f8762016-09-30 22:29:43 -070015#include "webrtc/test/gtest.h"
sprang@webrtc.org131bea82015-02-18 12:46:06 +000016#include "webrtc/test/run_test.h"
ivica5d6a06c2015-09-17 05:30:24 -070017#include "webrtc/video/video_quality_test.h"
sprang@webrtc.org131bea82015-02-18 12:46:06 +000018
19namespace webrtc {
20namespace flags {
21
sprangce4aef12015-11-02 07:23:20 -080022// Flags common with video loopback, with different default values.
sprangd6358952015-07-29 07:58:13 -070023DEFINE_int32(width, 1850, "Video width (crops source).");
sprang@webrtc.org131bea82015-02-18 12:46:06 +000024size_t Width() {
sprangd6358952015-07-29 07:58:13 -070025 return static_cast<size_t>(FLAGS_width);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000026}
sprangd6358952015-07-29 07:58:13 -070027
28DEFINE_int32(height, 1110, "Video height (crops source).");
sprang@webrtc.org131bea82015-02-18 12:46:06 +000029size_t Height() {
sprangd6358952015-07-29 07:58:13 -070030 return static_cast<size_t>(FLAGS_height);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000031}
32
33DEFINE_int32(fps, 5, "Frames per second.");
34int Fps() {
35 return static_cast<int>(FLAGS_fps);
36}
37
ivica5d6a06c2015-09-17 05:30:24 -070038DEFINE_int32(min_bitrate, 50, "Call and stream min bitrate in kbps.");
39int MinBitrateKbps() {
40 return static_cast<int>(FLAGS_min_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000041}
42
sprang7169bda2016-04-22 03:48:59 -070043DEFINE_int32(start_bitrate,
44 Call::Config::kDefaultStartBitrateBps / 1000,
45 "Call start bitrate in kbps.");
ivica5d6a06c2015-09-17 05:30:24 -070046int StartBitrateKbps() {
47 return static_cast<int>(FLAGS_start_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000048}
49
sprang7169bda2016-04-22 03:48:59 -070050DEFINE_int32(target_bitrate, 200, "Stream target bitrate in kbps.");
ivica5d6a06c2015-09-17 05:30:24 -070051int 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.org131bea82015-02-18 12:46:06 +000058}
59
sprangef7228c2015-08-05 02:01:29 -070060DEFINE_int32(num_temporal_layers, 2, "Number of temporal layers to use.");
sprangce4aef12015-11-02 07:23:20 -080061int NumTemporalLayers() {
62 return static_cast<int>(FLAGS_num_temporal_layers);
ivica87f83a92015-10-08 05:13:32 -070063}
64
sprangce4aef12015-11-02 07:23:20 -080065// Flags common with video loopback, with equal default values.
sprang7a975f72015-10-12 06:33:21 -070066DEFINE_string(codec, "VP8", "Video codec to use.");
67std::string Codec() {
68 return static_cast<std::string>(FLAGS_codec);
ivica87f83a92015-10-08 05:13:32 -070069}
70
sprangce4aef12015-11-02 07:23:20 -080071DEFINE_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.org131bea82015-02-18 12:46:06 +000098DEFINE_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.");
ivica5d6a06c2015-09-17 05:30:24 -0700106int LinkCapacityKbps() {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000107 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
sprangce4aef12015-11-02 07:23:20 -0800129DEFINE_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
palmkviste75f2042016-09-28 06:19:48 -0700174DEFINE_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
ivica87f83a92015-10-08 05:13:32 -0700182DEFINE_bool(logs, false, "print logs to stderr");
183
Erik Språng6b8d3552015-09-24 15:06:57 +0200184DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation");
185
philipela2c55232016-01-26 08:41:53 -0800186DEFINE_bool(allow_reordering, false, "Allow packet reordering to occur");
187
ivica5d6a06c2015-09-17 05:30:24 -0700188DEFINE_string(
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000189 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 \"/\"");
sprangce4aef12015-11-02 07:23:20 -0800195
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.org131bea82015-02-18 12:46:06 +0000217} // namespace flags
218
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000219void Loopback() {
ivica5d6a06c2015-09-17 05:30:24 -0700220 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();
philipela2c55232016-01-26 08:41:53 -0800226 pipe_config.allow_reordering = flags::FLAGS_allow_reordering;
ivica5d6a06c2015-09-17 05:30:24 -0700227
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
minyue73208662016-08-18 06:28:55 -0700233 VideoQualityTest::Params params;
minyue626bc952016-10-31 05:47:02 -0700234 params.call = {flags::FLAGS_send_side_bwe, call_bitrate_config};
235 params.video = {true,
236 flags::Width(),
237 flags::Height(),
238 flags::Fps(),
239 flags::MinBitrateKbps() * 1000,
240 flags::TargetBitrateKbps() * 1000,
241 flags::MaxBitrateKbps() * 1000,
242 false,
243 flags::Codec(),
244 flags::NumTemporalLayers(),
245 flags::SelectedTL(),
246 flags::MinTransmitBitrateKbps() * 1000,
247 false,
248 flags::EncodedFramePath(),
249 ""};
250 params.audio = {false, false};
minyue73208662016-08-18 06:28:55 -0700251 params.screenshare = {true, flags::SlideChangeInterval(),
252 flags::ScrollDuration()};
253 params.analyzer = {"screenshare", 0.0, 0.0, flags::DurationSecs(),
254 flags::OutputFilename(), flags::GraphTitle()};
255 params.pipe = pipe_config;
256 params.logs = flags::FLAGS_logs;
ivica5d6a06c2015-09-17 05:30:24 -0700257
sprangce4aef12015-11-02 07:23:20 -0800258 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
ivica5d6a06c2015-09-17 05:30:24 -0700268 VideoQualityTest test;
sprangce4aef12015-11-02 07:23:20 -0800269 if (flags::DurationSecs()) {
sprang7a975f72015-10-12 06:33:21 -0700270 test.RunWithAnalyzer(params);
sprangce4aef12015-11-02 07:23:20 -0800271 } else {
minyue73208662016-08-18 06:28:55 -0700272 test.RunWithRenderers(params);
sprangce4aef12015-11-02 07:23:20 -0800273 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000274}
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}