Skip to main content

VideoDecoderBackendSession

Trait VideoDecoderBackendSession 

Source
pub trait VideoDecoderBackendSession {
    type BufferStorage: VideoDecoderBufferBacking;

    // Required methods
    fn decode(
        &mut self,
        input: &Self::BufferStorage,
        index: u32,
        timestamp: timeval,
        bytes_used: u32,
    ) -> IoctlResult<()>;
    fn use_as_output(
        &mut self,
        index: u32,
        backing: &mut Self::BufferStorage,
    ) -> IoctlResult<()>;
    fn drain(&mut self) -> IoctlResult<()>;
    fn clear_output_buffers(&mut self) -> IoctlResult<()>;
    fn next_event(&mut self) -> Option<VideoDecoderBackendEvent>;
    fn current_format(&self, direction: QueueDirection) -> V4l2MplaneFormat;
    fn stream_params(&self) -> StreamParams;

    // Provided methods
    fn buffers_allocated(
        &mut self,
        _direction: QueueDirection,
        _num_buffers: u32,
    ) { ... }
    fn poll_fd(&self) -> Option<BorrowedFd<'_>> { ... }
    fn streaming_state(&mut self, _direction: QueueDirection, _streaming: bool) { ... }
    fn resume(&mut self) { ... }
}
Expand description

Trait for a video decoding session.

Required Associated Types§

Required Methods§

Source

fn decode( &mut self, input: &Self::BufferStorage, index: u32, timestamp: timeval, bytes_used: u32, ) -> IoctlResult<()>

Decode the encoded stream in input, of length bytes_used, which corresponds to OUTPUT buffer index.

timestamp is the timestamp of the frame, to be reported in any frame produced from this call.

Source

fn use_as_output( &mut self, index: u32, backing: &mut Self::BufferStorage, ) -> IoctlResult<()>

Use backing as the backing storage for output buffer index.

Source

fn drain(&mut self) -> IoctlResult<()>

Start draining the decoder pipeline for all buffers still in it.

The backend will report a frame with the V4L2_BUF_FLAG_LAST once the drain process is completed.

Source

fn clear_output_buffers(&mut self) -> IoctlResult<()>

Remove any output buffer that has been previously added using [use_as_output].

Source

fn next_event(&mut self) -> Option<VideoDecoderBackendEvent>

Returns the next pending event if there is one, or None if there aren’t any.

Source

fn current_format(&self, direction: QueueDirection) -> V4l2MplaneFormat

Returns the current format set for the given direction, in a form suitable as a reply to VIDIOC_G_FMT.

Source

fn stream_params(&self) -> StreamParams

Returns the stream parameters as read from the input.

Provided Methods§

Source

fn buffers_allocated(&mut self, _direction: QueueDirection, _num_buffers: u32)

Called whenever the decoder device has allocated buffers for a given queue.

This can be useful for some backends that need to know how many buffers they will work with. The default implementation does nothing, which should be suitable for backends that don’t care.

Source

fn poll_fd(&self) -> Option<BorrowedFd<'_>>

Returns a file descriptor that signals POLLIN whenever an event is pending and can be read using [next_event], or None if the backend does not support this.

Source

fn streaming_state(&mut self, _direction: QueueDirection, _streaming: bool)

Optional hook called whenever the streaming state of a queue changes. Some backends may need this information to operate properly.

Source

fn resume(&mut self)

Optional hook called by the decoder to signal it has processed a pausing event sent by the backend.

Pausing event are currently limited to VideoDecoderBackendEvent::StreamFormatChanged. Whenever the resolution changes, the backend must stop processing until the decoder has adapted its conditions for decoding to resume (e.g. CAPTURE buffers of the proper size and format have been allocated).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§