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>

source

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.

source

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.

source

pub fn into_inner(self) -> PacketReader<T>

source

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.

source

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.

source

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.

source

pub fn stream_serial(&self) -> u32

Returns the stream serial of the current stream

The stream serial can change in chained ogg files.

source

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.

source

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.

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for OggStreamReader<T>
where T: RefUnwindSafe,

§

impl<T> Send for OggStreamReader<T>
where T: Send,

§

impl<T> Sync for OggStreamReader<T>
where T: Sync,

§

impl<T> Unpin for OggStreamReader<T>
where T: Unpin,

§

impl<T> UnwindSafe for OggStreamReader<T>
where T: UnwindSafe,

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>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.