Commit 578089ca authored by Xiaohan Wang's avatar Xiaohan Wang Committed by Commit Bot

media: Add EME persistent-usage-record session support

This CL updates blink and chromium to support persistent-usage-record
session, which is behind a flag.

To enable the support, use the following command line flag:

--enable-blink-features=EncryptedMediaPersistentUsageRecordSession

ExternalClearKey key system is also updated to declare support
for this session type, even though in the implementation it doesn't do
anything special.

No other CDMs support this session type yet, which will be done later.

TBR=foolip@chromium.org

Bug: 856925
Cq-Include-Trybots: luci.chromium.try:linux_chromium_dbg_ng
Change-Id: Iff38bc79f43e375144f045564e045a830d86699a
Reviewed-on: https://chromium-review.googlesource.com/1119565
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarJohn Rummell <jrummell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587674}
parent e773216e
...@@ -180,8 +180,10 @@ class EncryptedMediaSupportedTypesTest : public InProcessBrowserTest { ...@@ -180,8 +180,10 @@ class EncryptedMediaSupportedTypesTest : public InProcessBrowserTest {
test_launcher_utils::RemoveCommandLineSwitch( test_launcher_utils::RemoveCommandLineSwitch(
default_command_line, switches::kDisableComponentUpdate, command_line); default_command_line, switches::kDisableComponentUpdate, command_line);
#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS) #endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
command_line->AppendSwitchASCII("enable-blink-features", command_line->AppendSwitchASCII(
"EncryptedMediaEncryptionSchemeQuery"); "enable-blink-features",
"EncryptedMediaEncryptionSchemeQuery,"
"EncryptedMediaPersistentUsageRecordSession");
} }
void SetUpOnMainThread() override { void SetUpOnMainThread() override {
...@@ -260,8 +262,9 @@ class EncryptedMediaSupportedTypesTest : public InProcessBrowserTest { ...@@ -260,8 +262,9 @@ class EncryptedMediaSupportedTypesTest : public InProcessBrowserTest {
} }
enum class SessionType { enum class SessionType {
kTemporary, // Temporary session kTemporary, // Temporary session
kPersistentLicense // Persistent license session kPersistentLicense, // Persistent license session
kPersistentUsageRecord // Persistent usage record session
}; };
std::string GetSessionTypeString(SessionType session_type) { std::string GetSessionTypeString(SessionType session_type) {
...@@ -270,6 +273,8 @@ class EncryptedMediaSupportedTypesTest : public InProcessBrowserTest { ...@@ -270,6 +273,8 @@ class EncryptedMediaSupportedTypesTest : public InProcessBrowserTest {
return "temporary"; return "temporary";
case SessionType::kPersistentLicense: case SessionType::kPersistentLicense:
return "persistent-license"; return "persistent-license";
case SessionType::kPersistentUsageRecord:
return "persistent-usage-record";
} }
NOTREACHED(); NOTREACHED();
...@@ -638,9 +643,11 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesClearKeyTest, SessionType) { ...@@ -638,9 +643,11 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesClearKeyTest, SessionType) {
// Temporary session always supported. // Temporary session always supported.
EXPECT_SUCCESS(IsSessionTypeSupported(kClearKey, SessionType::kTemporary)); EXPECT_SUCCESS(IsSessionTypeSupported(kClearKey, SessionType::kTemporary));
// Persistent license session not supported by Clear Key key system. // Persistent sessions not supported by Clear Key key system.
EXPECT_UNSUPPORTED( EXPECT_UNSUPPORTED(
IsSessionTypeSupported(kClearKey, SessionType::kPersistentLicense)); IsSessionTypeSupported(kClearKey, SessionType::kPersistentLicense));
EXPECT_UNSUPPORTED(
IsSessionTypeSupported(kClearKey, SessionType::kPersistentUsageRecord));
} }
IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesClearKeyTest, Robustness) { IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesClearKeyTest, Robustness) {
...@@ -838,9 +845,11 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesExternalClearKeyTest, ...@@ -838,9 +845,11 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesExternalClearKeyTest,
EXPECT_SUCCESS( EXPECT_SUCCESS(
IsSessionTypeSupported(kExternalClearKey, SessionType::kTemporary)); IsSessionTypeSupported(kExternalClearKey, SessionType::kTemporary));
// Persistent license session always supported by External Clear Key. // Persistent sessions always supported by External Clear Key.
EXPECT_SUCCESS(IsSessionTypeSupported(kExternalClearKey, EXPECT_SUCCESS(IsSessionTypeSupported(kExternalClearKey,
SessionType::kPersistentLicense)); SessionType::kPersistentLicense));
EXPECT_SUCCESS(IsSessionTypeSupported(kExternalClearKey,
SessionType::kPersistentUsageRecord));
} }
IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesExternalClearKeyTest, IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesExternalClearKeyTest,
...@@ -1062,6 +1071,10 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineTest, SessionType) { ...@@ -1062,6 +1071,10 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineTest, SessionType) {
#else #else
EXPECT_UNSUPPORTED(result); EXPECT_UNSUPPORTED(result);
#endif #endif
// Persistent usage record session not supported on any platform.
EXPECT_UNSUPPORTED(
IsSessionTypeSupported(kWidevine, SessionType::kPersistentUsageRecord));
} }
IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineTest, Robustness) { IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineTest, Robustness) {
......
...@@ -559,7 +559,8 @@ void ChromeContentClient::AddContentDecryptionModules( ...@@ -559,7 +559,8 @@ void ChromeContentClient::AddContentDecryptionModules(
content::CdmCapability capability( content::CdmCapability capability(
{}, {media::EncryptionMode::kCenc, media::EncryptionMode::kCbcs}, {}, {media::EncryptionMode::kCenc, media::EncryptionMode::kCbcs},
{media::CdmSessionType::kTemporary, {media::CdmSessionType::kTemporary,
media::CdmSessionType::kPersistentLicense}, media::CdmSessionType::kPersistentLicense,
media::CdmSessionType::kPersistentUsageRecord},
{}); {});
// Register kExternalClearKeyDifferentGuidTestKeySystem first separately. // Register kExternalClearKeyDifferentGuidTestKeySystem first separately.
......
...@@ -82,6 +82,7 @@ static void AddExternalClearKey( ...@@ -82,6 +82,7 @@ static void AddExternalClearKey(
static const char kExternalClearKeyCdmProxyKeySystem[] = static const char kExternalClearKeyCdmProxyKeySystem[] =
"org.chromium.externalclearkey.cdmproxy"; "org.chromium.externalclearkey.cdmproxy";
// TODO(xhwang): Actually use |capability| to determine capabilities.
media::mojom::KeySystemCapabilityPtr capability; media::mojom::KeySystemCapabilityPtr capability;
if (!content::IsKeySystemSupported(kExternalClearKeyKeySystem, &capability)) { if (!content::IsKeySystemSupported(kExternalClearKeyKeySystem, &capability)) {
DVLOG(1) << "External Clear Key not supported"; DVLOG(1) << "External Clear Key not supported";
...@@ -282,7 +283,13 @@ static void AddWidevine( ...@@ -282,7 +283,13 @@ static void AddWidevine(
capability->session_types, media::CdmSessionType::kPersistentLicense); capability->session_types, media::CdmSessionType::kPersistentLicense);
auto persistent_license_support = auto persistent_license_support =
GetPersistentLicenseSupport(cdm_supports_persistent_license); GetPersistentLicenseSupport(cdm_supports_persistent_license);
auto persistent_usage_record_support = EmeSessionTypeSupport::NOT_SUPPORTED;
// TODO(xhwang): Check more conditions as needed.
auto persistent_usage_record_support =
base::ContainsValue(capability->session_types,
media::CdmSessionType::kPersistentUsageRecord)
? EmeSessionTypeSupport::SUPPORTED
: EmeSessionTypeSupport::NOT_SUPPORTED;
// Others. // Others.
auto persistent_state_support = EmeFeatureSupport::REQUESTABLE; auto persistent_state_support = EmeFeatureSupport::REQUESTABLE;
......
...@@ -66,7 +66,7 @@ ExternalClearKeyProperties::GetPersistentLicenseSessionSupport() const { ...@@ -66,7 +66,7 @@ ExternalClearKeyProperties::GetPersistentLicenseSessionSupport() const {
media::EmeSessionTypeSupport media::EmeSessionTypeSupport
ExternalClearKeyProperties::GetPersistentUsageRecordSessionSupport() const { ExternalClearKeyProperties::GetPersistentUsageRecordSessionSupport() const {
return media::EmeSessionTypeSupport::NOT_SUPPORTED; return media::EmeSessionTypeSupport::SUPPORTED;
} }
media::EmeFeatureSupport ExternalClearKeyProperties::GetPersistentStateSupport() media::EmeFeatureSupport ExternalClearKeyProperties::GetPersistentStateSupport()
......
...@@ -418,11 +418,6 @@ void KeySystemsImpl::AddSupportedKeySystems( ...@@ -418,11 +418,6 @@ void KeySystemsImpl::AddSupportedKeySystems(
EmeSessionTypeSupport::NOT_SUPPORTED); EmeSessionTypeSupport::NOT_SUPPORTED);
} }
// persistent-usage-record sessions are not currently supported.
// http://crbug.com/448888
DCHECK(properties->GetPersistentUsageRecordSessionSupport() ==
EmeSessionTypeSupport::NOT_SUPPORTED);
// If distinctive identifiers are not supported, then no other features can // If distinctive identifiers are not supported, then no other features can
// require them. // require them.
if (properties->GetDistinctiveIdentifierSupport() == if (properties->GetDistinctiveIdentifierSupport() ==
......
...@@ -4,12 +4,15 @@ ...@@ -4,12 +4,15 @@
#include "third_party/blink/renderer/modules/encryptedmedia/encrypted_media_utils.h" #include "third_party/blink/renderer/modules/encryptedmedia/encrypted_media_utils.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
namespace blink { namespace blink {
namespace { namespace {
const char kTemporary[] = "temporary"; const char kTemporary[] = "temporary";
const char kPersistentLicense[] = "persistent-license"; const char kPersistentLicense[] = "persistent-license";
const char kPersistentUsageRecord[] = "persistent-usage-record";
} // namespace } // namespace
...@@ -54,6 +57,11 @@ WebEncryptedMediaSessionType EncryptedMediaUtils::ConvertToSessionType( ...@@ -54,6 +57,11 @@ WebEncryptedMediaSessionType EncryptedMediaUtils::ConvertToSessionType(
return WebEncryptedMediaSessionType::kTemporary; return WebEncryptedMediaSessionType::kTemporary;
if (session_type == kPersistentLicense) if (session_type == kPersistentLicense)
return WebEncryptedMediaSessionType::kPersistentLicense; return WebEncryptedMediaSessionType::kPersistentLicense;
if (session_type == kPersistentUsageRecord &&
RuntimeEnabledFeatures::
EncryptedMediaPersistentUsageRecordSessionEnabled()) {
return WebEncryptedMediaSessionType::kPersistentUsageRecord;
}
// |sessionType| is not restricted in the idl, so anything is possible. // |sessionType| is not restricted in the idl, so anything is possible.
return WebEncryptedMediaSessionType::kUnknown; return WebEncryptedMediaSessionType::kUnknown;
...@@ -67,10 +75,14 @@ String EncryptedMediaUtils::ConvertFromSessionType( ...@@ -67,10 +75,14 @@ String EncryptedMediaUtils::ConvertFromSessionType(
return kTemporary; return kTemporary;
case WebEncryptedMediaSessionType::kPersistentLicense: case WebEncryptedMediaSessionType::kPersistentLicense:
return kPersistentLicense; return kPersistentLicense;
// TODO(crbug.com/856925): Add support for kPersistentUsageRecord.
case WebEncryptedMediaSessionType::kPersistentUsageRecord: case WebEncryptedMediaSessionType::kPersistentUsageRecord:
if (RuntimeEnabledFeatures::
EncryptedMediaPersistentUsageRecordSessionEnabled()) {
return kPersistentUsageRecord;
}
FALLTHROUGH;
case WebEncryptedMediaSessionType::kUnknown: case WebEncryptedMediaSessionType::kUnknown:
// Chromium should not use Unknown. // Unexpected session type from Chromium.
NOTREACHED(); NOTREACHED();
return String(); return String();
} }
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "third_party/blink/renderer/platform/bindings/script_state.h" #include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/bindings/v8_throw_exception.h" #include "third_party/blink/renderer/platform/bindings/v8_throw_exception.h"
#include "third_party/blink/renderer/platform/instance_counters.h" #include "third_party/blink/renderer/platform/instance_counters.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/timer.h" #include "third_party/blink/renderer/platform/timer.h"
#define MEDIA_KEYS_LOG_LEVEL 3 #define MEDIA_KEYS_LOG_LEVEL 3
...@@ -233,6 +234,21 @@ MediaKeySession* MediaKeys::createSession(ScriptState* script_state, ...@@ -233,6 +234,21 @@ MediaKeySession* MediaKeys::createSession(ScriptState* script_state,
DVLOG(MEDIA_KEYS_LOG_LEVEL) DVLOG(MEDIA_KEYS_LOG_LEVEL)
<< __func__ << "(" << this << ") " << session_type_string; << __func__ << "(" << this << ") " << session_type_string;
// [RuntimeEnabled] does not work with enum values. So we have to check it
// here. See https://crbug.com/871867 for details.
if (!RuntimeEnabledFeatures::
EncryptedMediaPersistentUsageRecordSessionEnabled() &&
session_type_string == "persistent-usage-record") {
DVLOG(MEDIA_KEYS_LOG_LEVEL)
<< __func__ << ": 'persistent-usage-record' support not enabled.";
// The message here is carefully chosen to be exactly the same as what the
// generated bindings would generate for invalid enum values.
exception_state.ThrowTypeError(
"The provided value 'persistent-usage-record' is not a valid enum "
"value of type MediaKeySessionType.");
return nullptr;
}
// From http://w3c.github.io/encrypted-media/#createSession // From http://w3c.github.io/encrypted-media/#createSession
// When this method is invoked, the user agent must run the following steps: // When this method is invoked, the user agent must run the following steps:
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
enum MediaKeySessionType { enum MediaKeySessionType {
"temporary", "temporary",
"persistent-license", "persistent-license",
"persistent-usage-record",
}; };
[ [
......
...@@ -394,6 +394,10 @@ ...@@ -394,6 +394,10 @@
origin_trial_feature_name: "EncryptedMediaHdcpPolicyCheck", origin_trial_feature_name: "EncryptedMediaHdcpPolicyCheck",
status: "experimental", status: "experimental",
}, },
{
name: "EncryptedMediaPersistentUsageRecordSession",
status: "test",
},
{ {
name: "EventTiming", name: "EventTiming",
origin_trial_feature_name: "EventTiming", origin_trial_feature_name: "EventTiming",
......
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