Commit a8a9143d authored by sandersd's avatar sandersd Committed by Commit bot

Implement robustness strings in requestMediaKeySystemAccess().

BUG=442586,460616

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

Cr-Commit-Position: refs/heads/master@{#322219}
parent f1eb0a7e
......@@ -75,22 +75,22 @@ static void AddExternalClearKey(
KeySystemInfo info;
info.key_system = kExternalClearKeyKeySystem;
info.supported_codecs = media::EME_CODEC_WEBM_ALL;
info.supported_init_data_types =
media::EME_INIT_DATA_TYPE_WEBM | media::EME_INIT_DATA_TYPE_KEYIDS;
info.supported_codecs = media::EME_CODEC_WEBM_ALL;
#if defined(USE_PROPRIETARY_CODECS)
info.supported_codecs |= media::EME_CODEC_MP4_ALL;
info.supported_init_data_types |= media::EME_INIT_DATA_TYPE_CENC;
info.supported_codecs |= media::EME_CODEC_MP4_ALL;
#endif // defined(USE_PROPRIETARY_CODECS)
info.max_audio_robustness = media::EmeRobustness::EMPTY;
info.max_video_robustness = media::EmeRobustness::EMPTY;
// Persistent sessions are faked.
info.persistent_license_support = media::EME_SESSION_TYPE_SUPPORTED;
info.persistent_release_message_support =
media::EME_SESSION_TYPE_NOT_SUPPORTED;
// TODO(sandersd): Using ALWAYS_ENABLED prevents "not-allowed" from
// succeeding. Change this to REQUESTABLE once the state can be blocked.
// http://crbug.com/457482
info.persistent_state_support = media::EME_FEATURE_ALWAYS_ENABLED;
info.persistent_state_support = media::EME_FEATURE_REQUESTABLE;
info.distinctive_identifier_support = media::EME_FEATURE_NOT_SUPPORTED;
info.pepper_type = kExternalClearKeyPepperType;
......@@ -193,23 +193,20 @@ static void AddPepperBasedWidevine(
cdm::AddWidevineWithCodecs(
cdm::WIDEVINE, supported_codecs,
#if defined(OS_CHROMEOS)
// Persistent licenses are supported if remote attestation succeeds.
media::EME_SESSION_TYPE_SUPPORTED_WITH_PERMISSION,
media::EME_SESSION_TYPE_NOT_SUPPORTED, // Persistent release message.
// TODO(sandersd): Using ALWAYS_ENABLED prevents "not-allowed" from
// succeeding. Change this to REQUESTABLE once the state can be blocked.
// http://crbug.com/457482
media::EME_FEATURE_ALWAYS_ENABLED, // Persistent state.
// A distinctive identifier will be available if remote attestation
// succeeds.
media::EME_FEATURE_REQUESTABLE_WITH_PERMISSION,
media::EmeRobustness::HW_SECURE_ALL, // Maximum audio robustness.
media::EmeRobustness::HW_SECURE_ALL, // Maximim video robustness.
// persistent-license.
media::EME_SESSION_TYPE_SUPPORTED_WITH_IDENTIFIER,
media::EME_SESSION_TYPE_NOT_SUPPORTED, // persistent-release-message.
media::EME_FEATURE_REQUESTABLE, // Persistent state.
// Distinctive identifier.
media::EME_FEATURE_REQUESTABLE_WITH_IDENTIFIER,
#else // (Desktop)
media::EME_SESSION_TYPE_NOT_SUPPORTED, // Persistent license.
media::EME_SESSION_TYPE_NOT_SUPPORTED, // Persistent release message.
// TODO(sandersd): Using ALWAYS_ENABLED prevents "not-allowed" from
// succeeding. Change this to REQUESTABLE once the state can be blocked.
// http://crbug.com/457482
media::EME_FEATURE_ALWAYS_ENABLED, // Persistent state.
media::EmeRobustness::SW_SECURE_CRYPTO, // Maximum audio robustness.
media::EmeRobustness::SW_SECURE_DECODE, // Maximum video robustness.
media::EME_SESSION_TYPE_NOT_SUPPORTED, // persistent-license.
media::EME_SESSION_TYPE_NOT_SUPPORTED, // persistent-release-message.
media::EME_FEATURE_REQUESTABLE, // Persistent state.
media::EME_FEATURE_NOT_SUPPORTED, // Distinctive identifier.
#endif // defined(OS_CHROMEOS)
concrete_key_systems);
......
......@@ -22,9 +22,11 @@ void AddKeySystemWithCodecs(
std::vector<::media::KeySystemInfo>* key_systems_info) {
::media::KeySystemInfo info;
info.key_system = key_system_name;
info.supported_init_data_types = ::media::EME_INIT_DATA_TYPE_CENC;
info.supported_codecs =
::media::EME_CODEC_MP4_AAC | ::media::EME_CODEC_MP4_AVC1;
info.supported_init_data_types = ::media::EME_INIT_DATA_TYPE_CENC;
info.max_audio_robustness = ::media::EmeRobustness::EMPTY;
info.max_video_robustness = ::media::EmeRobustness::EMPTY;
info.persistent_license_support = ::media::EME_SESSION_TYPE_NOT_SUPPORTED;
info.persistent_release_message_support =
::media::EME_SESSION_TYPE_NOT_SUPPORTED;
......@@ -39,8 +41,10 @@ void AddChromecastKeySystems(
AddWidevineWithCodecs(
cdm::WIDEVINE,
::media::EME_CODEC_MP4_AAC | ::media::EME_CODEC_MP4_AVC1,
::media::EME_SESSION_TYPE_NOT_SUPPORTED, // Persistent license.
::media::EME_SESSION_TYPE_NOT_SUPPORTED, // Persistent release message.
::media::EmeRobustness::HW_SECURE_ALL, // Max audio robustness.
::media::EmeRobustness::HW_SECURE_ALL, // Max video robustness.
::media::EME_SESSION_TYPE_NOT_SUPPORTED, // persistent-license.
::media::EME_SESSION_TYPE_NOT_SUPPORTED, // persistent-release-message.
::media::EME_FEATURE_NOT_SUPPORTED, // Persistent state.
::media::EME_FEATURE_ALWAYS_ENABLED, // Distinctive identifier.
key_systems_info);
......
......@@ -7,14 +7,17 @@
#include <string>
#include <vector>
#include "base/command_line.h"
#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 "media/base/eme_constants.h"
#include "media/base/media_switches.h"
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
using media::EmeRobustness;
using media::KeySystemInfo;
using media::SupportedCodecs;
......@@ -39,24 +42,48 @@ static SupportedKeySystemResponse QueryKeySystemSupport(
void AddAndroidWidevine(std::vector<KeySystemInfo>* concrete_key_systems) {
SupportedKeySystemResponse response = QueryKeySystemSupport(
kWidevineKeySystem);
if (response.compositing_codecs != media::EME_CODEC_NONE) {
// When creating the WIDEVINE key system, BrowserCdmFactoryAndroid configures
// the CDM's security level based on the --mediadrm-enable-non-compositing
// flag (L1 if the flag is enabled, L3 otherwise). Therefore the supported
// codec/robustenss combinations depend on that flag.
// TODO(sandersd): For unprefixed, set the security level based on the
// requested robustness instead of the flag. http://crbug.com/467779
SupportedCodecs codecs = response.compositing_codecs;
EmeRobustness max_audio_robustness = EmeRobustness::SW_SECURE_CRYPTO;
EmeRobustness max_video_robustness = EmeRobustness::SW_SECURE_CRYPTO;
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kMediaDrmEnableNonCompositing)) {
codecs = response.non_compositing_codecs;
max_audio_robustness = EmeRobustness::HW_SECURE_CRYPTO;
max_video_robustness = EmeRobustness::HW_SECURE_ALL;
}
if (codecs != media::EME_CODEC_NONE) {
AddWidevineWithCodecs(
WIDEVINE,
static_cast<SupportedCodecs>(response.compositing_codecs),
media::EME_SESSION_TYPE_NOT_SUPPORTED, // Persistent license.
media::EME_SESSION_TYPE_NOT_SUPPORTED, // Persistent release message.
codecs,
max_audio_robustness,
max_video_robustness,
media::EME_SESSION_TYPE_NOT_SUPPORTED, // persistent-license.
media::EME_SESSION_TYPE_NOT_SUPPORTED, // persistent-release-message.
media::EME_FEATURE_NOT_SUPPORTED, // Persistent state.
media::EME_FEATURE_ALWAYS_ENABLED, // Distinctive identifier.
concrete_key_systems);
}
if (response.non_compositing_codecs != media::EME_CODEC_NONE) {
// For compatibility with the prefixed API, register a separate L1 key system.
// When creating the WIDEVINE_HR_NON_COMPOSITING key system,
// BrowserCdmFactoryAndroid does not configure the CDM's security level (that
// is, leaves it as L1); therefore only secure codecs are supported.
// TODO(ddorwin): Remove with unprefixed. http://crbug.com/249976
if (response.non_compositing_codecs != media::EME_CODEC_NONE) {
AddWidevineWithCodecs(
WIDEVINE_HR_NON_COMPOSITING,
static_cast<SupportedCodecs>(response.non_compositing_codecs),
media::EME_SESSION_TYPE_NOT_SUPPORTED, // Persistent license.
media::EME_SESSION_TYPE_NOT_SUPPORTED, // Persistent release message.
response.non_compositing_codecs,
EmeRobustness::HW_SECURE_CRYPTO, // Max audio robustness.
EmeRobustness::HW_SECURE_ALL, // Max video robustness.
media::EME_SESSION_TYPE_NOT_SUPPORTED, // persistent-license.
media::EME_SESSION_TYPE_NOT_SUPPORTED, // persistent-release-message.
media::EME_FEATURE_NOT_SUPPORTED, // Persistent state.
media::EME_FEATURE_ALWAYS_ENABLED, // Distinctive identifier.
concrete_key_systems);
......@@ -85,6 +112,8 @@ void AddAndroidPlatformKeySystems(
if (response.compositing_codecs & media::EME_CODEC_MP4_ALL)
info.supported_init_data_types |= media::EME_INIT_DATA_TYPE_CENC;
#endif // defined(USE_PROPRIETARY_CODECS)
info.max_audio_robustness = EmeRobustness::EMPTY;
info.max_video_robustness = EmeRobustness::EMPTY;
// Assume the worst case (from a user point of view).
info.persistent_license_support = media::EME_SESSION_TYPE_NOT_SUPPORTED;
info.persistent_release_message_support =
......
......@@ -29,6 +29,8 @@ static std::string GetDirectParentName(std::string name) {
void AddWidevineWithCodecs(
WidevineCdmType widevine_cdm_type,
SupportedCodecs supported_codecs,
media::EmeRobustness max_audio_robustness,
media::EmeRobustness max_video_robustness,
media::EmeSessionTypeSupport persistent_license_support,
media::EmeSessionTypeSupport persistent_release_message_support,
media::EmeFeatureSupport persistent_state_support,
......@@ -66,6 +68,8 @@ void AddWidevineWithCodecs(
info.supported_init_data_types |= media::EME_INIT_DATA_TYPE_CENC;
#endif // defined(USE_PROPRIETARY_CODECS)
info.max_audio_robustness = max_audio_robustness;
info.max_video_robustness = max_video_robustness;
info.persistent_license_support = persistent_license_support;
info.persistent_release_message_support = persistent_release_message_support;
info.persistent_state_support = persistent_state_support;
......
......@@ -22,6 +22,8 @@ enum WidevineCdmType {
void AddWidevineWithCodecs(
WidevineCdmType widevine_cdm_type,
media::SupportedCodecs supported_codecs,
media::EmeRobustness max_audio_robustness,
media::EmeRobustness max_video_robustness,
media::EmeSessionTypeSupport persistent_license_support,
media::EmeSessionTypeSupport persistent_release_message_support,
media::EmeFeatureSupport persistent_state_support,
......
......@@ -27,6 +27,8 @@ class TestContentRendererClient : public ContentRendererClient {
// TODO(sandersd): Was this supposed to be added to the list?
media::KeySystemInfo key_system_info;
key_system_info.key_system = "test.keysystem";
key_system_info.max_audio_robustness = media::EmeRobustness::EMPTY;
key_system_info.max_video_robustness = media::EmeRobustness::EMPTY;
key_system_info.persistent_license_support =
media::EME_SESSION_TYPE_NOT_SUPPORTED;
key_system_info.persistent_release_message_support =
......@@ -40,6 +42,8 @@ class TestContentRendererClient : public ContentRendererClient {
if (is_extra_key_system_enabled_) {
media::KeySystemInfo wv_key_system_info;
wv_key_system_info.key_system = kWidevineKeySystem;
wv_key_system_info.max_audio_robustness = media::EmeRobustness::EMPTY;
wv_key_system_info.max_video_robustness = media::EmeRobustness::EMPTY;
wv_key_system_info.persistent_license_support =
media::EME_SESSION_TYPE_NOT_SUPPORTED;
wv_key_system_info.persistent_release_message_support =
......
......@@ -34,7 +34,7 @@ scoped_ptr<BrowserCdm> BrowserCdmFactoryAndroid::CreateBrowserCdm(
}
// TODO(xhwang/ddorwin): Pass the security level from key system.
// http://crbug.com/459400
// http://crbug.com/467779
if (key_system == kWidevineKeySystem) {
MediaDrmBridge::SecurityLevel security_level =
MediaDrmBridge::SECURITY_LEVEL_3;
......
......@@ -55,32 +55,75 @@ enum EmeSessionTypeSupport {
EME_SESSION_TYPE_INVALID,
// The session type is not supported.
EME_SESSION_TYPE_NOT_SUPPORTED,
// The session type is supported if the encrypted media permission is granted.
EME_SESSION_TYPE_SUPPORTED_WITH_PERMISSION,
// The session type is supported if a distinctive identifier is available.
EME_SESSION_TYPE_SUPPORTED_WITH_IDENTIFIER,
// The session type is always supported.
EME_SESSION_TYPE_SUPPORTED,
};
// Used to declare support for distinctive identifier and persistent state.
enum EmeFeatureSupport {
// Invalid default value.
EME_FEATURE_INVALID,
// Access to the feature is not supported at all.
EME_FEATURE_NOT_SUPPORTED,
// Access to the feature may be requested if the encrypted media permission is
// granted.
EME_FEATURE_REQUESTABLE_WITH_PERMISSION,
// Access to the feature may be requested if a distinctive identifier is
// available. (This is the correct choice for declaring support for a
// requestable distinctive identifier.)
EME_FEATURE_REQUESTABLE_WITH_IDENTIFIER,
// Access to the feature may be requested.
EME_FEATURE_REQUESTABLE,
// Access to the feature cannot be blocked.
EME_FEATURE_ALWAYS_ENABLED,
};
// Used to query support for distinctive identifier and persistent state.
enum EmeFeatureRequirement {
EME_FEATURE_NOT_ALLOWED,
EME_FEATURE_OPTIONAL,
EME_FEATURE_REQUIRED,
};
enum class EmeMediaType {
AUDIO,
VIDEO,
};
// Robustness values understood by KeySystems.
// Note: KeySystems expects this ordering (in GetRobustnessConfigRule()),
// changes may be required there if this list changes.
enum class EmeRobustness {
INVALID,
EMPTY,
SW_SECURE_CRYPTO,
SW_SECURE_DECODE,
HW_SECURE_CRYPTO,
HW_SECURE_DECODE,
HW_SECURE_ALL,
};
// Configuration rules indicate the configuration state required to support a
// configuration option (note: a configuration option may be disallowing a
// feature). Configuration rules are used to answer queries about distinctive
// identifier, persistent state, and robustness requirements, as well as to
// describe support for different session types.
//
// If in the future there are reasons to request user permission other than
// access to a distinctive identifier, then additional rules should be added.
// Rules are implemented in ConfigState and are otherwise opaque.
enum class EmeConfigRule {
// The configuration option is not supported.
NOT_SUPPORTED,
// The configuration option is supported if a distinctive identifier is
// available.
IDENTIFIER_REQUIRED,
// The configuration option is supported, but the user experience may be
// improved if a distinctive identifier is available.
IDENTIFIER_RECOMMENDED,
// The configuration option is supported without conditions.
SUPPORTED,
};
} // namespace media
#endif // MEDIA_BASE_EME_CONSTANTS_H_
......@@ -9,6 +9,8 @@ namespace media {
KeySystemInfo::KeySystemInfo()
: supported_init_data_types(EME_INIT_DATA_TYPE_NONE),
supported_codecs(EME_CODEC_NONE),
max_audio_robustness(EmeRobustness::INVALID),
max_video_robustness(EmeRobustness::INVALID),
persistent_license_support(EME_SESSION_TYPE_INVALID),
persistent_release_message_support(EME_SESSION_TYPE_INVALID),
persistent_state_support(EME_FEATURE_INVALID),
......
......@@ -35,13 +35,10 @@ struct MEDIA_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;
// Specifies session types and features supported by |key_system|.
EmeRobustness max_audio_robustness;
EmeRobustness max_video_robustness;
EmeSessionTypeSupport persistent_license_support;
EmeSessionTypeSupport persistent_release_message_support;
EmeFeatureSupport persistent_state_support;
......
This diff is collapsed.
......@@ -85,27 +85,32 @@ MEDIA_EXPORT std::string GetPepperType(
const std::string& concrete_key_system);
#endif
// Returns whether |key_system| supports persistent-license sessions.
MEDIA_EXPORT bool IsPersistentLicenseSessionSupported(
// Returns the configuration rule for supporting a robustness requirement.
// TODO(sandersd): Also take a list of codecs, as they may affect the result.
MEDIA_EXPORT EmeConfigRule GetRobustnessConfigRule(
const std::string& key_system,
bool is_permission_granted);
EmeMediaType media_type,
const std::string& requested_robustness);
// Returns whether |key_system| supports persistent-release-message sessions.
MEDIA_EXPORT bool IsPersistentReleaseMessageSessionSupported(
const std::string& key_system,
bool is_permission_granted);
// Returns the configuration rule for supporting persistent-license sessions.
MEDIA_EXPORT EmeConfigRule GetPersistentLicenseSessionConfigRule(
const std::string& key_system);
// Returns the configuration rule for supporting persistent-release-message
// sessions.
MEDIA_EXPORT EmeConfigRule GetPersistentReleaseMessageSessionConfigRule(
const std::string& key_system);
// Returns whether |key_system| supports persistent state as requested.
MEDIA_EXPORT bool IsPersistentStateRequirementSupported(
// Returns the configuration rule for supporting a persistent state requirement.
MEDIA_EXPORT EmeConfigRule GetPersistentStateConfigRule(
const std::string& key_system,
EmeFeatureRequirement requirement,
bool is_permission_granted);
EmeFeatureRequirement requirement);
// Returns whether |key_system| supports distinctive identifiers as requested.
MEDIA_EXPORT bool IsDistinctiveIdentifierRequirementSupported(
// Returns the configuration rule for supporting a distinctive identifier
// requirement.
MEDIA_EXPORT EmeConfigRule GetDistinctiveIdentifierConfigRule(
const std::string& key_system,
EmeFeatureRequirement requirement,
bool is_permission_granted);
EmeFeatureRequirement requirement);
#if defined(UNIT_TEST)
// Helper functions to add container/codec types for testing purposes.
......
......@@ -166,6 +166,8 @@ void TestMediaClient::AddUsesAesKeySystem(
system.supported_codecs = EME_CODEC_WEBM_ALL;
system.supported_codecs |= TEST_CODEC_FOO_ALL;
system.supported_init_data_types = EME_INIT_DATA_TYPE_WEBM;
system.max_audio_robustness = EmeRobustness::EMPTY;
system.max_video_robustness = EmeRobustness::EMPTY;
system.persistent_license_support = EME_SESSION_TYPE_NOT_SUPPORTED;
system.persistent_release_message_support = EME_SESSION_TYPE_NOT_SUPPORTED;
system.persistent_state_support = EME_FEATURE_NOT_SUPPORTED;
......@@ -181,6 +183,8 @@ void TestMediaClient::AddExternalKeySystem(
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.max_audio_robustness = EmeRobustness::EMPTY;
ext.max_video_robustness = EmeRobustness::EMPTY;
ext.persistent_license_support = EME_SESSION_TYPE_SUPPORTED;
ext.persistent_release_message_support = EME_SESSION_TYPE_NOT_SUPPORTED;
ext.persistent_state_support = EME_FEATURE_ALWAYS_ENABLED;
......
This diff is collapsed.
......@@ -85,8 +85,10 @@ PlayerUtils.registerEMEEventListeners = function(player) {
this.registerDefaultEventListeners(player);
Utils.timeLog('Setting video media keys: ' + player.testConfig.keySystem);
var persistentState = player.testConfig.sessionToLoad ? "required"
: "optional";
return navigator.requestMediaKeySystemAccess(
player.testConfig.keySystem, [{}])
player.testConfig.keySystem, [{persistentState: persistentState}])
.then(function(access) { return access.createMediaKeys(); })
.then(function(mediaKeys) {
return player.video.setMediaKeys(mediaKeys);
......
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