blob: 91002ef9043484f0b82b8b650e35ee3c617d0d00 [file] [log] [blame]
sprang@webrtc.org131bea82015-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.org131bea82015-02-18 12:46:0613#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:0617#include "webrtc/test/run_test.h"
ivica5d6a06c2015-09-17 12:30:2418#include "webrtc/video/video_quality_test.h"
sprang@webrtc.org131bea82015-02-18 12:46:0619
20namespace webrtc {
21namespace flags {
22
sprangce4aef12015-11-02 15:23:2023// Flags common with video loopback, with different default values.
sprangd6358952015-07-29 14:58:1324DEFINE_int32(width, 1850, "Video width (crops source).");
sprang@webrtc.org131bea82015-02-18 12:46:0625size_t Width() {
sprangd6358952015-07-29 14:58:1326 return static_cast<size_t>(FLAGS_width);
sprang@webrtc.org131bea82015-02-18 12:46:0627}
sprangd6358952015-07-29 14:58:1328
29DEFINE_int32(height, 1110, "Video height (crops source).");
sprang@webrtc.org131bea82015-02-18 12:46:0630size_t Height() {
sprangd6358952015-07-29 14:58:1331 return static_cast<size_t>(FLAGS_height);
sprang@webrtc.org131bea82015-02-18 12:46:0632}
33
34DEFINE_int32(fps, 5, "Frames per second.");
35int Fps() {
36 return static_cast<int>(FLAGS_fps);
37}
38
ivica5d6a06c2015-09-17 12:30:2439DEFINE_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:0642}
43
ivica5d6a06c2015-09-17 12:30:2444DEFINE_int32(start_bitrate, 200, "Call start bitrate in kbps.");
45int StartBitrateKbps() {
46 return static_cast<int>(FLAGS_start_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:0647}
48
ivica5d6a06c2015-09-17 12:30:2449DEFINE_int32(target_bitrate, 2000, "Stream target bitrate in kbps.");
50int TargetBitrateKbps() {
51 return static_cast<int>(FLAGS_target_bitrate);
52}
53
54DEFINE_int32(max_bitrate, 2000, "Call and stream max bitrate in kbps.");
55int MaxBitrateKbps() {
56 return static_cast<int>(FLAGS_max_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:0657}
58
sprangef7228c2015-08-05 09:01:2959DEFINE_int32(num_temporal_layers, 2, "Number of temporal layers to use.");
sprangce4aef12015-11-02 15:23:2060int NumTemporalLayers() {
61 return static_cast<int>(FLAGS_num_temporal_layers);
ivica87f83a92015-10-08 12:13:3262}
63
sprangce4aef12015-11-02 15:23:2064// Flags common with video loopback, with equal default values.
sprang7a975f72015-10-12 13:33:2165DEFINE_string(codec, "VP8", "Video codec to use.");
66std::string Codec() {
67 return static_cast<std::string>(FLAGS_codec);
ivica87f83a92015-10-08 12:13:3268}
69
sprangce4aef12015-11-02 15:23:2070DEFINE_int32(selected_tl,
71 -1,
72 "Temporal layer to show or analyze. -1 to disable filtering.");
73int SelectedTL() {
74 return static_cast<int>(FLAGS_selected_tl);
75}
76
77DEFINE_int32(
78 duration,
79 0,
80 "Duration of the test in seconds. If 0, rendered will be shown instead.");
81int DurationSecs() {
82 return static_cast<int>(FLAGS_duration);
83}
84
85DEFINE_string(output_filename, "", "Target graph data filename.");
86std::string OutputFilename() {
87 return static_cast<std::string>(FLAGS_output_filename);
88}
89
90DEFINE_string(graph_title,
91 "",
92 "If empty, title will be generated automatically.");
93std::string GraphTitle() {
94 return static_cast<std::string>(FLAGS_graph_title);
95}
96
sprang@webrtc.org131bea82015-02-18 12:46:0697DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost.");
98int LossPercent() {
99 return static_cast<int>(FLAGS_loss_percent);
100}
101
102DEFINE_int32(link_capacity,
103 0,
104 "Capacity (kbps) of the fake link. 0 means infinite.");
ivica5d6a06c2015-09-17 12:30:24105int LinkCapacityKbps() {
sprang@webrtc.org131bea82015-02-18 12:46:06106 return static_cast<int>(FLAGS_link_capacity);
107}
108
109DEFINE_int32(queue_size, 0, "Size of the bottleneck link queue in packets.");
110int QueueSize() {
111 return static_cast<int>(FLAGS_queue_size);
112}
113
114DEFINE_int32(avg_propagation_delay_ms,
115 0,
116 "Average link propagation delay in ms.");
117int AvgPropagationDelayMs() {
118 return static_cast<int>(FLAGS_avg_propagation_delay_ms);
119}
120
121DEFINE_int32(std_propagation_delay_ms,
122 0,
123 "Link propagation delay standard deviation in ms.");
124int StdPropagationDelayMs() {
125 return static_cast<int>(FLAGS_std_propagation_delay_ms);
126}
127
sprangce4aef12015-11-02 15:23:20128DEFINE_int32(selected_stream, 0, "ID of the stream to show or analyze.");
129int SelectedStream() {
130 return static_cast<int>(FLAGS_selected_stream);
131}
132
133DEFINE_int32(num_spatial_layers, 1, "Number of spatial layers to use.");
134int NumSpatialLayers() {
135 return static_cast<int>(FLAGS_num_spatial_layers);
136}
137
138DEFINE_int32(selected_sl,
139 -1,
140 "Spatial layer to show or analyze. -1 to disable filtering.");
141int SelectedSL() {
142 return static_cast<int>(FLAGS_selected_sl);
143}
144
145DEFINE_string(stream0,
146 "",
147 "Comma separated values describing VideoStream for stream #0.");
148std::string Stream0() {
149 return static_cast<std::string>(FLAGS_stream0);
150}
151
152DEFINE_string(stream1,
153 "",
154 "Comma separated values describing VideoStream for stream #1.");
155std::string Stream1() {
156 return static_cast<std::string>(FLAGS_stream1);
157}
158
159DEFINE_string(sl0,
160 "",
161 "Comma separated values describing SpatialLayer for layer #0.");
162std::string SL0() {
163 return static_cast<std::string>(FLAGS_sl0);
164}
165
166DEFINE_string(sl1,
167 "",
168 "Comma separated values describing SpatialLayer for layer #1.");
169std::string SL1() {
170 return static_cast<std::string>(FLAGS_sl1);
171}
172
ivica87f83a92015-10-08 12:13:32173DEFINE_bool(logs, false, "print logs to stderr");
174
Erik Språng6b8d3552015-09-24 13:06:57175DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation");
176
philipela2c55232016-01-26 16:41:53177DEFINE_bool(allow_reordering, false, "Allow packet reordering to occur");
178
ivica5d6a06c2015-09-17 12:30:24179DEFINE_string(
sprang@webrtc.org131bea82015-02-18 12:46:06180 force_fieldtrials,
181 "",
182 "Field trials control experimental feature code which can be forced. "
183 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
184 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple "
185 "trials are separated by \"/\"");
sprangce4aef12015-11-02 15:23:20186
187// Screenshare-specific flags.
188DEFINE_int32(min_transmit_bitrate, 400, "Min transmit bitrate incl. padding.");
189int MinTransmitBitrateKbps() {
190 return FLAGS_min_transmit_bitrate;
191}
192
193DEFINE_int32(slide_change_interval,
194 10,
195 "Interval (in seconds) between simulated slide changes.");
196int SlideChangeInterval() {
197 return static_cast<int>(FLAGS_slide_change_interval);
198}
199
200DEFINE_int32(
201 scroll_duration,
202 0,
203 "Duration (in seconds) during which a slide will be scrolled into place.");
204int ScrollDuration() {
205 return static_cast<int>(FLAGS_scroll_duration);
206}
207
sprang@webrtc.org131bea82015-02-18 12:46:06208} // namespace flags
209
sprang@webrtc.org131bea82015-02-18 12:46:06210void Loopback() {
ivica5d6a06c2015-09-17 12:30:24211 FakeNetworkPipe::Config pipe_config;
212 pipe_config.loss_percent = flags::LossPercent();
213 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps();
214 pipe_config.queue_length_packets = flags::QueueSize();
215 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs();
216 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs();
philipela2c55232016-01-26 16:41:53217 pipe_config.allow_reordering = flags::FLAGS_allow_reordering;
ivica5d6a06c2015-09-17 12:30:24218
219 Call::Config::BitrateConfig call_bitrate_config;
220 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000;
221 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000;
222 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000;
223
224 VideoQualityTest::Params params{
Erik Språng6b8d3552015-09-24 13:06:57225 {flags::Width(), flags::Height(), flags::Fps(),
226 flags::MinBitrateKbps() * 1000, flags::TargetBitrateKbps() * 1000,
227 flags::MaxBitrateKbps() * 1000, flags::Codec(),
sprangce4aef12015-11-02 15:23:20228 flags::NumTemporalLayers(), flags::SelectedTL(),
229 flags::MinTransmitBitrateKbps() * 1000, call_bitrate_config,
Erik Språng6b8d3552015-09-24 13:06:57230 flags::FLAGS_send_side_bwe},
ivica5d6a06c2015-09-17 12:30:24231 {}, // Video specific.
232 {true, flags::SlideChangeInterval(), flags::ScrollDuration()},
sprangce4aef12015-11-02 15:23:20233 {"screenshare", 0.0, 0.0, flags::DurationSecs(), flags::OutputFilename(),
234 flags::GraphTitle()},
ivica5d6a06c2015-09-17 12:30:24235 pipe_config,
236 flags::FLAGS_logs};
237
sprangce4aef12015-11-02 15:23:20238 std::vector<std::string> stream_descriptors;
239 stream_descriptors.push_back(flags::Stream0());
240 stream_descriptors.push_back(flags::Stream1());
241 std::vector<std::string> SL_descriptors;
242 SL_descriptors.push_back(flags::SL0());
243 SL_descriptors.push_back(flags::SL1());
244 VideoQualityTest::FillScalabilitySettings(
245 &params, stream_descriptors, flags::SelectedStream(),
246 flags::NumSpatialLayers(), flags::SelectedSL(), SL_descriptors);
247
ivica5d6a06c2015-09-17 12:30:24248 VideoQualityTest test;
sprangce4aef12015-11-02 15:23:20249 if (flags::DurationSecs()) {
sprang7a975f72015-10-12 13:33:21250 test.RunWithAnalyzer(params);
sprangce4aef12015-11-02 15:23:20251 } else {
252 test.RunWithVideoRenderer(params);
253 }
sprang@webrtc.org131bea82015-02-18 12:46:06254}
255} // namespace webrtc
256
257int main(int argc, char* argv[]) {
258 ::testing::InitGoogleTest(&argc, argv);
259 google::ParseCommandLineFlags(&argc, &argv, true);
260 webrtc::test::InitFieldTrialsFromString(
261 webrtc::flags::FLAGS_force_fieldtrials);
262 webrtc::test::RunTest(webrtc::Loopback);
263 return 0;
264}