diff options
author | ycheo@chromium.org <ycheo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-13 07:13:58 +0000 |
---|---|---|
committer | ycheo@chromium.org <ycheo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-13 07:13:58 +0000 |
commit | 244722b1cbc6adbc2d662fbb9ff06c92d350241c (patch) | |
tree | c746b6d1ed26e7779c04c770fd41b2a7b0ac2c73 /components/cdm | |
parent | 3304602a91e4c6603e8e98e1a04908365e795a02 (diff) | |
download | chromium_src-244722b1cbc6adbc2d662fbb9ff06c92d350241c.zip chromium_src-244722b1cbc6adbc2d662fbb9ff06c92d350241c.tar.gz chromium_src-244722b1cbc6adbc2d662fbb9ff06c92d350241c.tar.bz2 |
Add an IPC to return the platform supported key-system names in Android.
- Split widevine_key_systems.(cc|h) into andorid_key_systems.* and
widevine_key_system.*.
- Add a method MediaDrmBridge::GetPlatformKeySystemNames().
BUG=322395
Review URL: https://codereview.chromium.org/320383005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276953 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/cdm')
-rw-r--r-- | components/cdm/browser/cdm_message_filter_android.cc | 16 | ||||
-rw-r--r-- | components/cdm/browser/cdm_message_filter_android.h | 9 | ||||
-rw-r--r-- | components/cdm/common/cdm_messages_android.h | 11 | ||||
-rw-r--r-- | components/cdm/renderer/android_key_systems.cc | 73 | ||||
-rw-r--r-- | components/cdm/renderer/android_key_systems.h | 24 | ||||
-rw-r--r-- | components/cdm/renderer/widevine_key_systems.cc | 34 | ||||
-rw-r--r-- | components/cdm/renderer/widevine_key_systems.h | 5 |
7 files changed, 124 insertions, 48 deletions
diff --git a/components/cdm/browser/cdm_message_filter_android.cc b/components/cdm/browser/cdm_message_filter_android.cc index 2bda860..ccea5fe 100644 --- a/components/cdm/browser/cdm_message_filter_android.cc +++ b/components/cdm/browser/cdm_message_filter_android.cc @@ -5,6 +5,7 @@ #include "components/cdm/browser/cdm_message_filter_android.h" #include <string> +#include <vector> #include "components/cdm/common/cdm_messages_android.h" #include "ipc/ipc_message_macros.h" @@ -73,8 +74,10 @@ CdmMessageFilterAndroid::~CdmMessageFilterAndroid() {} bool CdmMessageFilterAndroid::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(CdmMessageFilterAndroid, message) - IPC_MESSAGE_HANDLER(ChromeViewHostMsg_GetSupportedKeySystems, - OnGetSupportedKeySystems) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_QueryKeySystemSupport, + OnQueryKeySystemSupport) + IPC_MESSAGE_HANDLER(ChromeViewHostMsg_GetPlatformKeySystemNames, + OnGetPlatformKeySystemNames) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -83,11 +86,11 @@ bool CdmMessageFilterAndroid::OnMessageReceived(const IPC::Message& message) { void CdmMessageFilterAndroid::OverrideThreadForMessage( const IPC::Message& message, BrowserThread::ID* thread) { // Move the IPC handling to FILE thread as it is not very cheap. - if (message.type() == ChromeViewHostMsg_GetSupportedKeySystems::ID) + if (message.type() == ChromeViewHostMsg_QueryKeySystemSupport::ID) *thread = BrowserThread::FILE; } -void CdmMessageFilterAndroid::OnGetSupportedKeySystems( +void CdmMessageFilterAndroid::OnQueryKeySystemSupport( const SupportedKeySystemRequest& request, SupportedKeySystemResponse* response) { if (!response) { @@ -110,4 +113,9 @@ void CdmMessageFilterAndroid::OnGetSupportedKeySystems( response->non_compositing_codecs = GetSupportedCodecs(request, false); } +void CdmMessageFilterAndroid::OnGetPlatformKeySystemNames( + std::vector<std::string>* key_systems) { + *key_systems = MediaDrmBridge::GetPlatformKeySystemNames(); +} + } // namespace cdm diff --git a/components/cdm/browser/cdm_message_filter_android.h b/components/cdm/browser/cdm_message_filter_android.h index 47aa445..5388648 100644 --- a/components/cdm/browser/cdm_message_filter_android.h +++ b/components/cdm/browser/cdm_message_filter_android.h @@ -29,10 +29,11 @@ class CdmMessageFilterAndroid const IPC::Message& message, content::BrowserThread::ID* thread) OVERRIDE; - // Retrieve the supported key systems. - void OnGetSupportedKeySystems( - const SupportedKeySystemRequest& request, - SupportedKeySystemResponse* response); + // Query the key system information. + void OnQueryKeySystemSupport(const SupportedKeySystemRequest& request, + SupportedKeySystemResponse* response); + + void OnGetPlatformKeySystemNames(std::vector<std::string>* key_systems); DISALLOW_COPY_AND_ASSIGN(CdmMessageFilterAndroid); }; diff --git a/components/cdm/common/cdm_messages_android.h b/components/cdm/common/cdm_messages_android.h index e63f81b..f78674d 100644 --- a/components/cdm/common/cdm_messages_android.h +++ b/components/cdm/common/cdm_messages_android.h @@ -29,8 +29,15 @@ IPC_STRUCT_END() // Messages sent from the renderer to the browser. -// Synchronously get a list of supported EME key systems. +// Synchronously query key system information. If the key system is supported, +// the response will be populated. IPC_SYNC_MESSAGE_CONTROL1_1( - ChromeViewHostMsg_GetSupportedKeySystems, + ChromeViewHostMsg_QueryKeySystemSupport, SupportedKeySystemRequest /* key system information request */, SupportedKeySystemResponse /* key system information response */) + +// Synchronously get a list of platform-supported EME key system names that +// are not explicitly handled by Chrome. +IPC_SYNC_MESSAGE_CONTROL0_1( + ChromeViewHostMsg_GetPlatformKeySystemNames, + std::vector<std::string> /* key system names */) diff --git a/components/cdm/renderer/android_key_systems.cc b/components/cdm/renderer/android_key_systems.cc new file mode 100644 index 0000000..5c3837c8 --- /dev/null +++ b/components/cdm/renderer/android_key_systems.cc @@ -0,0 +1,73 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/cdm/renderer/android_key_systems.h" + +#include <string> +#include <vector> + +#include "base/logging.h" +#include "components/cdm/common/cdm_messages_android.h" +#include "components/cdm/renderer/widevine_key_systems.h" +#include "content/public/renderer/render_thread.h" + +#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. + +using content::KeySystemInfo; +using content::SupportedCodecs; + +namespace cdm { + +static SupportedKeySystemResponse QueryKeySystemSupport( + const std::string& key_system) { + SupportedKeySystemRequest request; + SupportedKeySystemResponse response; + + request.key_system = key_system; + request.codecs = content::EME_CODEC_WEBM_ALL | content::EME_CODEC_MP4_ALL; + content::RenderThread::Get()->Send( + new ChromeViewHostMsg_QueryKeySystemSupport(request, &response)); + DCHECK(!(response.compositing_codecs & ~content::EME_CODEC_ALL)) + << "unrecognized codec"; + DCHECK(!(response.non_compositing_codecs & ~content::EME_CODEC_ALL)) + << "unrecognized codec"; + return response; +} + +void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems) { + SupportedKeySystemResponse response = QueryKeySystemSupport( + kWidevineKeySystem); + if (response.compositing_codecs != content::EME_CODEC_NONE) { + AddWidevineWithCodecs( + WIDEVINE, + static_cast<SupportedCodecs>(response.compositing_codecs), + concrete_key_systems); + } + + if (response.non_compositing_codecs != content::EME_CODEC_NONE) { + AddWidevineWithCodecs( + WIDEVINE_HR_NON_COMPOSITING, + static_cast<SupportedCodecs>(response.non_compositing_codecs), + concrete_key_systems); + } +} + +void AddAndroidPlatformKeySystems( + std::vector<KeySystemInfo>* concrete_key_systems) { + std::vector<std::string> key_system_names; + content::RenderThread::Get()->Send( + new ChromeViewHostMsg_GetPlatformKeySystemNames(&key_system_names)); + + for (std::vector<std::string>::const_iterator it = key_system_names.begin(); + it != key_system_names.end(); ++it) { + SupportedKeySystemResponse response = QueryKeySystemSupport(*it); + if (response.compositing_codecs != content::EME_CODEC_NONE) { + KeySystemInfo info(*it); + info.supported_codecs = response.compositing_codecs; + concrete_key_systems->push_back(info); + } + } +} + +} // namespace cdm diff --git a/components/cdm/renderer/android_key_systems.h b/components/cdm/renderer/android_key_systems.h new file mode 100644 index 0000000..36be6c9 --- /dev/null +++ b/components/cdm/renderer/android_key_systems.h @@ -0,0 +1,24 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_CDM_RENDERER_ANDROID_KEY_SYSTEMS_H_ +#define COMPONENTS_CDM_RENDERER_ANDROID_KEY_SYSTEMS_H_ + +#include <vector> + +#include "content/public/renderer/key_system_info.h" + +namespace cdm { + +void AddAndroidWidevine( + std::vector<content::KeySystemInfo>* concrete_key_systems); + +// Add platform-supported key systems which are not explicitly handled +// by Chrome. +void AddAndroidPlatformKeySystems( + std::vector<content::KeySystemInfo>* concrete_key_systems); + +} // namespace cdm + +#endif // COMPONENTS_CDM_RENDERER_ANDROID_KEY_SYSTEMS_H_ diff --git a/components/cdm/renderer/widevine_key_systems.cc b/components/cdm/renderer/widevine_key_systems.cc index c913fe0..2a41322 100644 --- a/components/cdm/renderer/widevine_key_systems.cc +++ b/components/cdm/renderer/widevine_key_systems.cc @@ -8,11 +8,8 @@ #include <vector> #include "base/logging.h" -#include "components/cdm/common/cdm_messages_android.h" -#include "content/public/renderer/key_system_info.h" -#include "content/public/renderer/render_thread.h" -#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. +#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. #if defined(WIDEVINE_CDM_AVAILABLE) @@ -59,35 +56,6 @@ void AddWidevineWithCodecs(WidevineCdmType widevine_cdm_type, concrete_key_systems->push_back(info); } -#if defined(OS_ANDROID) -void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems) { - SupportedKeySystemRequest request; - SupportedKeySystemResponse response; - - request.key_system = kWidevineKeySystem; - request.codecs = content::EME_CODEC_WEBM_ALL | content::EME_CODEC_MP4_ALL; - content::RenderThread::Get()->Send( - new ChromeViewHostMsg_GetSupportedKeySystems(request, &response)); - DCHECK(response.compositing_codecs & content::EME_CODEC_ALL) - << "unrecognized codec"; - DCHECK(response.non_compositing_codecs & content::EME_CODEC_ALL) - << "unrecognized codec"; - if (response.compositing_codecs != content::EME_CODEC_NONE) { - AddWidevineWithCodecs( - WIDEVINE, - static_cast<SupportedCodecs>(response.compositing_codecs), - concrete_key_systems); - } - - if (response.non_compositing_codecs != content::EME_CODEC_NONE) { - AddWidevineWithCodecs( - WIDEVINE_HR_NON_COMPOSITING, - static_cast<SupportedCodecs>(response.non_compositing_codecs), - concrete_key_systems); - } -} -#endif // OS_ANDROID - } // namespace cdm #endif // defined(WIDEVINE_CDM_AVAILABLE) diff --git a/components/cdm/renderer/widevine_key_systems.h b/components/cdm/renderer/widevine_key_systems.h index 3bed60c..ab1966f 100644 --- a/components/cdm/renderer/widevine_key_systems.h +++ b/components/cdm/renderer/widevine_key_systems.h @@ -23,11 +23,6 @@ void AddWidevineWithCodecs( content::SupportedCodecs supported_codecs, std::vector<content::KeySystemInfo>* concrete_key_systems); -#if defined(OS_ANDROID) -void AddAndroidWidevine( - std::vector<content::KeySystemInfo>* concrete_key_systems); -#endif // defined(OS_ANDROID) - } // namespace cdm #endif // COMPONENTS_CDM_RENDERER_WIDEVINE_KEY_SYSTEMS_H_ |