blob: 0974d5869f1983c1150c11e6213ebf23ad4fad09 [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"
17#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 {
sprang@webrtc.org131bea82015-02-18 12:46:0621namespace flags {
22
sprangce4aef12015-11-02 15:23:2023// Flags common with screenshare loopback, with different default values.
sprang@webrtc.org131bea82015-02-18 12:46:0624DEFINE_int32(width, 640, "Video width.");
25size_t Width() {
26 return static_cast<size_t>(FLAGS_width);
27}
28
29DEFINE_int32(height, 480, "Video height.");
30size_t Height() {
31 return static_cast<size_t>(FLAGS_height);
32}
33
34DEFINE_int32(fps, 30, "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, 300, "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, 800, "Stream target bitrate in kbps.");
50int TargetBitrateKbps() {
51 return static_cast<int>(FLAGS_target_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:0652}
53
ivica5d6a06c2015-09-17 12:30:2454DEFINE_int32(max_bitrate, 800, "Call and stream max bitrate in kbps.");
55int MaxBitrateKbps() {
56 return static_cast<int>(FLAGS_max_bitrate);
57}
sprang@webrtc.org131bea82015-02-18 12:46:0658
sprangce4aef12015-11-02 15:23:2059DEFINE_int32(num_temporal_layers,
60 1,
61 "Number of temporal layers. Set to 1-4 to override.");
62int NumTemporalLayers() {
63 return static_cast<int>(FLAGS_num_temporal_layers);
64}
65
66// Flags common with screenshare loopback, with equal default values.
sprang@webrtc.org131bea82015-02-18 12:46:0667DEFINE_string(codec, "VP8", "Video codec to use.");
68std::string Codec() {
69 return static_cast<std::string>(FLAGS_codec);
70}
71
sprangce4aef12015-11-02 15:23:2072DEFINE_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:0699DEFINE_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 12:30:24107int LinkCapacityKbps() {
sprang@webrtc.org131bea82015-02-18 12:46:06108 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 15:23:20130DEFINE_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
sprang@webrtc.org131bea82015-02-18 12:46:06175DEFINE_bool(logs, false, "print logs to stderr");
176
sprangce4aef12015-11-02 15:23:20177DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation");
178
philipela2c55232016-01-26 16:41:53179DEFINE_bool(allow_reordering, false, "Allow packet reordering to occur");
180
philipel274c1dc2016-05-04 13:21:01181DEFINE_bool(use_fec, false, "Use forward error correction.");
182
sprang@webrtc.org131bea82015-02-18 12:46:06183DEFINE_string(
184 force_fieldtrials,
185 "",
186 "Field trials control experimental feature code which can be forced. "
187 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
188 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple "
189 "trials are separated by \"/\"");
pbos9874ee02015-06-22 11:44:26190
sprangce4aef12015-11-02 15:23:20191// Video-specific flags.
ivica5d6a06c2015-09-17 12:30:24192DEFINE_string(clip,
193 "",
194 "Name of the clip to show. If empty, using chroma generator.");
195std::string Clip() {
196 return static_cast<std::string>(FLAGS_clip);
197}
198
sprang@webrtc.org131bea82015-02-18 12:46:06199} // namespace flags
200
201void Loopback() {
ivica5d6a06c2015-09-17 12:30:24202 FakeNetworkPipe::Config pipe_config;
203 pipe_config.loss_percent = flags::LossPercent();
204 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps();
205 pipe_config.queue_length_packets = flags::QueueSize();
206 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs();
207 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs();
philipela2c55232016-01-26 16:41:53208 pipe_config.allow_reordering = flags::FLAGS_allow_reordering;
ivica5d6a06c2015-09-17 12:30:24209
210 Call::Config::BitrateConfig call_bitrate_config;
211 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000;
212 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000;
213 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000;
214
ivica5d6a06c2015-09-17 12:30:24215 VideoQualityTest::Params params{
Erik Språng6b8d3552015-09-24 13:06:57216 {flags::Width(), flags::Height(), flags::Fps(),
217 flags::MinBitrateKbps() * 1000, flags::TargetBitrateKbps() * 1000,
218 flags::MaxBitrateKbps() * 1000, flags::Codec(),
sprangce4aef12015-11-02 15:23:20219 flags::NumTemporalLayers(), flags::SelectedTL(),
Erik Språng6b8d3552015-09-24 13:06:57220 0, // No min transmit bitrate.
philipel274c1dc2016-05-04 13:21:01221 call_bitrate_config,
222 flags::FLAGS_send_side_bwe,
223 flags::FLAGS_use_fec},
sprangce4aef12015-11-02 15:23:20224 {flags::Clip()},
ivica5d6a06c2015-09-17 12:30:24225 {}, // Screenshare specific.
sprangce4aef12015-11-02 15:23:20226 {"video", 0.0, 0.0, flags::DurationSecs(), flags::OutputFilename(),
227 flags::GraphTitle()},
ivica5d6a06c2015-09-17 12:30:24228 pipe_config,
229 flags::FLAGS_logs};
230
sprangce4aef12015-11-02 15:23:20231 std::vector<std::string> stream_descriptors;
232 stream_descriptors.push_back(flags::Stream0());
233 stream_descriptors.push_back(flags::Stream1());
234 std::vector<std::string> SL_descriptors;
235 SL_descriptors.push_back(flags::SL0());
236 SL_descriptors.push_back(flags::SL1());
237 VideoQualityTest::FillScalabilitySettings(
238 &params, stream_descriptors, flags::SelectedStream(),
239 flags::NumSpatialLayers(), flags::SelectedSL(), SL_descriptors);
240
ivica5d6a06c2015-09-17 12:30:24241 VideoQualityTest test;
sprangce4aef12015-11-02 15:23:20242 if (flags::DurationSecs()) {
sprang7a975f72015-10-12 13:33:21243 test.RunWithAnalyzer(params);
sprangce4aef12015-11-02 15:23:20244 } else {
245 test.RunWithVideoRenderer(params);
246 }
sprang@webrtc.org131bea82015-02-18 12:46:06247}
248} // namespace webrtc
249
250int main(int argc, char* argv[]) {
251 ::testing::InitGoogleTest(&argc, argv);
252 google::ParseCommandLineFlags(&argc, &argv, true);
253 webrtc::test::InitFieldTrialsFromString(
254 webrtc::flags::FLAGS_force_fieldtrials);
255 webrtc::test::RunTest(webrtc::Loopback);
256 return 0;
257}