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> | |
14 | |
15 #include "gflags/gflags.h" | 13 #include "gflags/gflags.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
17 | 15 |
18 #include "webrtc/test/field_trial.h" | 16 #include "webrtc/test/field_trial.h" |
19 #include "webrtc/test/run_test.h" | 17 #include "webrtc/test/run_test.h" |
20 #include "webrtc/typedefs.h" | |
21 #include "webrtc/video/video_quality_test.h" | 18 #include "webrtc/video/video_quality_test.h" |
22 | 19 |
23 namespace webrtc { | 20 namespace webrtc { |
24 | |
25 namespace flags { | 21 namespace flags { |
26 | 22 |
| 23 // Flags common with screenshare loopback, with different default values. |
27 DEFINE_int32(width, 640, "Video width."); | 24 DEFINE_int32(width, 640, "Video width."); |
28 size_t Width() { | 25 size_t Width() { |
29 return static_cast<size_t>(FLAGS_width); | 26 return static_cast<size_t>(FLAGS_width); |
30 } | 27 } |
31 | 28 |
32 DEFINE_int32(height, 480, "Video height."); | 29 DEFINE_int32(height, 480, "Video height."); |
33 size_t Height() { | 30 size_t Height() { |
34 return static_cast<size_t>(FLAGS_height); | 31 return static_cast<size_t>(FLAGS_height); |
35 } | 32 } |
36 | 33 |
(...skipping 15 matching lines...) Expand all Loading... |
52 DEFINE_int32(target_bitrate, 800, "Stream target bitrate in kbps."); | 49 DEFINE_int32(target_bitrate, 800, "Stream target bitrate in kbps."); |
53 int TargetBitrateKbps() { | 50 int TargetBitrateKbps() { |
54 return static_cast<int>(FLAGS_target_bitrate); | 51 return static_cast<int>(FLAGS_target_bitrate); |
55 } | 52 } |
56 | 53 |
57 DEFINE_int32(max_bitrate, 800, "Call and stream max bitrate in kbps."); | 54 DEFINE_int32(max_bitrate, 800, "Call and stream max bitrate in kbps."); |
58 int MaxBitrateKbps() { | 55 int MaxBitrateKbps() { |
59 return static_cast<int>(FLAGS_max_bitrate); | 56 return static_cast<int>(FLAGS_max_bitrate); |
60 } | 57 } |
61 | 58 |
| 59 DEFINE_int32(num_temporal_layers, |
| 60 1, |
| 61 "Number of temporal layers. Set to 1-4 to override."); |
| 62 size_t NumTemporalLayers() { |
| 63 return static_cast<size_t>(FLAGS_num_temporal_layers); |
| 64 } |
| 65 |
| 66 // Flags common with screenshare loopback, with equal default values. |
62 DEFINE_string(codec, "VP8", "Video codec to use."); | 67 DEFINE_string(codec, "VP8", "Video codec to use."); |
63 std::string Codec() { | 68 std::string Codec() { |
64 return static_cast<std::string>(FLAGS_codec); | 69 return static_cast<std::string>(FLAGS_codec); |
65 } | 70 } |
66 | 71 |
| 72 DEFINE_int32(selected_tl, |
| 73 -1, |
| 74 "Temporal layer to show or analyze. -1 to disable filtering."); |
| 75 int SelectedTL() { |
| 76 return static_cast<int>(FLAGS_selected_tl); |
| 77 } |
| 78 |
| 79 DEFINE_int32( |
| 80 duration, |
| 81 0, |
| 82 "Duration of the test in seconds. If 0, rendered will be shown instead."); |
| 83 int DurationSecs() { |
| 84 return static_cast<int>(FLAGS_duration); |
| 85 } |
| 86 |
| 87 DEFINE_string(output_filename, "", "Target graph data filename."); |
| 88 std::string OutputFilename() { |
| 89 return static_cast<std::string>(FLAGS_output_filename); |
| 90 } |
| 91 |
| 92 DEFINE_string(graph_title, |
| 93 AUTO_GRAPH_TITLE, |
| 94 "If default value used, title will be generated automatically."); |
| 95 std::string GraphTitle() { |
| 96 return static_cast<std::string>(FLAGS_graph_title); |
| 97 } |
| 98 |
67 DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost."); | 99 DEFINE_int32(loss_percent, 0, "Percentage of packets randomly lost."); |
68 int LossPercent() { | 100 int LossPercent() { |
69 return static_cast<int>(FLAGS_loss_percent); | 101 return static_cast<int>(FLAGS_loss_percent); |
70 } | 102 } |
71 | 103 |
72 DEFINE_int32(link_capacity, | 104 DEFINE_int32(link_capacity, |
73 0, | 105 0, |
74 "Capacity (kbps) of the fake link. 0 means infinite."); | 106 "Capacity (kbps) of the fake link. 0 means infinite."); |
75 int LinkCapacityKbps() { | 107 int LinkCapacityKbps() { |
76 return static_cast<int>(FLAGS_link_capacity); | 108 return static_cast<int>(FLAGS_link_capacity); |
(...skipping 11 matching lines...) Expand all Loading... |
88 return static_cast<int>(FLAGS_avg_propagation_delay_ms); | 120 return static_cast<int>(FLAGS_avg_propagation_delay_ms); |
89 } | 121 } |
90 | 122 |
91 DEFINE_int32(std_propagation_delay_ms, | 123 DEFINE_int32(std_propagation_delay_ms, |
92 0, | 124 0, |
93 "Link propagation delay standard deviation in ms."); | 125 "Link propagation delay standard deviation in ms."); |
94 int StdPropagationDelayMs() { | 126 int StdPropagationDelayMs() { |
95 return static_cast<int>(FLAGS_std_propagation_delay_ms); | 127 return static_cast<int>(FLAGS_std_propagation_delay_ms); |
96 } | 128 } |
97 | 129 |
| 130 DEFINE_int32(selected_stream, 0, "ID of the stream to show or analyze."); |
| 131 size_t SelectedStream() { |
| 132 return static_cast<size_t>(FLAGS_selected_stream); |
| 133 } |
| 134 |
| 135 DEFINE_int32(num_spatial_layers, 1, "Number of spatial layers to use."); |
| 136 int NumSpatialLayers() { |
| 137 return static_cast<int>(FLAGS_num_spatial_layers); |
| 138 } |
| 139 |
| 140 DEFINE_int32(selected_sl, |
| 141 -1, |
| 142 "Spatial layer to show or analyze. -1 to disable filtering."); |
| 143 int SelectedSL() { |
| 144 return static_cast<int>(FLAGS_selected_sl); |
| 145 } |
| 146 |
| 147 DEFINE_string(stream0, |
| 148 "", |
| 149 "Comma separated values describing VideoStream for stream #0."); |
| 150 std::string Stream0() { |
| 151 return static_cast<std::string>(FLAGS_stream0); |
| 152 } |
| 153 |
| 154 DEFINE_string(stream1, |
| 155 "", |
| 156 "Comma separated values describing VideoStream for stream #1."); |
| 157 std::string Stream1() { |
| 158 return static_cast<std::string>(FLAGS_stream1); |
| 159 } |
| 160 |
| 161 DEFINE_string( |
| 162 sl0, "", "Comma separated values describing SpatialLayer for layer #0."); |
| 163 std::string SL0() { |
| 164 return static_cast<std::string>(FLAGS_sl0); |
| 165 } |
| 166 |
| 167 DEFINE_string( |
| 168 sl1, "", "Comma separated values describing SpatialLayer for layer #1."); |
| 169 std::string SL1() { |
| 170 return static_cast<std::string>(FLAGS_sl1); |
| 171 } |
| 172 |
98 DEFINE_bool(logs, false, "print logs to stderr"); | 173 DEFINE_bool(logs, false, "print logs to stderr"); |
99 | 174 |
| 175 DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation"); |
| 176 |
100 DEFINE_string( | 177 DEFINE_string( |
101 force_fieldtrials, | 178 force_fieldtrials, |
102 "", | 179 "", |
103 "Field trials control experimental feature code which can be forced. " | 180 "Field trials control experimental feature code which can be forced. " |
104 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" | 181 "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" |
105 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple " | 182 " will assign the group Enable to field trial WebRTC-FooFeature. Multiple " |
106 "trials are separated by \"/\""); | 183 "trials are separated by \"/\""); |
107 | 184 |
108 DEFINE_int32(num_temporal_layers, | 185 // Video-specific flags. |
109 1, | |
110 "Number of temporal layers. Set to 1-4 to override."); | |
111 size_t NumTemporalLayers() { | |
112 return static_cast<size_t>(FLAGS_num_temporal_layers); | |
113 } | |
114 | |
115 DEFINE_int32( | |
116 tl_discard_threshold, | |
117 0, | |
118 "Discard TLs with id greater or equal the threshold. 0 to disable."); | |
119 size_t TLDiscardThreshold() { | |
120 return static_cast<size_t>(FLAGS_tl_discard_threshold); | |
121 } | |
122 | |
123 DEFINE_string(clip, | 186 DEFINE_string(clip, |
124 "", | 187 "", |
125 "Name of the clip to show. If empty, using chroma generator."); | 188 "Name of the clip to show. If empty, using chroma generator."); |
126 std::string Clip() { | 189 std::string Clip() { |
127 return static_cast<std::string>(FLAGS_clip); | 190 return static_cast<std::string>(FLAGS_clip); |
128 } | 191 } |
129 | 192 |
130 DEFINE_string( | |
131 output_filename, | |
132 "", | |
133 "Name of a target graph data file. If set, no preview will be shown."); | |
134 std::string OutputFilename() { | |
135 return static_cast<std::string>(FLAGS_output_filename); | |
136 } | |
137 | |
138 DEFINE_int32(duration, 60, "Duration of the test in seconds."); | |
139 int DurationSecs() { | |
140 return static_cast<int>(FLAGS_duration); | |
141 } | |
142 | |
143 DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation"); | |
144 | |
145 } // namespace flags | 193 } // namespace flags |
146 | 194 |
147 void Loopback() { | 195 void Loopback() { |
148 FakeNetworkPipe::Config pipe_config; | 196 FakeNetworkPipe::Config pipe_config; |
149 pipe_config.loss_percent = flags::LossPercent(); | 197 pipe_config.loss_percent = flags::LossPercent(); |
150 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps(); | 198 pipe_config.link_capacity_kbps = flags::LinkCapacityKbps(); |
151 pipe_config.queue_length_packets = flags::QueueSize(); | 199 pipe_config.queue_length_packets = flags::QueueSize(); |
152 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs(); | 200 pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs(); |
153 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs(); | 201 pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs(); |
154 | 202 |
155 Call::Config::BitrateConfig call_bitrate_config; | 203 Call::Config::BitrateConfig call_bitrate_config; |
156 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000; | 204 call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000; |
157 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000; | 205 call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000; |
158 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000; | 206 call_bitrate_config.max_bitrate_bps = flags::MaxBitrateKbps() * 1000; |
159 | 207 |
160 std::string clip = flags::Clip(); | |
161 std::string graph_title = clip.empty() ? "" : "video " + clip; | |
162 VideoQualityTest::Params params{ | 208 VideoQualityTest::Params params{ |
163 {flags::Width(), flags::Height(), flags::Fps(), | 209 {flags::Width(), flags::Height(), flags::Fps(), |
164 flags::MinBitrateKbps() * 1000, flags::TargetBitrateKbps() * 1000, | 210 flags::MinBitrateKbps() * 1000, flags::TargetBitrateKbps() * 1000, |
165 flags::MaxBitrateKbps() * 1000, flags::Codec(), | 211 flags::MaxBitrateKbps() * 1000, flags::Codec(), |
166 flags::NumTemporalLayers(), | 212 flags::NumTemporalLayers(), flags::SelectedTL(), |
167 0, // No min transmit bitrate. | 213 0, // No min transmit bitrate. |
168 call_bitrate_config, flags::TLDiscardThreshold(), | 214 call_bitrate_config, flags::FLAGS_send_side_bwe}, |
169 flags::FLAGS_send_side_bwe}, | 215 {flags::Clip()}, |
170 {clip}, | |
171 {}, // Screenshare specific. | 216 {}, // Screenshare specific. |
172 {graph_title, 0.0, 0.0, flags::DurationSecs(), flags::OutputFilename()}, | 217 {"video", 0.0, 0.0, flags::DurationSecs(), flags::OutputFilename(), |
| 218 flags::GraphTitle()}, |
173 pipe_config, | 219 pipe_config, |
174 flags::FLAGS_logs}; | 220 flags::FLAGS_logs}; |
175 | 221 |
| 222 VideoQualityTest::FillScalabilitySettings( |
| 223 ¶ms, |
| 224 {flags::Stream0(), flags::Stream1()}, |
| 225 flags::SelectedStream(), |
| 226 flags::NumSpatialLayers(), |
| 227 flags::SelectedSL(), |
| 228 {flags::SL0(), flags::SL1()}); |
| 229 |
176 VideoQualityTest test; | 230 VideoQualityTest test; |
177 if (flags::OutputFilename().empty()) | 231 if (flags::DurationSecs()) |
| 232 test.RunWithAnalyzer(params); |
| 233 else |
178 test.RunWithVideoRenderer(params); | 234 test.RunWithVideoRenderer(params); |
179 else | |
180 test.RunWithAnalyzer(params); | |
181 } | 235 } |
182 } // namespace webrtc | 236 } // namespace webrtc |
183 | 237 |
184 int main(int argc, char* argv[]) { | 238 int main(int argc, char* argv[]) { |
185 ::testing::InitGoogleTest(&argc, argv); | 239 ::testing::InitGoogleTest(&argc, argv); |
186 google::ParseCommandLineFlags(&argc, &argv, true); | 240 google::ParseCommandLineFlags(&argc, &argv, true); |
187 webrtc::test::InitFieldTrialsFromString( | 241 webrtc::test::InitFieldTrialsFromString( |
188 webrtc::flags::FLAGS_force_fieldtrials); | 242 webrtc::flags::FLAGS_force_fieldtrials); |
189 webrtc::test::RunTest(webrtc::Loopback); | 243 webrtc::test::RunTest(webrtc::Loopback); |
190 return 0; | 244 return 0; |
191 } | 245 } |
OLD | NEW |