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