Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Unified Diff: third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-utils.js

Issue 2084053002: EME: Update tests so 'audioCapabilities' always provided (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changes (+rebase) Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-utils.js
diff --git a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-utils.js b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-utils.js
index b1e6c9207f295fb506d400ff9161e0960c9b470a..d270037922c1296df69ede2cb60bdf88c7b5a0fa 100644
--- a/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-utils.js
+++ b/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-utils.js
@@ -17,23 +17,8 @@ function consoleWrite(text)
function isInitDataTypeSupported(initDataType)
{
return navigator.requestMediaKeySystemAccess(
- "org.w3.clearkey", [{ initDataTypes : [initDataType] }])
- .then(function() { return(true); }, function() { return(false); });
-}
-
-// Returns a promise that is fulfilled with an initDataType that is supported,
-// rejected if none are supported.
-function getSupportedInitDataType()
-{
- var configuration = [{ initDataTypes : [ 'webm', 'cenc', 'keyids' ] }];
- return navigator.requestMediaKeySystemAccess('org.w3.clearkey', configuration)
- .then(function(access) {
- var initDataTypes = access.getConfiguration().initDataTypes;
- assert_greater_than(initDataTypes.length, 0);
- return Promise.resolve(initDataTypes[0]);
- }, function(error) {
- return Promise.reject('No supported initDataType.');
- });
+ "org.w3.clearkey", getSimpleConfigurationForInitDataType(initDataType))
+ .then(function() { return true; }, function() { return false; });
}
function getInitData(initDataType)
@@ -71,6 +56,54 @@ function getInitData(initDataType)
throw 'initDataType ' + initDataType + ' not supported.';
}
+// Returns an array of audioCapabilities that includes entries for a set of
+// codecs that should cover all user agents.
+function getPossibleAudioCapabilities()
+{
+ return [
+ { contentType: 'audio/mp4; codecs="mp4a.40.2"' },
+ { contentType: 'audio/webm; codecs="opus"' },
+ ];
+}
+
+// Returns a trivial MediaKeySystemConfiguration that should be accepted,
+// possibly as a subset of the specified capabilities, by all user agents.
+function getSimpleConfiguration()
+{
+ return [ {
+ initDataTypes : [ 'webm', 'cenc', 'keyids' ],
+ audioCapabilities: getPossibleAudioCapabilities()
+ } ];
+}
+
+// Returns a MediaKeySystemConfiguration for |initDataType| that should be
+// accepted, possibly as a subset of the specified capabilities, by all
+// user agents.
+function getSimpleConfigurationForInitDataType(initDataType)
+{
+ return [ {
+ initDataTypes: [ initDataType ],
+ audioCapabilities: getPossibleAudioCapabilities()
+ } ];
+}
+
+// Returns a MediaKeySystemConfiguration for |mediaFile| that specifies
+// both audio and video capabilities for the specified file..
+function getConfigurationForFile(mediaFile)
+{
+ if (mediaFile.toLowerCase().endsWith('webm')) {
ddorwin 2016/07/20 19:34:20 It would be slightly better if this was .webm.
+ return [ {
+ initDataTypes: [ 'webm' ],
+ audioCapabilities: [ { contentType: 'audio/webm; codecs="opus"' } ],
+ videoCapabilities: [ { contentType: 'video/webm; codecs="vp8"' } ]
+ } ];
+ }
+
+ // NOTE: Supporting other mediaFormats is not currently implemented as
+ // Chromium only tests with WebM files.
+ throw 'mediaFile ' + mediaFile + ' not supported.';
+}
+
function waitForEventAndRunStep(eventName, element, func, stepTest)
{
var eventCallback = function(event) {
@@ -268,7 +301,7 @@ function createMediaKeys(keyId, key)
var request = stringToUint8Array(createKeyIDs(keyId));
var jwkSet = stringToUint8Array(createJWKSet(createJWK(keyId, key)));
- return navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).then(function(access) {
+ return navigator.requestMediaKeySystemAccess('org.w3.clearkey', getSimpleConfigurationForInitDataType('keyids')).then(function(access) {
return access.createMediaKeys();
}).then(function(result) {
mediaKeys = result;

Powered by Google App Engine
This is Rietveld 408576698