import type { VideoFrameMessage } from './protocol'; import { ILogger } from './logger'; /** * Interface defining the basic decoder operations */ export interface IDecoder { /** Indicates if the decoder is ready to process frames */ ready: boolean; /** Indicates if the decoder is currently paused */ paused: boolean; /** Stops the decoder operations */ stop(): void; /** Starts the decoder operations */ start(): void; } interface VideoDecoderConfig { codec: string; codedHeight?: number; codedWidth?: number; colorSpace?: VideoColorSpaceInit; description?: ArrayBuffer | ArrayBufferView; displayAspectHeight?: number; displayAspectWidth?: number; hardwareAcceleration?: "no-preference" | "prefer-hardware" | "prefer-software"; optimizeForLatency?: boolean; } /** * Configuration for the video decoder. */ export declare const videoDecoderConfig: VideoDecoderConfig; /** * Decoder class responsible for decoding video frames and rendering them using WebGL. * Handles frame queueing, decoding, and rendering through WebGL. */ export declare class Decoder implements IDecoder { private _decoder; private readonly _canvas; private readonly _renderer; private readonly _logger; private _firstDecoded; private _skipUntil; private _queue; private _pendingFrame; private _renderId; private _decodeId; /** * Indicates whether the decoder is ready and configured. * @returns {boolean} True if the decoder is configured, false otherwise. */ get ready(): boolean; /** * Creates an instance of the Decoder class. * @param originalCanvas - The original HTML canvas element to render frames onto * @param logger - Logger instance for debugging and error reporting * @throws {Error} When video decoder configuration is not supported */ constructor(originalCanvas: HTMLCanvasElement, logger: ILogger); /** * Indicates whether the decoder is currently paused. * @returns {boolean} True if paused, false otherwise. */ get paused(): boolean; /** * Pauses the decoder and renderer. */ stop(): void; /** * Resumes the decoder and renderer. */ start(): void; /** * Clears decoding and rendering callbacks. */ private _clearCallbacks; /** * Enqueues a video frame message for decoding. * If a key frame is received, the queue is cleared except for the first frame * to maintain decoder stability. * @param frame - The video frame message to be queued for decoding */ enqueue(frame: VideoFrameMessage): void; /** * Processes and decodes all queued video frame messages. * Skips processing if the decoder isn't ready or the queue is empty. * @throws {Error} When decoding fails for a video chunk */ decode(): void; /** * Clears the decoder state and renderer buffer. * Does not close the decoder instance. */ clear(): void; /** * Completely disposes of the decoder instance and releases all resources. * Should be called when the decoder is no longer needed. */ dispose(): void; /** * Cleans up internal resources and cancels ongoing operations. * @private */ private _cleanUp; /** * Creates an EncodedVideoChunk from a VideoFrameMessage. * @param message - The video frame message to convert * @returns {EncodedVideoChunk} A chunk ready for decoder processing * @private */ private createChunk; /** * Handles the animation loop for continuous frame rendering. * Processes pending frames and manages the render timing. * @private */ private animate; /** * Processes a decoded video frame for rendering. * Manages frame replacement and cleanup of previous frames. * @param frame - The decoded video frame ready for rendering * @private */ private renderFrame; } export {};