MediaSegmentParser Class
The byte stream parser of a SourceBuffer of the Media Source Extensions (https://w3c.github.io/media-source/#byte-stream-formats), created by MediaBackend.CreateSegmentParser for the MIME type of addSourceBuffer() or changeType(): it splits the bytes appended by appendBuffer() into initialization segments (the tracks) and media segments (the coded frames: their timestamps, their durations and whether they are random access points). The library implements the rest of the specification on top of it: the segment parser loop, the coded frame processing algorithm (timestampOffset, mode, the append window), the track buffers and their buffered ranges, the removals, the duration, the ready states of the media element...
public abstract class MediaSegmentParser : IDisposableRemarks
The members are called on the thread of the event loop of the global object (a window or a dedicated worker) that created the MediaSource.
- Implements
Constructors
| Name | Description |
|---|---|
| MediaSegmentParser() |
MediaSegmentParser()
protected MediaSegmentParser()No documentation is available.
Properties
| Name | Description |
|---|---|
| BufferCapacity | Gets the size in bytes of the media segments the SourceBuffer keeps before it is full, or null for the default (150 MB with a video track, 12 MB for audio, as in Chromium). When the buffer is full, the frames that were played are evicted, and appendBuffer() throws a QuotaExceededError when it is still full (https://w3c.github.io/media-source/#sourcebuffer-coded-frame-eviction). |
| GeneratesTimestamps | Gets a value indicating whether the timestamps of the coded frames are generated by the SourceBuffer (the "Generate Timestamps Flag" of the byte stream format registry, https://www.w3.org/TR/mse-byte-stream-format-registry/): true for the formats whose frames have no timestamp (audio/mpeg, audio/aac). The mode of the SourceBuffer is then sequence. The default is false. |
BufferCapacity
MediaSegmentParser.csGets the size in bytes of the media segments the SourceBuffer keeps before it is full, or null for the default (150 MB with a video track, 12 MB for audio, as in Chromium). When the buffer is full, the frames that were played are evicted, and appendBuffer() throws a QuotaExceededError when it is still full (https://w3c.github.io/media-source/#sourcebuffer-coded-frame-eviction).
public virtual long? BufferCapacity { get; }Property value
GeneratesTimestamps
MediaSegmentParser.csGets a value indicating whether the timestamps of the coded frames are generated by the SourceBuffer (the "Generate Timestamps Flag" of the byte stream format registry, https://www.w3.org/TR/mse-byte-stream-format-registry/): true for the formats whose frames have no timestamp (audio/mpeg, audio/aac). The mode of the SourceBuffer is then sequence. The default is false.
public virtual bool GeneratesTimestamps { get; }Property value
Methods
| Name | Description |
|---|---|
| Dispose() | Releases the resources of the parser: its SourceBuffer is removed, or its type changed. |
| Dispose(bool) | Releases the resources of the parser. |
| Parse(ReadOnlyMemory<byte>) | Parses the start of the input buffer of the SourceBuffer (the segment parser loop, https://w3c.github.io/media-source/#sourcebuffer-segment-parser-loop). The method is called again with the rest of the buffer until it returns MediaSegmentParseResult.NeedMoreData or an error, and again when more bytes are appended. |
| Reset() | Resets the parser (https://w3c.github.io/media-source/#sourcebuffer-reset-parser-state): the bytes that were not consumed are dropped (abort(), changeType(), an append error), and the next bytes are the start of a segment. The default implementation does nothing. |
Dispose overloads
Dispose()
MediaSegmentParser.csReleases the resources of the parser: its SourceBuffer is removed, or its type changed.
public void Dispose()Dispose(bool)
MediaSegmentParser.csReleases the resources of the parser.
Parameters
disposingbool- Whether the method is called by
MediaSegmentParser.Dispose.
Parse(ReadOnlyMemory<byte>)
Parses the start of the input buffer of the SourceBuffer (the segment parser loop, https://w3c.github.io/media-source/#sourcebuffer-segment-parser-loop). The method is called again with the rest of the buffer until it returns MediaSegmentParseResult.NeedMoreData or an error, and again when more bytes are appended.
public abstract MediaSegmentParseResult Parse(ReadOnlyMemory<byte> input)Parameters
inputReadOnlyMemory<byte>- The bytes that were appended and not consumed yet. The buffer is not empty.
Returns
MediaSegmentParseResult What the start of the buffer contains, and the number of bytes to remove from the buffer.
Reset()
MediaSegmentParser.csResets the parser (https://w3c.github.io/media-source/#sourcebuffer-reset-parser-state): the bytes that were not consumed are dropped (abort(), changeType(), an append error), and the next bytes are the start of a segment. The default implementation does nothing.
public virtual void Reset()