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" |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "content/public/test/browser_test_utils.h" | 13 #include "content/public/test/browser_test_utils.h" |
14 #include "media/cdm/key_system_names.h" | |
xhwang
2013/11/22 07:44:26
We could use key system names defined in this file
ddorwin
2013/11/22 18:04:01
I hope to remove that file - at least for non-test
xhwang
2013/11/22 18:18:22
SG, removed.
| |
14 #if defined(OS_ANDROID) | 15 #if defined(OS_ANDROID) |
15 #include "base/android/build_info.h" | 16 #include "base/android/build_info.h" |
16 #endif | 17 #endif |
17 | 18 |
18 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 19 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
19 | 20 |
20 #if defined(ENABLE_PEPPER_CDMS) | 21 #if defined(ENABLE_PEPPER_CDMS) |
21 // Platform-specific filename relative to the chrome executable. | 22 // Platform-specific filename relative to the chrome executable. |
22 const char kClearKeyCdmAdapterFileName[] = | 23 const char kClearKeyCdmAdapterFileName[] = |
23 #if defined(OS_MACOSX) | 24 #if defined(OS_MACOSX) |
24 "clearkeycdmadapter.plugin"; | 25 "clearkeycdmadapter.plugin"; |
25 #elif defined(OS_WIN) | 26 #elif defined(OS_WIN) |
26 "clearkeycdmadapter.dll"; | 27 "clearkeycdmadapter.dll"; |
27 #elif defined(OS_POSIX) | 28 #elif defined(OS_POSIX) |
28 "libclearkeycdmadapter.so"; | 29 "libclearkeycdmadapter.so"; |
29 #endif | 30 #endif |
30 | 31 |
31 const char kClearKeyCdmPluginMimeType[] = "application/x-ppapi-clearkey-cdm"; | 32 const char kClearKeyCdmPluginMimeType[] = "application/x-ppapi-clearkey-cdm"; |
32 #endif // defined(ENABLE_PEPPER_CDMS) | 33 #endif // defined(ENABLE_PEPPER_CDMS) |
33 | 34 |
34 // Available key systems. | 35 // Available key systems. |
35 const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; | 36 const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; |
36 const char kExternalClearKeyKeySystem[] = | 37 const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey"; |
37 "org.chromium.externalclearkey"; | 38 const char kExternalClearKeyDecryptOnlyKeySystem[] = |
39 "org.chromium.externalclearkey.decryptonly"; | |
40 const char kExternalClearKeyInitializeFailKeySystem[] = | |
41 "org.chromium.externalclearkey.initializefail"; | |
38 | 42 |
39 // Supported media types. | 43 // Supported media types. |
40 const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\""; | 44 const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\""; |
41 const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\""; | 45 const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\""; |
42 const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\""; | 46 const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\""; |
43 #if defined(USE_PROPRIETARY_CODECS) | 47 #if defined(USE_PROPRIETARY_CODECS) |
44 const char kMP4AudioOnly[] = "audio/mp4; codecs=\"mp4a.40.2\""; | 48 const char kMP4AudioOnly[] = "audio/mp4; codecs=\"mp4a.40.2\""; |
45 const char kMP4VideoOnly[] = "video/mp4; codecs=\"avc1.4D4041\""; | 49 const char kMP4VideoOnly[] = "video/mp4; codecs=\"avc1.4D4041\""; |
46 #endif // defined(USE_PROPRIETARY_CODECS) | 50 #endif // defined(USE_PROPRIETARY_CODECS) |
47 | 51 |
(...skipping 16 matching lines...) Expand all Loading... | |
64 } | 68 } |
65 #endif // defined(OS_ANDROID) | 69 #endif // defined(OS_ANDROID) |
66 return true; | 70 return true; |
67 } | 71 } |
68 | 72 |
69 // Base class for encrypted media tests. | 73 // Base class for encrypted media tests. |
70 class EncryptedMediaTestBase : public MediaBrowserTest { | 74 class EncryptedMediaTestBase : public MediaBrowserTest { |
71 public: | 75 public: |
72 EncryptedMediaTestBase() : is_pepper_cdm_registered_(false) {} | 76 EncryptedMediaTestBase() : is_pepper_cdm_registered_(false) {} |
73 | 77 |
74 bool IsExternalClearKey(const char* key_system) { | |
75 return (strcmp(key_system, kExternalClearKeyKeySystem) == 0); | |
76 } | |
77 | |
78 #if defined(WIDEVINE_CDM_AVAILABLE) | 78 #if defined(WIDEVINE_CDM_AVAILABLE) |
79 bool IsWidevine(const char* key_system) { | 79 bool IsWidevine(const std::string& key_system) { |
80 return (strcmp(key_system, kWidevineKeySystem) == 0); | 80 return key_system == kWidevineKeySystem; |
81 } | 81 } |
82 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 82 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
83 | 83 |
84 void RunEncryptedMediaTest(const char* html_page, | 84 void RunEncryptedMediaTest(const char* html_page, |
85 const char* media_file, | 85 const char* media_file, |
86 const char* media_type, | 86 const char* media_type, |
87 const char* key_system, | 87 const char* key_system, |
88 SrcType src_type, | 88 SrcType src_type, |
89 const char* expectation) { | 89 const char* expectation) { |
90 if (src_type == MSE && !IsMSESupported()) { | 90 if (src_type == MSE && !IsMSESupported()) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 140 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
141 #if defined(OS_ANDROID) | 141 #if defined(OS_ANDROID) |
142 command_line->AppendSwitch( | 142 command_line->AppendSwitch( |
143 switches::kDisableGestureRequirementForMediaPlayback); | 143 switches::kDisableGestureRequirementForMediaPlayback); |
144 #endif // defined(OS_ANDROID) | 144 #endif // defined(OS_ANDROID) |
145 } | 145 } |
146 | 146 |
147 void SetUpCommandLineForKeySystem(const char* key_system, | 147 void SetUpCommandLineForKeySystem(const char* key_system, |
148 CommandLine* command_line) { | 148 CommandLine* command_line) { |
149 #if defined(ENABLE_PEPPER_CDMS) | 149 #if defined(ENABLE_PEPPER_CDMS) |
150 if (IsExternalClearKey(key_system)) { | 150 if (media::IsExternalClearKey(key_system)) { |
ddorwin
2013/11/22 18:04:01
Since I want to get rid of that file, I'm not sure
xhwang
2013/11/22 18:18:22
Done.
| |
151 RegisterPepperCdm(command_line, kClearKeyCdmAdapterFileName, | 151 RegisterPepperCdm(command_line, kClearKeyCdmAdapterFileName, key_system); |
152 kExternalClearKeyKeySystem); | |
153 } | 152 } |
154 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | 153 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
155 else if (IsWidevine(key_system)) { | 154 else if (IsWidevine(key_system)) { |
156 RegisterPepperCdm(command_line, kWidevineCdmAdapterFileName, | 155 RegisterPepperCdm(command_line, kWidevineCdmAdapterFileName, key_system); |
157 kWidevineKeySystem); | |
158 } | 156 } |
159 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | 157 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) |
160 #endif // defined(ENABLE_PEPPER_CDMS) | 158 #endif // defined(ENABLE_PEPPER_CDMS) |
161 } | 159 } |
162 | 160 |
163 private: | 161 private: |
164 #if defined(ENABLE_PEPPER_CDMS) | 162 #if defined(ENABLE_PEPPER_CDMS) |
165 void RegisterPepperCdm(CommandLine* command_line, | 163 void RegisterPepperCdm(CommandLine* command_line, |
166 const std::string& adapter_name, | 164 const std::string& adapter_name, |
167 const std::string& key_system) { | 165 const std::string& key_system) { |
(...skipping 12 matching lines...) Expand all Loading... | |
180 pepper_plugin.append(ASCIIToWide(GetPepperType(key_system))); | 178 pepper_plugin.append(ASCIIToWide(GetPepperType(key_system))); |
181 #else | 179 #else |
182 pepper_plugin.append(GetPepperType(key_system)); | 180 pepper_plugin.append(GetPepperType(key_system)); |
183 #endif | 181 #endif |
184 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, | 182 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, |
185 pepper_plugin); | 183 pepper_plugin); |
186 } | 184 } |
187 | 185 |
188 // Adapted from key_systems.cc. | 186 // Adapted from key_systems.cc. |
189 std::string GetPepperType(const std::string& key_system) { | 187 std::string GetPepperType(const std::string& key_system) { |
190 if (key_system == kExternalClearKeyKeySystem) | 188 if (media::IsExternalClearKey(key_system)) |
191 return kClearKeyCdmPluginMimeType; | 189 return kClearKeyCdmPluginMimeType; |
192 #if defined(WIDEVINE_CDM_AVAILABLE) | 190 #if defined(WIDEVINE_CDM_AVAILABLE) |
193 if (key_system == kWidevineKeySystem) | 191 if (IsWidevine(key_system)) |
194 return kWidevineCdmPluginMimeType; | 192 return kWidevineCdmPluginMimeType; |
195 #endif // WIDEVINE_CDM_AVAILABLE | 193 #endif // WIDEVINE_CDM_AVAILABLE |
196 | 194 |
197 NOTREACHED(); | 195 NOTREACHED(); |
198 return ""; | 196 return ""; |
199 } | 197 } |
200 #endif // defined(ENABLE_PEPPER_CDMS) | 198 #endif // defined(ENABLE_PEPPER_CDMS) |
201 | 199 |
202 bool is_pepper_cdm_registered_; | 200 bool is_pepper_cdm_registered_; |
203 }; | 201 }; |
204 | 202 |
205 #if defined(ENABLE_PEPPER_CDMS) | 203 #if defined(ENABLE_PEPPER_CDMS) |
206 // Tests encrypted media playback using ExternalClearKey key system. | 204 // Tests encrypted media playback using ExternalClearKey key system in |
205 // decrypt-and-decode mode. | |
207 class ECKEncryptedMediaTest : public EncryptedMediaTestBase { | 206 class ECKEncryptedMediaTest : public EncryptedMediaTestBase { |
208 protected: | 207 protected: |
209 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 208 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
210 EncryptedMediaTestBase::SetUpCommandLine(command_line); | 209 EncryptedMediaTestBase::SetUpCommandLine(command_line); |
211 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line); | 210 SetUpCommandLineForKeySystem(kExternalClearKeyKeySystem, command_line); |
212 } | 211 } |
213 }; | 212 }; |
214 | 213 |
215 #if defined(WIDEVINE_CDM_AVAILABLE) | 214 #if defined(WIDEVINE_CDM_AVAILABLE) |
216 // Tests encrypted media playback using Widevine key system. | 215 // Tests encrypted media playback using Widevine key system. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 | 292 |
294 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest, | 293 INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest, |
295 Combine(Values(kClearKeyKeySystem), Values(MSE))); | 294 Combine(Values(kClearKeyKeySystem), Values(MSE))); |
296 | 295 |
297 // External Clear Key is currently only used on platforms that use Pepper CDMs. | 296 // External Clear Key is currently only used on platforms that use Pepper CDMs. |
298 #if defined(ENABLE_PEPPER_CDMS) | 297 #if defined(ENABLE_PEPPER_CDMS) |
299 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey, EncryptedMediaTest, | 298 INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey, EncryptedMediaTest, |
300 Combine(Values(kExternalClearKeyKeySystem), Values(SRC))); | 299 Combine(Values(kExternalClearKeyKeySystem), Values(SRC))); |
301 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey, EncryptedMediaTest, | 300 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey, EncryptedMediaTest, |
302 Combine(Values(kExternalClearKeyKeySystem), Values(MSE))); | 301 Combine(Values(kExternalClearKeyKeySystem), Values(MSE))); |
302 // To reduce test time, only run ExternalClearKeyDecryptOnly with MSE. | |
303 INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly, EncryptedMediaTest, | |
304 Combine(Values(kExternalClearKeyDecryptOnlyKeySystem), Values(MSE))); | |
303 #endif // defined(ENABLE_PEPPER_CDMS) | 305 #endif // defined(ENABLE_PEPPER_CDMS) |
304 | 306 |
305 #if defined(WIDEVINE_CDM_AVAILABLE) | 307 #if defined(WIDEVINE_CDM_AVAILABLE) |
306 // This test doesn't fully test playback with Widevine. So we only run Widevine | 308 // This test doesn't fully test playback with Widevine. So we only run Widevine |
307 // test with MSE (no SRC) to reduce test time. Also, on Android EME only works | 309 // test with MSE (no SRC) to reduce test time. Also, on Android EME only works |
308 // with MSE and we cannot run this test with SRC. | 310 // with MSE and we cannot run this test with SRC. |
309 INSTANTIATE_TEST_CASE_P(MSE_Widevine, EncryptedMediaTest, | 311 INSTANTIATE_TEST_CASE_P(MSE_Widevine, EncryptedMediaTest, |
310 Combine(Values(kWidevineKeySystem), Values(MSE))); | 312 Combine(Values(kWidevineKeySystem), Values(MSE))); |
311 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 313 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
312 | 314 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 kEmeNotSupportedError); | 376 kEmeNotSupportedError); |
375 } | 377 } |
376 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 378 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
377 | 379 |
378 #if defined(ENABLE_PEPPER_CDMS) | 380 #if defined(ENABLE_PEPPER_CDMS) |
379 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, | 381 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, |
380 ExternalClearKeyInitializeCDMFail) { | 382 ExternalClearKeyInitializeCDMFail) { |
381 RunEncryptedMediaTest("encrypted_media_player.html", | 383 RunEncryptedMediaTest("encrypted_media_player.html", |
382 "bear-a-enc_a.webm", | 384 "bear-a-enc_a.webm", |
383 kWebMAudioOnly, | 385 kWebMAudioOnly, |
384 "org.chromium.externalclearkey.initializefail", | 386 kExternalClearKeyInitializeFailKeySystem, |
385 SRC, | 387 SRC, |
386 kEmeKeyError); | 388 kEmeKeyError); |
387 } | 389 } |
388 #endif // defined(ENABLE_PEPPER_CDMS) | 390 #endif // defined(ENABLE_PEPPER_CDMS) |
OLD | NEW |