Skip to main content

TrackAudioPacketProvider

Struct TrackAudioPacketProvider 

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

An AudioPacketProvider that reads an AAC or Vorbis track’s compressed packets from a ByteSource on demand, holding only track’s index (and whatever S itself caches) rather than every packet’s bytes.

The audio counterpart of TrackSampleProvider, with the same requirement that S::read_at’s future resolve the first time it is polled: a source that suspends makes Self::read report ErrorKind::Unsupported rather than block.

Self::new builds the whole index without reading any packet. An AAC packet’s decoded interval comes from the track’s sample durations, and a Vorbis packet’s from the block sizes of it and the packet before it, which Track::vorbis_packet_heads names. An Opus packet’s interval is in its own table-of-contents byte, which only the packet has, so Opus tracks use crate::TrackSampleLoader::opus_packet_provider or Track::to_encoded_audio_samples; Self::new rejects them.

Implementations§

Source§

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

Source

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

Fails if track is not an AAC or Vorbis audio track; reads no packet 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> AudioPacketProvider for TrackAudioPacketProvider<S>

Source§

fn len(&self) -> usize

The number of packets.
Source§

fn decoded_range(&self, index: usize) -> SampleRange

Source§

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

Returns the compressed bytes of one packet.
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.