Skip to main content

SampleProvider

Trait SampleProvider 

Source
pub trait SampleProvider: Send {
    // Required methods
    fn len(&self) -> usize;
    fn is_random_access(&self, decode_index: usize) -> bool;
    fn presentation_index(&self, decode_index: usize) -> FrameIndex;
    fn read(&self, decode_index: usize) -> Result<Cow<'_, [u8]>>;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Supplies ExactFrameReader with compressed video samples by decode index, so a reader does not have to own every sample of a track up front.

An owned Vec<EncodedVideoSample> implements this directly and is what ExactFrameReader::new wraps, so that constructor and its callers are unchanged. ExactFrameReader::from_provider accepts any other implementation, such as one that reads through a container track’s index and a crate::io::ByteSource on demand, holding only the index and a bounded cache of compressed bytes rather than the whole track.

len, is_random_access and presentation_index answer from the index alone and must not read sample data; only Self::read may do that, and only for the one sample it is asked for.

Implementations used from a decode thread must be Send, matching VideoDecoder’s own requirement.

Required Methods§

Source

fn len(&self) -> usize

The number of samples, in decode order.

Source

fn is_random_access(&self, decode_index: usize) -> bool

Source

fn presentation_index(&self, decode_index: usize) -> FrameIndex

Source

fn read(&self, decode_index: usize) -> Result<Cow<'_, [u8]>>

Returns the compressed bytes of one decode-order sample.

Provided Methods§

Source

fn is_empty(&self) -> bool

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl SampleProvider for Vec<EncodedVideoSample>

Source§

fn len(&self) -> usize

Source§

fn is_random_access(&self, decode_index: usize) -> bool

Source§

fn presentation_index(&self, decode_index: usize) -> FrameIndex

Source§

fn read(&self, decode_index: usize) -> Result<Cow<'_, [u8]>>

Implementors§