Creating draft FPWD. Reverting main document to editor's draft.
authorAdrian Bateman <adrianba@microsoft.com>
Mon, 14 Jan 2013 18:24:13 -0800
changeset 73 265f993d54a7
parent 72 61c22837f159
child 74 0e5e12a7750f
Creating draft FPWD. Reverting main document to editor's draft.
encrypted-media/encrypted-media-fpwd.html
encrypted-media/encrypted-media.html
encrypted-media/encrypted-media.xml
encrypted-media/main.css
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/encrypted-media/encrypted-media-fpwd.html	Mon Jan 14 18:24:13 2013 -0800
@@ -0,0 +1,1490 @@
+<!DOCTYPE html SYSTEM "about:legacy-compat">
+<html>
+  <head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+    <title>Encrypted Media Extensions</title>
+    <link rel="stylesheet" href="video-working-draft.css">
+    <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-WD">
+    <style type="text/css">
+      div.nonnormative { color: green; margin: 2em 0 2em 0em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
+      .nonnormative:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This section is non-normative.'; color: black; font-style: italic; border: solid 2px; background: white; padding: 0 0.25em; }
+
+      
+      .non-normative { font-style: italic; color: DarkSlateGrey; }
+      .non-normative em { font-style: normal;}
+      .non-normative var { font-style: normal;}
+    </style>
+  </head>
+  <body>
+    <div class="head">
+      <p><a href="http://www.w3.org/"><img src="http://www.w3.org/Icons/w3c_home" alt="W3C" width="72" height="48"></a></p>
+      <h1>Encrypted Media Extensions</h1>
+      <h2 id="draft-date">W3C Working Draft 24 January 2013</h2>
+      <dl>
+        <dt>This Version:</dt>
+        <dd><a href="http://www.w3.org/TR/2013/WD-encrypted-media-20130124/">http://www.w3.org/TR/2013/WD-encrypted-media-20130124/</a></dd>
+        <dt>Latest Published Version:</dt>
+        <dd><a href="http://www.w3.org/TR/encrypted-media/">http://www.w3.org/TR/encrypted-media/</a></dd>
+        <dt>Latest editor's draft:</dt>
+        <dd><a href="http://dvcs.w3.org/hg/html-media/raw-file/tip/encrypted-media/encrypted-media.html">http://dvcs.w3.org/hg/html-media/raw-file/tip/encrypted-media/encrypted-media.html</a></dd>
+        <dt>Editors:</dt>
+        <dd>David Dorwin, Google, Inc.</dd>
+        <dd>Adrian Bateman, Microsoft Corporation</dd>
+        <dd>Mark Watson, Netflix, Inc.</dd>
+  <dt>Bug/Issue lists:</dt>
+  <dd>
+<a href="http://w3.org/brief/MjY5">Bugzilla</a>, <a href="http://www.w3.org/html/wg/tracker/products/19">Tracker</a>
+</dd>
+  <dt>Discussion list:</dt>
+  <dd><a href="http://lists.w3.org/Archives/Public/public-html-media/">public-html-media@w3.org</a></dd>
+  <dt>Test Suite:</dt>
+  <dd>None yet</dd>
+      </dl>
+    </div>
+
+    <p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2013 <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.</p>
+    <hr>
+
+    <h2>Abstract</h2>
+
+    <p>This proposal extends HTMLMediaElement providing APIs to control playback of protected content.</p>
+    <p>The API supports use cases ranging from simple clear key decryption to high value video (given an appropriate user agent implementation).
+    License/key exchange is controlled by the application, facilitating the development of robust playback applications supporting a range of content decryption and protection technologies.</p>
+    <p>This specification does not define a content protection or Digital Rights Management system. Rather, it defines a common API that may be used to discover, select and interact with
+    such systems as well as with simpler content encryption systems. Implementation of Digital Rights Management is not required for compliance with this specification: only the simple
+    clear key system is required to be implemented as a common baseline.</p>
+    <p>The common API supports a simple set of content encryption capabilities, leaving application functions such as authentication and authorization to page authors. This is achieved by
+    requiring content protection system-specific messaging to be mediated by the page rather than assuming out-of-band communication between the encryption system and a license
+    or other server.</p>
+ 
+    <h2>Status of This Document</h2>
+
+    <p><em>
+      This section describes the status of this document at the time of its publication. Other documents may supersede this document.
+      A list of current W3C publications and the latest revision of this technical report can be found in the
+      <a href="http://www.w3.org/TR/">W3C technical reports index</a> at http://www.w3.org/TR/.
+    </em></p>
+    <p>Implementors should be aware that this specification is not stable. <strong>Implementors who are not taking part in the discussions are likely to find the specification changing out from under them in incompatible ways.</strong> Vendors interested in implementing this specification before it eventually reaches the Candidate Recommendation stage should join the mailing list mentioned below and take part in the discussions.</p>
+    <p>
+      This document was published by the <a href="http://www.w3.org/html/wg/">HTML working group</a> as an Editor's Draft.
+      Please submit comments regarding this document by using the W3C's (<a href="https://www.w3.org/Bugs/Public/enter_bug.cgi?product=HTML%20WG&amp;component=Encrypted%20Media%20Extensions">public bug database</a>) with the product set to <kbd>HTML WG</kbd> and the component set to
+      <kbd>Encrypted Media Extensions</kbd>.
+      If you cannot access the bug database, submit comments to <a href="mailto:public-html-media@w3.org">public-html-media@w3.org</a>
+      (<a href="mailto:public-html-media-request@w3.org?subject=subscribe">subscribe</a>,
+      <a href="http://lists.w3.org/Archives/Public/public-html-media/">archives</a>) and arrangements will be made to transpose the comments to the bug database.
+      All feedback is welcome.
+    </p>
+    <p>
+      Publication as an Editor's Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated,
+      replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
+    </p>
+    <p>
+      This document was produced by a group operating under the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent Policy</a>.
+      W3C maintains a <a href="http://www.w3.org/2004/01/pp-impl/40318/status" rel="disclosure">public list of any patent disclosures</a> made in connection with
+      the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which
+      the individual believes contains <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a> must disclose the
+      information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the W3C Patent Policy</a>.
+      </p>
+
+
+    <h2 id="toc">Table of Contents</h2>
+
+    <ul style="list-style-type:none">
+      <li><a href="#introduction">1. Introduction</a></li>
+        <li><ul style="list-style-type:none">
+          <li><a href="#goals">1.1 Goals</a></li>
+          <li><a href="#definitions">1.2. Definitions</a></li>
+        </ul></li>
+      <li><a href="#extensions">2. Media Element Extensions</a></li>
+        <li><ul style="list-style-type:none">
+          <li><a href="#error-codes">2.1. Error Codes</a></li>
+        </ul></li>
+      <li><a href="#events">3. Events</a></li>
+        <li><ul style="list-style-type:none">
+          <li><a href="#event-definitions">3.1 Event Definitions</a></li>
+          <li><a href="#event-summary">3.2 Event Summary</a></li>
+        </ul></li>
+      <li><a href="#key-release">4. Key Release</a></li>
+      <li><a href="#algorithms">5. Algorithms</a></li>
+        <li><ul style="list-style-type:none">
+          <li><a href="#algorithms-enrypted-block">5.1. Encrypted Block Encountered</a></li>
+          <li><a href="#algorithms-encrypted-stream">5.2. Potentially Encrypted Stream Encountered</a></li>
+          <li><a href="#algorithms-load">5.3. Addition to Media Element Load Algorithm</a></li>
+        </ul></li>
+      <li><a href="#simple-decryption">6. Simple Decryption</a></li>
+        <li><ul style="list-style-type:none">
+          <li><a href="#simple-decryption-clear-key">6.1. Clear Key</a></li>
+        </ul></li>
+      <li><a href="#containers">7. Container Guidelines</a></li>
+        <li><ul style="list-style-type:none">
+          <li><a href="#webm">7.1. WebM</a></li>
+          <li><a href="#iso">7.2. ISO Base Media File Format</a></li>
+        </ul></li>
+      <li><a href="#examples">8. Examples</a></li>
+      <li><a href="#faq">9. FAQ</a></li>
+        <li><ul style="list-style-type:none">
+          <li><a href="#faq-use-cases">9.1. Use Cases</a></li>
+          <li><a href="#faq-use">9.2. Use</a></li>
+          <li><a href="#faq-api">9.3. API</a></li>
+          <li><a href="#faq-source">9.4. Source, Containers, and Streams</a></li>
+          <li><a href="#faq-protection">9.5. Content and Key Protection</a></li>
+        </ul></li>
+      <li><a href="#revision-history">10. Revision History</a></li>
+    </ul>
+
+
+    <h2 id="introduction">1. Introduction</h2>
+    <p><i>This section is non-normative.</i></p>
+    <p>This proposal allows JavaScript to select content protection mechanisms, control license/key exchange, and implement custom license management algorithms.
+    It supports a wide range of use cases without requiring client-side modifications in each user agent for each use case.
+    This also enables content providers to develop a single application solution for all devices.
+    A generic stack implemented using the proposed APIs is shown below.
+    This is just an example flow and is not intended to show all possible communication or uses.</p>
+    <img src="stack_overview.png" alt="A generic stack implemented using the proposed APIs" height="700">
+
+    <h3 id="goals">1.1 Goals</h3>
+    <p><i>This section is non-normative.</i></p>
+    <p>This proposal was designed with the following goals in mind:</p>
+    <ul>
+      <li>Support simple decryption without the need for DRM servers, etc.</li>
+      <li>Support a wide range of media containers and codecs.</li>
+      <li>Support a range of content security models, including software and hardware-based models</li>
+      <li>Stream reusability - the actual encrypted content stream/file for a given container/codec should be identical regardless of the user agent and content decryption and protection mechanism.</li>
+      <li>Support a wide range of use cases.</li>
+      <li>Flexibility (and control) for applications and content providers without requiring client/user agent updates.</li>
+      <li>Minimize additions to HTMLMediaElement and new capabilities added to the user agent.
+      <ul>
+        <li>Defer all information and algorithms about the content decryption and protection solution to the application/server and client <a href="#cdm">content decryption module</a>. The user agent should just pass information.</li>
+        <li>The user agent should not be responsible for communication with license servers.</li>
+        <li>The user agent should not select among content decryption and protection options. The application should make this decision.</li>
+        <li>Note: Applications are already capable of everything required except secure decryption and decode.</li>
+      </ul>
+</li>
+      <li>Compatible with adaptive streaming.</li>
+      <li>Usability.</li>
+    </ul>
+
+    <h3 id="definitions">1.2. Definitions</h3>
+    <p>Text in <span class="non-normative">this font and color</span> is non-normative.</p>
+
+    <h4 id="cdm">1.2.1. Content Decryption Module (CDM)</h4>
+    <p><i>This section is non-normative.</i></p>
+    <p>The Content Decryption Module (CDM) is a generic term for a part of or add-on to the user agent that provides functionality for one or more <a href="#key-system">Key Systems</a>.
+    Implementations may or may not separate the implementations of CDMs and may or may not treat them as separate from the user agent.
+    This is transparent to the API and application.
+    A user agent may support one or more CDMs.</p>
+
+    <h4 id="key-system">1.2.2. Key System</h4>
+    <p>A Key System is a generic term for a decryption mechanism and/or content protection provider.
+    Key System strings provide unique identification of a Key System.
+    They are used by the user agent to select the <a href="#cdm">Content Decryption Modules</a> and identify the source of a key-related event.
+    <a href="#simple-decryption">Simple Decryption</a> Key Systems are supported by all user agents. User agents may also provide additional CDMs with corresponding Key System strings.
+    </p>
+
+    <p>A Key System string is always a reverse domain name. <span class="non-normative">For example, "com.example.somesystem".</span>
+    Within a given system <span class="non-normative">("somesystem" in the example)</span>, subsystems may be defined as determined by the key system provider.
+    <span class="non-normative">For example, "com.example.somesystem.1" and "com.example.somesystem.1_5".</span>
+    <span class="non-normative">Key System providers should keep in mind that these will be used for comparison and discovery, so they should be easy to compare and the structure should remain reasonably simple.</span>
+    </p>
+
+    <h4 id="session-id">1.2.3. Session ID</h4>
+    <p>A session ID is an optional string ID used to associate calls related to a key/license lifetime, starting with the request.
+    <span class="non-normative">It is a local binding between a request and key/license.
+    It does not associate keys or licenses for different streams (i.e. audio and video).</span>
+    If supported by the <a href="#key-system">Key System</a>, it is generated by the user agent/CDM and provided to the application in the <code><a href="#dom-keymessage">keymessage</a></code> event.
+    <span class="non-normative">(Session IDs need not necessarily be supported by the underlying content protection client or server.)</span>
+    </p>
+
+    <p>If Session IDs are supported, a new one will be generated each time <code><a href="#dom-createsession">createSession()</a></code> successfully creates a <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object.
+    The user agent/CDM manage the lifetime of Session IDs.
+    All Session IDs are cleared from the <a href="#media-element">media element</a> when a load occurs, although the CDM may retain them for longer periods.
+    </p>
+    <p>Each SessionID shall be unique within the browsing context in which it was created. If secure proof of key release is supported each Session ID shall
+    be unique within the origin. Note that this last requirement implies that Session IDs shall be unique over time including across browsing sessions.</p>
+
+    <p class="non-normative">Applications should always provide the session ID from an event in subsequent calls for this key or license.
+    (This is a best practice, even if the current Key System does not support session IDs.)
+    This may mean that the application must associate a server response with the session ID and provide them both to <code><a href="#dom-update">update()</a></code>.
+    </p>
+
+    <h4 id="initialization-data">1.2.4. Initialization Data</h4>
+    <p><i>This section is non-normative.</i></p>
+    <p>Initialization Data is a generic term for container-specific data that is used by <a href="#cdm">Content Decryption Modules</a> to generate a key request.
+    It should always allow unique identification of the key or keys needed to decrypt the content, possibly after being parsed by a CDM or server.
+    </p>
+
+    <p><a href="#key-system">Key Systems</a> usually require a block of initialization data containing information about the stream to be decrypted before they can construct a key request message.
+    This block could be as simple as a key or content ID to send to a server or as complex as an opaque Key System-specific collection of data.
+    This initialization information may be obtained in some application-specific way or may be stored with the <a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-data">media data</a>.
+    Container formats may provide for storage of such information, possibly for multiple <a href="#key-system">Key Systems</a> in a single media file.
+    </p>
+
+    <p>Initialization data found in the <a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-data">media data</a> is provided to the application in the <code><a href="#dom-initdata">initData</a></code> attribute of the <code><a href="#dom-needkey">needkey</a></code> event.
+    This data has a container-specific format and is assumed to contain one or more generic or Key System-specific sets of initialization information.
+    </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 class="non-normative">Note: For some <a href="#cdm">CDMs</a>, "key" and "key request" correspond to "license" and "license request", respectively.</p>
+
+    <pre class="idl">
+partial interface <dfn id="dom-htmlmediaelement">HTMLMediaElement</dfn> {
+  // Encrypted Media
+  readonly attribute <a href="#dom-mediakeys">MediaKeys</a> <a href="#dom-keys">keys</a>;
+  void <a href="#dom-setmediakeys">setMediaKeys</a>(<a href="#dom-mediakeys">MediaKeys</a> mediaKeys);
+  
+  attribute <a href="http://www.w3.org/TR/html5/webappapis.html#eventhandler">EventHandler</a> <a href="#dom-onneedkey">onneedkey</a>;
+};
+
+[<a href="#dom-media-keys-constructor">Constructor</a> (DOMString <a href="#key-system">keySystem</a>)]
+interface <dfn id="dom-mediakeys">MediaKeys</dfn> {
+  readonly attribute DOMString <a href="#dom-keysystem">keySystem</a>;
+
+  <a href="#dom-mediakeysession">MediaKeySession</a> <a href="#dom-createsession">createSession</a>(DOMString? type, Uint8Array? initData);
+
+  static bool <a href="#dom-istypesupported">isTypeSupported</a>(DOMString type, DOMstring <a href="#key-system">keySystem</a>);
+};
+
+interface <dfn id="dom-mediakeysession">MediaKeySession</dfn> : <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#eventtarget">EventTarget</a> {
+  // error state
+  readonly attribute <a href="#dom-mediakeyerror">MediaKeyError</a>? <a href="#dom-error">error</a>;
+
+  // session properties
+  readonly attribute DOMString <a href="#dom-keysystem">keySystem</a>;
+  readonly attribute DOMString <a href="#dom-sessionid">sessionId</a>;
+
+  // session operations
+  void <a href="#dom-update">update</a>(Uint8Array key);
+  void <a href="#dom-close">close</a>();
+};
+
+partial interface <dfn id="dom-htmlsourceelement">HTMLSourceElement</dfn> {
+  attribute DOMString <a href="#dom-sourcekeysystem">keySystem</a>;
+};</pre>
+
+    <p>The <dfn id="dom-keys"><code>keys</code></dfn> attribute is the <code><a href="#dom-mediakeys">MediaKeys</a></code> being used when decrypting encrypted <a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-data">media data</a> for this <a href="#media-element">media element</a>.</p>
+    <p>The <dfn id="dom-setmediakeys"><code>setMediaKeys</code></dfn> method provides the <code><a href="#dom-mediakeys">MediaKeys</a></code> to use. When calling this method, the media element must run the following steps:</p>
+    
+    <ol>
+      <li>
+<p>If loading has not started, throw an <code><a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-domexception-invalid_state_err">INVALID_STATE_ERR</a></code>.</p>
+      <p class="non-normative">In general, applications should wait for an event named <code><a href="#dom-needkey">needkey</a></code> or <code><a href="http://www.w3.org/TR/html5/embedded-content-0.html#event-media-loadstart">loadstart</a></code> (per the <a href="http://www.w3.org/TR/html5/embedded-content-0.html#concept-media-load-resource">resource fetch algorithm</a>) before calling this method.</p>
+      </li>
+      <li>Set the <code><a href="#dom-keys">keys</a></code> attribute of the media element to <var>mediaKeys</var>.</li>
+    </ol>
+
+    <p>The <dfn id="dom-onneedkey"><code>onneedkey</code></dfn> event handler for the <code><a href="#dom-needkey">needkey</a></code> event must be supported by all HTMLMediaElements as both a content attribute and an IDL attribute.</p>
+
+    <p>The <dfn id="dom-media-keys-constructor"><code>MediaKeys(<var title="true">keySystem</var>)</code></dfn> constructor must run the following steps:</p>
+
+    <ol>
+      <li><p>If <var title="true">keySystem</var> is null or an empty string, throw an <code><a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-domexception-invalid_access_err">INVALID_ACCESS_ERR</a></code> exception and abort these steps.</p></li>
+
+      <li><p>If <var title="true">keySystem</var> is not one of the user agent's supported <a href="#key-system">Key Systems</a>, throw a <code><a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-domexception-not_supported_err">NOT_SUPPORTED_ERR</a></code> and abort these steps.</p></li>
+
+      <li><p>Let <var title="true">cdm</var> be the <a href="#cdm">content decryption module</a> corresponding to <var title="true">keySystem</var>.</p></li>
+
+      <li>
+<p>Load <var title="true">cdm</var> if necessary.</p>
+        <dl class="switch">
+          <dt>If <var title="true">cdm</var> fails to load or initialize</dt>
+          <dd><ol>
+            <li>
+<p>Create a new <code><a href="#dom-mediakeyerror">MediaKeyError</a></code> object with the following attributes:</p>
+              <ul style="list-style-type:none"><li>
+                <code><a href="#dom-code">code</a></code> = the appropriate <code><a href="#dom-mediakeyerror">MediaKeyError</a></code> code<br>
+                <code><a href="#dom-systemcode">systemCode</a></code> = a Key System-specific value, if provided, and 0 otherwise
+              </li></ul>
+            </li>
+            <li><p>Set the new object's <code><a href="#dom-error">error</a></code> attribute to the error object created in the previous step.</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-keyerror">keyerror</a></code> at the new object.</p></li>
+            <li><p>Abort these steps.</p></li>
+          </ol></dd>
+        </dl>
+      </li>
+      
+      <li>Create a new <code><a href="#dom-mediakeys">MediaKeys</a></code> object.
+        <ol>
+          <li><p>Let the <code><a href="#dom-keysystem">keySystem</a></code> attribute be <var title="true">keySystem</var>.</p></li>
+        </ol>
+      </li>
+
+      <li>Return the new object to the caller.</li>
+    </ol>
+
+    <p>When destroying a <code><a href="#dom-mediakeys">MediaKeys</a></code> object, follow the steps in <code><a href="#dom-close">close()</a></code>.</p>
+    
+    <p>The <dfn id="dom-keysystem"><code>keySystem</code></dfn> attribute is an identifier for the <a href="#key-system">Key System</a> being used.</p>
+
+    <p>The <dfn id="dom-createsession"><code>createSession(type, initData)</code></dfn> method must run the following steps:</p>
+    <p class="non-normative">Note: The contents of <var title="true">initData</var> are container-specific <a href="#initialization-data">Initialization Data</a>.</p>
+
+    <ol>
+      <li><p>If <var title="true">type</var> is null or an empty string and <var title="true">initData</var> is <em>not</em> null or an empty string, throw an <code><a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-domexception-invalid_access_err">INVALID_ACCESS_ERR</a></code> exception and abort these steps.</p></li>
+      
+      <li><p>If <var title="true">type</var> contains a MIME type that is not supported or is not supported by the <code><a href="#dom-keysystem">keySystem</a></code>, throw a <code><a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-domexception-not_supported_err">NOT_SUPPORTED_ERR</a></code> exception and abort these steps.</p></li>
+
+      <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>Create a new <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object.
+        <ol>
+          <li><p>Let the <code><a href="#dom-keysystem">keySystem</a></code> attribute be <var title="true">keySystem</var>.</p></li>
+          <li><p>Let the <code><a href="#dom-sessionid">sessionId</a></code> attribute be a unique <a href="#session-id">Session ID</a> string. <span class="non-normative">It may be generated by <var title="true">cdm</var>.</span></p></li>
+        </ol>
+      </li>
+      
+      <li><p>Add the new object to an internal list of session objects.</p></li>
+
+      <li>
+<p>Schedule a task to generate a key request, providing <var title="true">type</var>, <var title="true">initData</var>, and the new object.</p>
+        <p>The user agent will asynchronously execute the following steps in the task:</p>
+        <ol>
+          <li><p>Let <var title="true">defaultURL</var> be null.</p></li>
+          <li>
+<p>Use <var title="true">cdm</var> to generate a key request and follow the steps for the first matching condition from the following list:</p>
+            <dl class="switch">
+              <dt>If a request is successfully generated</dt>
+              <dd>
+              <ol>
+                <li>
+<p>Let <var title="true">key request</var> be a key request generated by the <a href="#cdm">CDM</a> using <var title="true">initData</var>, if provided.</p>
+                  <p>Note: <var title="true">cdm</var> must not use any data, including <a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-data">media data</a>, not provided via <var title="true">initData</var>.</p>
+                  <p class="non-normative"><var title="true">type</var> may be used to determine how to interpret <var title="true">initData</var>.</p>
+                </li>
+                <li><p>If <var title="true">initData</var> is not null and contains a default URL for <var title="true">keySystem</var>, let <var title="true">defaultURL</var> be that URL.</p></li> 
+              </ol>
+              </dd>
+              <dt>Otherwise</dt>
+              <dd><ol>
+                <li>
+<p>Create a new <code><a href="#dom-mediakeyerror">MediaKeyError</a></code> object with the following attributes:</p>
+                  <ul style="list-style-type:none"><li>
+                    <code><a href="#dom-code">code</a></code> = the appropriate <code><a href="#dom-mediakeyerror">MediaKeyError</a></code> code<br>
+                    <code><a href="#dom-systemcode">systemCode</a></code> = a Key System-specific value, if provided, and 0 otherwise
+                  </li></ul>
+                </li>
+                <li><p>Set the <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object's <code><a href="#dom-error">error</a></code> attribute to the error object created in the previous step.</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-keyerror">keyerror</a></code> at the <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object.</p></li>
+                <li><p>Abort the task.</p></li>
+              </ol></dd>
+            </dl>
+          </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-keymessage">keymessage</a></code> at the new object</p>
+            <p>The event is of type <code><a href="#dom-mediakeymessageevent">MediaKeyMessageEvent</a></code> and has:</p>
+            <ul style="list-style-type:none"><li>
+              <code><a href="#dom-message">message</a></code> = <var title="true">key request</var><br>
+              <code><a href="#dom-destinationurl">destinationURL</a></code> = <var title="true">defaultURL</var>
+            </li></ul>
+            <p class="non-normative">Note: <code><a href="#dom-message">message</a></code> may be a request for multiple keys, depending on the <var title="true"><a href="#key-system">keySystem</a></var> and/or <var title="true">initData</var>. This is transparent to the application.</p>
+          </li>
+        </ol>
+      </li>
+      
+      <li>Return the new object to the caller.</li>
+    </ol>
+
+    <p>The <dfn id="dom-istypesupported"><code>isTypeSupported(type, keySystem)</code></dfn> method returns whether <var title="true">keySystem</var> is supported with the specified container and codec <var title="true">type</var>(s).</p>
+    <div class="example">
+      <p>The following list shows some examples.</p>
+      <dl>
+        <dt>Returns whether the Some System <a href="#key-system">Key System</a> is supported. Specific containers and codecs may or may not be supported with Some System.</dt>
+        <dd><pre class="code">MediaKeys.isTypeSupported(null, "com.example.somesystem")</pre></dd>
+        <dt>Returns whether version 1.5 of the Some System <a href="#key-system">Key System</a> is supported. Specific containers and codecs may or may not be supported with Some System 1.5.</dt>
+        <dd><pre class="code">MediaKeys.isTypeSupported(null, "com.example.somesystem.1_5")</pre></dd>
+        <dt>Returns whether the Some System <a href="#key-system">Key System</a> is present and supports the container and codec(s) specified by <var title="true">mimeType</var>.</dt>
+        <dd><pre class="code">MediaKeys.isTypeSupported(<var title="true">mimeType</var>, "com.example.somesystem")</pre></dd>
+        <dt>Returns whether the user agent supports <a href="#simple-decryption-clear-key">Clear Key</a> <a href="#simple-decryption">Simple Decryption</a> of the container and codec(s) specified by <var title="true">mimeType</var>.</dt>
+        <dd><pre class="code">MediaKeys.isTypeSupported(<var title="true">mimeType</var>, "org.w3.clearkey")</pre></dd>
+      </dl>
+    </div>
+    
+    <p>It must run the following steps:</p>
+    
+    <ol>
+      <li><p>If <var title="true">keySystem</var> contains an unrecognized or unsupported <a href="#key-system">Key System</a>, return false and abort these steps.</p></li>
+      <li><p>If <var title="true">type</var> is null or an empty string, return true and abort these steps.</p></li>
+      <li><p>If the <a href="#key-system">Key System</a> specified by <var title="true">keySystem</var> does not support decrypting the container and/or codec specified by <var title="true">type</var>, return false and abort these steps.</p></li>
+      <li><p>Return true.</p></li>
+    </ol>
+
+    <p>The <dfn id="dom-error"><code>error</code></dfn> attribute is a <code><a href="#dom-mediakeyerror">MediaKeyError</a></code> representing the current error state of the session. It is null if there is no error.</p>
+
+    <p>The <dfn id="dom-sessionid"><code>sessionId</code></dfn> attribute is the <a href="#session-id">Session ID</a> for this object and the associated key(s) or license(s).</p>
+
+    <p>The <dfn id="dom-update"><code>update(key)</code></dfn> method must run the following steps:</p>
+    <p class="non-normative">Note: The contents of <var title="true">key</var> are <var title="true"><a href="#key-system">keySystem</a></var>-specific.
+    It may be a raw key or a license containing a key.
+    The contents may also vary depending on the container, key length, etc.</p>
+
+    <ol>
+      <li><p>If the argument is null or an empty array, throw an <code><a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-domexception-invalid_access_err">INVALID_ACCESS_ERR</a></code>.</p></li>
+
+      <li>
+<p>Schedule a task to handle the call, providing <var title="true">key</var>.</p>
+        <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">next message</var> be null.</p></li>
+          <li>
+<p>Use <var title="true">cdm</var> to handle <var title="true">key</var>.</p>
+          <p class="non-normative">Note: For some <a href="#key-system">Key Systems</a>, <var title="true">key</var> may be a license or other structure containing multiple keys.</p>
+            <ol>
+              <li><p>Process <var title="true">key</var>.</p></li>
+              <li>
+<p>For each <var title="true">individual key</var> in <var title="true">key</var>, store the <var title="true">individual key</var>.</p>
+                <ol>
+                  <li><p>Let <var title="true">key ID</var> be null.</p></li>
+                  <li><p>If there is a key ID associated with the <var title="true">individual key</var>, let <var title="true">key ID</var> be that ID.</p></li>
+                  <li>
+<p>Store the <var title="true">individual key</var> by following the steps for the first matching condition from the following list:</p>  
+                    <dl class="switch">
+                      <dt>If <var title="true">key ID</var> is not null</dt>
+                      <dd>
+                        <ol>
+                          <li><p>Clear any stored key not associated with a key ID.</p></li>
+                          <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>
+                      </dd>
+                      <dt>Otherwise</dt>
+                      <dd>
+                        <ol>
+                          <li><p>Clear all stored keys.</p></li>
+                          <li><p>Store the <var title="true">individual key</var>, license, and/or license information with no associated key ID.</p></li>
+                        </ol>
+                      </dd>
+                    </dl>
+                    <p class="non-normative">At most one key may be stored if key IDs are not used.</p>
+                    <p class="non-normative">Clearing keys avoids needing to handle a mixture of keys with and without IDs in the <a href="#algorithms-enrypted-block">Encrypted Block Encountered algorithm</a>.</p>
+                    <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>
+              <li><p>If another message needs to be sent to the server, let <var title="true">next message</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 <var title="true">next message</var> is not null, <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-keymessage">keymessage</a></code> at the <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object.</p>
+             <p>The event is of type <code><a href="#dom-mediakeymessageevent">MediaKeyMessageEvent</a></code> and has:</p>
+             <ul style="list-style-type:none"><li>
+               <code><a href="#dom-message">message</a></code> = <var title="true">next message</var><br>
+               <code><a href="#dom-destinationurl">destinationURL</a></code> = null
+             </li></ul>
+          </li>
+          <li><p>If <var title="true">did store key</var> is true, <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-keyadded">keyadded</a></code> at the <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object.</p></li>
+          <li>
+<p>If any of the preceding steps in the task failed</p>
+              <ol>
+                <li>
+<p>Create a new <code><a href="#dom-mediakeyerror">MediaKeyError</a></code> object with the following attributes:</p>
+                  <ul style="list-style-type:none"><li>
+                    <code><a href="#dom-code">code</a></code> = the appropriate <code><a href="#dom-mediakeyerror">MediaKeyError</a></code> code<br>
+                    <code><a href="#dom-systemcode">systemCode</a></code> = a Key System-specific value, if provided, and 0 otherwise
+                  </li></ul>
+                </li>
+                <li><p>Set the <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object's <code><a href="#dom-error">error</a></code> attribute to the error object created in the previous step.</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-keyerror">keyerror</a></code> at the <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object.</p></li>
+                <li><p>Abort the task.</p></li>
+              </ol>
+          </li>
+      </ol>
+      </li>
+    </ol>
+
+    <p>The key acquisition process <em>may</em> involve the web page handling <code><a href="#dom-keymessage">keymessage</a></code> events, sending the message to a Key System-specific service, and calling <code><a href="#dom-update">update</a></code> with the response message.
+    <code><a href="#dom-update">update</a></code> calls may generate <code><a href="#dom-keyadded">keyadded</a></code> or <code><a href="#dom-keymessage">keymessage</a></code> events.
+    During the process, the web page may wish to cancel the acquisition process.
+    <span class="non-normative">For example, if the page cannot contact the license service because of network issues it may wish to fallback to an alternative key system.</span>
+    The page calls <code><a href="#dom-close">close()</a></code> to cancel the a key acquisition session.
+    </p>
+
+    <p>The <dfn id="dom-close"><code>close()</code></dfn> method causes the key acquisition session to close and all keys to be released. It must run the following steps:</p>
+
+     <ol>
+      <li>Clear any internal state associated with the session, including all keys and licenses.</li>
+    </ol>
+
+    <p>The <dfn id="dom-sourcekeysystem"><code>keySystem</code></dfn> attribute of <code><a href="#dom-htmlsourceelement">HTMLSourceElement</a></code> specifies the <a href="#key-system">Key System</a> to be used with the <code><a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-resource">media resource</a></code>.
+    The <a href="http://www.w3.org/TR/html5/embedded-content-0.html#concept-media-load-algorithm">resource selection algorithm</a> is modified to check the <code><a href="#dom-sourcekeysystem">keySystem</a></code> attribute after the existing <em>step 5</em> of the <em>Otherwise</em> branch of <em>step 6</em>:
+    </p>
+    <ol start="6">
+      <li><p>⌛ If <var title="">candidate</var> has a <code><a href="#dom-sourcekeysystem">keySystem</a></code> attribute whose value represents a <a href="#key-system">Key System</a> that the user agent knows it cannot use with <code><a href="http://www.w3.org/TR/html5/embedded-content-0.html#attr-source-type">type</a></code>, then end the <a href="http://www.w3.org/TR/html5/webappapis.html#synchronous-section">synchronous section</a>, and jump down to the <i title="">failed</i> step below.</p></li>
+    </ol>
+
+    <h3 id="error-codes">2.1. Error Codes</h3>
+    <p><code><a href="http://www.w3.org/TR/html5/embedded-content-0.html#mediaerror">MediaError</a></code> is extended, and a new error type is added.</p>
+    <pre class="idl">
+partial interface <dfn id="dom-mediaerror">MediaError</dfn> {
+  const unsigned short <a href="#dom-media_err_encrypted">MEDIA_ERR_ENCRYPTED</a> = 5;
+};
+
+interface <dfn id="dom-mediakeyerror">MediaKeyError</dfn> {
+  const unsigned short <a href="#dom-media_keyerr_unknown">MEDIA_KEYERR_UNKNOWN</a> = 1;
+  const unsigned short <a href="#dom-media_keyerr_client">MEDIA_KEYERR_CLIENT</a> = 2;
+  const unsigned short <a href="#dom-media_keyerr_service">MEDIA_KEYERR_SERVICE</a> = 3;
+  const unsigned short <a href="#dom-media_keyerr_output">MEDIA_KEYERR_OUTPUT</a> = 4;
+  const unsigned short <a href="#dom-media_keyerr_hardwarechange">MEDIA_KEYERR_HARDWARECHANGE</a> = 5;
+  const unsigned short <a href="#dom-media_keyerr_domain">MEDIA_KEYERR_DOMAIN</a> = 6;
+  readonly attribute unsigned short <a href="#dom-code">code</a>;
+  readonly attribute unsigned long <a href="#dom-systemcode">systemCode</a>;
+};</pre>
+
+    <dl class="domintro">
+     <dt>
+<var title="">session</var> . <var title="">error</var> . <code><a href="#dom-code">code</a></code>
+</dt>
+     <dd>
+       <p>Returns the current error's error code, from the list below.</p>
+     </dd>
+     <dt>
+<var title="">session</var> . <var title="">error</var> . <code><a href="#dom-systemcode">systemCode</a></code>
+</dt>
+     <dd>
+       <p>Returns the current error's system code.</p>
+     </dd>
+    </dl>
+
+    <p>The <dfn id="dom-mediaerrorcode"><code>code</code></dfn> attribute of a <code><a href="#dom-mediaerror">MediaError</a></code> may additionally return the following:</p>
+    <dl>
+      <dt>
+<dfn id="dom-media_err_encrypted"><code>MEDIA_ERR_ENCRYPTED</code></dfn> (numeric value 5)</dt>
+      <dd>The stream could not be played because it is encrypted and one of the following:
+        <ol>
+          <li>No key was provided and no <code><a href="#dom-needkey">needkey</a></code> handler was provided</li>
+          <li>The provided key could not be successfully applied</li>
+          <li>The user agent does not support decryption of this <a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-data">media data</a>
+</li>
+        </ol>
+      </dd>
+    </dl>
+
+    <div class="impl">
+    <p>The <dfn id="dom-code"><code>code</code></dfn> attribute of a <code><a href="#dom-mediakeyerror">MediaKeyError</a></code> object must return the code for the error, which must be one of the following:</p>
+    <dl>
+      <dt>
+<dfn id="dom-media_keyerr_unknown"><code>MEDIA_KEYERR_UNKNOWN</code></dfn> (numeric value 1)</dt>
+      <dd>An unspecified error occurred. This value is used for errors that don't match any of the following codes.</dd>
+      <dt>
+<dfn id="dom-media_keyerr_client"><code>MEDIA_KEYERR_CLIENT</code></dfn> (numeric value 2)</dt>
+      <dd>The <a href="#key-system">Key System</a> could not be installed or updated.</dd>
+      <dt>
+<dfn id="dom-media_keyerr_service"><code>MEDIA_KEYERR_SERVICE</code></dfn> (numeric value 3)</dt>
+      <dd>The message passed into <code><a href="#dom-update">update</a></code> indicated an error from the license service.</dd>
+      <dt>
+<dfn id="dom-media_keyerr_output"><code>MEDIA_KEYERR_OUTPUT</code></dfn> (numeric value 4)</dt>
+      <dd>There is no available output device with the required characteristics for the content protection system.</dd>
+      <dt>
+<dfn id="dom-media_keyerr_hardwarechange"><code>MEDIA_KEYERR_HARDWARECHANGE</code></dfn> (numeric value 5)</dt>
+      <dd>A hardware configuration change caused a content protection error.</dd>
+      <dt>
+<dfn id="dom-media_keyerr_domain"><code>MEDIA_KEYERR_DOMAIN</code></dfn> (numeric value 6)</dt>
+      <dd>An error occurred in a multi-device domain licensing configuration. <span class="non-normative">The most common error is a failure to join the domain.</span>
+</dd>
+    </dl>
+
+    <p>The <dfn id="dom-systemcode"><code>systemCode</code></dfn> attribute of a <code><a href="#dom-mediakeysession">MediaKeySession</a></code> object is a <a href="#key-system">Key System</a>-dependent status code for the error that occurred.
+    <span class="non-normative">This allows a more granular status to be returned than the more general <code><a href="#dom-code">code</a></code>.</span>
+    It should be 0 if there is no associated status code or such status codes are not supported by the Key System.
+    </p>
+    </div>
+
+
+    <h2 id="events">3. Events</h2>
+
+    <h3 id="event-definitions">3.1. Event Definitions</h3>
+    <pre class="idl">
+[Constructor(DOMString type, optional <a href="#dom-mediakeymessageeventinit">MediaKeyMessageEventInit</a> eventInitDict)]
+interface <dfn id="dom-mediakeymessageevent">MediaKeyMessageEvent</dfn> : <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event">Event</a> {
+  readonly attribute Uint8Array <a href="#dom-message">message</a>;
+  readonly attribute DOMString? <a href="#dom-destinationurl">destinationURL</a>;
+};
+
+dictionary <dfn id="dom-mediakeymessageeventinit">MediaKeyMessageEventInit</dfn> : <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#eventinit">EventInit</a> {
+  Uint8Array <a href="#dom-message">message</a>;
+  DOMString? <a href="#dom-destinationurl">destinationURL</a>;
+};</pre>
+
+    <pre class="idl">
+[Constructor(DOMString type, optional <a href="#dom-mediakeyneededeventinit">MediaKeyNeededEventInit</a> eventInitDict)]
+interface <dfn id="dom-mediakeyneededevent">MediaKeyNeededEvent</dfn> : <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event">Event</a> {
+  readonly attribute Uint8Array? <a href="#dom-initdata">initData</a>;
+};
+
+dictionary <dfn id="dom-mediakeyneededeventinit">MediaKeyNeededEventInit</dfn> : <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#eventinit">EventInit</a> {
+  Uint8Array? <a href="#dom-initdata">initData</a>;
+};</pre>
+
+    <dl class="domintro">
+     <dt>
+<var title="">event</var> . <code><a href="#dom-destinationurl">destinationURL</a></code>
+</dt>
+     <dd>
+       <p>Returns the URL to send the <code><a href="#dom-message">message</a></code> to.</p>
+     </dd>
+     <dt>
+<var title="">event</var> . <code><a href="#dom-initdata">initData</a></code>
+</dt>
+     <dd>
+       <p>Returns the <a href="#initialization-data">Initialization Data</a> related to the event.</p>
+     </dd>
+     <dt>
+<var title="">event</var> . <code><a href="#dom-message">message</a></code>
+</dt>
+     <dd>
+       <p>Returns the message <span class="non-normative">(i.e. key request)</span> to send.</p>
+     </dd>
+    </dl>
+    <div class="impl">
+    <p>The <dfn id="dom-initdata"><code>initData</code></dfn> attribute contains <a href="#initialization-data">Initialization Data</a> specific to the event.</p>
+    <p>The <dfn id="dom-message"><code>message</code></dfn> attribute contains a message from the CDM. Messages are Key System-specific. <span class="non-normative">In most cases, it should be sent to a key server.</span></p>
+    <p>The <dfn id="dom-destinationurl"><code>destinationURL</code></dfn> is the URL to send the <code><a href="#dom-message">message</a></code> to.
+       An application <em>may</em> override this.
+       <span class="non-normative">In some cases, it may have been provided by the <a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-data">media data</a>.</span>
+       It may be null.
+    </p>
+
+    <p>If a response (i.e. a license) is necessary, applications should use one of the <a href="#dom-htmlmediaelement">new methods</a> to provide the response.</p>
+    </div>
+
+    <h3 id="event-summary">3.2. Event Summary</h3>
+
+    <p>The following events are fired at <code><a href="#dom-mediakeysession">MediaKeySession</a></code>.</p>
+    <table>
+      <thead>
+        <tr>
+          <th>Event name</th>
+          <th>Interface</th>
+          <th>Dispatched when...</th>
+          <th>Preconditions</th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <td><dfn id="dom-keyadded"><code>keyadded</code></dfn></td>
+          <td><code><a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event">Event</a></code></td>
+          <td>A key has been added as the result of a <code><a href="#dom-update">update()</a></code> call.
+          </td>
+          <td></td>
+        </tr>
+        <tr>
+          <td><dfn id="dom-keyerror"><code>keyerror</code></dfn></td>
+          <td><code><a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event">Event</a></code></td>
+          <td>An error occurs in the session.</td>
+          <td></td>
+        </tr>
+        <tr>
+          <td><dfn id="dom-keymessage"><code>keymessage</code></dfn></td>
+          <td><code><a href="#dom-mediakeymessageevent">MediaKeyMessageEvent</a></code></td>
+          <td>
+            A message has been generated <span class="non-normative">(and likely needs to be sent to a server)</span>.
+            <span class="non-normative">For example, a key request has been generated as the result of a <code><a href="#dom-createsession">createSession()</a></code> call or another message must be sent in response to an <code><a href="#dom-update">update()</a></code> call.</span>
+          </td>
+          <td></td>
+        </tr>
+      </tbody>
+    </table>
+
+    <p>The following event is fired at <code><a href="#dom-htmlmediaelement">HTMLMediaElement</a></code>.</p>
+    <table>
+      <thead>
+        <tr>
+          <th>Event name</th>
+          <th>Interface</th>
+          <th>Dispatched when...</th>
+          <th>Preconditions</th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <td><dfn id="dom-needkey"><code>needkey</code></dfn></td>
+          <td><code><a href="#dom-mediakeyneededevent">MediaKeyNeededEvent</a></code></td>
+          <td>
+            The user agent needs a key or license to begin or continue playback.
+            <br><span class="non-normative"><br>It may have encountered <a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-data">media data</a> that may/does require decryption to load or play OR need a new key/license to continue playback.</span>
+          </td>
+          <td>
+<code title="dom-media-readyState"><a href="http://www.w3.org/TR/html5/embedded-content-0.html#dom-media-readystate">readyState</a></code> is equal to <code title="dom-media-HAVE_METADATA"><a href="http://www.w3.org/TR/html5/embedded-content-0.html#dom-media-have_metadata">HAVE_METADATA</a></code> or greater.
+          <span class="non-normative">It is possible that the element is playing or has played.</span>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+
+    <h2 id="key-release">4. Key Release</h2>
+    <h3 id="key-release-intro">4.1. Introduction</h3>
+    <p><i>This section is non-normative.</i></p>
+    <p>The above sections provide for delivery of key/license information to a <a href="#cdm">Content Decryption Module</a>.
+    This section provides for management of the entire key/license lifecycle, that is, secure proof of key release.
+    Use cases for such proof include any service where is it necessary for the service to know, reliably, which granted keys/licences are still available for use by the user and which have been deleted.
+    Examples include a service with restrictions on the number of concurrent streams available to a user or a service where content is available on a rental basis, for use offline.
+    </p>
+    
+    <p>Secure proof of key release must necessarily involve the CDM due to the relative ease with which scripts may be modified.
+    The CDM must provide a message asserting, in a CDM-specific form, that a specific key or license has been destroyed.
+    Such messages must be cached in the CDM until acknowledgement of their delivery to the service has been received.
+    This acknowledgement must also be in the form of a CDM-specific message.
+    </p>
+    
+    <p>The mechanism for secure proof of key release operates outside the scope of any <a href="#media-element">media element</a>.
+    This is because proof-of-release messages may be cached in CDMs after the associated media elements have been destroyed.
+    Proof-of-key-release messages are subject to the same origin policy: they shall only be delivered to scripts with the same origin as the script which created the media element that provided the key/license.
+    </p>
+
+    <h2 id="algorithms">5. Algorithms</h2>
+
+    <h3 id="algorithms-enrypted-block">5.1. Encrypted Block Encountered</h3>
+    <p>The following steps are run when the <a href="#media-element">media element</a> encounters a block <span class="non-normative">(i.e. frame)</span> of encrypted <a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-data">media data</a> during the <a href="http://www.w3.org/TR/html5/embedded-content-0.html#concept-media-load-resource">resource fetch algorithm</a>:</p>
+
+    <ol>
+      <li><p>Let <var title="">cdm</var> be null.</p></li>
+      <li><p>Let <var title="">block initData</var> be null.</p></li>
+      <li><p>Let <var title="">block key</var> be null.</p></li>
+      <li><p>If the block (or its parent entity) has <a href="#initialization-data">Initialization Data</a>, let <var title="">block initData</var> be that initialization data.</p></li>
+      <li>
+<p>Determine whether there is an active <a href="#cdm">CDM</a> by following the steps for the first matching condition from the following list:</p>
+      <dl class="switch">
+        <dt>If the media element's <code><a href="#dom-keys">keys</a></code> attribute is not null</dt>
+        <dd>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>.</dd>
+        <dt>Otherwise</dt>
+        <dd>Jump to the <i>Key Presence</i> step below.</dd>
+      </dl>
+      </li>
+      <li>
+<p>Use <var title="true">cdm</var> to select the key:</p>
+        <ol>
+          <li><p>Let <var title="">block key ID</var> be null.</p></li>
+          <li><p>If <var title="">block initData</var> is not null and contains a key ID, let <var title="">block key ID</var> be that ID.</p></li>
+          <li>
+<p>Select the key by following the steps for the first matching condition from the following list:</p>  
+          <dl class="switch">
+            <dt>If <var title="">block key ID</var> is not null</dt>
+            <dd>
+            <p>Select the key by using <var title="true">cdm</var> to follow the steps for the first matching condition from the following list:</p>
+            <dl class="switch">
+              <dt>If <var title="true">cdm</var>  has a key cached for <var title="">block key ID</var>
+</dt>
+              <dd>Let <var title="">block key</var> be the matching cached key.</dd>
+              <dt>If <var title="true">cdm</var> has a key cached with no ID <span class="non-normative">(there can be one at most)</span>
+</dt>
+              <dd>Let <var title="">block key</var> be the single cached key.</dd>
+              <dt>Otherwise (<var title="true">cdm</var> has no keys cached OR has one or more keys cached, none of which have a matching key ID)</dt>
+              <dd>Jump to the <i>Key Presence</i> step below.</dd>
+            </dl>
+            </dd>
+            <dt>Otherwise</dt>
+            <dd>
+            <p>Select the key by using <var title="true">cdm</var> to follow the steps for the first matching condition from the following list:</p>
+            <dl class="switch">
+              <dt>If <var title="true">cdm</var> has a single key cached (with or without a key ID)</dt>
+              <dd>Let <var title="">block key</var> be the single cached key.</dd>
+              <dt>If <var title="true">cdm</var> has more than one key cached <span class="non-normative">(all would have IDs)</span>
+</dt>
+              <dd>Abort media element's <a href="http://www.w3.org/TR/html5/embedded-content-0.html#concept-media-load-resource">resource fetch algorithm</a> and run the steps to report a <code><a href="#dom-media_err_encrypted">MEDIA_ERR_ENCRYPTED</a></code> error.</dd>
+              <dt>Otherwise</dt>
+              <dd>Jump to the <i>Key Presence</i> step below.</dd>
+            </dl>
+            </dd>
+          </dl>
+          </li>
+        </ol>
+      </li>
+      <li>
+<p><i>Key Presence</i>: Handle the presence of a key by following the steps for the first matching condition from the following list:</p>
+      <dl class="switch">
+        <dt>If <var title="">cdm</var> is not null and <var title="">block key</var> is not null.</dt>
+        <dd>Use <var title="true">cdm</var> to Decrypt the block using <var title="">block key</var> by following the steps for the first matching condition from the following list:
+          <dl class="switch">
+            <dt>If decryption fails</dt>
+            <dd>Abort media element's <a href="http://www.w3.org/TR/html5/embedded-content-0.html#concept-media-load-resource">resource fetch algorithm</a> and run the steps to report a <code><a href="#dom-media_err_encrypted">MEDIA_ERR_ENCRYPTED</a></code> error.</dd>
+            <dt>Otherwise</dt>
+            <dd>Continue.</dd>
+          </dl>
+          <p class="non-normative">Note: Not all decryption problems (i.e. using the wrong key) will result in a decryption failure. In such cases, no error is fired here but one may be fired during decode.</p>
+        </dd>
+        <dt>If there is an event handler for <code><a href="#dom-needkey">needkey</a></code>
+</dt>
+        <dd>
+        <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-needkey">needkey</a></code> at the <a href="#media-element">media element</a>.
+        <p>The event is of type <code><a href="#dom-mediakeyneededevent">MediaKeyNeededEvent</a></code> and has:</p>
+        <ul style="list-style-type:none"><li>
+          <code><a href="#dom-initdata">initData</a></code> = <var title="">block initData</var>
+        </li></ul>
+        <p class="non-normative">The <a href="#media-element">media element</a> is said to be <code><a href="http://www.w3.org/TR/html5/embedded-content-0.html#potentially-playing">potentially playing</a></code>
+        unless playback stops because the stream cannot be decrypted, in which case the <a href="#media-element">media element</a> is said to be <a href="#waiting-for-a-key">waiting for a key</a>.
+        </p>
+        </dd>
+        <dt>Otherwise</dt>
+        <dd>Abort media element's <a href="http://www.w3.org/TR/html5/embedded-content-0.html#concept-media-load-resource">resource fetch algorithm</a> and run the steps to report a <code><a href="#dom-media_err_encrypted">MEDIA_ERR_ENCRYPTED</a></code> error.</dd>
+      </dl>
+      </li>
+    </ol>
+
+    <div class="non-normative">
+    <p>For frame-based encryption, this may be implemented as follows when the media element attempts to decode a frame as part of the <a href="http://www.w3.org/TR/html5/embedded-content-0.html#concept-media-load-resource">resource fetch algorithm</a>:</p>
+    <ol>
+      <li><p>Let <var title="">encrypted</var> be false.</p></li>
+      <li>
+<p>Detect whether the frame is encrypted.</p>
+        <dl class="switch">
+          <dt>If the frame is encrypted</dt>
+          <dd>Run the steps above.</dd>
+          <dt>Otherwise</dt>
+          <dd>Continue.</dd>
+        </dl>
+      </li>
+      <li><p>Decode the frame.</p></li>
+      <li><p>Provide the frame for rendering.</p></li>
+    </ol>
+    </div>
+
+    <p>The following paragraph is added to <a href="http://www.w3.org/TR/html5/embedded-content-0.html#playing-the-media-resource">Playing the media resource</a>.</p>
+    <ul style="list-style-type:none">
+    <li>A <a href="#media-element">media element</a> is said to be <dfn id="waiting-for-a-key">waiting for a key</dfn> when
+    it would be <code><a href="http://www.w3.org/TR/html5/embedded-content-0.html#potentially-playing">potentially playing</a></code> but
+    the user agent has reached a point in the <code><a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-resource">media resource</a></code> that must be decrypted for the resource to continue and the <a href="#cdm">CDM</a> does not have the necessary key.
+    </li>
+    <li class="non-normative">The media element leaves this state when seeking but could re-enter it if the same conditions exist.</li>
+    </ul>
+
+    <h3 id="algorithms-encrypted-stream">5.2. Potentially Encrypted Stream Encountered</h3>
+    <p>The following steps are run when the <a href="#media-element">media element</a> encounters a source that may contain encrypted blocks or streams during the <a href="http://www.w3.org/TR/html5/embedded-content-0.html#concept-media-load-resource">resource fetch algorithm</a>:</p>
+
+    <ol>
+      <li><p>Let <var title="">cdm</var> be null.</p></li>
+      <li><p>Let <var title="">initData</var> be null.</p></li>
+      <li><p>If <a href="#initialization-data">Initialization Data</a> was encountered, let <var title="">initData</var> be that initialization data.</p></li>
+      <li>
+<p>Determine whether there is an active <a href="#cdm">CDM</a> by following the steps for the first matching condition from the following list:</p>
+      <dl class="switch">
+        <dt>If the media element's <code><a href="#dom-keys">keys</a></code> attribute is not null</dt>
+        <dd>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>.</dd>
+        <dt>Otherwise</dt>
+        <dd>Jump to the <i>Need Key</i> step below.</dd>
+      </dl>
+      </li>
+      <li>
+<p>Use <var title="true">cdm</var> to determine whether the key is known:</p>
+        <ol>
+          <li><p>Let <var title="">key ID</var> be null.</p></li>
+          <li><p>If a key ID for the source is known at this time, let <var title="">key ID</var> be that ID.</p></li>
+          <li><p>If <var title="">initData</var> is not null and contains a key ID, let <var title="">key ID</var> be that ID.</p></li>
+          <li>
+<p>Determine whether the key is already known by following the steps for the first matching condition from the following list:</p>
+          <dl class="switch">
+            <dt>If <var title="">key ID</var> is not null</dt>
+            <dd>
+            <p>Determine whether the key is known by following the steps for the first matching condition from the following list:</p>
+            <dl class="switch">
+              <dt>If there is a key cached for <var title="">key ID</var>
+</dt>
+              <dd>Jump to the <i>Continue Normal Flow</i> step below.</dd>
+              <dt>Otherwise</dt>
+              <dd>Jump to the <i>Need Key</i> step below.</dd>
+            </dl>
+            </dd>
+            <dt>Otherwise</dt>
+            <dd>
+            <p>Determine whether the key is known by following the steps for the first matching condition from the following list:</p>
+            <dl class="switch">
+              <dt>If there is a single key cached (with or without a key ID)</dt>
+              <dd>Jump to the <i>Continue Normal Flow</i> step below.</dd>
+              <dt>Otherwise</dt>
+              <dd>Jump to the <i>Need Key</i> step below.</dd>
+            </dl>
+            </dd>
+          </dl>
+          </li>
+        </ol>
+      </li>
+      <li>
+<p><i>Need Key</i>: <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-needkey">needkey</a></code> at the <a href="#media-element">media element</a>.</p>
+        <p>The event is of type <code><a href="#dom-mediakeyneededevent">MediaKeyNeededEvent</a></code> and has:</p>
+        <ul style="list-style-type:none"><li>
+          <code><a href="#dom-initdata">initData</a></code> = <var title="">initData</var>
+        </li></ul>
+        <p class="non-normative">Firing this event allows the application to begin acquiring the key process before it is needed.</p>
+        <p class="non-normative">Note that <code title="dom-media-readyState"><a href="http://www.w3.org/TR/html5/embedded-content-0.html#dom-media-readystate">readyState</a></code> is <em>not</em> changed and no algorithms are aborted. This event is merely informative.</p>
+      </li>
+
+      <li><p><i>Continue Normal Flow</i>: Continue with the existing media element's <a href="http://www.w3.org/TR/html5/embedded-content-0.html#concept-media-load-resource">resource fetch algorithm</a>.</p></li>
+    </ol>
+
+    <h3 id="algorithms-load">5.3. Addition to Media Element Load Algorithm</h3>
+    <p>The following step is added to the existing <a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-element-load-algorithm">media element load algorithm</a>:</p>
+    <ul>
+      <li>
+<p>Clear the <code><a href="#dom-keys">keys</a></code> attribute for this <a href="#media-element">media element</a>.</p>
+      <p class="non-normative">This also means the <code><a href="#dom-keys">keys</a></code> attribute will be cleared when the <code><a href="http://www.w3.org/TR/html5/embedded-content-0.html#attr-media-src">src</a></code> attribute is set or changed per <a href="http://www.w3.org/TR/html5/embedded-content-0.html#location-of-the-media-resource">Location of the media resource</a></p>
+      </li>
+    </ul>
+
+
+    <h2 id="simple-decryption">6. Simple Decryption</h2>
+    <p>All user agents must support the simple decryption capabilities described in this section regardless of whether they support a more advanced <a href="#cdm">CDM</a>.
+    <span class="non-normative">This ensures that there is a common baseline level of protection that is guaranteed to be supported in all user agents, including those that are entirely open source.
+    Thus, content providers that need only basic protection can build simple applications that will work on all platforms without needing to work with any content protection providers.</span>
+    </p>
+
+    <h3 id="simple-decryption-clear-key">6.1. Clear Key</h3>
+    <p>The "org.w3.clearkey" <a href="#key-system">Key System</a> indicates a plain-text clear (unencrypted) key will be used to decrypt the source.
+    No additional client-side content protection is required.
+    Use of this Key System is described below.
+    </p>
+    
+    <p>The <var title="true">keySystem</var> parameter and <code><a href="#dom-keysystem">keySystem</a></code> attributes are always <code>"org.w3.clearkey"</code>.
+    The <code><a href="#dom-sessionid">sessionId</a></code> string is numerical.</p>
+
+    <p>The <code><a href="#dom-initdata">initData</a></code> attribute of the <code><a href="#dom-needkey">needkey</a></code> event and the <var title="true">initData</var> parameter of <code><a href="#dom-createsession">createSession()</a></code> are the same container-specific <a href="#initialization-data">Initialization Data</a> format and values.
+    <span class="non-normative">
+    If supported, these values should provide some type of identification of the content or key that could be used to look up the key (since there is no defined logic for parsing it).
+    For containers that support a simple key ID, it should be a binary array containing the raw key ID.
+    For other containers, it may be some other opaque blob or null.</span>
+    </p>
+
+    
+    <p>The <code><a href="#dom-mediakeymessageevent">MediaKeyMessageEvent</a></code> generated by <code><a href="#dom-createsession">createSession()</a></code> has:</p>
+    <ul style="list-style-type:none"><li>
+      <code><a href="#dom-message">message</a></code> = a container-specific value extracted from the <var title="true">initData</var> parameter of <code><a href="#dom-createsession">createSession()</a></code>. null if <var title="true">initData</var> was null or a value could not be extracted.<br>
+      <code><a href="#dom-destinationurl">destinationURL</a></code> = value of the default URL if present in the <a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-data">media data</a> and null otherwise.
+    </li></ul>
+
+    <p>The <var title="true">key</var> parameter of <code><a href="#dom-update">update()</a></code> should be a JSON Web Key (JWK) representation of the symmetric key to be used for decryption, as defined in the <a href="http://tools.ietf.org/html/draft-jones-jose-json-private-and-symmetric-key">IETF Internet-draft JSON Private and Symmetric Key specification</a>. The JSON string is encoded into the Uint8Array parameter using <a href="http://www.w3.org/TR/html5/infrastructure.html#ascii-compatible-character-encoding">ASCII-compatible character encoding</a>.</p>
+    <p>When the JWK 'key type' ("kty") member value is 'octet sequence' ("oct"), the 'key value' ("k") member will be a base64 encoding of the octet sequence containing the symmetric key value.</p>
+    <p>For example, the following contains a single symmetric key represented as a JWK, designated as being for use with the AES Key Wrap algorithm (line breaks for readability, only).</p>
+
+    <div class="example">
+      <pre class="code">
+{
+  "keys": 
+    [{
+      "kty":"oct",
+      "alg":"A128KW",
+      "kid":"67ef0gd8pvfd0=",
+      "k":"GawgguFyGrWKav7AX4VKUg"
+    }]
+}</pre>
+    </div>
+    
+
+    <h2 id="containers">7. Container Guidelines</h2>
+    <p>This document describes behavior independent of specific media containers.
+    The following sections provide container-specific details for implementations that choose to support those containers.
+    </p>
+    
+    <h3 id="webm">7.1 WebM</h3>
+    <div class="nonnormative">
+      <p>This section defines the stream format and Initialization Data for implementations that choose to support <a href="http://www.webmproject.org/code/specs/container/">WebM</a>.</p>
+
+      <h4 id="webm-stream-format">7.1.1.Stream Format </h4>
+      <p><a href="http://wiki.webmproject.org/encryption/webm-encryption-rfc">Encrypted WebM streams</a> are encrypted at the block level with AES-128 CTR encryption.
+      The container shall include appropriate values within the <a href="http://matroska.org/technical/specs/index.html#ContentEncryption">ContentEncryption</a> element.
+      </p>
+
+      <p>WebM streams may be partially encrypted, both at the <a href="http://matroska.org/technical/specs/index.html#LevelTrack">Track</a> level and the block level.
+      In the former case, a subset of Tracks in the stream have a <a href="http://matroska.org/technical/specs/index.html#ContentEncryption">ContentEncryption</a> element.
+      In the latter case, a subset of the blocks within a Track containing a <a href="http://matroska.org/technical/specs/index.html#ContentEncryption">ContentEncryption</a> element are marked as encrypted.</p>
+
+      <h4 id="webm-detect-encrypt">7.1.2. Detecting Encryption</h4>
+      <p>When a WebM <a href="http://matroska.org/technical/specs/index.html#LevelTrack">Track</a> is parsed, the presence of a <a href="http://matroska.org/technical/specs/index.html#ContentEncKeyID">ContentEncKeyID</a> element shall indicate that the stream is <a href="#algorithms-encrypted-stream">potentially encrypted</a>.</p>
+
+      <p><a href="#algorithms-enrypted-block">Encrypted blocks</a> are those marked encrypted by the <a href="http://wiki.webmproject.org/encryption/webm-encryption-rfc#TOC-4.6-Signal-Byte-Format">Signal Byte.</a></p>
+
+      <h4 id="webm-init-data">7.1.3. Initialization Data and Events</h4>
+      <p><a href="#initialization-data">Initialization Data</a> in <a href="#events">events</a> is always a key ID, which is the <a href="http://matroska.org/technical/specs/index.html#ContentEncKeyID">ContentEncKeyID</a> of the current <a href="http://matroska.org/technical/specs/index.html#LevelTrack">Track</a>.
+      The current Track is the one being parsed or that contains the block being decrypted.
+      </p>
+
+      <p>Events only contain a single key ID.
+      However, if supported by the key system, multiple key IDs may be bundled by the application before requesting a key and multiple key ID-key pairs may be returned by the license server.
+      </p>
+
+      <p>An event will be fired for each new key ID (in <a href="http://matroska.org/technical/specs/index.html#ContentEncKeyID">ContentEncKeyID</a>) encountered for which a key is not already known.</p>
+    </div>
+
+    <h3 id="iso">7.2 ISO Base Media File Format</h3>
+    <div class="nonnormative">
+      <p>This section defines the stream format and initialization data for ISO Base media File Format (ISOBMFF) content.</p>
+
+      <h4 id="iso-stream-format">7.2.1 Stream format</h4>
+      <p>The stream format is dependent upon the protection scheme, as defined in the scheme type box ('schm').</p>
+      <p>For example, under the common encryption ("cenc") protection scheme, ISOBMFF content is encrypted at the sample level with AES-128 CTR encryption, according to ISO/IEC 23001-7:2012, "Information technology - MPEG system technologies - Part 7: Common encryption in ISO base media file format files". This protection method enables multiple Key Systems to decrypt the same media content.</p>
+
+      <h4 id="iso-detect-encrypt">7.2.2 Detecting Encryption</h4>
+      <p>Protection scheme signaling conforms with ISO/IEC 14496-12. When protection has been applied, the stream type will be transformed to 'encv' for video or 'enca' for audio, with a scheme information box ('sinf') added to the sample entry in the sample description box ('stsd'). The scheme information box ('sinf') will contain a scheme type box ('schm') with a scheme_type field set to the 4CC value of the protection scheme.</p>
+      <p>Additionally, if the protection scheme is common encryption ("cenc"), the "encrypted block" is a sample. Determining whether a sample is encrypted depends on the corresponding track encryption box ('tenc') and the sample group associated with the sample. In this case the default encryption state of a sample is defined by the IsEncrypted flag in the associated track encryption box ('tenc'). This default state may be modified by the IsEncrypted flag in the Sample Group Description Box ('sgpd'), pointed to by an index in the Sample to Group Box ('sbgp').</p>
+      <p>For complete information about "cenc" see ISO/IEC 23001-7:2012.</p>
+
+      <h4 id="iso-init-data">7.2.3 Initialization Data and Events</h4>
+      <p>For ISOBMFF the InitData begins with a the protection scheme information box ('sinf'). The 'sinf' includes the scheme type box ('schm'), giving the scheme_type, and the scheme information box ('schi').</p>
+      <p>If this scheme_type is common encryption ("cenc"), the scheme information box will also contain the track encryption box ('tenc'), giving the defaults for IsEncrypted, IV_size and KID for that track. In addition, one or more protection system specific heder boxes ('pssh') will be concatenated after the 'sinf' box.</p>
+      <p>In a file encrypted with common encryption, each key is identified by a Key ID and each encrypted sample is associated with the Key ID of the key needed to decrypt it. This association is signaled either through the specification of a default Key ID in the track encryption box ('tenc') or by assigning the sample to a Sample Group, the definition of which specifies a Key ID. Common encryption files may contain a mixture of encrypted and unencrypted samples. Playback of unencrypted samples should not be impeded by unavailability of the keys needed to decrypt other samples in the same file or track.</p>
+      <p>Note that if there is already an active Key System CDM and the key storage for that Key System already contains the key associated with the Key ID, there is no need to generate a needkey event.</p>
+    </div>
+    
+
+    <h2 id="examples">8. Examples</h2>
+    <p><i>This section and its subsections are non-normative.</i></p>
+    <p>This section contains example solutions for various use cases using the proposed extensions.
+    These are not the only solutions to these use cases.
+    Video elements are used in the examples, but the same would apply to all <a href="#media-element">media element</a>s.
+    In some cases, such as using synchronous XHR, the examples are simplified to keep the focus on the extensions.
+    </p>
+
+    <h3 id="example-source-and-key-known" class="exampleheader">8.1. Source and Key Known at Page Load (Clear Key Encryption)</h3>
+    <p class="exampledescription">In this simple example, the source file and <a href="#simple-decryption-clear-key">clear-text key</a> are hard-coded in the page.</p>
+    <p class="exampledescription">This example is very simple because it does not care when the key has been added or associating that event with the <code><a href="#dom-update">update()</a></code> call. It also does not handle errors.</p>
+
+    <div class="example">
+      <pre class="code">
+&lt;script&gt;
+  function load() {
+    var video = document.getElementById("video");
+
+    if (!video.<a href="#dom-keys">keys</a>)
+      video.<a href="#dom-keys">keys</a> = video.<a href="#dom-mediakeys">MediaKeys</a>("org.w3.clearkey");
+    if (!video.<a href="#dom-keys">keys</a>)
+      throw "Could not create MediaKeys";
+
+    var keySession = video.<a href="#dom-keys">keys</a>.<a href="#dom-createsession">createSession</a>();
+    if (!keySession)
+      throw "Could not create key session";
+
+    keySession.on<a href="#dom-keymessage">keymessage</a>="handleMessage(event)";
+  }
+
+  function handleMessage(event) {
+    var keySession = event.target;
+
+    var key = new Uint8Array([ ... ]);
+    keySession.<a href="#dom-update">update</a>(key);
+  }
+&lt;/script&gt;
+
+&lt;body onload="load()"&gt;
+  &lt;video src="foo.webm" autoplay id="video"&gt;&lt;/video&gt;
+&lt;/body&gt;</pre>
+    </div>
+
+    <h3 id="example-source-known-but-key-not-known" class="exampleheader">8.2. Source Known but Key Not Known at Page Load</h3>
+    <p class="exampledescription">In this case, the <a href="#initialization-data">Initialization Data</a> is contained in the <a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-data">media data</a>.
+    If this was not the case, <code>handleKeyNeeded()</code> could obtain and provide it instead of getting it from the event.</p>
+
+    <p class="exampledescription">If any asynchronous operation is required to get the key in <code>handleKeyNeeded()</code>, it could be called a second time if the stream is detected as potentially encrypted before an encrypted block/frame is encountered. In this case, applications may want to handle subsequent calls specially to avoid redundant license requests. This is not shown in the examples below.</p>
+
+    <h4 id="example-clear-key" class="exampleheader">8.2.1. Clear Key Encryption</h4>
+    <p class="exampledescription">This solution uses the <a href="#simple-decryption-clear-key">Clear Key</a> <a href="#simple-decryption">Simple Decryption</a>.</p>
+    <p class="exampledescription">As with the previous example, this one is very simple because it does not care when the key has been added or handle errors.</p>
+
+    <div class="example">
+      <pre class="code">
+&lt;script&gt;
+  function handleKeyNeeded(event) {
+    var video = event.target;
+    var initData = event.<a href="#dom-initdata">initData</a>;
+
+    if (!video.<a href="#dom-keys">keys</a>)
+      video.<a href="#dom-keys">keys</a> = video.<a href="#dom-mediakeys">MediaKeys</a>("org.w3.clearkey");
+    if (!video.<a href="#dom-keys">keys</a>)
+      throw "Could not create MediaKeys";
+
+    var keySession = video.<a href="#dom-keys">keys</a>.<a href="#dom-createsession">createSession</a>(mimeType, initData);
+    if (!keySession)
+      throw "Could not create key session";
+
+    keySession.on<a href="#dom-keymessage">keymessage</a>="handleMessage(event)";
+  }
+
+  function handleMessage(event) {
+    var keySession = event.target;
+    var message = event.<a href="#dom-message">message</a>;
+
+    var xmlhttp = new XMLHttpRequest();
+    xmlhttp.open("POST", "http://.../getkey", false);
+    xmlhttp.send(message);
+    var key = new Uint8Array(xmlhttp.response);
+    keySession.<a href="#dom-update">update</a>(key);
+  }
+&lt;/script&gt;
+
+&lt;video src="foo.webm" autoplay on<a href="#dom-needkey">needkey</a>="handleKeyNeeded(event)"&gt;&lt;/video&gt;</pre>
+    </div>
+
+    <h4 id="example-other-cdm" class="exampleheader">8.2.2. Other Content Decryption Module</h4>
+    <p class="exampledescription">This solution uses more advanced decryption from a fictitious <a href="#cdm">content decryption module</a> called Some System.</p>
+
+    <div class="example">
+      <pre class="code">
+&lt;script&gt;
+  function handleKeyNeeded(event) {
+    var video = event.target;
+    var initData = event.<a href="#dom-initdata">initData</a>;
+
+    if (!video.<a href="#dom-keys">keys</a>)
+      video.<a href="#dom-keys">keys</a> = video.<a href="#dom-mediakeys">MediaKeys</a>("com.example.somesystem.1_0");
+    if (!video.<a href="#dom-keys">keys</a>)
+      throw "Could not create MediaKeys";
+
+    var keySession = video.<a href="#dom-keys">keys</a>.<a href="#dom-createsession">createSession</a>(mimeType, initData);
+    if (!keySession)
+      throw "Could not create key session";
+
+    keySession.on<a href="#dom-keymessage">keymessage</a>="licenseRequestReady(event)";
+  }
+
+  function licenseRequestReady(event) {
+    var keySession = event.target;
+    var request = event.<a href="#dom-message">message</a>;
+    if (!request)
+      throw "Could not create license request";
+
+    var xmlhttp = new XMLHttpRequest();
+    xmlhttp.open("POST", "http://.../getkey", false);
+    xmlhttp.send(request);
+    var license = new Uint8Array(xmlhttp.response);
+    keySession.<a href="#dom-update">update</a>(license);
+  }
+&lt;/script&gt;
+
+&lt;video src="foo.webm" autoplay on<a href="#dom-needkey">needkey</a>="handleKeyNeeded(event)"&gt;&lt;/video&gt;</pre>
+    </div>
+
+    <h3 id="examples-selecting-key-system" class="exampleheader">8.3. Selecting a Supported Key System</h3>
+    <p class="exampledescription">Below is an example of detecting supported <a href="#key-system">Key System</a> using the <code><a href="#dom-istypesupported">isTypeSupported()</a></code> and selecting one.
+    </p>
+
+    <div class="example">
+      <pre class="code">
+&lt;script&gt;
+  var keySystem;
+  var licenseUrl;
+
+  function selectKeySystem() {
+    if (<a href="#dom-mediakeys">MediaKeys</a>.<a href="#dom-istypesupported">isTypeSupported</a>("video/webm; codecs='vp8, vorbis'", "com.example.somesystem")) {
+      licenseUrl = "https://license.example.com/getkey"; // OR "https://example.&lt;My Video Site domain&gt;"
+      if (<a href="#dom-mediakeys">MediaKeys</a>.<a href="#dom-istypesupported">isTypeSupported</a>("video/webm; codecs='vp8, vorbis'", "com.example.somesystem.2_0")) {
+        keySystem = "com.example.somesystem.2_0";
+      } else if (<a href="#dom-mediakeys">MediaKeys</a>.<a href="#dom-istypesupported">isTypeSupported</a>("video/webm; codecs='vp8, vorbis'", "com.example.somesystem.1_5")) {
+        keySystem = "com.example.somesystem.1_5";
+      }
+    } else if (<a href="#dom-mediakeys">MediaKeys</a>.<a href="#dom-istypesupported">isTypeSupported</a>("video/webm; codecs='vp8, vorbis'", "foobar")) {
+      licenseUrl = "https://license.foobar.com/request";
+      keySystem = "foobar";
+    } else {
+      throw "Key System not supported";
+    }
+  }
+
+  function handleKeyNeeded(event) {
+    var video = event.target;
+    var initData = event.<a href="#dom-initdata">initData</a>;
+
+    if (!video.<a href="#dom-keys">keys</a>) {
+      selectKeySystem();
+      video.<a href="#dom-keys">keys</a> = video.<a href="#dom-mediakeys">MediaKeys</a>(keySystem);
+    }
+    if (!video.<a href="#dom-keys">keys</a>)
+      throw "Could not create MediaKeys";
+
+    var keySession = video.<a href="#dom-keys">keys</a>.<a href="#dom-createsession">createSession</a>(mimeType, initData);
+    if (!keySession)
+      throw "Could not create key session";
+
+    keySession.on<a href="#dom-keymessage">keymessage</a>="licenseRequestReady(event)";
+  }
+  
+  function licenseRequestReady(event) {
+    var keySession = event.target;
+    var request = event.<a href="#dom-message">message</a>;
+    if (!request)
+      throw "Could not create license request";
+
+    var xmlhttp = new XMLHttpRequest();
+    xmlhttp.open("POST", licenseUrl, false);
+    xmlhttp.send(request);
+    var license = new Uint8Array(xmlhttp.response);
+    keySession.<a href="#dom-update">update</a>(license);
+  }
+&lt;/script&gt;
+
+&lt;video src="foo.webm" autoplay on<a href="#dom-needkey">needkey</a>="handleKeyNeeded(event)"&gt;&lt;/video&gt;</pre>
+    </div>
+
+    <h3 id="example-using-all-events" class="exampleheader">8.4. Using All Events</h3>
+    <p class="exampledescription">This is a more complete example showing all events being used along with asynchronous XHR.</p>
+    <p class="exampledescription">Note that <code>handleKeyMessage</code> could be called multiple times, including in response to the <code><a href="#dom-update">update()</a></code> call if multiple round trips are required and for any other reason the Key System might need to send a message.</p>
+
+    <div class="example">
+      <pre class="code">
+&lt;script&gt;
+  var keySystem;
+  var licenseUrl;
+
+  function handleMessageResponse() {
+    var license = new Uint8Array(xmlhttp.response);
+    this.keySession.<a href="#dom-update">update</a>(license);
+  }
+  
+  function sendMessage(message, keySession) {
+    xmlhttp = new XMLHttpRequest();
+    xmlhttp.keySession = keySession;
+    xmlhttp.onreadystatechange = handleMessageResponse;
+    xmlhttp.open("POST", licenseUrl, true);
+    xmlhttp.send(message);
+  }
+
+  function handleKeyMessage(event) {
+    var keySession = event.target;
+    var message = event.<a href="#dom-message">message</a>;
+    if (!message)
+      throw "Invalid key message";
+  
+    sendMessage(message, keySession);
+  }
+
+  function handleKeyComplete(event) {
+    // Do some bookkeeping with event.target.<a href="#dom-sessionid">sessionId</a> if necessary.
+  }
+
+  function handleKeyError(event) {
+    // Report event.target.error.<a href="#dom-code">code</a> and event.target.error.<a href="#dom-systemcode">systemCode</a>,
+    // and do some bookkeeping with event.target.<a href="#dom-sessionid">sessionId</a> if necessary.
+  }
+
+  function handleKeyNeeded(event) {
+    var video = event.target;
+    var initData = event.<a href="#dom-initdata">initData</a>;
+
+    if (!video.<a href="#dom-keys">keys</a>) {
+      selectKeySystem();  // See previous example for implementation.
+      video.<a href="#dom-keys">keys</a> = video.<a href="#dom-mediakeys">MediaKeys</a>(keySystem);
+    }
+    if (!video.<a href="#dom-keys">keys</a>)
+      throw "Could not create MediaKeys";
+
+    var keySession = video.<a href="#dom-keys">keys</a>.<a href="#dom-createsession">createSession</a>(mimeType, initData);
+    if (!keySession)
+      throw "Could not create key session";
+
+    keySession.on<a href="#dom-keymessage">keymessage</a>="handleKeyMessage(event)";
+    keySession.on<a href="#dom-keyadded">keyadded</a>="handleKeyComplete(event)";
+    keySession.on<a href="#dom-keyerror">keyerror</a>="handleKeyError(event)";
+  }
+&lt;/script&gt;
+
+&lt;video src="foo.webm" autoplay on<a href="#dom-needkey">needkey</a>="handleKeyNeeded(event)"&gt;&lt;/video&gt;</pre>
+    </div>
+
+
+    <h2 id="faq">9. FAQ</h2>
+    <p><i>This section and its subsections are non-normative.</i></p>
+
+    <h3 id="faq-use-cases">9.1. Use Cases</h3>
+
+    <h4 id="faq-what-use-cases" class="faqquestion">What use cases does this support?</h4>
+    <p class="faqanswer">Everything from user-generated content to be shared with family (user is not an adversary) to online radio to feature-length movies.</p>
+
+    <h4 id="faq-adaptive-streaming" class="faqquestion">Is this proposal compatible with adaptive streaming?</h4>
+    <p class="faqanswer">Yes, this proposal is compatible with both "Type 1" and "Type 3" <a href="http://www.w3.org/2011/webtv/wiki/MPTF/HTML_adaptive_calls">adaptive streaming modes</a> as defined by the <a href="http://www.w3.org/2011/webtv/">W3C Web &amp; TV Interest Group</a>.</p>
+    <ul>
+      <li>If adaptive streaming is handled within the user agent (Type 1), the adaptive implementation can expose the events and methods needed to provide key(s) for the streams via the APIs in this proposal.</li>
+      <li>If adaptive streaming is handled in the application/JavaScript (Type 3), behavior should be very similar to the non-adaptive case.
+      For example, the <a href="http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html">Media Source Extensions</a> allow the application to provide a dynamic <code>src</code>, which could be encrypted and handled just like a normal stream.
+      </li>
+    </ul>
+
+    <h4 id="faq-key-rotation" class="faqquestion">Is key rotation supported?</h4>
+    <p class="faqanswer">Yes.</p>
+
+    <h4 id="faq-encrypt-captions" class="faqquestion">Can I encrypt captions / &lt;track&gt; elements?</h4>
+    <p class="faqanswer">No, this proposal only supports decrypting audio and video that are part of the <a href="http://www.w3.org/TR/html5/embedded-content-0.html#media-data">media data</a>.</p>
+
+    <h4 id="sourceelement" class="faqquestion">Can I let the user agent select the appropriate CDM using <code>&lt;source&gt;</code> elements?</h4>
+    <p class="faqanswer">Yes, using the <code><a href="#dom-sourcekeysystem">keySystem</a></code> attribute of the <code><a href="#dom-htmlsourceelement">HTMLSourceElement</a></code>.
+    When used with <code><a href="http://www.w3.org/TR/html5/embedded-content-0.html#attr-source-type">type</a></code> attribute, this will select the first <code>&lt;source&gt;</code> element (container, codec, and <a href="#key-system">Key System</a>) that the user agent might support.
+    </p>
+
+    <h4 id="faq-heartbeat" class="faqquestion">Is a heartbeat supported?</h4>
+    <p class="faqanswer">Yes.</p>
+    <p class="faqanswer">Heartbeat is a mode of operation where the <a href="#cdm">Content Decryption Module</a> requires to receive an explicit heartbeat message from its server on a regular basis, otherwise decryption is blocked.
+    This enables use-cases requiring strict online control of access to the content.
+    Heartbeat must be supported by the CDM and is implemented in this model by supplying an expiration time or valid duration in the license provided to the CDM.
+    Before expiry of this license, the CDM must trigger a new message exchange to obtain an updated license.
+    </p>
+
+    <h3 id="faq-use">9.2. Use</h3>
+
+    <h4 id="faq-send-a-token" class="faqquestion">Can I send a token for the signed-in user with the license request?</h4>
+    <p class="faqanswer">Yes. The application can add this to the license request (sent via <code>XMLHttpRequest</code> in the <a href="#examples">examples</a>) or send it to the <a href="#cdm">CDM</a> via <code><a href="#dom-createsession">createSession()</a></code> to be included in the license request.</p>
+
+    <h4 id="faq-resume-playback" class="faqquestion">How do I resume playback after receiving the <code><a href="#dom-needkey">needkey</a></code> event in the <a href="#algorithms-enrypted-block">Encrypted Block Encountered algorithm</a>?</h4>
+    <p class="faqanswer">Assuming there are no other issues, playback will resume when the needed key is provided by <code><a href="#dom-update">update()</a></code> and processed.</p>
+
+    <h4 id="faq-multiple-cdms" class="faqquestion">Can an application use multiple content protection providers / Key Systems?</h4>
+    <p class="faqanswer">Yes, this will likely be necessary to support all or a majority of user agents.
+    An application could also use different <a href="#key-system">Key Systems</a> on a single user agent for different purposes.</p>
+
+    <h4 id="faq-multiple-key-systems" class="faqquestion">Can an <code><a href="#dom-htmlmediaelement">HTMLMediaElement</a></code> use multiple <a href="#key-system">Key System</a>s at the same time?</h4>
+    <p class="faqanswer">No.</p>
+
+    <h4 id="faq-add-cdm" class="faqquestion">How do I add support for a CDM to my application?</h4>
+    <p id="faq-cdm-library" class="faqanswer">We envision <a href="#cdm">CDM</a> providers creating JavaScript libraries that application developers can include. <code><a href="#dom-istypesupported">isTypeSupported()</a></code> can then be used to select from supported libraries.</p>
+
+    <h4 id="faq-provider-capabilities" class="faqquestion">How do I determine if the UA supports specific capabilities for a given provider?</h4>
+    <p class="faqanswer">This is vendor-/<a href="#key-system">Key System</a>-specific.</p>
+    <p class="faqanswer">Obtaining this information could take time and is open-ended, so it is not appropriate for <code><a href="#dom-istypesupported">isTypeSupported()</a></code>.
+    There is also no way for <code><a href="#dom-istypesupported">isTypeSupported()</a></code> to attest to capabilities anyway.
+    </p>
+
+    <h4 id="faq-license-url" class="faqquestion">What is a license URL (<code>licenseUrl</code>) in the examples?</h4>
+    <p class="faqanswer">This is the URL for a server capable of providing the key for the stream, usually using the <a href="#initialization-data">Initialization Data</a> and often after verifying the requesting user.
+    The URL is application- and/or <a href="#key-system">Key System</a>-specific and may be a content provider or a Key System provider depending on the solution.</p>
+
+    <h4 id="faq-too-complex" class="faqquestion">This is too complex and hard to use.</h4>
+    <p class="faqanswer">That's not a question, but we'll try to address it anyway.
+    As shown in the <a href="#examples">examples</a>, the basic use cases are reasonably simple and only require a little setup to get the key and provide it to the user agent.
+    We believe most small content sites can add basic protection to their applications with minimal efforts.</p>
+    <p class="faqanswer">The more complex cases, such as fast time to first frame and various license management algorithms, require more complex code, but professional-strength content protection is complex and that is to be expected.
+    Professional-strength content protection requires server components and working with one or more content protection vendors, so this isn't really any more complex.
+    In fact, if you implement a few solutions, it will work on any browser-based platform, avoiding the need for per-platform solutions on both the server and client.
+    The fixed set of interfaces may even lead to more consistent patterns and behavior across various solutions.
+    It is generally the large content providers that have more complex requirements, and we believe they will have the appropriate resources to implement applications that meet their requirements.
+    </p>
+    <p class="faqanswer">Providers of <a href="#cdm">content decryption modules</a> will need to provide detailed specifications for actions and events to guide content providers in designing the algorithms in their applications.
+    They can also provide a <a href="#faq-cdm-library">JavaScript libraries</a> for their solution that can be integrated into any application.
+    An application would then basically select a solution and delegate a lot of the work to the appropriate library.</p>
+
+    <h3 id="faq-api">9.3. API</h3>
+
+    <h4 id="faq-decrypt-algm" class="faqquestion">How is the decryption algorithm specified?</h4>
+    <p class="faqanswer">This is container specific. A container may standardize on a specific algorithm (i.e. AES-128) and/or allow it to be specified. The user agent must know and/or detect the appropriate algorithm to use with the key provided by this API.</p>
+
+    <h4 id="faq-advantage-key-exchange" class="faqquestion">What are the advantages of doing license/key exchange in the application?</h4>
+    <p class="faqanswer">Advantages include:</p>
+    <ul>
+      <li>
+<a href="#simple-decryption">Simple Decryption</a> works in the same way as more advanced solutions and without additional APIs.</li>
+      <li>The user agent is not responsible for deciding which decryption mechanism to use.</li>
+      <li>The application has full control (i.e. of deciding what streams to offer) and does not need to rely on errors from (or a detailed API to) the <a href="#cdm">CDM</a>.</li>
+      <li>The application can manage its own license protocol, authentication refresh, key rotation etc. without relying on changes to or specific use cases being implemented in each user agent's CDM (as long as the appropriate primitives are available in the CDM).</li>
+      <li>Error handling can be tailored to the application without needing to expose status information and failure conditions from the CDM through the API.</li>
+      <li>The content provider can decide whether and what to proxy to the (potentially third-party) license server without client modifications.</li>
+      <li>Reduces the complexity and size of the CDM.</li>
+    </ul>
+
+    <h4 id="faq-key-system-mime-type" class="faqquestion">Why isn't the <a href="#key-system">Key System</a> part of the MIME type (like codecs)?</h4>
+    <p class="faqanswer">In many cases (especially the direction the content providers and standards are moving), the stream is not specific to any one Key System or provider. Multiple Key Systems could be used to decrypt the same generic stream. Thus, the <a href="#key-system">Key System</a> is not information about the file and should not be part of the MIME type.</p>
+    <p class="faqanswer">One could argue that the encryption algorithm (e.g. AES-128) and configuration should be in the MIME type. That is not required for this proposal, so it is not addressed here.</p>
+
+    <h4 id="faq-why-additional-events" class="faqquestion">Why do we need additional events?</h4>
+    <p class="faqanswer">While many use case could be implemented without an additional event (by requiring the app to provide all the information up front), some use cases may be better handled by an event.</p>
+
+    <h4 id="faq-why-new-error-code" class="faqquestion">Why do we need a new <code><a href="#dom-mediaerror">MediaError</a></code> code?</h4>
+    <p class="faqanswer">Without a new error code (<code><a href="#dom-media_err_encrypted">MEDIA_ERR_ENCRYPTED</a></code>), it is not possible for user agents to clearly indicate to an application that playback failed because the content was encrypted and user agents will likely need to fire a <code>MEDIA_ERR_DECODE</code> or <code>MEDIA_ERR_SRC_NOT_SUPPORTED</code>, which would be confusing.</p>
+
+    <h4 id="faq-error-break-apps" class="faqquestion">Will adding a new error code to <code><a href="#dom-mediaerror">MediaError</a></code> break existing applications?</h4>
+    <p class="faqanswer">Applications that are not aware of the new error code (<code><a href="#dom-media_err_encrypted">MEDIA_ERR_ENCRYPTED</a></code>) may not correctly handle it, but they should still be able to detect that an error has occurred because a) an error event is fired and b) <var title="">media</var> . <code title="dom-media-error"><code><a href="http://www.w3.org/TR/html5/embedded-content-0.html#mediaerror">error</a></code></code> is not null.</p>
+
+    <h4 id="faq-response-needkey" class="faqquestion">What happens if a response to the <code><a href="#dom-needkey">needkey</a></code> event from a <a href="#algorithms-encrypted-stream">encountering a potentially encrypted stream</a> is not received before <a href="#algorithms-enrypted-block">encountering an encrypted block</a>?</h4>
+    <p class="faqanswer">The <a href="#algorithms-enrypted-block">Encrypted Block Encountered algorithm</a> will proceed as normal.
+    If no appropriate key has been provided, a second <code><a href="#dom-needkey">needkey</a></code> event will be fired and decoding will stop.
+    </p>
+
+    <h4 id="faq-same-needkey" class="faqquestion">The same <code><a href="#dom-needkey">needkey</a></code> event with the same attributes is fired for both <a href="#algorithms-enrypted-block">Encrypted Block Encountered</a> and <a href="#algorithms-encrypted-stream">Potentially Encrypted Stream Encountered</a>. How can an application distinguish between the two?</h4>
+    <p class="faqanswer">The same event was used intentionally to reduce the complexity of applications. Ideally, they would not need to know.</p>
+
+    <h4 id="faq-same-initdata-update" class="faqquestion">What if a key/license for the same <a href="#initialization-data">Initialization Data</a> (i.e. key ID) is provided more than once to <code><a href="#dom-update">update()</a></code>?</h4>
+    <p class="faqanswer">The CDM will replace previous entries, updating the overall key ordering to reflect that this key ID was most recently added.
+    In other words, simply replacing the existing key data is not sufficient.
+    The exact algorithm is covered in <code><a href="#dom-update">update()</a></code>.
+    </p>
+
+    <h3 id="faq-source">9.4. Source, Containers, and Streams</h3>
+
+    <h4 id="faq-container-codec-support" class="faqquestion">What containers and codecs are supported?</h4>
+    <p class="faqanswer">Containers and codecs are not specified. A user agent may support decryption of whichever container and codec combination(s) it wishes.</p>
+    <p class="faqanswer">If a user agent support decryption of a container/codec combination (as reported by <code><a href="#dom-istypesupported">isTypeSupported()</a></code>), it must also support <a href="#simple-decryption">Simple Decryption</a> of that combination.</p>
+
+    <h4 id="faq-container-code-indicate" class="faqquestion">What if a container/codec does not support indicating the stream or a frame/block is encrypted?</h4>
+    <p class="faqanswer">The application must use <code><a href="#dom-update">update()</a></code> to indicate the stream is encrypted and provide the key before decoding starts.</p>
+
+    <h4 id="faq-must-init-data" class="faqquestion">Must the container provide Initialization Data or a content key ID?</h4>
+    <p class="faqanswer">This is ideal, but the API would also support the application sending the <a href="#initialization-data">Initialization Data</a> or ID directly to the server or providing it to the <a href="#cdm">CDM</a> via <code><a href="#dom-createsession">createSession()</a></code>.</p>
+
+    <h4 id="faq-not-support-ids" class="faqquestion">What if a container/codec does not support key IDs or bit(s)?</h4>
+    <p class="faqanswer">The application will need to use some other mechanism to select the appropriate key for the content.
+    The user agent will only be able to use one key at a time.
+    <a href="#faq-key-rotation">Key rotation</a> will be much more complex or impossible.
+    </p>
+
+    <h4 id="faq-adaptive-streaming-multiple-keys" class="faqquestion">Can I use different keys for each stream (<a href="#faq-adaptive-streaming">adaptive streaming</a>)?</h4>
+    <p class="faqanswer">Yes, though you may want to consider the complexity and performance drawbacks. For the best user experience, you will want to provide keys for the streams to the user agent before the switch.</p>
+
+    <h4 id="faq-elements-encrypted" class="faqquestion">What elements of the source are encrypted?</h4>
+    <p class="faqanswer">This depends on the container/codec being used. This proposal should support all cases, including entirely encrypted streams, individual frames encrypted separately, groups of frames encrypted, and portions of frames encrypted.
+    If not all blocks or frames are encrypted, the user agent should be able to easily detect this, either based on an indication in the container or the block/frame.</p>
+
+    <h4 id="faq-all-blocks-encrypted" class="faqquestion">Must all blocks/frames in a stream be encrypted?</h4>
+    <p class="faqanswer">No, subject to container/codec limitations.</p>
+
+    <h4 id="faq-ciphers-parameters" class="faqquestion">What cipher and parameters should be used for decryption?</h4>
+    <p class="faqanswer">The cipher and parameters should be implicit in or specified by the container. If some are optional, the application must know what is supported by the <a href="#cdm">CDM</a>.</p>
+
+    <h4 id="faq-simple-decryption" class="faqquestion">What cipher and parameters should be used for <a href="#simple-decryption">Simple Decryption</a>? Which must the user agent support?</h4>
+    <p class="faqanswer">As in the above question, these are either implicit in or specified by the container. User agents must support any default or baseline ciphers and parameters in the container specification. Practically, user agents should support all ciphers and parameters commonly used with the container.</p>
+
+    <h3 id="faq-protection">9.5. Content and Key Protection</h3>
+
+    <h4 id="faq-ensure-protected" class="faqquestion">Can I ensure the content key is protected without working with a content protection provider?</h4>
+    <p class="faqanswer">No. Protecting the content key would require that the browser's media stack have some secret that cannot easily be obtained. This is the type of thing DRM solutions provide. Establishing a standard mechanism to support this is beyond the scope of HTML5 standards and should be deferred to specific user agent solutions. In addition, it is not something that fully open source browsers could natively support.</p>
+    <p class="faqanswer">Content protected using this proposal without a content protection provider is still more secure and a higher barrier than providing an unencrypted file over HTTP or HTTPS. We would also argue that it is no less secure than encrypted HLS. For long streams, <a href="#faq-key-rotation">key rotation</a> can provide additional protection.</p>
+    <p class="faqanswer">It is also possible to extend the proposed specification in the future to support a more robust basic case <strong>without changing the API</strong>.</p>
+
+    <h4 id="faq-multiple-cdm-support" class="faqquestion">Can a user agent support multiple content protection providers?</h4>
+    <p class="faqanswer">Yes. The application will query the user agent's capabilities and select the <a href="#key-system">Key System</a> to use.</p>
+
+    <h4 id="faq-protect-compressed" class="faqquestion">Can a user agent protect the compressed content?</h4>
+    <p class="faqanswer">Yes, this proposal naturally supports such protection.</p>
+
+    <h4 id="faq-protect-rendering" class="faqquestion">Can a user agent protect the rendering path or protect the uncompressed content after decoding?</h4>
+    <p class="faqanswer">Yes, a user agent could use platform-specific capabilities to protect the rendering path.
+    </p>
+
+
+    <h2 id="revision-history">10. Revision History</h2>
+    <table>
+      <thead>
+        <tr>
+          <th>Version</th>
+          <th>Comment</th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <td>16 August 2012</td>
+          <td>Converted to the object-oriented API.</td>
+        </tr>
+        <tr>
+          <td><a href="http://dvcs.w3.org/hg/html-media/raw-file/eme-v0.1b/encrypted-media/encrypted-media.html">0.1b</a></td>
+          <td>Last non-object-oriented revision.</td>
+        </tr>
+        <tr>
+          <td><a href="http://dvcs.w3.org/hg/html-media/raw-file/eme-v0.1a/encrypted-media/encrypted-media.html">0.1a</a></td>
+          <td>Corrects minor mistakes in 0.1.</td>
+        </tr>
+        <tr>
+          <td><a href="http://dvcs.w3.org/hg/html-media/raw-file/eme-v0.1/encrypted-media/encrypted-media.html">0.1</a></td>
+          <td>Initial Proposal</td>
+        </tr>
+      </tbody>
+    </table>
+  </body>
+</html>
--- a/encrypted-media/encrypted-media.html	Mon Jan 14 18:19:51 2013 -0800
+++ b/encrypted-media/encrypted-media.html	Mon Jan 14 18:24:13 2013 -0800
@@ -4,7 +4,7 @@
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     <title>Encrypted Media Extensions</title>
     <link rel="stylesheet" href="video-working-draft.css">
-    <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-WD">
+    <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/w3c-ed.css">
     <style type="text/css">
       div.nonnormative { color: green; margin: 2em 0 2em 0em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
       .nonnormative:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This section is non-normative.'; color: black; font-style: italic; border: solid 2px; background: white; padding: 0 0.25em; }
@@ -19,10 +19,10 @@
     <div class="head">
       <p><a href="http://www.w3.org/"><img src="http://www.w3.org/Icons/w3c_home" alt="W3C" width="72" height="48"></a></p>
       <h1>Encrypted Media Extensions</h1>
-      <h2 id="draft-date">W3C Working Draft 24 January 2013</h2>
+      <h2 id="draft-date">W3C Editor's Draft 14 January 2013</h2>
       <dl>
         <dt>This Version:</dt>
-        <dd><a href="http://www.w3.org/TR/2013/WD-encrypted-media-20130124/">http://www.w3.org/TR/2013/WD-encrypted-media-20130124/</a></dd>
+        <dd><a href="http://dvcs.w3.org/hg/html-media/raw-file/tip/encrypted-media/encrypted-media.html">http://dvcs.w3.org/hg/html-media/raw-file/tip/encrypted-media/encrypted-media.html</a></dd>
         <dt>Latest Published Version:</dt>
         <dd><a href="http://www.w3.org/TR/encrypted-media/">http://www.w3.org/TR/encrypted-media/</a></dd>
         <dt>Latest editor's draft:</dt>
--- a/encrypted-media/encrypted-media.xml	Mon Jan 14 18:19:51 2013 -0800
+++ b/encrypted-media/encrypted-media.xml	Mon Jan 14 18:24:13 2013 -0800
@@ -3,7 +3,7 @@
   <head>
     <title>Encrypted Media Extensions</title>
     <link rel="stylesheet" href="video-working-draft.css" />
-    <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-WD"/>
+    <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/w3c-ed.css"/>
     <style type="text/css">
       div.nonnormative { color: green; margin: 2em 0 2em 0em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
       .nonnormative:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This section is non-normative.'; color: black; font-style: italic; border: solid 2px; background: white; padding: 0 0.25em; }
@@ -18,10 +18,10 @@
     <div class="head">
       <p><a href="http://www.w3.org/"><img src="http://www.w3.org/Icons/w3c_home" alt="W3C" width="72" height="48" /></a></p>
       <h1>Encrypted Media Extensions</h1>
-      <h2 id="draft-date">W3C Working Draft 24 January 2013</h2>
+      <h2 id="draft-date">W3C Editor's Draft 14 January 2013</h2>
       <dl>
         <dt>This Version:</dt>
-        <dd><a href="http://www.w3.org/TR/2013/WD-encrypted-media-20130124/">http://www.w3.org/TR/2013/WD-encrypted-media-20130124/</a></dd>
+        <dd><a href="http://dvcs.w3.org/hg/html-media/raw-file/tip/encrypted-media/encrypted-media.html">http://dvcs.w3.org/hg/html-media/raw-file/tip/encrypted-media/encrypted-media.html</a></dd>
         <dt>Latest Published Version:</dt>
         <dd><a href="http://www.w3.org/TR/encrypted-media/">http://www.w3.org/TR/encrypted-media/</a></dd>
         <dt>Latest editor's draft:</dt>
--- a/encrypted-media/main.css	Mon Jan 14 18:19:51 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/* Style for a public "Working Draft" */
-
-/*
-   Copyright 1997-2003 W3C (MIT, ERCIM, Keio). All Rights Reserved.
-   The following software licensing rules apply:
-   http://www.w3.org/Consortium/Legal/copyright-software */
-
-/* $Id: base.css,v 1.25 2006/04/18 08:42:53 bbos Exp $ */
-
-body {
-  padding: 2em 1em 2em 70px;
-  margin: 0;
-  font-family: sans-serif;
-  color: black;
-  background: white;
-  background-position: top left;
-  background-attachment: fixed;
-  background-repeat: no-repeat;
-}
-:link { color: #00C; background: transparent }
-:visited { color: #609; background: transparent }
-a:active { color: #C00; background: transparent }
-
-a:link img, a:visited img { border-style: none } /* no border on img links */
-
-a img { color: white; }        /* trick to hide the border in Netscape 4 */
-@media all {                   /* hide the next rule from Netscape 4 */
-  a img { color: inherit; }    /* undo the color change above */
-}
-
-th, td { /* ns 4 */
-  font-family: sans-serif;
-}
-
-h1, h2, h3, h4, h5, h6 { text-align: left }
-/* background should be transparent, but WebTV has a bug */
-h1, h2, h3 { color: #005A9C; background: white }
-h1 { font: 170% sans-serif }
-h2 { font: 140% sans-serif }
-h3 { font: 120% sans-serif }
-h4 { font: bold 100% sans-serif }
-h5 { font: italic 100% sans-serif }
-h6 { font: small-caps 100% sans-serif }
-
-.hide { display: none }
-
-div.head { margin-bottom: 1em }
-div.head h1 { margin-top: 2em; clear: both }
-div.head table { margin-left: 2em; margin-top: 2em }
-
-p.copyright { font-size: small }
-p.copyright small { font-size: small }
-
-@media screen {  /* hide from IE3 */
-a[href]:hover { background: #ffa }
-}
-
-pre { margin-left: 2em }
-/*
-p {
-  margin-top: 0.6em;
-  margin-bottom: 0.6em;
-}
-*/
-dt, dd { margin-top: 0; margin-bottom: 0 } /* opera 3.50 */
-dt { font-weight: bold }
-
-pre, code { font-family: monospace } /* navigator 4 requires this */
-
-ul.toc, ol.toc {
-    list-style: disc;/* Mac NS has problem with 'none' */
-  list-style: none;
-}
-
-@media aural {  
-  h1, h2, h3 { stress: 20; richness: 90 }
-  .hide { speak: none }
-  p.copyright { volume: x-soft; speech-rate: x-fast }
-  dt { pause-before: 20% }
-  pre { speak-punctuation: code } 
-}