pub trait VideoDecoder {
    // Required methods
    fn decode(
        &mut self,
        timestamp: u64,
        bitstream: &[u8]
    ) -> Result<(), DecodeError>;
    fn flush(&mut self);
    fn num_resources_left(&self) -> usize;
    fn num_resources_total(&self) -> usize;
    fn coded_resolution(&self) -> Option<Resolution>;
    fn next_event(&mut self) -> Option<DecoderEvent<'_>>;
}
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.

Required Methods§

source

fn decode( &mut self, timestamp: u64, bitstream: &[u8] ) -> Result<(), 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.

source

fn flush(&mut self)

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.

source

fn num_resources_left(&self) -> usize

Gets the number of output resources left in the backend.

source

fn num_resources_total(&self) -> usize

Gets the number of output resources allocated by the backend.

source

fn coded_resolution(&self) -> Option<Resolution>

Returns the current coded resolution of the bitstream being processed. This may be None if we have not read the stream parameters yet.

source

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

Returns the next event, if there is any pending.

Implementors§

source§

impl<T, P> VideoDecoder for cros_codecs::decoders::h264::decoder::Decoder<T, P>where T: DecodedHandle + Clone + 'static,

source§

impl<T: DecodedHandle + Clone + 'static> VideoDecoder for cros_codecs::decoders::vp8::decoder::Decoder<T>

source§

impl<T: DecodedHandle + Clone + 'static> VideoDecoder for cros_codecs::decoders::vp9::decoder::Decoder<T>