/*! * 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 SrtTarget}. * * @group \@mediabunny/server * @public */ export type SrtTargetOptions = { /** * **Seconds** to wait for a peer - for a caller to answer, or for one to arrive while listening. * Defaults to 30. Never infinite: a wait cannot be cancelled once started. */ connectTimeout?: number; /** AES passphrase. SRT requires 10 to 79 characters. Without one the stream is unencrypted. */ passphrase?: string; /** AES key length in bits. Defaults to 128. Only meaningful alongside a passphrase. */ keyLength?: 128 | 192 | 256; /** * SRT latency budget in **milliseconds**, the window it has to recover lost packets in. * * Named for its unit because the timeouts beside it are in seconds, which is easy to cross. */ latencyMs?: number; /** * SRT latency budget in milliseconds. * * @deprecated Use {@link SrtTargetOptions.latencyMs}, which states its unit. Still milliseconds, so * a value that worked here still works there. */ latency?: number; /** * Bytes to hold for a receiver that is not keeping up, before the target starts dropping. Defaults * to 2 MiB. See {@link SrtTarget} for what dropping means. */ maxQueueBytes?: number; }; /** * An {@link https://mediabunny.dev/guide/writing-media-files#target | output target} that sends bytes over * SRT, so an `Output` can stream to an SRT receiver the way it writes to a file. A byte sink: it carries * whatever the format writes, which for a live feed means `MpegTsOutputFormat`. * * Calls out by default, or listens with `?mode=listener`. The socket is opened on the first write, so * constructing one never blocks, and every wait is bounded by `connectTimeout`. * * Writes are queued and sent by a pump, so a slow receiver is dropped for rather than blocking the * muxer - see {@link SrtTarget.droppedBytes}. A dead peer stops the bytes and errors on close; * reconnecting is the caller's, by building a new `Output`. * * @example * ```ts * const target = new SrtTarget('srt://receiver:9000', { passphrase: 'a-good-passphrase', latency: 200 }); * const output = new Output({ format: new MpegTsOutputFormat(), target }); * ``` * * @group \@mediabunny/server * @public */ export declare class SrtTarget extends AppendOnlyStreamTarget { constructor(url: string, options?: SrtTargetOptions); /** * Sends what is short of a full datagram now rather than waiting for the bytes that would fill it. * * A datagram is packed to 1316 bytes so each one carries whole MPEG-TS packets, which means a tail * shorter than that waits for more data — and at a low bitrate that wait is latency. Calling this * trades the packing for promptness. `TargetWriter.flush()` deliberately does not do it: it is the * normal per-fragment flush, and sending a short datagram at each one would spend the payload * efficiency the packing exists for. */ flushPartialDatagram(): Promise; /** Bytes handed to the socket so far. */ get sentBytes(): number; /** * Bytes waiting to go to the socket. Against {@link SrtTarget.maxQueueBytes} this is the headroom a * caller has before anything is dropped, which is the only way to see it coming rather than after. */ get queuedBytes(): number; /** The bound {@link SrtTarget.queuedBytes} is held against, from the options or the default. */ get maxQueueBytes(): number; /** Bytes dropped because the receiver was not keeping up. Stays 0 for a receiver that keeps up. */ get droppedBytes(): number; /** Datagrams' worth of dropped bytes, which is the unit a receiver sees missing. */ get droppedDatagrams(): number; } //# sourceMappingURL=srt-target.d.ts.map