Skip to main content

Decoder

Struct Decoder 

Source
pub struct Decoder { /* private fields */ }
Expand description

A stateful V4L2 decode session on one device node.

Implementations§

Source§

impl Decoder

Source

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.

Source

pub fn codec(&self) -> Codec

Which codec this session decodes.

Source

pub fn ready_for_input(&mut self) -> bool

Whether a compressed buffer is free right now — feed only when true.

Source

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.

Source

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.

Source

pub fn dmabuf(&self, index: u32) -> Option<BorrowedFd<'_>>

The dmabuf backing capture buffer index.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.