Skip to main content

TrackSampleProvider

Struct TrackSampleProvider 

Source
pub struct TrackSampleProvider<S> { /* private fields */ }
Expand description

A SampleProvider that reads a video track’s compressed bytes from a ByteSource on demand, holding only track’s index (and whatever S itself caches) rather than every sample’s bytes.

Built from a container-neutral Track index, so it works over MP4 and WebM alike.

S::read_at’s future must resolve the first time it is polled: this provider is used from ExactFrameReader::get, which is synchronous, so Self::read polls the read once and reports ErrorKind::Unsupported rather than blocking if the source does not finish immediately. MemorySource and a CachingByteSource wrapping one both satisfy this; a source that genuinely waits on I/O (a network fetch, for example) needs its own asynchronous reader rather than this provider.

S must be Send so the provider - and a reader built over it - can be moved to a decode thread, matching SampleProvider’s own requirement.

Implementations§

Source§

impl<S: ByteSource + Send> TrackSampleProvider<S>

Source

pub fn new(track: Track, source: S) -> Result<Self>

Fails if track is not a video track; reads no sample data.

Source

pub fn track(&self) -> &Track

Source

pub fn source(&self) -> &S

Source

pub fn into_source(self) -> S

Trait Implementations§

Source§

impl<S: ByteSource + Send> SampleProvider for TrackSampleProvider<S>

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.
Source§

fn is_empty(&self) -> bool

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.