Commit a5dfedf7 authored by John Rummell's avatar John Rummell Committed by Commit Bot

Change EncryptionScheme to match latest spec

The current version of the EME spec
(https://w3c.github.io/encrypted-media/) has encryptionScheme as a
DOMString with an additional value allowed ("cbcs-1-9"). Updating
the code to match this.

This also moves the feature to stable now that it has been approved.

With this change the W3C test
(https://wpt.live/encrypted-media/clearkey-check-encryption-scheme.https.html)
passes.

Bug: 1035153
Test: Updated media_blink_unittests, browser_tests, and WPT tests pass
Change-Id: I00cb2ce8a4c4f52f95817471226b5e8129660247
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1972617Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarXiaohan Wang <xhwang@chromium.org>
Commit-Queue: John Rummell <jrummell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#731780}
parent 65afcfa0
...@@ -61,11 +61,9 @@ const char kSuccessResult[] = "success"; ...@@ -61,11 +61,9 @@ const char kSuccessResult[] = "success";
const char kUnsupportedResult[] = const char kUnsupportedResult[] =
"Unsupported keySystem or supportedConfigurations."; "Unsupported keySystem or supportedConfigurations.";
const char kUnexpectedResult[] = "unexpected result"; const char kUnexpectedResult[] = "unexpected result";
const char kTypeErrorResult[] = "TypeError";
#define EXPECT_SUCCESS(test) EXPECT_EQ(kSuccessResult, test) #define EXPECT_SUCCESS(test) EXPECT_EQ(kSuccessResult, test)
#define EXPECT_UNSUPPORTED(test) EXPECT_EQ(kUnsupportedResult, test) #define EXPECT_UNSUPPORTED(test) EXPECT_EQ(kUnsupportedResult, test)
#define EXPECT_TYPEERROR(test) EXPECT_EQ(kTypeErrorResult, test)
// Any support is acceptable. This can be used around new CDM check-in time // Any support is acceptable. This can be used around new CDM check-in time
// where test expectations can change based on the new CDM's capability. // where test expectations can change based on the new CDM's capability.
...@@ -280,7 +278,6 @@ class EncryptedMediaSupportedTypesTest : public InProcessBrowserTest { ...@@ -280,7 +278,6 @@ class EncryptedMediaSupportedTypesTest : public InProcessBrowserTest {
base::ASCIIToUTF16(kSuccessResult)); base::ASCIIToUTF16(kSuccessResult));
title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kUnsupportedResult)); title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kUnsupportedResult));
title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kUnexpectedResult)); title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kUnexpectedResult));
title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16(kTypeErrorResult));
EXPECT_TRUE(content::ExecuteScript(contents, command)); EXPECT_TRUE(content::ExecuteScript(contents, command));
base::string16 result = title_watcher.WaitAndGetTitle(); base::string16 result = title_watcher.WaitAndGetTitle();
return base::UTF16ToASCII(result); return base::UTF16ToASCII(result);
...@@ -722,17 +719,17 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesClearKeyTest, ...@@ -722,17 +719,17 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesClearKeyTest,
EXPECT_SUCCESS(IsAudioEncryptionSchemeSupported(kClearKey, nullptr)); EXPECT_SUCCESS(IsAudioEncryptionSchemeSupported(kClearKey, nullptr));
EXPECT_SUCCESS(IsAudioEncryptionSchemeSupported(kClearKey, "cenc")); EXPECT_SUCCESS(IsAudioEncryptionSchemeSupported(kClearKey, "cenc"));
EXPECT_SUCCESS(IsAudioEncryptionSchemeSupported(kClearKey, "cbcs")); EXPECT_SUCCESS(IsAudioEncryptionSchemeSupported(kClearKey, "cbcs"));
EXPECT_SUCCESS(IsAudioEncryptionSchemeSupported(kClearKey, "cbcs-1-9"));
EXPECT_SUCCESS(IsVideoEncryptionSchemeSupported(kClearKey, nullptr)); EXPECT_SUCCESS(IsVideoEncryptionSchemeSupported(kClearKey, nullptr));
EXPECT_SUCCESS(IsVideoEncryptionSchemeSupported(kClearKey, "cenc")); EXPECT_SUCCESS(IsVideoEncryptionSchemeSupported(kClearKey, "cenc"));
EXPECT_SUCCESS(IsVideoEncryptionSchemeSupported(kClearKey, "cbcs")); EXPECT_SUCCESS(IsVideoEncryptionSchemeSupported(kClearKey, "cbcs"));
EXPECT_SUCCESS(IsVideoEncryptionSchemeSupported(kClearKey, "cbcs-1-9"));
// Invalid encryption schemes will be rejected. However, invalid values // Invalid encryption schemes will be rejected.
// generate a TypeError (The provided value '...' is not a valid enum value EXPECT_UNSUPPORTED(IsAudioEncryptionSchemeSupported(kClearKey, "Invalid"));
// of type EncryptionScheme), which is not handled by the test page. EXPECT_UNSUPPORTED(IsVideoEncryptionSchemeSupported(kClearKey, "Invalid"));
EXPECT_TYPEERROR(IsAudioEncryptionSchemeSupported(kClearKey, "Invalid")); EXPECT_UNSUPPORTED(IsAudioEncryptionSchemeSupported(kClearKey, ""));
EXPECT_TYPEERROR(IsVideoEncryptionSchemeSupported(kClearKey, "Invalid")); EXPECT_UNSUPPORTED(IsVideoEncryptionSchemeSupported(kClearKey, ""));
EXPECT_TYPEERROR(IsAudioEncryptionSchemeSupported(kClearKey, ""));
EXPECT_TYPEERROR(IsVideoEncryptionSchemeSupported(kClearKey, ""));
} }
// //
...@@ -942,19 +939,21 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesExternalClearKeyTest, ...@@ -942,19 +939,21 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesExternalClearKeyTest,
EXPECT_SUCCESS(IsAudioEncryptionSchemeSupported(kExternalClearKey, nullptr)); EXPECT_SUCCESS(IsAudioEncryptionSchemeSupported(kExternalClearKey, nullptr));
EXPECT_SUCCESS(IsAudioEncryptionSchemeSupported(kExternalClearKey, "cenc")); EXPECT_SUCCESS(IsAudioEncryptionSchemeSupported(kExternalClearKey, "cenc"));
EXPECT_SUCCESS(IsAudioEncryptionSchemeSupported(kExternalClearKey, "cbcs")); EXPECT_SUCCESS(IsAudioEncryptionSchemeSupported(kExternalClearKey, "cbcs"));
EXPECT_SUCCESS(
IsAudioEncryptionSchemeSupported(kExternalClearKey, "cbcs-1-9"));
EXPECT_SUCCESS(IsVideoEncryptionSchemeSupported(kExternalClearKey, nullptr)); EXPECT_SUCCESS(IsVideoEncryptionSchemeSupported(kExternalClearKey, nullptr));
EXPECT_SUCCESS(IsVideoEncryptionSchemeSupported(kExternalClearKey, "cenc")); EXPECT_SUCCESS(IsVideoEncryptionSchemeSupported(kExternalClearKey, "cenc"));
EXPECT_SUCCESS(IsVideoEncryptionSchemeSupported(kExternalClearKey, "cbcs")); EXPECT_SUCCESS(IsVideoEncryptionSchemeSupported(kExternalClearKey, "cbcs"));
EXPECT_SUCCESS(
IsVideoEncryptionSchemeSupported(kExternalClearKey, "cbcs-1-9"));
// Invalid encryption schemes will be rejected. However, invalid values // Invalid encryption schemes will be rejected.
// generate a TypeError (The provided value '...' is not a valid enum value EXPECT_UNSUPPORTED(
// of type EncryptionScheme), which is not handled by the test page.
EXPECT_TYPEERROR(
IsAudioEncryptionSchemeSupported(kExternalClearKey, "Invalid")); IsAudioEncryptionSchemeSupported(kExternalClearKey, "Invalid"));
EXPECT_TYPEERROR( EXPECT_UNSUPPORTED(
IsVideoEncryptionSchemeSupported(kExternalClearKey, "Invalid")); IsVideoEncryptionSchemeSupported(kExternalClearKey, "Invalid"));
EXPECT_TYPEERROR(IsAudioEncryptionSchemeSupported(kExternalClearKey, "")); EXPECT_UNSUPPORTED(IsAudioEncryptionSchemeSupported(kExternalClearKey, ""));
EXPECT_TYPEERROR(IsVideoEncryptionSchemeSupported(kExternalClearKey, "")); EXPECT_UNSUPPORTED(IsVideoEncryptionSchemeSupported(kExternalClearKey, ""));
} }
// External Clear Key is disabled by default. // External Clear Key is disabled by default.
...@@ -1199,17 +1198,17 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineTest, ...@@ -1199,17 +1198,17 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineTest,
EXPECT_WV_SUCCESS(IsAudioEncryptionSchemeSupported(kWidevine, nullptr)); EXPECT_WV_SUCCESS(IsAudioEncryptionSchemeSupported(kWidevine, nullptr));
EXPECT_WV_SUCCESS(IsAudioEncryptionSchemeSupported(kWidevine, "cenc")); EXPECT_WV_SUCCESS(IsAudioEncryptionSchemeSupported(kWidevine, "cenc"));
EXPECT_WV_SUCCESS(IsAudioEncryptionSchemeSupported(kWidevine, "cbcs")); EXPECT_WV_SUCCESS(IsAudioEncryptionSchemeSupported(kWidevine, "cbcs"));
EXPECT_WV_SUCCESS(IsAudioEncryptionSchemeSupported(kWidevine, "cbcs-1-9"));
EXPECT_WV_SUCCESS(IsVideoEncryptionSchemeSupported(kWidevine, nullptr)); EXPECT_WV_SUCCESS(IsVideoEncryptionSchemeSupported(kWidevine, nullptr));
EXPECT_WV_SUCCESS(IsVideoEncryptionSchemeSupported(kWidevine, "cenc")); EXPECT_WV_SUCCESS(IsVideoEncryptionSchemeSupported(kWidevine, "cenc"));
EXPECT_WV_SUCCESS(IsVideoEncryptionSchemeSupported(kWidevine, "cbcs")); EXPECT_WV_SUCCESS(IsVideoEncryptionSchemeSupported(kWidevine, "cbcs"));
EXPECT_WV_SUCCESS(IsVideoEncryptionSchemeSupported(kWidevine, "cbcs-1-9"));
// Invalid encryption schemes will be rejected. However, invalid values // Invalid encryption schemes will be rejected.
// generate a TypeError (The provided value '...' is not a valid enum value EXPECT_UNSUPPORTED(IsAudioEncryptionSchemeSupported(kWidevine, "Invalid"));
// of type EncryptionScheme), which is not handled by the test page. EXPECT_UNSUPPORTED(IsVideoEncryptionSchemeSupported(kWidevine, "Invalid"));
EXPECT_TYPEERROR(IsAudioEncryptionSchemeSupported(kWidevine, "Invalid")); EXPECT_UNSUPPORTED(IsAudioEncryptionSchemeSupported(kWidevine, ""));
EXPECT_TYPEERROR(IsVideoEncryptionSchemeSupported(kWidevine, "Invalid")); EXPECT_UNSUPPORTED(IsVideoEncryptionSchemeSupported(kWidevine, ""));
EXPECT_TYPEERROR(IsAudioEncryptionSchemeSupported(kWidevine, ""));
EXPECT_TYPEERROR(IsVideoEncryptionSchemeSupported(kWidevine, ""));
} }
// //
...@@ -1220,8 +1219,8 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineTest, ...@@ -1220,8 +1219,8 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineTest,
// - Linux/Mac/Windows: Feature media::kHardwareSecureDecryption is enabled, and // - Linux/Mac/Windows: Feature media::kHardwareSecureDecryption is enabled, and
// command line switch kOverrideHardwareSecureCodecsForTesting is used to always // command line switch kOverrideHardwareSecureCodecsForTesting is used to always
// enable vp8 and vp9, and disable avc1; always enable 'cenc' and disable // enable vp8 and vp9, and disable avc1; always enable 'cenc' and disable
// 'cbcs', for HW_SECURE* robustness levels. With the switch, real hardware // 'cbcs'/'cbcs-1-9', for HW_SECURE* robustness levels. With the switch, real
// capabilities are not checked for the stability of tests. // hardware capabilities are not checked for the stability of tests.
IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineHwSecureTest, IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineHwSecureTest,
Robustness) { Robustness) {
...@@ -1297,8 +1296,10 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineHwSecureTest, ...@@ -1297,8 +1296,10 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineHwSecureTest,
// Both encryption schemes are supported when no robustness is specified. // Both encryption schemes are supported when no robustness is specified.
EXPECT_WV_SUCCESS(IsAudioEncryptionSchemeSupported(kWidevine, "cenc")); EXPECT_WV_SUCCESS(IsAudioEncryptionSchemeSupported(kWidevine, "cenc"));
EXPECT_WV_SUCCESS(IsAudioEncryptionSchemeSupported(kWidevine, "cbcs")); EXPECT_WV_SUCCESS(IsAudioEncryptionSchemeSupported(kWidevine, "cbcs"));
EXPECT_WV_SUCCESS(IsAudioEncryptionSchemeSupported(kWidevine, "cbcs-1-9"));
EXPECT_WV_SUCCESS(IsVideoEncryptionSchemeSupported(kWidevine, "cenc")); EXPECT_WV_SUCCESS(IsVideoEncryptionSchemeSupported(kWidevine, "cenc"));
EXPECT_WV_SUCCESS(IsVideoEncryptionSchemeSupported(kWidevine, "cbcs")); EXPECT_WV_SUCCESS(IsVideoEncryptionSchemeSupported(kWidevine, "cbcs"));
EXPECT_WV_SUCCESS(IsVideoEncryptionSchemeSupported(kWidevine, "cbcs-1-9"));
// Both encryption schemes are supported when SW_SECURE* robustness is // Both encryption schemes are supported when SW_SECURE* robustness is
// specified. // specified.
...@@ -1306,10 +1307,14 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineHwSecureTest, ...@@ -1306,10 +1307,14 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineHwSecureTest,
IsAudioEncryptionSchemeSupported(kWidevine, "cenc", "SW_SECURE_CRYPTO")); IsAudioEncryptionSchemeSupported(kWidevine, "cenc", "SW_SECURE_CRYPTO"));
EXPECT_WV_SUCCESS( EXPECT_WV_SUCCESS(
IsAudioEncryptionSchemeSupported(kWidevine, "cbcs", "SW_SECURE_CRYPTO")); IsAudioEncryptionSchemeSupported(kWidevine, "cbcs", "SW_SECURE_CRYPTO"));
EXPECT_WV_SUCCESS(IsAudioEncryptionSchemeSupported(kWidevine, "cbcs-1-9",
"SW_SECURE_CRYPTO"));
EXPECT_WV_SUCCESS( EXPECT_WV_SUCCESS(
IsVideoEncryptionSchemeSupported(kWidevine, "cenc", "SW_SECURE_DECODE")); IsVideoEncryptionSchemeSupported(kWidevine, "cenc", "SW_SECURE_DECODE"));
EXPECT_WV_SUCCESS( EXPECT_WV_SUCCESS(
IsVideoEncryptionSchemeSupported(kWidevine, "cbcs", "SW_SECURE_DECODE")); IsVideoEncryptionSchemeSupported(kWidevine, "cbcs", "SW_SECURE_DECODE"));
EXPECT_WV_SUCCESS(IsVideoEncryptionSchemeSupported(kWidevine, "cbcs-1-9",
"SW_SECURE_DECODE"));
// For HW_SECURE* robustness levels. 'cenc' is always supported. 'cbcs' is // For HW_SECURE* robustness levels. 'cenc' is always supported. 'cbcs' is
// supported on ChromeOS, but not on other platforms. // supported on ChromeOS, but not on other platforms.
...@@ -1320,13 +1325,21 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineHwSecureTest, ...@@ -1320,13 +1325,21 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaSupportedTypesWidevineHwSecureTest,
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
EXPECT_WV_SUCCESS( EXPECT_WV_SUCCESS(
IsAudioEncryptionSchemeSupported(kWidevine, "cbcs", "HW_SECURE_CRYPTO")); IsAudioEncryptionSchemeSupported(kWidevine, "cbcs", "HW_SECURE_CRYPTO"));
EXPECT_WV_SUCCESS(IsAudioEncryptionSchemeSupported(kWidevine, "cbcs-1-9",
"HW_SECURE_CRYPTO"));
EXPECT_WV_SUCCESS( EXPECT_WV_SUCCESS(
IsVideoEncryptionSchemeSupported(kWidevine, "cbcs", "HW_SECURE_ALL")); IsVideoEncryptionSchemeSupported(kWidevine, "cbcs", "HW_SECURE_ALL"));
EXPECT_WV_SUCCESS(
IsVideoEncryptionSchemeSupported(kWidevine, "cbcs-1-9", "HW_SECURE_ALL"));
#else #else
EXPECT_UNSUPPORTED( EXPECT_UNSUPPORTED(
IsAudioEncryptionSchemeSupported(kWidevine, "cbcs", "HW_SECURE_CRYPTO")); IsAudioEncryptionSchemeSupported(kWidevine, "cbcs", "HW_SECURE_CRYPTO"));
EXPECT_UNSUPPORTED(IsAudioEncryptionSchemeSupported(kWidevine, "cbcs-1-9",
"HW_SECURE_CRYPTO"));
EXPECT_UNSUPPORTED( EXPECT_UNSUPPORTED(
IsVideoEncryptionSchemeSupported(kWidevine, "cbcs", "HW_SECURE_ALL")); IsVideoEncryptionSchemeSupported(kWidevine, "cbcs", "HW_SECURE_ALL"));
EXPECT_UNSUPPORTED(
IsVideoEncryptionSchemeSupported(kWidevine, "cbcs-1-9", "HW_SECURE_ALL"));
#endif #endif
} }
......
...@@ -368,9 +368,10 @@ EmeConfigRule KeySystemConfigSelector::GetEncryptionSchemeConfigRule( ...@@ -368,9 +368,10 @@ EmeConfigRule KeySystemConfigSelector::GetEncryptionSchemeConfigRule(
const std::string& key_system, const std::string& key_system,
const EmeEncryptionScheme encryption_scheme) { const EmeEncryptionScheme encryption_scheme) {
switch (encryption_scheme) { switch (encryption_scheme) {
// https://github.com/WICG/encrypted-media-encryption-scheme/blob/master/explainer.md // https://w3c.github.io/encrypted-media/#dom-mediakeysystemmediacapability-encryptionscheme
// "A missing or null value indicates that any encryption scheme is // "A value which is null or not present indicates to the user agent that
// acceptable." // no specific encryption scheme is required by the application, and
// therefore any encryption scheme is acceptable."
// To fully implement this, we need to get the config rules for both kCenc // To fully implement this, we need to get the config rules for both kCenc
// and kCbcs, which could be conflicting, and choose a final config rule // and kCbcs, which could be conflicting, and choose a final config rule
// somehow. If we end up choosing the rule for kCbcs, we could actually // somehow. If we end up choosing the rule for kCbcs, we could actually
...@@ -381,8 +382,16 @@ EmeConfigRule KeySystemConfigSelector::GetEncryptionSchemeConfigRule( ...@@ -381,8 +382,16 @@ EmeConfigRule KeySystemConfigSelector::GetEncryptionSchemeConfigRule(
return key_systems_->GetEncryptionSchemeConfigRule( return key_systems_->GetEncryptionSchemeConfigRule(
key_system, EncryptionScheme::kCenc); key_system, EncryptionScheme::kCenc);
case EmeEncryptionScheme::kCbcs: case EmeEncryptionScheme::kCbcs:
case EmeEncryptionScheme::kCbcs_1_9:
return key_systems_->GetEncryptionSchemeConfigRule( return key_systems_->GetEncryptionSchemeConfigRule(
key_system, EncryptionScheme::kCbcs); key_system, EncryptionScheme::kCbcs);
case EmeEncryptionScheme::kUnrecognized:
// https://w3c.github.io/encrypted-media/#get-supported-capabilities-for-audio-video-type
// "If encryption scheme is non-null and is not recognized or not
// supported by implementation, continue to the next iteration."
// The value provided was an empty string or some other value that is
// not recognized, so treat it as a scheme that is not supported.
return EmeConfigRule::NOT_SUPPORTED;
} }
NOTREACHED(); NOTREACHED();
......
...@@ -84,7 +84,11 @@ media::EncryptionScheme ConvertEncryptionScheme( ...@@ -84,7 +84,11 @@ media::EncryptionScheme ConvertEncryptionScheme(
case EncryptionScheme::kCenc: case EncryptionScheme::kCenc:
return media::EncryptionScheme::kCenc; return media::EncryptionScheme::kCenc;
case EncryptionScheme::kCbcs: case EncryptionScheme::kCbcs:
case EncryptionScheme::kCbcs_1_9:
return media::EncryptionScheme::kCbcs; return media::EncryptionScheme::kCbcs;
case EncryptionScheme::kUnrecognized:
// Not used in these tests.
break;
} }
NOTREACHED(); NOTREACHED();
......
...@@ -14,6 +14,8 @@ struct WebMediaKeySystemMediaCapability { ...@@ -14,6 +14,8 @@ struct WebMediaKeySystemMediaCapability {
kNotSpecified, kNotSpecified,
kCenc, kCenc,
kCbcs, kCbcs,
kCbcs_1_9, // CBCS with a specific encrypt:skip pattern of 1:9.
kUnrecognized
}; };
WebMediaKeySystemMediaCapability() = default; WebMediaKeySystemMediaCapability() = default;
......
...@@ -93,6 +93,11 @@ static HeapVector<Member<MediaKeySystemMediaCapability>> ConvertCapabilities( ...@@ -93,6 +93,11 @@ static HeapVector<Member<MediaKeySystemMediaCapability>> ConvertCapabilities(
switch (capabilities[i].encryption_scheme) { switch (capabilities[i].encryption_scheme) {
case WebMediaKeySystemMediaCapability::EncryptionScheme::kNotSpecified: case WebMediaKeySystemMediaCapability::EncryptionScheme::kNotSpecified:
// https://w3c.github.io/encrypted-media/#dom-mediakeysystemaccess-getconfiguration
// "If encryptionScheme was not given by the application, the
// accumulated configuration MUST still contain a encryptionScheme
// field with a value of null, so that polyfills can detect the user
// agent's support for the field without specifying specific values."
capability->setEncryptionSchemeToNull(); capability->setEncryptionSchemeToNull();
break; break;
case WebMediaKeySystemMediaCapability::EncryptionScheme::kCenc: case WebMediaKeySystemMediaCapability::EncryptionScheme::kCenc:
...@@ -101,6 +106,13 @@ static HeapVector<Member<MediaKeySystemMediaCapability>> ConvertCapabilities( ...@@ -101,6 +106,13 @@ static HeapVector<Member<MediaKeySystemMediaCapability>> ConvertCapabilities(
case WebMediaKeySystemMediaCapability::EncryptionScheme::kCbcs: case WebMediaKeySystemMediaCapability::EncryptionScheme::kCbcs:
capability->setEncryptionScheme("cbcs"); capability->setEncryptionScheme("cbcs");
break; break;
case WebMediaKeySystemMediaCapability::EncryptionScheme::kCbcs_1_9:
capability->setEncryptionScheme("cbcs-1-9");
break;
case WebMediaKeySystemMediaCapability::EncryptionScheme::kUnrecognized:
NOTREACHED()
<< "Unrecognized encryption scheme should never be returned.";
break;
} }
result[i] = capability; result[i] = capability;
......
...@@ -33,9 +33,11 @@ ConvertEncryptionScheme(const String& encryption_scheme) { ...@@ -33,9 +33,11 @@ ConvertEncryptionScheme(const String& encryption_scheme) {
return WebMediaKeySystemMediaCapability::EncryptionScheme::kCenc; return WebMediaKeySystemMediaCapability::EncryptionScheme::kCenc;
if (encryption_scheme == "cbcs") if (encryption_scheme == "cbcs")
return WebMediaKeySystemMediaCapability::EncryptionScheme::kCbcs; return WebMediaKeySystemMediaCapability::EncryptionScheme::kCbcs;
if (encryption_scheme == "cbcs-1-9")
return WebMediaKeySystemMediaCapability::EncryptionScheme::kCbcs_1_9;
NOTREACHED(); // Any other strings are not recognized (and therefore not supported).
return WebMediaKeySystemMediaCapability::EncryptionScheme::kNotSpecified; return WebMediaKeySystemMediaCapability::EncryptionScheme::kUnrecognized;
} }
static WebVector<WebMediaKeySystemMediaCapability> ConvertCapabilities( static WebVector<WebMediaKeySystemMediaCapability> ConvertCapabilities(
...@@ -57,14 +59,8 @@ static WebVector<WebMediaKeySystemMediaCapability> ConvertCapabilities( ...@@ -57,14 +59,8 @@ static WebVector<WebMediaKeySystemMediaCapability> ConvertCapabilities(
if (type.GetParameters().ParameterCount() == 1u) if (type.GetParameters().ParameterCount() == 1u)
result[i].codecs = type.ParameterValueForName("codecs"); result[i].codecs = type.ParameterValueForName("codecs");
} }
result[i].robustness = capabilities[i]->robustness();
// From result[i].robustness = capabilities[i]->robustness();
// https://github.com/WICG/encrypted-media-encryption-scheme/blob/master/explainer.md
// "Asking for "any" encryption scheme is unrealistic. Defining null as
// "any scheme" is convenient for backward compatibility, though.
// Applications which ignore this feature by leaving encryptionScheme null
// get the same user agent behavior they did before this feature existed."
result[i].encryption_scheme = result[i].encryption_scheme =
capabilities[i]->hasEncryptionScheme() capabilities[i]->hasEncryptionScheme()
? ConvertEncryptionScheme(capabilities[i]->encryptionScheme()) ? ConvertEncryptionScheme(capabilities[i]->encryptionScheme())
......
...@@ -2,12 +2,10 @@ ...@@ -2,12 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// https://w3c.github.io/encrypted-media/#idl-def-MediaKeySystemMediaCapability // https://w3c.github.io/encrypted-media/#mediakeysystemmediacapability-dictionary
enum EncryptionScheme { "cenc", "cbcs" };
dictionary MediaKeySystemMediaCapability { dictionary MediaKeySystemMediaCapability {
DOMString contentType = ""; DOMString contentType = "";
DOMString robustness = ""; DOMString robustness = "";
[RuntimeEnabled=EncryptedMediaEncryptionSchemeQuery] EncryptionScheme? encryptionScheme = null; [RuntimeEnabled=EncryptedMediaEncryptionSchemeQuery] DOMString? encryptionScheme = null;
}; };
...@@ -623,7 +623,7 @@ ...@@ -623,7 +623,7 @@
}, },
{ {
name: "EncryptedMediaEncryptionSchemeQuery", name: "EncryptedMediaEncryptionSchemeQuery",
status: "test", status: "stable",
}, },
{ {
name: "EncryptedMediaHdcpPolicyCheck", name: "EncryptedMediaHdcpPolicyCheck",
......
...@@ -38,4 +38,9 @@ function runTest(config, qualifier) ...@@ -38,4 +38,9 @@ function runTest(config, qualifier)
promise_test( promise_test(
() => checkEncryptionScheme('cbcs'), () => checkEncryptionScheme('cbcs'),
testnamePrefix(qualifier, config.keysystem) + ' support for "cbcs" encryption scheme.'); testnamePrefix(qualifier, config.keysystem) + ' support for "cbcs" encryption scheme.');
promise_test(
() => checkEncryptionScheme('cbcs-1-9'),
testnamePrefix(qualifier, config.keysystem) +
' support for "cbcs-1-9" encryption scheme.');
} }
...@@ -33,15 +33,15 @@ ...@@ -33,15 +33,15 @@
} }
// Verifies that calling navigator.requestMediaKeySystemAccess() // Verifies that calling navigator.requestMediaKeySystemAccess()
// with |configuration| throws a TypeError. // with |configuration| fails (due to no encryptionScheme being
function expectTypeError(configuration, testName) { // supported).
function expectFailure(configuration, testName) {
promise_test(async test => { promise_test(async test => {
try { try {
await navigator.requestMediaKeySystemAccess('org.w3.clearkey', configuration); await navigator.requestMediaKeySystemAccess('org.w3.clearkey', configuration);
assert_unreached('Unexpected requestMediaKeySystemAccess() success.'); assert_unreached('Unexpected requestMediaKeySystemAccess() success.');
} catch(error) { } catch(error) {
// Error must be a TypeError. // Error is what we want to happen.
assert_equals(error.name, 'TypeError', 'unexpected error');
} }
}, testName); }, testName);
} }
...@@ -102,17 +102,27 @@ ...@@ -102,17 +102,27 @@
expectSupport([buildConfiguration({audio: 'cbcs'}, {video: 'cbcs'})], expectSupport([buildConfiguration({audio: 'cbcs'}, {video: 'cbcs'})],
'cbcs', 'cbcs', 'Audio and Video supports cbcs'); 'cbcs', 'cbcs', 'Audio and Video supports cbcs');
// Test "cbcs-1-9".
expectSupport([buildConfiguration({audio: 'cbcs-1-9'})],
'cbcs-1-9', undefined, 'Audio supports cbcs-1-9');
expectSupport([buildConfiguration({video: 'cbcs-1-9'})],
undefined, 'cbcs-1-9', 'Video supports cbcs-1-9');
expectSupport([buildConfiguration({audio: 'cbcs-1-9'}, {video: 'cbcs-1-9'})],
'cbcs-1-9', 'cbcs-1-9', 'Audio and Video supports cbcs-1-9');
// Test "invalid", which should fail. // Test "invalid", which should fail.
expectTypeError([buildConfiguration({audio: 'invalid'})], expectFailure([buildConfiguration({audio: 'invalid'})],
'Audio fails with invalid scheme'); 'Audio fails with invalid scheme');
expectTypeError([buildConfiguration({video: 'invalid'})], expectFailure([buildConfiguration({video: 'invalid'})],
'Video fails with invalid scheme'); 'Video fails with invalid scheme');
expectTypeError([buildConfiguration({audio: 'invalid'}, {video: 'invalid'})], expectFailure([buildConfiguration({audio: 'invalid'}, {video: 'invalid'})],
'Audio and Video fails with invalid scheme'); 'Audio and Video fails with invalid scheme');
expectTypeError([buildConfiguration({audio: 'cenc'}, {video: 'invalid'})], expectFailure([buildConfiguration({audio: 'cenc'}, {video: 'invalid'})],
'Audio valid, Video invalid scheme'); 'Audio valid, Video invalid scheme');
expectTypeError([buildConfiguration({audio: 'invalid'}, {video: 'cbcs'})], expectFailure([buildConfiguration({audio: 'invalid'}, {video: 'cbcs'})],
'Audio invalid scheme, Video valid'); 'Audio invalid scheme, Video valid with cbcs');
expectFailure([buildConfiguration({audio: 'invalid'}, {video: 'cbcs-1-9'})],
'Audio invalid scheme, Video valid with cbcs-1-9');
// Test without encryptionScheme. // Test without encryptionScheme.
expectSupport([buildConfiguration({audio: null})], expectSupport([buildConfiguration({audio: null})],
...@@ -127,22 +137,30 @@ ...@@ -127,22 +137,30 @@
null, 'cbcs', 'Audio missing and Video valid'); null, 'cbcs', 'Audio missing and Video valid');
// Test with "", which is invalid. // Test with "", which is invalid.
expectTypeError([buildConfiguration({audio: ''})], expectFailure([buildConfiguration({audio: ''})],
'Audio handles empty encryptionScheme'); 'Audio handles empty encryptionScheme');
expectTypeError([buildConfiguration({video: ''})], expectFailure([buildConfiguration({video: ''})],
'Video handles empty encryptionScheme'); 'Video handles empty encryptionScheme');
expectTypeError([buildConfiguration({audio: ''}, {video: ''})], expectFailure([buildConfiguration({audio: ''}, {video: ''})],
'Audio and Video handles empty encryptionScheme'); 'Audio and Video handles empty encryptionScheme');
expectTypeError([buildConfiguration({audio: 'cbcs'}, {video: ''})], expectFailure([buildConfiguration({audio: 'cbcs'}, {video: ''})],
'Audio valid and Video empty'); 'Audio valid and Video empty');
expectTypeError([buildConfiguration({audio: ''}, {video: 'cbcs'})], expectFailure([buildConfiguration({audio: ''}, {video: 'cbcs'})],
'Audio empty and Video valid'); 'Audio empty and Video valid');
// Test mixed combinations. // Test mixed combinations.
expectSupport([buildConfiguration({audio: 'cbcs'}, {video: 'cenc'})],
'cbcs', 'cenc', 'Audio supports cbcs and Video supports cenc');
expectSupport([buildConfiguration({audio: 'cenc'}, {video: 'cbcs'})], expectSupport([buildConfiguration({audio: 'cenc'}, {video: 'cbcs'})],
'cenc', 'cbcs', 'Audio supports cenc and Video supports cbcs'); 'cenc', 'cbcs', 'Audio supports cenc and Video supports cbcs');
expectSupport([buildConfiguration({audio: 'cenc'}, {video: 'cbcs-1-9'})],
'cenc', 'cbcs-1-9', 'Audio supports cenc and Video supports cbcs-1-9');
expectSupport([buildConfiguration({audio: 'cbcs'}, {video: 'cenc'})],
'cbcs', 'cenc', 'Audio supports cbcs and Video supports cenc');
expectSupport([buildConfiguration({audio: 'cbcs'}, {video: 'cbcs-1-9'})],
'cbcs', 'cbcs-1-9', 'Audio supports cbcs and Video supports cbcs-1-9');
expectSupport([buildConfiguration({audio: 'cbcs-1-9'}, {video: 'cenc'})],
'cbcs-1-9', 'cenc', 'Audio supports cbcs-1-9 and Video supports cenc');
expectSupport([buildConfiguration({audio: 'cbcs-1-9'}, {video: 'cbcs'})],
'cbcs-1-9', 'cbcs', 'Audio supports cbcs-1-9 and Video supports cbcs');
// Test multiple configurations. // Test multiple configurations.
expectSupport([buildConfiguration({audio: 'cenc'}), expectSupport([buildConfiguration({audio: 'cenc'}),
...@@ -167,11 +185,11 @@ ...@@ -167,11 +185,11 @@
undefined, 'cbcs', 'Mixed entries supports cbcs'); undefined, 'cbcs', 'Mixed entries supports cbcs');
// Test invalid values. // Test invalid values.
expectTypeError([buildConfiguration({audio: 3})], expectFailure([buildConfiguration({audio: 3})],
'Audio fails with numeric scheme'); 'Audio fails with numeric scheme');
expectTypeError([buildConfiguration({audio: [1, 2, 3]})], expectFailure([buildConfiguration({audio: [1, 2, 3]})],
'Audio fails with array scheme'); 'Audio fails with array scheme');
expectTypeError([buildConfiguration({audio: {test: 'test'}})], expectFailure([buildConfiguration({audio: {test: 'test'}})],
'Audio fails with object scheme'); 'Audio fails with object scheme');
</script> </script>
</body> </body>
......
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