blob: 789b5cceacf0f4601a7c391bc7590c069b3cce16 [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"
21#include "webrtc/video/loopback.h"
22
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
42DEFINE_int32(min_bitrate, 50, "Minimum video bitrate.");
43size_t MinBitrate() {
44 return static_cast<size_t>(FLAGS_min_bitrate);
45}
46
47DEFINE_int32(start_bitrate, 300, "Video starting bitrate.");
48size_t StartBitrate() {
49 return static_cast<size_t>(FLAGS_start_bitrate);
50}
51
52DEFINE_int32(max_bitrate, 800, "Maximum video bitrate.");
53size_t MaxBitrate() {
54 return static_cast<size_t>(FLAGS_max_bitrate);
55}
56
57int MinTransmitBitrate() {
58 return 0;
59} // No min padding for regular video.
60
61DEFINE_string(codec, "VP8", "Video codec to use.");
62std::string Codec() {
63 return static_cast<std::string>(FLAGS_codec);
64}
65
66DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost.");
67int LossPercent() {
68 return static_cast<int>(FLAGS_loss_percent);
69}
70
71DEFINE_int32(link_capacity,
72 0,
73 "Capacity (kbps) of the fake link. 0 means infinite.");
74int LinkCapacity() {
75 return static_cast<int>(FLAGS_link_capacity);
76}
77
78DEFINE_int32(queue_size, 0, "Size of the bottleneck link queue in packets.");
79int QueueSize() {
80 return static_cast<int>(FLAGS_queue_size);
81}
82
83DEFINE_int32(avg_propagation_delay_ms,
84 0,
85 "Average link propagation delay in ms.");
86int AvgPropagationDelayMs() {
87 return static_cast<int>(FLAGS_avg_propagation_delay_ms);
88}
89
90DEFINE_int32(std_propagation_delay_ms,
91 0,
92 "Link propagation delay standard deviation in ms.");
93int StdPropagationDelayMs() {
94 return static_cast<int>(FLAGS_std_propagation_delay_ms);
95}
96
97DEFINE_bool(logs, false, "print logs to stderr");
98
99DEFINE_string(
100 force_fieldtrials,
101 "",
102 "Field trials control experimental feature code which can be forced. "
103 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
104 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple "
105 "trials are separated by \"/\"");
pbos9874ee02015-06-22 04:44:26 -0700106
107DEFINE_int32(num_temporal_layers,
108 0,
109 "Number of temporal layers. Set to 1-4 to override.");
110
111size_t NumTemporalLayers() {
112 return static_cast<size_t>(FLAGS_num_temporal_layers);
113}
114
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000115} // namespace flags
116
117void Loopback() {
118 test::Loopback::Config config{flags::Width(),
119 flags::Height(),
120 flags::Fps(),
121 flags::MinBitrate(),
122 flags::StartBitrate(),
123 flags::MaxBitrate(),
124 0, // No min transmit bitrate.
125 flags::Codec(),
pbos9874ee02015-06-22 04:44:26 -0700126 flags::NumTemporalLayers(),
sprang@webrtc.org131bea82015-02-18 12:46:06 +0000127 flags::LossPercent(),
128 flags::LinkCapacity(),
129 flags::QueueSize(),
130 flags::AvgPropagationDelayMs(),
131 flags::StdPropagationDelayMs(),
132 flags::FLAGS_logs};
133 test::Loopback loopback(config);
134 loopback.Run();
135}
136} // namespace webrtc
137
138int main(int argc, char* argv[]) {
139 ::testing::InitGoogleTest(&argc, argv);
140 google::ParseCommandLineFlags(&argc, &argv, true);
141 webrtc::test::InitFieldTrialsFromString(
142 webrtc::flags::FLAGS_force_fieldtrials);
143 webrtc::test::RunTest(webrtc::Loopback);
144 return 0;
145}