/** * @blockcast/fec-worker — Main-Thread Client * * Wraps one Worker per track instance. Provides typed API for the * FecWorkerCommand/FecWorkerEvent protocol with zero-copy ArrayBuffer transfers. * * Constructor accepts either a URL (creates Worker internally) or a pre-created * Worker instance (for testing via constructor injection). */ import type { FecTrackConfig, FecTrackStats, FecBlockSnapshot, FrameMeta, FecWorkerErrorCode } from "./fec-worker-types.js"; export declare class FecWorkerClient { #private; /** * Create a FecWorkerClient. * @param workerOrUrl - Either a Worker instance (for testing) or a URL to create one */ constructor(workerOrUrl: Worker | URL); /** * Configure the Worker with FEC parameters and WASM module. * `interleaveMs: 0` is a valid no-span catalog value; in that mode the * caller supplies a positive receiver-local `deliveryWindowMs`. * wasmModule is transferred (not neutered — WebAssembly.Module is shareable). */ configure(config: FecTrackConfig, wasmModule: WebAssembly.Module): void; /** * Feed a source symbol to the Worker. data ArrayBuffer is transferred (zero-copy). * Caller must not access data after this call — it is transferred with the * task's symbol batch, before any later command of this client. */ feedSource(ssId: number, data: ArrayBuffer, ts: number): void; /** * Feed a repair symbol to the Worker. data ArrayBuffer is transferred (zero-copy). * Caller must not access data after this call — it is detached. * * Carries the wire-level Repair FEC Payload ID fields (ISO 23008-1 §C.5.3): * - ssStart: SS_ID of first source symbol in the block (any uint32; the block key) * - ssbLength: authored source-symbol count (1..configured K) * - rsId: repair symbol index within the block */ feedRepair(ssStart: number, ssbLength: number, rsId: number, data: ArrayBuffer, ts: number): void; /** * Submit relay block signature for verification. sig and hash are transferred. */ relayBlockSig(sbn: number, sig: ArrayBuffer, hash: ArrayBuffer): void; /** * Trigger cleanup after a block's inactivity deadline. `currentSbn` is the * block key, the block's SS_Start. * * While one queue-drain barrier is in flight, later SBNs are coalesced into * the next command without losing their individual acknowledgement identity. */ cleanup(currentSbn: number): void; /** Reset this track's decoder epoch while preserving Worker configuration. */ reset(): void; /** Register callback for decoded/recovered frames (FEC-03). */ onFrame(cb: (data: ArrayBuffer, meta: FrameMeta) => void): void; /** Register callback for periodic stats snapshots (FEC-04). */ onSnapshot(cb: (stats: FecTrackStats) => void): void; /** * Register callback for individual block state changes. The Worker posts * them only once asked, so registering subscribes (after the Worker * announces `subscribeBlockUpdates`). An older Worker that does not * announce it posts them unasked. */ onBlockUpdate(cb: (block: FecBlockSnapshot) => void): void; /** Register callback fired after the Worker drains all commands queued before cleanup. */ onCleanupComplete(cb: (sbn: number) => void): void; /** Register callback for Worker errors. */ onError(cb: (message: string, code?: FecWorkerErrorCode) => void): void; /** * True once dispose() ran. A disposed client cannot decode, fill, or * acknowledge anything, so routing symbols to it discards them; every * command method (feedSource, feedRepair, relayBlockSig, cleanup, reset) * throws rather than pretend otherwise. Callers check this first. */ get disposed(): boolean; /** * Dispose the Worker. Sends dispose command then terminates. * Idempotent — safe to call multiple times. */ dispose(): void; } //# sourceMappingURL=fec-worker-client.d.ts.map