Skip to main content

Abstract Class: EncodedFrameConsumer

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

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​

Constructor​

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

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

Create a new encoded frame consumer.

Parameters​

ParameterTypeDescription
params{ decoded_frame_consumer: DecodedFrameConsumer | null; }-
params.decoded_frame_consumerDecodedFrameConsumer | nullThe 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.clients/livelink.js/sources/rendering/streaming/EncodedFrameConsumer.ts:97

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(params: {
frame_dimensions: Vec2;
}): void;

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

Resize the consumer with the new frame dimensions.

Parameters​

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

Returns​

void


release()​

abstract release(): void;

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

Release any resources used by the consumer.

Returns​

void


consumeEncodedFrame()​

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

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

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

Parameters​

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

Returns​

void


_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