Skip to main content

openipc_video/api/
surface.rs

1/// Visible dimensions of a decoded frame.
2#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
3pub struct FrameDimensions {
4    /// Width in pixels.
5    pub width: u32,
6    /// Height in pixels.
7    pub height: u32,
8}
9
10/// Platform-independent description of common decoded pixel formats.
11#[derive(Debug, Clone, Copy, PartialEq, Eq)]
12#[non_exhaustive]
13pub enum PixelFormat {
14    /// Bi-planar 8-bit YUV 4:2:0, video range.
15    Nv12VideoRange,
16    /// Bi-planar 8-bit YUV 4:2:0, full range.
17    Nv12FullRange,
18    /// 32-bit BGRA.
19    Bgra8,
20    /// Platform-specific format represented by its native code.
21    Native(u32),
22}
23
24/// A decoded platform surface retained from the operating system or browser.
25///
26/// Desktop surface implementations are `Send + Sync`. Browser `VideoFrame`
27/// objects and some mobile image leases are intentionally thread-local, so
28/// cross-thread applications should add `Send + Sync` to their own generic
29/// bounds when they require it.
30pub trait DecodedSurface: 'static {
31    /// Visible frame dimensions.
32    fn dimensions(&self) -> FrameDimensions;
33
34    /// Pixel format of the retained surface.
35    fn pixel_format(&self) -> PixelFormat;
36}