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

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: auto detection of initDataType Created 4 years, 6 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..05bf9201323a8c714260108a83b9303a113a6cc6 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,25 +17,10 @@ function consoleWrite(text)
function isInitDataTypeSupported(initDataType)
{
return navigator.requestMediaKeySystemAccess(
- "org.w3.clearkey", [{ initDataTypes : [initDataType] }])
+ "org.w3.clearkey", simpleConfigurationForInitDataType(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.');
- });
-}
-
function getInitData(initDataType)
{
if (initDataType == 'webm') {
@@ -71,6 +56,53 @@ 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 includes entries
ddorwin 2016/07/20 17:05:28 Trying to make this a bit clearer. Maybe: ... that
jrummell 2016/07/20 19:07:49 Done.
+// that all user agents support some part of.
+function simpleConfiguration()
ddorwin 2016/07/20 17:05:28 These three methods are not named as actions like
jrummell 2016/07/20 19:07:49 Done.
+{
+ return [ {
+ initDataTypes : [ 'webm', 'cenc', 'keyids' ],
+ audioCapabilities: getPossibleAudioCapabilities()
+ } ];
+}
+
+// Returns a MediaKeySystemConfiguration for |initDataType|. This includes
+// entries that should cover all user agents that support |initDataType|.
ddorwin 2016/07/20 17:05:27 Similar text change.
jrummell 2016/07/20 19:07:48 Done.
+function simpleConfigurationForInitDataType(initDataType)
+{
+ return [ {
+ initDataTypes: [ initDataType ],
+ audioCapabilities: getPossibleAudioCapabilities()
+ } ];
+}
+
+// Returns a MediaKeySystemConfiguration for |mediaFormat| that specifies
+// both audio and video capabilities.
ddorwin 2016/07/20 17:05:27 When the change below is made, add "... for the sp
jrummell 2016/07/20 19:07:48 Done.
+function avConfiguration(mediaFormat)
ddorwin 2016/07/20 17:05:27 Longer-term (for spec tests), it might make sense
jrummell 2016/07/20 19:07:49 Done.
+{
+ if (mediaFormat == 'webm') {
+ return [ {
+ initDataTypes: [ 'webm' ],
+ audioCapabilities: [ { contentType: 'audio/webm; codecs="opus"' } ],
+ videoCapabilities: [ { contentType: 'video/webm; codecs="vp8"' } ]
+ } ];
+ }
+
+ // NOTE: Supporting other mediaFormats not currently implemented as
ddorwin 2016/07/20 17:05:27 nit: *is* not...
jrummell 2016/07/20 19:07:48 Done.
+ // Chromium only tests with WebM files.
+ throw 'mediaFormat ' + mediaFormat + ' not supported.';
+}
+
function waitForEventAndRunStep(eventName, element, func, stepTest)
{
var eventCallback = function(event) {
@@ -268,7 +300,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', simpleConfigurationForInitDataType('keyids')).then(function(access) {
return access.createMediaKeys();
}).then(function(result) {
mediaKeys = result;

Powered by Google App Engine
This is Rietveld 408576698