/** * GaussianCodecRegistry - Central registry for Gaussian splat codecs * * Manages codec lifecycle, format detection, and codec selection. Provides * a single entry point for the rendering pipeline to discover and use codecs * without coupling to any specific implementation. * * Features: * - Auto-detection of file format from buffer magic bytes or URL extension * - Priority-based codec selection when multiple codecs support a format * - Lazy initialization of codecs on first use * - Global singleton pattern for application-wide codec access * * Usage: * ```typescript * // Get the global registry (auto-populated with built-in codecs) * const registry = getGlobalCodecRegistry(); * * // Decode a file by URL * const result = await registry.decode('scene.spz'); * * // Or manually select a codec * const spz = registry.getCodec('khr.spz.v2'); * const result = await spz.decode(buffer); * * // Register a custom codec * registry.register(new MyCustomCodec()); * ``` * * Architecture decision (W.038): * The registry decouples the rendering pipeline from specific codec implementations, * enabling seamless transition from KHR/SPZ to MPEG GSC when the standard ships. * * @module gpu/codecs * @version 1.0.0 */ import type { IGaussianCodec } from './IGaussianCodec.js'; import type { GaussianCodecId, GaussianCodecCapabilities, GaussianSplatData, GaussianDecodeOptions, CodecResult } from './types.js'; /** * Options for codec auto-detection. */ export interface CodecDetectOptions { /** URL of the file (used for extension-based detection) */ url?: string; /** First bytes of the file (used for magic byte detection) */ headerBytes?: ArrayBuffer; /** Explicit codec ID to use (bypasses detection) */ codecId?: GaussianCodecId; /** Only consider codecs with these maturity levels */ maturityFilter?: Array<'production' | 'beta' | 'experimental' | 'stub'>; } /** * Information about a registered codec. */ export interface RegisteredCodec { /** The codec instance */ codec: IGaussianCodec; /** Codec capabilities */ capabilities: GaussianCodecCapabilities; /** Registration priority (higher = preferred) */ priority: number; /** Whether the codec has been initialized */ initialized: boolean; } export declare class GaussianCodecRegistry { private codecs; /** * Register a codec with the registry. * * @param codec - Codec instance to register * @param priority - Priority for codec selection (default: 0, higher = preferred) * @returns The registry instance (for chaining) */ register(codec: IGaussianCodec, priority?: number): this; /** * Unregister a codec by ID. * * @param codecId - ID of the codec to unregister * @returns true if the codec was found and removed */ unregister(codecId: GaussianCodecId): boolean; /** * Get a specific codec by ID. * * @param codecId - Codec identifier * @returns The codec instance, or undefined if not registered */ getCodec(codecId: GaussianCodecId): IGaussianCodec | undefined; /** * Get a specific codec by ID, throwing if not found. * * @param codecId - Codec identifier * @returns The codec instance * @throws Error if the codec is not registered */ requireCodec(codecId: GaussianCodecId): IGaussianCodec; /** * Get all registered codec IDs. */ getRegisteredIds(): GaussianCodecId[]; /** * Get capabilities of all registered codecs. */ getAllCapabilities(): GaussianCodecCapabilities[]; /** * Check if a specific codec is registered. */ hasCodec(codecId: GaussianCodecId): boolean; /** * Auto-detect the best codec for a given file. * * Detection priority: * 1. Explicit codecId in options (bypass detection) * 2. Magic byte detection from headerBytes * 3. File extension detection from URL * 4. Priority-based fallback among matching codecs * * @param options - Detection options (URL, header bytes, etc.) * @returns Best-matching codec, or undefined if no codec can handle the file */ detectCodec(options: CodecDetectOptions): IGaussianCodec | undefined; /** * Auto-detect and decode a buffer. * * Convenience method that combines detection and decode in one call. * * @param buffer - Raw binary data * @param options - Decode options + detection options * @returns Decoded Gaussian data * @throws Error if no codec can handle the data */ decode(buffer: ArrayBuffer, options?: GaussianDecodeOptions & CodecDetectOptions): Promise>; /** * Auto-detect codec from URL and decode via streaming. * * @param url - URL to fetch and decode * @param options - Decode and detection options * @returns Decoded Gaussian data */ decodeFromUrl(url: string, options?: GaussianDecodeOptions & CodecDetectOptions): Promise>; /** * Initialize all registered codecs. * * Useful for pre-warming at application startup. */ initializeAll(): Promise; /** * Dispose all registered codecs and clear the registry. */ disposeAll(): void; private ensureInitialized; private extractExtension; private matchesMaturity; } /** * Create a registry pre-populated with all built-in codecs. * * Built-in codecs: * - SpzCodec (khr.spz.v2): Production, priority 100 * - GltfGaussianSplatCodec (khr.gltf.gaussian): Beta, priority 50 * - MpegGscCodec (mpeg.gsc.v1): Stub, priority 0 */ export declare function createDefaultCodecRegistry(): GaussianCodecRegistry; /** * Get or create the global codec registry. * * The global registry is pre-populated with all built-in codecs. * Additional codecs can be registered at any time. * * @example * ```typescript * const registry = getGlobalCodecRegistry(); * * // Decode an SPZ file * const result = await registry.decode(spzBuffer); * * // Register a custom codec * registry.register(new MyCustomCodec(), 50); * ``` */ export declare function getGlobalCodecRegistry(): GaussianCodecRegistry; /** * Reset the global codec registry. * * Disposes all codecs and creates a fresh registry with built-in codecs. * Useful for testing or when reinitializing the application. */ export declare function resetGlobalCodecRegistry(): void; //# sourceMappingURL=GaussianCodecRegistry.d.ts.map