blob: 05ebc2e02f6288681731c7e23ca0a1411cdbe69d [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"
14#include "testing/gtest/include/gtest/gtest.h"
15
16#include "webrtc/test/field_trial.h"
sprang@webrtc.org131bea82015-02-18 12:46:06 +000017#include "webrtc/test/run_test.h"
ivica5d6a06c2015-09-17 05:30:24 -070018#include "webrtc/video/video_quality_test.h"
sprang@webrtc.org131bea82015-02-18 12:46:06 +000019
20namespace webrtc {
21namespace flags {
22
sprangce4aef12015-11-02 07:23:20 -080023// Flags common with video loopback, with different default values.
sprangd6358952015-07-29 07:58:13 -070024DEFINE_int32(width, 1850, "Video width (crops source).");
sprang@webrtc.org131bea82015-02-18 12:46:06 +000025size_t Width() {
sprangd6358952015-07-29 07:58:13 -070026 return static_cast<size_t>(FLAGS_width);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000027}
sprangd6358952015-07-29 07:58:13 -070028
29DEFINE_int32(height, 1110, "Video height (crops source).");
sprang@webrtc.org131bea82015-02-18 12:46:06 +000030size_t Height() {
sprangd6358952015-07-29 07:58:13 -070031 return static_cast<size_t>(FLAGS_height);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000032}
33
34DEFINE_int32(fps, 5, "Frames per second.");
35int Fps() {
36 return static_cast<int>(FLAGS_fps);
37}
38
ivica5d6a06c2015-09-17 05:30:24 -070039DEFINE_int32(min_bitrate, 50, "Call and stream min bitrate in kbps.");
40int MinBitrateKbps() {
41 return static_cast<int>(FLAGS_min_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000042}
43
sprang7169bda2016-04-22 03:48:59 -070044DEFINE_int32(start_bitrate,
45 Call::Config::kDefaultStartBitrateBps / 1000,
46 "Call start bitrate in kbps.");
ivica5d6a06c2015-09-17 05:30:24 -070047int StartBitrateKbps() {
48 return static_cast<int>(FLAGS_start_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000049}
50
sprang7169bda2016-04-22 03:48:59 -070051DEFINE_int32(target_bitrate, 200, "Stream target bitrate in kbps.");
ivica5d6a06c2015-09-17 05:30:24 -070052int TargetBitrateKbps() {
53 return static_cast<int>(FLAGS_target_bitrate);
54}
55
56DEFINE_int32(max_bitrate, 2000, "Call and stream max bitrate in kbps.");
57int MaxBitrateKbps() {
58 return static_cast<int>(FLAGS_max_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000059}
60
sprangef7228c2015-08-05 02:01:29 -070061DEFINE_int32(num_temporal_layers, 2, "Number of temporal layers to use.");
sprangce4aef12015-11-02 07:23:20 -080062int NumTemporalLayers() {
63 return static_cast<int>(FLAGS_num_temporal_layers);
ivica87f83a92015-10-08 05:13:32 -070064}
65
sprangce4aef12015-11-02 07:23:20 -080066// Flags common with video loopback, with equal default values.
sprang7a975f72015-10-12 06:33:21 -070067DEFINE_string(codec, "VP8", "Video codec to use.");
68std::string Codec() {
69 return static_cast<std::string>(FLAGS_codec);
ivica87f83a92015-10-08 05:13:32 -070070}
71
sprangce4aef12015-11-02 07:23:20 -080072DEFINE_int32(selected_tl,
73 -1,
74 "Temporal layer to show or analyze. -1 to disable filtering.");
75int SelectedTL() {
76 return static_cast<int>(FLAGS_selected_tl);
77}
78
79DEFINE_int32(
80 duration,
81 0,
82 "Duration of the test in seconds. If 0, rendered will be shown instead.");
83int DurationSecs() {
84 return static_cast<int>(FLAGS_duration);
85}
86
87DEFINE_string(output_filename, "", "Target graph data filename.");
88std::string OutputFilename() {
89 return static_cast<std::string>(FLAGS_output_filename);
90}
91
92DEFINE_string(graph_title,
93 "",
94 "If empty, title will be generated automatically.");
95std::string GraphTitle() {
96 return static_cast<std::string>(FLAGS_graph_title);
97}
98
sprang@webrtc.org131bea82015-02-18 12:46:06 +000099DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost.");
100int LossPercent() {
101 return static_cast<int>(FLAGS_loss_percent);
102}
103
104DEFINE_int32(link_capacity,
105 0,
106 "Capacity (kbps) of the fake link. 0 means infinite.");
ivica5d6a06c2015-09-17 05:30:24 -0700107int LinkCapacityKbps() {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000108 return static_cast<int>(FLAGS_link_capacity);
109}
110
111DEFINE_int32(queue_size, 0, "Size of the bottleneck link queue in packets.");
112int QueueSize() {
113 return static_cast<int>(FLAGS_queue_size);
114}
115
116DEFINE_int32(avg_propagation_delay_ms,
117 0,
118 "Average link propagation delay in ms.");
119int AvgPropagationDelayMs() {
120 return static_cast<int>(FLAGS_avg_propagation_delay_ms);
121}
122
123DEFINE_int32(std_propagation_delay_ms,
124 0,
125 "Link propagation delay standard deviation in ms.");
126int StdPropagationDelayMs() {
127 return static_cast<int>(FLAGS_std_propagation_delay_ms);
128}
129
sprangce4aef12015-11-02 07:23:20 -0800130DEFINE_int32(selected_stream, 0, "ID of the stream to show or analyze.");
131int SelectedStream() {
132 return static_cast<int>(FLAGS_selected_stream);
133}
134
135DEFINE_int32(num_spatial_layers, 1, "Number of spatial layers to use.");
136int NumSpatialLayers() {
137 return static_cast<int>(FLAGS_num_spatial_layers);
138}
139
140DEFINE_int32(selected_sl,
141 -1,
142 "Spatial layer to show or analyze. -1 to disable filtering.");
143int SelectedSL() {
144 return static_cast<int>(FLAGS_selected_sl);
145}
146
147DEFINE_string(stream0,
148 "",
149 "Comma separated values describing VideoStream for stream #0.");
150std::string Stream0() {
151 return static_cast<std::string>(FLAGS_stream0);
152}
153
154DEFINE_string(stream1,
155 "",
156 "Comma separated values describing VideoStream for stream #1.");
157std::string Stream1() {
158 return static_cast<std::string>(FLAGS_stream1);
159}
160
161DEFINE_string(sl0,
162 "",
163 "Comma separated values describing SpatialLayer for layer #0.");
164std::string SL0() {
165 return static_cast<std::string>(FLAGS_sl0);
166}
167
168DEFINE_string(sl1,
169 "",
170 "Comma separated values describing SpatialLayer for layer #1.");
171std::string SL1() {
172 return static_cast<std::string>(FLAGS_sl1);
173}
174
ivica87f83a92015-10-08 05:13:32 -0700175DEFINE_bool(logs, false, "print logs to stderr");
176
Erik Språng6b8d3552015-09-24 15:06:57 +0200177DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation");
178
philipela2c55232016-01-26 08:41:53 -0800179DEFINE_bool(allow_reordering, false, "Allow packet reordering to occur");
180
ivica5d6a06c2015-09-17 05:30:24 -0700181DEFINE_string(
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000182 force_fieldtrials,
183 "",
184 "Field trials control experimental feature code which can be forced. "
185 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
186 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple "
187 "trials are separated by \"/\"");
sprangce4aef12015-11-02 07:23:20 -0800188
189// Screenshare-specific flags.
190DEFINE_int32(min_transmit_bitrate, 400, "Min transmit bitrate incl. padding.");
191int MinTransmitBitrateKbps() {
192 return FLAGS_min_transmit_bitrate;
193}
194
195DEFINE_int32(slide_change_interval,
196 10,
197 "Interval (in seconds) between simulated slide changes.");
198int SlideChangeInterval() {
199 return static_cast<int>(FLAGS_slide_change_interval);
200}
201
202DEFINE_int32(
203 scroll_duration,
204 0,
205 "Duration (in seconds) during which a slide will be scrolled into place.");
206int ScrollDuration() {
207 return static_cast<int>(FLAGS_scroll_duration);
208}
209
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000210} // namespace flags
211
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000212void Loopback() {
ivica5d6a06c2015-09-17 05:30:24 -0700213 FakeNetworkPipe::Config pipe_config;
214 pipe_config.loss_percent = flags::LossPercent();
215 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps();
216 pipe_config.queue_length_packets = flags::QueueSize();
217 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs();
218 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs();
philipela2c55232016-01-26 08:41:53 -0800219 pipe_config.allow_reordering = flags::FLAGS_allow_reordering;
ivica5d6a06c2015-09-17 05:30:24 -0700220
221 Call::Config::BitrateConfig call_bitrate_config;
222 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000;
223 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000;
224 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000;
225
226 VideoQualityTest::Params params{
Erik Språng6b8d3552015-09-24 15:06:57 +0200227 {flags::Width(), flags::Height(), flags::Fps(),
228 flags::MinBitrateKbps() * 1000, flags::TargetBitrateKbps() * 1000,
mflodman48a4beb2016-07-01 13:03:59 +0200229 flags::MaxBitrateKbps() * 1000, false, flags::Codec(),
sprangce4aef12015-11-02 07:23:20 -0800230 flags::NumTemporalLayers(), flags::SelectedTL(),
stefanb1797672016-08-11 07:00:57 -0700231 flags::MinTransmitBitrateKbps() * 1000, flags::FLAGS_send_side_bwe,
232 false, call_bitrate_config},
ivica5d6a06c2015-09-17 05:30:24 -0700233 {}, // Video specific.
234 {true, flags::SlideChangeInterval(), flags::ScrollDuration()},
sprangce4aef12015-11-02 07:23:20 -0800235 {"screenshare", 0.0, 0.0, flags::DurationSecs(), flags::OutputFilename(),
236 flags::GraphTitle()},
ivica5d6a06c2015-09-17 05:30:24 -0700237 pipe_config,
238 flags::FLAGS_logs};
239
sprangce4aef12015-11-02 07:23:20 -0800240 std::vector<std::string> stream_descriptors;
241 stream_descriptors.push_back(flags::Stream0());
242 stream_descriptors.push_back(flags::Stream1());
243 std::vector<std::string> SL_descriptors;
244 SL_descriptors.push_back(flags::SL0());
245 SL_descriptors.push_back(flags::SL1());
246 VideoQualityTest::FillScalabilitySettings(
247 &params, stream_descriptors, flags::SelectedStream(),
248 flags::NumSpatialLayers(), flags::SelectedSL(), SL_descriptors);
249
ivica5d6a06c2015-09-17 05:30:24 -0700250 VideoQualityTest test;
sprangce4aef12015-11-02 07:23:20 -0800251 if (flags::DurationSecs()) {
sprang7a975f72015-10-12 06:33:21 -0700252 test.RunWithAnalyzer(params);
sprangce4aef12015-11-02 07:23:20 -0800253 } else {
254 test.RunWithVideoRenderer(params);
255 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000256}
257} // namespace webrtc
258
259int main(int argc, char* argv[]) {
260 ::testing::InitGoogleTest(&argc, argv);
261 google::ParseCommandLineFlags(&argc, &argv, true);
262 webrtc::test::InitFieldTrialsFromString(
263 webrtc::flags::FLAGS_force_fieldtrials);
264 webrtc::test::RunTest(webrtc::Loopback);
265 return 0;
266}