Skip to main content

VideoDecoderBackend

Trait VideoDecoderBackend 

Source
pub trait VideoDecoderBackend: Send {
    // Required methods
    fn backend_kind(&self) -> HardwareDecoderKind;
    fn capabilities(&self) -> HardwareDecoderCapabilities;
    fn configure(&mut self, config: &VideoDecoderConfig) -> Result<(), String>;
    fn decode_packet(
        &mut self,
        packet: &EncodedVideoPacket,
        pool: &VideoFramePool,
    ) -> Result<Option<DecodedVideoFrame>, String>;
    fn flush(&mut self);
}
Expand description

Pluggable hardware or software video decoder backend interface.

Required Methods§

Source

fn backend_kind(&self) -> HardwareDecoderKind

Returns the backend identifier (VideoToolbox, MediaCodec, Vaapi, Dxva, WebCodecs, or SoftwareFallback).

§Arguments
  • &Self - Decoder backend reference.
§Returns
  • HardwareDecoderKind - Active backend kind.
Source

fn capabilities(&self) -> HardwareDecoderCapabilities

Reports codec, resolution, HDR, and zero-copy capabilities supported by this backend.

§Arguments
  • &Self - Decoder backend reference.
§Returns
  • HardwareDecoderCapabilities - Backend capability descriptor.
Source

fn configure(&mut self, config: &VideoDecoderConfig) -> Result<(), String>

Configures or reconfigures the decoder for a video track descriptor.

§Arguments
  • &Self - Mutable decoder backend.
  • &VideoDecoderConfig - Track dimensions, codec, and color/HDR metadata.
§Returns
  • Result<(), String> - Ok(()) on successful initialization or descriptive error.
Source

fn decode_packet( &mut self, packet: &EncodedVideoPacket, pool: &VideoFramePool, ) -> Result<Option<DecodedVideoFrame>, String>

Decodes a single demuxed packet into an optional decoded video frame backed by GPU surface or pooled CPU memory.

§Arguments
  • &Self - Mutable decoder backend.
  • &EncodedVideoPacket - Demuxed compressed or structured frame packet with DTS/PTS and generation tag.
  • &VideoFramePool - Bounded CPU pixel buffer pool for software fallback frames.
§Returns
  • Result<Option<DecodedVideoFrame>, String> - Decoded frame ready for the PTS queue, None when buffered internally, or error.
Source

fn flush(&mut self)

Flushes internal reference frames and reorder buffers (invoked on seek or generation reset).

§Arguments
  • &Self - Mutable decoder backend.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl VideoDecoderBackend for HardwareZeroCopyDecoder

Zero-copy GPU surface VideoDecoderBackend implementation for HardwareZeroCopyDecoder.

Source§

impl VideoDecoderBackend for SoftwareVideoDecoder

Pure-Rust software fallback VideoDecoderBackend implementation for SoftwareVideoDecoder.