Trait StatelessVideoDecoder

Source
pub trait StatelessVideoDecoder {
    type Handle: DecodedHandle;
    type FramePool: FramePool<Descriptor = <Self::Handle as DecodedHandle>::Descriptor> + ?Sized;

    // Required methods
    fn decode(
        &mut self,
        timestamp: u64,
        bitstream: &[u8],
    ) -> Result<usize, DecodeError>;
    fn flush(&mut self) -> Result<(), DecodeError>;
    fn frame_pool(&mut self, layer: PoolLayer) -> Vec<&mut Self::FramePool>;
    fn stream_info(&self) -> Option<&StreamInfo>;
    fn next_event(&mut self) -> Option<DecoderEvent<'_, Self::Handle>>;
    fn poll_fd(&self) -> BorrowedFd<'_>;

    // Provided method
    fn into_trait_object(
        self,
    ) -> DynStatelessVideoDecoder<<Self::Handle as DecodedHandle>::Descriptor>
       where Self: Sized + 'static,
             Self::FramePool: Sized + 'static,
             Self::Handle: 'static { ... }
}
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 Associated Types§

Source

type Handle: DecodedHandle

Type of the DecodedHandles that decoded frames are returned into.

Source

type FramePool: FramePool<Descriptor = <Self::Handle as DecodedHandle>::Descriptor> + ?Sized

FramePool providing frames to decode into. Its descriptor must be the same as StatelessVideoDecoder::Handle.

Required Methods§

Source

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

Attempts to decode bitstream if the current conditions allow it.

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 frame_pool(&mut self, layer: PoolLayer) -> Vec<&mut Self::FramePool>

Returns the frame pool for resolution in use with the decoder. If resolution is None, the pool of the highest resolution is returned.

Multiple pools may be in use for SVC streams, since each spatial layer will receive its frames from a separate pool.

Useful to add new frames as decode targets.

Source

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

Source

fn next_event(&mut self) -> Option<DecoderEvent<'_, Self::Handle>>

Returns the next event, if there is any pending.

Source

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

Returns a file descriptor that signals POLLIN whenever an event is pending on this decoder.

Provided Methods§

Source

fn into_trait_object( self, ) -> DynStatelessVideoDecoder<<Self::Handle as DecodedHandle>::Descriptor>
where Self: Sized + 'static, Self::FramePool: Sized + 'static, Self::Handle: 'static,

Transforms the decoder into a StatelessVideoDecoder trait object.

All decoders going through this method present the same virtual interface when they return. This is useful in order avoid monomorphization of application code that can control decoders using various codecs or backends.

Implementors§