import type { FfmpegOptions } from "./options.ts"; import { FfmpegProcess } from "./process.ts"; import type { FfmpegProcessInit } from "./process.ts"; import type { IpFamily } from "./dgram-util.ts"; /** * UDP return-port descriptor for the stream-health monitor. * * @property ipFamily - The IP family: `"ipv4"` binds to `127.0.0.1`, `"ipv6"` binds to `::1`. Shares the {@link IpFamily} alias with `RtpDemuxerInit`, * `PortReservationInit`, and `PortReservation` so every UDP-aware init type in the FFmpeg subsystem reads from the same vocabulary. * @property port - The UDP port to bind to. Pass `0` to request kernel-assigned ephemeral allocation: the bind succeeds atomically against whichever port * the kernel hands out, eliminating the reserve-then-rebind race that a separate reservation step would carry. The assigned port is then * observable via {@link FfmpegStreamingProcess.returnPort} once {@link FfmpegStreamingProcess.ready} resolves. * * @category FFmpeg */ export interface FfmpegStreamingReturnPort { ipFamily: IpFamily; port: number; } /** * Construction-time options for {@link FfmpegStreamingProcess}. * * @property healthTimeout - Optional inactivity window, in milliseconds, between inbound packets on the return port (the HomeKit client's RTCP receiver reports). * The watchdog arms on the first such packet, then aborts with `HbpuAbortError("timeout")` if a later window elapses with no packet. * Defaults to {@link STREAM_HEALTH_TIMEOUT} (5 seconds). This is the watchdog's own cadence, not an FFmpeg input timeout. * @property returnPort - Optional UDP return-port descriptor. When provided, the subclass binds a UDP socket to the port and enforces the liveness watchdog on * inbound traffic. Omit for two-way-audio sessions where packet flow is demuxed externally (e.g., via `RtpDemuxer`). * * @see FfmpegProcessInit * * @category FFmpeg */ export interface FfmpegStreamingInit extends FfmpegProcessInit { healthTimeout?: number; returnPort?: FfmpegStreamingReturnPort; } /** * FFmpeg process specialization for HomeKit livestreaming. Extends {@link FfmpegProcess} directly and composes an internal stream-health UDP socket when a return port * is configured. * * Lifecycle is entirely signal-driven: construction spawns the child and (optionally) binds the health socket; the socket watches for inbound packets and aborts the * process with `"timeout"` if the window lapses; the inherited teardown path closes the socket and clears the watchdog timer as part of its signal-abort listener * fan-out. The subclass adds no new public verbs beyond what {@link FfmpegProcess} provides. * * @example * * ```ts * await using proc = new FfmpegStreamingProcess(ffmpegOptions, { * * args: commandLineArgs, * returnPort: { ipFamily: "ipv4", port: 50000 }, * signal: session.controller.signal * }); * * await proc.ready; * * // Observe the process from the session's own control flow. When the health socket detects a stall, proc.signal fires * // with reason "timeout" and proc.exited resolves with the kill-driven exit context. Surface crashes via the owning * // session's error path. * proc.exited.catch((error) => session.onStreamingError(error)); * ``` * * @see FfmpegProcess * * @category FFmpeg */ export declare class FfmpegStreamingProcess extends FfmpegProcess { #private; /** * Construct and spawn a new streaming FFmpeg process. * * Spawning happens synchronously as part of construction. When `init.returnPort` is supplied, the subclass binds a UDP socket and enforces the liveness watchdog; the * socket closes and the watchdog clears as part of the inherited teardown when the signal aborts for any reason. * * @param options - Shared {@link FfmpegOptions} configuration (codec support, logger, debug flag, name). * @param init - Optional init options. See {@link FfmpegStreamingInit}. */ constructor(options: FfmpegOptions, init?: FfmpegStreamingInit); /** * The UDP return-port descriptor the health socket is bound to, or `undefined` when no return port was configured. For a specific-port construction * (`init.returnPort.port` non-zero), this descriptor equals `init.returnPort` from the moment the constructor returns; for an ephemeral construction * (`init.returnPort.port === 0`), the `port` field is `0` until the kernel completes the bind, then the kernel-assigned port. Consumers that need the assigned * ephemeral port `await proc.ready` before reading it; in practice the health-socket bind completes well before the FFmpeg child reaches the `ready` signal, so a * post-`ready` read always observes the kernel's pick. * * Returns a fresh descriptor on every read; callers must treat the result as read-only. The `ipFamily` field is the verbatim value passed at construction; the * `port` field reads from the live socket-address projection once captured (specific and ephemeral binds converge on a single read path). * * @returns The bound return-port descriptor, or `undefined` when no return port was configured. */ get returnPort(): FfmpegStreamingReturnPort | undefined; } //# sourceMappingURL=stream.d.ts.map