blob: 64829752f2c46cc631a096c25272a49b31edaedf [file] [log] [blame]
Victor Porof6e096922022-06-10 13:01:05 +00001// GENERATED CONTENT - DO NOT EDIT
2// Content was automatically extracted by Reffy into webref
3// (https://github.com/w3c/webref)
4// Source: WebCodecs (https://w3c.github.io/webcodecs/)
5
6[Exposed=(Window,DedicatedWorker), SecureContext]
7interface AudioDecoder {
8 constructor(AudioDecoderInit init);
9
10 readonly attribute CodecState state;
11 readonly attribute unsigned long decodeQueueSize;
12
13 undefined configure(AudioDecoderConfig config);
14 undefined decode(EncodedAudioChunk chunk);
15 Promise<undefined> flush();
16 undefined reset();
17 undefined close();
18
19 static Promise<AudioDecoderSupport> isConfigSupported(AudioDecoderConfig config);
20};
21
22dictionary AudioDecoderInit {
23 required AudioDataOutputCallback output;
24 required WebCodecsErrorCallback error;
25};
26
27callback AudioDataOutputCallback = undefined(AudioData output);
28
29[Exposed=(Window,DedicatedWorker), SecureContext]
30interface VideoDecoder {
31 constructor(VideoDecoderInit init);
32
33 readonly attribute CodecState state;
34 readonly attribute unsigned long decodeQueueSize;
35
36 undefined configure(VideoDecoderConfig config);
37 undefined decode(EncodedVideoChunk chunk);
38 Promise<undefined> flush();
39 undefined reset();
40 undefined close();
41
42 static Promise<VideoDecoderSupport> isConfigSupported(VideoDecoderConfig config);
43};
44
45dictionary VideoDecoderInit {
46 required VideoFrameOutputCallback output;
47 required WebCodecsErrorCallback error;
48};
49
50callback VideoFrameOutputCallback = undefined(VideoFrame output);
51
52[Exposed=(Window,DedicatedWorker), SecureContext]
53interface AudioEncoder {
54 constructor(AudioEncoderInit init);
55
56 readonly attribute CodecState state;
57 readonly attribute unsigned long encodeQueueSize;
58
59 undefined configure(AudioEncoderConfig config);
60 undefined encode(AudioData data);
61 Promise<undefined> flush();
62 undefined reset();
63 undefined close();
64
65 static Promise<AudioEncoderSupport> isConfigSupported(AudioEncoderConfig config);
66};
67
68dictionary AudioEncoderInit {
69 required EncodedAudioChunkOutputCallback output;
70 required WebCodecsErrorCallback error;
71};
72
73callback EncodedAudioChunkOutputCallback =
74 undefined (EncodedAudioChunk output,
75 optional EncodedAudioChunkMetadata metadata = {});
76
77dictionary EncodedAudioChunkMetadata {
78 AudioDecoderConfig decoderConfig;
79};
80
81[Exposed=(Window,DedicatedWorker), SecureContext]
82interface VideoEncoder {
83 constructor(VideoEncoderInit init);
84
85 readonly attribute CodecState state;
86 readonly attribute unsigned long encodeQueueSize;
87
88 undefined configure(VideoEncoderConfig config);
89 undefined encode(VideoFrame frame, optional VideoEncoderEncodeOptions options = {});
90 Promise<undefined> flush();
91 undefined reset();
92 undefined close();
93
94 static Promise<VideoEncoderSupport> isConfigSupported(VideoEncoderConfig config);
95};
96
97dictionary VideoEncoderInit {
98 required EncodedVideoChunkOutputCallback output;
99 required WebCodecsErrorCallback error;
100};
101
102callback EncodedVideoChunkOutputCallback =
103 undefined (EncodedVideoChunk chunk,
104 optional EncodedVideoChunkMetadata metadata = {});
105
106dictionary EncodedVideoChunkMetadata {
107 VideoDecoderConfig decoderConfig;
108 SvcOutputMetadata svc;
109 BufferSource alphaSideData;
110};
111
112dictionary SvcOutputMetadata {
113 unsigned long temporalLayerId;
114};
115
116dictionary AudioDecoderSupport {
117 boolean supported;
118 AudioDecoderConfig config;
119};
120
121dictionary VideoDecoderSupport {
122 boolean supported;
123 VideoDecoderConfig config;
124};
125
126dictionary AudioEncoderSupport {
127 boolean supported;
128 AudioEncoderConfig config;
129};
130
131dictionary VideoEncoderSupport {
132 boolean supported;
133 VideoEncoderConfig config;
134};
135
136dictionary AudioDecoderConfig {
137 required DOMString codec;
138 [EnforceRange] required unsigned long sampleRate;
139 [EnforceRange] required unsigned long numberOfChannels;
140 BufferSource description;
141};
142
143dictionary VideoDecoderConfig {
144 required DOMString codec;
145 BufferSource description;
146 [EnforceRange] unsigned long codedWidth;
147 [EnforceRange] unsigned long codedHeight;
148 [EnforceRange] unsigned long displayAspectWidth;
149 [EnforceRange] unsigned long displayAspectHeight;
150 VideoColorSpaceInit colorSpace;
151 HardwareAcceleration hardwareAcceleration = "no-preference";
152 boolean optimizeForLatency;
153};
154
155dictionary AudioEncoderConfig {
156 required DOMString codec;
157 [EnforceRange] unsigned long sampleRate;
158 [EnforceRange] unsigned long numberOfChannels;
159 [EnforceRange] unsigned long long bitrate;
160};
161
162dictionary VideoEncoderConfig {
163 required DOMString codec;
164 [EnforceRange] required unsigned long width;
165 [EnforceRange] required unsigned long height;
166 [EnforceRange] unsigned long displayWidth;
167 [EnforceRange] unsigned long displayHeight;
168 [EnforceRange] unsigned long long bitrate;
169 [EnforceRange] double framerate;
170 HardwareAcceleration hardwareAcceleration = "no-preference";
171 AlphaOption alpha = "discard";
172 DOMString scalabilityMode;
173 BitrateMode bitrateMode = "variable";
174 LatencyMode latencyMode = "quality";
175};
176
177enum HardwareAcceleration {
178 "no-preference",
179 "prefer-hardware",
180 "prefer-software",
181};
182
183enum AlphaOption {
184 "keep",
185 "discard",
186};
187
188enum LatencyMode {
189 "quality",
190 "realtime"
191};
192
193dictionary VideoEncoderEncodeOptions {
194 boolean keyFrame = false;
195};
196
197enum CodecState {
198 "unconfigured",
199 "configured",
200 "closed"
201};
202
203callback WebCodecsErrorCallback = undefined(DOMException error);
204
205[Exposed=(Window,DedicatedWorker)]
206interface EncodedAudioChunk {
207 constructor(EncodedAudioChunkInit init);
208 readonly attribute EncodedAudioChunkType type;
209 readonly attribute long long timestamp; // microseconds
210 readonly attribute unsigned long long? duration; // microseconds
211 readonly attribute unsigned long byteLength;
212
213 undefined copyTo([AllowShared] BufferSource destination);
214};
215
216dictionary EncodedAudioChunkInit {
217 required EncodedAudioChunkType type;
218 [EnforceRange] required long long timestamp; // microseconds
219 [EnforceRange] unsigned long long duration; // microseconds
220 required BufferSource data;
221};
222
223enum EncodedAudioChunkType {
224 "key",
225 "delta",
226};
227
228[Exposed=(Window,DedicatedWorker)]
229interface EncodedVideoChunk {
230 constructor(EncodedVideoChunkInit init);
231 readonly attribute EncodedVideoChunkType type;
232 readonly attribute long long timestamp; // microseconds
233 readonly attribute unsigned long long? duration; // microseconds
234 readonly attribute unsigned long byteLength;
235
236 undefined copyTo([AllowShared] BufferSource destination);
237};
238
239dictionary EncodedVideoChunkInit {
240 required EncodedVideoChunkType type;
241 [EnforceRange] required long long timestamp; // microseconds
242 [EnforceRange] unsigned long long duration; // microseconds
243 required BufferSource data;
244};
245
246enum EncodedVideoChunkType {
247 "key",
248 "delta",
249};
250
251[Exposed=(Window,DedicatedWorker), Serializable, Transferable]
252interface AudioData {
253 constructor(AudioDataInit init);
254
255 readonly attribute AudioSampleFormat? format;
256 readonly attribute float sampleRate;
257 readonly attribute unsigned long numberOfFrames;
258 readonly attribute unsigned long numberOfChannels;
259 readonly attribute unsigned long long duration; // microseconds
260 readonly attribute long long timestamp; // microseconds
261
262 unsigned long allocationSize(AudioDataCopyToOptions options);
263 undefined copyTo([AllowShared] BufferSource destination, AudioDataCopyToOptions options);
264 AudioData clone();
265 undefined close();
266};
267
268dictionary AudioDataInit {
269 required AudioSampleFormat format;
270 required float sampleRate;
271 [EnforceRange] required unsigned long numberOfFrames;
272 [EnforceRange] required unsigned long numberOfChannels;
273 [EnforceRange] required long long timestamp; // microseconds
274 required BufferSource data;
275};
276
277dictionary AudioDataCopyToOptions {
278 [EnforceRange] required unsigned long planeIndex;
279 [EnforceRange] unsigned long frameOffset = 0;
280 [EnforceRange] unsigned long frameCount;
281 AudioSampleFormat format;
282};
283
284enum AudioSampleFormat {
285 "u8",
286 "s16",
287 "s32",
288 "f32",
289 "u8-planar",
290 "s16-planar",
291 "s32-planar",
292 "f32-planar",
293};
294
295[Exposed=(Window,DedicatedWorker), Serializable, Transferable]
296interface VideoFrame {
297 constructor(CanvasImageSource image, optional VideoFrameInit init = {});
298 constructor([AllowShared] BufferSource data, VideoFrameBufferInit init);
299
300 readonly attribute VideoPixelFormat? format;
301 readonly attribute unsigned long codedWidth;
302 readonly attribute unsigned long codedHeight;
303 readonly attribute DOMRectReadOnly? codedRect;
304 readonly attribute DOMRectReadOnly? visibleRect;
305 readonly attribute unsigned long displayWidth;
306 readonly attribute unsigned long displayHeight;
307 readonly attribute unsigned long long? duration; // microseconds
308 readonly attribute long long? timestamp; // microseconds
309 readonly attribute VideoColorSpace colorSpace;
310
311 unsigned long allocationSize(
312 optional VideoFrameCopyToOptions options = {});
313 Promise<sequence<PlaneLayout>> copyTo(
314 [AllowShared] BufferSource destination,
315 optional VideoFrameCopyToOptions options = {});
316 VideoFrame clone();
317 undefined close();
318};
319
320dictionary VideoFrameInit {
321 unsigned long long duration; // microseconds
322 long long timestamp; // microseconds
323 AlphaOption alpha = "keep";
324
325 // Default matches image. May be used to efficiently crop. Will trigger
326 // new computation of displayWidth and displayHeight using image’s pixel
327 // aspect ratio unless an explicit displayWidth and displayHeight are given.
328 DOMRectInit visibleRect;
329
330 // Default matches image unless visibleRect is provided.
331 [EnforceRange] unsigned long displayWidth;
332 [EnforceRange] unsigned long displayHeight;
333};
334
335dictionary VideoFrameBufferInit {
336 required VideoPixelFormat format;
337 required [EnforceRange] unsigned long codedWidth;
338 required [EnforceRange] unsigned long codedHeight;
339 required [EnforceRange] long long timestamp; // microseconds
340 [EnforceRange] unsigned long long duration; // microseconds
341
342 // Default layout is tightly-packed.
343 sequence<PlaneLayout> layout;
344
345 // Default visible rect is coded size positioned at (0,0)
346 DOMRectInit visibleRect;
347
348 // Default display dimensions match visibleRect.
349 [EnforceRange] unsigned long displayWidth;
350 [EnforceRange] unsigned long displayHeight;
351
352 VideoColorSpaceInit colorSpace;
353};
354
355dictionary VideoFrameCopyToOptions {
356 DOMRectInit rect;
357 sequence<PlaneLayout> layout;
358};
359
360dictionary PlaneLayout {
361 [EnforceRange] required unsigned long offset;
362 [EnforceRange] required unsigned long stride;
363};
364
365enum VideoPixelFormat {
366 // 4:2:0 Y, U, V
367 "I420",
368 // 4:2:0 Y, U, V, A
369 "I420A",
370 // 4:2:2 Y, U, V
371 "I422",
372 // 4:4:4 Y, U, V
373 "I444",
374 // 4:2:0 Y, UV
375 "NV12",
376 // 32bpp RGBA
377 "RGBA",
378 // 32bpp RGBX (opaque)
379 "RGBX",
380 // 32bpp BGRA
381 "BGRA",
382 // 32bpp BGRX (opaque)
383 "BGRX",
384};
385
386[Exposed=(Window,DedicatedWorker)]
387interface VideoColorSpace {
388 constructor(optional VideoColorSpaceInit init = {});
389
390 readonly attribute VideoColorPrimaries? primaries;
391 readonly attribute VideoTransferCharacteristics? transfer;
392 readonly attribute VideoMatrixCoefficients? matrix;
393 readonly attribute boolean? fullRange;
394
395 [Default] VideoColorSpaceInit toJSON();
396};
397
398dictionary VideoColorSpaceInit {
399 VideoColorPrimaries primaries;
400 VideoTransferCharacteristics transfer;
401 VideoMatrixCoefficients matrix;
402 boolean fullRange;
403};
404
405enum VideoColorPrimaries {
406 "bt709", // BT.709, sRGB
407 "bt470bg", // BT.601 PAL
408 "smpte170m", // BT.601 NTSC
409};
410
411enum VideoTransferCharacteristics {
412 "bt709", // BT.709
413 "smpte170m", // BT.601 (functionally the same as bt709)
414 "iec61966-2-1", // sRGB
415};
416
417enum VideoMatrixCoefficients {
418 "rgb", // sRGB
419 "bt709", // BT.709
420 "bt470bg", // BT.601 PAL
421 "smpte170m", // BT.601 NTSC (functionally the same as bt470bg)
422};
423
424[Exposed=(Window,DedicatedWorker), SecureContext]
425interface ImageDecoder {
426 constructor(ImageDecoderInit init);
427
428 readonly attribute DOMString type;
429 readonly attribute boolean complete;
430 readonly attribute Promise<undefined> completed;
431 readonly attribute ImageTrackList tracks;
432
433 Promise<ImageDecodeResult> decode(optional ImageDecodeOptions options = {});
434 undefined reset();
435 undefined close();
436
437 static Promise<boolean> isTypeSupported(DOMString type);
438};
439
440typedef (BufferSource or ReadableStream) ImageBufferSource;
441dictionary ImageDecoderInit {
442 required DOMString type;
443 required ImageBufferSource data;
444 PremultiplyAlpha premultiplyAlpha = "default";
445 ColorSpaceConversion colorSpaceConversion = "default";
446 [EnforceRange] unsigned long desiredWidth;
447 [EnforceRange] unsigned long desiredHeight;
448 boolean preferAnimation;
449};
450
451dictionary ImageDecodeOptions {
452 [EnforceRange] unsigned long frameIndex = 0;
453 boolean completeFramesOnly = true;
454};
455
456dictionary ImageDecodeResult {
457 required VideoFrame image;
458 required boolean complete;
459};
460
461[Exposed=(Window,DedicatedWorker)]
462interface ImageTrackList {
463 getter ImageTrack (unsigned long index);
464
465 readonly attribute Promise<undefined> ready;
466 readonly attribute unsigned long length;
467 readonly attribute long selectedIndex;
468 readonly attribute ImageTrack? selectedTrack;
469};
470
471[Exposed=(Window,DedicatedWorker)]
472interface ImageTrack : EventTarget {
473 readonly attribute boolean animated;
474 readonly attribute unsigned long frameCount;
475 readonly attribute unrestricted float repetitionCount;
476 attribute EventHandler onchange;
477 attribute boolean selected;
478};