Struct lewton::inside_ogg::OggStreamReader
source · pub struct OggStreamReader<T: Read + Seek> {
pub ident_hdr: IdentHeader,
pub comment_hdr: CommentHeader,
pub setup_hdr: SetupHeader,
/* private fields */
}
Expand description
Reading ogg/vorbis files or streams
This is a small helper struct to help reading ogg/vorbis files or streams in that format.
It only supports the main use case of pure audio ogg files streams. Reading a file where vorbis is only one of multiple streams, like in the case of ogv, is not supported.
If you need support for this, you need to use the lower level methods instead.
Fields§
§ident_hdr: IdentHeader
§comment_hdr: CommentHeader
§setup_hdr: SetupHeader
Implementations§
source§impl<T: Read + Seek> OggStreamReader<T>
impl<T: Read + Seek> OggStreamReader<T>
sourcepub fn new(rdr: T) -> Result<Self, VorbisError>
pub fn new(rdr: T) -> Result<Self, VorbisError>
Constructs a new OggStreamReader from a given implementation of Read + Seek
.
Please note that this function doesn’t work well with async
I/O. In order to support this use case, enable the async_ogg
feature,
and use the HeadersReader
struct instead.
sourcepub fn from_ogg_reader(rdr: PacketReader<T>) -> Result<Self, VorbisError>
pub fn from_ogg_reader(rdr: PacketReader<T>) -> Result<Self, VorbisError>
Constructs a new OggStreamReader from a given Ogg PacketReader.
The new
function is a nice wrapper around this function that
also creates the ogg reader.
Please note that this function doesn’t work well with async
I/O. In order to support this use case, enable the async_ogg
feature,
and use the HeadersReader
struct instead.
pub fn into_inner(self) -> PacketReader<T>
sourcepub fn read_dec_packet(&mut self) -> Result<Option<Vec<Vec<i16>>>, VorbisError>
pub fn read_dec_packet(&mut self) -> Result<Option<Vec<Vec<i16>>>, VorbisError>
Reads and decompresses an audio packet from the stream.
On read errors, it returns Err(e) with the error.
On success, it either returns None, when the end of the stream has been reached, or Some(packet_data), with the data of the decompressed packet.
sourcepub fn read_dec_packet_generic<S: Samples>(
&mut self
) -> Result<Option<S>, VorbisError>
pub fn read_dec_packet_generic<S: Samples>( &mut self ) -> Result<Option<S>, VorbisError>
Reads and decompresses an audio packet from the stream (generic).
On read errors, it returns Err(e) with the error.
On success, it either returns None, when the end of the stream has been reached, or Some(packet_data), with the data of the decompressed packet.
sourcepub fn read_dec_packet_itl(&mut self) -> Result<Option<Vec<i16>>, VorbisError>
pub fn read_dec_packet_itl(&mut self) -> Result<Option<Vec<i16>>, VorbisError>
Reads and decompresses an audio packet from the stream (interleaved).
On read errors, it returns Err(e) with the error.
On success, it either returns None, when the end of the stream has been reached, or Some(packet_data), with the data of the decompressed packet.
Unlike read_dec_packet
, this function returns the
interleaved samples.
sourcepub fn stream_serial(&self) -> u32
pub fn stream_serial(&self) -> u32
Returns the stream serial of the current stream
The stream serial can change in chained ogg files.
sourcepub fn get_last_absgp(&self) -> Option<u64>
pub fn get_last_absgp(&self) -> Option<u64>
Returns the absolute granule position of the last read page.
In the case of ogg/vorbis, the absolute granule position is given as number of PCM samples, on a per channel basis.
sourcepub fn seek_absgp_pg(&mut self, absgp: u64) -> Result<(), VorbisError>
pub fn seek_absgp_pg(&mut self, absgp: u64) -> Result<(), VorbisError>
Seeks to the specified absolute granule position, with a page granularity.
The granularity is per-page, and the obtained position is then <= the seeked absgp.
In the case of ogg/vorbis, the absolute granule position is given as number of PCM samples, on a per channel basis.