//! High-level interface for a V4L2 video decoder. Currently only supports the //! [stateful interface](https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/dev-encoder.html). use crate::{ device::queue::{ direction::{Capture, Output}, dqbuf::DqBuffer, handles_provider::HandlesProvider, CanceledBuffer, FormatBuilder, }, memory::BufferHandles, Rect, }; pub mod format; pub mod stateful; pub enum CompletedInputBuffer { Dequeued(DqBuffer), Canceled(CanceledBuffer), } pub trait InputDoneCallback: Fn(CompletedInputBuffer) {} impl InputDoneCallback for F where OP: BufferHandles, F: Fn(CompletedInputBuffer), { } // TODO: add errors? pub enum DecoderEvent { /// Emitted when a frame is decoded. /// /// The parameter is the dequeued buffer, containing the plane handles of /// the decoded frame as well as its V4L2 parameters such as flags. The /// flags remain untouched, but the client should not take action on some /// of them: for instance, when the `V4L2_BUF_FLAG_LAST` is set, the proper /// corresponding event (resolution change or end of stream) will be /// signaled appropriately. FrameDecoded(DqBuffer), /// Emitted when a previously requested `drain` request completes. /// /// When this event is emitted, the client knows that all the frames /// corresponding to all the input buffers queued before the `drain` request /// have been emitted. EndOfStream, } pub trait DecoderEventCallback: FnMut(DecoderEvent

) + Send + 'static { } impl DecoderEventCallback

for F where P: HandlesProvider, F: FnMut(DecoderEvent

) + Send + 'static, { } pub struct FormatChangedReply { pub provider: P, pub mem_type: ::SupportedMemoryType, pub num_buffers: usize, } pub trait FormatChangedCallback: Fn(FormatBuilder, Rect, usize) -> anyhow::Result> + Send + 'static { } impl FormatChangedCallback

for F where P: HandlesProvider, F: Fn(FormatBuilder, Rect, usize) -> anyhow::Result> + Send + 'static, { }