tor-browser

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

VideoFrame.webidl (4719B)


      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/#videoframe
      8 */
      9 
     10 enum AlphaOption {
     11  "keep",
     12  "discard",
     13 };
     14 
     15 // [Serializable, Transferable] are implemented without adding attributes here.
     16 [Exposed=(Window,DedicatedWorker), Func="mozilla::dom::VideoFrame::PrefEnabled"]
     17 interface VideoFrame {
     18  // The constructors should be shortened to:
     19  //   ```
     20  //   constructor(CanvasImageSource image, optional VideoFrameInit init = {});
     21  //   constructor(AllowSharedBufferSource data, VideoFrameBufferInit init);
     22  //   ```
     23  // but a `No support for unions as distinguishing arguments yet` error occurs
     24  // when using the CanvasImageSource and AllowSharedBufferSource unions
     25  // (bug 1786410).
     26  [Throws]
     27  constructor(HTMLImageElement imageElement, optional VideoFrameInit init = {});
     28  [Throws]
     29  constructor(SVGImageElement svgImageElement, optional VideoFrameInit init = {});
     30  [Throws]
     31  constructor(HTMLCanvasElement canvasElement, optional VideoFrameInit init = {});
     32  [Throws]
     33  constructor(HTMLVideoElement videoElement, optional VideoFrameInit init = {});
     34  [Throws]
     35  constructor(OffscreenCanvas offscreenCanvas, optional VideoFrameInit init = {});
     36  [Throws]
     37  constructor(ImageBitmap imageBitmap, optional VideoFrameInit init = {});
     38  [Throws]
     39  constructor(VideoFrame videoFrame, optional VideoFrameInit init = {});
     40  [Throws]
     41  constructor([AllowShared] ArrayBufferView bufferView, VideoFrameBufferInit init);
     42  [Throws]
     43  constructor([AllowShared] ArrayBuffer buffer, VideoFrameBufferInit init);
     44 
     45 
     46  readonly attribute VideoPixelFormat? format;
     47  readonly attribute unsigned long codedWidth;
     48  readonly attribute unsigned long codedHeight;
     49  readonly attribute DOMRectReadOnly? codedRect;
     50  readonly attribute DOMRectReadOnly? visibleRect;
     51  readonly attribute unsigned long displayWidth;
     52  readonly attribute unsigned long displayHeight;
     53  readonly attribute unsigned long long? duration;  // microseconds
     54  readonly attribute long long timestamp;           // microseconds
     55  readonly attribute VideoColorSpace colorSpace;
     56 
     57  [Throws]
     58  unsigned long allocationSize(
     59      optional VideoFrameCopyToOptions options = {});
     60  [Throws]
     61  Promise<sequence<PlaneLayout>> copyTo(
     62      AllowSharedBufferSource destination,
     63      optional VideoFrameCopyToOptions options = {});
     64  [Throws]
     65  VideoFrame clone();
     66  undefined close();
     67 };
     68 
     69 dictionary VideoFrameInit {
     70  unsigned long long duration;  // microseconds
     71  long long timestamp;          // microseconds
     72  AlphaOption alpha = "keep";
     73 
     74  // Default matches image. May be used to efficiently crop. Will trigger
     75  // new computation of displayWidth and displayHeight using image’s pixel
     76  // aspect ratio unless an explicit displayWidth and displayHeight are given.
     77  DOMRectInit visibleRect;
     78 
     79  // Default matches image unless visibleRect is provided.
     80  [EnforceRange] unsigned long displayWidth;
     81  [EnforceRange] unsigned long displayHeight;
     82 };
     83 
     84 dictionary VideoFrameBufferInit {
     85  required VideoPixelFormat format;
     86  required [EnforceRange] unsigned long codedWidth;
     87  required [EnforceRange] unsigned long codedHeight;
     88  required [EnforceRange] long long timestamp;  // microseconds
     89  [EnforceRange] unsigned long long duration;   // microseconds
     90 
     91  // Default layout is tightly-packed.
     92  sequence<PlaneLayout> layout;
     93 
     94  // Default visible rect is coded size positioned at (0,0)
     95  DOMRectInit visibleRect;
     96 
     97  // Default display dimensions match visibleRect.
     98  [EnforceRange] unsigned long displayWidth;
     99  [EnforceRange] unsigned long displayHeight;
    100 
    101  VideoColorSpaceInit colorSpace;
    102 };
    103 
    104 dictionary VideoFrameCopyToOptions {
    105  DOMRectInit rect;
    106  sequence<PlaneLayout> layout;
    107  VideoPixelFormat format;
    108  PredefinedColorSpace colorSpace;
    109 };
    110 
    111 dictionary PlaneLayout {
    112  // TODO: https://github.com/w3c/webcodecs/pull/488
    113  required [EnforceRange] unsigned long offset;
    114  required [EnforceRange] unsigned long stride;
    115 };
    116 
    117 enum VideoPixelFormat {
    118  // 4:2:0 Y, U, V
    119  "I420",
    120  "I420P10",
    121  "I420P12",
    122  // 4:2:0 Y, U, V, A
    123  "I420A",
    124  "I420AP10",
    125  "I420AP12",
    126  // 4:2:2 Y, U, V
    127  "I422",
    128  "I422P10",
    129  "I422P12",
    130  // 4:2:2 Y, U, V, A
    131  "I422A",
    132  "I422AP10",
    133  "I422AP12",
    134  // 4:4:4 Y, U, V
    135  "I444",
    136  "I444P10",
    137  "I444P12",
    138  // 4:4:4 Y, U, V, A
    139  "I444A",
    140  "I444AP10",
    141  "I444AP12",
    142  // 4:2:0 Y, UV
    143  "NV12",
    144  // 4:4:4 RGBA
    145  "RGBA",
    146  // 4:4:4 RGBX (opaque)
    147  "RGBX",
    148  // 4:4:4 BGRA
    149  "BGRA",
    150  // 4:4:4 BGRX (opaque)
    151  "BGRX",
    152 };