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/.
6 * The origin of this IDL file is
7 * https://w3c.github.io/webcodecs/#audiodata
10 // [Serializable, Transferable] are implemented without adding attributes here,
11 // but directly with {Read,Write}StructuredClone and Transfer/FromTransfered.
12 [Exposed=(Window,DedicatedWorker), Pref="dom.media.webcodecs.enabled"]
15 constructor(AudioDataInit init);
17 readonly attribute AudioSampleFormat? format;
18 readonly attribute float sampleRate;
19 readonly attribute unsigned long numberOfFrames;
20 readonly attribute unsigned long numberOfChannels;
21 readonly attribute unsigned long long duration; // microseconds
22 readonly attribute long long timestamp; // microseconds
25 unsigned long allocationSize(AudioDataCopyToOptions options);
28 // bug 1696216: Should be `copyTo(AllowSharedBufferSource destination, ...)`
29 ([AllowShared] ArrayBufferView or [AllowShared] ArrayBuffer) destination,
30 AudioDataCopyToOptions options);
36 dictionary AudioDataInit {
37 required AudioSampleFormat format;
38 required float sampleRate;
39 required [EnforceRange] unsigned long numberOfFrames;
40 required [EnforceRange] unsigned long numberOfChannels;
41 required [EnforceRange] long long timestamp; // microseconds
42 // bug 1696216: Should be AllowSharedBufferSource
43 required ([AllowShared] ArrayBufferView or [AllowShared] ArrayBuffer) data;
44 sequence<ArrayBuffer> transfer = [];
47 enum AudioSampleFormat {
58 dictionary AudioDataCopyToOptions {
59 required [EnforceRange] unsigned long planeIndex;
60 [EnforceRange] unsigned long frameOffset = 0;
61 [EnforceRange] unsigned long frameCount;
62 AudioSampleFormat format;