libpag
Version:
Portable Animated Graphics
61 lines (60 loc) • 2.65 kB
TypeScript
import type { VideoReader } from "./interfaces";
/**
* VideoReaderManager is responsible for managing multiple VideoReader instances.
* It handles video decoder initialization, frame preparation, and lifecycle management.
*/
export declare class VideoReaderManager {
/**
* Checks whether the given PAG composition contains any video content.
* @param wasmIns - The WebAssembly instance to check
* @returns True if the composition contains video, false otherwise
*/
static HasVideo(wasmIns: any): boolean;
/**
* Factory method to create and initialize a VideoReaderManager instance.
* @param wasmIns - The WebAssembly instance containing video information
* @returns A promise that resolves to a fully initialized VideoReaderManager instance
*/
static make(wasmIns: any): Promise<VideoReaderManager>;
/** WebAssembly instance for video information management */
wasmIns: any;
/** Array of video IDs managed by this instance */
videoIDs: Array<number>;
/** Flag indicating whether this instance has been destroyed */
isDestroyed: boolean;
/** Map storing VideoReader instances indexed by video ID */
private videoReaderMap;
/**
* Constructor for VideoReaderManager.
* Initializes the WASM instance and retrieves all video IDs.
* @param wasmIns - The WebAssembly instance
* @throws Error if VideoReaderManager creation fails
*/
constructor(wasmIns: any);
/**
* Creates VideoReader instances for all videos in the PAG file.
* For each video ID, retrieves MP4 data and initializes the corresponding VideoReader.
* Also prepares the first frame with the initial playback rate.
*/
createVideoReader(): Promise<void>;
/**
* Retrieves a VideoReader instance by video ID.
* Marks the video as using hardware decoding (software decode disabled).
* @param id - The video ID
* @returns The VideoReader instance or undefined if not found
* @throws Error if VideoReader is not found for the given ID
*/
getVideoReaderByID(id: number): VideoReader | undefined;
/**
* Prepares target frames for all videos based on current playback position.
* This method is called during rendering to ensure the correct frames are decoded.
* It handles both hardware and software decoding modes.
*/
prepareTargetFrame(): Promise<void>;
/**
* Destroys the VideoReaderManager instance and cleans up all resources.
* This includes destroying the WASM instance, all VideoReader instances,
* and clearing internal maps.
*/
destroy(): void;
}