Source code

Revision control

Copy as Markdown

Other Tools

/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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
* The origin of this IDL file is
* Some members of this API are codec-specific, in which case the source of the
* IDL are in the codec-specific registry entries, that are listed in
* commented with a link of the document in which the member is listed.
dictionary AudioEncoderSupport {
boolean supported;
AudioEncoderConfig config;
dictionary AudioEncoderConfig {
required DOMString codec;
[EnforceRange] unsigned long sampleRate;
[EnforceRange] unsigned long numberOfChannels;
[EnforceRange] unsigned long long bitrate;
BitrateMode bitrateMode = "variable";
OpusEncoderConfig opus;
// Opus specific configuration options:
enum OpusBitstreamFormat {
dictionary OpusEncoderConfig {
OpusBitstreamFormat format = "opus";
[EnforceRange] unsigned long long frameDuration = 20000;
[EnforceRange] unsigned long complexity;
[EnforceRange] unsigned long packetlossperc = 0;
boolean useinbandfec = false;
boolean usedtx = false;
[Exposed=(Window,DedicatedWorker), SecureContext, Pref=""]
interface AudioEncoder : EventTarget {
constructor(AudioEncoderInit init);
readonly attribute CodecState state;
readonly attribute unsigned long encodeQueueSize;
attribute EventHandler ondequeue;
undefined configure(AudioEncoderConfig config);
[Throws, BinaryName="AudioEncoder::EncodeAudioData"]
undefined encode(AudioData data);
Promise<undefined> flush();
undefined reset();
undefined close();
[NewObject, Throws]
static Promise<AudioEncoderSupport> isConfigSupported(AudioEncoderConfig config);
dictionary AudioEncoderInit {
required EncodedAudioChunkOutputCallback output;
required WebCodecsErrorCallback error;
callback EncodedAudioChunkOutputCallback =
undefined (EncodedAudioChunk output,
optional EncodedAudioChunkMetadata metadata = {});
dictionary EncodedAudioChunkMetadata {
AudioDecoderConfig decoderConfig;