Skip to main content

EncodedFrameConsumer

@3dverse/livelink v0.8.10


@3dverse/livelink / EncodedFrameConsumer

Class: abstract EncodedFrameConsumer

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

A base class for consuming encoded frames.

flowchart LR
A(Renderer) -->|Network Packet| B(Core)
B -->|Encoded Frame| C(EncodedFrameConsumer)
C -->|Decoded Frame| D(DecodedFrameConsumer)
style C fill:#191,stroke:#333,stroke-width:4px

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): EncodedFrameConsumer

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

Create a new encoded frame consumer.

Parameters

params
decoded_frame_consumer

null | DecodedFrameConsumer

The decoded frame consumer that will receive the decoded frames

Returns

EncodedFrameConsumer

Methods

configure()

abstract configure(params): 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

params
codec

CodecType

The codec used to encode the frames

frame_dimensions

Vec2

The 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 });

release()

abstract release(): void

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

Release any resources used by the consumer.

Returns

void


consumeEncodedFrame()

abstract consumeEncodedFrame(frame): void

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

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

Parameters

frame
encoded_frame

DataView

The encoded frame data

meta_data

FrameMetaData

The frame meta data

Returns

void


_onFrameDecoded()

protected _onFrameDecoded(frame): void

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

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

Parameters

frame

The decoded frame data

decoded_frame

OffscreenCanvas | VideoFrame

The decoded frame data

meta_data

FrameMetaData

The frame meta data

Returns

void