Skip to content

Commit

Permalink
Implement Chromium side of MediaKeys.isTypeSupported().
Browse files Browse the repository at this point in the history
BUG=405731

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

Cr-Commit-Position: refs/heads/master@{#297550}
  • Loading branch information
sandersd authored and Commit bot committed Sep 30, 2014
1 parent a683d26 commit 3573622
Show file tree
Hide file tree
Showing 12 changed files with 250 additions and 72 deletions.
3 changes: 3 additions & 0 deletions chrome/renderer/media/chrome_key_systems.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion components/cdm/common/cdm_messages_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions components/cdm/renderer/DEPS
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include_rules = [
"+content/public/common",
"+content/public/renderer",
]
10 changes: 10 additions & 0 deletions components/cdm/renderer/android_key_systems.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}
}
Expand Down
11 changes: 11 additions & 0 deletions components/cdm/renderer/widevine_key_systems.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion content/content_common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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_
2 changes: 2 additions & 0 deletions content/public/renderer/key_system_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
}

Expand Down
5 changes: 4 additions & 1 deletion content/public/renderer/key_system_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand Down
Loading

0 comments on commit 3573622

Please sign in to comment.