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>;
// Provided methods
fn scaled_output_capability(&self) -> ScaledOutputCapability { ... }
fn request_scaled_output(
&mut self,
size: (u32, u32),
) -> ScaledOutputCapability { ... }
}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.
Provided Methods§
Sourcefn scaled_output_capability(&self) -> ScaledOutputCapability
fn scaled_output_capability(&self) -> ScaledOutputCapability
Whether this session can currently emit pictures at a caller-
requested output size instead of full coded size. See
ScaledOutputCapability for what a Self::Supported answer
costs a caller who acts on it.
A pure query — it does not itself request anything, and calling
it has no effect on what receive_frame
delivers. Defaults to ScaledOutputCapability::Unsupported so
every existing implementor of this trait keeps compiling; a
backend that can honor a request overrides both this and
request_scaled_output to say so.
Sourcefn request_scaled_output(&mut self, size: (u32, u32)) -> ScaledOutputCapability
fn request_scaled_output(&mut self, size: (u32, u32)) -> ScaledOutputCapability
Requests that this session emit decoded pictures at size
(width, height) from here on, and reports whether the request was
honored.
Refusal is not an error: a backend that cannot honor the
request answers ScaledOutputCapability::Unsupported and
leaves the session decoding at full coded size — nothing about
send_packet or
receive_frame can fail because a
requested size was refused. The caller reads the return value (or
calls scaled_output_capability
again) to learn which happened, and falls back to resampling the
full-size picture itself when it did not take effect.
Defaults to a no-op that always answers
ScaledOutputCapability::Unsupported, matching
scaled_output_capability’s
default — every existing implementor keeps compiling.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".