//#region src/preview/QualityUpgradeScheduler.d.ts /** * QualityUpgradeScheduler: Centralized deadline-ordered work queue * * Coordinates main-quality segment fetching across multiple video elements. * Generic scheduler that doesn't understand media concepts (segments, renditions, etc.) * - only processes { key, deadlineMs, fetch, isCached, owner } tuples. * * Design principles: * - Deadline-based ordering: always process nearest deadline first * - Ground-truth cache validation: check cache before starting any fetch * - In-flight fetches never cancelled: they populate shared cache * - Event-driven: elements submit tasks only on state changes, not every frame */ interface UpgradeTask { /** Opaque dedup key (e.g. "${owner}:${segmentId}:${renditionId}") */ key: string; /** Fetch function that populates the cache */ fetch: (signal: AbortSignal) => Promise; /** Returns true if the segment is still present in the cache. Used to skip * re-queuing completed tasks whose segment is still cached, and to allow * re-queuing when the segment has been LRU-evicted. If absent, a completed * task is conservatively treated as still cached (skip re-queue). */ isCached?: () => boolean; /** Timeline time when this segment will be needed */ deadlineMs: number; /** Element ID, for bulk operations */ owner: string; } interface UpgradeTaskStatus { key: string; owner: string; deadlineMs: number; status: "queued" | "active" | "completed" | "failed"; error?: string; } interface OwnerProgress { queued: number; active: number; completed: number; failed: number; } declare class QualityUpgradeScheduler { #private; constructor(options: { requestFrameRender: () => void; maxConcurrent?: number; }); /** * Add tasks without affecting existing ones (additive). * Used for lookahead extension during playback. */ enqueue(tasks: UpgradeTask[]): void; /** * Replace all queued tasks for an owner. * Used on seeks, trim changes, timeline position changes where old deadlines are stale. * Does NOT cancel in-flight tasks (they populate shared cache). */ replaceForOwner(owner: string, tasks: UpgradeTask[]): void; /** * Cancel all tasks for an owner. * Removes queued tasks. Does NOT abort in-flight fetches. */ cancelForOwner(owner: string): void; /** * Check whether a task is currently in-flight (started, not yet complete). */ isActive(key: string): boolean; /** * Check whether a task is waiting in the queue (submitted but not yet started). */ isPending(key: string): boolean; /** * Get snapshot of current queue state for debugging. */ getQueueSnapshot(): UpgradeTaskStatus[]; /** * Get progress for a specific owner. */ getOwnerProgress(owner: string): OwnerProgress; /** * Dispose the scheduler - abort all in-flight work. */ dispose(): void; /** * Revive a disposed scheduler so it can accept new tasks after the host * element is reconnected to the DOM (e.g. workbench reparenting). */ revive(): void; } //#endregion export { QualityUpgradeScheduler }; //# sourceMappingURL=QualityUpgradeScheduler.d.ts.map