@seydx/rtsp / Sink
Interface: Sink
Defined in: types.ts:515
A consumer of the relayed stream.
The relay calls init once with the resolved stream info, then write for each packet destined for this sink (already keyframe-gated), and finally close on teardown. The relay frees each packet after the write promise resolves, so a sink must not retain a packet beyond that point; if it needs to hold one, it must clone it first.
Example
import { Sink, StreamInfo, MediaPacket } from '@seydx/rtsp';
const sink: Sink = {
init(info: StreamInfo) { setup(info); },
write(packet: MediaPacket) { forward(packet); },
close() { teardown(); },
};See
- Source For the producing side of the relay
- MediaPacket For the units a sink receives
Methods
close()
close():
void|Promise<void>
Defined in: types.ts:565
Tear the sink down.
Called when the relay stops, allowing the sink to flush and release any resources it acquired during init.
Returns
void | Promise<void>
Nothing, or a promise that resolves once teardown completes
Example
await sink.close();init()
init(
info):void|Promise<void>
Defined in: types.ts:531
Initialize the sink with the resolved stream layout.
Called once before any packet is written, giving the sink the chance to configure muxers, encoders, or output channels from the source's tracks.
Parameters
info
The resolved stream information for the source being relayed
Returns
void | Promise<void>
Nothing, or a promise that resolves once initialization completes
Example
await sink.init(info);write()
write(
packet):void|Promise<void>
Defined in: types.ts:550
Write a single packet to the sink.
Called per packet destined for this sink, already keyframe-gated by the relay. The packet is owned by the relay and freed once the returned promise resolves, so the sink must clone it to retain it beyond this call.
Parameters
packet
The media packet to consume
Returns
void | Promise<void>
Nothing, or a promise that resolves once the packet has been consumed
Example
await sink.write(packet);