blob: d183920b16787e6f79fd0cc9da8ddb482f4944b9 [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 \"/\"");
106} // namespace flags
107
108void Loopback() {
109 test::Loopback::Config config{flags::Width(),
110 flags::Height(),
111 flags::Fps(),
112 flags::MinBitrate(),
113 flags::StartBitrate(),
114 flags::MaxBitrate(),
115 0, // No min transmit bitrate.
116 flags::Codec(),
117 flags::LossPercent(),
118 flags::LinkCapacity(),
119 flags::QueueSize(),
120 flags::AvgPropagationDelayMs(),
121 flags::StdPropagationDelayMs(),
122 flags::FLAGS_logs};
123 test::Loopback loopback(config);
124 loopback.Run();
125}
126} // namespace webrtc
127
128int main(int argc, char* argv[]) {
129 ::testing::InitGoogleTest(&argc, argv);
130 google::ParseCommandLineFlags(&argc, &argv, true);
131 webrtc::test::InitFieldTrialsFromString(
132 webrtc::flags::FLAGS_force_fieldtrials);
133 webrtc::test::RunTest(webrtc::Loopback);
134 return 0;
135}