Skip to main content

VideoFrame

Trait VideoFrame 

Source
pub trait VideoFrame:
    Any
    + Send
    + Sync {
    // Required methods
    fn width(&self) -> u32;
    fn height(&self) -> u32;
    fn texture(&self, device: &Device) -> Option<Texture>;
}
Expand description

One picture of a video as the system hands it out, as WebCodecs’ VideoFrame. It holds its slot in the decoder’s pool until it, and every texture made of it, are dropped.

Each host implements it over the frames its system hands out. Platform code reaches the system’s own frame by downcasting through Any to the type of the host that handed it out: on Apple’s systems inset-embedder-winit’s CoreVideoFrame, whose pixel_buffer is the CVPixelBuffer AVFoundation handed out.

Required Methods§

Source

fn width(&self) -> u32

The picture’s width, in its own pixels.

Source

fn height(&self) -> u32

The picture’s height, in its own pixels.

Source

fn texture(&self, device: &Device) -> Option<Texture>

A texture of the frame on device, for sampling, sharing its memory where the system can. The texture holds the frame. None for a device that cannot take the frame’s memory: on macOS a wgpu device not on Metal, or one Core Video makes no texture of the frame on.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§