pub struct MediaSource<R, S = Seekable> { /* private fields */ }Expand description
MediaSource represents a media data source that can be parsed by
MediaParser.
-
Use
MediaSource::file_pathorMediaSource::fileto create a MediaSource from a file -
Use
MediaSource::tcp_streamto create a MediaSource from aTcpStream -
In other cases:
-
Use
MediaSource::seekableto create a MediaSource from aRead + Seek -
Use
MediaSource::unseekableto create a MediaSource from a reader that only implRead
-
Note: Please use MediaSource::seekable in preference to MediaSource::unseekable,
since the former is more efficient when the parser needs to skip a large number of bytes.
Passing in a BufRead should be avoided because MediaParser comes with
its own buffer management and the buffers can be shared between multiple
parsing tasks, thus avoiding frequent memory allocations.
Implementations§
Source§impl<R: Read, S: Skip<R>> MediaSource<R, S>
impl<R: Read, S: Skip<R>> MediaSource<R, S>
Source§impl<R: Read + Seek> MediaSource<R, Seekable>
impl<R: Read + Seek> MediaSource<R, Seekable>
Sourcepub fn seekable(reader: R) -> Result<Self>
pub fn seekable(reader: R) -> Result<Self>
Use MediaSource::seekable to create a MediaSource from a Read + Seek
Note: Please use MediaSource::seekable in preference to MediaSource::unseekable,
since the former is more efficient when the parser needs to skip a large number of bytes.
Source§impl<R: Read> MediaSource<R, Unseekable>
impl<R: Read> MediaSource<R, Unseekable>
Sourcepub fn unseekable(reader: R) -> Result<Self>
pub fn unseekable(reader: R) -> Result<Self>
Use MediaSource::unseekable to create a MediaSource from a
reader that only impl Read
Note: Please use MediaSource::seekable in preference to MediaSource::unseekable,
since the former is more efficient when the parser needs to skip a large number of bytes.