blob: 34f68947f660e84fc342196a019fa9778a1ec443 [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
sprangd6358952015-07-29 07:58:13 -070023DEFINE_int32(width, 1850, "Video width (crops source).");
sprang@webrtc.org131bea82015-02-18 12:46:06 +000024size_t Width() {
sprangd6358952015-07-29 07:58:13 -070025 return static_cast<size_t>(FLAGS_width);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000026}
sprangd6358952015-07-29 07:58:13 -070027
28DEFINE_int32(height, 1110, "Video height (crops source).");
sprang@webrtc.org131bea82015-02-18 12:46:06 +000029size_t Height() {
sprangd6358952015-07-29 07:58:13 -070030 return static_cast<size_t>(FLAGS_height);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000031}
32
33DEFINE_int32(fps, 5, "Frames per second.");
34int Fps() {
35 return static_cast<int>(FLAGS_fps);
36}
37
sprangd6358952015-07-29 07:58:13 -070038DEFINE_int32(slide_change_interval,
39 10,
40 "Interval (in seconds) between simulated slide changes.");
41int SlideChangeInterval() {
42 return static_cast<int>(FLAGS_slide_change_interval);
43}
44
45DEFINE_int32(
46 scroll_duration,
47 0,
48 "Duration (in seconds) during which a slide will be scrolled into place.");
49int ScrollDuration() {
50 return static_cast<int>(FLAGS_scroll_duration);
51}
52
ivica5d6a06c2015-09-17 05:30:24 -070053DEFINE_int32(min_bitrate, 50, "Call and stream min bitrate in kbps.");
54int MinBitrateKbps() {
55 return static_cast<int>(FLAGS_min_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000056}
57
ivica5d6a06c2015-09-17 05:30:24 -070058DEFINE_int32(start_bitrate, 200, "Call start bitrate in kbps.");
59int StartBitrateKbps() {
60 return static_cast<int>(FLAGS_start_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000061}
62
ivica5d6a06c2015-09-17 05:30:24 -070063DEFINE_int32(target_bitrate, 2000, "Stream target bitrate in kbps.");
64int TargetBitrateKbps() {
65 return static_cast<int>(FLAGS_target_bitrate);
66}
67
68DEFINE_int32(max_bitrate, 2000, "Call and stream max bitrate in kbps.");
69int MaxBitrateKbps() {
70 return static_cast<int>(FLAGS_max_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000071}
72
sprangef7228c2015-08-05 02:01:29 -070073DEFINE_int32(num_temporal_layers, 2, "Number of temporal layers to use.");
ivica5d6a06c2015-09-17 05:30:24 -070074size_t NumTemporalLayers() {
75 return static_cast<size_t>(FLAGS_num_temporal_layers);
ivica7f6a6fc2015-09-08 02:40:29 -070076}
77
78DEFINE_int32(
79 tl_discard_threshold,
80 0,
81 "Discard TLs with id greater or equal the threshold. 0 to disable.");
ivica5d6a06c2015-09-17 05:30:24 -070082size_t TLDiscardThreshold() {
83 return static_cast<size_t>(FLAGS_tl_discard_threshold);
ivica7f6a6fc2015-09-08 02:40:29 -070084}
85
sprang@webrtc.org131bea82015-02-18 12:46:06 +000086DEFINE_int32(min_transmit_bitrate, 400, "Min transmit bitrate incl. padding.");
ivica5d6a06c2015-09-17 05:30:24 -070087int MinTransmitBitrateKbps() {
sprang@webrtc.org131bea82015-02-18 12:46:06 +000088 return FLAGS_min_transmit_bitrate;
89}
90
91DEFINE_string(codec, "VP8", "Video codec to use.");
92std::string Codec() {
93 return static_cast<std::string>(FLAGS_codec);
94}
95
96DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost.");
97int LossPercent() {
98 return static_cast<int>(FLAGS_loss_percent);
99}
100
101DEFINE_int32(link_capacity,
102 0,
103 "Capacity (kbps) of the fake link. 0 means infinite.");
ivica5d6a06c2015-09-17 05:30:24 -0700104int LinkCapacityKbps() {
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000105 return static_cast<int>(FLAGS_link_capacity);
106}
107
108DEFINE_int32(queue_size, 0, "Size of the bottleneck link queue in packets.");
109int QueueSize() {
110 return static_cast<int>(FLAGS_queue_size);
111}
112
113DEFINE_int32(avg_propagation_delay_ms,
114 0,
115 "Average link propagation delay in ms.");
116int AvgPropagationDelayMs() {
117 return static_cast<int>(FLAGS_avg_propagation_delay_ms);
118}
119
120DEFINE_int32(std_propagation_delay_ms,
121 0,
122 "Link propagation delay standard deviation in ms.");
123int StdPropagationDelayMs() {
124 return static_cast<int>(FLAGS_std_propagation_delay_ms);
125}
126
127DEFINE_bool(logs, false, "print logs to stderr");
128
129DEFINE_string(
ivica5d6a06c2015-09-17 05:30:24 -0700130 output_filename,
131 "",
132 "Name of a target graph data file. If set, no preview will be shown.");
133std::string OutputFilename() {
134 return static_cast<std::string>(FLAGS_output_filename);
135}
136
137DEFINE_int32(duration, 60, "Duration of the test in seconds.");
138int DurationSecs() {
139 return static_cast<int>(FLAGS_duration);
140}
141
142DEFINE_string(
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000143 force_fieldtrials,
144 "",
145 "Field trials control experimental feature code which can be forced. "
146 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
147 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple "
148 "trials are separated by \"/\"");
149} // namespace flags
150
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000151void Loopback() {
ivica5d6a06c2015-09-17 05:30:24 -0700152 FakeNetworkPipe::Config pipe_config;
153 pipe_config.loss_percent = flags::LossPercent();
154 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps();
155 pipe_config.queue_length_packets = flags::QueueSize();
156 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs();
157 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs();
158
159 Call::Config::BitrateConfig call_bitrate_config;
160 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000;
161 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000;
162 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000;
163
164 VideoQualityTest::Params params{
165 {
166 flags::Width(),
167 flags::Height(),
168 flags::Fps(),
169 flags::MinBitrateKbps() * 1000,
170 flags::TargetBitrateKbps() * 1000,
171 flags::MaxBitrateKbps() * 1000,
172 flags::Codec(),
173 flags::NumTemporalLayers(),
174 flags::MinTransmitBitrateKbps() * 1000,
175 call_bitrate_config,
176 flags::TLDiscardThreshold()
177 },
178 {}, // Video specific.
179 {true, flags::SlideChangeInterval(), flags::ScrollDuration()},
180 {"screenshare", 0.0, 0.0, flags::DurationSecs(), flags::OutputFilename()},
181 pipe_config,
182 flags::FLAGS_logs};
183
184 VideoQualityTest test;
185 if (flags::OutputFilename().empty())
186 test.RunWithVideoRenderer(params);
187 else
188 test.RunWithAnalyzer(params);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000189}
190} // namespace webrtc
191
192int main(int argc, char* argv[]) {
193 ::testing::InitGoogleTest(&argc, argv);
194 google::ParseCommandLineFlags(&argc, &argv, true);
195 webrtc::test::InitFieldTrialsFromString(
196 webrtc::flags::FLAGS_force_fieldtrials);
197 webrtc::test::RunTest(webrtc::Loopback);
198 return 0;
199}