Skip to content

@seydx/rtsp / CallbackSinkHandlers

Interface: CallbackSinkHandlers

Defined in: sinks/callback.ts:11

Lifecycle callbacks for a CallbackSink.

Each handler is optional, so a consumer can subscribe to only the phases it cares about. Handlers may be synchronous or asynchronous; when a handler returns a promise the relay awaits it before proceeding, which provides natural backpressure on the upstream packet flow.

Properties

onClose?

optional onClose?: () => void | Promise<void>

Defined in: sinks/callback.ts:37

Called once on teardown, after the last packet has been delivered.

Use this to release any resources allocated in onInit. If it returns a promise, the relay awaits it as part of closing the sink.

Returns

void | Promise<void>


onInit?

optional onInit?: (info) => void | Promise<void>

Defined in: sinks/callback.ts:20

Called once when the relay resolves the upstream stream layout.

Receives the full StreamInfo (tracks plus any backchannel format) before the first packet is delivered, giving the consumer a chance to set up per-track state. If it returns a promise, the relay awaits it before delivering packets.

Parameters

info

StreamInfo

Returns

void | Promise<void>


onPacket?

optional onPacket?: (packet) => void | Promise<void>

Defined in: sinks/callback.ts:29

Called for every keyframe-gated packet the relay delivers to this sink.

The MediaPacket is only valid for the duration of this call: the relay frees it once the returned promise resolves, so any payload that must outlive the call has to be copied out (or the packet cloned) here.

Parameters

packet

MediaPacket

Returns

void | Promise<void>