tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

AudioEncoder.webidl (2494B)


      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
      8 
      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 */
     14 
     15 dictionary AudioEncoderSupport {
     16  boolean supported;
     17  AudioEncoderConfig config;
     18 };
     19 
     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;
     27 };
     28 
     29 // Opus specific configuration options:
     30 // https://w3c.github.io/webcodecs/opus_codec_registration.html
     31 enum OpusBitstreamFormat {
     32  "opus",
     33  "ogg",
     34 };
     35 
     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;
     43 };
     44 
     45 [Exposed=(Window,DedicatedWorker), SecureContext, Func="nsRFPService::ExposeWebCodecsAPI"]
     46 interface AudioEncoder : EventTarget {
     47  [Throws]
     48  constructor(AudioEncoderInit init);
     49 
     50  readonly attribute CodecState state;
     51  readonly attribute unsigned long encodeQueueSize;
     52  attribute EventHandler ondequeue;
     53 
     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();
     64 
     65  [NewObject, Throws]
     66  static Promise<AudioEncoderSupport> isConfigSupported(AudioEncoderConfig config);
     67 };
     68 
     69 dictionary AudioEncoderInit {
     70  required EncodedAudioChunkOutputCallback output;
     71  required WebCodecsErrorCallback error;
     72 };
     73 
     74 callback EncodedAudioChunkOutputCallback =
     75    undefined (EncodedAudioChunk output,
     76               optional EncodedAudioChunkMetadata metadata = {});
     77 
     78 dictionary EncodedAudioChunkMetadata {
     79  AudioDecoderConfig decoderConfig;
     80 };