Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/string16.h" | 9 #include "base/string16.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "webkit/media/crypto/key_systems.h" | 22 #include "webkit/media/crypto/key_systems.h" |
| 23 | 23 |
| 24 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 24 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
| 25 | 25 |
| 26 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(OS_LINUX) | 26 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(OS_LINUX) |
| 27 #include <gnu/libc-version.h> | 27 #include <gnu/libc-version.h> |
| 28 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(OS_LINUX) | 28 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(OS_LINUX) |
| 29 | 29 |
| 30 // Platform-specific filename relative to the chrome executable. | 30 // Platform-specific filename relative to the chrome executable. |
| 31 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 32 static const char kClearKeyLibraryName[] = "clearkeycdmadapter.dll"; | 32 static const wchar_t kClearKeyLibraryName[] = L"clearkeycdmadapter.dll"; |
| 33 static const char kWidevineLibraryName[] = "widevinecdmadapter.dll"; | 33 static const wchar_t kWidevineLibraryName[] = L"widevinecdmadapter.dll"; |
| 34 #elif defined(OS_MACOSX) | 34 #elif defined(OS_MACOSX) |
| 35 static const char kClearKeyLibraryName[] = "clearkeycdmadapter.plugin"; | 35 static const char kClearKeyLibraryName[] = "clearkeycdmadapter.plugin"; |
| 36 static const char kWidevineLibraryName[] = "widevinecdmadapter.plugin"; | 36 static const char kWidevineLibraryName[] = "widevinecdmadapter.plugin"; |
| 37 #elif defined(OS_POSIX) | 37 #elif defined(OS_POSIX) |
| 38 static const char kClearKeyLibraryName[] = "libclearkeycdmadapter.so"; | 38 static const char kClearKeyLibraryName[] = "libclearkeycdmadapter.so"; |
| 39 static const char kWidevineLibraryName[] = "libwidevinecdmadapter.so"; | 39 static const char kWidevineLibraryName[] = "libwidevinecdmadapter.so"; |
|
xhwang
2013/05/10 00:26:44
For WV, can we use kWidevineCdmPluginFileName in w
ddorwin
2013/05/14 00:17:10
Done.
| |
| 40 #endif | 40 #endif |
| 41 | 41 |
| 42 // Available key systems. | 42 // Available key systems. |
| 43 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; | 43 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; |
| 44 static const char kExternalClearKeyKeySystem[] = | 44 static const char kExternalClearKeyKeySystem[] = |
| 45 "org.chromium.externalclearkey"; | 45 "org.chromium.externalclearkey"; |
| 46 | 46 |
| 47 // Supported media types. | 47 // Supported media types. |
| 48 static const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\""; | 48 static const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\""; |
| 49 static const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\""; | 49 static const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\""; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 std::string fail_message; | 98 std::string fail_message; |
| 99 EXPECT_TRUE(ExecuteScriptAndExtractString( | 99 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 100 shell()->web_contents(), | 100 shell()->web_contents(), |
| 101 "window.domAutomationController.send(failMessage);", | 101 "window.domAutomationController.send(failMessage);", |
| 102 &fail_message)); | 102 &fail_message)); |
| 103 LOG(INFO) << "Test failed: " << fail_message; | 103 LOG(INFO) << "Test failed: " << fail_message; |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 protected: | 107 protected: |
| 108 // Registers any CDM plugins not registered by default. | |
| 109 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 108 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 110 RegisterPepperPlugin(command_line, kClearKeyLibraryName, | 109 RegisterPepperCdm(command_line, kClearKeyLibraryName, |
|
xhwang
2013/05/10 00:26:44
what's the reason these pepper related code isn't
ddorwin
2013/05/14 00:17:10
We can handle compatibility with a single ifdef at
| |
| 111 kExternalClearKeyKeySystem); | 110 kExternalClearKeyKeySystem); |
| 112 } | 111 } |
| 113 | 112 |
| 114 virtual void RegisterPepperPlugin(CommandLine* command_line, | 113 virtual void RegisterPepperCdm(CommandLine* command_line, |
| 115 const std::string& library_name, | 114 const base::FilePath::StringType& library_name, |
| 116 const std::string& key_system) { | 115 const std::string& key_system) { |
| 116 #if defined(ENABLE_PEPPER_CDMS) | |
| 117 // Append the switch to register the Clear Key CDM Adapter. | 117 // Append the switch to register the Clear Key CDM Adapter. |
| 118 base::FilePath plugin_dir; | 118 base::FilePath plugin_dir; |
| 119 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); | 119 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); |
| 120 #if defined(OS_WIN) | |
| 121 base::FilePath plugin_lib = plugin_dir.Append(ASCIIToWide(library_name)); | |
| 122 #else | |
| 123 base::FilePath plugin_lib = plugin_dir.Append(library_name); | 120 base::FilePath plugin_lib = plugin_dir.Append(library_name); |
| 124 #endif | |
| 125 EXPECT_TRUE(file_util::PathExists(plugin_lib)); | 121 EXPECT_TRUE(file_util::PathExists(plugin_lib)); |
| 126 base::FilePath::StringType pepper_plugin = plugin_lib.value(); | 122 base::FilePath::StringType pepper_plugin = plugin_lib.value(); |
| 127 pepper_plugin.append(FILE_PATH_LITERAL("#CDM#0.1.0.0;")); | 123 pepper_plugin.append(FILE_PATH_LITERAL("#CDM#0.1.0.0;")); |
| 128 #if defined(OS_WIN) | 124 #if defined(OS_WIN) |
| 129 pepper_plugin.append(ASCIIToWide(webkit_media::GetPluginType(key_system))); | 125 pepper_plugin.append(ASCIIToWide(webkit_media::GetPepperType(key_system))); |
| 130 #else | 126 #else |
| 131 pepper_plugin.append(webkit_media::GetPluginType(key_system)); | 127 pepper_plugin.append(webkit_media::GetPepperType(key_system)); |
| 132 #endif | 128 #endif |
| 133 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, | 129 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, |
| 134 pepper_plugin); | 130 pepper_plugin); |
| 131 #endif // defined(ENABLE_PEPPER_CDMS) | |
| 135 } | 132 } |
| 136 }; | 133 }; |
| 137 | 134 |
| 138 #if defined(WIDEVINE_CDM_AVAILABLE) | 135 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 139 class WVEncryptedMediaTest : public EncryptedMediaTest { | 136 class WVEncryptedMediaTest : public EncryptedMediaTest { |
| 140 public: | 137 public: |
| 141 // Tests that the following happen after trying to play encrypted media: | 138 // Tests that the following happen after trying to play encrypted media: |
| 142 // - webkitneedkey event is fired. | 139 // - webkitneedkey event is fired. |
| 143 // - webkitGenerateKeyRequest() does not fail. | 140 // - webkitGenerateKeyRequest() does not fail. |
| 144 // - webkitkeymessage is fired | 141 // - webkitkeymessage is fired |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 158 key_system, kExpectedWebKitError); | 155 key_system, kExpectedWebKitError); |
| 159 bool receivedKeyMessage = false; | 156 bool receivedKeyMessage = false; |
| 160 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 157 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 161 shell()->web_contents(), | 158 shell()->web_contents(), |
| 162 "window.domAutomationController.send(video.receivedKeyMessage);", | 159 "window.domAutomationController.send(video.receivedKeyMessage);", |
| 163 &receivedKeyMessage)); | 160 &receivedKeyMessage)); |
| 164 ASSERT_TRUE(receivedKeyMessage); | 161 ASSERT_TRUE(receivedKeyMessage); |
| 165 } | 162 } |
| 166 | 163 |
| 167 protected: | 164 protected: |
| 168 // Registers any CDM plugins not registered by default. | |
| 169 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 165 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 170 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); | 166 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); |
| 171 RegisterPepperPlugin(command_line, kWidevineLibraryName, | 167 RegisterPepperCdm(command_line, kWidevineLibraryName, kWidevineKeySystem); |
| 172 kWidevineKeySystem); | |
| 173 } | 168 } |
| 174 }; | 169 }; |
| 175 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 170 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 176 | 171 |
| 177 INSTANTIATE_TEST_CASE_P(ClearKey, EncryptedMediaTest, | 172 INSTANTIATE_TEST_CASE_P(ClearKey, EncryptedMediaTest, |
| 178 ::testing::Values(kClearKeyKeySystem)); | 173 ::testing::Values(kClearKeyKeySystem)); |
| 179 | 174 |
| 175 // External Clear Key is currently only used on platforms that use Pepper CDMs. | |
| 176 #if defined(ENABLE_PEPPER_CDMS) | |
| 180 INSTANTIATE_TEST_CASE_P(ExternalClearKey, EncryptedMediaTest, | 177 INSTANTIATE_TEST_CASE_P(ExternalClearKey, EncryptedMediaTest, |
| 181 ::testing::Values(kExternalClearKeyKeySystem)); | 178 ::testing::Values(kExternalClearKeyKeySystem)); |
| 179 #endif | |
| 182 | 180 |
| 183 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, InvalidKeySystem) { | 181 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, InvalidKeySystem) { |
| 184 const string16 kExpected = ASCIIToUTF16( | 182 const string16 kExpected = ASCIIToUTF16( |
| 185 StringToUpperASCII(std::string("GenerateKeyRequestException"))); | 183 StringToUpperASCII(std::string("GenerateKeyRequestException"))); |
| 186 TestSimplePlayback("bear-320x240-av-enc_av.webm", kWebMAudioVideo, | 184 TestSimplePlayback("bear-320x240-av-enc_av.webm", kWebMAudioVideo, |
| 187 "com.example.invalid", kExpected); | 185 "com.example.invalid", kExpected); |
| 188 } | 186 } |
| 189 | 187 |
| 190 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { | 188 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { |
| 191 TestSimplePlayback("bear-a-enc_a.webm", kWebMAudioOnly, GetParam(), | 189 TestSimplePlayback("bear-a-enc_a.webm", kWebMAudioOnly, GetParam(), |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 | 267 |
| 270 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, Playback_AudioOnly_MP4) { | 268 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, Playback_AudioOnly_MP4) { |
| 271 TestSimplePlayback("bear-640x360-a_frag-cenc.mp4", kMP4AudioOnly, | 269 TestSimplePlayback("bear-640x360-a_frag-cenc.mp4", kMP4AudioOnly, |
| 272 kWidevineKeySystem); | 270 kWidevineKeySystem); |
| 273 } | 271 } |
| 274 #endif // defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) | 272 #endif // defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) |
| 275 #endif // !defined(DISABLE_WIDEVINE_CDM_BROWSERTESTS) | 273 #endif // !defined(DISABLE_WIDEVINE_CDM_BROWSERTESTS) |
| 276 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 274 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 277 | 275 |
| 278 } // namespace content | 276 } // namespace content |
| OLD | NEW |