Struct symphonia_core::io::MediaSourceStream
source · pub struct MediaSourceStream { /* private fields */ }
Expand description
MediaSourceStream
is the main reader type for Symphonia.
By using type erasure and dynamic dispatch, MediaSourceStream
wraps and hides the inner
reader from the consumer, allowing any typical Read
er to be used with Symphonia in a generic
way, selectable at runtime.
MediaSourceStream
is designed to provide speed and flexibility in a number of challenging I/O
scenarios.
First, to minimize system call and dynamic dispatch overhead on the inner reader, and to
amortize that overhead over many bytes, MediaSourceStream
implements an exponentially growing
read-ahead buffer. The read-ahead length starts at 1kB, and doubles in length as more sequential
reads are performed until it reaches 32kB. Growing the read-ahead length over time reduces the
excess data buffered on consecutive seek()
calls.
Second, to better support non-seekable sources, MediaSourceStream
implements a configurable
length buffer cache. By default, the buffer caches allows backtracking by up-to the minimum of
either buffer_len - 32kB
or the total number of bytes read since instantiation or the last
buffer cache invalidation. Note that regular a seek()
will invalidate the buffer cache.
Implementations§
source§impl MediaSourceStream
impl MediaSourceStream
pub fn new( source: Box<dyn MediaSource>, options: MediaSourceStreamOptions, ) -> Self
Trait Implementations§
source§impl MediaSource for MediaSourceStream
impl MediaSource for MediaSourceStream
source§impl Read for MediaSourceStream
impl Read for MediaSourceStream
source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read
, except that it reads into a slice of buffers. Read moresource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf
. Read more1.0.0 · source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf
. Read more1.6.0 · source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf
. Read moresource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)cursor
. Read more1.0.0 · source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read
. Read moresource§impl ReadBytes for MediaSourceStream
impl ReadBytes for MediaSourceStream
source§fn read_byte(&mut self) -> Result<u8>
fn read_byte(&mut self) -> Result<u8>
source§fn read_double_bytes(&mut self) -> Result<[u8; 2]>
fn read_double_bytes(&mut self) -> Result<[u8; 2]>
source§fn read_triple_bytes(&mut self) -> Result<[u8; 3]>
fn read_triple_bytes(&mut self) -> Result<[u8; 3]>
source§fn read_quad_bytes(&mut self) -> Result<[u8; 4]>
fn read_quad_bytes(&mut self) -> Result<[u8; 4]>
source§fn read_buf(&mut self, buf: &mut [u8]) -> Result<usize>
fn read_buf(&mut self, buf: &mut [u8]) -> Result<usize>
source§fn read_buf_exact(&mut self, buf: &mut [u8]) -> Result<()>
fn read_buf_exact(&mut self, buf: &mut [u8]) -> Result<()>
source§fn scan_bytes_aligned<'a>(
&mut self,
_: &[u8],
_: usize,
_: &'a mut [u8],
) -> Result<&'a mut [u8]>
fn scan_bytes_aligned<'a>( &mut self, _: &[u8], _: usize, _: &'a mut [u8], ) -> Result<&'a mut [u8]>
source§fn ignore_bytes(&mut self, count: u64) -> Result<()>
fn ignore_bytes(&mut self, count: u64) -> Result<()>
source§fn read_u8(&mut self) -> Result<u8>
fn read_u8(&mut self) -> Result<u8>
source§fn read_i8(&mut self) -> Result<i8>
fn read_i8(&mut self) -> Result<i8>
source§fn read_u16(&mut self) -> Result<u16>
fn read_u16(&mut self) -> Result<u16>
source§fn read_i16(&mut self) -> Result<i16>
fn read_i16(&mut self) -> Result<i16>
source§fn read_be_u16(&mut self) -> Result<u16>
fn read_be_u16(&mut self) -> Result<u16>
source§fn read_be_i16(&mut self) -> Result<i16>
fn read_be_i16(&mut self) -> Result<i16>
source§fn read_u24(&mut self) -> Result<u32>
fn read_u24(&mut self) -> Result<u32>
source§fn read_i24(&mut self) -> Result<i32>
fn read_i24(&mut self) -> Result<i32>
source§fn read_be_u24(&mut self) -> Result<u32>
fn read_be_u24(&mut self) -> Result<u32>
source§fn read_be_i24(&mut self) -> Result<i32>
fn read_be_i24(&mut self) -> Result<i32>
source§fn read_u32(&mut self) -> Result<u32>
fn read_u32(&mut self) -> Result<u32>
source§fn read_i32(&mut self) -> Result<i32>
fn read_i32(&mut self) -> Result<i32>
source§fn read_be_u32(&mut self) -> Result<u32>
fn read_be_u32(&mut self) -> Result<u32>
source§fn read_be_i32(&mut self) -> Result<i32>
fn read_be_i32(&mut self) -> Result<i32>
source§fn read_u64(&mut self) -> Result<u64>
fn read_u64(&mut self) -> Result<u64>
source§fn read_i64(&mut self) -> Result<i64>
fn read_i64(&mut self) -> Result<i64>
source§fn read_be_u64(&mut self) -> Result<u64>
fn read_be_u64(&mut self) -> Result<u64>
source§fn read_be_i64(&mut self) -> Result<i64>
fn read_be_i64(&mut self) -> Result<i64>
source§fn read_f32(&mut self) -> Result<f32>
fn read_f32(&mut self) -> Result<f32>
source§fn read_be_f32(&mut self) -> Result<f32>
fn read_be_f32(&mut self) -> Result<f32>
source§fn read_f64(&mut self) -> Result<f64>
fn read_f64(&mut self) -> Result<f64>
source§fn read_be_f64(&mut self) -> Result<f64>
fn read_be_f64(&mut self) -> Result<f64>
source§fn read_boxed_slice(&mut self, len: usize) -> Result<Box<[u8]>>
fn read_boxed_slice(&mut self, len: usize) -> Result<Box<[u8]>>
source§impl Seek for MediaSourceStream
impl Seek for MediaSourceStream
source§fn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
1.55.0 · source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
source§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
seek_stream_len
)source§impl SeekBuffered for MediaSourceStream
impl SeekBuffered for MediaSourceStream
source§fn ensure_seekback_buffer(&mut self, len: usize)
fn ensure_seekback_buffer(&mut self, len: usize)
len
bytes will be available for backwards seeking if len
bytes have been
previously read.