Backed out changeset 06f41c22f3a6 (bug 1888460) for causing linux xpcshell failures...
[gecko.git] / dom / webidl / AudioEncoder.webidl
blobe3800c83f1c177fa05d12b8ab78f470cc6f73e82
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4  * You can obtain one at http://mozilla.org/MPL/2.0/.
5  *
6  * The origin of this IDL file is
7  * https://w3c.github.io/webcodecs/#audioencoder
9  * Some members of this API are codec-specific, in which case the source of the
10  * IDL are in the codec-specific registry entries, that are listed in
11  * https://w3c.github.io/webcodecs/codec_registry.html. Those members are
12  * commented with a link of the document in which the member is listed.
13  */
15 dictionary AudioEncoderSupport {
16   boolean supported;
17   AudioEncoderConfig config;
20 dictionary AudioEncoderConfig {
21   required DOMString codec;
22   [EnforceRange] unsigned long sampleRate;
23   [EnforceRange] unsigned long numberOfChannels;
24   [EnforceRange] unsigned long long bitrate;
25   BitrateMode bitrateMode = "variable";
26   OpusEncoderConfig opus;
29 // Opus specific configuration options:
30 // https://w3c.github.io/webcodecs/opus_codec_registration.html
31 enum OpusBitstreamFormat {
32   "opus",
33   "ogg",
36 dictionary OpusEncoderConfig {
37   OpusBitstreamFormat format = "opus";
38   [EnforceRange] unsigned long long frameDuration = 20000;
39   [EnforceRange] unsigned long complexity;
40   [EnforceRange] unsigned long packetlossperc = 0;
41   boolean useinbandfec = false;
42   boolean usedtx = false;
45 [Exposed=(Window,DedicatedWorker), SecureContext, Pref="dom.media.webcodecs.enabled"]
46 interface AudioEncoder : EventTarget {
47   [Throws]
48   constructor(AudioEncoderInit init);
50   readonly attribute CodecState state;
51   readonly attribute unsigned long encodeQueueSize;
52   attribute EventHandler ondequeue;
54   [Throws]
55   undefined configure(AudioEncoderConfig config);
56   [Throws, BinaryName="AudioEncoder::EncodeAudioData"]
57   undefined encode(AudioData data);
58   [Throws]
59   Promise<undefined> flush();
60   [Throws]
61   undefined reset();
62   [Throws]
63   undefined close();
65   [NewObject, Throws]
66   static Promise<AudioEncoderSupport> isConfigSupported(AudioEncoderConfig config);
69 dictionary AudioEncoderInit {
70   required EncodedAudioChunkOutputCallback output;
71   required WebCodecsErrorCallback error;
74 callback EncodedAudioChunkOutputCallback =
75     undefined (EncodedAudioChunk output,
76                optional EncodedAudioChunkMetadata metadata = {});
78 dictionary EncodedAudioChunkMetadata {
79   AudioDecoderConfig decoderConfig;