pub struct Decoder { /* private fields */ }Expand description
A stateful V4L2 decode session on one device node.
Implementations§
Source§impl Decoder
impl Decoder
Sourcepub fn open(path: impl AsRef<Path>, codec: Codec) -> Result<Self, VideoError>
pub fn open(path: impl AsRef<Path>, codec: Codec) -> Result<Self, VideoError>
Opens path and prepares the compressed side for codec.
The capture side is deliberately not touched: its geometry belongs to
the stream, and the driver announces it through SOURCE_CHANGE once
it has parsed the headers this session feeds it.
Sourcepub fn ready_for_input(&mut self) -> bool
pub fn ready_for_input(&mut self) -> bool
Whether a compressed buffer is free right now — feed only when true.
Sourcepub fn feed(&mut self, access_unit: &[u8]) -> Result<bool, VideoError>
pub fn feed(&mut self, access_unit: &[u8]) -> Result<bool, VideoError>
Queues one access unit, starting the stream on the first.
Returns false — feeding nothing — when every buffer is in flight;
call Decoder::pump and try again. An access unit larger than the
buffer is truncated, which cannot happen inside the menu’s 1080p bound.
Sourcepub fn pump(&mut self) -> Result<Option<DecodedFrame>, VideoError>
pub fn pump(&mut self) -> Result<Option<DecodedFrame>, VideoError>
Advances the session: handles the source-change handshake, and returns a decoded frame when one is ready. Never blocks.
Sourcepub fn dmabuf(&self, index: u32) -> Option<BorrowedFd<'_>>
pub fn dmabuf(&self, index: u32) -> Option<BorrowedFd<'_>>
The dmabuf backing capture buffer index.
Sourcepub fn recycle(&mut self, index: u32) -> Result<(), VideoError>
pub fn recycle(&mut self, index: u32) -> Result<(), VideoError>
Gives a displayed frame’s buffer back to the decoder.
Call once scanout has moved past it — in practice, when the next frame has been flipped onto the plane.
Sourcepub fn restart(&mut self) -> Result<(), VideoError>
pub fn restart(&mut self) -> Result<(), VideoError>
Stops both queues, forgetting all stream state; the next
Decoder::feed starts the stream over. This is the whole of
seeking: a promo loop restarts from its parameter sets.