sprang@webrtc.org | 131bea8 | 2015-02-18 12:46:06 +0000 | [diff] [blame^] | 1 | /* |
| 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 | |
| 23 | namespace webrtc { |
| 24 | |
| 25 | namespace flags { |
| 26 | |
| 27 | DEFINE_int32(width, 640, "Video width."); |
| 28 | size_t Width() { |
| 29 | return static_cast<size_t>(FLAGS_width); |
| 30 | } |
| 31 | |
| 32 | DEFINE_int32(height, 480, "Video height."); |
| 33 | size_t Height() { |
| 34 | return static_cast<size_t>(FLAGS_height); |
| 35 | } |
| 36 | |
| 37 | DEFINE_int32(fps, 30, "Frames per second."); |
| 38 | int Fps() { |
| 39 | return static_cast<int>(FLAGS_fps); |
| 40 | } |
| 41 | |
| 42 | DEFINE_int32(min_bitrate, 50, "Minimum video bitrate."); |
| 43 | size_t MinBitrate() { |
| 44 | return static_cast<size_t>(FLAGS_min_bitrate); |
| 45 | } |
| 46 | |
| 47 | DEFINE_int32(start_bitrate, 300, "Video starting bitrate."); |
| 48 | size_t StartBitrate() { |
| 49 | return static_cast<size_t>(FLAGS_start_bitrate); |
| 50 | } |
| 51 | |
| 52 | DEFINE_int32(max_bitrate, 800, "Maximum video bitrate."); |
| 53 | size_t MaxBitrate() { |
| 54 | return static_cast<size_t>(FLAGS_max_bitrate); |
| 55 | } |
| 56 | |
| 57 | int MinTransmitBitrate() { |
| 58 | return 0; |
| 59 | } // No min padding for regular video. |
| 60 | |
| 61 | DEFINE_string(codec, "VP8", "Video codec to use."); |
| 62 | std::string Codec() { |
| 63 | return static_cast<std::string>(FLAGS_codec); |
| 64 | } |
| 65 | |
| 66 | DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost."); |
| 67 | int LossPercent() { |
| 68 | return static_cast<int>(FLAGS_loss_percent); |
| 69 | } |
| 70 | |
| 71 | DEFINE_int32(link_capacity, |
| 72 | 0, |
| 73 | "Capacity (kbps) of the fake link. 0 means infinite."); |
| 74 | int LinkCapacity() { |
| 75 | return static_cast<int>(FLAGS_link_capacity); |
| 76 | } |
| 77 | |
| 78 | DEFINE_int32(queue_size, 0, "Size of the bottleneck link queue in packets."); |
| 79 | int QueueSize() { |
| 80 | return static_cast<int>(FLAGS_queue_size); |
| 81 | } |
| 82 | |
| 83 | DEFINE_int32(avg_propagation_delay_ms, |
| 84 | 0, |
| 85 | "Average link propagation delay in ms."); |
| 86 | int AvgPropagationDelayMs() { |
| 87 | return static_cast<int>(FLAGS_avg_propagation_delay_ms); |
| 88 | } |
| 89 | |
| 90 | DEFINE_int32(std_propagation_delay_ms, |
| 91 | 0, |
| 92 | "Link propagation delay standard deviation in ms."); |
| 93 | int StdPropagationDelayMs() { |
| 94 | return static_cast<int>(FLAGS_std_propagation_delay_ms); |
| 95 | } |
| 96 | |
| 97 | DEFINE_bool(logs, false, "print logs to stderr"); |
| 98 | |
| 99 | DEFINE_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 | |
| 108 | void 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 | |
| 128 | int 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 | } |