Commit 3573622d authored by sandersd's avatar sandersd Committed by Commit bot

Implement Chromium side of MediaKeys.isTypeSupported().

BUG=405731

Review URL: https://codereview.chromium.org/557723003

Cr-Commit-Position: refs/heads/master@{#297550}
parent a683d267
......@@ -13,6 +13,7 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/common/render_messages.h"
#include "components/cdm/renderer/widevine_key_systems.h"
#include "content/public/common/eme_constants.h"
#include "content/public/renderer/render_thread.h"
#if defined(OS_ANDROID)
......@@ -74,8 +75,10 @@ static void AddExternalClearKey(
KeySystemInfo info(kExternalClearKeyKeySystem);
info.supported_codecs = content::EME_CODEC_WEBM_ALL;
info.supported_init_data_types = content::EME_INIT_DATA_TYPE_WEBM;
#if defined(USE_PROPRIETARY_CODECS)
info.supported_codecs |= content::EME_CODEC_MP4_ALL;
info.supported_init_data_types |= content::EME_INIT_DATA_TYPE_CENC;
#endif // defined(USE_PROPRIETARY_CODECS)
info.pepper_type = kExternalClearKeyPepperType;
......
......@@ -7,7 +7,7 @@
#include <vector>
#include "content/public/common/eme_codec.h"
#include "content/public/common/eme_constants.h"
#include "ipc/ipc_message_macros.h"
#define IPC_MESSAGE_START EncryptedMediaMsgStart
......
include_rules = [
"+content/public/common",
"+content/public/renderer",
]
......@@ -10,6 +10,7 @@
#include "base/logging.h"
#include "components/cdm/common/cdm_messages_android.h"
#include "components/cdm/renderer/widevine_key_systems.h"
#include "content/public/common/eme_constants.h"
#include "content/public/renderer/render_thread.h"
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
......@@ -65,6 +66,15 @@ void AddAndroidPlatformKeySystems(
if (response.compositing_codecs != content::EME_CODEC_NONE) {
KeySystemInfo info(*it);
info.supported_codecs = response.compositing_codecs;
// Here we assume that support for a container implies support for the
// associated initialization data type. KeySystems handles validating
// |init_data_type| x |container| pairings.
if (response.compositing_codecs & content::EME_CODEC_WEBM_ALL)
info.supported_init_data_types |= content::EME_INIT_DATA_TYPE_WEBM;
#if defined(USE_PROPRIETARY_CODECS)
if (response.compositing_codecs & content::EME_CODEC_MP4_ALL)
info.supported_init_data_types |= content::EME_INIT_DATA_TYPE_CENC;
#endif // defined(USE_PROPRIETARY_CODECS)
concrete_key_systems->push_back(info);
}
}
......
......@@ -8,6 +8,7 @@
#include <vector>
#include "base/logging.h"
#include "content/public/common/eme_constants.h"
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
......@@ -49,6 +50,16 @@ void AddWidevineWithCodecs(WidevineCdmType widevine_cdm_type,
// initDataType.
info.supported_codecs = supported_codecs;
// Here we assume that support for a container imples support for the
// associated initialization data type. KeySystems handles validating
// |init_data_type| x |container| pairings.
if (supported_codecs & content::EME_CODEC_WEBM_ALL)
info.supported_init_data_types |= content::EME_INIT_DATA_TYPE_WEBM;
#if defined(USE_PROPRIETARY_CODECS)
if (supported_codecs & content::EME_CODEC_MP4_ALL)
info.supported_init_data_types |= content::EME_INIT_DATA_TYPE_CENC;
#endif // defined(USE_PROPRIETARY_CODECS)
#if defined(ENABLE_PEPPER_CDMS)
info.pepper_type = kWidevineCdmPluginMimeType;
#endif // defined(ENABLE_PEPPER_CDMS)
......
......@@ -57,7 +57,7 @@
'public/common/context_menu_params.h',
'public/common/drop_data.cc',
'public/common/drop_data.h',
'public/common/eme_codec.h',
'public/common/eme_constants.h',
'public/common/favicon_url.cc',
'public/common/favicon_url.h',
'public/common/file_chooser_params.cc',
......
......@@ -2,15 +2,30 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_COMMON_EME_CODEC_H_
#define CONTENT_PUBLIC_COMMON_EME_CODEC_H_
#ifndef CONTENT_PUBLIC_COMMON_EME_CONSTANTS_H_
#define CONTENT_PUBLIC_COMMON_EME_CONSTANTS_H_
#include <stdint.h>
namespace content {
// Defines bitmask values that specify registered initialization data types used
// in Encrypted Media Extensions (EME).
// The mask values are stored in a SupportedInitDataTypes.
enum EmeInitDataType {
EME_INIT_DATA_TYPE_NONE = 0,
EME_INIT_DATA_TYPE_WEBM = 1 << 0,
#if defined(USE_PROPRIETARY_CODECS)
EME_INIT_DATA_TYPE_CENC = 1 << 1,
#endif // defined(USE_PROPRIETARY_CODECS)
};
// Defines bitmask values that specify codecs used in Encrypted Media Extension
// (EME). Each value represents a codec within a specific container.
// The mask values are stored in a SupportedCodecs.
enum EmeCodec {
// *_ALL values should only be used for masking, do not use them to specify
// codec support because they may be extended to include more codecs.
EME_CODEC_NONE = 0,
EME_CODEC_WEBM_VORBIS = 1 << 0,
EME_CODEC_WEBM_AUDIO_ALL = EME_CODEC_WEBM_VORBIS,
......@@ -30,8 +45,9 @@ enum EmeCodec {
#endif // defined(USE_PROPRIETARY_CODECS)
};
typedef uint32 SupportedCodecs;
typedef uint32_t SupportedInitDataTypes;
typedef uint32_t SupportedCodecs;
} // namespace content
#endif // CONTENT_PUBLIC_COMMON_EME_CODEC_H_
#endif // CONTENT_PUBLIC_COMMON_EME_CONSTANTS_H_
......@@ -8,6 +8,8 @@ namespace content {
KeySystemInfo::KeySystemInfo(const std::string& key_system)
: key_system(key_system),
supported_init_data_types(EME_INIT_DATA_TYPE_NONE),
supported_codecs(EME_CODEC_NONE),
use_aes_decryptor(false) {
}
......
......@@ -11,7 +11,7 @@
#include "base/basictypes.h"
#include "base/containers/hash_tables.h"
#include "content/common/content_export.h"
#include "content/public/common/eme_codec.h"
#include "content/public/common/eme_constants.h"
// Definitions:
// * Key system
......@@ -38,6 +38,9 @@ struct CONTENT_EXPORT KeySystemInfo {
std::string key_system;
// Specifies registered initialization data types supported by |key_system|.
SupportedInitDataTypes supported_init_data_types;
// Specifies codecs supported by |key_system|.
SupportedCodecs supported_codecs;
......
......@@ -24,6 +24,24 @@ std::string GetUnprefixedKeySystemName(const std::string& key_system);
// Gets the prefixed key system name for |key_system|.
std::string GetPrefixedKeySystemName(const std::string& key_system);
// Returns false if a container-specific |init_data_type| is specified with an
// inappropriate container.
// TODO(sandersd): Remove this essentially internal detail if the spec is
// updated to not convolve the two in a single method call.
// TODO(sandersd): Use enum values instead of strings. http://crbug.com/417440
bool IsSaneInitDataTypeWithContainer(
const std::string& init_data_type,
const std::string& container);
// Note: Shouldn't be used for prefixed API as the original
// IsSupportedKeySystemWithMediaMimeType() path reports UMAs, but this path does
// not.
bool IsSupportedKeySystem(const std::string& key_system);
bool IsSupportedKeySystemWithInitDataType(
const std::string& key_system,
const std::string& init_data_type);
// Returns whether |key_system| is a real supported key system that can be
// instantiated.
// Abstract parent |key_system| strings will return false.
......
......@@ -6,6 +6,7 @@
#include <vector>
#include "content/public/common/content_client.h"
#include "content/public/common/eme_constants.h"
#include "content/public/renderer/content_renderer_client.h"
#include "content/public/renderer/key_system_info.h"
#include "content/renderer/media/crypto/key_systems.h"
......@@ -100,12 +101,14 @@ void TestContentRendererClient::AddKeySystems(
KeySystemInfo aes(kUsesAes);
aes.supported_codecs = EME_CODEC_WEBM_ALL;
aes.supported_codecs |= TEST_CODEC_FOO_ALL;
aes.supported_init_data_types = EME_INIT_DATA_TYPE_WEBM;
aes.use_aes_decryptor = true;
key_systems->push_back(aes);
KeySystemInfo ext(kExternal);
ext.supported_codecs = EME_CODEC_WEBM_ALL;
ext.supported_codecs |= TEST_CODEC_FOO_ALL;
ext.supported_init_data_types = EME_INIT_DATA_TYPE_WEBM;
ext.parent_key_system = kExternalParent;
#if defined(ENABLE_PEPPER_CDMS)
ext.pepper_type = "application/x-ppapi-external-cdm";
......@@ -113,6 +116,7 @@ void TestContentRendererClient::AddKeySystems(
key_systems->push_back(ext);
}
// TODO(sandersd): Refactor. http://crbug.com/417444
class KeySystemsTest : public testing::Test {
protected:
KeySystemsTest() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment