pub trait VideoDecoder {
    fn decode(
        &mut self,
        timestamp: u64,
        bitstream: &[u8]
    ) -> Result<Vec<Box<dyn DynDecodedHandle>>>; fn flush(&mut self) -> Result<Vec<Box<dyn DynDecodedHandle>>>; fn negotiation_possible(&self) -> bool; fn num_resources_left(&self) -> Option<usize>; fn num_resources_total(&self) -> usize; fn coded_resolution(&self) -> Option<Resolution>; fn poll(
        &mut self,
        blocking_mode: BlockingMode
    ) -> Result<Vec<Box<dyn DynDecodedHandle>>>; }

Required Methods

Decode the bitstream represented by timestamp. Returns zero or more decoded handles representing the decoded data.

Flush the decoder i.e. finish processing all queued decode requests and emit frames for them.

Whether negotiation of the decoded format is possible. In particular, a decoder will indicate that negotiation is possible after enough metadata is collected from parsing the bitstream through calls to the decode() method.

The negotiation process will start as soon as negotiation_possible() returns true. At this moment, the client and the backend can settle on a format by using the supported_formats_for_stream(), format() and try_format() methods.

When negotiation_possible() returns true, the client may also query the backend for new values for the coded resolution, display resolution and/or to the number of resources allocated.

The negotiation process ends as soon as another call to decode() is made, at which point any queued data will be processed first in order to generate any frames that might have been pending while the negotiation process was under way and negotiation_possible() will from then on return false.

If no action is undertaken by the client in the window of time where negotiation_possible() returns true, it is assumed that the default format chosen by the backend is acceptable.

The negotiation process can happen more than once if new stream metadata indicate a change of the stream parameters such that the current decoded format becomes incompatible with the stream. In this case, negotiation_possible() will once again return true and the same process described above will take place.

Gets the number of output resources left in the backend after accounting for any buffers that might be queued in the decoder.

Gets the number of output resources allocated by the backend.

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

Polls the decoder, emitting frames for all queued decode requests. This is similar to flush, but it does not change the state of the decoded picture buffer nor does it reset any internal state.

Implementors