blob: c5e9254c087ff4a106903885be2797e56551657e [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
13#include <map>
14
15#include "gflags/gflags.h"
16#include "testing/gtest/include/gtest/gtest.h"
17
18#include "webrtc/test/field_trial.h"
19#include "webrtc/test/run_test.h"
20#include "webrtc/typedefs.h"
ivica5d6a06c2015-09-17 05:30:24 -070021#include "webrtc/video/video_quality_test.h"
sprang@webrtc.org131bea82015-02-18 12:46:06 +000022
23namespace webrtc {
24
25namespace flags {
26
27DEFINE_int32(width, 640, "Video width.");
28size_t Width() {
29 return static_cast<size_t>(FLAGS_width);
30}
31
32DEFINE_int32(height, 480, "Video height.");
33size_t Height() {
34 return static_cast<size_t>(FLAGS_height);
35}
36
37DEFINE_int32(fps, 30, "Frames per second.");
38int Fps() {
39 return static_cast<int>(FLAGS_fps);
40}
41
ivica5d6a06c2015-09-17 05:30:24 -070042DEFINE_int32(min_bitrate, 50, "Call and stream min bitrate in kbps.");
43int MinBitrateKbps() {
44 return static_cast<int>(FLAGS_min_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000045}
46
ivica5d6a06c2015-09-17 05:30:24 -070047DEFINE_int32(start_bitrate, 300, "Call start bitrate in kbps.");
48int StartBitrateKbps() {
49 return static_cast<int>(FLAGS_start_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000050}
51
ivica5d6a06c2015-09-17 05:30:24 -070052DEFINE_int32(target_bitrate, 800, "Stream target bitrate in kbps.");
53int TargetBitrateKbps() {
54 return static_cast<int>(FLAGS_target_bitrate);
sprang@webrtc.org131bea82015-02-18 12:46:06 +000055}
56
ivica5d6a06c2015-09-17 05:30:24 -070057DEFINE_int32(max_bitrate, 800, "Call and stream max bitrate in kbps.");
58int MaxBitrateKbps() {
59 return static_cast<int>(FLAGS_max_bitrate);
60}
sprang@webrtc.org131bea82015-02-18 12:46:06 +000061
62DEFINE_string(codec, "VP8", "Video codec to use.");
63std::string Codec() {
64 return static_cast<std::string>(FLAGS_codec);
65}
66
67DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost.");
68int LossPercent() {
69 return static_cast<int>(FLAGS_loss_percent);
70}
71
72DEFINE_int32(link_capacity,
73 0,
74 "Capacity (kbps) of the fake link. 0 means infinite.");
ivica5d6a06c2015-09-17 05:30:24 -070075int LinkCapacityKbps() {
sprang@webrtc.org131bea82015-02-18 12:46:06 +000076 return static_cast<int>(FLAGS_link_capacity);
77}
78
79DEFINE_int32(queue_size, 0, "Size of the bottleneck link queue in packets.");
80int QueueSize() {
81 return static_cast<int>(FLAGS_queue_size);
82}
83
84DEFINE_int32(avg_propagation_delay_ms,
85 0,
86 "Average link propagation delay in ms.");
87int AvgPropagationDelayMs() {
88 return static_cast<int>(FLAGS_avg_propagation_delay_ms);
89}
90
91DEFINE_int32(std_propagation_delay_ms,
92 0,
93 "Link propagation delay standard deviation in ms.");
94int StdPropagationDelayMs() {
95 return static_cast<int>(FLAGS_std_propagation_delay_ms);
96}
97
98DEFINE_bool(logs, false, "print logs to stderr");
99
100DEFINE_string(
101 force_fieldtrials,
102 "",
103 "Field trials control experimental feature code which can be forced. "
104 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
105 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple "
106 "trials are separated by \"/\"");
pbos9874ee02015-06-22 04:44:26 -0700107
108DEFINE_int32(num_temporal_layers,
ivica5d6a06c2015-09-17 05:30:24 -0700109 1,
pbos9874ee02015-06-22 04:44:26 -0700110 "Number of temporal layers. Set to 1-4 to override.");
pbos9874ee02015-06-22 04:44:26 -0700111size_t NumTemporalLayers() {
112 return static_cast<size_t>(FLAGS_num_temporal_layers);
113}
114
ivica5d6a06c2015-09-17 05:30:24 -0700115DEFINE_int32(
116 tl_discard_threshold,
117 0,
118 "Discard TLs with id greater or equal the threshold. 0 to disable.");
119size_t TLDiscardThreshold() {
120 return static_cast<size_t>(FLAGS_tl_discard_threshold);
121}
122
123DEFINE_string(clip,
124 "",
125 "Name of the clip to show. If empty, using chroma generator.");
126std::string Clip() {
127 return static_cast<std::string>(FLAGS_clip);
128}
129
130DEFINE_string(
131 output_filename,
132 "",
133 "Name of a target graph data file. If set, no preview will be shown.");
134std::string OutputFilename() {
135 return static_cast<std::string>(FLAGS_output_filename);
136}
137
138DEFINE_int32(duration, 60, "Duration of the test in seconds.");
139int DurationSecs() {
140 return static_cast<int>(FLAGS_duration);
141}
142
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000143} // namespace flags
144
145void Loopback() {
ivica5d6a06c2015-09-17 05:30:24 -0700146 FakeNetworkPipe::Config pipe_config;
147 pipe_config.loss_percent = flags::LossPercent();
148 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps();
149 pipe_config.queue_length_packets = flags::QueueSize();
150 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs();
151 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs();
152
153 Call::Config::BitrateConfig call_bitrate_config;
154 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000;
155 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000;
156 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000;
157
158 std::string clip = flags::Clip();
159 std::string graph_title = clip.empty() ? "" : "video " + clip;
160 VideoQualityTest::Params params{
161 {
162 flags::Width(),
163 flags::Height(),
164 flags::Fps(),
165 flags::MinBitrateKbps() * 1000,
166 flags::TargetBitrateKbps() * 1000,
167 flags::MaxBitrateKbps() * 1000,
168 flags::Codec(),
169 flags::NumTemporalLayers(),
170 0, // No min transmit bitrate.
171 call_bitrate_config,
172 flags::TLDiscardThreshold()
173 },
174 {clip},
175 {}, // Screenshare specific.
176 {graph_title, 0.0, 0.0, flags::DurationSecs(), flags::OutputFilename()},
177 pipe_config,
178 flags::FLAGS_logs};
179
180 VideoQualityTest test;
181 if (flags::OutputFilename().empty())
182 test.RunWithVideoRenderer(params);
183 else
184 test.RunWithAnalyzer(params);
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000185}
186} // namespace webrtc
187
188int main(int argc, char* argv[]) {
189 ::testing::InitGoogleTest(&argc, argv);
190 google::ParseCommandLineFlags(&argc, &argv, true);
191 webrtc::test::InitFieldTrialsFromString(
192 webrtc::flags::FLAGS_force_fieldtrials);
193 webrtc::test::RunTest(webrtc::Loopback);
194 return 0;
195}