import { M as Ms, P as Project } from '../../types-BTUuytwo.js'; import { P as PlaybackEngine, a as PlaybackEngineOptions, b as PlaybackEngineFactory } from '../../types-B1786Fvo.js'; interface WebCodecsEngineOptions extends PlaybackEngineOptions { /** * Show a corner HUD ("engine: webcodecs • t=… • decoded N • queue M"). * Off by default — production hosts get a clean canvas. */ debug?: boolean; } /** * Frame-accurate single-track playback via WebCodecs `VideoDecoder`. * Mp4Demuxer feeds encoded samples; the decoder emits VideoFrames we * paint to a canvas on rAF. Seek snaps to the nearest keyframe at-or- * before the target and decodes forward (true frame-accurate, not the * browser's keyframe-snap). * * Scope of v1 (this PoC): * - Single video clip per source (boundaries handled, but no * transitions / compositing yet). * - MP4 / MOV containers via mp4box.js (H.264 / HEVC / VP9 / AV1 * codecs, whatever the browser's VideoDecoder supports). * - Audio not played. * * Follow-ups: multi-track compositing, audio, in/out trim cropping at * the decoder level, segment-prefetch across clip boundaries. */ declare class WebCodecsEngine implements PlaybackEngine { private host; private mount; private canvas; private ctx; private badge; private project; private currentClipId; private sources; private playing; private timeMs; private rafHandle; private lastFrameTs; private decodedFramesTotal; private destroyed; /** Output frame rect (fixed bounds, no transform) in CSS pixels. */ private lastOutputRect; /** Post-transform content rect in CSS pixels. */ private lastFrameRect; onTimeUpdate?: (ms: Ms) => void; onEnded?: () => void; onError?: (err: Error) => void; onReady?: () => void; onSourceMetadata?: (sourceId: string, durationMs: Ms) => void; constructor(opts: WebCodecsEngineOptions); setProject(next: Project): void; play(): void; pause(): void; isPlaying(): boolean; getTime(): Ms; seek(timeMs: Ms): void; destroy(): void; getOutputFrameRect(): { x: number; y: number; w: number; h: number; } | null; getFrameRect(): { x: number; y: number; w: number; h: number; } | null; private syncSources; private teardownSource; private onTrackReady; private onDecodedFrame; private activate; private seekActiveTo; private flushFrames; /** * Feed enough samples to keep the frame queue at FRAME_QUEUE_AHEAD. * Called every paint() cycle plus immediately after seek. */ private feedDecoder; private clipById; private clipAtTime; private nextClipAfterTime; private totalDuration; private resizeCanvas; private startTickLoop; private stopTickLoop; private advance; /** * Render the frame matching the current playhead, top up the decoder * queue, evict stale frames. Always runs (not just on play) so seek * previews the target frame and the HUD stays current when paused. */ private paint; private updateBadge; } /** Factory shorthand — defaults debug off. */ declare const webCodecsEngineFactory: PlaybackEngineFactory; /** * Feature detection — every API the engine needs must be present. * Used both by the engine constructor (hard gate) and by hosts that * want to conditionally render an engine selector. */ declare function isWebCodecsSupported(): boolean; interface DemuxedTrack { trackId: number; /** WebCodecs codec string, e.g. "avc1.42E01E" / "hvc1.1.6.L93.B0". */ codec: string; /** Raw bytes of the codec config box (avcC / hvcC / vpcC / av1C) * — feed straight to `decoder.configure({ description })`. */ description: Uint8Array; width: number; height: number; /** Track timescale (ticks per second in cts/dts). */ timescale: number; /** Track duration in ms. */ durationMs: Ms; } export { type DemuxedTrack, WebCodecsEngine, type WebCodecsEngineOptions, isWebCodecsSupported, webCodecsEngineFactory };