euv-core 0.47.1

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
use super::*;

/// Pluggable hardware or software video decoder backend interface.
#[cfg(not(target_arch = "wasm32"))]
pub trait VideoDecoderBackend: Send {
    /// Returns the backend identifier (`VideoToolbox`, `MediaCodec`, `Vaapi`, `Dxva`, `WebCodecs`, or `SoftwareFallback`).
    ///
    /// # Arguments
    ///
    /// - `&Self` - Decoder backend reference.
    ///
    /// # Returns
    ///
    /// - `HardwareDecoderKind` - Active backend kind.
    fn backend_kind(&self) -> HardwareDecoderKind;

    /// Reports codec, resolution, HDR, and zero-copy capabilities supported by this backend.
    ///
    /// # Arguments
    ///
    /// - `&Self` - Decoder backend reference.
    ///
    /// # Returns
    ///
    /// - `HardwareDecoderCapabilities` - Backend capability descriptor.
    fn capabilities(&self) -> HardwareDecoderCapabilities;

    /// 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.
    fn configure(&mut self, config: &VideoDecoderConfig) -> Result<(), 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.
    fn decode_packet(
        &mut self,
        packet: &EncodedVideoPacket,
        pool: &VideoFramePool,
    ) -> Result<Option<DecodedVideoFrame>, String>;

    /// Flushes internal reference frames and reorder buffers (invoked on seek or generation reset).
    ///
    /// # Arguments
    ///
    /// - `&Self` - Mutable decoder backend.
    fn flush(&mut self);
}

/// Pluggable hardware or software video decoder backend interface for single-threaded WebAssembly hosts.
#[cfg(target_arch = "wasm32")]
pub trait VideoDecoderBackend {
    /// Returns the backend identifier (`WebCodecs` or `SoftwareFallback`).
    ///
    /// # Arguments
    ///
    /// - `&Self` - Decoder backend reference.
    ///
    /// # Returns
    ///
    /// - `HardwareDecoderKind` - Active backend kind.
    fn backend_kind(&self) -> HardwareDecoderKind;

    /// Reports codec, resolution, HDR, and zero-copy capabilities supported by this backend.
    ///
    /// # Arguments
    ///
    /// - `&Self` - Decoder backend reference.
    ///
    /// # Returns
    ///
    /// - `HardwareDecoderCapabilities` - Backend capability descriptor.
    fn capabilities(&self) -> HardwareDecoderCapabilities;

    /// 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.
    fn configure(&mut self, config: &VideoDecoderConfig) -> Result<(), 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.
    fn decode_packet(
        &mut self,
        packet: &EncodedVideoPacket,
        pool: &VideoFramePool,
    ) -> Result<Option<DecodedVideoFrame>, String>;

    /// Flushes internal reference frames and reorder buffers (invoked on seek or generation reset).
    ///
    /// # Arguments
    ///
    /// - `&Self` - Mutable decoder backend.
    fn flush(&mut self);
}