ImageDecoder.webidl (2369B)
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/#image-decoding 8 */ 9 10 typedef (AllowSharedBufferSource or ReadableStream) ImageBufferSource; 11 dictionary ImageDecoderInit { 12 required DOMString type; 13 required ImageBufferSource data; 14 ColorSpaceConversion colorSpaceConversion = "default"; 15 [EnforceRange] unsigned long desiredWidth; 16 [EnforceRange] unsigned long desiredHeight; 17 boolean preferAnimation; 18 sequence<ArrayBuffer> transfer = []; 19 }; 20 21 dictionary ImageDecodeOptions { 22 [EnforceRange] unsigned long frameIndex = 0; 23 boolean completeFramesOnly = true; 24 }; 25 26 dictionary ImageDecodeResult { 27 required VideoFrame image; 28 required boolean complete; 29 }; 30 31 dictionary ImageSize { 32 required unsigned long width; 33 required unsigned long height; 34 }; 35 36 [Exposed=(Window,DedicatedWorker), 37 SecureContext, 38 Func="nsRFPService::ExposeWebCodecsAPIImageDecoder"] 39 interface ImageTrack { 40 readonly attribute boolean animated; 41 readonly attribute unsigned long frameCount; 42 readonly attribute unrestricted float repetitionCount; 43 attribute boolean selected; 44 45 // Mozilla-internal-only addition 46 [ChromeOnly] 47 sequence<ImageSize> getSizes(); 48 }; 49 50 [Exposed=(Window,DedicatedWorker), 51 SecureContext, 52 Func="nsRFPService::ExposeWebCodecsAPIImageDecoder"] 53 interface ImageTrackList { 54 getter ImageTrack (unsigned long index); 55 56 readonly attribute Promise<undefined> ready; 57 readonly attribute unsigned long length; 58 readonly attribute long selectedIndex; 59 readonly attribute ImageTrack? selectedTrack; 60 }; 61 62 [Exposed=(Window,DedicatedWorker), 63 SecureContext, 64 Func="nsRFPService::ExposeWebCodecsAPIImageDecoder"] 65 interface ImageDecoder { 66 [Throws] 67 constructor(ImageDecoderInit init); 68 69 readonly attribute DOMString type; 70 readonly attribute boolean complete; 71 readonly attribute Promise<undefined> completed; 72 readonly attribute ImageTrackList tracks; 73 74 [Throws] 75 Promise<ImageDecodeResult> decode(optional ImageDecodeOptions options = {}); 76 undefined reset(); 77 undefined close(); 78 79 [Throws] 80 static Promise<boolean> isTypeSupported(DOMString type); 81 };