MediaCodecBackend Class

The audio and video codecs plugged into the browsing contexts (BrowsingContextOptions.MediaCodecs): the implementations of the decoders and the encoders of WebCodecs (https://w3c.github.io/webcodecs/), also used by MediaRecorder. The backend tells which configurations it supports and creates the codec implementations; the library implements the codec processing model on top of them (the states, the control message queue, the queue sizes and the dequeue events, flush(), reset(), close(), the output and error callbacks, the validation and the cloning of the configurations, the decoder configuration of the encoded chunks).

public abstract class MediaCodecBackend

Remarks

Without a backend (the default), there is no codec: isConfigSupported() resolves with supported: false, and configure() closes the codec with a NotSupportedError.

A backend can be shared by several browsing contexts and by their workers: its methods may be called from several threads, each codec implementation being used by the thread of the event loop of its codec. The codec implementations run in the tasks of that event loop, one operation at a time. The configurations given to the backend are clones with the members recognized by the library: their description is a Byte array. MediaCodecString parses the codec strings of the WebCodecs codec registry.

Constructors

NameDescription
MediaCodecBackend()

MediaCodecBackend()

protected MediaCodecBackend()

No documentation is available.

Methods

NameDescription
CreateAudioDecoder(AudioDecoderConfig)Creates an audio decoder for a configuration that MediaCodecBackend.IsConfigSupported accepts, or returns null when it cannot (the codec is closed with a NotSupportedError). The default implementation returns null.
CreateAudioEncoder(AudioEncoderConfig)Creates an audio encoder for a supported configuration, or returns null. The default implementation returns null.
CreateVideoDecoder(VideoDecoderConfig)Creates a video decoder for a supported configuration, or returns null. The default implementation returns null.
CreateVideoEncoder(VideoEncoderConfig)Creates a video encoder for a supported configuration, or returns null. The default implementation returns null.
IsConfigSupported(AudioDecoderConfig)Returns whether the backend can decode the audio of a configuration (https://w3c.github.io/webcodecs/#check-configuration-support). The configuration is valid (its codec string is not empty); the codec string is case-sensitive and must not have leading or trailing spaces. The default implementation returns false.
IsConfigSupported(AudioEncoderConfig)Returns whether the backend can encode audio with a configuration. The default implementation returns false.
IsConfigSupported(VideoDecoderConfig)Returns whether the backend can decode the video of a configuration. The default implementation returns false.
IsConfigSupported(VideoEncoderConfig)Returns whether the backend can encode video with a configuration. The default implementation returns false.

CreateAudioDecoder(AudioDecoderConfig)

MediaCodecBackend.cs

Creates an audio decoder for a configuration that MediaCodecBackend.IsConfigSupported accepts, or returns null when it cannot (the codec is closed with a NotSupportedError). The default implementation returns null.

public virtual MediaAudioDecoder? CreateAudioDecoder(AudioDecoderConfig config)

Parameters

config AudioDecoderConfig
The configuration.

Returns

MediaAudioDecoder?

CreateAudioEncoder(AudioEncoderConfig)

MediaCodecBackend.cs

Creates an audio encoder for a supported configuration, or returns null. The default implementation returns null.

public virtual MediaAudioEncoder? CreateAudioEncoder(AudioEncoderConfig config)

Parameters

config AudioEncoderConfig
The configuration.

Returns

MediaAudioEncoder?

CreateVideoDecoder(VideoDecoderConfig)

MediaCodecBackend.cs

Creates a video decoder for a supported configuration, or returns null. The default implementation returns null.

public virtual MediaVideoDecoder? CreateVideoDecoder(VideoDecoderConfig config)

Parameters

config VideoDecoderConfig
The configuration.

Returns

MediaVideoDecoder?

CreateVideoEncoder(VideoEncoderConfig)

MediaCodecBackend.cs

Creates a video encoder for a supported configuration, or returns null. The default implementation returns null.

public virtual MediaVideoEncoder? CreateVideoEncoder(VideoEncoderConfig config)

Parameters

config VideoEncoderConfig
The configuration.

Returns

MediaVideoEncoder?

IsConfigSupported overloads

IsConfigSupported(AudioDecoderConfig)

MediaCodecBackend.cs

Returns whether the backend can decode the audio of a configuration (https://w3c.github.io/webcodecs/#check-configuration-support). The configuration is valid (its codec string is not empty); the codec string is case-sensitive and must not have leading or trailing spaces. The default implementation returns false.

public virtual bool IsConfigSupported(AudioDecoderConfig config)
Parameters
config AudioDecoderConfig
The configuration.
Returns

bool

IsConfigSupported(AudioEncoderConfig)

MediaCodecBackend.cs

Returns whether the backend can encode audio with a configuration. The default implementation returns false.

public virtual bool IsConfigSupported(AudioEncoderConfig config)
Parameters
config AudioEncoderConfig
The configuration.
Returns

bool

IsConfigSupported(VideoDecoderConfig)

MediaCodecBackend.cs

Returns whether the backend can decode the video of a configuration. The default implementation returns false.

public virtual bool IsConfigSupported(VideoDecoderConfig config)
Parameters
config VideoDecoderConfig
The configuration.
Returns

bool

IsConfigSupported(VideoEncoderConfig)

MediaCodecBackend.cs

Returns whether the backend can encode video with a configuration. The default implementation returns false.

public virtual bool IsConfigSupported(VideoEncoderConfig config)
Parameters
config VideoEncoderConfig
The configuration.
Returns

bool