/*! * Copyright (c) 2025-present, Vanilagy and contributors * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import { AVCodecID } from 'node-av'; /** * Encodes audio frames into encoded chunks. * * Corresponds to the WebCodecs AudioEncoder API. */ export declare class AudioEncoderPolyfill extends EventTarget { private init; private config; private codecContext; private mutex; private frame; private packet; private _encodeQueueSize; private currentConfigId; private chunkOutputted; private chunkTimestampOffset; private pendingFlushResolvers; private resampler; private lastResamplerKey; private dstFrame; private nextPts; private aacAudioSpecificConfig; private resampledSampleCount; private _state; /** * The current state of the encoder: "unconfigured", "configured", or "closed". */ get state(): CodecState; /** * The number of pending encode operations. */ get encodeQueueSize(): number; /** * Event handler called when an encode operation completes and leaves the queue. */ ondequeue: ((this: AudioEncoder, ev: Event) => unknown) | null; /** * Creates a new AudioEncoder. */ constructor(init: AudioEncoderInit); private static createCodecContext; /** * Checks if the encoder can support the given configuration. */ static isConfigSupported(config: AudioEncoderConfig): Promise; /** * Configures the encoder with the given configuration. */ configure(config: AudioEncoderConfig): void; private configureInternal; /** * Queues audio data to be encoded. */ encode(data: AudioData): void; private outputChunk; private decrementQueue; private encodeInternal; private getBytesPerSample; private formatIsPlanar; private createOutputBuffers; private createInputSilenceBuffers; private sendFrameAndReceivePackets; private pullResampledFrames; /** * Flushes all pending encode operations and waits for completion. */ flush(): Promise; private flushInternal; /** * Closes the encoder and releases all resources. */ close(): void; /** * Resets the encoder to an unconfigured state. */ reset(): void; private handleAsyncError; } export declare const getDecentAudioBitrate: (codec: AVCodecID) => number;