Struct caf::CafPacketReader
[−]
[src]
pub struct CafPacketReader<T> where
T: Read + Seek, { pub audio_desc: AudioDescription, pub packet_table: Option<PacketTable>, pub chunks: Vec<CafChunk>, pub edit_count: u32, // some fields omitted }
High level Packet reading
Provides a very convenient iterator over the packets of the audio chunk.
Fields
audio_desc: AudioDescription
packet_table: Option<PacketTable>
chunks: Vec<CafChunk>
edit_count: u32
The edit count value stored in the audio chunk.
Methods
impl<T> CafPacketReader<T> where
T: Read + Seek,
[src]
T: Read + Seek,
fn new(rdr: T, filter_by: Vec<ChunkType>) -> Result<Self, CafError>
Creates a new CAF packet reader struct from a given reader.
With the filter_by
argument you can pass a list of chunk types
that are important for you. You shouldn't specify three chunk
types though: AudioData
, AudioDescription
and PacketTable
.
These are implicitly retrieved, and you can extract the content
through iterating over the packets (which are all small parts of
the AudioData
chunk), and through the audio_desc
and packet_table
members.
Equal to calling CafChunkReader::new
and passing its result to
from_chunk_reader
.
fn from_chunk_reader(
ch_rdr: CafChunkReader<T>,
filter_by: Vec<ChunkType>
) -> Result<Self, CafError>
ch_rdr: CafChunkReader<T>,
filter_by: Vec<ChunkType>
) -> Result<Self, CafError>
Creates a new CAF packet reader struct from a given chunk reader.
With the filter_by
argument you can pass a list of chunk types
that are important for you. You shouldn't specify three chunk
types though: AudioData
, AudioDescription
and PacketTable
.
These are implicitly retrieved, and you can extract the content
through iterating over the packets (which are all small parts of
the AudioData
chunk), and through the audio_desc
and packet_table
members.
fn into_inner(self) -> CafChunkReader<T>
fn packet_size_is_constant(&self) -> bool
Returns whether the size of the packets doesn't change
Some formats have a constant, not changing packet size (mostly the uncompressed ones).
fn next_packet_size(&self) -> Option<usize>
Returns the size of the next packet in bytes.
Returns None if all packets were read, Some(_) otherwise.
Very useful if you want to allocate the packet slice yourself.
fn next_packet(&mut self) -> Result<Option<Vec<u8>>, CafError>
Read one packet from the audio chunk
Returns Ok(Some(v)) if the next packet could be read successfully, Ok(None) if its the last chunk.
fn read_packet_into(&mut self, data: &mut [u8]) -> Result<(), CafError>
Read one packet from the audio chunk into a pre-allocated array
The method doesn't check whether the size of the passed slice matches
the actual next packet length, it uses the length blindly.
For correct operation, only use sizes returned from the
next_packet_size
function, and only if it didn't return None
.
fn get_packet_count(&self) -> Option<usize>
Gets the number of packets if its known.
fn get_packet_idx(&self) -> usize
Returns the index of the currently read packet
fn seek_to_packet(&mut self, packet_idx: usize) -> Result<(), CafError>
Seeks to the packet with the given index
This function never has been tested. If there are bugs please report them.