Interface VideoFrameBuffer

[[VideoFrameBuffer]] is an interface that can be used as input or output with VideoFrameProcessor. It must implement the method to return buffer as CanvasImageSource but the internal handle to the video frame buffer can be flexible.

interface VideoFrameBuffer {
    framerate: number;
    height: number;
    width: number;
    asCanvasElement(): OffscreenCanvas | HTMLCanvasElement;
    asCanvasImageSource(): Promise<CanvasImageSource>;
    asTransferable(): Promise<Transferable>;
    destroy(): void;
}

Implemented by

Properties

framerate: number

The frame rate of the source in the [[VideoFrameBuffer]].

height: number

The height in pixels of the source in the [[VideoFrameBuffer]].

width: number

The width in pixels of the source in the [[VideoFrameBuffer]].

Methods

  • Returns HTMLCanvasElement or OffscreenCanvas if the internal source can be transformed into one. Optional method. Returns null if the buffer is destroyed.

    Returns OffscreenCanvas | HTMLCanvasElement

  • Returns the buffer as CanvasImageSource which can be drawn on HTMLCanvasElement directly. If destroy is already called, asCanvasImageSource should reject.

    Returns Promise<CanvasImageSource>

  • Returns [[Transferable]] if the internal source can be transformed into one. Optional method. If destroy is already called, asTransferable should reject.

    Returns Promise<Transferable>

  • Explicitly destroys the source and intermediate buffers in [[VideoFrameBuffer]]. After destroy is called, this [[VideoFrameBuffer]] must be discarded. destroy is typically required to be called, when MediaStream, HTMLVideoElement and ImageData are passed in as initialization data.

    Returns void