/**
 * Stream Handler for Voice Module
 *
 * Provides audio stream chunking, backpressure handling, and stream coordination.
 *
 * @module voice/stream-handler
 */
import { EventEmitter } from "events";
import type { AudioStreamChunk, StreamHandlerConfig } from "../types/index.js";
/**
 * Chunked Audio Stream Handler
 *
 * Handles audio stream chunking with backpressure management.
 *
 * @example
 * ```typescript
 * const handler = new ChunkedAudioStream({
 *   chunkDurationMs: 100,
 *   sampleRate: 16000,
 * });
 *
 * handler.on('chunk', (chunk) => {
 *   // Process audio chunk
 * });
 *
 * handler.write(audioData);
 * handler.end();
 * ```
 */
export declare class ChunkedAudioStream extends EventEmitter {
    private readonly config;
    private readonly chunkSize;
    private buffer;
    private chunkIndex;
    private timestampMs;
    private isPaused;
    private isEnded;
    private pendingData;
    private bufferTimeout;
    constructor(config?: StreamHandlerConfig);
    /**
     * Write audio data to the stream
     *
     * @param data - Audio data buffer
     * @returns True if more data can be written, false if backpressure
     */
    write(data: Buffer): boolean;
    /**
     * Process incoming data
     */
    private processData;
    /**
     * End the stream
     */
    end(): void;
    /**
     * Reset buffer timeout
     */
    private resetBufferTimeout;
    /**
     * Clear buffer timeout
     */
    private clearBufferTimeout;
    /**
     * Cleanup resources
     */
    private cleanup;
    /**
     * Get stream statistics
     */
    getStats(): {
        chunksEmitted: number;
        bufferedBytes: number;
        pendingChunks: number;
        totalDurationMs: number;
        isPaused: boolean;
        isEnded: boolean;
    };
}
/**
 * Stream merger for combining multiple audio streams
 */
export declare class StreamMerger extends EventEmitter {
    private readonly streams;
    private readonly config;
    constructor(config?: StreamHandlerConfig);
    /**
     * Add a stream to merge
     *
     * @param id - Stream identifier
     * @returns The created stream
     */
    addStream(id: string): ChunkedAudioStream;
    /**
     * Remove a stream
     *
     * @param id - Stream identifier
     */
    removeStream(id: string): void;
    /**
     * Write to a specific stream
     *
     * @param id - Stream identifier
     * @param data - Audio data
     */
    write(id: string, data: Buffer): boolean;
    /**
     * End all streams
     */
    endAll(): void;
    /**
     * Get number of active streams
     */
    get activeStreams(): number;
}
/**
 * Stream splitter for distributing audio to multiple consumers
 */
export declare class StreamSplitter extends EventEmitter {
    private readonly consumers;
    private readonly input;
    constructor(config?: StreamHandlerConfig);
    /**
     * Write audio data
     *
     * @param data - Audio data buffer
     */
    write(data: Buffer): boolean;
    /**
     * End the stream
     */
    end(): void;
    /**
     * Add a consumer
     *
     * @param id - Consumer identifier
     * @param handler - Chunk handler function
     */
    addConsumer(id: string, handler: (chunk: AudioStreamChunk) => void): void;
    /**
     * Remove a consumer
     *
     * @param id - Consumer identifier
     */
    removeConsumer(id: string): void;
    /**
     * Get number of consumers
     */
    get consumerCount(): number;
}
/**
 * Create an async iterable from a chunked audio stream
 *
 * @param stream - Chunked audio stream
 * @returns Async iterable of audio chunks
 */
export declare function streamToAsyncIterable(stream: ChunkedAudioStream): AsyncIterable<AudioStreamChunk>;
/**
 * Create a chunked audio stream from an async iterable
 *
 * @param iterable - Async iterable of audio buffers
 * @param config - Stream configuration
 * @returns Chunked audio stream
 */
export declare function asyncIterableToStream(iterable: AsyncIterable<Buffer>, config?: StreamHandlerConfig): Promise<ChunkedAudioStream>;
export { ChunkedAudioStream as StreamHandler };
