Skip to main content

Class: WebCodecsDecoder

Defined in: livelink.clients/livelink.js/sources/rendering/streaming/WebCodecsDecoder.ts:21

A decoder that uses the WebCodecs API to decode video frames.

This decoder is hardware accelerated (if supported) and is the most efficient way to decode video frames.

This decoder is only available in browsers that support the WebCodecs API.

See​

https://developer.mozilla.org/en-US/docs/Web/API/WebCodecs_API

Extends​

Constructors​

Constructor​

new WebCodecsDecoder(frame_consumer: {
decoded_frame_consumer: DecodedFrameConsumer;
}): WebCodecsDecoder;

Defined in: livelink.clients/livelink.js/sources/rendering/streaming/WebCodecsDecoder.ts:142

Create a new WebCodecsDecoder that will send the decoded frames to the given frame consumer.

Parameters​

ParameterTypeDescription
frame_consumer{ decoded_frame_consumer: DecodedFrameConsumer; }The frame consumer that will receive the decoded frames
frame_consumer.decoded_frame_consumerDecodedFrameConsumer-

Returns​

WebCodecsDecoder

Overrides​

EncodedFrameConsumer.constructor

Methods​

_onFrameDecoded()​

protected _onFrameDecoded(params: {
decoded_frame: DecodedFrame;
}): void;

Defined in: livelink.clients/livelink.js/sources/rendering/streaming/EncodedFrameConsumer.ts:132

Must be called by the implementation as soon as the frame is decoded to update the cameras in the scene.

Parameters​

ParameterTypeDescription
params{ decoded_frame: DecodedFrame; }-
params.decoded_frameDecodedFrameThe decoded frame

Returns​

void

Inherited from​

EncodedFrameConsumer._onFrameDecoded


findSupportedCodec()​

static findSupportedCodec(): Promise<
| CodecType
| null>;

Defined in: livelink.clients/livelink.js/sources/rendering/streaming/WebCodecsDecoder.ts:35

Find a supported codec that can be decoded by the WebCodecs API.

This method can be used to check if the WebCodecs API is supported by the browser.

If the WebCodecs API is not supported, this method will return null.

If the WebCodecs API is supported, this method will return the best codec that is supported by the browser.

If no codec is supported by the browser, this method will return null.

Returns​

Promise< | CodecType | null>

The codec that is supported by the browser, or null if the WebCodecs API is not supported or no codec is supported by the browser.


configure()​

configure(__namedParameters: {
codec: CodecType;
frame_dimensions: Vec2;
}): Promise<EncodedFrameConsumer>;

Defined in: livelink.clients/livelink.js/sources/rendering/streaming/WebCodecsDecoder.ts:150

Configure the decoder with the codec and frame dimensions. This method replaces the constructor to allow for async initialization.

Parameters​

ParameterType
__namedParameters{ codec: CodecType; frame_dimensions: Vec2; }
__namedParameters.codecCodecType
__namedParameters.frame_dimensionsVec2

Returns​

Promise<EncodedFrameConsumer>

Overrides​

EncodedFrameConsumer.configure


resize()​

resize(params: {
frame_dimensions: Vec2;
}): void;

Defined in: livelink.clients/livelink.js/sources/rendering/streaming/WebCodecsDecoder.ts:187

Resize the decoder with the new frame dimensions.

Parameters​

ParameterTypeDescription
params{ frame_dimensions: Vec2; }-
params.frame_dimensionsVec2The new frame dimensions

Returns​

void

Overrides​

EncodedFrameConsumer.resize


release()​

release(): void;

Defined in: livelink.clients/livelink.js/sources/rendering/streaming/WebCodecsDecoder.ts:208

Release any resources used by the decoder.

Returns​

void

Overrides​

EncodedFrameConsumer.release


consumeEncodedFrame()​

consumeEncodedFrame(params: {
encoded_frame: EncodedFrame;
}): void;

Defined in: livelink.clients/livelink.js/sources/rendering/streaming/WebCodecsDecoder.ts:220

Consume an encoded frame.

Parameters​

ParameterTypeDescription
params{ encoded_frame: EncodedFrame; }-
params.encoded_frameEncodedFrameThe encoded frame

Returns​

void

Overrides​

EncodedFrameConsumer.consumeEncodedFrame