Skip to main content

VideoStreamDecoder

Trait VideoStreamDecoder 

Source
pub trait VideoStreamDecoder {
    type Adapter: VideoAdapter;
    type Buffer: AsRef<[u8]>;
    type Error;

    // Required methods
    fn send_packet(
        &mut self,
        packet: &VideoPacket<<Self::Adapter as VideoAdapter>::PacketExtra, Self::Buffer>,
    ) -> Result<Sent, Self::Error>;
    fn receive_frame(
        &mut self,
        dst: &mut VideoFrame<<Self::Adapter as VideoAdapter>::PixelFormat, <Self::Adapter as VideoAdapter>::FrameExtra, Self::Buffer>,
    ) -> Result<Received, Self::Error>;
    fn send_eof(&mut self) -> Result<Sent, Self::Error>;
    fn flush(&mut self) -> Result<(), Self::Error>;
}
Expand description

Push-style video decoder. Caller submits compressed packets and drains decoded frames.

Backends: FFmpeg, WebCodecs, ProRes RAW (VideoToolbox).

Required Associated Types§

Source

type Adapter: VideoAdapter

Backend-specific vocabulary.

Source

type Buffer: AsRef<[u8]>

Buffer type held by the packets and frames this decoder produces or accepts.

Source

type Error

Decoder-specific error type.

Required Methods§

Source

fn send_packet( &mut self, packet: &VideoPacket<<Self::Adapter as VideoAdapter>::PacketExtra, Self::Buffer>, ) -> Result<Sent, Self::Error>

Submits one compressed packet.

Sent::Accepted means the packet was consumed. Sent::MustDrain means it was not — the session’s output must be drained through receive_frame and the same packet offered again. That is back pressure, not a refusal, and it is why Err here can be read as a fault without a second attempt.

Source

fn receive_frame( &mut self, dst: &mut VideoFrame<<Self::Adapter as VideoAdapter>::PixelFormat, <Self::Adapter as VideoAdapter>::FrameExtra, Self::Buffer>, ) -> Result<Received, Self::Error>

Drains one decoded frame into dst.

Received::Frame means dst was written. Received::NeedsInput and Received::Ended are the protocol’s other two answers, and neither is an error — Err is a fault.

Source

fn send_eof(&mut self) -> Result<Sent, Self::Error>

Signals end-of-stream.

Answers Sent for the same reason send_packet does: a session with undrained output can be unable to take the signal yet, and Sent::MustDrain means the end-of-stream was not recorded. Drain and signal again.

Source

fn flush(&mut self) -> Result<(), Self::Error>

Flushes internal state. Not a submission — nothing is offered, so there is nothing to be back-pressured.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§