MediaSegmentParseResult Class

public sealed class MediaSegmentParseResult

Properties

NameDescription
ByteCountGets the number of bytes to remove from the start of the buffer.
ErrorMessageGets the diagnostic message of an error, or an empty string.
FramesGets the complete coded frames of the media segment (MediaSegmentParseStatus.MediaSegment), in decode order.
InitializationSegmentGets the initialization segment (MediaSegmentParseStatus.InitializationSegment), or null.
IsParsingMediaSegmentGets a value indicating whether the parser is in the middle of a media segment: the rest of the segment is not received yet (the append state of the SourceBuffer is then PARSING_MEDIA_SEGMENT: mode and timestampOffset cannot be set until the segment is complete or abort() is called).
StatusGets what the start of the buffer contains.

Gets the number of bytes to remove from the start of the buffer.

public int ByteCount { get; }

Property value

int

Gets the diagnostic message of an error, or an empty string.

public string ErrorMessage { get; }

Property value

string

Gets the complete coded frames of the media segment (MediaSegmentParseStatus.MediaSegment), in decode order.

public IReadOnlyList<MediaCodedFrame> Frames { get; }

InitializationSegment

MediaSegmentParser.cs

Gets the initialization segment (MediaSegmentParseStatus.InitializationSegment), or null.

public MediaInitializationSegment? InitializationSegment { get; }

IsParsingMediaSegment

MediaSegmentParser.cs

Gets a value indicating whether the parser is in the middle of a media segment: the rest of the segment is not received yet (the append state of the SourceBuffer is then PARSING_MEDIA_SEGMENT: mode and timestampOffset cannot be set until the segment is complete or abort() is called).

public bool IsParsingMediaSegment { get; }

Property value

bool

Gets what the start of the buffer contains.

public MediaSegmentParseStatus Status { get; }

Methods

NameDescription
Error(string)The bytes violate the byte stream format, use a codec that is not supported, or cannot be decoded.
Ignore(int)The buffer starts with bytes that the byte stream format ignores (e.g. an unknown box).
Initialization(int, MediaInitializationSegment)The buffer starts with a complete initialization segment.
Media(int, IReadOnlyList<MediaCodedFrame>, bool)The buffer starts with complete coded frames of a media segment.
NeedMoreData(bool)The buffer does not contain a complete segment yet.

The bytes violate the byte stream format, use a codec that is not supported, or cannot be decoded.

public static MediaSegmentParseResult Error(string message = "")

Parameters

message string
A diagnostic message.

Returns

MediaSegmentParseResult

The buffer starts with bytes that the byte stream format ignores (e.g. an unknown box).

public static MediaSegmentParseResult Ignore(int byteCount)

Parameters

byteCount int
The number of bytes to ignore.

Returns

MediaSegmentParseResult

Initialization(int, MediaInitializationSegment)

MediaSegmentParser.cs

The buffer starts with a complete initialization segment.

public static MediaSegmentParseResult Initialization(int byteCount, MediaInitializationSegment segment)

Parameters

byteCount int
The size of the segment in bytes (0 when the segment has no byte of its own: e.g. the header of the first frame of an MPEG audio stream, which is then parsed as a media segment).
segment MediaInitializationSegment
The tracks and the duration of the segment.

Returns

MediaSegmentParseResult

Media(int, IReadOnlyList<MediaCodedFrame>, bool)

MediaSegmentParser.cs

The buffer starts with complete coded frames of a media segment.

public static MediaSegmentParseResult Media(int byteCount, IReadOnlyList<MediaCodedFrame> frames, bool isComplete = true)

Parameters

byteCount int
The number of bytes of the buffer that were parsed (0 or more when the segment is not complete).
frames IReadOnlyList<MediaCodedFrame>
The coded frames, in decode order.
isComplete bool
Whether the media segment is complete: otherwise the next bytes are the rest of the segment.

Returns

MediaSegmentParseResult

NeedMoreData(bool)

MediaSegmentParser.cs

The buffer does not contain a complete segment yet.

public static MediaSegmentParseResult NeedMoreData(bool isParsingMediaSegment = false)

Parameters

isParsingMediaSegment bool
Whether the buffer starts with (or continues) a media segment that is not complete.

Returns

MediaSegmentParseResult