Replace SourceBufferList.remove() with MediaSource.removeSourceBuffer()
authorAaron Colwell <acolwell@google.com>
Tue, 17 Jul 2012 14:07:12 -0700
changeset 17 32d0ee562168
parent 16 b499a199e427
child 18 ab36e8e882c6
Replace SourceBufferList.remove() with MediaSource.removeSourceBuffer()

mailing list discussion: http://lists.w3.org/Archives/Public/public-html-media/2012Jul/0020.html
bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=17082
media-source/media-source.html
media-source/media-source.xml
media-source/spec-html.xsl
--- a/media-source/media-source.html	Mon Jul 02 16:05:53 2012 -0700
+++ b/media-source/media-source.html	Tue Jul 17 14:07:12 2012 -0700
@@ -291,7 +291,7 @@
 
 
     <h3 id="source-buffer-remove">2.10. Removing Source Buffers</h3>
-    <p>Removing a <code><a href="#dom-sourcebuffer">SourceBuffer</a></code> with <code><a href="#dom-remove">remove()</a></code> releases all resources associated with the object. This includes destroying the all the segment data, <a href="#track-buffer">track buffers</a>, and decoders. The media element will also remove the appropriate tracks from <code><a href="http://dev.w3.org/html5/spec/media-elements.html#dom-media-audiotracks">audioTracks</a></code>, <code><a href="http://dev.w3.org/html5/spec/media-elements.html#dom-media-videotracks">videoTracks</a></code>,  &amp; <code><a href="http://dev.w3.org/html5/spec/media-elements.html#dom-media-texttracks">textTracks</a></code> and fire the necessary <code><a href="http://dev.w3.org/html5/spec/media-elements.html#handler-tracklist-onchange">change</a></code> events. Playback may become degraded or stop if the currently selected <code><a href="http://dev.w3.org/html5/spec/media-elements.html#videotrack">VideoTrack</a></code> or the only enabled <code><a href="http://dev.w3.org/html5/spec/media-elements.html#audiotrack">AudioTracks</a></code> are removed.</p>
+    <p>Removing a <code><a href="#dom-sourcebuffer">SourceBuffer</a></code> with <code><a href="#dom-removeSourceBuffer">removeSourceBuffer()</a></code> releases all resources associated with the object. This includes destroying the all the segment data, <a href="#track-buffer">track buffers</a>, and decoders. The media element will also remove the appropriate tracks from <code><a href="http://dev.w3.org/html5/spec/media-elements.html#dom-media-audiotracks">audioTracks</a></code>, <code><a href="http://dev.w3.org/html5/spec/media-elements.html#dom-media-videotracks">videoTracks</a></code>,  &amp; <code><a href="http://dev.w3.org/html5/spec/media-elements.html#dom-media-texttracks">textTracks</a></code> and fire the necessary <code><a href="http://dev.w3.org/html5/spec/media-elements.html#handler-tracklist-onchange">change</a></code> events. Playback may become degraded or stop if the currently selected <code><a href="http://dev.w3.org/html5/spec/media-elements.html#videotrack">VideoTrack</a></code> or the only enabled <code><a href="http://dev.w3.org/html5/spec/media-elements.html#audiotrack">AudioTracks</a></code> are removed.</p>
 
     <h2 id="mediasource">3. MediaSource Object</h2>
     <p>The MediaSource object represents a source of media data for an HTMLMediaElement. It keeps track of the <code><a href="#dom-readyState">readyState</a></code> for this source as well as a list of <code><a href="#dom-sourcebuffer">SourceBuffer</a></code> objects that can be used to add media data to the presentation. MediaSource objects are created by the web application and then attached to an HTMLMediaElement. The application uses the <code><a href="#dom-sourcebuffer">SourceBuffer</a></code> objects in <code><a href="#dom-sourcebuffers">sourceBuffers</a></code> to add media data to this source. The HTMLMediaElement fetches this media data from the <code><a href="#dom-mediasource">MediaSource</a></code> object when it is needed during playback.</p>
@@ -305,8 +305,8 @@
   // Subset of sourceBuffers that provide data for the selected/enabled tracks.
   readonly attribute <a href="#dom-sourcebufferlist">SourceBufferList</a> <a href="#dom-activesourcebuffers">activeSourceBuffers</a>;
 
-  // Adds another source buffer.
   <a href="#dom-sourcebuffer">SourceBuffer</a> <a href="#dom-addsourcebuffer">addSourceBuffer</a>(DOMString type);
+  void <a href="#dom-removesourcebuffer">removeSourceBuffer</a>(<a href="#dom-sourcebuffer">SourceBuffer</a> sourceBuffer);
 
   enum State { "closed", "open", "ended" };
   readonly attribute State <a href="#dom-readystate">readyState</a>;
@@ -331,6 +331,17 @@
       <li>Add the new object to <code><a href="#dom-sourcebuffers">sourceBuffers</a></code> and fire a <code><a href="#dom-addsourcebuffer">addsourcebuffer</a></code> on that object.</li>
       <li>Return the new object to the caller.</li>
     </ol>
+    <p>The <dfn id="dom-removesourcebuffer"><code>removeSourceBuffer(sourceBuffer)</code></dfn> method must run the following steps:</p>
+    <ol>
+      <li>If <var title="true">sourceBuffer</var> is null then 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.</li>
+      <li>If <code><a href="#dom-sourcebuffers">sourceBuffers</a></code> is empty then 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> exception and abort these steps.</li>
+      <li>If <var title="true">sourceBuffer</var> specifies an object that is not in <code><a href="#dom-sourcebuffers">sourceBuffers</a></code> then throw a <code><a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-domexception-not_found_err">NOT_FOUND_ERR</a></code> exception and abort these steps.</li>
+      <li>Remove track information from <code><a href="http://dev.w3.org/html5/spec/media-elements.html#dom-media-audiotracks">audioTracks</a></code>, <code><a href="http://dev.w3.org/html5/spec/media-elements.html#dom-media-videotracks">videoTracks</a></code>, and <code><a href="http://dev.w3.org/html5/spec/media-elements.html#dom-media-texttracks">textTracks</a></code> for all tracks associated with <var title="true">sourceBuffer</var> and fire a simple event named <code><a href="http://dev.w3.org/html5/spec/media-elements.html#handler-tracklist-onchange">change</a></code> on the modified lists.</li>
+      <li>If <var title="true">sourceBuffer</var> is in <code><a href="#dom-activesourcebuffers">activeSourceBuffers</a></code>, then remove it from that list and fire a <code><a href="#dom-removesourcebuffer">removesourcebuffer</a></code> event on that object.</li>
+      <li>Remove <var title="true">sourceBuffer</var> from <code><a href="#dom-sourcebuffers">sourceBuffers</a></code> and fire a <code><a href="#dom-removesourcebuffer">removesourcebuffer</a></code> event on that object.</li>
+      <li>Destroy all resources for <var title="true">sourceBuffer</var>.</li>
+    </ol>
+
 
     <p>The <dfn id="dom-readystate"><code>readyState</code></dfn> attribute indicates the current state of the <code><a href="#dom-mediasource">MediaSource</a></code> object. It can have the following values:</p>
     <dl>
@@ -647,13 +658,12 @@
     </ol>
 
         <h2 id="sourcebufferlist">5. SourceBufferList Object</h2>
-    <p>SourceBufferList is a simple container object for <code><a href="#dom-sourcebuffer">SourceBuffer</a></code> objects. It provides a read-only array accessor, fires events when the list is modified, and provides a way to remove SourceBuffer objects from the list.</p>
+    <p>SourceBufferList is a simple container object for <code><a href="#dom-sourcebuffer">SourceBuffer</a></code> objects. It provides a read-only array accessor and fires events when the list is modified.</p>
 
     <pre class="idl">
 interface <dfn id="dom-sourcebufferlist">SourceBufferList</dfn> : EventTarget {
   readonly attribute unsigned long <a href="#dom-length">length</a>;
   <a href="#dom-getter">getter</a> <a href="#dom-sourcebuffer">SourceBuffer</a> (unsigned long index);
-  void <a href="#dom-remove">remove</a>(<a href="#dom-sourcebuffer">SourceBuffer</a> buffer);
 };
     </pre>
     <h3 id="sourcebufferlist-methods">5.1. Methods and Attributes</h3>
@@ -663,15 +673,6 @@
       <li>If <var title="true">index</var> is greater than or equal to the <code><a href="#dom-length">length</a></code> attribute then return undefined and abort these steps.</li>
       <li>Return the <var title="true">index</var>'th <code><a href="#dom-sourcebuffer">SourceBuffer</a></code> object in the list.</li>
     </ol>
-    <p>The <dfn id="dom-remove"><code>remove(buffer)</code></dfn> method must run the following steps:</p>
-    <ol>
-      <li>If <var title="true">buffer</var> is null then 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.</li>
-      <li>If the list is empty then 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> exception and abort these steps.</li>
-      <li>If <var title="true">buffer</var> specifies an object that is not in this list then throw a <code><a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-domexception-not_found_err">NOT_FOUND_ERR</a></code> exception and abort these steps.</li>
-      <li>Remove track information from <code><a href="http://dev.w3.org/html5/spec/media-elements.html#dom-media-audiotracks">audioTracks</a></code>, <code><a href="http://dev.w3.org/html5/spec/media-elements.html#dom-media-videotracks">videoTracks</a></code>, and <code><a href="http://dev.w3.org/html5/spec/media-elements.html#dom-media-texttracks">textTracks</a></code> for all tracks associated with <var title="true">buffer</var> and fire a simple event named <code><a href="http://dev.w3.org/html5/spec/media-elements.html#handler-tracklist-onchange">change</a></code> on the modified lists.</li>
-      <li>Destroy all resources for <var title="true">buffer</var>.</li>
-      <li>Remove <var title="true">buffer</var> from the list and fire an <code><a href="#dom-removesourcebuffer">removesourcebuffer</a></code> event.</li>
-    </ol>
 
     <h3 id="sourcebufferlist-events">5.2. Event Summary</h3>
     <table>
--- a/media-source/media-source.xml	Mon Jul 02 16:05:53 2012 -0700
+++ b/media-source/media-source.xml	Tue Jul 17 14:07:12 2012 -0700
@@ -286,7 +286,7 @@
 
 
     <h3 id="source-buffer-remove">2.10. Removing Source Buffers</h3>
-    <p>Removing a <SourceBuffer/> with <remove/> releases all resources associated with the object. This includes destroying the all the segment data, <track-buffers/>, and decoders. The media element will also remove the appropriate tracks from <audiotracks/>, <videotracks/>,  &amp; <texttracks/> and fire the necessary <videoref name="handler-tracklist-onchange">change</videoref> events. Playback may become degraded or stop if the currently selected <video-track/> or the only enabled <audio-tracks/> are removed.</p>
+    <p>Removing a <SourceBuffer/> with <removeSourceBuffer/> releases all resources associated with the object. This includes destroying the all the segment data, <track-buffers/>, and decoders. The media element will also remove the appropriate tracks from <audiotracks/>, <videotracks/>,  &amp; <texttracks/> and fire the necessary <videoref name="handler-tracklist-onchange">change</videoref> events. Playback may become degraded or stop if the currently selected <video-track/> or the only enabled <audio-tracks/> are removed.</p>
 
     <h2 id="mediasource">3. MediaSource Object</h2>
     <p>The MediaSource object represents a source of media data for an HTMLMediaElement. It keeps track of the <readyState/> for this source as well as a list of <SourceBuffer/> objects that can be used to add media data to the presentation. MediaSource objects are created by the web application and then attached to an HTMLMediaElement. The application uses the <SourceBuffer/> objects in <sourceBuffers/> to add media data to this source. The HTMLMediaElement fetches this media data from the <MediaSource/> object when it is needed during playback.</p>
@@ -300,8 +300,8 @@
   // Subset of sourceBuffers that provide data for the selected/enabled tracks.
   readonly attribute <precoderef>SourceBufferList</precoderef> <precoderef>activeSourceBuffers</precoderef>;
 
-  // Adds another source buffer.
   <precoderef>SourceBuffer</precoderef> <premethodref>addSourceBuffer</premethodref>(DOMString type);
+  void <premethodref>removeSourceBuffer</premethodref>(<precoderef>SourceBuffer</precoderef> sourceBuffer);
 
   enum State { "closed", "open", "ended" };
   readonly attribute State <precoderef>readyState</precoderef>;
@@ -326,6 +326,17 @@
       <li>Add the new object to <sourceBuffers/> and fire a <coderef>addsourcebuffer</coderef> on that object.</li>
       <li>Return the new object to the caller.</li>
     </ol>
+    <p>The <methoddfn name="removeSourceBuffer">removeSourceBuffer(<var title="true">sourceBuffer</var>)</methoddfn> method must run the following steps:</p>
+    <ol>
+      <li>If <var title="true">sourceBuffer</var> is null then throw an <invalid-access-err/> exception and abort these steps.</li>
+      <li>If <sourceBuffers/> is empty then throw an <invalid-state-err/> exception and abort these steps.</li>
+      <li>If <var title="true">sourceBuffer</var> specifies an object that is not in <sourceBuffers/> then throw a <not-found-err/> exception and abort these steps.</li>
+      <li>Remove track information from <audiotracks/>, <videotracks/>, and <texttracks/> for all tracks associated with <var title="true">sourceBuffer</var> and fire a simple event named <videoref name="handler-tracklist-onchange">change</videoref> on the modified lists.</li>
+      <li>If <var title="true">sourceBuffer</var> is in <activeSourceBuffers/>, then remove it from that list and fire a <removesourcebuffer/> event on that object.</li>
+      <li>Remove <var title="true">sourceBuffer</var> from <sourceBuffers/> and fire a <removesourcebuffer/> event on that object.</li>
+      <li>Destroy all resources for <var title="true">sourceBuffer</var>.</li>
+    </ol>
+
 
     <p>The <codedfn>readyState</codedfn> attribute indicates the current state of the <MediaSource/> object. It can have the following values:</p>
     <dl>
@@ -618,13 +629,12 @@
     </ol>
 
         <h2 id="sourcebufferlist">5. SourceBufferList Object</h2>
-    <p>SourceBufferList is a simple container object for <SourceBuffer/> objects. It provides a read-only array accessor, fires events when the list is modified, and provides a way to remove SourceBuffer objects from the list.</p>
+    <p>SourceBufferList is a simple container object for <SourceBuffer/> objects. It provides a read-only array accessor and fires events when the list is modified.</p>
 
     <pre class="idl">
 interface <dfn id="dom-sourcebufferlist">SourceBufferList</dfn> : EventTarget {
   readonly attribute unsigned long <precoderef>length</precoderef>;
   <precoderef>getter</precoderef> <precoderef>SourceBuffer</precoderef> (unsigned long index);
-  void <premethodref>remove</premethodref>(<precoderef>SourceBuffer</precoderef> buffer);
 };
     </pre>
     <h3 id="sourcebufferlist-methods">5.1. Methods and Attributes</h3>
@@ -634,15 +644,6 @@
       <li>If <var title="true">index</var> is greater than or equal to the <length/> attribute then return undefined and abort these steps.</li>
       <li>Return the <var title="true">index</var>'th <SourceBuffer/> object in the list.</li>
     </ol>
-    <p>The <methoddfn name="remove">remove(<var title="true">buffer</var>)</methoddfn> method must run the following steps:</p>
-    <ol>
-      <li>If <var title="true">buffer</var> is null then throw an <invalid-access-err/> exception and abort these steps.</li>
-      <li>If the list is empty then throw an <invalid-state-err/> exception and abort these steps.</li>
-      <li>If <var title="true">buffer</var> specifies an object that is not in this list then throw a <not-found-err/> exception and abort these steps.</li>
-      <li>Remove track information from <audiotracks/>, <videotracks/>, and <texttracks/> for all tracks associated with <var title="true">buffer</var> and fire a simple event named <videoref name="handler-tracklist-onchange">change</videoref> on the modified lists.</li>
-      <li>Destroy all resources for <var title="true">buffer</var>.</li>
-      <li>Remove <var title="true">buffer</var> from the list and fire an <removesourcebuffer/> event.</li>
-    </ol>
 
     <h3 id="sourcebufferlist-events">5.2. Event Summary</h3>
     <table>
--- a/media-source/spec-html.xsl	Mon Jul 02 16:05:53 2012 -0700
+++ b/media-source/spec-html.xsl	Tue Jul 17 14:07:12 2012 -0700
@@ -59,6 +59,14 @@
     </xsl:call-template>
   </xsl:template>
 
+  <xsl:template match="//removeSourceBuffer">
+    <xsl:call-template name="coderef_helper">
+      <xsl:with-param name="fragment">removeSourceBuffer</xsl:with-param>
+      <xsl:with-param name="link_text">removeSourceBuffer()</xsl:with-param>
+    </xsl:call-template>
+  </xsl:template>
+
+
   <xsl:template match="//readyState">
     <xsl:call-template name="coderef_helper">
       <xsl:with-param name="fragment">readyState</xsl:with-param>
@@ -73,12 +81,6 @@
       <xsl:with-param name="link_text">length</xsl:with-param>
     </xsl:call-template>
   </xsl:template>
-  <xsl:template match="//remove">
-    <xsl:call-template name="coderef_helper">
-      <xsl:with-param name="fragment">remove</xsl:with-param>
-      <xsl:with-param name="link_text">remove()</xsl:with-param>
-    </xsl:call-template>
-  </xsl:template>
 
   <xsl:template match="//addsourcebuffer">
     <xsl:call-template name="coderef_helper">