pub trait StatelessVideoDecoder<M> {
    // Required methods
    fn decode(
        &mut self,
        timestamp: u64,
        bitstream: &[u8]
    ) -> Result<usize, DecodeError>;
    fn flush(&mut self) -> Result<(), DecodeError>;
    fn surface_pool(&mut self) -> &mut dyn SurfacePool<M>;
    fn stream_info(&self) -> Option<&StreamInfo>;
    fn next_event(&mut self) -> Option<DecoderEvent<'_, M>>;
}
Expand description

Stateless video decoder interface.

A stateless decoder differs from a stateful one in that its input and output queues are not operating independently: a new decode unit can only be processed if there is already an output resource available to receive its decoded content.

Therefore decode can refuse work if there is no output resource available at the time of calling, in which case the caller is responsible for calling decode again with the same parameters after processing at least one pending output frame and returning it to the decoder.

The M generic parameter is the type of the memory descriptor backing the output frames.

Required Methods§

source

fn decode( &mut self, timestamp: u64, bitstream: &[u8] ) -> Result<usize, DecodeError>

Try to decode the bitstream represented by timestamp.

This method will return DecodeError::CheckEvents if processing cannot take place until pending events are handled. This could either be because a change of output format has been detected that the client should acknowledge, or because there are no available output resources and dequeueing and returning pending frames will fix that. After the cause has been addressed, the client is responsible for calling this method again with the same data.

The return value is the number of bytes in bitstream that have been processed. Usually this will be equal to the length of bitstream, but some codecs may only do partial processing if e.g. several units are sent at the same time. It is the responsibility of the caller to check that all submitted input has been processed, and to resubmit the unprocessed part if it hasn’t. See the documentation of each codec for their expectations.

source

fn flush(&mut self) -> Result<(), DecodeError>

Flush the decoder i.e. finish processing all pending decode requests and make sure the resulting frames are ready to be retrieved via next_event.

Note that after flushing, a key frame must be submitted before decoding can resume.

source

fn surface_pool(&mut self) -> &mut dyn SurfacePool<M>

Returns the surface pool in use with the decoder. Useful to add new frames as decode. targets.

source

fn stream_info(&self) -> Option<&StreamInfo>

source

fn next_event(&mut self) -> Option<DecoderEvent<'_, M>>

Returns the next event, if there is any pending.

Implementors§