Address remaining issues for FPWD.
authorAaron Colwell <acolwell@chromium.org>
Fri, 04 Jan 2013 09:44:08 -0800
changeset 5652a85235137b
parent 55 7176347ca1ee
child 57 ad438a9c7b42
Address remaining issues for FPWD.

Bug 20434 - Renamed append() to appendArrayBuffer() and made appending asynchronous.
Bug 18962 - Added SourceBuffer.appendStream().
Bug 17006 - Added SourceBuffer.setTrackInfo() methods.

- Added issue boxes to relevant sections for outstanding bugs.
media-source/media-source-respec.html
media-source/media-source.html
media-source/media-source.js
     1.1 --- a/media-source/media-source-respec.html	Tue Dec 18 09:20:45 2012 -0800
     1.2 +++ b/media-source/media-source-respec.html	Fri Jan 04 09:44:08 2013 -0800
     1.3 @@ -1,4 +1,4 @@
     1.4 -<!DOCTYPE html SYSTEM "about:legacy-compat">
     1.5 +<!DOCTYPE html SYSTEM "about:legacy-compat">
     1.6  <html>
     1.7    <head>
     1.8      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     1.9 @@ -78,7 +78,7 @@
    1.10    <body>
    1.11      
    1.12      <section id="sotd">
    1.13 -        <p>The working groups maintains <a href="http://w3.org/brief/Mjcw">a list of all bug reports that the editors have not yet tried to address</a>.</p>
    1.14 +        <p>The working groups maintains <a href="http://w3.org/brief/Mjcw">a list of all bug reports that the editors have not yet tried to address</a>. This draft highlights some of the pending issues that are still to be discussed in the working group. No decision has been taken on the outcome of these issues including whether they are valid.</p>
    1.15          <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>
    1.16      </section>
    1.17  
    1.18 @@ -155,7 +155,7 @@
    1.19            <dd>The parent media source of a <a>SourceBuffer</a> object is the <a>MediaSource</a> object that created it.</dd>
    1.20  
    1.21            <dt id="append-sequence">Append Sequence</dt>
    1.22 -          <dd>A series of <a def-id="append"></a> calls on a <a>SourceBuffer</a> without any intervening <a def-id="abort"></a> calls. The
    1.23 +          <dd>A series of <a def-id="appendArrayBuffer"></a> or <a def-id="appendStream"></a> calls on a <a>SourceBuffer</a> without any intervening <a def-id="abort"></a> calls. The
    1.24            <a def-id="media-segments"></a> in an append sequence must be adjacent and monotonically increasing in time without any gaps. An
    1.25            <a def-id="abort"></a> call starts a new append sequence which allows <a def-id="media-segments"></a> to be appended in non-monotonically
    1.26            increasing order.</dd>
    1.27 @@ -178,6 +178,9 @@
    1.28          <h3>Appending a Media Segment over a buffered region</h3>
    1.29          <p>There are several ways that <a def-id="media-segments"></a> can overlap segments in the <a>SourceBuffer</a>. Behavior for the different overlap situations are described below. If more than one overlap applies, then the <a href="#source-buffer-overlap-start">start overlap</a> must be resolved first, followed by any <a href="#source-buffer-overlap-complete">complete overlaps</a>, and finally the <a href="#source-buffer-overlap-end">end overlap</a>. If a segment contains multiple tracks then the overlap is resolved independently for each track.</p>
    1.30  
    1.31 +        <p class="issue"><a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=19673">Bug 19673</a> - Seamless audio signal transitions at splice points</p>
    1.32 +        <p class="issue"><a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=19784">Bug 19784</a> - timestampOffset with multiplexed Media Segments</p>
    1.33 +
    1.34          <section id="source-buffer-overlap-complete">
    1.35            <h4>Complete Overlap</h4>
    1.36            <img src="complete_overlap.png" alt="Complete overlap diagram">
    1.37 @@ -224,7 +227,7 @@
    1.38        <p>The MediaSource object represents a source of media data for an HTMLMediaElement. It keeps track of the <a def-id="readyState"></a> for this source as well as a list of <a>SourceBuffer</a> 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 <a>SourceBuffer</a> objects in <a def-id="sourceBuffers"></a> to add media data to this source. The HTMLMediaElement fetches this media data from the <a>MediaSource</a> object when it is needed during playback.</p>
    1.39  
    1.40        <dl title="enum ReadyState" class="idl">
    1.41 -        <dt><dfn id="dom-closed">closed</dfn></dt>
    1.42 +        <dt>closed</dt>
    1.43          <dd>
    1.44            Indicates the source is not currently attached to a media element.
    1.45          </dd>
    1.46 @@ -286,7 +289,7 @@
    1.47              <li>If the value being set is negative or NaN then throw an <a def-id="invalid-access-err"></a> exception and abort these steps.</li>
    1.48              <li>If the <a def-id="readyState"></a> attribute is not <a def-id="open"></a> then throw an <a def-id="invalid-state-err"></a> exception and abort these steps.</li>
    1.49              <li>Run the <a def-id="duration-change-algorithm"></a> with <var>new duration</var> set to the value being assigned to this attribute.
    1.50 -	      <p class="note"><a def-id="append"></a> and <a def-id="endOfStream"></a> can update the duration under certain circumstances.</p>
    1.51 +	      <p class="note"><a def-id="appendArrayBuffer"></a>, <a def-id="appendStream"></a> and <a def-id="endOfStream"></a> can update the duration under certain circumstances.</p>
    1.52              </li>
    1.53            </ol>
    1.54          </dd>
    1.55 @@ -366,7 +369,7 @@
    1.56  	            <li>Run the <a def-id="duration-change-algorithm"></a> with <var>new duration</var> set to the highest end timestamp across all <a>SourceBuffer</a> objects in <a def-id="sourceBuffers"></a>.<br>
    1.57  		      <p class="note">This allows the duration to properly reflect the end of the appended media segments. For example, if the duration was explicitly set to 10 seconds and only media segments for 0 to 5 seconds were appended before endOfStream() was called, then the duration will get updated to 5 seconds.</p>
    1.58  	            </li>
    1.59 -	            <li>Notify the media element that it now has all of the media data. Playback should continue until all the media passed in via <a def-id="append"></a> has been played.</li>
    1.60 +	            <li>Notify the media element that it now has all of the media data. Playback should continue until all the media passed in via <a def-id="appendArrayBuffer"></a> and <a def-id="appendStream"></a> has been played.</li>
    1.61  	          </ol>
    1.62  	        </dd>
    1.63                  <dt>If <var>error</var> is set to <a def-id="network"></a>
    1.64 @@ -400,6 +403,22 @@
    1.65            </ol>
    1.66          </dd>
    1.67  
    1.68 +        <dt>void setTrackInfo(VideoTrack track, DOMString kind, DOMString language)</dt>
    1.69 +        <dd>
    1.70 +            <p>Set the <a def-id="videotrack-kind"></a> and <a def-id="videotrack-language"></a> of the <a def-id="video-track"></a> <var>track</var>.</p>
    1.71 +            <p class="note">This method would be unnecessary if the <a def-id="videotrack-kind"></a> and <a def-id="videotrack-language"></a> attributes of <a def-id="video-track"></a> were not read-only.</p>
    1.72 +        </dd>
    1.73 +        <dt>void setTrackInfo(AudioTrack track, DOMString kind, DOMString language)</dt>
    1.74 +        <dd>
    1.75 +            <p>Set the <a def-id="audiotrack-kind"></a> and <a def-id="audiotrack-language"></a> of the <a def-id="audio-track"></a> <var>track</var>.</p>
    1.76 +            <p class="note">This method would be unnecessary if the <a def-id="audiotrack-kind"></a> and <a def-id="audiotrack-language"></a> attributes of <a def-id="audio-track"></a> were not read-only.</p>
    1.77 +        </dd>
    1.78 +        <dt>void setTrackInfo(TextTrack track, DOMString kind, DOMString language)</dt>
    1.79 +        <dd>
    1.80 +            <p>Set the <a def-id="texttrack-kind"></a> and <a def-id="texttrack-language"></a> of the <a def-id="text-track"></a> <var>track</var>.</p>
    1.81 +            <p class="note">This method would be unnecessary if the <a def-id="texttrack-kind"></a> and <a def-id="texttrack-language"></a> attributes of <a def-id="text-track"></a> were not read-only.</p>
    1.82 +        </dd>
    1.83 +
    1.84          <dt>static bool isTypeSupported(DOMString type)</dt>
    1.85          <dd>
    1.86            <p>Check to see whether the <a>MediaSource</a> is capable of creating <a>SourceBuffer</a> objects for the the specified MIME type.</p>
    1.87 @@ -435,17 +454,17 @@
    1.88              <tr>
    1.89                <td><a def-id="eventdfn">sourceopen</a></td>
    1.90                <td><code>Event</code></td>
    1.91 -              <td>When <a def-id="readyState"></a> transitions from <a def-id="closed"></a> to <a def-id="open"></a> or from <a def-id="ended"></a> to <a def-id="open"></a>.</td>
    1.92 +              <td><a def-id="readyState"></a> transitions from <a def-id="closed"></a> to <a def-id="open"></a> or from <a def-id="ended"></a> to <a def-id="open"></a>.</td>
    1.93              </tr>
    1.94              <tr>
    1.95                <td><a def-id="eventdfn">sourceended</a></td>
    1.96                <td><code>Event</code></td>
    1.97 -              <td>When <a def-id="readyState"></a> transitions from <a def-id="open"></a> to <a def-id="ended"></a>.</td>
    1.98 +              <td><a def-id="readyState"></a> transitions from <a def-id="open"></a> to <a def-id="ended"></a>.</td>
    1.99              </tr>
   1.100              <tr>
   1.101                <td><a def-id="eventdfn">sourceclose</a></td>
   1.102                <td><code>Event</code></td>
   1.103 -	      <td>When <a def-id="readyState"></a> transitions from <a def-id="open"></a> to <a def-id="closed"></a> or <a def-id="ended"></a> to <a def-id="closed"></a>.</td>
   1.104 +	      <td><a def-id="readyState"></a> transitions from <a def-id="open"></a> to <a def-id="closed"></a> or <a def-id="ended"></a> to <a def-id="closed"></a>.</td>
   1.105              </tr>
   1.106            </tbody>
   1.107          </table>
   1.108 @@ -469,7 +488,7 @@
   1.109                  <li>Set the <a def-id="readyState"></a> attribute to <a def-id="open"></a>.</li>
   1.110                  <li>
   1.111                    <a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="sourceopen"></a> at the <a>MediaSource</a>.</li>
   1.112 -                <li>Allow the <a def-id="resource-fetch-algorithm"></a> to progress based on data passed in via <a def-id="append"></a>.</li>
   1.113 +                <li>Allow the <a def-id="resource-fetch-algorithm"></a> to progress based on data passed in via <a def-id="appendArrayBuffer"></a> and <a def-id="appendStream"></a>.</li>
   1.114                </ol>
   1.115              </dd>
   1.116            </dl>
   1.117 @@ -503,7 +522,7 @@
   1.118  	        <dd>
   1.119  	          <ol>
   1.120  	            <li>Set the <a def-id="ready-state"></a> attribute to <a def-id="have-metadata"></a>.</li>
   1.121 -	            <li>The media element waits for the necessary <a def-id="media-segments"></a> to be passed to <a def-id="append"></a>.
   1.122 +	            <li>The media element waits for the necessary <a def-id="media-segments"></a> to be passed to <a def-id="appendArrayBuffer"></a> or <a def-id="appendStream"></a>.
   1.123                        <p class="note">The web application can use <a def-id="buffered"></a> to determine what the media element needs to resume playback.</p>
   1.124                      </li>
   1.125  	          </ol>
   1.126 @@ -523,6 +542,7 @@
   1.127            <h4>SourceBuffer Monitoring</h4>
   1.128            <p>The following steps are periodically run during playback to make sure that all of the <a>SourceBuffer</a> objects in <a def-id="activeSourceBuffers"></a> have enough data to ensure uninterrupted playback. Appending new segments and changes to <a def-id="activeSourceBuffers"></a> also cause these steps to run because they affect the conditions that trigger state transitions.</p>
   1.129            <p class="note">The web application can monitor changes in <a def-id="ready-state"></a> to drive <a def-id="media-segment"></a> appending.</p>
   1.130 +          <p class="issue"><a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=18592">Bug 18592</a> - How much is "enough data to ensure uninterrupted playback"</p>
   1.131            <dl class="switch">
   1.132              <dt>If <a def-id="buffered"></a> for all objects in <a def-id="activeSourceBuffers"></a> do not contain <a def-id="timeranges"></a> for the current playback position:</dt>
   1.133              <dd>
   1.134 @@ -653,7 +673,14 @@
   1.135      <section id="sourcebuffer">
   1.136        <h2>SourceBuffer Object</h2>
   1.137  
   1.138 +      <p class="issue"><a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=20327">Bug 20327</a> - Continuous splice flag</p>
   1.139 +
   1.140        <dl title="interface SourceBuffer : EventTarget" class="idl">
   1.141 +        <dt>readonly attribute boolean appending</dt>
   1.142 +        <dd>
   1.143 +          <p>Indicates whether an <a def-id="appendArrayBuffer"></a> or <a def-id="appendStream"></a> operation is still being processed.</p>
   1.144 +        </dd>
   1.145 +
   1.146          <dt>readonly attribute TimeRanges buffered</dt>
   1.147          <dd>
   1.148            <p>Indicates what <a def-id="timeranges"></a> are buffered in the <a>SourceBuffer</a>.</p>
   1.149 @@ -668,22 +695,24 @@
   1.150          <dd>
   1.151            <p>Controls the offset applied to timestamps inside subsequent <a def-id="media-segments"></a> that are appended to this <a>SourceBuffer</a>. The <a def-id="timestampOffset"></a> is initially set to 0 which indicates that no offset is being applied.</p>
   1.152            <p>On getting, Return the initial value or the last value that was successfully set.</p>
   1.153 -          <p>On setting, run following steps:</p>
   1.154 +          <p>On setting, run the following steps:</p>
   1.155            <ol>
   1.156              <li>If this object has been removed from the <a def-id="sourceBuffers"></a> attribute of the <a def-id="parent-media-source"></a>, then throw an <a def-id="invalid-state-err"></a> exception and abort these steps.</li>
   1.157              <li>If the <a def-id="readyState"></a> attribute of the <a def-id="parent-media-source"></a> is not in the <a def-id="open"></a> state, then throw an <a def-id="invalid-state-err"></a> exception and abort these steps.</li>
   1.158              <li>If this object is waiting for the end of a <a def-id="media-segment"></a> to be appended, then throw an <a def-id="invalid-state-err"></a> and abort these steps.</li>
   1.159              <li>Update the attribute to the new value.</li>
   1.160            </ol>
   1.161 +          <p class="issue"><a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=19676">Bug 19676</a> - timestampOffset accuracy</p>
   1.162          </dd>
   1.163  
   1.164 -        <dt>void append(Uint8Array data)</dt>
   1.165 +        <dt>void appendArrayBuffer(ArrayBuffer data)</dt>
   1.166          <dd>
   1.167 -          <p>Appends segment data to the source buffer.</p>
   1.168 +          <p>Appends the segment data in an ArrayBuffer to the source buffer.</p>
   1.169  
   1.170            <ol class="method-algorithm">
   1.171              <li>If <var>data</var> is null then throw an <a def-id="invalid-access-err"></a> exception and abort these steps.</li>
   1.172              <li>If this object has been removed from the <a def-id="sourceBuffers"></a> attribute of the <a def-id="parent-media-source"></a> then throw an <a def-id="invalid-state-err"></a> exception and abort these steps.</li>
   1.173 +            <li>If the <a def-id="appending"></a> attribute equals true, then throw an <a def-id="invalid-state-err"></a> exception and abort these steps.</li>
   1.174              <li>If the <a def-id="readyState"></a> attribute of the <a def-id="parent-media-source"></a> is in the <a def-id="closed"></a> state then throw an <a def-id="invalid-state-err"></a> exception and abort these steps.</li>
   1.175              <li>
   1.176                <p>If the <a def-id="readyState"></a> attribute of the <a def-id="parent-media-source"></a> is in the <a def-id="ended"></a> state then run the following steps:</p>
   1.177 @@ -699,9 +728,41 @@
   1.178                <p>If the <a def-id="buffer-full-flag"></a> equals true, then throw a <a def-id="quota-exceeded-err"></a> exception and abort these step.</p>
   1.179                <p class="note">The web application must use <a def-id="remove"></a> to free up space in the <a>SourceBuffer</a>.</p>
   1.180              </li>
   1.181 -            <li>Add <var>data</var> to the end of the <a def-id="input-buffer"></a>
   1.182 +            <li>Add <var>data</var> to the end of the <a def-id="input-buffer"></a>.</li>
   1.183 +            <li>Set the <a def-id="appending"></a> attribute to true.</li>
   1.184 +            <li><a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="appendstart"></a> at this <a>SourceBuffer</a> object.</li>
   1.185 +            <li>Asynchronously run the <a def-id="segment-parser-loop"></a> algorithm.</li>
   1.186 +          </ol>
   1.187 +        </dd>
   1.188 +
   1.189 +        <dt>void appendStream(Stream stream, optional unsigned long long maxSize)</dt>
   1.190 +        <dd>
   1.191 +          <p>Appends segment data to the source buffer from a <a def-id="Stream"></a>.</p>
   1.192 +
   1.193 +          <ol class="method-algorithm">
   1.194 +            <li>If <var>stream</var> is null then throw an <a def-id="invalid-access-err"></a> exception and abort these steps.</li>
   1.195 +            <li>If this object has been removed from the <a def-id="sourceBuffers"></a> attribute of the <a def-id="parent-media-source"></a> then throw
   1.196 +              an <a def-id="invalid-state-err"></a> exception and abort these steps.</li>
   1.197 +            <li>If the <a def-id="readyState"></a> attribute of the <a def-id="parent-media-source"></a> is in the <a def-id="closed"></a> state then throw
   1.198 +              an <a def-id="invalid-state-err"></a> exception and abort these steps.</li>
   1.199 +            <li>If the <a def-id="appending"></a> attribute equals true, then throw an <a def-id="invalid-state-err"></a> exception and abort these
   1.200 +              steps.</li>
   1.201 +            <li>
   1.202 +              <p>If the <a def-id="readyState"></a> attribute of the <a def-id="parent-media-source"></a> is in the <a def-id="ended"></a> state then run
   1.203 +                the following steps:</p>
   1.204 +              <ol>
   1.205 +	        <li>Set the <a def-id="readyState"></a> attribute of the <a def-id="parent-media-source"></a> to <a def-id="open"></a></li>
   1.206 +	        <li><a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="sourceopen"></a> at the <a def-id="parent-media-source"></a> .</li>
   1.207 +              </ol>
   1.208              </li>
   1.209 -            <li>Run the <a def-id="segment-parser-loop"></a>.</li>
   1.210 +            <li>If <var>maxSize</var> equals 0, then abort these steps.</li>
   1.211 +            <li>
   1.212 +              <p>If the <a def-id="buffer-full-flag"></a> equals true, then throw a <a def-id="quota-exceeded-err"></a> exception and abort these step.</p>
   1.213 +              <p class="note">The web application must use <a def-id="remove"></a> to free up space in the <a>SourceBuffer</a>.</p>
   1.214 +            </li>
   1.215 +            <li>Set the <a def-id="appending"></a> attribute to true.</li>
   1.216 +            <li><a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="appendstart"></a> at this <a>SourceBuffer</a> object.</li>
   1.217 +            <li>Asynchronously run the <a def-id="stream-append-loop"></a> algorithm with <var>stream</var> and <var>maxSize</var>.</li>
   1.218            </ol>
   1.219          </dd>
   1.220  
   1.221 @@ -712,10 +773,14 @@
   1.222            <ol class="method-algorithm">
   1.223              <li>If this object has been removed from the <a def-id="sourceBuffers"></a> attribute of the <a def-id="parent-media-source"></a> then throw an <a def-id="invalid-state-err"></a> exception and abort these steps.</li>
   1.224              <li>If the <a def-id="readyState"></a> attribute of the <a def-id="parent-media-source"></a> is not in the <a def-id="open"></a> state then throw an <a def-id="invalid-state-err"></a> exception and abort these steps.</li>
   1.225 -            <li>If the <a def-id="append-state"></a> equals <a def-id="parsing-media-segment"></a> and the <a def-id="input-buffer"></a> contains some complete <a def-id="coded-frames"></a>, then run the <a def-id="coded-frame-processing-algorithm"></a> as if the media segment only contained these frames.</li>
   1.226 -            <li>Unset the <a def-id="last-decode-timestamp"></a> on all <a def-id="track-buffers"></a>.</li>
   1.227 -            <li>Remove all bytes from the <a def-id="input-buffer"></a>.</li>
   1.228 -            <li>Set <a def-id="append-state"></a> to <a def-id="waiting-for-segment"></a>.</li>
   1.229 +            <li>Run the <a def-id="reset-parser-state-algorithm"></a>.</li>
   1.230 +            <li>If the <a def-id="appending"></a> attribute equals true, then run the following steps:
   1.231 +              <ol>
   1.232 +                <li>Set the <a def-id="appending"></a> attribute to false.</li>
   1.233 +                <li><a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="appendabort"></a> at this <a>SourceBuffer</a> object.</li>
   1.234 +                <li><a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="appendend"></a> at this <a>SourceBuffer</a> object.</li>
   1.235 +              </ol>
   1.236 +            </li>
   1.237            </ol>
   1.238          </dd>
   1.239  
   1.240 @@ -761,6 +826,41 @@
   1.241            unset to indicate that no <a def-id="coded-frames"></a> have been appended yet.</p>
   1.242        </section>
   1.243  
   1.244 +      <section id="sourcebuffer-events">
   1.245 +        <h3>Event Summary</h3>
   1.246 +        <table class="old-table">
   1.247 +          <thead>
   1.248 +            <tr>
   1.249 +              <th>Event name</th>
   1.250 +              <th>Interface</th>
   1.251 +              <th>Dispatched when...</th>
   1.252 +            </tr>
   1.253 +          </thead>
   1.254 +          <tbody>
   1.255 +            <tr>
   1.256 +              <td><a def-id="eventdfn">appendstart</a></td>
   1.257 +              <td><code>Event</code></td>
   1.258 +              <td><a def-id="appending"></a> transitions from false to true.</td>
   1.259 +            </tr>
   1.260 +            <tr>
   1.261 +              <td><a def-id="eventdfn">appendend</a></td>
   1.262 +              <td><code>Event</code></td>
   1.263 +              <td><a def-id="appending"></a> transitions from true to false.</td>
   1.264 +            </tr>
   1.265 +            <tr>
   1.266 +              <td><a def-id="eventdfn">error</a></td>
   1.267 +              <td><code>Event</code></td>
   1.268 +              <td>An error occurred during the append.</td>
   1.269 +            </tr>
   1.270 +            <tr>
   1.271 +              <td><a def-id="eventdfn">abort</a></td>
   1.272 +              <td><code>Event</code></td>
   1.273 +              <td>The append was aborted by an <a def-id="abort"></a> call.</td>
   1.274 +            </tr>
   1.275 +          </tbody>
   1.276 +        </table>
   1.277 +      </section>
   1.278 +
   1.279        <section id="sourcebuffer-algorithms">
   1.280          <h3>Algorithms</h3>
   1.281  
   1.282 @@ -790,39 +890,42 @@
   1.283              </tbody>
   1.284            </table>
   1.285            
   1.286 -          <p>The <dfn id="sourcebuffer-input-buffer">input buffer</dfn> is a byte buffer that is used to hold unparsed bytes across <a def-id="append"></a> calls. The buffer is empty when the SourceBuffer object is created.</p>
   1.287 +          <p>The <dfn id="sourcebuffer-input-buffer">input buffer</dfn> is a byte buffer that is used to hold unparsed bytes across <a def-id="appendArrayBuffer"></a> and <a def-id="appendStream"></a> calls. The buffer is empty when the SourceBuffer object is created.</p>
   1.288  
   1.289 -          <p>The <dfn id="sourcebuffer-buffer-full-flag">buffer full flag</dfn> keeps track of whether <a def-id="append"></a> is allowed to accept more
   1.290 -            bytes. It is set to false when the SourceBuffer object is created and gets updated as data is appended and removed.</p>
   1.291 +          <p>The <dfn id="sourcebuffer-buffer-full-flag">buffer full flag</dfn> keeps track of whether <a def-id="appendArrayBuffer"></a> or 
   1.292 +            <a def-id="appendStream"></a> is allowed to accept more bytes. It is set to false when the SourceBuffer object is created and gets updated 
   1.293 +            as data is appended and removed.</p>
   1.294  
   1.295 -          <p>While the <a def-id="input-buffer"></a> is not empty, run the following steps in a loop:</p>
   1.296 +          <p>When this algorithm is invoked, run the following steps:</p>
   1.297 +
   1.298            <ol>
   1.299 -            <li>If the <a def-id="input-buffer"></a> starts with bytes that violate the <a def-id="byte-stream-format-specs"></a>, then call <a def-id="eos-decode"></a>, and abort this algorithm.</li>
   1.300 +            <li><i>Loop Top:</i> If the <a def-id="input-buffer"></a> is empty, then jump to the <i>need more data</i> step below.</li>
   1.301 +            <li>If the <a def-id="input-buffer"></a> starts with bytes that violate the <a def-id="byte-stream-format-specs"></a>, then run the <a def-id="append-error-algorithm"></a> and abort this algorithm.</li>
   1.302              <li>Remove any bytes that the <a def-id="byte-stream-format-specs"></a> say should be ignored from the start of the <a def-id="input-buffer"></a>.</li>
   1.303              <li>
   1.304  	      <p>If the <a def-id="append-state"></a> equals <a def-id="waiting-for-segment"></a>, then run the following steps:</p>
   1.305  	      <ol>
   1.306  	        <li>If the beginning of the <a def-id="input-buffer"></a> indicates the start of an <a def-id="init-segment"></a>, set the <a def-id="append-state"></a> to <a def-id="parsing-init-segment"></a>.</li>
   1.307  	        <li>If the beginning of the <a def-id="input-buffer"></a> indicates the start of an <a def-id="media-segment"></a>, set <a def-id="append-state"></a> to <a def-id="parsing-media-segment"></a>.</li>
   1.308 -	        <li>Return  to the top of the loop.</li>
   1.309 +	        <li>Jump to the <i>loop top</i> step above.</li>
   1.310  	      </ol>
   1.311              </li>
   1.312              <li>
   1.313  	      <p>If the <a def-id="append-state"></a> equals <a def-id="parsing-init-segment"></a>, then run the following steps:</p>
   1.314  	      <ol>
   1.315 -	        <li>If the <a def-id="input-buffer"></a> does not contain a complete <a def-id="init-segment"></a> yet, then exit the loop.</li>
   1.316 +	        <li>If the <a def-id="input-buffer"></a> does not contain a complete <a def-id="init-segment"></a> yet, then jump to the <i>need more data</i> step below.</li>
   1.317  	        <li>Run the <a def-id="init-segment-received-algorithm"></a>.</li>
   1.318  	        <li>Remove the <a def-id="init-segment"></a> bytes from the beginning of the <a def-id="input-buffer"></a>.</li>
   1.319  	        <li>Set <a def-id="append-state"></a> to <a def-id="waiting-for-segment"></a>.</li>
   1.320 -	        <li>Return  to the top of the loop.</li>
   1.321 +	        <li>Jump to the <i>loop top</i> step above.</li>
   1.322  	      </ol>
   1.323              </li>
   1.324              <li>
   1.325  	      <p>If the <a def-id="append-state"></a> equals <a def-id="parsing-media-segment"></a>, then run the following steps:</p>
   1.326  	      <ol>
   1.327 -                <li>If the <a def-id="first-init-segment-flag"></a> is false, then run <a def-id="eos-decode"></a> and exit the loop.</li>
   1.328 +                <li>If the <a def-id="first-init-segment-flag"></a> is false, then run the <a def-id="append-error-algorithm"></a> and abort this algorithm.</li>
   1.329  	        <li>
   1.330 -	          <p>If the <a def-id="input-buffer"></a> does not contain a complete <a def-id="media-segment"></a> header yet, then exit the loop.</p>
   1.331 +	          <p>If the <a def-id="input-buffer"></a> does not contain a complete <a def-id="media-segment"></a> header yet, then jump to the <i>need more data</i> step below.</p>
   1.332  	          <p class="note">Implementations may choose to implement this state as an incremental parser so that it is not necessary to have the entire media segment before running the <a def-id="coded-frame-processing-algorithm"></a>.</p>
   1.333  	        </li>
   1.334  	        <li>Run the <a def-id="coded-frame-processing-algorithm"></a>.</li>
   1.335 @@ -832,9 +935,74 @@
   1.336  	          <p>Set <a def-id="append-state"></a> to <a def-id="waiting-for-segment"></a>.</p>
   1.337  	          <p class="note">Incremental parsers should only do this transition after the entire media segment has been received.</p>
   1.338  	        </li>
   1.339 -	        <li>Return  to the top of the loop.</li>
   1.340 +	        <li>Jump to the <i>loop top</i> step above.</li>
   1.341  	      </ol>
   1.342              </li>
   1.343 +            <li><i>Need more data:</i> If the <a def-id="stream-append-loop"></a> algorithm is running and still has data to read, then abort these steps.
   1.344 +            <li>Set the <a def-id="appending"></a> attribute to false.</li>
   1.345 +            <li><a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="appendend"></a> at this <a>SourceBuffer</a> object.</li>
   1.346 +          </ol>
   1.347 +        </section>
   1.348 +
   1.349 +        <section id="sourcebuffer-reset-parser-state">
   1.350 +          <h4>Reset Parser State</h4>
   1.351 +          <p>When the parser state needs to be reset, run the following steps:</p>
   1.352 +          <ol>
   1.353 +            <li>If the <a def-id="append-state"></a> equals <a def-id="parsing-media-segment"></a> and the <a def-id="input-buffer"></a> contains some complete <a def-id="coded-frames"></a>, then run the <a def-id="coded-frame-processing-algorithm"></a> as if the media segment only contained these frames.</li>
   1.354 +            <li>Unset the <a def-id="last-decode-timestamp"></a> on all <a def-id="track-buffers"></a>.</li>
   1.355 +            <li>Remove all bytes from the <a def-id="input-buffer"></a>.</li>
   1.356 +            <li>Set <a def-id="append-state"></a> to <a def-id="waiting-for-segment"></a>.</li>
   1.357 +          </ol>
   1.358 +        </section>
   1.359 +
   1.360 +        <section id="sourcebuffer-append-error">
   1.361 +          <h4>Append Error</h4>
   1.362 +          <p>When an error occurs during an append, run the following steps:</p>
   1.363 +          <ol>
   1.364 +            <li>Run the <a def-id="reset-parser-state-algorithm"></a>.</li>
   1.365 +            <li>Abort the <a def-id="stream-append-loop"></a> algorithm if it is running.</li>
   1.366 +            <li>Set the <a def-id="appending"></a> attribute to false.</li>
   1.367 +            <li>
   1.368 +              <a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="appenderror"></a> at this <a>SourceBuffer</a> object.
   1.369 +              <p class="issue">Need a way to convey error information.</p>
   1.370 +            </li>
   1.371 +            <li><a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="appendend"></a> at this <a>SourceBuffer</a> object.</li>
   1.372 +          </ol>
   1.373 +        </section>
   1.374 +
   1.375 +        <section id="sourcebuffer-stream-append-loop">
   1.376 +          <h4>Stream Append Loop</h4>
   1.377 +          <p>When a <a def-id="Stream"></a> is passed to <a def-id="appendStream"></a>, the following steps are run to transfer data from the
   1.378 +            <a def-id="Stream"></a> to the <a>SourceBuffer</a>. This algorithm is initialized with the  <var>stream</var> and <var>maxSize</var> parameters
   1.379 +            from the <a def-id="appendStream"></a> call.
   1.380 +          </p>
   1.381 +          <ol>
   1.382 +            <li>If <var>maxSize</var> is set, then let <var>bytesLeft</var> equal <var>maxSize</var>.</li>
   1.383 +            <li><i>Loop Top: </i>If <var>maxSize</var> is set and <var>bytesLeft</var> equals 0, then jump to the <i>loop done</i> step below.</li>
   1.384 +            <li>If <var>stream</var> has been aborted, then run the <a def-id="append-error-algorithm"></a> and abort this algorithm.</li>
   1.385 +            <li>If <var>stream</var> has been closed, then jump to the <i>loop done</i> step below.</li>
   1.386 +            <li>
   1.387 +              <p>If the <a def-id="buffer-full-flag"></a> equals true, then run the <a def-id="append-error-algorithm"></a> and abort this algorithm.</p>
   1.388 +              <p class="note">The web application must use <a def-id="remove"></a> to free up space in the <a>SourceBuffer</a>.</p>
   1.389 +            </li>
   1.390 +            <li>Read data from <var>stream</var> into <var>data</var>:
   1.391 +              <dl class="switch">
   1.392 +                <dt>If <var>maxSize</var> is set:</dt>
   1.393 +                <dd>
   1.394 +                  <ol>
   1.395 +                    <li>Read up to <var>bytesLeft</var> bytes from <var>stream</var> into <var>data</var>.</li>
   1.396 +                    <li>Subtract the number of bytes in <var>data</var> from <var>bytesLeft</var>.</li>
   1.397 +                </dd>
   1.398 +                <dt>Otherwise:</dt>
   1.399 +                <dd>Read all available bytes in <var>stream</var> into <var>data</var>.</dd>
   1.400 +              </dl>
   1.401 +            </li>
   1.402 +            <li>If an error occured while reading from <var>stream</var>, then run the <a def-id="append-error-algorithm"></a> and abort this algorithm.</li>
   1.403 +            <li>Add <var>data</var> to the end of the <a def-id="input-buffer"></a>.</li>
   1.404 +            <li>Run the <a def-id="segment-parser-loop"></a> algorithm.</li>
   1.405 +            <li>Jump to the <i>loop top</i> step above.</li>
   1.406 +            <li><i>Loop Done: </i>Set the <a def-id="appending"></a> attribute to false.</li>
   1.407 +            <li><a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="appendend"></a> at this <a>SourceBuffer</a> object.</li>
   1.408            </ol>
   1.409          </section>
   1.410  
   1.411 @@ -1096,6 +1264,8 @@
   1.412  	    <li>Let <var>highest intersection end time</var> be the highest end time in the <var>intersection range</var>.</li>
   1.413  	    <li>If the <var>highest intersection end time</var> is less than the <var>highest end time</var>, then update the <var>intersection range</var> so that the <var>highest intersection end time</var> equals the <var>highest end time</var>.</li>
   1.414  	  </ol>
   1.415 +        <p class="issue"><a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=18615">Bug 18615</a> - Define how SourceBuffer.buffered maps to HTMLMediaElement.buffered</p>
   1.416 +        <p class="issue"><a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=18400">Bug 18400</a> - Define and document timestamp heuristics</p>
   1.417          </li>
   1.418          <li>Return the <var>intersection range</var>.</li>
   1.419        </ol>
   1.420 @@ -1103,7 +1273,7 @@
   1.421      
   1.422      <section id="byte-stream-formats">
   1.423        <h2>Byte Stream Formats</h2>
   1.424 -      <p>The bytes provided through <a def-id="append"></a> for a <a>SourceBuffer</a> form a logical byte stream. The format of this byte stream depends on the media container format in use and is defined in a byte stream format specification. Byte stream format specifications based on WebM , the ISO Base Media File Format, and MPEG-2 Transport Streams are provided below. These format specifications are intended to be the authoritative source for how data from these containers is formatted and passed to a <a>SourceBuffer</a>. If a <a>MediaSource</a> implementation claims to support any of these container formats, then it must implement the corresponding byte stream format specification described below.</p>
   1.425 +      <p>The bytes provided through <a def-id="appendArrayBuffer"></a> and <a def-id="appendStream"></a> for a <a>SourceBuffer</a> form a logical byte stream. The format of this byte stream depends on the media container format in use and is defined in a byte stream format specification. Byte stream format specifications based on WebM , the ISO Base Media File Format, and MPEG-2 Transport Streams are provided below. These format specifications are intended to be the authoritative source for how data from these containers is formatted and passed to a <a>SourceBuffer</a>. If a <a>MediaSource</a> implementation claims to support any of these container formats, then it must implement the corresponding byte stream format specification described below.</p>
   1.426        <p>This section provides general requirements for all byte stream formats:</p>
   1.427        <ul>
   1.428          <li>A byte stream format specification must define <a def-id="init-segments"></a> and <a def-id="media-segments"></a>.</li>
   1.429 @@ -1202,6 +1372,7 @@
   1.430          <h3>ISO Base Media File Format Byte Streams</h3>
   1.431          <p>This section defines segment formats for implementations that choose to support the ISO Base Media File Format
   1.432  	  <a def-id="iso-14496-12"></a> (ISO BMFF).</p> 
   1.433 +          <p class="issue"><a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=18933">Bug 18933</a> - Segment byte boundaries are not defined</p>
   1.434  
   1.435  	<section id="iso-init-segments">
   1.436            <h4>Initialization Segments</h4>
   1.437 @@ -1321,10 +1492,15 @@
   1.438      }
   1.439  
   1.440      // Append the initialization segment.
   1.441 -    sourceBuffer.append(initSegment);
   1.442 +    var firstAppendHandler = function(e) {
   1.443 +      var sourceBuffer = e.target;
   1.444 +      sourceBuffer.removeEventListener('appendend', firstAppendHandler);
   1.445  
   1.446 -    // Append some initial media data.
   1.447 -    appendNextMediaSegment(mediaSource);
   1.448 +      // Append some initial media data.
   1.449 +      appendNextMediaSegment(mediaSource);
   1.450 +    };
   1.451 +    sourceBuffer.addEventListener('appendend', firstAppendHandler);
   1.452 +    sourceBuffer.appendArrayBuffer(initSegment);
   1.453    }
   1.454  
   1.455    function appendNextMediaSegment(mediaSource) {
   1.456 @@ -1337,6 +1513,10 @@
   1.457        return;
   1.458      }
   1.459  
   1.460 +    // Make sure the previous append is not still pending.
   1.461 +    if (mediaSource.sourceBuffers[0].appending)
   1.462 +        return;
   1.463 +
   1.464      var mediaSegment = GetNextMediaSegment();
   1.465  
   1.466      if (!mediaSegment) {
   1.467 @@ -1345,7 +1525,7 @@
   1.468        return;
   1.469      }
   1.470  
   1.471 -    mediaSource.sourceBuffers[0].append(mediaSegment);
   1.472 +    mediaSource.sourceBuffers[0].appendArrayBuffer(mediaSegment);
   1.473    }
   1.474  
   1.475    function onSeeking(mediaSource, e) {
   1.476 @@ -1358,8 +1538,7 @@
   1.477      // new playback position.
   1.478      SeekToMediaSegmentAt(video.currentTime);
   1.479  
   1.480 -    // Append media segments from the new playback position.
   1.481 -    appendNextMediaSegment(mediaSource);
   1.482 +    // Append a media segment from the new playback position.
   1.483      appendNextMediaSegment(mediaSource);
   1.484    }
   1.485  
   1.486 @@ -1392,7 +1571,18 @@
   1.487          </thead>
   1.488          <tbody>
   1.489            <tr>
   1.490 -	    <td>14 December 2012</td>
   1.491 +	    <td>04 January 2013</td>
   1.492 +            <td>
   1.493 +              <ul>
   1.494 +                <li>Renamed append() to appendArrayBuffer() and made appending asynchronous.</li>
   1.495 +                <li>Added SourceBuffer.appendStream().</li>
   1.496 +                <li>Added SourceBuffer.setTrackInfo() methods.</li>
   1.497 +                <li>Added issue boxes to relevant sections for outstanding bugs.</li>
   1.498 +              </ul>
   1.499 +            </td>
   1.500 +          </tr>
   1.501 +          <tr>
   1.502 +	    <td><a href="http://dvcs.w3.org/hg/html-media/raw-file/53ea7c19edd2/media-source/media-source.html">14 December 2012</a></td>
   1.503              <td>
   1.504                Pubrules, Link Checker, and Markup Validation fixes.
   1.505              </td>
     2.1 --- a/media-source/media-source.html	Tue Dec 18 09:20:45 2012 -0800
     2.2 +++ b/media-source/media-source.html	Fri Jan 04 09:44:08 2013 -0800
     2.3 @@ -1,4 +1,4 @@
     2.4 -<!DOCTYPE html>
     2.5 +<!DOCTYPE html>
     2.6  <html lang="en" dir="ltr">
     2.7  <head>
     2.8      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     2.9 @@ -397,7 +397,7 @@
    2.10    </p>
    2.11    <h1 class="title" id="title">Media Source Extensions</h1>
    2.12    
    2.13 -  <h2 id="w3c-editor-s-draft-18-december-2012"><abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft 18 December 2012</h2>
    2.14 +  <h2 id="w3c-editor-s-draft-04-january-2013"><abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft 04 January 2013</h2>
    2.15    <dl>
    2.16      
    2.17        <dt>This version:</dt>
    2.18 @@ -430,7 +430,7 @@
    2.19      
    2.20        <p class="copyright">
    2.21          <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 
    2.22 -        2012
    2.23 +        2013
    2.24          
    2.25          <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> 
    2.26          (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>,
    2.27 @@ -463,7 +463,7 @@
    2.28            index</a> at http://www.w3.org/TR/.</em>
    2.29          </p>
    2.30          
    2.31 -        <p>The working groups maintains <a href="http://w3.org/brief/Mjcw">a list of all bug reports that the editors have not yet tried to address</a>.</p>
    2.32 +        <p>The working groups maintains <a href="http://w3.org/brief/Mjcw">a list of all bug reports that the editors have not yet tried to address</a>. This draft highlights some of the pending issues that are still to be discussed in the working group. No decision has been taken on the outcome of these issues including whether they are valid.</p>
    2.33          <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>
    2.34      
    2.35          <p>
    2.36 @@ -507,7 +507,7 @@
    2.37        
    2.38      
    2.39    
    2.40 -</section><section id="toc"><h2 class="introductory">Table of Contents</h2><ul class="toc"><li class="tocline"><a href="#introduction" class="tocxref"><span class="secno">1. </span>Introduction</a><ul class="toc"><li class="tocline"><a href="#goals" class="tocxref"><span class="secno">1.1 </span>Goals</a></li><li class="tocline"><a href="#definitions" class="tocxref"><span class="secno">1.2 </span>Definitions</a></li></ul></li><li class="tocline"><a href="#source-buffer-model" class="tocxref"><span class="secno">2. </span>Source Buffer Model</a><ul class="toc"><li class="tocline"><a href="#source-buffer-overlapping-segments" class="tocxref"><span class="secno">2.1 </span>Appending a Media Segment over a buffered region</a><ul class="toc"><li class="tocline"><a href="#source-buffer-overlap-complete" class="tocxref"><span class="secno">2.1.1 </span>Complete Overlap</a></li><li class="tocline"><a href="#source-buffer-overlap-start" class="tocxref"><span class="secno">2.1.2 </span>Start Overlap</a></li><li class="tocline"><a href="#source-buffer-overlap-end" class="tocxref"><span class="secno">2.1.3 </span>End Overlap</a></li><li class="tocline"><a href="#source-buffer-overlap-middle" class="tocxref"><span class="secno">2.1.4 </span>Middle Overlap</a></li></ul></li><li class="tocline"><a href="#track-buffer-to-decoder-buffer" class="tocxref"><span class="secno">2.2 </span>Track Buffer to Decoder Buffer transfer</a></li></ul></li><li class="tocline"><a href="#mediasource" class="tocxref"><span class="secno">3. </span>MediaSource Object</a><ul class="toc"><li class="tocline"><a href="#attributes" class="tocxref"><span class="secno">3.1 </span>Attributes</a></li><li class="tocline"><a href="#methods" class="tocxref"><span class="secno">3.2 </span>Methods</a></li><li class="tocline"><a href="#mediasource-events" class="tocxref"><span class="secno">3.3 </span>Event Summary</a></li><li class="tocline"><a href="#mediasource-algorithms" class="tocxref"><span class="secno">3.4 </span>Algorithms</a><ul class="toc"><li class="tocline"><a href="#mediasource-attach" class="tocxref"><span class="secno">3.4.1 </span>Attaching to a media element</a></li><li class="tocline"><a href="#mediasource-detach" class="tocxref"><span class="secno">3.4.2 </span>Detaching from a media element</a></li><li class="tocline"><a href="#mediasource-seeking" class="tocxref"><span class="secno">3.4.3 </span>Seeking</a></li><li class="tocline"><a href="#buffer-monitoring" class="tocxref"><span class="secno">3.4.4 </span>SourceBuffer Monitoring</a></li><li class="tocline"><a href="#active-source-buffer-changes" class="tocxref"><span class="secno">3.4.5 </span>Changes to selected/enabled track state</a></li><li class="tocline"><a href="#duration-change-algorithm" class="tocxref"><span class="secno">3.4.6 </span>Duration change</a></li></ul></li></ul></li><li class="tocline"><a href="#sourcebuffer" class="tocxref"><span class="secno">4. </span>SourceBuffer Object</a><ul class="toc"><li class="tocline"><a href="#attributes-1" class="tocxref"><span class="secno">4.1 </span>Attributes</a></li><li class="tocline"><a href="#methods-1" class="tocxref"><span class="secno">4.2 </span>Methods</a></li><li class="tocline"><a href="#track-buffers" class="tocxref"><span class="secno">4.3 </span>Track Buffers</a></li><li class="tocline"><a href="#sourcebuffer-algorithms" class="tocxref"><span class="secno">4.4 </span>Algorithms</a><ul class="toc"><li class="tocline"><a href="#sourcebuffer-segment-parser-loop" class="tocxref"><span class="secno">4.4.1 </span>Segment Parser Loop</a></li><li class="tocline"><a href="#sourcebuffer-init-segment-received" class="tocxref"><span class="secno">4.4.2 </span>Initialization Segment Received</a></li><li class="tocline"><a href="#sourcebuffer-coded-frame-processing" class="tocxref"><span class="secno">4.4.3 </span>Coded Frame Processing</a></li></ul></li></ul></li><li class="tocline"><a href="#sourcebufferlist" class="tocxref"><span class="secno">5. </span>SourceBufferList Object</a><ul class="toc"><li class="tocline"><a href="#attributes-2" class="tocxref"><span class="secno">5.1 </span>Attributes</a></li><li class="tocline"><a href="#methods-2" class="tocxref"><span class="secno">5.2 </span>Methods</a></li><li class="tocline"><a href="#sourcebufferlist-events" class="tocxref"><span class="secno">5.3 </span>Event Summary</a></li></ul></li><li class="tocline"><a href="#url" class="tocxref"><span class="secno">6. </span>URL Object</a><ul class="toc"><li class="tocline"><a href="#methods-3" class="tocxref"><span class="secno">6.1 </span>Methods</a></li></ul></li><li class="tocline"><a href="#htmlmediaelement-attributes" class="tocxref"><span class="secno">7. </span>HTMLMediaElement attributes</a></li><li class="tocline"><a href="#byte-stream-formats" class="tocxref"><span class="secno">8. </span>Byte Stream Formats</a><ul class="toc"><li class="tocline"><a href="#webm" class="tocxref"><span class="secno">8.1 </span>WebM Byte Streams</a><ul class="toc"><li class="tocline"><a href="#webm-init-segments" class="tocxref"><span class="secno">8.1.1 </span>Initialization Segments</a></li><li class="tocline"><a href="#webm-media-segments" class="tocxref"><span class="secno">8.1.2 </span>Media Segments</a></li><li class="tocline"><a href="#webm-random-access-points" class="tocxref"><span class="secno">8.1.3 </span>Random Access Points</a></li></ul></li><li class="tocline"><a href="#iso" class="tocxref"><span class="secno">8.2 </span>ISO Base Media File Format Byte Streams</a><ul class="toc"><li class="tocline"><a href="#iso-init-segments" class="tocxref"><span class="secno">8.2.1 </span>Initialization Segments</a></li><li class="tocline"><a href="#iso-media-segments" class="tocxref"><span class="secno">8.2.2 </span>Media Segments</a></li><li class="tocline"><a href="#iso-random-access-points" class="tocxref"><span class="secno">8.2.3 </span>Random Access Points</a></li></ul></li><li class="tocline"><a href="#mpeg2ts" class="tocxref"><span class="secno">8.3 </span>MPEG-2 Transport Stream Byte Streams</a><ul class="toc"><li class="tocline"><a href="#mpeg2ts-general" class="tocxref"><span class="secno">8.3.1 </span>General</a></li><li class="tocline"><a href="#mpeg2ts-init-segments" class="tocxref"><span class="secno">8.3.2 </span>Initialization Segments</a></li><li class="tocline"><a href="#mpeg2ts-media-segments" class="tocxref"><span class="secno">8.3.3 </span>Media Segments</a></li><li class="tocline"><a href="#mpeg2ts-random-access-points" class="tocxref"><span class="secno">8.3.4 </span>Random Access Points</a></li><li class="tocline"><a href="#mpeg2ts-discontinuities" class="tocxref"><span class="secno">8.3.5 </span>Timestamp Rollover &amp; Discontinuities</a></li></ul></li></ul></li><li class="tocline"><a href="#examples" class="tocxref"><span class="secno">9. </span>Examples</a></li><li class="tocline"><a href="#revision-history" class="tocxref"><span class="secno">10. </span>Revision History</a></li></ul></section>
    2.41 +</section><section id="toc"><h2 class="introductory">Table of Contents</h2><ul class="toc"><li class="tocline"><a href="#introduction" class="tocxref"><span class="secno">1. </span>Introduction</a><ul class="toc"><li class="tocline"><a href="#goals" class="tocxref"><span class="secno">1.1 </span>Goals</a></li><li class="tocline"><a href="#definitions" class="tocxref"><span class="secno">1.2 </span>Definitions</a></li></ul></li><li class="tocline"><a href="#source-buffer-model" class="tocxref"><span class="secno">2. </span>Source Buffer Model</a><ul class="toc"><li class="tocline"><a href="#source-buffer-overlapping-segments" class="tocxref"><span class="secno">2.1 </span>Appending a Media Segment over a buffered region</a><ul class="toc"><li class="tocline"><a href="#source-buffer-overlap-complete" class="tocxref"><span class="secno">2.1.1 </span>Complete Overlap</a></li><li class="tocline"><a href="#source-buffer-overlap-start" class="tocxref"><span class="secno">2.1.2 </span>Start Overlap</a></li><li class="tocline"><a href="#source-buffer-overlap-end" class="tocxref"><span class="secno">2.1.3 </span>End Overlap</a></li><li class="tocline"><a href="#source-buffer-overlap-middle" class="tocxref"><span class="secno">2.1.4 </span>Middle Overlap</a></li></ul></li><li class="tocline"><a href="#track-buffer-to-decoder-buffer" class="tocxref"><span class="secno">2.2 </span>Track Buffer to Decoder Buffer transfer</a></li></ul></li><li class="tocline"><a href="#mediasource" class="tocxref"><span class="secno">3. </span>MediaSource Object</a><ul class="toc"><li class="tocline"><a href="#attributes" class="tocxref"><span class="secno">3.1 </span>Attributes</a></li><li class="tocline"><a href="#methods" class="tocxref"><span class="secno">3.2 </span>Methods</a></li><li class="tocline"><a href="#mediasource-events" class="tocxref"><span class="secno">3.3 </span>Event Summary</a></li><li class="tocline"><a href="#mediasource-algorithms" class="tocxref"><span class="secno">3.4 </span>Algorithms</a><ul class="toc"><li class="tocline"><a href="#mediasource-attach" class="tocxref"><span class="secno">3.4.1 </span>Attaching to a media element</a></li><li class="tocline"><a href="#mediasource-detach" class="tocxref"><span class="secno">3.4.2 </span>Detaching from a media element</a></li><li class="tocline"><a href="#mediasource-seeking" class="tocxref"><span class="secno">3.4.3 </span>Seeking</a></li><li class="tocline"><a href="#buffer-monitoring" class="tocxref"><span class="secno">3.4.4 </span>SourceBuffer Monitoring</a></li><li class="tocline"><a href="#active-source-buffer-changes" class="tocxref"><span class="secno">3.4.5 </span>Changes to selected/enabled track state</a></li><li class="tocline"><a href="#duration-change-algorithm" class="tocxref"><span class="secno">3.4.6 </span>Duration change</a></li></ul></li></ul></li><li class="tocline"><a href="#sourcebuffer" class="tocxref"><span class="secno">4. </span>SourceBuffer Object</a><ul class="toc"><li class="tocline"><a href="#attributes-1" class="tocxref"><span class="secno">4.1 </span>Attributes</a></li><li class="tocline"><a href="#methods-1" class="tocxref"><span class="secno">4.2 </span>Methods</a></li><li class="tocline"><a href="#track-buffers" class="tocxref"><span class="secno">4.3 </span>Track Buffers</a></li><li class="tocline"><a href="#sourcebuffer-events" class="tocxref"><span class="secno">4.4 </span>Event Summary</a></li><li class="tocline"><a href="#sourcebuffer-algorithms" class="tocxref"><span class="secno">4.5 </span>Algorithms</a><ul class="toc"><li class="tocline"><a href="#sourcebuffer-segment-parser-loop" class="tocxref"><span class="secno">4.5.1 </span>Segment Parser Loop</a></li><li class="tocline"><a href="#sourcebuffer-reset-parser-state" class="tocxref"><span class="secno">4.5.2 </span>Reset Parser State</a></li><li class="tocline"><a href="#sourcebuffer-append-error" class="tocxref"><span class="secno">4.5.3 </span>Append Error</a></li><li class="tocline"><a href="#sourcebuffer-stream-append-loop" class="tocxref"><span class="secno">4.5.4 </span>Stream Append Loop</a></li><li class="tocline"><a href="#sourcebuffer-init-segment-received" class="tocxref"><span class="secno">4.5.5 </span>Initialization Segment Received</a></li><li class="tocline"><a href="#sourcebuffer-coded-frame-processing" class="tocxref"><span class="secno">4.5.6 </span>Coded Frame Processing</a></li></ul></li></ul></li><li class="tocline"><a href="#sourcebufferlist" class="tocxref"><span class="secno">5. </span>SourceBufferList Object</a><ul class="toc"><li class="tocline"><a href="#attributes-2" class="tocxref"><span class="secno">5.1 </span>Attributes</a></li><li class="tocline"><a href="#methods-2" class="tocxref"><span class="secno">5.2 </span>Methods</a></li><li class="tocline"><a href="#sourcebufferlist-events" class="tocxref"><span class="secno">5.3 </span>Event Summary</a></li></ul></li><li class="tocline"><a href="#url" class="tocxref"><span class="secno">6. </span>URL Object</a><ul class="toc"><li class="tocline"><a href="#methods-3" class="tocxref"><span class="secno">6.1 </span>Methods</a></li></ul></li><li class="tocline"><a href="#htmlmediaelement-attributes" class="tocxref"><span class="secno">7. </span>HTMLMediaElement attributes</a></li><li class="tocline"><a href="#byte-stream-formats" class="tocxref"><span class="secno">8. </span>Byte Stream Formats</a><ul class="toc"><li class="tocline"><a href="#webm" class="tocxref"><span class="secno">8.1 </span>WebM Byte Streams</a><ul class="toc"><li class="tocline"><a href="#webm-init-segments" class="tocxref"><span class="secno">8.1.1 </span>Initialization Segments</a></li><li class="tocline"><a href="#webm-media-segments" class="tocxref"><span class="secno">8.1.2 </span>Media Segments</a></li><li class="tocline"><a href="#webm-random-access-points" class="tocxref"><span class="secno">8.1.3 </span>Random Access Points</a></li></ul></li><li class="tocline"><a href="#iso" class="tocxref"><span class="secno">8.2 </span>ISO Base Media File Format Byte Streams</a><ul class="toc"><li class="tocline"><a href="#iso-init-segments" class="tocxref"><span class="secno">8.2.1 </span>Initialization Segments</a></li><li class="tocline"><a href="#iso-media-segments" class="tocxref"><span class="secno">8.2.2 </span>Media Segments</a></li><li class="tocline"><a href="#iso-random-access-points" class="tocxref"><span class="secno">8.2.3 </span>Random Access Points</a></li></ul></li><li class="tocline"><a href="#mpeg2ts" class="tocxref"><span class="secno">8.3 </span>MPEG-2 Transport Stream Byte Streams</a><ul class="toc"><li class="tocline"><a href="#mpeg2ts-general" class="tocxref"><span class="secno">8.3.1 </span>General</a></li><li class="tocline"><a href="#mpeg2ts-init-segments" class="tocxref"><span class="secno">8.3.2 </span>Initialization Segments</a></li><li class="tocline"><a href="#mpeg2ts-media-segments" class="tocxref"><span class="secno">8.3.3 </span>Media Segments</a></li><li class="tocline"><a href="#mpeg2ts-random-access-points" class="tocxref"><span class="secno">8.3.4 </span>Random Access Points</a></li><li class="tocline"><a href="#mpeg2ts-discontinuities" class="tocxref"><span class="secno">8.3.5 </span>Timestamp Rollover &amp; Discontinuities</a></li></ul></li></ul></li><li class="tocline"><a href="#examples" class="tocxref"><span class="secno">9. </span>Examples</a></li><li class="tocline"><a href="#revision-history" class="tocxref"><span class="secno">10. </span>Revision History</a></li></ul></section>
    2.42  
    2.43  
    2.44      <section id="introduction">
    2.45 @@ -575,7 +575,7 @@
    2.46            <dd>The parent media source of a <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a> object is the <a href="#idl-def-MediaSource" class="idlType"><code>MediaSource</code></a> object that created it.</dd>
    2.47  
    2.48            <dt id="append-sequence">Append Sequence</dt>
    2.49 -          <dd>A series of <code><a href="#widl-SourceBuffer-append-void-Uint8Array-data">append()</a></code> calls on a <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a> without any intervening <code><a href="#widl-SourceBuffer-abort-void">abort()</a></code> calls. The
    2.50 +          <dd>A series of <code><a href="#widl-SourceBuffer-appendArrayBuffer-void-ArrayBuffer-data">appendArrayBuffer()</a></code> or <code><a href="#widl-SourceBuffer-appendStream-void-Stream-stream-unsigned-long-long-maxSize">appendStream()</a></code> calls on a <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a> without any intervening <code><a href="#widl-SourceBuffer-abort-void">abort()</a></code> calls. The
    2.51            <a href="#media-segment">media segments</a> in an append sequence must be adjacent and monotonically increasing in time without any gaps. An
    2.52            <code><a href="#widl-SourceBuffer-abort-void">abort()</a></code> call starts a new append sequence which allows <a href="#media-segment">media segments</a> to be appended in non-monotonically
    2.53            increasing order.</dd>
    2.54 @@ -598,6 +598,9 @@
    2.55          <h3><span class="secno">2.1 </span>Appending a Media Segment over a buffered region</h3>
    2.56          <p>There are several ways that <a href="#media-segment">media segments</a> can overlap segments in the <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a>. Behavior for the different overlap situations are described below. If more than one overlap applies, then the <a href="#source-buffer-overlap-start">start overlap</a> must be resolved first, followed by any <a href="#source-buffer-overlap-complete">complete overlaps</a>, and finally the <a href="#source-buffer-overlap-end">end overlap</a>. If a segment contains multiple tracks then the overlap is resolved independently for each track.</p>
    2.57  
    2.58 +        <div class="issue"><div class="issue-title"><span>Issue 1</span></div><p class=""><a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=19673">Bug 19673</a> - Seamless audio signal transitions at splice points</p></div>
    2.59 +        <div class="issue"><div class="issue-title"><span>Issue 2</span></div><p class=""><a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=19784">Bug 19784</a> - timestampOffset with multiplexed Media Segments</p></div>
    2.60 +
    2.61          <section id="source-buffer-overlap-complete">
    2.62            <h4><span class="secno">2.1.1 </span>Complete Overlap</h4>
    2.63            <img src="complete_overlap.png" alt="Complete overlap diagram">
    2.64 @@ -678,6 +681,9 @@
    2.65  <span class="idlMethod">    <span class="idlMethType"><a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a>?</span> <span class="idlMethName"><a href="#widl-MediaSource-getSourceBuffer-SourceBuffer-AudioTrack-audioTrack">getSourceBuffer</a></span> (<span class="idlParam"><span class="idlParamType"><a>AudioTrack</a></span> <span class="idlParamName">audioTrack</span></span>);</span>
    2.66  <span class="idlMethod">    <span class="idlMethType"><a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a>?</span> <span class="idlMethName"><a href="#widl-MediaSource-getSourceBuffer-SourceBuffer-TextTrack-textTrack">getSourceBuffer</a></span> (<span class="idlParam"><span class="idlParamType"><a>TextTrack</a></span> <span class="idlParamName">textTrack</span></span>);</span>
    2.67  <span class="idlMethod">    <span class="idlMethType"><a>void</a></span>          <span class="idlMethName"><a href="#widl-MediaSource-endOfStream-void-EndOfStreamError-error">endOfStream</a></span> (<span class="idlParam">optional <span class="idlParamType"><a href="#idl-def-EndOfStreamError" class="idlType"><code>EndOfStreamError</code></a></span> <span class="idlParamName">error</span></span>);</span>
    2.68 +<span class="idlMethod">    <span class="idlMethType"><a>void</a></span>          <span class="idlMethName"><a href="#widl-MediaSource-setTrackInfo-void-VideoTrack-track-DOMString-kind-DOMString-language">setTrackInfo</a></span> (<span class="idlParam"><span class="idlParamType"><a>VideoTrack</a></span> <span class="idlParamName">track</span></span>, <span class="idlParam"><span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">kind</span></span>, <span class="idlParam"><span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">language</span></span>);</span>
    2.69 +<span class="idlMethod">    <span class="idlMethType"><a>void</a></span>          <span class="idlMethName"><a href="#widl-MediaSource-setTrackInfo-void-AudioTrack-track-DOMString-kind-DOMString-language">setTrackInfo</a></span> (<span class="idlParam"><span class="idlParamType"><a>AudioTrack</a></span> <span class="idlParamName">track</span></span>, <span class="idlParam"><span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">kind</span></span>, <span class="idlParam"><span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">language</span></span>);</span>
    2.70 +<span class="idlMethod">    <span class="idlMethType"><a>void</a></span>          <span class="idlMethName"><a href="#widl-MediaSource-setTrackInfo-void-TextTrack-track-DOMString-kind-DOMString-language">setTrackInfo</a></span> (<span class="idlParam"><span class="idlParamType"><a>TextTrack</a></span> <span class="idlParamName">track</span></span>, <span class="idlParam"><span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">kind</span></span>, <span class="idlParam"><span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">language</span></span>);</span>
    2.71  <span class="idlMethod">    static <span class="idlMethType"><a>bool</a></span>   <span class="idlMethName"><a href="#widl-MediaSource-isTypeSupported-bool-DOMString-type">isTypeSupported</a></span> (<span class="idlParam"><span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">type</span></span>);</span>
    2.72  };</span></pre><section id="attributes"><h3><span class="secno">3.1 </span>Attributes</h3><dl class="attributes"><dt id="widl-MediaSource-activeSourceBuffers"><code>activeSourceBuffers</code> of type <span class="idlAttrType"><a href="#idl-def-SourceBufferList" class="idlType"><code>SourceBufferList</code></a></span>, readonly</dt><dd>
    2.73            <p>Contains the subset of <code><a href="#widl-MediaSource-sourceBuffers">sourceBuffers</a></code> that are providing the 
    2.74 @@ -699,7 +705,7 @@
    2.75              <li>If the value being set is negative or NaN then throw an <code><a href="http://dom.spec.whatwg.org/#dom-domexception-invalid_access_err">INVALID_ACCESS_ERR</a></code> exception and abort these steps.</li>
    2.76              <li>If the <code><a href="#widl-MediaSource-readyState">readyState</a></code> attribute is not <code><a href="#idl-def-ReadyState">"open"</a></code> then throw an <code><a href="http://dom.spec.whatwg.org/#dom-domexception-invalid_state_err">INVALID_STATE_ERR</a></code> exception and abort these steps.</li>
    2.77              <li>Run the <a href="#duration-change-algorithm">duration change algorithm</a> with <var>new duration</var> set to the value being assigned to this attribute.
    2.78 -	      <div class="note"><div class="note-title"><span>Note</span></div><p class=""><code><a href="#widl-SourceBuffer-append-void-Uint8Array-data">append()</a></code> and <code><a href="#widl-MediaSource-endOfStream-void-EndOfStreamError-error">endOfStream()</a></code> can update the duration under certain circumstances.</p></div>
    2.79 +	      <div class="note"><div class="note-title"><span>Note</span></div><p class=""><code><a href="#widl-SourceBuffer-appendArrayBuffer-void-ArrayBuffer-data">appendArrayBuffer()</a></code>, <code><a href="#widl-SourceBuffer-appendStream-void-Stream-stream-unsigned-long-long-maxSize">appendStream()</a></code> and <code><a href="#widl-MediaSource-endOfStream-void-EndOfStreamError-error">endOfStream()</a></code> can update the duration under certain circumstances.</p></div>
    2.80              </li>
    2.81            </ol>
    2.82          </dd><dt id="widl-MediaSource-readyState"><code>readyState</code> of type <span class="idlAttrType"><a href="#idl-def-ReadyState" class="idlType"><code>ReadyState</code></a></span>, readonly</dt><dd>
    2.83 @@ -734,7 +740,7 @@
    2.84  	            <li>Run the <a href="#duration-change-algorithm">duration change algorithm</a> with <var>new duration</var> set to the highest end timestamp across all <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a> objects in <code><a href="#widl-MediaSource-sourceBuffers">sourceBuffers</a></code>.<br>
    2.85  		      <div class="note"><div class="note-title"><span>Note</span></div><p class="">This allows the duration to properly reflect the end of the appended media segments. For example, if the duration was explicitly set to 10 seconds and only media segments for 0 to 5 seconds were appended before endOfStream() was called, then the duration will get updated to 5 seconds.</p></div>
    2.86  	            </li>
    2.87 -	            <li>Notify the media element that it now has all of the media data. Playback should continue until all the media passed in via <code><a href="#widl-SourceBuffer-append-void-Uint8Array-data">append()</a></code> has been played.</li>
    2.88 +	            <li>Notify the media element that it now has all of the media data. Playback should continue until all the media passed in via <code><a href="#widl-SourceBuffer-appendArrayBuffer-void-ArrayBuffer-data">appendArrayBuffer()</a></code> and <code><a href="#widl-SourceBuffer-appendStream-void-Stream-stream-unsigned-long-long-maxSize">appendStream()</a></code> has been played.</li>
    2.89  	          </ol>
    2.90  	        </dd>
    2.91                  <dt>If <var>error</var> is set to <code><a href="#idl-def-EndOfStreamError">"network"</a></code>
    2.92 @@ -814,7 +820,16 @@
    2.93              <li>If <var>sourceBuffer</var> is in <code><a href="#widl-MediaSource-activeSourceBuffers">activeSourceBuffers</a></code>, then remove it from <code><a href="#widl-MediaSource-activeSourceBuffers">activeSourceBuffers</a></code> and <a href="http://dev.w3.org/html5/spec/webappapis.html#queue-a-task">queue a task</a> to <a href="http://dev.w3.org/html5/spec/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-evt-removesourcebuffer">removesourcebuffer</a></code> at <code><a href="#widl-MediaSource-activeSourceBuffers">activeSourceBuffers</a></code>.</li>
    2.94              <li>Remove <var>sourceBuffer</var> from <code><a href="#widl-MediaSource-sourceBuffers">sourceBuffers</a></code> and <a href="http://dev.w3.org/html5/spec/webappapis.html#queue-a-task">queue a task</a> to <a href="http://dev.w3.org/html5/spec/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-evt-removesourcebuffer">removesourcebuffer</a></code> at <code><a href="#widl-MediaSource-sourceBuffers">sourceBuffers</a></code>.</li>
    2.95              <li>Destroy all resources for <var>sourceBuffer</var>.</li>
    2.96 -          </ol></dd></dl></section>
    2.97 +          </ol></dd><dt id="widl-MediaSource-setTrackInfo-void-VideoTrack-track-DOMString-kind-DOMString-language"><code>setTrackInfo</code></dt><dd>
    2.98 +            <p>Set the <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-videotrack-kind">kind</a></code> and <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-videotrack-language">language</a></code> of the <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#videotrack">VideoTrack</a></code> <var>track</var>.</p>
    2.99 +            <div class="note"><div class="note-title"><span>Note</span></div><p class="">This method would be unnecessary if the <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-videotrack-kind">kind</a></code> and <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-videotrack-language">language</a></code> attributes of <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#videotrack">VideoTrack</a></code> were not read-only.</p></div>
   2.100 +        <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">track</td><td class="prmType"><code><a>VideoTrack</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr><tr><td class="prmName">kind</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr><tr><td class="prmName">language</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr></table><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-MediaSource-setTrackInfo-void-AudioTrack-track-DOMString-kind-DOMString-language"><code>setTrackInfo</code></dt><dd>
   2.101 +            <p>Set the <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-audiotrack-kind">kind</a></code> and <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-audiotrack-language">language</a></code> of the <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#audiotrack">AudioTrack</a></code> <var>track</var>.</p>
   2.102 +            <div class="note"><div class="note-title"><span>Note</span></div><p class="">This method would be unnecessary if the <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-audiotrack-kind">kind</a></code> and <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-audiotrack-language">language</a></code> attributes of <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#audiotrack">AudioTrack</a></code> were not read-only.</p></div>
   2.103 +        <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">track</td><td class="prmType"><code><a>AudioTrack</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr><tr><td class="prmName">kind</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr><tr><td class="prmName">language</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr></table><div><em>Return type: </em><code><a>void</a></code></div></dd><dt id="widl-MediaSource-setTrackInfo-void-TextTrack-track-DOMString-kind-DOMString-language"><code>setTrackInfo</code></dt><dd>
   2.104 +            <p>Set the <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-texttrack-kind">kind</a></code> and <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-texttrack-language">language</a></code> of the <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#texttrack">TextTrack</a></code> <var>track</var>.</p>
   2.105 +            <div class="note"><div class="note-title"><span>Note</span></div><p class="">This method would be unnecessary if the <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-texttrack-kind">kind</a></code> and <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-texttrack-language">language</a></code> attributes of <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#texttrack">TextTrack</a></code> were not read-only.</p></div>
   2.106 +        <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">track</td><td class="prmType"><code><a>TextTrack</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr><tr><td class="prmName">kind</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr><tr><td class="prmName">language</td><td class="prmType"><code><a>DOMString</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr></table><div><em>Return type: </em><code><a>void</a></code></div></dd></dl></section>
   2.107  
   2.108        <section id="mediasource-events">
   2.109          <h3><span class="secno">3.3 </span>Event Summary</h3>
   2.110 @@ -830,17 +845,17 @@
   2.111              <tr>
   2.112                <td><dfn id="dom-evt-sourceopen"><code>sourceopen</code></dfn></td>
   2.113                <td><code>Event</code></td>
   2.114 -              <td>When <code><a href="#widl-MediaSource-readyState">readyState</a></code> transitions from <code><a href="#idl-def-ReadyState">"closed"</a></code> to <code><a href="#idl-def-ReadyState">"open"</a></code> or from <code><a href="#idl-def-ReadyState">"ended"</a></code> to <code><a href="#idl-def-ReadyState">"open"</a></code>.</td>
   2.115 +              <td><code><a href="#widl-MediaSource-readyState">readyState</a></code> transitions from <code><a href="#idl-def-ReadyState">"closed"</a></code> to <code><a href="#idl-def-ReadyState">"open"</a></code> or from <code><a href="#idl-def-ReadyState">"ended"</a></code> to <code><a href="#idl-def-ReadyState">"open"</a></code>.</td>
   2.116              </tr>
   2.117              <tr>
   2.118                <td><dfn id="dom-evt-sourceended"><code>sourceended</code></dfn></td>
   2.119                <td><code>Event</code></td>
   2.120 -              <td>When <code><a href="#widl-MediaSource-readyState">readyState</a></code> transitions from <code><a href="#idl-def-ReadyState">"open"</a></code> to <code><a href="#idl-def-ReadyState">"ended"</a></code>.</td>
   2.121 +              <td><code><a href="#widl-MediaSource-readyState">readyState</a></code> transitions from <code><a href="#idl-def-ReadyState">"open"</a></code> to <code><a href="#idl-def-ReadyState">"ended"</a></code>.</td>
   2.122              </tr>
   2.123              <tr>
   2.124                <td><dfn id="dom-evt-sourceclose"><code>sourceclose</code></dfn></td>
   2.125                <td><code>Event</code></td>
   2.126 -	      <td>When <code><a href="#widl-MediaSource-readyState">readyState</a></code> transitions from <code><a href="#idl-def-ReadyState">"open"</a></code> to <code><a href="#idl-def-ReadyState">"closed"</a></code> or <code><a href="#idl-def-ReadyState">"ended"</a></code> to <code><a href="#idl-def-ReadyState">"closed"</a></code>.</td>
   2.127 +	      <td><code><a href="#widl-MediaSource-readyState">readyState</a></code> transitions from <code><a href="#idl-def-ReadyState">"open"</a></code> to <code><a href="#idl-def-ReadyState">"closed"</a></code> or <code><a href="#idl-def-ReadyState">"ended"</a></code> to <code><a href="#idl-def-ReadyState">"closed"</a></code>.</td>
   2.128              </tr>
   2.129            </tbody>
   2.130          </table>
   2.131 @@ -864,7 +879,7 @@
   2.132                  <li>Set the <code><a href="#widl-MediaSource-readyState">readyState</a></code> attribute to <code><a href="#idl-def-ReadyState">"open"</a></code>.</li>
   2.133                  <li>
   2.134                    <a href="http://dev.w3.org/html5/spec/webappapis.html#queue-a-task">Queue a task</a> to <a href="http://dev.w3.org/html5/spec/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-evt-sourceopen">sourceopen</a></code> at the <a href="#idl-def-MediaSource" class="idlType"><code>MediaSource</code></a>.</li>
   2.135 -                <li>Allow the <a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#concept-media-load-resource">resource fetch algorithm</a> to progress based on data passed in via <code><a href="#widl-SourceBuffer-append-void-Uint8Array-data">append()</a></code>.</li>
   2.136 +                <li>Allow the <a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#concept-media-load-resource">resource fetch algorithm</a> to progress based on data passed in via <code><a href="#widl-SourceBuffer-appendArrayBuffer-void-ArrayBuffer-data">appendArrayBuffer()</a></code> and <code><a href="#widl-SourceBuffer-appendStream-void-Stream-stream-unsigned-long-long-maxSize">appendStream()</a></code>.</li>
   2.137                </ol>
   2.138              </dd>
   2.139            </dl>
   2.140 @@ -898,7 +913,7 @@
   2.141  	        <dd>
   2.142  	          <ol>
   2.143  	            <li>Set the <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-media-readystate">HTMLMediaElement.readyState</a></code> attribute to <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-media-have_metadata">HAVE_METADATA</a></code>.</li>
   2.144 -	            <li>The media element waits for the necessary <a href="#media-segment">media segments</a> to be passed to <code><a href="#widl-SourceBuffer-append-void-Uint8Array-data">append()</a></code>.
   2.145 +	            <li>The media element waits for the necessary <a href="#media-segment">media segments</a> to be passed to <code><a href="#widl-SourceBuffer-appendArrayBuffer-void-ArrayBuffer-data">appendArrayBuffer()</a></code> or <code><a href="#widl-SourceBuffer-appendStream-void-Stream-stream-unsigned-long-long-maxSize">appendStream()</a></code>.
   2.146                        <div class="note"><div class="note-title"><span>Note</span></div><p class="">The web application can use <code><a href="#widl-SourceBuffer-buffered">buffered</a></code> to determine what the media element needs to resume playback.</p></div>
   2.147                      </li>
   2.148  	          </ol>
   2.149 @@ -918,6 +933,7 @@
   2.150            <h4><span class="secno">3.4.4 </span>SourceBuffer Monitoring</h4>
   2.151            <p>The following steps are periodically run during playback to make sure that all of the <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a> objects in <code><a href="#widl-MediaSource-activeSourceBuffers">activeSourceBuffers</a></code> have enough data to ensure uninterrupted playback. Appending new segments and changes to <code><a href="#widl-MediaSource-activeSourceBuffers">activeSourceBuffers</a></code> also cause these steps to run because they affect the conditions that trigger state transitions.</p>
   2.152            <div class="note"><div class="note-title"><span>Note</span></div><p class="">The web application can monitor changes in <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#dom-media-readystate">HTMLMediaElement.readyState</a></code> to drive <a href="#media-segment">media segment</a> appending.</p></div>
   2.153 +          <div class="issue"><div class="issue-title"><span>Issue 3</span></div><p class=""><a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=18592">Bug 18592</a> - How much is "enough data to ensure uninterrupted playback"</p></div>
   2.154            <dl class="switch">
   2.155              <dt>If <code><a href="#widl-SourceBuffer-buffered">buffered</a></code> for all objects in <code><a href="#widl-MediaSource-activeSourceBuffers">activeSourceBuffers</a></code> do not contain <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#timeranges">TimeRanges</a></code> for the current playback position:</dt>
   2.156              <dd>
   2.157 @@ -1048,13 +1064,19 @@
   2.158      <section id="sourcebuffer">
   2.159        <!--OddPage--><h2><span class="secno">4. </span>SourceBuffer Object</h2>
   2.160  
   2.161 +      <div class="issue"><div class="issue-title"><span>Issue 4</span></div><p class=""><a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=20327">Bug 20327</a> - Continuous splice flag</p></div>
   2.162 +
   2.163        <pre class="idl"><span class="idlInterface" id="idl-def-SourceBuffer">interface <span class="idlInterfaceID">SourceBuffer</span> : <span class="idlSuperclass"><a>EventTarget</a></span> {
   2.164 +<span class="idlAttribute">    readonly attribute <span class="idlAttrType"><a>boolean</a></span>    <span class="idlAttrName"><a href="#widl-SourceBuffer-appending">appending</a></span>;</span>
   2.165  <span class="idlAttribute">    readonly attribute <span class="idlAttrType"><a>TimeRanges</a></span> <span class="idlAttrName"><a href="#widl-SourceBuffer-buffered">buffered</a></span>;</span>
   2.166  <span class="idlAttribute">             attribute <span class="idlAttrType"><a>double</a></span>     <span class="idlAttrName"><a href="#widl-SourceBuffer-timestampOffset">timestampOffset</a></span>;</span>
   2.167 -<span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-SourceBuffer-append-void-Uint8Array-data">append</a></span> (<span class="idlParam"><span class="idlParamType"><a>Uint8Array</a></span> <span class="idlParamName">data</span></span>);</span>
   2.168 +<span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-SourceBuffer-appendArrayBuffer-void-ArrayBuffer-data">appendArrayBuffer</a></span> (<span class="idlParam"><span class="idlParamType"><a>ArrayBuffer</a></span> <span class="idlParamName">data</span></span>);</span>
   2.169 +<span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-SourceBuffer-appendStream-void-Stream-stream-unsigned-long-long-maxSize">appendStream</a></span> (<span class="idlParam"><span class="idlParamType"><a>Stream</a></span> <span class="idlParamName">stream</span></span>, <span class="idlParam">optional <span class="idlParamType"><a>unsigned long long</a></span> <span class="idlParamName">maxSize</span></span>);</span>
   2.170  <span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-SourceBuffer-abort-void">abort</a></span> ();</span>
   2.171  <span class="idlMethod">    <span class="idlMethType"><a>void</a></span> <span class="idlMethName"><a href="#widl-SourceBuffer-remove-void-double-start-double-end">remove</a></span> (<span class="idlParam"><span class="idlParamType"><a>double</a></span> <span class="idlParamName">start</span></span>, <span class="idlParam"><span class="idlParamType"><a>double</a></span> <span class="idlParamName">end</span></span>);</span>
   2.172 -};</span></pre><section id="attributes-1"><h3><span class="secno">4.1 </span>Attributes</h3><dl class="attributes"><dt id="widl-SourceBuffer-buffered"><code>buffered</code> of type <span class="idlAttrType"><a>TimeRanges</a></span>, readonly</dt><dd>
   2.173 +};</span></pre><section id="attributes-1"><h3><span class="secno">4.1 </span>Attributes</h3><dl class="attributes"><dt id="widl-SourceBuffer-appending"><code>appending</code> of type <span class="idlAttrType"><a>boolean</a></span>, readonly</dt><dd>
   2.174 +          <p>Indicates whether an <code><a href="#widl-SourceBuffer-appendArrayBuffer-void-ArrayBuffer-data">appendArrayBuffer()</a></code> or <code><a href="#widl-SourceBuffer-appendStream-void-Stream-stream-unsigned-long-long-maxSize">appendStream()</a></code> operation is still being processed.</p>
   2.175 +        </dd><dt id="widl-SourceBuffer-buffered"><code>buffered</code> of type <span class="idlAttrType"><a>TimeRanges</a></span>, readonly</dt><dd>
   2.176            <p>Indicates what <code><a href="http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#timeranges">TimeRanges</a></code> are buffered in the <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a>.</p>
   2.177            <p>When the attribute is read the following steps must occur:</p>
   2.178            <ol>
   2.179 @@ -1064,13 +1086,14 @@
   2.180          </dd><dt id="widl-SourceBuffer-timestampOffset"><code>timestampOffset</code> of type <span class="idlAttrType"><a>double</a></span></dt><dd>
   2.181            <p>Controls the offset applied to timestamps inside subsequent <a href="#media-segment">media segments</a> that are appended to this <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a>. The <code><a href="#widl-SourceBuffer-timestampOffset">timestampOffset</a></code> is initially set to 0 which indicates that no offset is being applied.</p>
   2.182            <p>On getting, Return the initial value or the last value that was successfully set.</p>
   2.183 -          <p>On setting, run following steps:</p>
   2.184 +          <p>On setting, run the following steps:</p>
   2.185            <ol>
   2.186              <li>If this object has been removed from the <code><a href="#widl-MediaSource-sourceBuffers">sourceBuffers</a></code> attribute of the <a href="#parent-media-source">parent media source</a>, then throw an <code><a href="http://dom.spec.whatwg.org/#dom-domexception-invalid_state_err">INVALID_STATE_ERR</a></code> exception and abort these steps.</li>
   2.187              <li>If the <code><a href="#widl-MediaSource-readyState">readyState</a></code> attribute of the <a href="#parent-media-source">parent media source</a> is not in the <code><a href="#idl-def-ReadyState">"open"</a></code> state, then throw an <code><a href="http://dom.spec.whatwg.org/#dom-domexception-invalid_state_err">INVALID_STATE_ERR</a></code> exception and abort these steps.</li>
   2.188              <li>If this object is waiting for the end of a <a href="#media-segment">media segment</a> to be appended, then throw an <code><a href="http://dom.spec.whatwg.org/#dom-domexception-invalid_state_err">INVALID_STATE_ERR</a></code> and abort these steps.</li>
   2.189              <li>Update the attribute to the new value.</li>
   2.190            </ol>
   2.191 +          <div class="issue"><div class="issue-title"><span>Issue 5</span></div><p class=""><a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=19676">Bug 19676</a> - timestampOffset accuracy</p></div>
   2.192          </dd></dl></section><section id="methods-1"><h3><span class="secno">4.2 </span>Methods</h3><dl class="methods"><dt id="widl-SourceBuffer-abort-void"><code>abort</code></dt><dd>
   2.193            <p>Aborts the current segment and resets the segment parser.</p>
   2.194  
   2.195 @@ -1078,17 +1101,22 @@
   2.196          <div><em>No parameters.</em></div><div><em>Return type: </em><code><a>void</a></code></div><p>When this method is invoked, the user agent must run the following steps:</p><ol class="method-algorithm">
   2.197              <li>If this object has been removed from the <code><a href="#widl-MediaSource-sourceBuffers">sourceBuffers</a></code> attribute of the <a href="#parent-media-source">parent media source</a> then throw an <code><a href="http://dom.spec.whatwg.org/#dom-domexception-invalid_state_err">INVALID_STATE_ERR</a></code> exception and abort these steps.</li>
   2.198              <li>If the <code><a href="#widl-MediaSource-readyState">readyState</a></code> attribute of the <a href="#parent-media-source">parent media source</a> is not in the <code><a href="#idl-def-ReadyState">"open"</a></code> state then throw an <code><a href="http://dom.spec.whatwg.org/#dom-domexception-invalid_state_err">INVALID_STATE_ERR</a></code> exception and abort these steps.</li>
   2.199 -            <li>If the <var><a href="#sourcebuffer-append-state">append state</a></var> equals <a href="#sourcebuffer-parsing-media-segment">PARSING_MEDIA_SEGMENT</a> and the <var><a href="#sourcebuffer-input-buffer">input buffer</a></var> contains some complete <a href="#coded-frame">coded frames</a>, then run the <a href="#sourcebuffer-coded-frame-processing">coded frame processing algorithm</a> as if the media segment only contained these frames.</li>
   2.200 -            <li>Unset the <var><a href="#last-decode-timestamp">last decode timestamp</a></var> on all <a href="#track-buffer">track buffers</a>.</li>
   2.201 -            <li>Remove all bytes from the <var><a href="#sourcebuffer-input-buffer">input buffer</a></var>.</li>
   2.202 -            <li>Set <var><a href="#sourcebuffer-append-state">append state</a></var> to <a href="#sourcebuffer-waiting-for-segment">WAITING_FOR_SEGMENT</a>.</li>
   2.203 -          </ol></dd><dt id="widl-SourceBuffer-append-void-Uint8Array-data"><code>append</code></dt><dd>
   2.204 -          <p>Appends segment data to the source buffer.</p>
   2.205 +            <li>Run the <a href="#sourcebuffer-reset-parser-state">reset parser state algorithm</a>.</li>
   2.206 +            <li>If the <code><a href="#widl-SourceBuffer-appending">appending</a></code> attribute equals true, then run the following steps:
   2.207 +              <ol>
   2.208 +                <li>Set the <code><a href="#widl-SourceBuffer-appending">appending</a></code> attribute to false.</li>
   2.209 +                <li><a href="http://dev.w3.org/html5/spec/webappapis.html#queue-a-task">Queue a task</a> to <a href="http://dev.w3.org/html5/spec/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-evt-abort">abort</a></code> at this <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a> object.</li>
   2.210 +                <li><a href="http://dev.w3.org/html5/spec/webappapis.html#queue-a-task">Queue a task</a> to <a href="http://dev.w3.org/html5/spec/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-evt-appendend">appendend</a></code> at this <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a> object.</li>
   2.211 +              </ol>
   2.212 +            </li>
   2.213 +          </ol></dd><dt id="widl-SourceBuffer-appendArrayBuffer-void-ArrayBuffer-data"><code>appendArrayBuffer</code></dt><dd>
   2.214 +          <p>Appends the segment data in an ArrayBuffer to the source buffer.</p>
   2.215  
   2.216            
   2.217 -        <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">data</td><td class="prmType"><code><a>Uint8Array</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr></table><div><em>Return type: </em><code><a>void</a></code></div><p>When this method is invoked, the user agent must run the following steps:</p><ol class="method-algorithm">
   2.218 +        <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">data</td><td class="prmType"><code><a>ArrayBuffer</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr></table><div><em>Return type: </em><code><a>void</a></code></div><p>When this method is invoked, the user agent must run the following steps:</p><ol class="method-algorithm">
   2.219              <li>If <var>data</var> is null then throw an <code><a href="http://dom.spec.whatwg.org/#dom-domexception-invalid_access_err">INVALID_ACCESS_ERR</a></code> exception and abort these steps.</li>
   2.220              <li>If this object has been removed from the <code><a href="#widl-MediaSource-sourceBuffers">sourceBuffers</a></code> attribute of the <a href="#parent-media-source">parent media source</a> then throw an <code><a href="http://dom.spec.whatwg.org/#dom-domexception-invalid_state_err">INVALID_STATE_ERR</a></code> exception and abort these steps.</li>
   2.221 +            <li>If the <code><a href="#widl-SourceBuffer-appending">appending</a></code> attribute equals true, then throw an <code><a href="http://dom.spec.whatwg.org/#dom-domexception-invalid_state_err">INVALID_STATE_ERR</a></code> exception and abort these steps.</li>
   2.222              <li>If the <code><a href="#widl-MediaSource-readyState">readyState</a></code> attribute of the <a href="#parent-media-source">parent media source</a> is in the <code><a href="#idl-def-ReadyState">"closed"</a></code> state then throw an <code><a href="http://dom.spec.whatwg.org/#dom-domexception-invalid_state_err">INVALID_STATE_ERR</a></code> exception and abort these steps.</li>
   2.223              <li>
   2.224                <p>If the <code><a href="#widl-MediaSource-readyState">readyState</a></code> attribute of the <a href="#parent-media-source">parent media source</a> is in the <code><a href="#idl-def-ReadyState">"ended"</a></code> state then run the following steps:</p>
   2.225 @@ -1104,9 +1132,38 @@
   2.226                <p>If the <var><a href="#sourcebuffer-buffer-full-flag">buffer full flag</a></var> equals true, then throw a <code><a href="http://dom.spec.whatwg.org/#dom-domexception-quota_exceeded_err">QUOTA_EXCEEDED_ERR</a></code> exception and abort these step.</p>
   2.227                <div class="note"><div class="note-title"><span>Note</span></div><p class="">The web application must use <code><a href="#widl-SourceBuffer-remove-void-double-start-double-end">remove()</a></code> to free up space in the <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a>.</p></div>
   2.228              </li>
   2.229 -            <li>Add <var>data</var> to the end of the <var><a href="#sourcebuffer-input-buffer">input buffer</a></var>
   2.230 +            <li>Add <var>data</var> to the end of the <var><a href="#sourcebuffer-input-buffer">input buffer</a></var>.</li>
   2.231 +            <li>Set the <code><a href="#widl-SourceBuffer-appending">appending</a></code> attribute to true.</li>
   2.232 +            <li><a href="http://dev.w3.org/html5/spec/webappapis.html#queue-a-task">Queue a task</a> to <a href="http://dev.w3.org/html5/spec/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-evt-appendstart">appendstart</a></code> at this <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a> object.</li>
   2.233 +            <li>Asynchronously run the <a href="#sourcebuffer-segment-parser-loop">segment parser loop</a> algorithm.</li>
   2.234 +          </ol></dd><dt id="widl-SourceBuffer-appendStream-void-Stream-stream-unsigned-long-long-maxSize"><code>appendStream</code></dt><dd>
   2.235 +          <p>Appends segment data to the source buffer from a <a href="http://dvcs.w3.org/hg/streams-api/raw-file/tip/Overview.htm#idl-def-Stream">Stream</a>.</p>
   2.236 +
   2.237 +          
   2.238 +        <table class="parameters"><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">stream</td><td class="prmType"><code><a>Stream</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptFalse">✘</td><td class="prmDesc"></td></tr><tr><td class="prmName">maxSize</td><td class="prmType"><code><a>unsigned long long</a></code></td><td class="prmNullFalse">✘</td><td class="prmOptTrue">✔</td><td class="prmDesc"></td></tr></table><div><em>Return type: </em><code><a>void</a></code></div><p>When this method is invoked, the user agent must run the following steps:</p><ol class="method-algorithm">
   2.239 +            <li>If <var>stream</var> is null then throw an <code><a href="http://dom.spec.whatwg.org/#dom-domexception-invalid_access_err">INVALID_ACCESS_ERR</a></code> exception and abort these steps.</li>
   2.240 +            <li>If this object has been removed from the <code><a href="#widl-MediaSource-sourceBuffers">sourceBuffers</a></code> attribute of the <a href="#parent-media-source">parent media source</a> then throw
   2.241 +              an <code><a href="http://dom.spec.whatwg.org/#dom-domexception-invalid_state_err">INVALID_STATE_ERR</a></code> exception and abort these steps.</li>
   2.242 +            <li>If the <code><a href="#widl-MediaSource-readyState">readyState</a></code> attribute of the <a href="#parent-media-source">parent media source</a> is in the <code><a href="#idl-def-ReadyState">"closed"</a></code> state then throw
   2.243 +              an <code><a href="http://dom.spec.whatwg.org/#dom-domexception-invalid_state_err">INVALID_STATE_ERR</a></code> exception and abort these steps.</li>
   2.244 +            <li>If the <code><a href="#widl-SourceBuffer-appending">appending</a></code> attribute equals true, then throw an <code><a href="http://dom.spec.whatwg.org/#dom-domexception-invalid_state_err">INVALID_STATE_ERR</a></code> exception and abort these
   2.245 +              steps.</li>
   2.246 +            <li>
   2.247 +              <p>If the <code><a href="#widl-MediaSource-readyState">readyState</a></code> attribute of the <a href="#parent-media-source">parent media source</a> is in the <code><a href="#idl-def-ReadyState">"ended"</a></code> state then run
   2.248 +                the following steps:</p>
   2.249 +              <ol>
   2.250 +	        <li>Set the <code><a href="#widl-MediaSource-readyState">readyState</a></code> attribute of the <a href="#parent-media-source">parent media source</a> to <code><a href="#idl-def-ReadyState">"open"</a></code></li>
   2.251 +	        <li><a href="http://dev.w3.org/html5/spec/webappapis.html#queue-a-task">Queue a task</a> to <a href="http://dev.w3.org/html5/spec/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-evt-sourceopen">sourceopen</a></code> at the <a href="#parent-media-source">parent media source</a> .</li>
   2.252 +              </ol>
   2.253              </li>
   2.254 -            <li>Run the <a href="#sourcebuffer-segment-parser-loop">segment parser loop</a>.</li>
   2.255 +            <li>If <var>maxSize</var> equals 0, then abort these steps.</li>
   2.256 +            <li>
   2.257 +              <p>If the <var><a href="#sourcebuffer-buffer-full-flag">buffer full flag</a></var> equals true, then throw a <code><a href="http://dom.spec.whatwg.org/#dom-domexception-quota_exceeded_err">QUOTA_EXCEEDED_ERR</a></code> exception and abort these step.</p>
   2.258 +              <div class="note"><div class="note-title"><span>Note</span></div><p class="">The web application must use <code><a href="#widl-SourceBuffer-remove-void-double-start-double-end">remove()</a></code> to free up space in the <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a>.</p></div>
   2.259 +            </li>
   2.260 +            <li>Set the <code><a href="#widl-SourceBuffer-appending">appending</a></code> attribute to true.</li>
   2.261 +            <li><a href="http://dev.w3.org/html5/spec/webappapis.html#queue-a-task">Queue a task</a> to <a href="http://dev.w3.org/html5/spec/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-evt-appendstart">appendstart</a></code> at this <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a> object.</li>
   2.262 +            <li>Asynchronously run the <a href="#sourcebuffer-stream-append-loop">stream append loop</a> algorithm with <var>stream</var> and <var>maxSize</var>.</li>
   2.263            </ol></dd><dt id="widl-SourceBuffer-remove-void-double-start-double-end"><code>remove</code></dt><dd>
   2.264            <p>Removes media for a specific time range.</p>
   2.265  
   2.266 @@ -1147,11 +1204,46 @@
   2.267            unset to indicate that no <a href="#coded-frame">coded frames</a> have been appended yet.</p>
   2.268        </section>
   2.269  
   2.270 +      <section id="sourcebuffer-events">
   2.271 +        <h3><span class="secno">4.4 </span>Event Summary</h3>
   2.272 +        <table class="old-table">
   2.273 +          <thead>
   2.274 +            <tr>
   2.275 +              <th>Event name</th>
   2.276 +              <th>Interface</th>
   2.277 +              <th>Dispatched when...</th>
   2.278 +            </tr>
   2.279 +          </thead>
   2.280 +          <tbody>
   2.281 +            <tr>
   2.282 +              <td><dfn id="dom-evt-appendstart"><code>appendstart</code></dfn></td>
   2.283 +              <td><code>Event</code></td>
   2.284 +              <td><code><a href="#widl-SourceBuffer-appending">appending</a></code> transitions from false to true.</td>
   2.285 +            </tr>
   2.286 +            <tr>
   2.287 +              <td><dfn id="dom-evt-appendend"><code>appendend</code></dfn></td>
   2.288 +              <td><code>Event</code></td>
   2.289 +              <td><code><a href="#widl-SourceBuffer-appending">appending</a></code> transitions from true to false.</td>
   2.290 +            </tr>
   2.291 +            <tr>
   2.292 +              <td><dfn id="dom-evt-error"><code>error</code></dfn></td>
   2.293 +              <td><code>Event</code></td>
   2.294 +              <td>An error occurred during the append.</td>
   2.295 +            </tr>
   2.296 +            <tr>
   2.297 +              <td><dfn id="dom-evt-abort"><code>abort</code></dfn></td>
   2.298 +              <td><code>Event</code></td>
   2.299 +              <td>The append was aborted by an <code><a href="#widl-SourceBuffer-abort-void">abort()</a></code> call.</td>
   2.300 +            </tr>
   2.301 +          </tbody>
   2.302 +        </table>
   2.303 +      </section>
   2.304 +
   2.305        <section id="sourcebuffer-algorithms">
   2.306 -        <h3><span class="secno">4.4 </span>Algorithms</h3>
   2.307 +        <h3><span class="secno">4.5 </span>Algorithms</h3>
   2.308  
   2.309          <section id="sourcebuffer-segment-parser-loop">
   2.310 -          <h4><span class="secno">4.4.1 </span>Segment Parser Loop</h4>
   2.311 +          <h4><span class="secno">4.5.1 </span>Segment Parser Loop</h4>
   2.312            <p>All SourceBuffer objects have an internal <dfn id="sourcebuffer-append-state">append state</dfn> variable that keeps track of the high-level segment parsing state. It is initially set to <a href="#sourcebuffer-waiting-for-segment">WAITING_FOR_SEGMENT</a> and can transition to the following states as data is appended.</p>
   2.313            <table class="old-table">
   2.314              <thead>
   2.315 @@ -1176,39 +1268,42 @@
   2.316              </tbody>
   2.317            </table>
   2.318            
   2.319 -          <p>The <dfn id="sourcebuffer-input-buffer">input buffer</dfn> is a byte buffer that is used to hold unparsed bytes across <code><a href="#widl-SourceBuffer-append-void-Uint8Array-data">append()</a></code> calls. The buffer is empty when the SourceBuffer object is created.</p>
   2.320 +          <p>The <dfn id="sourcebuffer-input-buffer">input buffer</dfn> is a byte buffer that is used to hold unparsed bytes across <code><a href="#widl-SourceBuffer-appendArrayBuffer-void-ArrayBuffer-data">appendArrayBuffer()</a></code> and <code><a href="#widl-SourceBuffer-appendStream-void-Stream-stream-unsigned-long-long-maxSize">appendStream()</a></code> calls. The buffer is empty when the SourceBuffer object is created.</p>
   2.321  
   2.322 -          <p>The <dfn id="sourcebuffer-buffer-full-flag">buffer full flag</dfn> keeps track of whether <code><a href="#widl-SourceBuffer-append-void-Uint8Array-data">append()</a></code> is allowed to accept more
   2.323 -            bytes. It is set to false when the SourceBuffer object is created and gets updated as data is appended and removed.</p>
   2.324 +          <p>The <dfn id="sourcebuffer-buffer-full-flag">buffer full flag</dfn> keeps track of whether <code><a href="#widl-SourceBuffer-appendArrayBuffer-void-ArrayBuffer-data">appendArrayBuffer()</a></code> or 
   2.325 +            <code><a href="#widl-SourceBuffer-appendStream-void-Stream-stream-unsigned-long-long-maxSize">appendStream()</a></code> is allowed to accept more bytes. It is set to false when the SourceBuffer object is created and gets updated 
   2.326 +            as data is appended and removed.</p>
   2.327  
   2.328 -          <p>While the <var><a href="#sourcebuffer-input-buffer">input buffer</a></var> is not empty, run the following steps in a loop:</p>
   2.329 +          <p>When this algorithm is invoked, run the following steps:</p>
   2.330 +
   2.331            <ol>
   2.332 -            <li>If the <var><a href="#sourcebuffer-input-buffer">input buffer</a></var> starts with bytes that violate the <a href="#byte-stream-formats">byte stream format specifications</a>, then call <code><a href="#widl-MediaSource-endOfStream-void-EndOfStreamError-error">endOfStream("decode")</a></code>, and abort this algorithm.</li>
   2.333 +            <li><i>Loop Top:</i> If the <var><a href="#sourcebuffer-input-buffer">input buffer</a></var> is empty, then jump to the <i>need more data</i> step below.</li>
   2.334 +            <li>If the <var><a href="#sourcebuffer-input-buffer">input buffer</a></var> starts with bytes that violate the <a href="#byte-stream-formats">byte stream format specifications</a>, then run the <a href="#sourcebuffer-append-error">append error algorithm</a> and abort this algorithm.</li>
   2.335              <li>Remove any bytes that the <a href="#byte-stream-formats">byte stream format specifications</a> say should be ignored from the start of the <var><a href="#sourcebuffer-input-buffer">input buffer</a></var>.</li>
   2.336              <li>
   2.337  	      <p>If the <var><a href="#sourcebuffer-append-state">append state</a></var> equals <a href="#sourcebuffer-waiting-for-segment">WAITING_FOR_SEGMENT</a>, then run the following steps:</p>
   2.338  	      <ol>
   2.339  	        <li>If the beginning of the <var><a href="#sourcebuffer-input-buffer">input buffer</a></var> indicates the start of an <a href="#init-segment">initialization segment</a>, set the <var><a href="#sourcebuffer-append-state">append state</a></var> to <a href="#sourcebuffer-parsing-init-segment">PARSING_INIT_SEGMENT</a>.</li>
   2.340  	        <li>If the beginning of the <var><a href="#sourcebuffer-input-buffer">input buffer</a></var> indicates the start of an <a href="#media-segment">media segment</a>, set <var><a href="#sourcebuffer-append-state">append state</a></var> to <a href="#sourcebuffer-parsing-media-segment">PARSING_MEDIA_SEGMENT</a>.</li>
   2.341 -	        <li>Return  to the top of the loop.</li>
   2.342 +	        <li>Jump to the <i>loop top</i> step above.</li>
   2.343  	      </ol>
   2.344              </li>
   2.345              <li>
   2.346  	      <p>If the <var><a href="#sourcebuffer-append-state">append state</a></var> equals <a href="#sourcebuffer-parsing-init-segment">PARSING_INIT_SEGMENT</a>, then run the following steps:</p>
   2.347  	      <ol>
   2.348 -	        <li>If the <var><a href="#sourcebuffer-input-buffer">input buffer</a></var> does not contain a complete <a href="#init-segment">initialization segment</a> yet, then exit the loop.</li>
   2.349 +	        <li>If the <var><a href="#sourcebuffer-input-buffer">input buffer</a></var> does not contain a complete <a href="#init-segment">initialization segment</a> yet, then jump to the <i>need more data</i> step below.</li>
   2.350  	        <li>Run the <a href="#sourcebuffer-init-segment-received">initialization segment received algorithm</a>.</li>
   2.351  	        <li>Remove the <a href="#init-segment">initialization segment</a> bytes from the beginning of the <var><a href="#sourcebuffer-input-buffer">input buffer</a></var>.</li>
   2.352  	        <li>Set <var><a href="#sourcebuffer-append-state">append state</a></var> to <a href="#sourcebuffer-waiting-for-segment">WAITING_FOR_SEGMENT</a>.</li>
   2.353 -	        <li>Return  to the top of the loop.</li>
   2.354 +	        <li>Jump to the <i>loop top</i> step above.</li>
   2.355  	      </ol>
   2.356              </li>
   2.357              <li>
   2.358  	      <p>If the <var><a href="#sourcebuffer-append-state">append state</a></var> equals <a href="#sourcebuffer-parsing-media-segment">PARSING_MEDIA_SEGMENT</a>, then run the following steps:</p>
   2.359  	      <ol>
   2.360 -                <li>If the <var><a href="#first-init-segment-flag">first initialization segment flag</a></var> is false, then run <code><a href="#widl-MediaSource-endOfStream-void-EndOfStreamError-error">endOfStream("decode")</a></code> and exit the loop.</li>
   2.361 +                <li>If the <var><a href="#first-init-segment-flag">first initialization segment flag</a></var> is false, then run the <a href="#sourcebuffer-append-error">append error algorithm</a> and abort this algorithm.</li>
   2.362  	        <li>
   2.363 -	          <p>If the <var><a href="#sourcebuffer-input-buffer">input buffer</a></var> does not contain a complete <a href="#media-segment">media segment</a> header yet, then exit the loop.</p>
   2.364 +	          <p>If the <var><a href="#sourcebuffer-input-buffer">input buffer</a></var> does not contain a complete <a href="#media-segment">media segment</a> header yet, then jump to the <i>need more data</i> step below.</p>
   2.365  	          <div class="note"><div class="note-title"><span>Note</span></div><p class="">Implementations may choose to implement this state as an incremental parser so that it is not necessary to have the entire media segment before running the <a href="#sourcebuffer-coded-frame-processing">coded frame processing algorithm</a>.</p></div>
   2.366  	        </li>
   2.367  	        <li>Run the <a href="#sourcebuffer-coded-frame-processing">coded frame processing algorithm</a>.</li>
   2.368 @@ -1218,14 +1313,79 @@
   2.369  	          <p>Set <var><a href="#sourcebuffer-append-state">append state</a></var> to <a href="#sourcebuffer-waiting-for-segment">WAITING_FOR_SEGMENT</a>.</p>
   2.370  	          <div class="note"><div class="note-title"><span>Note</span></div><p class="">Incremental parsers should only do this transition after the entire media segment has been received.</p></div>
   2.371  	        </li>
   2.372 -	        <li>Return  to the top of the loop.</li>
   2.373 +	        <li>Jump to the <i>loop top</i> step above.</li>
   2.374  	      </ol>
   2.375              </li>
   2.376 +            <li><i>Need more data:</i> If the <a href="#sourcebuffer-stream-append-loop">stream append loop</a> algorithm is running and still has data to read, then abort these steps.
   2.377 +            </li><li>Set the <code><a href="#widl-SourceBuffer-appending">appending</a></code> attribute to false.</li>
   2.378 +            <li><a href="http://dev.w3.org/html5/spec/webappapis.html#queue-a-task">Queue a task</a> to <a href="http://dev.w3.org/html5/spec/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-evt-appendend">appendend</a></code> at this <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a> object.</li>
   2.379 +          </ol>
   2.380 +        </section>
   2.381 +
   2.382 +        <section id="sourcebuffer-reset-parser-state">
   2.383 +          <h4><span class="secno">4.5.2 </span>Reset Parser State</h4>
   2.384 +          <p>When the parser state needs to be reset, run the following steps:</p>
   2.385 +          <ol>
   2.386 +            <li>If the <var><a href="#sourcebuffer-append-state">append state</a></var> equals <a href="#sourcebuffer-parsing-media-segment">PARSING_MEDIA_SEGMENT</a> and the <var><a href="#sourcebuffer-input-buffer">input buffer</a></var> contains some complete <a href="#coded-frame">coded frames</a>, then run the <a href="#sourcebuffer-coded-frame-processing">coded frame processing algorithm</a> as if the media segment only contained these frames.</li>
   2.387 +            <li>Unset the <var><a href="#last-decode-timestamp">last decode timestamp</a></var> on all <a href="#track-buffer">track buffers</a>.</li>
   2.388 +            <li>Remove all bytes from the <var><a href="#sourcebuffer-input-buffer">input buffer</a></var>.</li>
   2.389 +            <li>Set <var><a href="#sourcebuffer-append-state">append state</a></var> to <a href="#sourcebuffer-waiting-for-segment">WAITING_FOR_SEGMENT</a>.</li>
   2.390 +          </ol>
   2.391 +        </section>
   2.392 +
   2.393 +        <section id="sourcebuffer-append-error">
   2.394 +          <h4><span class="secno">4.5.3 </span>Append Error</h4>
   2.395 +          <p>When an error occurs during an append, run the following steps:</p>
   2.396 +          <ol>
   2.397 +            <li>Run the <a href="#sourcebuffer-reset-parser-state">reset parser state algorithm</a>.</li>
   2.398 +            <li>Abort the <a href="#sourcebuffer-stream-append-loop">stream append loop</a> algorithm if it is running.</li>
   2.399 +            <li>Set the <code><a href="#widl-SourceBuffer-appending">appending</a></code> attribute to false.</li>
   2.400 +            <li>
   2.401 +              <a href="http://dev.w3.org/html5/spec/webappapis.html#queue-a-task">Queue a task</a> to <a href="http://dev.w3.org/html5/spec/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-evt-error">error</a></code> at this <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a> object.
   2.402 +              <div class="issue"><div class="issue-title"><span>Issue 6</span></div><p class="">Need a way to convey error information.</p></div>
   2.403 +            </li>
   2.404 +            <li><a href="http://dev.w3.org/html5/spec/webappapis.html#queue-a-task">Queue a task</a> to <a href="http://dev.w3.org/html5/spec/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-evt-appendend">appendend</a></code> at this <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a> object.</li>
   2.405 +          </ol>
   2.406 +        </section>
   2.407 +
   2.408 +        <section id="sourcebuffer-stream-append-loop">
   2.409 +          <h4><span class="secno">4.5.4 </span>Stream Append Loop</h4>
   2.410 +          <p>When a <a href="http://dvcs.w3.org/hg/streams-api/raw-file/tip/Overview.htm#idl-def-Stream">Stream</a> is passed to <code><a href="#widl-SourceBuffer-appendStream-void-Stream-stream-unsigned-long-long-maxSize">appendStream()</a></code>, the following steps are run to transfer data from the
   2.411 +            <a href="http://dvcs.w3.org/hg/streams-api/raw-file/tip/Overview.htm#idl-def-Stream">Stream</a> to the <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a>. This algorithm is initialized with the  <var>stream</var> and <var>maxSize</var> parameters
   2.412 +            from the <code><a href="#widl-SourceBuffer-appendStream-void-Stream-stream-unsigned-long-long-maxSize">appendStream()</a></code> call.
   2.413 +          </p>
   2.414 +          <ol>
   2.415 +            <li>If <var>maxSize</var> is set, then let <var>bytesLeft</var> equal <var>maxSize</var>.</li>
   2.416 +            <li><i>Loop Top: </i>If <var>maxSize</var> is set and <var>bytesLeft</var> equals 0, then jump to the <i>loop done</i> step below.</li>
   2.417 +            <li>If <var>stream</var> has been aborted, then run the <a href="#sourcebuffer-append-error">append error algorithm</a> and abort this algorithm.</li>
   2.418 +            <li>If <var>stream</var> has been closed, then jump to the <i>loop done</i> step below.</li>
   2.419 +            <li>
   2.420 +              <p>If the <var><a href="#sourcebuffer-buffer-full-flag">buffer full flag</a></var> equals true, then run the <a href="#sourcebuffer-append-error">append error algorithm</a> and abort this algorithm.</p>
   2.421 +              <div class="note"><div class="note-title"><span>Note</span></div><p class="">The web application must use <code><a href="#widl-SourceBuffer-remove-void-double-start-double-end">remove()</a></code> to free up space in the <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a>.</p></div>
   2.422 +            </li>
   2.423 +            <li>Read data from <var>stream</var> into <var>data</var>:
   2.424 +              <dl class="switch">
   2.425 +                <dt>If <var>maxSize</var> is set:</dt>
   2.426 +                <dd>
   2.427 +                  <ol>
   2.428 +                    <li>Read up to <var>bytesLeft</var> bytes from <var>stream</var> into <var>data</var>.</li>
   2.429 +                    <li>Subtract the number of bytes in <var>data</var> from <var>bytesLeft</var>.</li>
   2.430 +                </ol></dd>
   2.431 +                <dt>Otherwise:</dt>
   2.432 +                <dd>Read all available bytes in <var>stream</var> into <var>data</var>.</dd>
   2.433 +              </dl>
   2.434 +            </li>
   2.435 +            <li>If an error occured while reading from <var>stream</var>, then run the <a href="#sourcebuffer-append-error">append error algorithm</a> and abort this algorithm.</li>
   2.436 +            <li>Add <var>data</var> to the end of the <var><a href="#sourcebuffer-input-buffer">input buffer</a></var>.</li>
   2.437 +            <li>Run the <a href="#sourcebuffer-segment-parser-loop">segment parser loop</a> algorithm.</li>
   2.438 +            <li>Jump to the <i>loop top</i> step above.</li>
   2.439 +            <li><i>Loop Done: </i>Set the <code><a href="#widl-SourceBuffer-appending">appending</a></code> attribute to false.</li>
   2.440 +            <li><a href="http://dev.w3.org/html5/spec/webappapis.html#queue-a-task">Queue a task</a> to <a href="http://dev.w3.org/html5/spec/webappapis.html#fire-a-simple-event">fire a simple event</a> named <code><a href="#dom-evt-appendend">appendend</a></code> at this <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a> object.</li>
   2.441            </ol>
   2.442          </section>
   2.443  
   2.444          <section id="sourcebuffer-init-segment-received">
   2.445 -          <h4><span class="secno">4.4.2 </span>Initialization Segment Received</h4>
   2.446 +          <h4><span class="secno">4.5.5 </span>Initialization Segment Received</h4>
   2.447            <p>The following steps are run when the <a href="#sourcebuffer-segment-parser-loop">segment parser loop</a> successfully parses a complete <a href="#init-segment">initialization segment</a>:</p>
   2.448            <p>Each SourceBuffer object has an internal <dfn id="first-init-segment-flag">first initialization segment flag</dfn> that tracks whether the first <a href="#init-segment">initialization segment</a> has been appended. This flag is set to false when the SourceBuffer is created and updated by the algorithm below.</p>
   2.449            <ol>
   2.450 @@ -1338,7 +1498,7 @@
   2.451          </section>
   2.452  
   2.453          <section id="sourcebuffer-coded-frame-processing">
   2.454 -          <h4><span class="secno">4.4.3 </span>Coded Frame Processing</h4>
   2.455 +          <h4><span class="secno">4.5.6 </span>Coded Frame Processing</h4>
   2.456            <p>When complete <a href="#coded-frame">coded frames</a> have been parsed by the <a href="#sourcebuffer-segment-parser-loop">segment parser loop</a> then the following steps are run:</p>
   2.457            <ol>
   2.458              <li>
   2.459 @@ -1479,6 +1639,8 @@
   2.460  	    <li>Let <var>highest intersection end time</var> be the highest end time in the <var>intersection range</var>.</li>
   2.461  	    <li>If the <var>highest intersection end time</var> is less than the <var>highest end time</var>, then update the <var>intersection range</var> so that the <var>highest intersection end time</var> equals the <var>highest end time</var>.</li>
   2.462  	  </ol>
   2.463 +        <div class="issue"><div class="issue-title"><span>Issue 7</span></div><p class=""><a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=18615">Bug 18615</a> - Define how SourceBuffer.buffered maps to HTMLMediaElement.buffered</p></div>
   2.464 +        <div class="issue"><div class="issue-title"><span>Issue 8</span></div><p class=""><a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=18400">Bug 18400</a> - Define and document timestamp heuristics</p></div>
   2.465          </li>
   2.466          <li>Return the <var>intersection range</var>.</li>
   2.467        </ol>
   2.468 @@ -1486,7 +1648,7 @@
   2.469      
   2.470      <section id="byte-stream-formats">
   2.471        <!--OddPage--><h2><span class="secno">8. </span>Byte Stream Formats</h2>
   2.472 -      <p>The bytes provided through <code><a href="#widl-SourceBuffer-append-void-Uint8Array-data">append()</a></code> for a <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a> form a logical byte stream. The format of this byte stream depends on the media container format in use and is defined in a byte stream format specification. Byte stream format specifications based on WebM , the ISO Base Media File Format, and MPEG-2 Transport Streams are provided below. These format specifications are intended to be the authoritative source for how data from these containers is formatted and passed to a <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a>. If a <a href="#idl-def-MediaSource" class="idlType"><code>MediaSource</code></a> implementation claims to support any of these container formats, then it must implement the corresponding byte stream format specification described below.</p>
   2.473 +      <p>The bytes provided through <code><a href="#widl-SourceBuffer-appendArrayBuffer-void-ArrayBuffer-data">appendArrayBuffer()</a></code> and <code><a href="#widl-SourceBuffer-appendStream-void-Stream-stream-unsigned-long-long-maxSize">appendStream()</a></code> for a <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a> form a logical byte stream. The format of this byte stream depends on the media container format in use and is defined in a byte stream format specification. Byte stream format specifications based on WebM , the ISO Base Media File Format, and MPEG-2 Transport Streams are provided below. These format specifications are intended to be the authoritative source for how data from these containers is formatted and passed to a <a href="#idl-def-SourceBuffer" class="idlType"><code>SourceBuffer</code></a>. If a <a href="#idl-def-MediaSource" class="idlType"><code>MediaSource</code></a> implementation claims to support any of these container formats, then it must implement the corresponding byte stream format specification described below.</p>
   2.474        <p>This section provides general requirements for all byte stream formats:</p>
   2.475        <ul>
   2.476          <li>A byte stream format specification must define <a href="#init-segment">initialization segments</a> and <a href="#media-segment">media segments</a>.</li>
   2.477 @@ -1585,6 +1747,7 @@
   2.478          <h3><span class="secno">8.2 </span>ISO Base Media File Format Byte Streams</h3>
   2.479          <p>This section defines segment formats for implementations that choose to support the ISO Base Media File Format
   2.480  	  <a href="http://standards.iso.org/ittf/PubliclyAvailableStandards/c061988_ISO_IEC_14496-12_2012.zip">ISO/IEC 14496-12</a> (ISO BMFF).</p> 
   2.481 +          <div class="issue"><div class="issue-title"><span>Issue 9</span></div><p class=""><a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=18933">Bug 18933</a> - Segment byte boundaries are not defined</p></div>
   2.482  
   2.483  	<section id="iso-init-segments">
   2.484            <h4><span class="secno">8.2.1 </span>Initialization Segments</h4>
   2.485 @@ -1702,10 +1865,15 @@
   2.486      }
   2.487  
   2.488      // Append the initialization segment.
   2.489 -    sourceBuffer.append(initSegment);
   2.490 +    var firstAppendHandler = function(e) {
   2.491 +      var sourceBuffer = e.target;
   2.492 +      sourceBuffer.removeEventListener('appendend', firstAppendHandler);
   2.493  
   2.494 -    // Append some initial media data.
   2.495 -    appendNextMediaSegment(mediaSource);
   2.496 +      // Append some initial media data.
   2.497 +      appendNextMediaSegment(mediaSource);
   2.498 +    };
   2.499 +    sourceBuffer.addEventListener('appendend', firstAppendHandler);
   2.500 +    sourceBuffer.appendArrayBuffer(initSegment);
   2.501    }
   2.502  
   2.503    function appendNextMediaSegment(mediaSource) {
   2.504 @@ -1718,6 +1886,10 @@
   2.505        return;
   2.506      }
   2.507  
   2.508 +    // Make sure the previous append is not still pending.
   2.509 +    if (mediaSource.sourceBuffers[0].appending)
   2.510 +        return;
   2.511 +
   2.512      var mediaSegment = GetNextMediaSegment();
   2.513  
   2.514      if (!mediaSegment) {
   2.515 @@ -1726,7 +1898,7 @@
   2.516        return;
   2.517      }
   2.518  
   2.519 -    mediaSource.sourceBuffers[0].append(mediaSegment);
   2.520 +    mediaSource.sourceBuffers[0].appendArrayBuffer(mediaSegment);
   2.521    }
   2.522  
   2.523    function onSeeking(mediaSource, e) {
   2.524 @@ -1739,8 +1911,7 @@
   2.525      // new playback position.
   2.526      SeekToMediaSegmentAt(video.currentTime);
   2.527  
   2.528 -    // Append media segments from the new playback position.
   2.529 -    appendNextMediaSegment(mediaSource);
   2.530 +    // Append a media segment from the new playback position.
   2.531      appendNextMediaSegment(mediaSource);
   2.532    }
   2.533  
   2.534 @@ -1773,7 +1944,18 @@
   2.535          </thead>
   2.536          <tbody>
   2.537            <tr>
   2.538 -	    <td>14 December 2012</td>
   2.539 +	    <td>04 January 2013</td>
   2.540 +            <td>
   2.541 +              <ul>
   2.542 +                <li>Renamed append() to appendArrayBuffer() and made appending asynchronous.</li>
   2.543 +                <li>Added SourceBuffer.appendStream().</li>
   2.544 +                <li>Added SourceBuffer.setTrackInfo() methods.</li>
   2.545 +                <li>Added issue boxes to relevant sections for outstanding bugs.</li>
   2.546 +              </ul>
   2.547 +            </td>
   2.548 +          </tr>
   2.549 +          <tr>
   2.550 +	    <td><a href="http://dvcs.w3.org/hg/html-media/raw-file/53ea7c19edd2/media-source/media-source.html">14 December 2012</a></td>
   2.551              <td>
   2.552                Pubrules, Link Checker, and Markup Validation fixes.
   2.553              </td>
   2.554 @@ -1922,4 +2104,4 @@
   2.555      </section>
   2.556    
   2.557  
   2.558 -</body></html>
   2.559 \ No newline at end of file
   2.560 +</body></html>
     3.1 --- a/media-source/media-source.js	Tue Dec 18 09:20:45 2012 -0800
     3.2 +++ b/media-source/media-source.js	Fri Jan 04 09:44:08 2013 -0800
     3.3 @@ -25,6 +25,10 @@
     3.4      link_helper(doc, df, 'http://www.w3.org/TR/FileAPI/#' + id, text);
     3.5    }
     3.6  
     3.7 +  function streamapi_helper(doc, df, id, text) {
     3.8 +      link_helper(doc, df, 'http://dvcs.w3.org/hg/streams-api/raw-file/tip/Overview.htm#' + id, text);
     3.9 +  }
    3.10 +
    3.11    function webappapis_helper(doc, df, id, text) {
    3.12      link_helper(doc, df, 'http://dev.w3.org/html5/spec/webappapis.html#' + id, text);
    3.13    }
    3.14 @@ -70,9 +74,11 @@
    3.15      'eos-decode': { func: idlref_helper, fragment: 'widl-MediaSource-endOfStream-void-EndOfStreamError-error', link_text: 'endOfStream("decode")',  },
    3.16      'readyState': { func: idlref_helper, fragment: 'widl-MediaSource-readyState', link_text: 'readyState',  },
    3.17      'duration': { func: idlref_helper, fragment: 'widl-MediaSource-duration', link_text: 'duration',  },
    3.18 -    'append': { func: idlref_helper, fragment: 'widl-SourceBuffer-append-void-Uint8Array-data', link_text: 'append()',  },
    3.19 +    'appendArrayBuffer': { func: idlref_helper, fragment: 'widl-SourceBuffer-appendArrayBuffer-void-ArrayBuffer-data', link_text: 'appendArrayBuffer()',  },
    3.20 +    'appendStream': { func: idlref_helper, fragment: 'widl-SourceBuffer-appendStream-void-Stream-stream-unsigned-long-long-maxSize', link_text: 'appendStream()',  },
    3.21      'abort': { func: idlref_helper, fragment: 'widl-SourceBuffer-abort-void', link_text: 'abort()',  },
    3.22      'remove': { func: idlref_helper, fragment: 'widl-SourceBuffer-remove-void-double-start-double-end', link_text: 'remove()',  },
    3.23 +    'appending': { func: idlref_helper, fragment: 'widl-SourceBuffer-appending', link_text: 'appending',  },
    3.24      'buffered': { func: idlref_helper, fragment: 'widl-SourceBuffer-buffered', link_text: 'buffered',  },
    3.25      'timestampOffset': { func: idlref_helper, fragment: 'widl-SourceBuffer-timestampOffset', link_text: 'timestampOffset',  },
    3.26      'length': { func: idlref_helper, fragment: 'widl-SourceBufferList-length', link_text: 'length',  },
    3.27 @@ -83,6 +89,11 @@
    3.28      'network': { func: idlref_helper, fragment: 'idl-def-EndOfStreamError', link_text: '"network"',  },
    3.29      'decode': { func: idlref_helper, fragment: 'idl-def-EndOfStreamError', link_text: '"decode"',  },
    3.30  
    3.31 +    'appendstart': { func: eventref_helper, fragment: 'appendstart', link_text: 'appendstart',  },
    3.32 +    'appendend': { func: eventref_helper, fragment: 'appendend', link_text: 'appendend',  },
    3.33 +    'appenderror': { func: eventref_helper, fragment: 'error', link_text: 'error',  },
    3.34 +    'appendabort': { func: eventref_helper, fragment: 'abort', link_text: 'abort',  },
    3.35 +
    3.36      'sourceopen': { func: eventref_helper, fragment: 'sourceopen', link_text: 'sourceopen',  },
    3.37      'sourceended': { func: eventref_helper, fragment: 'sourceended', link_text: 'sourceended',  },
    3.38      'sourceclose': { func: eventref_helper, fragment: 'sourceclose', link_text: 'sourceclose',  },
    3.39 @@ -113,6 +124,9 @@
    3.40      'parsing-init-segment': { func: link_helper, fragment: '#sourcebuffer-parsing-init-segment', link_text: 'PARSING_INIT_SEGMENT', },
    3.41      'parsing-media-segment': { func: link_helper, fragment: '#sourcebuffer-parsing-media-segment', link_text: 'PARSING_MEDIA_SEGMENT', },
    3.42      'byte-stream-format-specs': { func: link_helper, fragment: '#byte-stream-formats', link_text: 'byte stream format specifications', },
    3.43 +    'append-error-algorithm': { func: link_helper, fragment: '#sourcebuffer-append-error', link_text: 'append error algorithm', },
    3.44 +    'reset-parser-state-algorithm': { func: link_helper, fragment: '#sourcebuffer-reset-parser-state', link_text: 'reset parser state algorithm', },
    3.45 +    'stream-append-loop': { func: link_helper, fragment: '#sourcebuffer-stream-append-loop', link_text: 'stream append loop', },
    3.46      'init-segment-received-algorithm': { func: link_helper, fragment: '#sourcebuffer-init-segment-received', link_text: 'initialization segment received algorithm', },
    3.47      'coded-frame-processing-algorithm': { func: link_helper, fragment: '#sourcebuffer-coded-frame-processing', link_text: 'coded frame processing algorithm', },
    3.48      'input-buffer': { func: var_helper, fragment: '#sourcebuffer-input-buffer', link_text: 'input buffer', },
    3.49 @@ -131,6 +145,8 @@
    3.50      'file-createObjectURL': { func: fileapi_helper, fragment: 'dfn-createObjectURL', link_text: 'createObjectURL()',  },
    3.51      'file-revokeObjectURL': { func: fileapi_helper, fragment: 'dfn-revokeObjectURL', link_text: 'revokeObjectURL()',  },
    3.52  
    3.53 +    'Stream': { func: streamapi_helper, fragment: 'idl-def-Stream', link_text: 'Stream', },
    3.54 +
    3.55      'eventdfn': { func: eventdfn_helper, fragment: '', link_text: '', },
    3.56  
    3.57      'videoref': { func: videoref_helper, fragment: '', link_text: '', },
    3.58 @@ -144,18 +160,24 @@
    3.59      'timeranges': { func: code_videoref_helper, fragment: 'timeranges', link_text: 'TimeRanges',  },
    3.60      'video-track': { func: code_videoref_helper, fragment: 'videotrack', link_text: 'VideoTrack',  },
    3.61      'videotrack-id': { func: code_videoref_helper, fragment: 'dom-videotrack-id', link_text: 'id',  },
    3.62 -    'videotrack-selected': { func: code_videoref_helper, fragment: 'dom-videotrack-selected', link_text: 'selected',  },
    3.63 +    'videotrack-kind': { func: code_videoref_helper, fragment: 'dom-videotrack-kind', link_text: 'kind', },
    3.64 +    'videotrack-language': { func: code_videoref_helper, fragment: 'dom-videotrack-language', link_text: 'language', },
    3.65 +    'videotrack-selected': { func: code_videoref_helper, fragment: 'dom-videotrack-selected', link_text: 'selected', },
    3.66      'videotracklist-length': { func: code_videoref_helper, fragment: 'dom-videotracklist-length', link_text: 'length',  },
    3.67      'videotracks': { func: code_videoref_helper, fragment: 'dom-media-videotracks', link_text: 'videoTracks',  },
    3.68      'audio-track': { func: code_videoref_helper, fragment: 'audiotrack', link_text: 'AudioTrack',  },
    3.69      'audiotracklist-length': { func: code_videoref_helper, fragment: 'dom-audiotracklist-length', link_text: 'length',  },
    3.70      'audiotracks': { func: code_videoref_helper, fragment: 'dom-media-audiotracks', link_text: 'audioTracks',  },
    3.71      'audiotrack-id': { func: code_videoref_helper, fragment: 'dom-audiotrack-id', link_text: 'id',  },
    3.72 -    'audiotrack-enabled': { func: code_videoref_helper, fragment: 'dom-audiotrack-enabled', link_text: 'enabled',  },
    3.73 +    'audiotrack-kind': { func: code_videoref_helper, fragment: 'dom-audiotrack-kind', link_text: 'kind', },
    3.74 +    'audiotrack-language': { func: code_videoref_helper, fragment: 'dom-audiotrack-language', link_text: 'language', },
    3.75 +    'audiotrack-enabled': { func: code_videoref_helper, fragment: 'dom-audiotrack-enabled', link_text: 'enabled', },
    3.76      'text-track': { func: code_videoref_helper, fragment: 'texttrack', link_text: 'TextTrack',  },
    3.77      'texttracks': { func: code_videoref_helper, fragment: 'dom-media-texttracks', link_text: 'textTracks',  },
    3.78      'texttrack-mode': { func: code_videoref_helper, fragment: 'dom-texttrack-mode', link_text: 'mode',  },
    3.79 -    'texttrack-showing': { func: code_videoref_helper, fragment: 'dom-texttrack-showing', link_text: '"showing"',  },
    3.80 +    'texttrack-kind': { func: code_videoref_helper, fragment: 'dom-texttrack-kind', link_text: 'kind', },
    3.81 +    'texttrack-language': { func: code_videoref_helper, fragment: 'dom-texttrack-language', link_text: 'language', },
    3.82 +    'texttrack-showing': { func: code_videoref_helper, fragment: 'dom-texttrack-showing', link_text: '"showing"', },
    3.83      'texttrack-hidden': { func: code_videoref_helper, fragment: 'dom-texttrack-hidden', link_text: '"hidden"',  },
    3.84      'ready-state': { func: code_videoref_helper, fragment: 'dom-media-readystate', link_text: 'HTMLMediaElement.readyState',  },
    3.85      'have-nothing': { func: code_videoref_helper, fragment: 'dom-media-have_nothing', link_text: 'HAVE_NOTHING',  },