import type { FMp4AudioTarget, FfmpegOptions, HomebridgePluginLogging } from "homebridge-plugin-utils";
import type { LivestreamSubscriptionState, Segment } from "unifi-protect";
/**
 * The minimal livestream-subscription surface the plugin's FFmpeg consumers depend on. The plugin OWNS this abstraction (dependency inversion): the unifi-protect
 * library's pooled LivestreamSubscription class and the RTSP-debug adapter below are interchangeable implementations behind it. It is a deliberate subset of the
 * library's richer class (interface segregation) - the plugin needs the segment stream, the cached init, the coarse lifecycle state (the timeshift's `isRestarting` reads
 * it), the in-flight recovery re-decision (the timeshift's transmit-start escalation calls it), disposal, identity, and the establishment latch, and nothing more (no
 * stats/codec). The coupling is a feature: a unifi-protect library change that breaks this surface fails to compile at ProtectCamera.livestream()'s return.
 */
export interface LivestreamSubscription extends AsyncIterable<Segment>, AsyncDisposable {
    readonly id: string;
    readonly initSegment: {
        codec: string;
        data: Buffer;
    } | null;
    readonly state: LivestreamSubscriptionState;
    reassess(): void;
    whenEstablished(): Promise<boolean>;
}
interface RtspLivestreamSubscriptionOptions {
    audio: FMp4AudioTarget;
    enableAudio: boolean;
    ffmpegOptions: FfmpegOptions;
    segmentLength?: number;
    signal?: AbortSignal;
    url: string;
    videoCodec: string;
}
/**
 * The RTSP-debug adapter (Debug.Video.Timeshift.UseRtsp). It implements the plugin's LivestreamSubscription interface over a single FfmpegLivestreamProcess that
 * transcodes the camera's RTSP stream into the same fMP4 Segment stream the unifi-protect library's pool produces, feeding the standing timeshift buffer from RTSP
 * rather than the native livestream API. This is a pure-FFmpeg plugin concern, so it stays the plugin behind the seam, and it is the mechanical seed of a future
 * first-class RTSP-fed-buffer option.
 *
 * There is deliberately NO recovery loop here: a failed RTSP transcode simply ends. The lifecycle state is correspondingly simple - "connecting" before the init
 * segment resolves, "live" after, "closed" after disposal - and it never reports "recovering" (so a consumer's `isRestarting` is always false on this debug
 * path, consistent with there being no recovery here). The underlying process consumes its abort signal itself at the spawn level, so disposing the adapter (or
 * aborting the signal) tears the process down; the adapter adds no separate signal listener.
 */
export declare class RtspLivestreamSubscription implements LivestreamSubscription {
    #private;
    readonly id: string;
    constructor(options: RtspLivestreamSubscriptionOptions);
    get initSegment(): {
        codec: string;
        data: Buffer;
    } | null;
    get state(): LivestreamSubscriptionState;
    reassess(): void;
    whenEstablished(): Promise<boolean>;
    [Symbol.asyncIterator](): AsyncIterator<Segment>;
    [Symbol.asyncDispose](): Promise<void>;
}
/**
 * Shared classification and logging for errors thrown from a livestream subscription iterator. Used by every consumer so the handling lives in one place.
 * `consumer` is the subject of the log sentence (e.g. "Timeshift buffer", "Live streaming"). The `ProtectCodecChangeError` and `ProtectLivestreamUnavailableError`
 * typed iterator errors from the unifi-protect library carry a known meaning we phrase for the user rather than surfacing as an unexpected failure: a codec change
 * is a benign, self-correcting restart, and an exhausted recovery episode is the give-up the pool throws after repeated reconnect failures. Everything else is
 * genuinely unexpected and logged with the error for diagnosis.
 *
 * @param options.consumer - The subject of the log sentence.
 * @param options.error - The error thrown from the iterator.
 * @param options.log - The logger to write to.
 */
export declare function logLivestreamIterationError(options: {
    consumer: string;
    error: unknown;
    log: HomebridgePluginLogging;
}): void;
export {};
//# sourceMappingURL=livestream.d.ts.map