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§
Sourcetype Adapter: VideoAdapter
type Adapter: VideoAdapter
Backend-specific vocabulary.
Required Methods§
Sourcefn send_packet(
&mut self,
packet: &VideoPacket<<Self::Adapter as VideoAdapter>::PacketExtra, Self::Buffer>,
) -> Result<Sent, Self::Error>
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.
Sourcefn receive_frame(
&mut self,
dst: &mut VideoFrame<<Self::Adapter as VideoAdapter>::PixelFormat, <Self::Adapter as VideoAdapter>::FrameExtra, Self::Buffer>,
) -> Result<Received, 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>
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.
Sourcefn send_eof(&mut self) -> Result<Sent, Self::Error>
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".