OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include <stdio.h> | 11 #include <stdio.h> |
12 | 12 |
13 #include <map> | 13 #include <map> |
14 | 14 |
15 #include "gflags/gflags.h" | 15 #include "gflags/gflags.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
18 #include "webrtc/test/field_trial.h" | 18 #include "webrtc/test/field_trial.h" |
19 #include "webrtc/test/run_test.h" | 19 #include "webrtc/test/run_test.h" |
20 #include "webrtc/typedefs.h" | 20 #include "webrtc/typedefs.h" |
21 #include "webrtc/video/loopback.h" | 21 #include "webrtc/video/video_quality_test.h" |
22 | 22 |
23 namespace webrtc { | 23 namespace webrtc { |
24 | 24 |
25 namespace flags { | 25 namespace flags { |
26 | 26 |
27 DEFINE_int32(width, 640, "Video width."); | 27 DEFINE_int32(width, 640, "Video width."); |
28 size_t Width() { | 28 size_t Width() { |
29 return static_cast<size_t>(FLAGS_width); | 29 return static_cast<size_t>(FLAGS_width); |
30 } | 30 } |
31 | 31 |
32 DEFINE_int32(height, 480, "Video height."); | 32 DEFINE_int32(height, 480, "Video height."); |
33 size_t Height() { | 33 size_t Height() { |
34 return static_cast<size_t>(FLAGS_height); | 34 return static_cast<size_t>(FLAGS_height); |
35 } | 35 } |
36 | 36 |
37 DEFINE_int32(fps, 30, "Frames per second."); | 37 DEFINE_int32(fps, 30, "Frames per second."); |
38 int Fps() { | 38 int Fps() { |
39 return static_cast<int>(FLAGS_fps); | 39 return static_cast<int>(FLAGS_fps); |
40 } | 40 } |
41 | 41 |
42 DEFINE_int32(min_bitrate, 50, "Minimum video bitrate."); | 42 DEFINE_int32(min_bitrate, 50, "Minimum video bitrate."); |
43 size_t MinBitrate() { | 43 size_t MinBitrateKbps() { |
44 return static_cast<size_t>(FLAGS_min_bitrate); | 44 return static_cast<size_t>(FLAGS_min_bitrate); |
45 } | 45 } |
46 | 46 |
47 DEFINE_int32(start_bitrate, 300, "Video starting bitrate."); | 47 DEFINE_int32(start_bitrate, 300, "Video starting bitrate."); |
48 size_t StartBitrate() { | 48 size_t StartBitrateKbps() { |
49 return static_cast<size_t>(FLAGS_start_bitrate); | 49 return static_cast<size_t>(FLAGS_start_bitrate); |
50 } | 50 } |
51 | 51 |
52 DEFINE_int32(max_bitrate, 800, "Maximum video bitrate."); | 52 DEFINE_int32(max_bitrate, 800, "Maximum video bitrate."); |
53 size_t MaxBitrate() { | 53 size_t MaxBitrateKbps() { |
54 return static_cast<size_t>(FLAGS_max_bitrate); | 54 return static_cast<size_t>(FLAGS_max_bitrate); |
55 } | 55 } |
56 | 56 |
57 int MinTransmitBitrate() { | |
58 return 0; | |
59 } // No min padding for regular video. | |
60 | |
61 DEFINE_string(codec, "VP8", "Video codec to use."); | 57 DEFINE_string(codec, "VP8", "Video codec to use."); |
62 std::string Codec() { | 58 std::string Codec() { |
63 return static_cast<std::string>(FLAGS_codec); | 59 return static_cast<std::string>(FLAGS_codec); |
64 } | 60 } |
65 | 61 |
66 DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost."); | 62 DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost."); |
67 int LossPercent() { | 63 int LossPercent() { |
68 return static_cast<int>(FLAGS_loss_percent); | 64 return static_cast<int>(FLAGS_loss_percent); |
69 } | 65 } |
70 | 66 |
71 DEFINE_int32(link_capacity, | 67 DEFINE_int32(link_capacity, |
72 0, | 68 0, |
73 "Capacity (kbps) of the fake link. 0 means infinite."); | 69 "Capacity (kbps) of the fake link. 0 means infinite."); |
74 int LinkCapacity() { | 70 int LinkCapacityKbps() { |
75 return static_cast<int>(FLAGS_link_capacity); | 71 return static_cast<int>(FLAGS_link_capacity); |
76 } | 72 } |
77 | 73 |
78 DEFINE_int32(queue_size, 0, "Size of the bottleneck link queue in packets."); | 74 DEFINE_int32(queue_size, 0, "Size of the bottleneck link queue in packets."); |
79 int QueueSize() { | 75 int QueueSize() { |
80 return static_cast<int>(FLAGS_queue_size); | 76 return static_cast<int>(FLAGS_queue_size); |
81 } | 77 } |
82 | 78 |
83 DEFINE_int32(avg_propagation_delay_ms, | 79 DEFINE_int32(avg_propagation_delay_ms, |
84 0, | 80 0, |
(...skipping 15 matching lines...) Expand all Loading... |
100 force_fieldtrials, | 96 force_fieldtrials, |
101 "", | 97 "", |
102 "Field trials control experimental feature code which can be forced. " | 98 "Field trials control experimental feature code which can be forced. " |
103 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" | 99 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" |
104 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple " | 100 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple " |
105 "trials are separated by \"/\""); | 101 "trials are separated by \"/\""); |
106 | 102 |
107 DEFINE_int32(num_temporal_layers, | 103 DEFINE_int32(num_temporal_layers, |
108 0, | 104 0, |
109 "Number of temporal layers. Set to 1-4 to override."); | 105 "Number of temporal layers. Set to 1-4 to override."); |
110 | |
111 size_t NumTemporalLayers() { | 106 size_t NumTemporalLayers() { |
112 return static_cast<size_t>(FLAGS_num_temporal_layers); | 107 return static_cast<size_t>(FLAGS_num_temporal_layers); |
113 } | 108 } |
114 | 109 |
| 110 DEFINE_int32( |
| 111 tl_discard_threshold, |
| 112 0, |
| 113 "Discard TLs with id greater or equal the threshold. 0 to disable."); |
| 114 size_t TLDiscardThreshold() { |
| 115 return static_cast<size_t>(FLAGS_tl_discard_threshold); |
| 116 } |
| 117 |
| 118 DEFINE_string(clip, |
| 119 "", |
| 120 "Name of the clip to show. If empty, using chroma generator."); |
| 121 std::string Clip() { |
| 122 return static_cast<std::string>(FLAGS_clip); |
| 123 } |
| 124 |
| 125 DEFINE_string( |
| 126 output_filename, |
| 127 "", |
| 128 "Name of a target graph data file. If set, no preview will be shown."); |
| 129 std::string OutputFilename() { |
| 130 return static_cast<std::string>(FLAGS_output_filename); |
| 131 } |
| 132 |
| 133 DEFINE_int32(duration, 60, "Duration of the test in seconds."); |
| 134 int DurationSecs() { |
| 135 return static_cast<int>(FLAGS_duration); |
| 136 } |
| 137 |
115 } // namespace flags | 138 } // namespace flags |
116 | 139 |
117 void Loopback() { | 140 void Loopback() { |
118 test::Loopback::Config config{flags::Width(), | 141 FakeNetworkPipe::Config pipe_config; |
119 flags::Height(), | 142 pipe_config.loss_percent = flags::LossPercent(); |
120 flags::Fps(), | 143 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps(); |
121 flags::MinBitrate(), | 144 pipe_config.queue_length_packets = flags::QueueSize(); |
122 flags::StartBitrate(), | 145 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs(); |
123 flags::MaxBitrate(), | 146 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs(); |
124 0, // No min transmit bitrate. | 147 |
125 flags::Codec(), | 148 std::string clip = flags::Clip(); |
126 flags::NumTemporalLayers(), | 149 std::string graph_title = clip.empty() ? "" : "video " + clip; |
127 flags::LossPercent(), | 150 VideoQualityTest::Params params{ |
128 flags::LinkCapacity(), | 151 { |
129 flags::QueueSize(), | 152 flags::Width(), |
130 flags::AvgPropagationDelayMs(), | 153 flags::Height(), |
131 flags::StdPropagationDelayMs(), | 154 flags::Fps(), |
132 flags::FLAGS_logs}; | 155 flags::MinBitrateKbps() * 1000, |
133 test::Loopback loopback(config); | 156 flags::StartBitrateKbps() * 1000, // TODO(ivica): target |
134 loopback.Run(); | 157 flags::MaxBitrateKbps() * 1000, |
| 158 flags::Codec(), |
| 159 flags::NumTemporalLayers(), |
| 160 flags::StartBitrateKbps() * 1000, |
| 161 0, // No min transmit bitrate. |
| 162 flags::TLDiscardThreshold() |
| 163 }, |
| 164 {clip}, |
| 165 {}, // Screenshare specific. |
| 166 {graph_title, 0.0, 0.0, flags::DurationSecs(), flags::OutputFilename()}, |
| 167 pipe_config, |
| 168 flags::FLAGS_logs}; |
| 169 |
| 170 VideoQualityTest test; |
| 171 if (flags::OutputFilename().empty()) |
| 172 test.RunWithVideoRenderer(params); |
| 173 else |
| 174 test.RunWithAnalyzer(params); |
135 } | 175 } |
136 } // namespace webrtc | 176 } // namespace webrtc |
137 | 177 |
138 int main(int argc, char* argv[]) { | 178 int main(int argc, char* argv[]) { |
139 ::testing::InitGoogleTest(&argc, argv); | 179 ::testing::InitGoogleTest(&argc, argv); |
140 google::ParseCommandLineFlags(&argc, &argv, true); | 180 google::ParseCommandLineFlags(&argc, &argv, true); |
141 webrtc::test::InitFieldTrialsFromString( | 181 webrtc::test::InitFieldTrialsFromString( |
142 webrtc::flags::FLAGS_force_fieldtrials); | 182 webrtc::flags::FLAGS_force_fieldtrials); |
143 webrtc::test::RunTest(webrtc::Loopback); | 183 webrtc::test::RunTest(webrtc::Loopback); |
144 return 0; | 184 return 0; |
145 } | 185 } |
OLD | NEW |