sequence |
- Media segments will be treated as adjacent in time independent of the timestamps in the media segment. Coded frames in a new media segment will be placed immediately after the coded
- frames in the previous media segment. The {{SourceBuffer/timestampOffset}} attribute will be updated if a new offset is needed to make the new media segments adjacent to the previous media segment.
- Setting the {{SourceBuffer/timestampOffset}} attribute in {{AppendMode/""sequence""}} mode allows a media segment to be placed at a specific position in the timeline without any knowledge
- of the timestamps in the media segment.
-
+};| Enumeration description |
+ segments |
+ The timestamps in the media segment or {{EncodedChunks}} determine where the [=coded frames=] are placed in
+ the presentation. Media segments can be appended in any order. Discontinuous {{EncodedChunks}} should not be
+ appended in the same {{SourceBuffer/appendEncodedChunks()}} call: the application should instead wait for the
+ {{SourceBuffer}} to no longer be {{SourceBuffer/updating}}, and then call {{SourceBuffer/abort()}} or
+ {{SourceBuffer/changeType()}} before appending {{EncodedChunks}} that are discontinuous with those in the
+ previous {{SourceBuffer/appendEncodedChunks()}} call.
+ |
+ sequence |
+ Media segments will be treated as adjacent in time independent of the timestamps in the media segment. Coded
+ frames in a new media segment will be placed immediately after the coded frames in the previous media segment.
+ As with {{AppendMode/""segments""}} mode, discontinuous {{EncodedChunks}} should not be appended in the same
+ {{SourceBuffer/appendEncodedChunks()}} call.
+ The {{SourceBuffer/timestampOffset}} attribute will be updated if a new offset is needed to make the new media
+ segments adjacent to the previous media segment. Setting the {{SourceBuffer/timestampOffset}} attribute in
+ {{AppendMode/""sequence""}} mode allows a media segment to be placed at a specific position in the timeline
+ without any knowledge of the timestamps in the media segment.
|
-[Exposed=(Window,DedicatedWorker)]
+
+[Exposed=(Window,DedicatedWorker)]
interface SourceBuffer : EventTarget {
attribute AppendMode mode;
readonly attribute boolean updating;
@@ -1155,13 +1260,30 @@ SourceBuffer Object
attribute EventHandler onerror;
attribute EventHandler onabort;
undefined appendBuffer (BufferSource data);
+ Promise < undefined > appendEncodedChunks(EncodedChunks chunks);
undefined abort ();
- undefined changeType (DOMString type);
+
+ // "optional" with default empty SourceBufferConfig dictionary is used here
+ // to pass WebIDL verification. Behavior of the method enforces that either
+ // a valid mime-type string or a valid SourceBufferConfig are provided.
+ undefined changeType (optional TypeOrConfig typeOrConfig = {});
+
undefined remove (double start, unrestricted double end);
-};
+};
+
+// This typedef simplifies the syntax for describing either a single audio or
+// video chunk, or a sequence of chunks. While this typedef does not provide the
+// ability to enforce that all members of a sequence of chunks are the same kind
+// (audio versus video), the behavior of the appendEncodedChunks method enforces
+// that constraint: the implementation MUST reject a sequence containing both
+// audio and video chunks.
+typedef (sequence< (EncodedAudioChunk or EncodedVideoChunk) >
+ or EncodedAudioChunk or EncodedVideoChunk) EncodedChunks;
+
[[HTML]] {{AudioTrackList}}, {{VideoTrackList}} and {{TextTrackList}} need Window+DedicatedWorker
exposure.
- Attributesmode of type AppendMode-
+
Attributes
+ mode of type AppendMode-
Controls how a sequence of [=media segments=] are handled. This attribute is initially set by {{MediaSource/addSourceBuffer()}} after the object is created, and can be updated by {{SourceBuffer/changeType()}} or setting this attribute.
On getting, Return the initial value or the last value that was successfully set.
On setting, run the following steps:
@@ -1185,7 +1307,7 @@ SourceBuffer Object
- Update the attribute to |new mode|.
updating of type {{boolean}}, readonly -
-
Indicates whether the asynchronous continuation of an {{SourceBuffer/appendBuffer()}} or {{SourceBuffer/remove()}}
+ Indicates whether the asynchronous continuation of an {{SourceBuffer/appendBuffer()}}, {{SourceBuffer/appendEncodedChunks()}} or {{SourceBuffer/remove()}}
operation is still being processed. This attribute is initially set to false when the object is created.
buffered of type {{TimeRanges}}, readonly -
Indicates what {{TimeRanges}} are buffered in the SourceBuffer. This
@@ -1211,7 +1333,7 @@ SourceBuffer Object
- Return the current value of this attribute.
timestampOffset of type {{double}}-
-
Controls the offset applied to timestamps inside subsequent [=media segments=] that are appended to this SourceBuffer. The {{SourceBuffer/timestampOffset}} is initially set to 0 which indicates that no offset is being applied.
+ Controls the offset applied to timestamps inside subsequent [=media segments=] or {{EncodedChunks}} that are appended to this SourceBuffer. The {{SourceBuffer/timestampOffset}} is initially set to 0 which indicates that no offset is being applied.
On getting, Return the initial value or the last value that was successfully set.
On setting, run the following steps:
@@ -1272,17 +1394,68 @@ SourceBuffer Object
The event handler for the {{error}} event.
onabort of type {{EventHandler}}-
The event handler for the {{abort}} event.
-
+ Methods
+ appendBuffer
+ -
Appends the segment data in an BufferSource[[!WEBIDL]] to the {{SourceBuffer}}.
- - Run the [=prepare append=] algorithm.
+ - Run the [=prepare append=] algorithm. If it throws exception and aborts, then these steps are also
+ aborted.
- Add |data:BufferSource| to the end of the {{SourceBuffer/[[input buffer]]}}.
- Set the {{SourceBuffer/updating}} attribute to true.
- [=Queue a task=] to [=fire an event=] named {{updatestart}} at this SourceBuffer object.
- - Asynchronously run the [=buffer append=] algorithm.
+ - Asynchronously run the [=buffer append=] algorithm.
+
If this {{SourceBuffer}} is currently configured by the most recent
+ of the {{MediaSource/addSourceBuffer()}} call that created this object or a more recent
+ {{SourceBuffer/changeType()}} call to expect to buffer WebCodecs {{EncodedChunks}} via
+ {{SourceBuffer/appendEncodedChunks()}}, the asynchronous [=buffer append=] algorithm will detect this and
+ trigger the [=append error=] algorithm.
+
- | Parameter | Type | Nullable | Optional | Description |
|---|
| |data| | {{BufferSource}} | ✘ | ✘ | |
Return type: {{undefined}} abort-
+
| Parameter | Type | Nullable | Optional | Description |
|---|
| |data| | {{BufferSource}} | ✘ | ✘ | |
Return type: {{undefined}}
+
+ appendEncodedChunks
+ -
+
Appends WebCodecs [[WEBCODECS]] {{EncodedChunks}} to the {{SourceBuffer}}.
+
+
+ - Run the [=prepare append=] algorithm. If it throws exception and aborts, then these steps are also
+ aborted.
+ - If any of the chunks in |chunks:EncodedChunks| have a null value for their duration attribute, throw a
+ {{TypeError}} exception and abort these steps.
+
This requirement is necessary to understand all chunks' presentation intervals in
+ the coded frame processing algorithm, enabling correct buffering when frames overlap other frames, are later
+ overlapped by other frames, or are in a disjoint portion of the presentation timeline.
+
+
+ - Add |chunks| to the end of {{SourceBuffer/[[input webcodecs configs and chunks]]}}.
+ - Set the {{SourceBuffer/updating}} attribute to true.
+
This promise-based method differs from the asynchronous event-signalling
+ {{SourceBuffer/appendBuffer()}} method: promise resolution or rejection is the way to detect the
+ analogues of "abort", "error", "updatestart", "update", and "updateend" events that are not enqueued
+ by {{SourceBuffer/appendEncodedChunks()}}.
+
+ - Let |promise:Promise| be a new {{Promise}}.
+ - Set {{SourceBuffer/[[pending append chunks promise]]}} to be |promise|.
+ - Return |promise| to the caller and run the rest of these steps asynchronously.
+ - Run the [=chunks append=] algorithm.
+
If this {{SourceBuffer}} is currently configured by the most recent
+ of the {{MediaSource/addSourceBuffer()}} call that created this object or a more recent
+ {{SourceBuffer/changeType()}} call to expect to buffer bytes parsed from a {{BufferSource}} via
+ {{SourceBuffer/appendBuffer()}}, the asynchronous [=chunks append=] algorithm will detect this and
+ trigger the [=append error=] algorithm.
+
+
+
+ | Parameter | Type | Nullable | Optional | Description |
+ | |chunks| | {{EncodedChunks}} | ✘ | ✘ | |
+ Return type: {{Promise}} < {{undefined}} >
+
+
+
+ abort-
Aborts the current segment and resets the segment parser.
@@ -1292,9 +1465,20 @@ SourceBuffer Object
- If the {{SourceBuffer/updating}} attribute equals true, then run the following steps:
- Abort the [=buffer append=] algorithm if it is running.
+ - Abort the [=chunks append=] algorithm if it is running.
- Set the {{SourceBuffer/updating}} attribute to false.
- - [=Queue a task=] to [=fire an event=] named {{abort}} at this SourceBuffer object.
- - [=Queue a task=] to [=fire an event=] named {{updateend}} at this SourceBuffer object.
+
+ - If this object has a {{Promise}} in {{SourceBuffer/[[pending append chunks promise]]}}:
+ - Reject that {{Promise}} with an {{AbortError}} {{DOMException}} and unset
+ {{SourceBuffer/[[pending append chunks promise]]}}.
+ - Otherwise:
+
+ - [=Queue a task=] to [=fire an event=] named {{abort}} at this {{SourceBuffer}} object.
+ - [=Queue a task=] to [=fire an event=] named {{updateend}} at this {{SourceBuffer}}
+ object.
+
+
+
- Run the [=reset parser state=] algorithm.
@@ -1303,12 +1487,38 @@ SourceBuffer Object
No parameters. Return type: {{undefined}}
changeType-
-
Changes the MIME type associated with this object. Subsequent {{SourceBuffer/appendBuffer()}} calls will expect the newly appended bytes to conform to the new type.
+ Changes the [=SourceBuffer byte stream format specification or WebCodecs chunks buffering expectations=] for
+ this object. Enables switching among bytestreams, codecs, or even between bytestream parsing versus
+ buffering of WebCodecs encoded chunks in the same {{SourceBuffer}}.
- - If |type:DOMString| is an empty string then throw a {{TypeError}} exception and abort these steps.
- - If this object has been removed from the {{MediaSource/sourceBuffers}} attribute of the [=parent media source=], then throw an {{InvalidStateError}} exception and abort these steps.
- - If the {{SourceBuffer/updating}} attribute equals true, then throw an {{InvalidStateError}} exception and abort these steps.
- - If |type| contains a MIME type that is not supported or contains a MIME type that is not supported with the types specified (currently or previously) of {{SourceBuffer}} objects in the {{MediaSource/sourceBuffers}} attribute of the [=parent media source=], then throw a {{NotSupportedError}} exception and abort these steps.
+ - If |typeOrConfig:TypeOrConfig| is an empty DOMString, then throw a {{TypeError}} exception and abort
+ these steps.
+ - If |typeOrConfig| is not a DOMString, then run the following steps:
+
+ - If |typeOrConfig| has both an {{SourceBufferConfig/audioConfig}} and a
+ {{SourceBufferConfig/videoConfig}} or has neither, then throw a {{TypeError}} exception and abort
+ these steps and this method.
+ - If |typeOrConfig| has neither a neither a [=valid AudioDecoderConfig=] in
+ {{SourceBufferConfig/audioConfig}} nor a [=valid VideoDecoderConfig=] in
+ {{SourceBufferConfig/videoConfig}}, then throw a {{TypeError}} exception and abort these steps and
+ this method.
+
+
+
+ - If this object has been removed from the {{MediaSource/sourceBuffers}} attribute of the [=parent media
+ source=], then throw an {{InvalidStateError}} exception and abort these steps.
+
+ - If the {{SourceBuffer/updating}} attribute equals true, then throw an {{InvalidStateError}} exception
+ and abort these steps.
+
+ - If |typeOrConfig| is a DOMString that contains a MIME type that is not supported or that contains a MIME
+ type that is not supported with the types specified (currently or previously) of {{SourceBuffer}} objects
+ in the {{MediaSource/sourceBuffers}} attribute of the [=parent media source=], then throw a
+ {{NotSupportedError}} exception and abort these steps.
+ - If |typeOrConfig| is not a DOMString, and if it contains a decoder configuration that is not supported
+ or is not supported with the types specified (currently or previously) of {{SourceBuffer}} objects in the
+ {{MediaSource/sourceBuffers}} attribute of the [=parent media source=], then throw a {{NotSupportedError}}
+ exception and abort these steps.
-
If the {{MediaSource/readyState}} attribute of the [=parent media source=] is in the {{ReadyState/""ended""}} state then run the following steps:
@@ -1317,9 +1527,28 @@ SourceBuffer Object
- Run the [=reset parser state=] algorithm.
- - Update the {{SourceBuffer/[[generate timestamps flag]]}} on this {{SourceBuffer}} object to the value in
- the "Generate Timestamps Flag" column of the byte stream format registry [[MSE-REGISTRY]] entry that is
- associated with |type|.
+
+ -
+
+ - If |typeOrConfig| is a DOMString:
+ - Update the {{SourceBuffer/[[generate timestamps flag]]}} on this {{SourceBuffer}} object to the value in the
+ "Generate Timestamps Flag" column of the byte stream format registry [[MSE-REGISTRY]] entry that is
+ associated with |typeOrConfig|.
+
+ - Otherwise:
+
+ - Update the {{SourceBuffer/[[generate timestamps flag]]}} on this {{SourceBuffer}} object to false.
+
WebCodecs encoded chunks are required to have timestamps, so there is no need to
+ generate them.
+
+ - Remove any {{SourceBufferConfig}} that may be in this {{SourceBuffer}} object's
+ {{SourceBuffer/[[input webcodecs configs and chunks]]}}.
+ - Copy the {{SourceBufferConfig}} from |typeOrConfig| into this {{SourceBuffer}} object's {{SourceBuffer/[[input
+ webcodecs configs and chunks]]}} for potential handling later during [=chunks append=] algorithm.
+
+
+
+
-
- If the {{SourceBuffer/[[generate timestamps flag]]}} equals true:
@@ -1345,8 +1574,8 @@ SourceBuffer Object
Description |
|
- | |type| |
- {{DOMString}} |
+ |typeOrConfig| |
+ {{TypeOrConfig}} |
✘ |
✘ |
|
@@ -1408,9 +1637,9 @@ SourceBuffer Object
Track Buffers
- A track buffer stores the [=track descriptions=] and [=coded frames=] for an individual
- track. The track buffer is updated as [=initialization segments=] and [=media segments=] are appended to the
- SourceBuffer.
+ A track buffer stores the [=track descriptions=] and [=coded frames=] for an
+ individual track. The track buffer is updated as [=initialization segments=], [=media segments=], decoder
+ configurations and {{EncodedChunks}} are given to the {{SourceBuffer}}.
Each [=track buffer=] has a last decode timestamp variable that stores
the decode timestamp of the last [=coded frame=] appended in the current [=coded frame group=]. The variable is initially
@@ -1516,8 +1745,9 @@
Segment Parser Loop
empty when the {{SourceBuffer}} object is created.
Each {{SourceBuffer}} object has a [[\buffer full flag]] internal
- slot that keeps track of whether {{SourceBuffer/appendBuffer()}} is allowed to accept more bytes. It is set
- to false when the {{SourceBuffer}} object is created and gets updated as data is appended and removed.
+ slot that keeps track of whether {{SourceBuffer/appendBuffer()}} is allowed to accept more bytes or
+ {{SourceBuffer/appendEncodedChunks()}} is allowed to accept more encoded chunks. It is set to false when the
+ {{SourceBuffer}} object is created and gets updated as data is appended and removed.
Each {{SourceBuffer}} object has a [[\group start timestamp]]
internal slot that keeps track of the starting timestamp for a new [=coded frame group=] in the
@@ -1544,6 +1774,7 @@
Segment Parser Loop
This flag is set by {{MediaSource/addSourceBuffer()}} when the {{SourceBuffer}} object is created and is
updated by {{SourceBuffer/changeType()}}.
+
When the segment parser loop algorithm is invoked, run the following steps:
@@ -1619,6 +1850,15 @@ Reset Parser State
- If the {{SourceBuffer/mode}} attribute equals {{AppendMode/""sequence""}}, then set the
{{SourceBuffer/[[group start timestamp]]}} to the {{SourceBuffer/[[group end timestamp]]}}
- Remove all bytes from the {{SourceBuffer/[[input buffer]]}}.
+ - If {{SourceBuffer/[[input webcodecs configs and chunks]]}} contains any {{EncodedChunks}}, remove them
+ from {{SourceBuffer/[[input webcodecs configs and chunks]]}}, but retain any {{AudioDecoderConfig}} or
+ {{VideoDecoderConfig}} that may be in that internal slot.
+
Keeping an unprocessed WebCodecs config in this internal slot lets future
+ {{SourceBuffer/appendEncodedChunks()}} reuse the config in the [=chunks append=] algorithm because
+ there is no other way to retain such an unprocessed config, except perhaps by the app calling
+ {{SourceBuffer/changeType()}} with the config again.
+
+
- Set {{SourceBuffer/[[append state]]}} to [=WAITING_FOR_SEGMENT=].
@@ -1629,8 +1869,18 @@ Append Error
- Run the [=reset parser state=] algorithm.
- Set the {{SourceBuffer/updating}} attribute to false.
- - [=Queue a task=] to [=fire an event=] named {{error}} at this SourceBuffer object.
- - [=Queue a task=] to [=fire an event=] named {{updateend}} at this SourceBuffer object.
+
+ - If this {{SourceBuffer}} has a {{Promise}} in {{SourceBuffer/[[pending append chunks
+ promise]]}}:
+ - Reject that {{Promise}} with an {{AbortError}} {{DOMException}} and unset {{SourceBuffer/[[pending
+ append chunks promise]]}}.
+ - Otherwise:
+
+ - [=Queue a task=] to [=fire an event=] named {{error}} at this {{SourceBuffer}} object.
+ - [=Queue a task=] to [=fire an event=] named {{updateend}} at this {{SourceBuffer}} object.
+
+
+
- Run the [=end of stream=] algorithm
with the |error:EndOfStreamError| parameter set to {{EndOfStreamError/""decode""}}.
@@ -1678,6 +1928,13 @@ Prepare Append
Buffer Append
When {{SourceBuffer/appendBuffer()}} is called, the following steps are run to process the appended data.
+ - If this {{SourceBuffer}} is currently configured to expect processing of WebCodecs {{EncodedChunks}},
+ then run the [=append error=] algorithm and abort this algorithm.
+
The expectation of processing an appended bytestream versus appended {{EncodedChunks}}
+ is based on the most recently successful execution of the initial {{MediaSource/addSourceBuffer()}} that
+ created this {{SourceBuffer}} or potentially a more recent {{SourceBuffer/changeType()}} call that may
+ have changed the expectation.
+
- Run the [=segment parser loop=] algorithm.
- If the [=segment parser loop=] algorithm in the previous step was aborted, then abort this algorithm.
- Set the {{SourceBuffer/updating}} attribute to false.
@@ -1686,6 +1943,82 @@ Buffer Append
+
+ Chunks Append
+ Each {{SourceBuffer}} object has a [[\pending append chunks
+ promise]] internal slot that stores the promise necessary to communicate the completion of
+ asynchronous steps begun by a call to {{SourceBuffer/appendEncodedChunks()}}. If there is no asynchronous
+ {{SourceBuffer/appendEncodedChunks()}} operation in progress, then this slot is unset.
+
+ Each {{SourceBuffer}} object has an [[\input webcodecs configs and
+ chunks]] internal slot that stores a queue of unprocessed {{EncodedChunks}} and at most one
+ {{SourceBufferConfig}}. The {{SourceBufferConfig}} is added if the initial call to
+ {{MediaSource/addSourceBuffer()}} that created this object was provided a {{SourceBufferConfig}}, or if
+ there is a more recent successful call to {{SourceBuffer/changeType()}} on this {{SourceBuffer}} that
+ provided a {{SourceBufferConfig}}. The contents of this slot are processed by the [=chunks append=]
+ algorithm to buffer the necessary decoder configuration and coded frames into the underlying [=track
+ buffer=].
+
+ When the chunks append algorithm is invoked, run the following steps to process the appended
+ {{EncodedChunks}} relative to the current {{SourceBufferConfig}}:
+
+ - If this {{SourceBuffer}} is currently configured to expect processing of an appended bytestream,
+ then run the [=append error=] algorithm and abort this algorithm.
+
The expectation of processing an appended bytestream versus appended {{EncodedChunks}}
+ is based on the most recently successful execution of the initial {{MediaSource/addSourceBuffer()}} that
+ created this {{SourceBuffer}} or potentially a more recent {{SourceBuffer/changeType()}} call that may
+ have changed the expectation.
+
+ - If there is a {{SourceBufferConfig}} in this {{SourceBuffer}}'s {{SourceBuffer/[[input webcodecs configs
+ and chunks]]}}, then run the following steps:
+
+ - Let |config:SourceBufferConfig| be the {{SourceBufferConfig}} from {{SourceBuffer/[[input webcodecs
+ configs and chunks]]}}.
+
There must be precisely one {{AudioDecoderConfig}} or {{VideoDecoderConfig}} in
+ |config|; this condition was already enforced by the {{MediaSource/addSourceBuffer()}} or
+ {{SourceBuffer/changeType()}} call that placed |config| into {{SourceBuffer/[[input webcodecs
+ configs and chunks]]}}.
+
+ - Remove the {{SourceBufferConfig}} from {{SourceBuffer/[[input webcodecs configs and chunks]]}}.
+ - Run the [=initialization segment received=] algorithm with |config| denoting a single track
+ configuration. If that algorithm aborts, then abort this algorithm.
+
+
+ - In the order in which they were added to {{SourceBuffer/[[input webcodecs configs and chunks]]}},
+ prepare the {{EncodedChunks}} for coded frame processing by running the following steps for each chunk:
+
+ - Let |chunk:EncodedAudioChunk or EncodedVideoChunk| be the next encoded chunk being prepared,
+ dequeued (removed) from the front of {{SourceBuffer/[[input webcodecs configs and chunks]]}}.
+ - If |chunk| is an {{EncodedAudioChunk}} but the most recently processed |config| by this object was a
+ {{VideoDecoderConfig}}, or if |chunk| is an {{EncodedVideoChunk}} but the most recently processed
+ |config| by this object was an {{AudioDecoderConfig}}, then run the [=append error=] algorithm and
+ abort this algorithm.
+
+ - Create a coded frame from |chunk|. Treat the frame as a random access point iff |chunk|'s type
+ is "key". Set the frame's decode timestamp to be 0.
+
Using a constant decode timestamp disables the [=coded frame processing=]
+ algorithm's discontinuity detection. Note that other mechanisms for signalling discontinuous
+ sequences of frames survive this simplification, with the most reliable yet lightweight being calling
+ {{SourceBuffer/abort()}} when {{SourceBuffer/updating}} is false. A more heavyweight option would be
+ to call {{SourceBuffer/changeType()}}. Also note that, though WebCodecs does not define a decode
+ timestamp attribute for encoded chunks, if reliable buffering of chunks into MSE needs real decode
+ timestamps, this spec may be refined to improve that support.
+
+
+
+
+ - Run the [=coded frame processing=] algorithm with the frames in order from the previous step.
+
This algorithm, unlike the [=segment parser loop=] algorithm, deterministically
+ consumes and clears all of its input state and processes all corresponding coded frames. Even the steps
+ which might abort this algorithm early do so after the [=append error=] algorithm clears any remaining
+ input state and rejects the promise.
+
+
+ - Set the {{SourceBuffer/updating}} attribute to false.
+
- Resolve the {{SourceBuffer/[[pending append chunks promise]]}} and unset that internal slot.
+
+
+
Range Removal
Follow these steps when a caller needs to initiate a JavaScript visible range removal
@@ -1705,7 +2038,8 @@
Range Removal
Initialization Segment Received
- The following steps are run when the [=segment parser loop=] successfully parses a complete [=initialization segment=]:
+ The following steps are run when the [=segment parser loop=] successfully parses a complete
+ [=initialization segment=] or the [=chunks append=] algorithm handles a {{SourceBufferConfig}}:
Each SourceBuffer object has a
[[\first initialization segment received flag]] internal slot that
tracks whether the first [=initialization segment=] has been appended and received by this algorithm. This
@@ -2066,10 +2400,11 @@
Initialization Segment Received
Coded Frame Processing
- When complete [=coded frames=] have been parsed by the [=segment parser loop=] then the following steps are run:
+ When complete [=coded frames=] have been parsed by the [=segment parser loop=] or emitted by the [=chunks
+ append=] algorithm, then the following steps are run:
-
-
For each [=coded frame=] in the [=media segment=] run the following steps:
+ For each [=coded frame=] run the following steps:
- Loop Top:
- If {{SourceBuffer/[[generate timestamps flag]]}} equals true:
@@ -2256,7 +2591,7 @@ Coded Frame Processing
If the {{HTMLMediaElement}}.{{HTMLMediaElement/readyState}} attribute is {{HTMLMediaElement/HAVE_FUTURE_DATA}} and the new [=coded frames=] cause {{HTMLMediaElement}}.{{HTMLMediaElement/buffered}} to have a {{TimeRanges}} that includes the current playback position and [=enough data to ensure uninterrupted playback=], then set the {{HTMLMediaElement}}.{{HTMLMediaElement/readyState}} attribute to {{HTMLMediaElement/HAVE_ENOUGH_DATA}}.
Per [[HTML]] logic, {{HTMLMediaElement}}.{{HTMLMediaElement/readyState}} changes may trigger events on the HTMLMediaElement.
- - If the [=media segment=] contains data beyond the current {{MediaSource/duration}}, then run the
+
- If the result of coded frame processing buffers data beyond the current {{MediaSource/duration}}, then run the
[=duration change=] algorithm with |new duration:unrestricted double| set to the maximum of the current
duration and the {{SourceBuffer/[[group end timestamp]]}}.
@@ -2319,9 +2654,11 @@ Coded Frame Removal
Coded Frame Eviction
- This algorithm is run to free up space in this {{SourceBuffer}} when new data is appended.
+ This algorithm is run to free up space in this {{SourceBuffer}} when new data is appended. New data is
+ either the bytes being appended via {{SourceBuffer/appendBuffer()}} or the WebCodecs {{EncodedChunks}} being
+ appended via {{SourceBuffer/appendEncodedChunks()}}.
- - Let |new data:BufferSource| equal the data that is about to be appended to this SourceBuffer.
+
- Let |new data:BufferSource or EncodedChunks| equal the data that is about to be appended to this SourceBuffer.
Need to recognize step here that implementations MAY decide to set {{SourceBuffer/[[buffer full
flag]]}} true here if it predicts that processing |new data| in addition to any existing bytes in
@@ -2809,6 +3146,10 @@
Byte Stream Formats
The byte stream format specifications in the registry are not intended to define new storage formats. They simply outline the subset of
existing storage format structures that implementations of this specification will accept.
Byte stream format parsing and validation is implemented in the [=segment parser loop=] algorithm.
+
When currently configured by {{MediaSource/addSourceBuffer()}} or {{SourceBuffer/changeType()}} to
+ expect appends of WebCodecs encoded chunks via {{SourceBuffer/appendEncodedChunks()}} instead of a bytestream
+ via {{SourceBuffer/appendBuffer}}, the {{SourceBuffer}} does not have a specific bytestream format
+ associated.
This section provides general requirements for all byte stream format specifications: