Skip to content

FrameWriter

Defined in: relay-sdks/ts/src/frame-writer.ts:69

Maps encoded frames onto a registered track’s groups, one frame at a time. Create one with createFrameWriter.

Type Parameter Default type
F extends Frame Frame
readonly backlog: number;

Defined in: relay-sdks/ts/src/frame-writer.ts:92

Frames waiting behind the one being written.


readonly closed: boolean;

Defined in: relay-sdks/ts/src/frame-writer.ts:84

True once close ran or the track ended under the writer.


readonly ended:
| RelayError
| undefined;

Defined in: relay-sdks/ts/src/frame-writer.ts:86

The failure that ended the track, once a write has seen it; undefined while the track is open.


readonly groups: number;

Defined in: relay-sdks/ts/src/frame-writer.ts:88

Groups opened so far.


readonly keyframeNeeded: boolean;

Defined in: relay-sdks/ts/src/frame-writer.ts:98

Whether the next frame the writer can send must be a keyframe: from the start until a keyframe arrives, and again after a relay demand change, an interruption, a stale or discontinuous frame, or a drop. Always false under frame grouping. Check it before each encode().


readonly objects: number;

Defined in: relay-sdks/ts/src/frame-writer.ts:90

Objects the transport accepted so far.

close(): Promise<void>;

Defined in: relay-sdks/ts/src/frame-writer.ts:82

Drop the backlog, FIN the open group once the frame being written settles, and refuse further frames. Idempotent. A RelayError from that FIN is swallowed: the group was abandoned either way. The registered track stays the application’s to close.

Promise<void>


write(frame): Promise<FrameOutcome>;

Defined in: relay-sdks/ts/src/frame-writer.ts:76

Send one frame if the relay wants it, and say what happened. May be called without awaiting the previous call: frames are served in call order, and those waiting are the backlog. Resolves when the transport accepted the object, or as soon as the frame is known not to be sent. Rejects with CLOSED after close; a track that ended on its own is an 'ended' outcome instead, because the encoder keeps producing.

Parameter Type
frame F

Promise<FrameOutcome>