[EME] Bug 25594 - tweaks to the previous fix.
authorDavid Dorwin <ddorwin@google.com>
Tue, 01 Jul 2014 18:37:50 -0700
changeset 360 c4a18d018444
parent 359 20e4e3ec0e88
child 361 75051d4bb6a7
[EME] Bug 25594 - tweaks to the previous fix.

Minor fixes to the text of changeset c02fbe3a2c13 and improved the example to use the promise.
encrypted-media/encrypted-media.html
encrypted-media/encrypted-media.xml
--- a/encrypted-media/encrypted-media.html	Tue Jul 01 11:44:11 2014 -0700
+++ b/encrypted-media/encrypted-media.html	Tue Jul 01 18:37:50 2014 -0700
@@ -202,10 +202,10 @@
           <li><a href="#algorithms-encrypted-block">4.2. Encrypted Block Encountered</a></li>
           <li><a href="#algorithms-queue-message">4.3. Queue a "message" Event</a></li>
           <li><a href="#algorithms-queue-error">4.4. Queue an "error" Event</a></li>
-          <li><a href="#algorithms-keys-changed">4.5. Keys changed</a></li>
-          <li><a href="#algorithms-update-expiration">4.6 Update Expiration</a></li>
+          <li><a href="#algorithms-keys-changed">4.5. Usable Keys Changed</a></li>
+          <li><a href="#algorithms-update-expiration">4.6. Update Expiration</a></li>
           <li><a href="#algorithms-session-close">4.7. Session Close</a></li>
-          <li><a href="#algorithms-queue-waiting">4.8 Queue a "waiting" Event</a></li>
+          <li><a href="#algorithms-queue-waiting">4.8. Queue a "waiting" Event</a></li>
           <li><a href="#algorithms-resume-playback">4.9. Attempt to Resume Playback If Necessary</a></li>
         </ul></li>
       <li><a href="#simple-decryption">5. Simple Decryption</a></li>
@@ -330,7 +330,7 @@
     </p>
 
     <h2 id="extensions">2. Media Element Extensions</h2>
-    <p>We extend <dfn id="media-element" title="media element"><a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-element">media element</a></dfn> to allow decryption key acquisition to be handled in JavaScript.</p>
+    <p>We extend <dfn id="media-element" title="media element"><a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-element">media element</a></dfn> to allow decryption key acquisition to be handled by the application.</p>
 
     <pre class="idl">
 enum <dfn id="dom-mediawaitingfor">MediaWaitingFor</dfn> { "<dfn id="dom-waitingfornone">none</dfn>", "<dfn id="dom-waitingfordata">data</dfn>", "<dfn id="dom-waitingforkey">key</dfn>" };
@@ -371,7 +371,7 @@
   Promise&lt;any&gt; <a href="#dom-close">close</a>();
   Promise&lt;any&gt; <a href="#dom-remove">remove</a>();
   
-  Promise&lt;sequence&lt;ArrayBuffer&gt;&gt; <a href="#dom-getusablekeyids__">getUsableKeyIds()</a>;
+  Promise&lt;sequence&lt;ArrayBuffer&gt;&gt; <a href="#dom-getusablekeyids">getUsableKeyIds</a>();
 };
 
 <div class="issue">
@@ -750,7 +750,7 @@
                 </p>
               </li> 
               <li>
-<p>If the set of usable keys changed, run the <a href="#algorithms-keys-changed">Keys changed</a> algorithm on the <var title="true">session</var>.</p>
+<p>If the set of usable keys changed, run the <a href="#algorithms-keys-changed">Usable Keys Changed</a> algorithm on the <var title="true">session</var>.</p>
                 <p>The algorithm may also be run later should additional processing be necessary to determine with certainty whether one or more keys is usable.</p>
               </li>
               <li><p>If the expiration time for the session changed, run the <a href="#algorithms-update-expiration">Update Expiration</a> algorithm on the <var title="true">session</var>, providing the new expiration time.</p></li>
@@ -845,14 +845,14 @@
           <li>
 <p>Use the <var title="true">cdm</var> to execute the following steps:</p>
             <ol>
-              <li><p>Let <var title="true">usable key ids</var> be a list of the key IDs for keys in the session that the CDM <em>knows</em> are currently usable usable to decrypt <a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-data">media data</a>. <var title="true">usable key ids</var> must not contain IDs for keys that <em>may not</em> currently be usable. Each element must be unique.</p></li>
+              <li><p>Let <var title="true">usable key ids</var> be a list of the key IDs for keys in the session that the CDM <em>knows</em> are currently usable to decrypt <a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-data">media data</a>. <var title="true">usable key ids</var> must not contain IDs for keys that <em>may not</em> currently be usable. Each element must be unique.</p></li>
             </ol>
           </li>
           <li>
             <p>If the preceding step failed, reject <var>promise</var> with a new <code><a href="http://www.w3.org/TR/dom/#exception-domexception">DOMException</a></code> whose name is the appropriate <a href="#mediakeyerror-names">error name</a> and that has an appropriate message.</p>
           </li>
           <li>
-            <p>Otherwise, resolve <var>promise</var> with a new Javascript Array object each element of which contains one element of <var title="true">usable key ids</var>.</p>
+            <p>Resolve <var>promise</var> with a new Sequence object, each element of which contains one element of <var title="true">usable key ids</var>.</p>
           </li>
         </ol>
       </li>
@@ -1273,8 +1273,8 @@
       <li><p><a href="http://www.w3.org/TR/html5/webappapis.html#queue-a-task">Queue a task</a> to <a href="http://www.w3.org/TR/html5/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-eventerror">error</a></code> at the <var title="true">session</var>.</p></li>
     </ol>
 
-    <h3 id="algorithms-keys-changed">4.5. Keys changed</h3>
-    <p>The Keys changed algorithm is run when the CDM changes the set of keys in the session that may be used for decryption.
+    <h3 id="algorithms-keys-changed">4.5. Usable Keys Changed</h3>
+    <p>The Usable Keys Changed algorithm is run when the CDM changes the set of keys in the session that may be used for decryption.
     This can happen as the result of an <code><a href="#dom-update">update()</a></code> call or some other event.
     Requests to run this algorithm include a target <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object.
     </p>
@@ -1282,7 +1282,10 @@
     <ol>
       <li><p>Let the <var title="true">session</var> be the associated <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object.</p></li>
       <li><p><a href="http://www.w3.org/TR/html5/webappapis.html#queue-a-task">Queue a task</a> to <a href="http://www.w3.org/TR/html5/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-eventkeyschange">keyschange</a></code> at the <var title="true">session</var>.</p></li>
-      <li><p>Run the <a href="#algorithms-resume-playback">Attempt to Resume Playback If Necessary</a> algorithm on each of the associated <a href="#media-element">media element(s)</a>.</p></li>
+      <li>
+<p>Run the <a href="#algorithms-resume-playback">Attempt to Resume Playback If Necessary</a> algorithm on each of the associated <a href="#media-element">media element(s)</a>.</p>
+        <p>The user agent may choose to skip this step if it knows resuming will fail <span class="non-normative">(i.e. no additional keys became available)</span>.</p>
+      </li>
     </ol>
 
     <h3 id="algorithms-update-expiration">4.6. Update Expiration</h3>
@@ -1390,7 +1393,7 @@
           <li><p><var>message</var> is considered invalid if it is not a valid JWK Set with at least one valid JWK key of a valid length for the media type.</p></li>
         </ul>
       </li>
-      <li><p>The <code><a href="#dom-getusablekeyids__">getUsableKeyIds()</a></code> method always returns all key IDs that have been provided via <code><a href="#dom-update">update()</a></code>.</p></li>
+      <li><p>The <code><a href="#dom-getusablekeyids">getUsableKeyIds()</a></code> method always returns all key IDs that have been provided via <code><a href="#dom-update">update()</a></code>.</p></li>
       <li><p><a href="#initialization-data">Initialization Data</a>: Implementations may support any combination of <a href="initdata-format-registry.html">registered and Initialization Data types</a>.
         Implementations should support the "<a href="keyids-format.html%20">keyids</a>" type and other types appropriate for content types supported by the user agent.
       </p></li>
@@ -1840,7 +1843,13 @@
   }
 
   function handleKeysChange(event) {
-    // Call event.target.<a href="#dom-getusablekeyids">getUsableKeyIds</a> and respond appropriately.
+    event.target.<a href="#dom-getusablekeyids">getUsableKeyIds</a>().then(
+      function(keyIdSequence) {
+        // Process keyIdSequence and respond appropriately.
+      }
+    ).catch(
+      console.error.bind(console, "Failed handling usable keys change")
+    );
   }
 
   function handleError(event) {
--- a/encrypted-media/encrypted-media.xml	Tue Jul 01 11:44:11 2014 -0700
+++ b/encrypted-media/encrypted-media.xml	Tue Jul 01 18:37:50 2014 -0700
@@ -199,10 +199,10 @@
           <li><a href="#algorithms-encrypted-block">4.2. Encrypted Block Encountered</a></li>
           <li><a href="#algorithms-queue-message">4.3. Queue a "message" Event</a></li>
           <li><a href="#algorithms-queue-error">4.4. Queue an "error" Event</a></li>
-          <li><a href="#algorithms-keys-changed">4.5. Keys changed</a></li>
-          <li><a href="#algorithms-update-expiration">4.6 Update Expiration</a></li>
+          <li><a href="#algorithms-keys-changed">4.5. Usable Keys Changed</a></li>
+          <li><a href="#algorithms-update-expiration">4.6. Update Expiration</a></li>
           <li><a href="#algorithms-session-close">4.7. Session Close</a></li>
-          <li><a href="#algorithms-queue-waiting">4.8 Queue a "waiting" Event</a></li>
+          <li><a href="#algorithms-queue-waiting">4.8. Queue a "waiting" Event</a></li>
           <li><a href="#algorithms-resume-playback">4.9. Attempt to Resume Playback If Necessary</a></li>
         </ul></li>
       <li><a href="#simple-decryption">5. Simple Decryption</a></li>
@@ -327,7 +327,7 @@
     </p>
 
     <h2 id="extensions">2. Media Element Extensions</h2>
-    <p>We extend <dfn id="media-element" title="media element"><media-element/></dfn> to allow decryption key acquisition to be handled in JavaScript.</p>
+    <p>We extend <dfn id="media-element" title="media element"><media-element/></dfn> to allow decryption key acquisition to be handled by the application.</p>
 
     <pre class="idl">
 enum <precodedfn>MediaWaitingFor</precodedfn> { "<precodedfn prefix="waitingfor">none</precodedfn>", "<precodedfn prefix="waitingfor">data</precodedfn>", "<precodedfn prefix="waitingfor">key</precodedfn>" };
@@ -368,7 +368,7 @@
   Promise&lt;any&gt; <premethodref>close</premethodref>();
   Promise&lt;any&gt; <premethodref>remove</premethodref>();
   
-  Promise&lt;sequence&lt;ArrayBuffer&gt;&gt; <precoderef>getUsableKeyIds()</precoderef>;
+  Promise&lt;sequence&lt;ArrayBuffer&gt;&gt; <premethodref>getUsableKeyIds</premethodref>();
 };
 
 <div class="issue"><div class="issue-title"><span>Issue 1</span></div><p class="">Extensions to <precoderef>HTMLSourceElement</precoderef> may be at risk as discussed in <a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=23827">Bug 23827</a>.</p></div>
@@ -708,7 +708,7 @@
                 This enables a reasonable number of key rotation algorithms to be implemented across user agents and may reduce the likelihood of playback interruptions in use cases that involve various streams in the same element (i.e. adaptive streams, various audio and video tracks) using different keys.
                 </p>
               </li> 
-              <li><p>If the set of usable keys changed, run the <a href="#algorithms-keys-changed">Keys changed</a> algorithm on the <var title="true">session</var>.</p>
+              <li><p>If the set of usable keys changed, run the <a href="#algorithms-keys-changed">Usable Keys Changed</a> algorithm on the <var title="true">session</var>.</p>
                 <p>The algorithm may also be run later should additional processing be necessary to determine with certainty whether one or more keys is usable.</p>
               </li>
               <li><p>If the expiration time for the session changed, run the <a href="#algorithms-update-expiration">Update Expiration</a> algorithm on the <var title="true">session</var>, providing the new expiration time.</p></li>
@@ -795,14 +795,14 @@
           <li><p>Let <var title="true">cdm</var> be the <var title="true">cdm</var> loaded in <methodref>create</methodref>.</p></li>
           <li><p>Use the <var title="true">cdm</var> to execute the following steps:</p>
             <ol>
-              <li><p>Let <var title="true">usable key ids</var> be a list of the key IDs for keys in the session that the CDM <em>knows</em> are currently usable usable to decrypt <videoanchor name="media-data">media data</videoanchor>. <var title="true">usable key ids</var> must not contain IDs for keys that <em>may not</em> currently be usable. Each element must be unique.</p></li>
+              <li><p>Let <var title="true">usable key ids</var> be a list of the key IDs for keys in the session that the CDM <em>knows</em> are currently usable to decrypt <videoanchor name="media-data">media data</videoanchor>. <var title="true">usable key ids</var> must not contain IDs for keys that <em>may not</em> currently be usable. Each element must be unique.</p></li>
             </ol>
           </li>
           <li>
             <p>If the preceding step failed, reject <var>promise</var> with a new <code><dom4ref name="exception-domexception">DOMException</dom4ref></code> whose name is the appropriate <a href="#mediakeyerror-names">error name</a> and that has an appropriate message.</p>
           </li>
           <li>
-            <p>Otherwise, resolve <var>promise</var> with a new Javascript Array object each element of which contains one element of <var title="true">usable key ids</var>.</p>
+            <p>Resolve <var>promise</var> with a new Sequence object, each element of which contains one element of <var title="true">usable key ids</var>.</p>
           </li>
         </ol>
       </li>
@@ -1200,8 +1200,8 @@
       <li><p><Queue-a-task/> to <fire-a-simple-event/> named <coderef prefix="event">error</coderef> at the <var title="true">session</var>.</p></li>
     </ol>
 
-    <h3 id="algorithms-keys-changed">4.5. Keys changed</h3>
-    <p>The Keys changed algorithm is run when the CDM changes the set of keys in the session that may be used for decryption.
+    <h3 id="algorithms-keys-changed">4.5. Usable Keys Changed</h3>
+    <p>The Usable Keys Changed algorithm is run when the CDM changes the set of keys in the session that may be used for decryption.
     This can happen as the result of an <methodref>update</methodref> call or some other event.
     Requests to run this algorithm include a target <coderef>MediaKeySession</coderef> object.
     </p>
@@ -1209,7 +1209,9 @@
     <ol>
       <li><p>Let the <var title="true">session</var> be the associated <coderef>MediaKeySession</coderef> object.</p></li>
       <li><p><Queue-a-task/> to <fire-a-simple-event/> named <coderef prefix="event">keyschange</coderef> at the <var title="true">session</var>.</p></li>
-      <li><p>Run the <a href="#algorithms-resume-playback">Attempt to Resume Playback If Necessary</a> algorithm on each of the associated <a href="#media-element">media element(s)</a>.</p></li>
+      <li><p>Run the <a href="#algorithms-resume-playback">Attempt to Resume Playback If Necessary</a> algorithm on each of the associated <a href="#media-element">media element(s)</a>.</p>
+        <p>The user agent may choose to skip this step if it knows resuming will fail <span class="non-normative">(i.e. no additional keys became available)</span>.</p>
+      </li>
     </ol>
 
     <h3 id="algorithms-update-expiration">4.6. Update Expiration</h3>
@@ -1313,7 +1315,7 @@
           <li><p><var>message</var> is considered invalid if it is not a valid JWK Set with at least one valid JWK key of a valid length for the media type.</p></li>
         </ul>
       </li>
-      <li><p>The <coderef>getUsableKeyIds()</coderef> method always returns all key IDs that have been provided via <methodref>update</methodref>.</p></li>
+      <li><p>The <methodref>getUsableKeyIds</methodref> method always returns all key IDs that have been provided via <methodref>update</methodref>.</p></li>
       <li><p><a href="#initialization-data">Initialization Data</a>: Implementations may support any combination of <a href="initdata-format-registry.html">registered and Initialization Data types</a>.
         Implementations should support the "<a href="keyids-format.html ">keyids</a>" type and other types appropriate for content types supported by the user agent.
       </p></li>
@@ -1760,7 +1762,13 @@
   }
 
   function handleKeysChange(event) {
-    // Call event.target.<precoderef>getUsableKeyIds</precoderef> and respond appropriately.
+    event.target.<precoderef>getUsableKeyIds</precoderef>().then(
+      function(keyIdSequence) {
+        // Process keyIdSequence and respond appropriately.
+      }
+    ).catch(
+      console.error.bind(console, "Failed handling usable keys change")
+    );
   }
 
   function handleError(event) {