VideoDecoder Class

Decodes video (https://w3c.github.io/webcodecs/#videodecoder-interface): the EncodedVideoChunk objects given to VideoDecoder.Decode are decoded by the codecs of BrowsingContextOptions.MediaCodecs, and the VideoFrame objects are given to the output callback, with the orientation, the display aspect ratio and the color space of the configuration.

public sealed class VideoDecoder : EventTarget
Inheritance
EventTarget VideoDecoder

Constructors

NameDescription
VideoDecoder(VideoDecoderInit)Creates a decoder (https://w3c.github.io/webcodecs/#dom-videodecoder-videodecoder).

VideoDecoder(VideoDecoderInit)

Codecs.cs

Creates a decoder (https://w3c.github.io/webcodecs/#dom-videodecoder-videodecoder).

public VideoDecoder(VideoDecoderInit init)

Parameters

init VideoDecoderInit
The output and error callbacks.

See also

Properties

NameDescription
DecodeQueueSizeGets the number of pending decode requests.
OnDequeueGets or sets the event handler of the dequeue event (the queue size decreased).
StateGets the state of the decoder.

DecodeQueueSize

Codecs.cs

Gets the number of pending decode requests.

public uint DecodeQueueSize { get; }

OnDequeue

Codecs.cs

Gets or sets the event handler of the dequeue event (the queue size decreased).

public Action<Event>? OnDequeue { get; set; }

Gets the state of the decoder.

public CodecState State { get; }

Methods

NameDescription
Close()Closes the decoder (https://w3c.github.io/webcodecs/#dom-videodecoder-close).
Configure(VideoDecoderConfig)Configures the decoder (https://w3c.github.io/webcodecs/#dom-videodecoder-configure): a configuration that the codecs do not support closes it with a NotSupportedError.
Decode(EncodedVideoChunk)Decodes a chunk (https://w3c.github.io/webcodecs/#dom-videodecoder-decode).
Flush()Decodes the pending chunks (https://w3c.github.io/webcodecs/#dom-videodecoder-flush): the promise resolves once their frames are delivered.
IsConfigSupported(VideoDecoderConfig)Returns whether the codecs support a configuration (https://w3c.github.io/webcodecs/#dom-videodecoder-isconfigsupported).
Reset()Discards the pending chunks and the configuration (https://w3c.github.io/webcodecs/#dom-videodecoder-reset).

Close()

Codecs.cs

Closes the decoder (https://w3c.github.io/webcodecs/#dom-videodecoder-close).

public void Close()

Exceptions

DomException
An InvalidStateError when the decoder is closed.

See also

Configure(VideoDecoderConfig)

Codecs.cs

Configures the decoder (https://w3c.github.io/webcodecs/#dom-videodecoder-configure): a configuration that the codecs do not support closes it with a NotSupportedError.

public void Configure(VideoDecoderConfig config)

Parameters

config VideoDecoderConfig
The configuration.

Exceptions

TypeErrorException
The configuration is invalid.
DomException
An InvalidStateError when the decoder is closed.

See also

Decode(EncodedVideoChunk)

Codecs.cs

Decodes a chunk (https://w3c.github.io/webcodecs/#dom-videodecoder-decode).

public void Decode(EncodedVideoChunk chunk)

Parameters

chunk EncodedVideoChunk
The chunk.

Exceptions

DomException
An InvalidStateError when the decoder is not configured, a DataError when a key chunk is required.

See also

Flush()

Codecs.cs

Decodes the pending chunks (https://w3c.github.io/webcodecs/#dom-videodecoder-flush): the promise resolves once their frames are delivered.

public Task Flush()

IsConfigSupported(VideoDecoderConfig)

Codecs.cs

Returns whether the codecs support a configuration (https://w3c.github.io/webcodecs/#dom-videodecoder-isconfigsupported).

public static Task<VideoDecoderSupport> IsConfigSupported(VideoDecoderConfig config)

Parameters

config VideoDecoderConfig
The configuration.

Returns

Task<VideoDecoderSupport> A task that completes with the support and the configuration with the recognized members, or fails with a TypeErrorException for an invalid configuration.

See also

Reset()

Codecs.cs

Discards the pending chunks and the configuration (https://w3c.github.io/webcodecs/#dom-videodecoder-reset).

public void Reset()

Exceptions

DomException
An InvalidStateError when the decoder is closed.

See also