Skip to main content

EncodedFrameConsumer

Defined in: livelink.js/sources/rendering/decoders/EncodedFrameConsumer.ts:28

A base class for consuming encoded frames.

This class can be extended to create custom encoded frame consumers.

As an example, a custom consumer could be created to embed the encoded frames in a video container format like MP4.

WebCodecsDecoder and SoftwareDecoder are examples of classes that extend this class.

Extended by

Constructors

new EncodedFrameConsumer()

new EncodedFrameConsumer(params: {
decoded_frame_consumer: null | DecodedFrameConsumer;
}): EncodedFrameConsumer

Defined in: livelink.js/sources/rendering/decoders/EncodedFrameConsumer.ts:40

Create a new encoded frame consumer.

Parameters

ParameterTypeDescription
params{ decoded_frame_consumer: null | DecodedFrameConsumer; }
params.decoded_frame_consumernull | DecodedFrameConsumerThe decoded frame consumer that will receive the decoded frames

Returns

EncodedFrameConsumer

Methods

configure()

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

Defined in: livelink.js/sources/rendering/decoders/EncodedFrameConsumer.ts:62

Configure the consumer with the codec and frame dimensions.

This method replaces the constructor to allow for async initialization.

This method should be called before any frames are consumed.

The consumer should be ready to consume frames after this method is called.

Parameters

ParameterTypeDescription
params{ codec: CodecType; frame_dimensions: Vec2; }
params.codecCodecTypeThe codec used to encode the frames
params.frame_dimensionsVec2The dimensions of the frame

Returns

Promise<EncodedFrameConsumer>

Must return a promise to this so that the method can be chained to the constructor:

const consumer = new MyConsumer().configure({ codec, frame_dimensions });

resize()

abstract resize(__namedParameters: {
frame_dimensions: Vec2;
}): void

Defined in: livelink.js/sources/rendering/decoders/EncodedFrameConsumer.ts:73

Resize the consumer with the new frame dimensions.

Parameters

ParameterType
__namedParameters{ frame_dimensions: Vec2; }
__namedParameters.frame_dimensionsVec2

Returns

void


release()

abstract release(): void

Defined in: livelink.js/sources/rendering/decoders/EncodedFrameConsumer.ts:78

Release any resources used by the consumer.

Returns

void


consumeEncodedFrame()

abstract consumeEncodedFrame(frame: {
encoded_frame: DataView;
meta_data: FrameMetaData;
}): void

Defined in: livelink.js/sources/rendering/decoders/EncodedFrameConsumer.ts:87

Consume an encoded frame. Called as soon as a frame is received.

Parameters

ParameterTypeDescription
frame{ encoded_frame: DataView; meta_data: FrameMetaData; }
frame.encoded_frameDataViewThe encoded frame data
frame.meta_dataFrameMetaDataThe frame meta data

Returns

void


_onFrameDecoded()

protected _onFrameDecoded(frame: {
decoded_frame: OffscreenCanvas | VideoFrame;
meta_data: FrameMetaData;
}): void

Defined in: livelink.js/sources/rendering/decoders/EncodedFrameConsumer.ts:95

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

Parameters

ParameterTypeDescription
frame{ decoded_frame: OffscreenCanvas | VideoFrame; meta_data: FrameMetaData; }The decoded frame data
frame.decoded_frameOffscreenCanvas | VideoFrameThe decoded frame data
frame.meta_dataFrameMetaDataThe frame meta data

Returns

void