blob: 2338a84a4399c538dfcf9a24f2983c425d9eaa4a [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"
17#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 {
sprang@webrtc.org131bea82015-02-18 12:46:06 +000021namespace flags {
22
sprangce4aef12015-11-02 07:23:20 -080023// Flags common with screenshare loopback, with different default values.
sprang@webrtc.org131bea82015-02-18 12:46:06 +000024DEFINE_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 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, 300, "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, 800, "Stream target bitrate in kbps.");
50int TargetBitrateKbps() {
51 return static_cast<int>(FLAGS_target_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000052}
53
ivica5d6a06c2015-09-17 05:30:24 -070054DEFINE_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:06 +000058
sprangce4aef12015-11-02 07:23:20 -080059DEFINE_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:06 +000067DEFINE_string(codec, "VP8", "Video codec to use.");
68std::string Codec() {
69 return static_cast<std::string>(FLAGS_codec);
70}
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
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000175DEFINE_bool(logs, false, "print logs to stderr");
176
sprangce4aef12015-11-02 07:23:20 -0800177DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation");
178
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000179DEFINE_string(
180 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 \"/\"");
pbos9874ee02015-06-22 04:44:26 -0700186
sprangce4aef12015-11-02 07:23:20 -0800187// Video-specific flags.
ivica5d6a06c2015-09-17 05:30:24 -0700188DEFINE_string(clip,
189 "",
190 "Name of the clip to show. If empty, using chroma generator.");
191std::string Clip() {
192 return static_cast<std::string>(FLAGS_clip);
193}
194
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000195} // namespace flags
196
197void Loopback() {
ivica5d6a06c2015-09-17 05:30:24 -0700198 FakeNetworkPipe::Config pipe_config;
199 pipe_config.loss_percent = flags::LossPercent();
200 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps();
201 pipe_config.queue_length_packets = flags::QueueSize();
202 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs();
203 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs();
204
205 Call::Config::BitrateConfig call_bitrate_config;
206 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000;
207 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000;
208 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000;
209
ivica5d6a06c2015-09-17 05:30:24 -0700210 VideoQualityTest::Params params{
Erik Språng6b8d3552015-09-24 15:06:57 +0200211 {flags::Width(), flags::Height(), flags::Fps(),
212 flags::MinBitrateKbps() * 1000, flags::TargetBitrateKbps() * 1000,
213 flags::MaxBitrateKbps() * 1000, flags::Codec(),
sprangce4aef12015-11-02 07:23:20 -0800214 flags::NumTemporalLayers(), flags::SelectedTL(),
Erik Språng6b8d3552015-09-24 15:06:57 +0200215 0, // No min transmit bitrate.
sprangce4aef12015-11-02 07:23:20 -0800216 call_bitrate_config, flags::FLAGS_send_side_bwe},
217 {flags::Clip()},
ivica5d6a06c2015-09-17 05:30:24 -0700218 {}, // Screenshare specific.
sprangce4aef12015-11-02 07:23:20 -0800219 {"video", 0.0, 0.0, flags::DurationSecs(), flags::OutputFilename(),
220 flags::GraphTitle()},
ivica5d6a06c2015-09-17 05:30:24 -0700221 pipe_config,
222 flags::FLAGS_logs};
223
sprangce4aef12015-11-02 07:23:20 -0800224 std::vector<std::string> stream_descriptors;
225 stream_descriptors.push_back(flags::Stream0());
226 stream_descriptors.push_back(flags::Stream1());
227 std::vector<std::string> SL_descriptors;
228 SL_descriptors.push_back(flags::SL0());
229 SL_descriptors.push_back(flags::SL1());
230 VideoQualityTest::FillScalabilitySettings(
231 &params, stream_descriptors, flags::SelectedStream(),
232 flags::NumSpatialLayers(), flags::SelectedSL(), SL_descriptors);
233
ivica5d6a06c2015-09-17 05:30:24 -0700234 VideoQualityTest test;
sprangce4aef12015-11-02 07:23:20 -0800235 if (flags::DurationSecs()) {
sprang7a975f72015-10-12 06:33:21 -0700236 test.RunWithAnalyzer(params);
sprangce4aef12015-11-02 07:23:20 -0800237 } else {
238 test.RunWithVideoRenderer(params);
239 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000240}
241} // namespace webrtc
242
243int main(int argc, char* argv[]) {
244 ::testing::InitGoogleTest(&argc, argv);
245 google::ParseCommandLineFlags(&argc, &argv, true);
246 webrtc::test::InitFieldTrialsFromString(
247 webrtc::flags::FLAGS_force_fieldtrials);
248 webrtc::test::RunTest(webrtc::Loopback);
249 return 0;
250}