[EME] Bug 19809 - Specify which portion of addKey() algorithm to run when updating license for a key
authorDavid Dorwin <ddorwin@google.com>
Tue, 05 Nov 2013 15:42:26 -0800
changeset 194 6b1b0aa1415c
parent 193 cf1786f8f616
child 195 ba003c9eee1a
[EME] Bug 19809 - Specify which portion of addKey() algorithm to run when updating license for a key

Updated the update() algorithm:
* Remove |did store key|.
* Remove the key storage algorithm.
* Add non-normative text about what happens when the parameter contains keys and/or related data.
* Note that overlapping key IDs in different sessions should be treated independently.
* Always attempt to resume playback when waiting for a key unless an error occurred.
encrypted-media/encrypted-media.html
encrypted-media/encrypted-media.xml
--- a/encrypted-media/encrypted-media.html	Tue Nov 05 13:48:39 2013 -0800
+++ b/encrypted-media/encrypted-media.html	Tue Nov 05 15:42:26 2013 -0800
@@ -483,38 +483,22 @@
         <p>The user agent will asynchronously execute the following steps in the task:</p>
         <ol>
           <li><p>Let <var title="true">cdm</var> be the <var title="true">cdm</var> loaded in the <a href="#dom-media-keys-constructor"><code>MediaKeys</code> constructor</a>.</p></li>
-          <li><p>Let <var title="true">did store key</var> be false.</p></li>
           <li><p>Let <var title="true">request</var> be null.</p></li>
           <li>
 <p>Use <var title="true">cdm</var> to execute the following steps:</p>
             <ol>
               <li>
 <p>Process <var title="true">response</var>.</p>
-              <p class="non-normative">Note: For some <a href="#key-system">Key Systems</a>, <var title="true">response</var> may be a license or other structure containing multiple keys.</p>
-              </li>
-              <li>
-<p>For each <var title="true">individual key</var> in <var title="true">response</var>, store the <var title="true">individual key</var>.</p>
-                <ol>
-                  <li><p>Let <var title="true">key ID</var> be the key ID associated with the <var title="true">individual key</var>.</p></li>
-                  <li>
-<p>Run the following to store the <var title="true">individual key</var>:</p>  
-                    <ol>
-                      <li><p>If a stored key already exists for <var title="true">key ID</var>, delete that key.</p></li>
-                      <li><p>Store the <var title="true">individual key</var>, license, and/or license information indexed by <var title="true">key ID</var>. <span class="non-normative">The replacement algorithm is <a href="#key-system">Key System</a>-dependent.</span></p></li>
-                    </ol>
-                    <p class="non-normative">Note: It is recommended that CDMs support a standard and reasonably high minimum number of cached keys/licenses (with IDs) per <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object as well as a standard replacement algorithm.
-                    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>Let <var title="true">did store key</var> be true.</p></li>
-                </ol>
-              </li>
+                <p class="non-normative">Note: When <var title="true">response</var> contains key(s) and/or related data, <var title="true">cdm</var> will likely store the key and related data indexed by key ID.</p>
+                <p class="non-normative">Note: The replacement algorithm within a session is <a href="#key-system">Key System</a>-dependent.</p>
+                <p class="non-normative">Note: Keys from different sessions should be stored independently such that closing one session does not affect keys in other sessions, even if they have overlapping key IDs.</p>
+                <p class="non-normative">Note: It is recommended that CDMs support a standard and reasonably high minimum number of keys per <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object, including a standard replacement algorithm, and a standard and reasonably high minimum number of <code><a href="#dom-mediakeysession">MediaKeySession</a></code> objects.
+                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 another message needs to be sent to the server, let <var title="true">request</var> be that message.</p></li>
             </ol>
           </li>
-          <li>If <var title="true">did store key</var> is true and the <a href="#media-element">media element</a> is <a href="#waiting-for-a-key">waiting for a key</a>, <a href="http://www.w3.org/TR/html5/webappapis.html#queue-a-task">queue a task</a> to attempt to resume playback.
-            <p class="non-normative">In other words, resume playback if the necessary key is provided.</p>
-          </li>
           <li>
 <p>If any of the preceding steps in the task failed, run the following steps:</p>
               <ol>
@@ -531,6 +515,9 @@
                 <li><p>Abort the task.</p></li>
               </ol>
           </li>
+          <li>If the associated <a href="#media-element">media element(s)</a> are <a href="#waiting-for-a-key">waiting for a key</a>, <a href="http://www.w3.org/TR/html5/webappapis.html#queue-a-task">queue a task</a> to attempt to resume playback.
+            <p class="non-normative">In other words, resume playback if the necessary key is provided.</p>
+          </li>
           <li>
 <p>Follow the steps for the first matching condition from the following list:</p>
             <dl class="switch">
--- a/encrypted-media/encrypted-media.xml	Tue Nov 05 13:48:39 2013 -0800
+++ b/encrypted-media/encrypted-media.xml	Tue Nov 05 15:42:26 2013 -0800
@@ -469,34 +469,20 @@
         <p>The user agent will asynchronously execute the following steps in the task:</p>
         <ol>
           <li><p>Let <var title="true">cdm</var> be the <var title="true">cdm</var> loaded in the <a href="#dom-media-keys-constructor"><code>MediaKeys</code> constructor</a>.</p></li>
-          <li><p>Let <var title="true">did store key</var> be false.</p></li>
           <li><p>Let <var title="true">request</var> be null.</p></li>
           <li><p>Use <var title="true">cdm</var> to execute the following steps:</p>
             <ol>
               <li><p>Process <var title="true">response</var>.</p>
-              <p class="non-normative">Note: For some <a href="#key-system">Key Systems</a>, <var title="true">response</var> may be a license or other structure containing multiple keys.</p>
-              </li>
-              <li><p>For each <var title="true">individual key</var> in <var title="true">response</var>, store the <var title="true">individual key</var>.</p>
-                <ol>
-                  <li><p>Let <var title="true">key ID</var> be the key ID associated with the <var title="true">individual key</var>.</p></li>
-                  <li><p>Run the following to store the <var title="true">individual key</var>:</p>  
-                    <ol>
-                      <li><p>If a stored key already exists for <var title="true">key ID</var>, delete that key.</p></li>
-                      <li><p>Store the <var title="true">individual key</var>, license, and/or license information indexed by <var title="true">key ID</var>. <span class="non-normative">The replacement algorithm is <a href="#key-system">Key System</a>-dependent.</span></p></li>
-                    </ol>
-                    <p class="non-normative">Note: It is recommended that CDMs support a standard and reasonably high minimum number of cached keys/licenses (with IDs) per <coderef>MediaKeySession</coderef> object as well as a standard replacement algorithm.
-                    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>Let <var title="true">did store key</var> be true.</p></li>
-                </ol>
-              </li>
+                <p class="non-normative">Note: When <var title="true">response</var> contains key(s) and/or related data, <var title="true">cdm</var> will likely store the key and related data indexed by key ID.</p>
+                <p class="non-normative">Note: The replacement algorithm within a session is <a href="#key-system">Key System</a>-dependent.</p>
+                <p class="non-normative">Note: Keys from different sessions should be stored independently such that closing one session does not affect keys in other sessions, even if they have overlapping key IDs.</p>
+                <p class="non-normative">Note: It is recommended that CDMs support a standard and reasonably high minimum number of keys per <coderef>MediaKeySession</coderef> object, including a standard replacement algorithm, and a standard and reasonably high minimum number of <coderef>MediaKeySession</coderef> objects.
+                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 another message needs to be sent to the server, let <var title="true">request</var> be that message.</p></li>
             </ol>
           </li>
-          <li>If <var title="true">did store key</var> is true and the <a href="#media-element">media element</a> is <a href="#waiting-for-a-key">waiting for a key</a>, <queue-a-task/> to attempt to resume playback.
-            <p class="non-normative">In other words, resume playback if the necessary key is provided.</p>
-          </li>
           <li><p>If any of the preceding steps in the task failed, run the following steps:</p>
               <ol>
                 <li><p>Create a new <coderef>MediaKeyError</coderef> object with the following attributes:</p>
@@ -511,6 +497,9 @@
                 <li><p>Abort the task.</p></li>
               </ol>
           </li>
+          <li>If the associated <a href="#media-element">media element(s)</a> are <a href="#waiting-for-a-key">waiting for a key</a>, <queue-a-task/> to attempt to resume playback.
+            <p class="non-normative">In other words, resume playback if the necessary key is provided.</p>
+          </li>
           <li><p>Follow the steps for the first matching condition from the following list:</p>
             <dl class="switch">
               <dt>If <var title="true">request</var> is not null</dt>