OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/win/windows_version.h" | 8 #include "base/win/windows_version.h" |
9 #include "chrome/browser/media/media_browsertest.h" | 9 #include "chrome/browser/media/media_browsertest.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // The type of video src used to load media. | 55 // The type of video src used to load media. |
56 enum SrcType { | 56 enum SrcType { |
57 SRC, | 57 SRC, |
58 MSE | 58 MSE |
59 }; | 59 }; |
60 | 60 |
61 // MSE is available on all desktop platforms and on Android 4.1 and later. | 61 // MSE is available on all desktop platforms and on Android 4.1 and later. |
62 static bool IsMSESupported() { | 62 static bool IsMSESupported() { |
63 #if defined(OS_ANDROID) | 63 #if defined(OS_ANDROID) |
64 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) { | 64 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) { |
65 LOG(INFO) << "MSE is only supported in Android 4.1 and later."; | 65 VLOG(0) << "MSE is only supported in Android 4.1 and later."; |
66 return false; | 66 return false; |
67 } | 67 } |
68 #endif // defined(OS_ANDROID) | 68 #endif // defined(OS_ANDROID) |
69 return true; | 69 return true; |
70 } | 70 } |
71 | 71 |
72 static bool IsParentKeySystemOf(const std::string& parent_key_system, | 72 static bool IsParentKeySystemOf(const std::string& parent_key_system, |
73 const std::string& key_system) { | 73 const std::string& key_system) { |
74 std::string prefix = parent_key_system + '.'; | 74 std::string prefix = parent_key_system + '.'; |
75 return key_system.substr(0, prefix.size()) == prefix; | 75 return key_system.substr(0, prefix.size()) == prefix; |
(...skipping 15 matching lines...) Expand all Loading... |
91 } | 91 } |
92 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 92 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
93 | 93 |
94 void RunEncryptedMediaTest(const char* html_page, | 94 void RunEncryptedMediaTest(const char* html_page, |
95 const char* media_file, | 95 const char* media_file, |
96 const char* media_type, | 96 const char* media_type, |
97 const char* key_system, | 97 const char* key_system, |
98 SrcType src_type, | 98 SrcType src_type, |
99 const char* expectation) { | 99 const char* expectation) { |
100 if (src_type == MSE && !IsMSESupported()) { | 100 if (src_type == MSE && !IsMSESupported()) { |
101 LOG(INFO) << "Skipping test - MSE not supported."; | 101 VLOG(0) << "Skipping test - MSE not supported."; |
102 return; | 102 return; |
103 } | 103 } |
104 | 104 |
105 std::vector<StringPair> query_params; | 105 std::vector<StringPair> query_params; |
106 query_params.push_back(std::make_pair("mediafile", media_file)); | 106 query_params.push_back(std::make_pair("mediafile", media_file)); |
107 query_params.push_back(std::make_pair("mediatype", media_type)); | 107 query_params.push_back(std::make_pair("mediatype", media_type)); |
108 query_params.push_back(std::make_pair("keysystem", key_system)); | 108 query_params.push_back(std::make_pair("keysystem", key_system)); |
109 if (src_type == MSE) | 109 if (src_type == MSE) |
110 query_params.push_back(std::make_pair("usemse", "1")); | 110 query_params.push_back(std::make_pair("usemse", "1")); |
111 RunMediaTestPage(html_page, &query_params, expectation, true); | 111 RunMediaTestPage(html_page, &query_params, expectation, true); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 } | 252 } |
253 | 253 |
254 void TestSimplePlayback(const char* encrypted_media, const char* media_type) { | 254 void TestSimplePlayback(const char* encrypted_media, const char* media_type) { |
255 RunSimpleEncryptedMediaTest( | 255 RunSimpleEncryptedMediaTest( |
256 encrypted_media, media_type, CurrentKeySystem(), CurrentSourceType()); | 256 encrypted_media, media_type, CurrentKeySystem(), CurrentSourceType()); |
257 } | 257 } |
258 | 258 |
259 void TestFrameSizeChange() { | 259 void TestFrameSizeChange() { |
260 #if defined(WIDEVINE_CDM_AVAILABLE) | 260 #if defined(WIDEVINE_CDM_AVAILABLE) |
261 if (IsWidevine(CurrentKeySystem())) { | 261 if (IsWidevine(CurrentKeySystem())) { |
262 LOG(INFO) << "FrameSizeChange test cannot run with Widevine."; | 262 VLOG(0) << "FrameSizeChange test cannot run with Widevine."; |
263 return; | 263 return; |
264 } | 264 } |
265 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 265 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
266 RunEncryptedMediaTest("encrypted_frame_size_change.html", | 266 RunEncryptedMediaTest("encrypted_frame_size_change.html", |
267 "frame_size_change-av-enc-v.webm", kWebMAudioVideo, | 267 "frame_size_change-av-enc-v.webm", kWebMAudioVideo, |
268 CurrentKeySystem(), CurrentSourceType(), kEnded); | 268 CurrentKeySystem(), CurrentSourceType(), kEnded); |
269 } | 269 } |
270 | 270 |
271 void TestConfigChange() { | 271 void TestConfigChange() { |
272 if (CurrentSourceType() != MSE || !IsMSESupported()) { | 272 if (CurrentSourceType() != MSE || !IsMSESupported()) { |
273 LOG(INFO) << "Skipping test - config change test requires MSE."; | 273 VLOG(0) << "Skipping test - config change test requires MSE."; |
274 return; | 274 return; |
275 } | 275 } |
276 #if defined(WIDEVINE_CDM_AVAILABLE) | 276 #if defined(WIDEVINE_CDM_AVAILABLE) |
277 if (IsWidevine(CurrentKeySystem())) { | 277 if (IsWidevine(CurrentKeySystem())) { |
278 LOG(INFO) << "ConfigChange test cannot run with Widevine."; | 278 VLOG(0) << "ConfigChange test cannot run with Widevine."; |
279 return; | 279 return; |
280 } | 280 } |
281 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 281 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
282 std::vector<StringPair> query_params; | 282 std::vector<StringPair> query_params; |
283 query_params.push_back(std::make_pair("keysystem", CurrentKeySystem())); | 283 query_params.push_back(std::make_pair("keysystem", CurrentKeySystem())); |
284 query_params.push_back(std::make_pair("runencrypted", "1")); | 284 query_params.push_back(std::make_pair("runencrypted", "1")); |
285 RunMediaTestPage("mse_config_change.html", &query_params, kEnded, true); | 285 RunMediaTestPage("mse_config_change.html", &query_params, kEnded, true); |
286 } | 286 } |
287 | 287 |
288 protected: | 288 protected: |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 352 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
353 return; | 353 return; |
354 #endif | 354 #endif |
355 TestFrameSizeChange(); | 355 TestFrameSizeChange(); |
356 } | 356 } |
357 | 357 |
358 #if defined(USE_PROPRIETARY_CODECS) | 358 #if defined(USE_PROPRIETARY_CODECS) |
359 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4) { | 359 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_MP4) { |
360 // MP4 without MSE is not support yet, http://crbug.com/170793. | 360 // MP4 without MSE is not support yet, http://crbug.com/170793. |
361 if (CurrentSourceType() != MSE) { | 361 if (CurrentSourceType() != MSE) { |
362 LOG(INFO) << "Skipping test; Can only play MP4 encrypted streams by MSE."; | 362 VLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE."; |
363 return; | 363 return; |
364 } | 364 } |
365 TestSimplePlayback("bear-640x360-v_frag-cenc.mp4", kMP4VideoOnly); | 365 TestSimplePlayback("bear-640x360-v_frag-cenc.mp4", kMP4VideoOnly); |
366 } | 366 } |
367 | 367 |
368 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_MP4) { | 368 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_MP4) { |
369 // MP4 without MSE is not support yet, http://crbug.com/170793. | 369 // MP4 without MSE is not support yet, http://crbug.com/170793. |
370 if (CurrentSourceType() != MSE) { | 370 if (CurrentSourceType() != MSE) { |
371 LOG(INFO) << "Skipping test; Can only play MP4 encrypted streams by MSE."; | 371 VLOG(0) << "Skipping test; Can only play MP4 encrypted streams by MSE."; |
372 return; | 372 return; |
373 } | 373 } |
374 TestSimplePlayback("bear-640x360-a_frag-cenc.mp4", kMP4AudioOnly); | 374 TestSimplePlayback("bear-640x360-a_frag-cenc.mp4", kMP4AudioOnly); |
375 } | 375 } |
376 #endif // defined(USE_PROPRIETARY_CODECS) | 376 #endif // defined(USE_PROPRIETARY_CODECS) |
377 | 377 |
378 #if defined(WIDEVINE_CDM_AVAILABLE) | 378 #if defined(WIDEVINE_CDM_AVAILABLE) |
379 // The parent key system cannot be used in generateKeyRequest. | 379 // The parent key system cannot be used in generateKeyRequest. |
380 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) { | 380 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) { |
381 RunEncryptedMediaTest("encrypted_media_player.html", | 381 RunEncryptedMediaTest("encrypted_media_player.html", |
382 "bear-a-enc_a.webm", | 382 "bear-a-enc_a.webm", |
383 kWebMAudioOnly, | 383 kWebMAudioOnly, |
384 "com.widevine", | 384 "com.widevine", |
385 MSE, | 385 MSE, |
386 kEmeNotSupportedError); | 386 kEmeNotSupportedError); |
387 } | 387 } |
388 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 388 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
389 | 389 |
390 #if defined(ENABLE_PEPPER_CDMS) | 390 #if defined(ENABLE_PEPPER_CDMS) |
391 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, | 391 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, |
392 ExternalClearKeyInitializeCDMFail) { | 392 ExternalClearKeyInitializeCDMFail) { |
393 RunEncryptedMediaTest("encrypted_media_player.html", | 393 RunEncryptedMediaTest("encrypted_media_player.html", |
394 "bear-a-enc_a.webm", | 394 "bear-a-enc_a.webm", |
395 kWebMAudioOnly, | 395 kWebMAudioOnly, |
396 kExternalClearKeyInitializeFailKeySystem, | 396 kExternalClearKeyInitializeFailKeySystem, |
397 SRC, | 397 SRC, |
398 kEmeKeyError); | 398 kEmeKeyError); |
399 } | 399 } |
400 #endif // defined(ENABLE_PEPPER_CDMS) | 400 #endif // defined(ENABLE_PEPPER_CDMS) |
OLD | NEW |