Bug 1207019 - Make EME mochitests specify mime types for video in MediaKeys request videoTypes, ditto for audio. r=gerald,a=lizzard
authorChris Pearce <cpearce@mozilla.com>
Mon, 05 Oct 2015 15:03:58 +1300
changeset 296699 d7438e734352
parent 296698 45f9754edccf
child 296700 0851006030fe
push id5296
push usercpearce@mozilla.com
push date2015-11-12 01:32 +0000
treeherdermozilla-beta@ba6b7797e925 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald, lizzard
bugs1207019
milestone43.0
Bug 1207019 - Make EME mochitests specify mime types for video in MediaKeys request videoTypes, ditto for audio. r=gerald,a=lizzard
dom/media/test/eme.js
dom/media/test/manifest.js
dom/media/test/test_can_play_type_mpeg.html
dom/media/test/test_eme_non_mse_fails.html
dom/media/test/test_eme_requestKeySystemAccess.html
--- a/dom/media/test/eme.js
+++ b/dom/media/test/eme.js
@@ -341,16 +341,21 @@ function SetupEME(test, token, params)
       Log(token, "session[" + session.sessionId + "].generateRequest(" + ev.initDataType + ", " + StringToHex(ArrayBufferToString(ev.initData)) + ") succeeded");
       if (params && params.onsessionupdated) {
         params.onsessionupdated(aSession);
       }
       processInitDataQueue();
     });
   }
 
+  function streamType(type) {
+    var x = test.tracks.find(o => o.name == type);
+    return x ? x.type : undefined;
+  }
+
   // All 'initDataType's should be the same.
   // null indicates no 'encrypted' event received yet.
   var initDataType = null;
   v.addEventListener("encrypted", function(ev) {
     if (initDataType === null) {
       Log(token, "got first encrypted(" + ev.initDataType + ", " + StringToHex(ArrayBufferToString(ev.initData)) + "), setup session");
       initDataType = ev.initDataType;
       initDataQueue.push(ev);
@@ -362,18 +367,18 @@ function SetupEME(test, token, params)
           onReject(reason);
           return Promise.reject();
         })
       }
 
       var options = [
          {
            initDataType: ev.initDataType,
-           videoType: test.type,
-           audioType: test.type,
+           videoType: streamType("video"),
+           audioType: streamType("audio"),
          }
        ];
       var p = navigator.requestMediaKeySystemAccess(KEYSYSTEM_TYPE, options);
       var r = bail(token + " Failed to request key system access.");
       chain(p, r)
       .then(function(keySystemAccess) {
         var p = keySystemAccess.createMediaKeys();
         var r = bail(token +  " Failed to create MediaKeys object");
--- a/dom/media/test/manifest.js
+++ b/dom/media/test/manifest.js
@@ -787,17 +787,16 @@ var gEMETests = [
     },
     sessionType:"temporary",
     sessionCount:2,
     crossOrigin:true,
     duration:1.60,
   },
   {
     name:"400x300 audio&video tracks, each with its key",
-    type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
     tracks: [
       {
         name:"audio",
         type:"audio/mp4; codecs=\"mp4a.40.2\"",
         fragments:[ "bipbop_300_215kbps-cenc-audio-key1-init.mp4",
                     "bipbop_300_215kbps-cenc-audio-key1-1.m4s",
                     "bipbop_300_215kbps-cenc-audio-key1-2.m4s",
                     "bipbop_300_215kbps-cenc-audio-key1-3.m4s",
@@ -819,17 +818,16 @@ var gEMETests = [
       "7e571d047e571d047e571d047e571d21" : "7e5744447e5744447e5744447e574421",
     },
     sessionType:"temporary",
     sessionCount:2,
     duration:1.60,
   },
   {
     name:"640x480@624kbps audio&video tracks, each with its key",
-    type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
     tracks: [
       {
         name:"audio",
         type:"audio/mp4; codecs=\"mp4a.40.2\"",
         fragments:[ "bipbop_480_624kbps-cenc-audio-key1-init.mp4",
                     "bipbop_480_624kbps-cenc-audio-key1-1.m4s",
                     "bipbop_480_624kbps-cenc-audio-key1-2.m4s",
                     "bipbop_480_624kbps-cenc-audio-key1-3.m4s",
@@ -851,17 +849,16 @@ var gEMETests = [
       "7e571d047e571d047e571d047e571d21" : "7e5744447e5744447e5744447e574421",
     },
     sessionType:"temporary",
     sessionCount:2,
     duration:1.60,
   },
   {
     name:"640x480@959kbps audio&video tracks, each with its key",
-    type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
     tracks: [
       {
         name:"audio",
         type:"audio/mp4; codecs=\"mp4a.40.2\"",
         fragments:[ "bipbop_480_959kbps-cenc-audio-key1-init.mp4",
                     "bipbop_480_959kbps-cenc-audio-key1-1.m4s",
                     "bipbop_480_959kbps-cenc-audio-key1-2.m4s",
                     "bipbop_480_959kbps-cenc-audio-key1-3.m4s",
@@ -883,17 +880,16 @@ var gEMETests = [
       "7e571d047e571d047e571d047e571d21" : "7e5744447e5744447e5744447e574421",
     },
     sessionType:"temporary",
     sessionCount:2,
     duration:1.60,
   },
   {
     name:"640x480 then 400x300, same key (1st) per track",
-    type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
     tracks: [
       {
         name:"audio",
         type:"audio/mp4; codecs=\"mp4a.40.2\"",
         fragments:[ "bipbop_480_624kbps-cenc-audio-key1-init.mp4",
                     "bipbop_480_624kbps-cenc-audio-key1-1.m4s",
                     "bipbop_480_624kbps-cenc-audio-key1-2.m4s",
                     "bipbop_480_624kbps-cenc-audio-key1-3.m4s",
@@ -916,17 +912,16 @@ var gEMETests = [
       "7e571d047e571d047e571d047e571d21" : "7e5744447e5744447e5744447e574421",
     },
     sessionType:"temporary",
     sessionCount:3,
     duration:1.60,
   },
   {
     name:"640x480 then 400x300, same key (2nd) per track",
-    type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
     tracks: [
       {
         name:"audio",
         type:"audio/mp4; codecs=\"mp4a.40.2\"",
         fragments:[ "bipbop_480_624kbps-cenc-audio-key2-init.mp4",
                     "bipbop_480_624kbps-cenc-audio-key2-1.m4s",
                     "bipbop_480_624kbps-cenc-audio-key2-2.m4s",
                     "bipbop_480_624kbps-cenc-audio-key2-3.m4s",
@@ -949,17 +944,16 @@ var gEMETests = [
       "7e571d047e571d047e571d047e571d22" : "7e5744447e5744447e5744447e574422",
     },
     sessionType:"temporary",
     sessionCount:3,
     duration:1.60,
   },
   {
     name:"640x480 with 1st keys then 400x300 with 2nd keys",
-    type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
     tracks: [
       {
         name:"audio",
         type:"audio/mp4; codecs=\"mp4a.40.2\"",
         fragments:[ "bipbop_480_624kbps-cenc-audio-key1-init.mp4",
                     "bipbop_480_624kbps-cenc-audio-key1-1.m4s",
                     "bipbop_480_624kbps-cenc-audio-key1-2.m4s",
                     "bipbop_480_624kbps-cenc-audio-key1-3.m4s",
@@ -983,17 +977,16 @@ var gEMETests = [
       "7e571d047e571d047e571d047e571d21" : "7e5744447e5744447e5744447e574421",
     },
     sessionType:"temporary",
     sessionCount:3,
     duration:1.60,
   },
   {
     name:"400x300 with 1st keys then 640x480 with 2nd keys",
-    type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
     tracks: [
       {
         name:"audio",
         type:"audio/mp4; codecs=\"mp4a.40.2\"",
         fragments:[ "bipbop_300_215kbps-cenc-audio-key1-init.mp4",
                     "bipbop_300_215kbps-cenc-audio-key1-1.m4s",
                     "bipbop_300_215kbps-cenc-audio-key1-2.m4s",
                     "bipbop_300_215kbps-cenc-audio-key1-3.m4s",
@@ -1017,17 +1010,16 @@ var gEMETests = [
       "7e571d047e571d047e571d047e571d21" : "7e5744447e5744447e5744447e574421",
     },
     sessionType:"temporary",
     sessionCount:3,
     duration:1.60,
   },
   {
     name:"640x480@959kbps with 1st keys then 640x480@624kbps with 2nd keys",
-    type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
     tracks: [
       {
         name:"audio",
         type:"audio/mp4; codecs=\"mp4a.40.2\"",
         fragments:[ "bipbop_480_959kbps-cenc-audio-key1-init.mp4",
                     "bipbop_480_959kbps-cenc-audio-key1-1.m4s",
                     "bipbop_480_959kbps-cenc-audio-key1-2.m4s",
                     "bipbop_480_959kbps-cenc-audio-key1-3.m4s",
@@ -1051,17 +1043,16 @@ var gEMETests = [
       "7e571d047e571d047e571d047e571d21" : "7e5744447e5744447e5744447e574421",
     },
     sessionType:"temporary",
     sessionCount:3,
     duration:1.60,
   },
   {
     name:"640x480@624kbps with 1st keys then 640x480@959kbps with 2nd keys",
-    type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
     tracks: [
       {
         name:"audio",
         type:"audio/mp4; codecs=\"mp4a.40.2\"",
         fragments:[ "bipbop_480_624kbps-cenc-audio-key1-init.mp4",
                     "bipbop_480_624kbps-cenc-audio-key1-1.m4s",
                     "bipbop_480_624kbps-cenc-audio-key1-2.m4s",
                     "bipbop_480_624kbps-cenc-audio-key1-3.m4s",
@@ -1085,17 +1076,16 @@ var gEMETests = [
       "7e571d047e571d047e571d047e571d21" : "7e5744447e5744447e5744447e574421",
     },
     sessionType:"temporary",
     sessionCount:3,
     duration:1.60,
   },
   {
     name:"400x300 with presentation size 533x300",
-    type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
     tracks: [
       {
         name:"audio",
         type:"audio/mp4; codecs=\"mp4a.40.2\"",
         fragments:[ "bipbop_300wp_227kbps-cenc-audio-key1-init.mp4",
                     "bipbop_300wp_227kbps-cenc-audio-key1-1.m4s",
                     "bipbop_300wp_227kbps-cenc-audio-key1-2.m4s",
                     "bipbop_300wp_227kbps-cenc-audio-key1-3.m4s",
@@ -1117,17 +1107,16 @@ var gEMETests = [
       "7e571d047e571d047e571d047e571d21" : "7e5744447e5744447e5744447e574421",
     },
     sessionType:"temporary",
     sessionCount:2,
     duration:1.60,
   },
   {
     name:"400x300 as-is then 400x300 presented as 533x300",
-    type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
     tracks: [
       {
         name:"audio",
         type:"audio/mp4; codecs=\"mp4a.40.2\"",
         fragments:[
                     "bipbop_300_215kbps-cenc-audio-key1-init.mp4",
                     "bipbop_300_215kbps-cenc-audio-key1-1.m4s",
                     "bipbop_300_215kbps-cenc-audio-key1-2.m4s",
@@ -1151,17 +1140,16 @@ var gEMETests = [
       "7e571d047e571d047e571d047e571d21" : "7e5744447e5744447e5744447e574421",
     },
     sessionType:"temporary",
     sessionCount:3,
     duration:1.60,
   },
   {
     name:"400x225",
-    type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
     tracks: [
       {
         name:"audio",
         type:"audio/mp4; codecs=\"mp4a.40.2\"",
         fragments:[ "bipbop_225w_175kbps-cenc-audio-key1-init.mp4",
                     "bipbop_225w_175kbps-cenc-audio-key1-1.m4s",
                     "bipbop_225w_175kbps-cenc-audio-key1-2.m4s",
                     "bipbop_225w_175kbps-cenc-audio-key1-3.m4s",
@@ -1182,17 +1170,16 @@ var gEMETests = [
       "7e571d047e571d047e571d047e571d21" : "7e5744447e5744447e5744447e574421",
     },
     sessionType:"temporary",
     sessionCount:2,
     duration:1.60,
   },
   {
     name:"640x360",
-    type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
     tracks: [
       {
         name:"audio",
         type:"audio/mp4; codecs=\"mp4a.40.2\"",
         fragments:[ "bipbop_360w_253kbps-cenc-audio-key1-init.mp4",
                     "bipbop_360w_253kbps-cenc-audio-key1-1.m4s",
                     "bipbop_360w_253kbps-cenc-audio-key1-2.m4s",
                     "bipbop_360w_253kbps-cenc-audio-key1-3.m4s",
@@ -1213,17 +1200,16 @@ var gEMETests = [
       "7e571d047e571d047e571d047e571d21" : "7e5744447e5744447e5744447e574421",
     },
     sessionType:"temporary",
     sessionCount:2,
     duration:1.60,
   },
   {
     name:"400x225 then 640x360",
-    type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
     tracks: [
       {
         name:"audio",
         type:"audio/mp4; codecs=\"mp4a.40.2\"",
         fragments:[ "bipbop_225w_175kbps-cenc-audio-key1-init.mp4",
                     "bipbop_225w_175kbps-cenc-audio-key1-1.m4s",
                     "bipbop_225w_175kbps-cenc-audio-key1-2.m4s",
                     "bipbop_225w_175kbps-cenc-audio-key1-3.m4s",
@@ -1247,17 +1233,16 @@ var gEMETests = [
       "7e571d037e571d037e571d037e571d12" : "7e5733337e5733337e5733337e573312",
     },
     sessionType:"temporary",
     sessionCount:3,
     duration:1.60,
   },
   {
     name:"640x360 then 640x480",
-    type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
     tracks: [
       {
         name:"audio",
         type:"audio/mp4; codecs=\"mp4a.40.2\"",
         fragments:[ "bipbop_360w_253kbps-cenc-audio-key1-init.mp4",
                     "bipbop_360w_253kbps-cenc-audio-key1-1.m4s",
                     "bipbop_360w_253kbps-cenc-audio-key1-2.m4s",
                     "bipbop_360w_253kbps-cenc-audio-key1-3.m4s",
@@ -1284,17 +1269,18 @@ var gEMETests = [
     sessionCount:3,
     duration:1.60,
   },
 ];
 
 var gEMENonMSEFailTests = [
   {
     name:"short-cenc.mp4",
-    type:"video/mp4; codecs=\"avc1.64000d,mp4a.40.2\"",
+    audioType:"audio/mp4; codecs=\"mp4a.40.2\"",
+    videoType:"video/mp4; codecs=\"avc1.64000d\"",
     duration:0.47,
   },
 ];
 
 function checkMetadata(msg, e, test) {
   if (test.width) {
     is(e.videoWidth, test.width, msg + " video width");
   }
--- a/dom/media/test/test_can_play_type_mpeg.html
+++ b/dom/media/test/test_can_play_type_mpeg.html
@@ -64,16 +64,18 @@ function check_mp4(v, enabled) {
   check("video/mp4; codecs=\"avc1.64001F\"", "probably");
 
   // AAC-LC
   check("audio/mp4; codecs=\"mp4a.40.2\"", "probably");
   check("audio/mp4; codecs=mp4a.40.2", "probably");
   check("audio/x-m4a; codecs=\"mp4a.40.2\"", "probably");
   check("audio/x-m4a; codecs=mp4a.40.2", "probably");
 
+  check("audio/mp4; codecs=\"mp4a.40.2,\"", ""); // Invalid codecs string
+
   // HE-AAC v1
   check("audio/mp4; codecs=\"mp4a.40.5\"", "probably");
   check("audio/mp4; codecs=mp4a.40.5", "probably");
   check("audio/x-m4a; codecs=\"mp4a.40.5\"", "probably");
   check("audio/x-m4a; codecs=mp4a.40.5", "probably");
 
 }
 
--- a/dom/media/test/test_eme_non_mse_fails.html
+++ b/dom/media/test/test_eme_non_mse_fails.html
@@ -7,21 +7,22 @@
   <script type="text/javascript" src="manifest.js"></script>
   <script type="text/javascript" src="eme.js"></script>
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 var manager = new MediaTestManager;
 
-function DoSetMediaKeys(v)
+function DoSetMediaKeys(v, test)
 {
   var options = [{
     initDataType: "cenc",
-    videoType: test.type,
+    audioType: test.audioType,
+    videoType: test.videoType,
   }];
 
   return navigator.requestMediaKeySystemAccess("org.w3.clearkey", options)
 
   .then(function(keySystemAccess) {
     return keySystemAccess.createMediaKeys();
   })
 
@@ -63,17 +64,17 @@ function TestSetSrc(test, token)
   manager.started(token);
 
   var v = document.createElement("video");
   v.addEventListener("error", function(err) {
     ok(true, token + " got error setting src on video element, as expected");
     manager.finished(token);
   });
 
-  DoSetMediaKeys(v)
+  DoSetMediaKeys(v, test)
 
   .then(function() {
     v.src = test.name;
   })
 
   .catch(function() {
     ok(false, token + " got error setting media keys");
   });
--- a/dom/media/test/test_eme_requestKeySystemAccess.html
+++ b/dom/media/test/test_eme_requestKeySystemAccess.html
@@ -197,58 +197,69 @@ var tests = [
       {
         initDataType: 'cenc',
         audioType: 'audio/mp4; codecs="mp3"',
       }
     ],
     shouldPass: false,
   },
   {
-    name: 'MP4 video container with mp3 and h264 is unsupported',
+    name: 'MP4 video container type with an audio codec is unsupported',
     keySystem: CLEARKEY_ID,
     options: [
       {
         initDataType: 'cenc',
-        videoType: 'video/mp4; codecs="avc1.42E01E,mp3"',
+        videoType: 'video/mp4; codecs="mp3"',
+      }
+    ],
+    shouldPass: false,
+  },
+  {
+    name: 'MP4 audio container type with a video codec is unsupported',
+    keySystem: CLEARKEY_ID,
+    options: [
+      {
+        initDataType: 'cenc',
+        audioType: 'audio/mp4; codecs="avc1.42E01E"',
       }
     ],
     shouldPass: false,
   },
   {
     name: 'MP4 video container with constrained baseline h.264',
     keySystem: CLEARKEY_ID,
     options: [
       {
         initDataType: 'cenc',
-        audioType: 'video/mp4; codecs="avc1.42E01E"',
+        videoType: 'video/mp4; codecs="avc1.42E01E"',
       }
     ],
     shouldPass: true,
   },
   {
     name: 'MP4 video container with invalid codecs',
     keySystem: CLEARKEY_ID,
     options: [
       {
         initDataType: 'cenc',
         videoType: 'video/mp4; codecs="bogus"',
       }
     ],
     shouldPass: false,
   },
   {
-    name: 'MP4 video container with constrained baseline h.264 and AAC-LC',
+    name: 'MP4 video container with both audio and video codec type in videoType',
     keySystem: CLEARKEY_ID,
     options: [
       {
         initDataType: 'cenc',
         videoType: 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',
       }
     ],
-    shouldPass: true,
+    shouldPass: false,
   },
   {
     name: 'MP4 audio and video type both specified',
     keySystem: CLEARKEY_ID,
     options: [
       {
         initDataType: 'cenc',
         videoType: 'video/mp4; codecs="avc1.42E01E"',