/*! * Copyright (c) 2026-present, Vanilagy and contributors * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import { AppendOnlyStreamTarget } from 'mediabunny'; /** * Options for {@link RistTarget}. * * @group \@mediabunny/server * @public */ export type RistTargetOptions = { /** * Whether to send to a receiver that is listening (`'caller'`, the default) or to bind the URL's * ports and wait for one to announce itself (`'listener'`). * * A caller sends RTP straight to the URL's address. A listener binds those ports and sends to * whichever address its first RTCP arrives from, which is how a receiver behind NAT is reached. */ mode?: 'listener' | 'caller'; /** * **Milliseconds** of sent packets kept for retransmission. Defaults to 1000, matching * `RistSource`'s own buffer: a receiver cannot ask for what it has already given up on. */ retransmitBufferMs?: number; /** Bytes to queue before the target blocks the writer, or drops. Defaults to 2 MiB. */ maxQueueBytes?: number; /** * What to do once {@link RistTargetOptions.maxQueueBytes} is reached: `'block'` (the default) makes * the writer wait for the socket to catch up, `'drop'` discards the write and counts it. * * Blocking is right for a relay, where losing bytes is worse than arriving late. Dropping is right * for a live encode that must not be stalled by a slow receiver, and is what * {@link RistTarget.droppedBytes} counts. */ onOverflow?: 'block' | 'drop'; /** * Send at the rate the stream itself states, read from the MPEG-TS PCR. On by default, and inert on * a payload carrying no PCR — there is then no rate to pace to, and the bytes go out as fast as the * socket takes them. * * An unpaced sender hands a whole segment to the kernel at once, which a receiver absorbs out of its * de-jitter buffer or not at all. */ pacing?: boolean; }; /** * An {@link https://mediabunny.dev/guide/writing-media-files#target | output target} that sends MPEG-TS * over RIST Simple Profile (VSF TR-06-1), the counterpart to {@link RistSource}. * * RTP goes to the URL's even port and RTCP is read on the next one, where a receiver's NACKs arrive; a * packet asked for is resent from a buffer of what was recently sent. The protocol is spoken directly * rather than through FFmpeg, which has no librist in this build. * * A byte sink, so the format decides what travels — for a live feed, `MpegTsOutputFormat`. Like * {@link SrtTarget} it drops rather than blocking: past * {@link RistTargetOptions.maxQueueBytes} the arriving bytes are dropped and counted. * * @example * ```ts * const output = new Output({ * format: new MpegTsOutputFormat(), * target: new RistTarget('rist://receiver:9000'), * }); * ``` * * Speaks **Simple Profile** only. `@mediabunny/rist` has a `RistTarget` of the same name over librist * which defaults to main profile, supports encryption, and leaves the send queue to librist — the two * are not interchangeable. * * @group \@mediabunny/server * @public */ export declare class RistTarget extends AppendOnlyStreamTarget { constructor(url: string, options?: RistTargetOptions); /** * Sends what is short of a full datagram now rather than waiting for the bytes that would fill it, * the counterpart of {@link SrtTarget.flushPartialDatagram} — see there for the trade. */ flushPartialDatagram(): Promise; /** RTP packets sent, not counting retransmissions. */ get sentPackets(): number; /** Packets sent again because a receiver asked for them. */ get retransmittedPackets(): number; /** Payload bytes handed to the socket so far, not counting retransmissions. */ get sentBytes(): number; /** * Bytes accepted but not yet handed to the socket, against the bound stated by * {@link RistTarget.maxQueueBytes}. This is the headroom a caller has before anything is dropped, * which is the only way to see it coming rather than after. * * Counted down per datagram rather than per chunk handed in, so it means bytes not yet on the wire * rather than chunks not yet picked up. It reads 0 whenever the sender is keeping up, which on a * healthy path is most of the time, and rises when a producer outruns the socket. */ get queuedBytes(): number; /** The bound {@link RistTarget.queuedBytes} is held against, from the options or the default. */ get maxQueueBytes(): number; /** * Bytes dropped because the queue was full. Not a count of what failed to arrive, and 0 unless * `onOverflow: 'drop'` was asked for — the default blocks the writer instead. */ get droppedBytes(): number; /** Datagrams' worth of dropped bytes, which is the unit a receiver sees missing. */ get droppedDatagrams(): number; } //# sourceMappingURL=rist-target.d.ts.map