blob: 6479aa4ebba9c09b51efa3d78163c50a4f981af4 [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
ivica5d6a06c2015-09-17 05:30:24 -070044DEFINE_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:06 +000047}
48
ivica5d6a06c2015-09-17 05:30:24 -070049DEFINE_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:06 +000057}
58
sprangef7228c2015-08-05 02:01:29 -070059DEFINE_int32(num_temporal_layers, 2, "Number of temporal layers to use.");
sprangce4aef12015-11-02 07:23:20 -080060int NumTemporalLayers() {
61 return static_cast<int>(FLAGS_num_temporal_layers);
ivica87f83a92015-10-08 05:13:32 -070062}
63
sprangce4aef12015-11-02 07:23:20 -080064// Flags common with video loopback, with equal default values.
sprang7a975f72015-10-12 06:33:21 -070065DEFINE_string(codec, "VP8", "Video codec to use.");
66std::string Codec() {
67 return static_cast<std::string>(FLAGS_codec);
ivica87f83a92015-10-08 05:13:32 -070068}
69
sprangce4aef12015-11-02 07:23:20 -080070DEFINE_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:06 +000097DEFINE_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 05:30:24 -0700105int LinkCapacityKbps() {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000106 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 07:23:20 -0800128DEFINE_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 05:13:32 -0700173DEFINE_bool(logs, false, "print logs to stderr");
174
Erik Språng6b8d3552015-09-24 15:06:57 +0200175DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation");
176
ivica5d6a06c2015-09-17 05:30:24 -0700177DEFINE_string(
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000178 force_fieldtrials,
179 "",
180 "Field trials control experimental feature code which can be forced. "
181 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
182 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple "
183 "trials are separated by \"/\"");
sprangce4aef12015-11-02 07:23:20 -0800184
185// Screenshare-specific flags.
186DEFINE_int32(min_transmit_bitrate, 400, "Min transmit bitrate incl. padding.");
187int MinTransmitBitrateKbps() {
188 return FLAGS_min_transmit_bitrate;
189}
190
191DEFINE_int32(slide_change_interval,
192 10,
193 "Interval (in seconds) between simulated slide changes.");
194int SlideChangeInterval() {
195 return static_cast<int>(FLAGS_slide_change_interval);
196}
197
198DEFINE_int32(
199 scroll_duration,
200 0,
201 "Duration (in seconds) during which a slide will be scrolled into place.");
202int ScrollDuration() {
203 return static_cast<int>(FLAGS_scroll_duration);
204}
205
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000206} // namespace flags
207
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000208void Loopback() {
ivica5d6a06c2015-09-17 05:30:24 -0700209 FakeNetworkPipe::Config pipe_config;
210 pipe_config.loss_percent = flags::LossPercent();
211 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps();
212 pipe_config.queue_length_packets = flags::QueueSize();
213 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs();
214 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs();
215
216 Call::Config::BitrateConfig call_bitrate_config;
217 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000;
218 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000;
219 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000;
220
221 VideoQualityTest::Params params{
Erik Språng6b8d3552015-09-24 15:06:57 +0200222 {flags::Width(), flags::Height(), flags::Fps(),
223 flags::MinBitrateKbps() * 1000, flags::TargetBitrateKbps() * 1000,
224 flags::MaxBitrateKbps() * 1000, flags::Codec(),
sprangce4aef12015-11-02 07:23:20 -0800225 flags::NumTemporalLayers(), flags::SelectedTL(),
226 flags::MinTransmitBitrateKbps() * 1000, call_bitrate_config,
Erik Språng6b8d3552015-09-24 15:06:57 +0200227 flags::FLAGS_send_side_bwe},
ivica5d6a06c2015-09-17 05:30:24 -0700228 {}, // Video specific.
229 {true, flags::SlideChangeInterval(), flags::ScrollDuration()},
sprangce4aef12015-11-02 07:23:20 -0800230 {"screenshare", 0.0, 0.0, flags::DurationSecs(), flags::OutputFilename(),
231 flags::GraphTitle()},
ivica5d6a06c2015-09-17 05:30:24 -0700232 pipe_config,
233 flags::FLAGS_logs};
234
sprangce4aef12015-11-02 07:23:20 -0800235 std::vector<std::string> stream_descriptors;
236 stream_descriptors.push_back(flags::Stream0());
237 stream_descriptors.push_back(flags::Stream1());
238 std::vector<std::string> SL_descriptors;
239 SL_descriptors.push_back(flags::SL0());
240 SL_descriptors.push_back(flags::SL1());
241 VideoQualityTest::FillScalabilitySettings(
242 &params, stream_descriptors, flags::SelectedStream(),
243 flags::NumSpatialLayers(), flags::SelectedSL(), SL_descriptors);
244
ivica5d6a06c2015-09-17 05:30:24 -0700245 VideoQualityTest test;
sprangce4aef12015-11-02 07:23:20 -0800246 if (flags::DurationSecs()) {
sprang7a975f72015-10-12 06:33:21 -0700247 test.RunWithAnalyzer(params);
sprangce4aef12015-11-02 07:23:20 -0800248 } else {
249 test.RunWithVideoRenderer(params);
250 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000251}
252} // namespace webrtc
253
254int main(int argc, char* argv[]) {
255 ::testing::InitGoogleTest(&argc, argv);
256 google::ParseCommandLineFlags(&argc, &argv, true);
257 webrtc::test::InitFieldTrialsFromString(
258 webrtc::flags::FLAGS_force_fieldtrials);
259 webrtc::test::RunTest(webrtc::Loopback);
260 return 0;
261}