| // Copyright 2019 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| // https://github.com/WICG/web-codecs |
| |
| [ |
| Exposed=(Window,DedicatedWorker), |
| Serializable, |
| RuntimeEnabled=WebCodecs |
| ] interface VideoFrame { |
| [CallWith=ScriptState, RaisesException] |
| constructor(CanvasImageSource source, optional VideoFrameInit init = {}); |
| [CallWith=ScriptState, RaisesException] |
| constructor(VideoPixelFormat format, |
| sequence<PlaneInit> planes, |
| VideoFramePlaneInit init); |
| |
| // TODO(sandersd): Provide a way to find out what pixel formats are supported. |
| // TODO(sandersd): Provide a way to convert to a specific pixel format, and to |
| // find out what pixel formats can be converted to. |
| |
| // TODO(sandersd): It's not clear whether it's better to use undefined, or a |
| // special enum value to mean 'opaque format'. Undefined does result in |
| // shorter branch conditions. |
| readonly attribute VideoPixelFormat? format; |
| readonly attribute FrozenArray<Plane>? planes; |
| |
| // The size of the frame; typically padded to a multiple of some block size. |
| readonly attribute unsigned long codedWidth; |
| readonly attribute unsigned long codedHeight; |
| |
| // The region of the frame that is not padding. |
| readonly attribute unsigned long cropLeft; |
| readonly attribute unsigned long cropTop; |
| readonly attribute unsigned long cropWidth; |
| readonly attribute unsigned long cropHeight; |
| |
| // The intended display size (and display aspect ratio) of the crop region. |
| // TODO(sandersd): The draft spec says double, and that makes sense, but it |
| // also makes createImageBitmap() ambiguous. |
| readonly attribute unsigned long displayWidth; |
| readonly attribute unsigned long displayHeight; |
| |
| // Presentation timestamp, in microseconds. |
| readonly attribute unsigned long long? timestamp; |
| // Presentation duration, in microseconds. |
| readonly attribute unsigned long long? duration; |
| |
| // TODO(sandersd): color space metadata. |
| // TODO(sandersd): rotation metadata. |
| |
| // DEPRECATED: use close() instead. |
| // Release held resources immediately. |
| [CallWith=ExecutionContext] void destroy(); |
| |
| // Release held resources. |
| void close(); |
| |
| // Creates of the copy of this VideoFrame, which needs to be independently |
| // destroyed. |
| [CallWith=ScriptState, RaisesException] |
| VideoFrame clone(); |
| |
| // Create an ImageBitmap from the crop region, scaled to the display size. |
| // TODO(sandersd): Should use the global createImageBitmap() instead. |
| [CallWith=ScriptState, RaisesException] Promise<ImageBitmap> |
| createImageBitmap(optional ImageBitmapOptions options = {}); |
| }; |