blob: 87aacc6755f86a2f61a785b8435018cf57b98f3e [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
philipela2c55232016-01-26 08:41:53 -0800179DEFINE_bool(allow_reordering, false, "Allow packet reordering to occur");
180
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000181DEFINE_string(
182 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 \"/\"");
pbos9874ee02015-06-22 04:44:26 -0700188
sprangce4aef12015-11-02 07:23:20 -0800189// Video-specific flags.
ivica5d6a06c2015-09-17 05:30:24 -0700190DEFINE_string(clip,
191 "",
192 "Name of the clip to show. If empty, using chroma generator.");
193std::string Clip() {
194 return static_cast<std::string>(FLAGS_clip);
195}
196
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000197} // namespace flags
198
199void Loopback() {
ivica5d6a06c2015-09-17 05:30:24 -0700200 FakeNetworkPipe::Config pipe_config;
201 pipe_config.loss_percent = flags::LossPercent();
202 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps();
203 pipe_config.queue_length_packets = flags::QueueSize();
204 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs();
205 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs();
philipela2c55232016-01-26 08:41:53 -0800206 pipe_config.allow_reordering = flags::FLAGS_allow_reordering;
ivica5d6a06c2015-09-17 05:30:24 -0700207
208 Call::Config::BitrateConfig call_bitrate_config;
209 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000;
210 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000;
211 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000;
212
ivica5d6a06c2015-09-17 05:30:24 -0700213 VideoQualityTest::Params params{
Erik Språng6b8d3552015-09-24 15:06:57 +0200214 {flags::Width(), flags::Height(), flags::Fps(),
215 flags::MinBitrateKbps() * 1000, flags::TargetBitrateKbps() * 1000,
216 flags::MaxBitrateKbps() * 1000, flags::Codec(),
sprangce4aef12015-11-02 07:23:20 -0800217 flags::NumTemporalLayers(), flags::SelectedTL(),
Erik Språng6b8d3552015-09-24 15:06:57 +0200218 0, // No min transmit bitrate.
sprangce4aef12015-11-02 07:23:20 -0800219 call_bitrate_config, flags::FLAGS_send_side_bwe},
220 {flags::Clip()},
ivica5d6a06c2015-09-17 05:30:24 -0700221 {}, // Screenshare specific.
sprangce4aef12015-11-02 07:23:20 -0800222 {"video", 0.0, 0.0, flags::DurationSecs(), flags::OutputFilename(),
223 flags::GraphTitle()},
ivica5d6a06c2015-09-17 05:30:24 -0700224 pipe_config,
225 flags::FLAGS_logs};
226
sprangce4aef12015-11-02 07:23:20 -0800227 std::vector<std::string> stream_descriptors;
228 stream_descriptors.push_back(flags::Stream0());
229 stream_descriptors.push_back(flags::Stream1());
230 std::vector<std::string> SL_descriptors;
231 SL_descriptors.push_back(flags::SL0());
232 SL_descriptors.push_back(flags::SL1());
233 VideoQualityTest::FillScalabilitySettings(
234 &params, stream_descriptors, flags::SelectedStream(),
235 flags::NumSpatialLayers(), flags::SelectedSL(), SL_descriptors);
236
ivica5d6a06c2015-09-17 05:30:24 -0700237 VideoQualityTest test;
sprangce4aef12015-11-02 07:23:20 -0800238 if (flags::DurationSecs()) {
sprang7a975f72015-10-12 06:33:21 -0700239 test.RunWithAnalyzer(params);
sprangce4aef12015-11-02 07:23:20 -0800240 } else {
241 test.RunWithVideoRenderer(params);
242 }
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000243}
244} // namespace webrtc
245
246int main(int argc, char* argv[]) {
247 ::testing::InitGoogleTest(&argc, argv);
248 google::ParseCommandLineFlags(&argc, &argv, true);
249 webrtc::test::InitFieldTrialsFromString(
250 webrtc::flags::FLAGS_force_fieldtrials);
251 webrtc::test::RunTest(webrtc::Loopback);
252 return 0;
253}