OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // Play a suitable, somewhat realistic video file. | 81 // Play a suitable, somewhat realistic video file. |
82 base::FilePath input_video = test::GetReferenceFilesDir() | 82 base::FilePath input_video = test::GetReferenceFilesDir() |
83 .Append(test::kReferenceFileName360p) | 83 .Append(test::kReferenceFileName360p) |
84 .AddExtension(test::kY4mFileExtension); | 84 .AddExtension(test::kY4mFileExtension); |
85 command_line->AppendSwitchPath(switches::kUseFileForFakeVideoCapture, | 85 command_line->AppendSwitchPath(switches::kUseFileForFakeVideoCapture, |
86 input_video); | 86 input_video); |
87 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); | 87 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); |
88 } | 88 } |
89 | 89 |
90 void StartCall(const std::string& audio_codec, | 90 void StartCall(const std::string& audio_codec, |
91 const std::string& video_codec) { | 91 const std::string& video_codec, |
| 92 bool prefer_hw_video_codec) { |
92 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); | 93 ASSERT_TRUE(test::HasReferenceFilesInCheckout()); |
93 ASSERT_TRUE(embedded_test_server()->Start()); | 94 ASSERT_TRUE(embedded_test_server()->Start()); |
94 | 95 |
95 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 100) | 96 ASSERT_GE(TestTimeouts::action_max_timeout().InSeconds(), 100) |
96 << "This is a long-running test; you must specify " | 97 << "This is a long-running test; you must specify " |
97 "--ui-test-action-max-timeout to have a value of at least 100000."; | 98 "--ui-test-action-max-timeout to have a value of at least 100000."; |
98 | 99 |
99 left_tab_ = OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 100 left_tab_ = OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
100 right_tab_ = OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 101 right_tab_ = OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
101 | 102 |
102 SetupPeerconnectionWithLocalStream(left_tab_); | 103 SetupPeerconnectionWithLocalStream(left_tab_); |
103 SetupPeerconnectionWithLocalStream(right_tab_); | 104 SetupPeerconnectionWithLocalStream(right_tab_); |
104 SetDefaultAudioCodec(left_tab_, audio_codec); | 105 SetDefaultAudioCodec(left_tab_, audio_codec); |
105 SetDefaultAudioCodec(right_tab_, audio_codec); | 106 SetDefaultAudioCodec(right_tab_, audio_codec); |
106 SetDefaultVideoCodec(left_tab_, video_codec); | 107 SetDefaultVideoCodec(left_tab_, video_codec, prefer_hw_video_codec); |
107 SetDefaultVideoCodec(right_tab_, video_codec); | 108 SetDefaultVideoCodec(right_tab_, video_codec, prefer_hw_video_codec); |
108 CreateDataChannel(left_tab_, "data"); | 109 CreateDataChannel(left_tab_, "data"); |
109 CreateDataChannel(right_tab_, "data"); | 110 CreateDataChannel(right_tab_, "data"); |
110 NegotiateCall(left_tab_, right_tab_); | 111 NegotiateCall(left_tab_, right_tab_); |
111 StartDetectingVideo(left_tab_, "remote-view"); | 112 StartDetectingVideo(left_tab_, "remote-view"); |
112 StartDetectingVideo(right_tab_, "remote-view"); | 113 StartDetectingVideo(right_tab_, "remote-view"); |
113 WaitForVideoToPlay(left_tab_); | 114 WaitForVideoToPlay(left_tab_); |
114 WaitForVideoToPlay(right_tab_); | 115 WaitForVideoToPlay(right_tab_); |
115 } | 116 } |
116 | 117 |
117 void EndCall() { | 118 void EndCall() { |
118 if (left_tab_) | 119 if (left_tab_) |
119 HangUp(left_tab_); | 120 HangUp(left_tab_); |
120 if (right_tab_) | 121 if (right_tab_) |
121 HangUp(right_tab_); | 122 HangUp(right_tab_); |
122 } | 123 } |
123 | 124 |
124 void RunsAudioAndVideoCallCollectingMetrics( | 125 void RunsAudioAndVideoCallCollectingMetricsWithAudioCodec( |
125 const std::string& audio_codec, const std::string& video_codec) { | 126 const std::string& audio_codec) { |
126 StartCall(audio_codec, video_codec); | 127 RunsAudioAndVideoCallCollectingMetrics(audio_codec, kUseDefaultVideoCodec, |
| 128 false /* prefer_hw_video_codec */); |
| 129 } |
| 130 |
| 131 void RunsAudioAndVideoCallCollectingMetricsWithVideoCodec( |
| 132 const std::string& video_codec, |
| 133 bool prefer_hw_video_codec) { |
| 134 RunsAudioAndVideoCallCollectingMetrics(kUseDefaultAudioCodec, video_codec, |
| 135 prefer_hw_video_codec); |
| 136 } |
| 137 |
| 138 void RunsAudioAndVideoCallCollectingMetrics(const std::string& audio_codec, |
| 139 const std::string& video_codec, |
| 140 bool prefer_hw_video_codec) { |
| 141 StartCall(audio_codec, video_codec, prefer_hw_video_codec); |
127 | 142 |
128 // Call for 60 seconds so that values may stabilize, bandwidth ramp up, etc. | 143 // Call for 60 seconds so that values may stabilize, bandwidth ramp up, etc. |
129 test::SleepInJavascript(left_tab_, 60000); | 144 test::SleepInJavascript(left_tab_, 60000); |
130 | 145 |
131 // The ramp-up may vary greatly and impact the resulting total bytes, to get | 146 // The ramp-up may vary greatly and impact the resulting total bytes, to get |
132 // reliable measurements we do two measurements, at 60 and 70 seconds and | 147 // reliable measurements we do two measurements, at 60 and 70 seconds and |
133 // look at the average bytes/second in that window. | 148 // look at the average bytes/second in that window. |
134 double audio_bytes_sent_before = 0.0; | 149 double audio_bytes_sent_before = 0.0; |
135 double audio_bytes_received_before = 0.0; | 150 double audio_bytes_received_before = 0.0; |
136 double video_bytes_sent_before = 0.0; | 151 double video_bytes_sent_before = 0.0; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 "bytes/second", false); | 207 "bytes/second", false); |
193 } | 208 } |
194 | 209 |
195 EndCall(); | 210 EndCall(); |
196 } | 211 } |
197 | 212 |
198 void RunsAudioAndVideoCallMeasuringGetStatsPerformance( | 213 void RunsAudioAndVideoCallMeasuringGetStatsPerformance( |
199 GetStatsVariation variation) { | 214 GetStatsVariation variation) { |
200 EXPECT_TRUE(base::TimeTicks::IsHighResolution()); | 215 EXPECT_TRUE(base::TimeTicks::IsHighResolution()); |
201 | 216 |
202 StartCall(kUseDefaultAudioCodec, kUseDefaultVideoCodec); | 217 StartCall(kUseDefaultAudioCodec, kUseDefaultVideoCodec, |
| 218 false /* prefer_hw_video_codec */); |
203 | 219 |
204 double invocation_time = 0.0; | 220 double invocation_time = 0.0; |
205 switch (variation) { | 221 switch (variation) { |
206 case GetStatsVariation::PROMISE_BASED: | 222 case GetStatsVariation::PROMISE_BASED: |
207 invocation_time = (MeasureGetStatsPerformance(left_tab_) + | 223 invocation_time = (MeasureGetStatsPerformance(left_tab_) + |
208 MeasureGetStatsPerformance(right_tab_)) / 2.0; | 224 MeasureGetStatsPerformance(right_tab_)) / 2.0; |
209 break; | 225 break; |
210 case GetStatsVariation::CALLBACK_BASED: | 226 case GetStatsVariation::CALLBACK_BASED: |
211 invocation_time = | 227 invocation_time = |
212 (MeasureGetStatsCallbackPerformance(left_tab_) + | 228 (MeasureGetStatsCallbackPerformance(left_tab_) + |
(...skipping 14 matching lines...) Expand all Loading... |
227 | 243 |
228 private: | 244 private: |
229 content::WebContents* left_tab_ = nullptr; | 245 content::WebContents* left_tab_ = nullptr; |
230 content::WebContents* right_tab_ = nullptr; | 246 content::WebContents* right_tab_ = nullptr; |
231 }; | 247 }; |
232 | 248 |
233 IN_PROC_BROWSER_TEST_F( | 249 IN_PROC_BROWSER_TEST_F( |
234 WebRtcStatsPerfBrowserTest, | 250 WebRtcStatsPerfBrowserTest, |
235 MANUAL_RunsAudioAndVideoCallCollectingMetrics_AudioCodec_opus) { | 251 MANUAL_RunsAudioAndVideoCallCollectingMetrics_AudioCodec_opus) { |
236 base::ThreadRestrictions::ScopedAllowIO allow_io; | 252 base::ThreadRestrictions::ScopedAllowIO allow_io; |
237 RunsAudioAndVideoCallCollectingMetrics("opus", kUseDefaultVideoCodec); | 253 RunsAudioAndVideoCallCollectingMetricsWithAudioCodec("opus"); |
238 } | 254 } |
239 | 255 |
240 IN_PROC_BROWSER_TEST_F( | 256 IN_PROC_BROWSER_TEST_F( |
241 WebRtcStatsPerfBrowserTest, | 257 WebRtcStatsPerfBrowserTest, |
242 MANUAL_RunsAudioAndVideoCallCollectingMetrics_AudioCodec_ISAC) { | 258 MANUAL_RunsAudioAndVideoCallCollectingMetrics_AudioCodec_ISAC) { |
243 base::ThreadRestrictions::ScopedAllowIO allow_io; | 259 base::ThreadRestrictions::ScopedAllowIO allow_io; |
244 RunsAudioAndVideoCallCollectingMetrics("ISAC", kUseDefaultVideoCodec); | 260 RunsAudioAndVideoCallCollectingMetricsWithAudioCodec("ISAC"); |
245 } | 261 } |
246 | 262 |
247 IN_PROC_BROWSER_TEST_F( | 263 IN_PROC_BROWSER_TEST_F( |
248 WebRtcStatsPerfBrowserTest, | 264 WebRtcStatsPerfBrowserTest, |
249 MANUAL_RunsAudioAndVideoCallCollectingMetrics_AudioCodec_G722) { | 265 MANUAL_RunsAudioAndVideoCallCollectingMetrics_AudioCodec_G722) { |
250 base::ThreadRestrictions::ScopedAllowIO allow_io; | 266 base::ThreadRestrictions::ScopedAllowIO allow_io; |
251 RunsAudioAndVideoCallCollectingMetrics("G722", kUseDefaultVideoCodec); | 267 RunsAudioAndVideoCallCollectingMetricsWithAudioCodec("G722"); |
252 } | 268 } |
253 | 269 |
254 IN_PROC_BROWSER_TEST_F( | 270 IN_PROC_BROWSER_TEST_F( |
255 WebRtcStatsPerfBrowserTest, | 271 WebRtcStatsPerfBrowserTest, |
256 MANUAL_RunsAudioAndVideoCallCollectingMetrics_AudioCodec_PCMU) { | 272 MANUAL_RunsAudioAndVideoCallCollectingMetrics_AudioCodec_PCMU) { |
257 base::ThreadRestrictions::ScopedAllowIO allow_io; | 273 base::ThreadRestrictions::ScopedAllowIO allow_io; |
258 RunsAudioAndVideoCallCollectingMetrics("PCMU", kUseDefaultVideoCodec); | 274 RunsAudioAndVideoCallCollectingMetricsWithAudioCodec("PCMU"); |
259 } | 275 } |
260 | 276 |
261 IN_PROC_BROWSER_TEST_F( | 277 IN_PROC_BROWSER_TEST_F( |
262 WebRtcStatsPerfBrowserTest, | 278 WebRtcStatsPerfBrowserTest, |
263 MANUAL_RunsAudioAndVideoCallCollectingMetrics_AudioCodec_PCMA) { | 279 MANUAL_RunsAudioAndVideoCallCollectingMetrics_AudioCodec_PCMA) { |
264 base::ThreadRestrictions::ScopedAllowIO allow_io; | 280 base::ThreadRestrictions::ScopedAllowIO allow_io; |
265 RunsAudioAndVideoCallCollectingMetrics("PCMA", kUseDefaultVideoCodec); | 281 RunsAudioAndVideoCallCollectingMetricsWithAudioCodec("PCMA"); |
266 } | 282 } |
267 | 283 |
268 IN_PROC_BROWSER_TEST_F( | 284 IN_PROC_BROWSER_TEST_F( |
269 WebRtcStatsPerfBrowserTest, | 285 WebRtcStatsPerfBrowserTest, |
270 MANUAL_RunsAudioAndVideoCallCollectingMetrics_VideoCodec_VP8) { | 286 MANUAL_RunsAudioAndVideoCallCollectingMetrics_VideoCodec_VP8) { |
271 base::ThreadRestrictions::ScopedAllowIO allow_io; | 287 base::ThreadRestrictions::ScopedAllowIO allow_io; |
272 RunsAudioAndVideoCallCollectingMetrics(kUseDefaultAudioCodec, "VP8"); | 288 RunsAudioAndVideoCallCollectingMetricsWithVideoCodec( |
| 289 "VP8", false /* prefer_hw_video_codec */); |
273 } | 290 } |
274 | 291 |
275 IN_PROC_BROWSER_TEST_F( | 292 IN_PROC_BROWSER_TEST_F( |
276 WebRtcStatsPerfBrowserTest, | 293 WebRtcStatsPerfBrowserTest, |
277 MANUAL_RunsAudioAndVideoCallCollectingMetrics_VideoCodec_VP9) { | 294 MANUAL_RunsAudioAndVideoCallCollectingMetrics_VideoCodec_VP9) { |
278 base::ThreadRestrictions::ScopedAllowIO allow_io; | 295 base::ThreadRestrictions::ScopedAllowIO allow_io; |
279 RunsAudioAndVideoCallCollectingMetrics(kUseDefaultAudioCodec, "VP9"); | 296 RunsAudioAndVideoCallCollectingMetricsWithVideoCodec( |
| 297 "VP9", false /* prefer_hw_video_codec */); |
280 } | 298 } |
281 | 299 |
282 #if BUILDFLAG(RTC_USE_H264) | 300 #if BUILDFLAG(RTC_USE_H264) |
283 | 301 |
284 IN_PROC_BROWSER_TEST_F( | 302 IN_PROC_BROWSER_TEST_F( |
285 WebRtcStatsPerfBrowserTest, | 303 WebRtcStatsPerfBrowserTest, |
286 MANUAL_RunsAudioAndVideoCallCollectingMetrics_VideoCodec_H264) { | 304 MANUAL_RunsAudioAndVideoCallCollectingMetrics_VideoCodec_H264) { |
287 base::ThreadRestrictions::ScopedAllowIO allow_io; | 305 base::ThreadRestrictions::ScopedAllowIO allow_io; |
288 // Only run test if run-time feature corresponding to |rtc_use_h264| is on. | 306 // Only run test if run-time feature corresponding to |rtc_use_h264| is on. |
289 if (!base::FeatureList::IsEnabled(content::kWebRtcH264WithOpenH264FFmpeg)) { | 307 if (!base::FeatureList::IsEnabled(content::kWebRtcH264WithOpenH264FFmpeg)) { |
290 LOG(WARNING) << "Run-time feature WebRTC-H264WithOpenH264FFmpeg disabled. " | 308 LOG(WARNING) << "Run-time feature WebRTC-H264WithOpenH264FFmpeg disabled. " |
291 "Skipping WebRtcPerfBrowserTest." | 309 "Skipping WebRtcPerfBrowserTest." |
292 "MANUAL_RunsAudioAndVideoCallCollectingMetrics_VideoCodec_H264 (test " | 310 "MANUAL_RunsAudioAndVideoCallCollectingMetrics_VideoCodec_H264 (test " |
293 "\"OK\")"; | 311 "\"OK\")"; |
294 return; | 312 return; |
295 } | 313 } |
296 RunsAudioAndVideoCallCollectingMetrics(kUseDefaultAudioCodec, "H264"); | 314 RunsAudioAndVideoCallCollectingMetricsWithVideoCodec( |
| 315 "H264", true /* prefer_hw_video_codec */); |
297 } | 316 } |
298 | 317 |
299 #endif // BUILDFLAG(RTC_USE_H264) | 318 #endif // BUILDFLAG(RTC_USE_H264) |
300 | 319 |
301 IN_PROC_BROWSER_TEST_F( | 320 IN_PROC_BROWSER_TEST_F( |
302 WebRtcStatsPerfBrowserTest, | 321 WebRtcStatsPerfBrowserTest, |
303 MANUAL_RunsAudioAndVideoCallMeasuringGetStatsPerformance_Promise) { | 322 MANUAL_RunsAudioAndVideoCallMeasuringGetStatsPerformance_Promise) { |
304 base::ThreadRestrictions::ScopedAllowIO allow_io; | 323 base::ThreadRestrictions::ScopedAllowIO allow_io; |
305 RunsAudioAndVideoCallMeasuringGetStatsPerformance( | 324 RunsAudioAndVideoCallMeasuringGetStatsPerformance( |
306 GetStatsVariation::PROMISE_BASED); | 325 GetStatsVariation::PROMISE_BASED); |
307 } | 326 } |
308 | 327 |
309 IN_PROC_BROWSER_TEST_F( | 328 IN_PROC_BROWSER_TEST_F( |
310 WebRtcStatsPerfBrowserTest, | 329 WebRtcStatsPerfBrowserTest, |
311 MANUAL_RunsAudioAndVideoCallMeasuringGetStatsPerformance_Callback) { | 330 MANUAL_RunsAudioAndVideoCallMeasuringGetStatsPerformance_Callback) { |
312 base::ThreadRestrictions::ScopedAllowIO allow_io; | 331 base::ThreadRestrictions::ScopedAllowIO allow_io; |
313 RunsAudioAndVideoCallMeasuringGetStatsPerformance( | 332 RunsAudioAndVideoCallMeasuringGetStatsPerformance( |
314 GetStatsVariation::CALLBACK_BASED); | 333 GetStatsVariation::CALLBACK_BASED); |
315 } | 334 } |
316 | 335 |
317 } // namespace | 336 } // namespace |
318 | 337 |
319 } // namespace content | 338 } // namespace content |
OLD | NEW |