import { AudioRendition, VideoRendition } from '../../../transcoding/types';
/**
 * State interface for media buffering - generic for both audio and video
 */
export interface MediaBufferState {
    currentSeekTimeMs: number;
    activeRequests: Set<number>;
    cachedSegments: Set<number>;
    requestQueue: number[];
}
/**
 * Configuration interface for media buffering - generic for both audio and video
 */
export interface MediaBufferConfig {
    bufferDurationMs: number;
    maxParallelFetches: number;
    enableBuffering: boolean;
    enableContinuousBuffering?: boolean;
}
/**
 * Dependencies interface for media buffering - generic for both audio and video
 */
export interface MediaBufferDependencies<T extends AudioRendition | VideoRendition> {
    computeSegmentId: (timeMs: number, rendition: T) => Promise<number | undefined>;
    fetchSegment: (segmentId: number, rendition: T) => Promise<ArrayBuffer>;
    getRendition: () => Promise<T>;
    logError: (message: string, error: any) => void;
}
/**
 * Compute segment range for a time window
 * Pure function - determines which segments are needed for a time range
 */
export declare const computeSegmentRange: <T extends AudioRendition | VideoRendition>(startTimeMs: number, endTimeMs: number, rendition: T, computeSegmentId: (timeMs: number, rendition: T) => number | undefined) => number[];
/**
 * Async version of computeSegmentRange for when computeSegmentId is async
 */
export declare const computeSegmentRangeAsync: <T extends AudioRendition | VideoRendition>(startTimeMs: number, endTimeMs: number, durationMs: number, rendition: T, computeSegmentId: (timeMs: number, rendition: T) => Promise<number | undefined>) => Promise<number[]>;
/**
 * Compute buffer queue based on current state and desired segments
 * Pure function - determines what segments should be fetched
 */
export declare const computeBufferQueue: (desiredSegments: number[], activeRequests: Set<number>, cachedSegments: Set<number>) => number[];
/**
 * Handle seek time change and recompute buffer queue
 * Pure function - computes new queue when seek time changes
 */
export declare const handleSeekTimeChange: <T extends AudioRendition | VideoRendition>(newSeekTimeMs: number, bufferDurationMs: number, rendition: T, currentState: MediaBufferState, computeSegmentId: (timeMs: number, rendition: T) => number | undefined) => {
    newQueue: number[];
    overlappingRequests: number[];
};
/**
 * Check if a specific segment is cached in the buffer
 * Pure function for accessing buffer cache state
 */
export declare const getCachedSegment: (segmentId: number, bufferState: MediaBufferState | undefined) => boolean;
/**
 * Get cached segments from a list of segment IDs
 * Pure function that returns which segments are available in cache
 */
export declare const getCachedSegments: (segmentIds: number[], bufferState: MediaBufferState | undefined) => Set<number>;
/**
 * Get missing segments from a list of segment IDs
 * Pure function that returns which segments need to be fetched
 */
export declare const getMissingSegments: (segmentIds: number[], bufferState: MediaBufferState | undefined) => number[];
/**
 * Core media buffering logic with explicit dependencies
 * Generic implementation that works for both audio and video
 */
export declare const manageMediaBuffer: <T extends AudioRendition | VideoRendition>(seekTimeMs: number, config: MediaBufferConfig, currentState: MediaBufferState, durationMs: number, signal: AbortSignal, deps: MediaBufferDependencies<T>) => Promise<MediaBufferState>;
