pub struct FlacDecoder {
pub stream_info: Option<FlacStreamInfo>,
pub comment: Option<FlacVorbisComment>,
/* private fields */
}Expand description
FLAC audio decoder.
Fields§
§stream_info: Option<FlacStreamInfo>Stream info parsed from the stream header.
comment: Option<FlacVorbisComment>Vorbis comment block (if present in the stream).
Implementations§
Source§impl FlacDecoder
impl FlacDecoder
Sourcepub fn stream_info(&self) -> Option<&FlacStreamInfo>
pub fn stream_info(&self) -> Option<&FlacStreamInfo>
Return a reference to the parsed stream info, if available.
Sourcepub fn comment_block(&self) -> Option<&FlacVorbisComment>
pub fn comment_block(&self) -> Option<&FlacVorbisComment>
Return a reference to the parsed Vorbis comment block, if available.
Sourcepub fn parse_metadata(&mut self, data: &[u8]) -> Result<(), CodecError>
pub fn parse_metadata(&mut self, data: &[u8]) -> Result<(), CodecError>
Parse all FLAC metadata blocks from the beginning of a FLAC byte stream.
Reads and parses:
- The
fLaCstream marker - All metadata blocks until the last-block flag is set
- STREAMINFO (block type 0) — mandatory first block
- VORBIS_COMMENT (block type 4) — optional
§Errors
Returns CodecError::InvalidData if the magic bytes are missing, STREAMINFO
is absent or malformed, or any block header is truncated.
Sourcepub fn probe(data: &[u8]) -> Result<FlacStreamInfo, CodecError>
pub fn probe(data: &[u8]) -> Result<FlacStreamInfo, CodecError>
Quick-probe a FLAC byte stream: validates the magic bytes and parses the mandatory STREAMINFO block, returning the stream info without retaining state.
§Errors
Returns CodecError::InvalidData if the magic is missing or STREAMINFO is
malformed.
Sourcepub fn parse_stream_header(&mut self, data: &[u8]) -> CodecResult<usize>
pub fn parse_stream_header(&mut self, data: &[u8]) -> CodecResult<usize>
Parse the FLAC stream header from the beginning of a FLAC byte stream.
Must be called once before decode_frame.
§Errors
Returns CodecError::InvalidData if the magic bytes or STREAMINFO are malformed.
Sourcepub fn decode_frame(&self, data: &[u8]) -> CodecResult<(DecodedBlock, usize)>
pub fn decode_frame(&self, data: &[u8]) -> CodecResult<(DecodedBlock, usize)>
Decode a single FLAC frame from the given byte slice.
Returns (decoded_block, bytes_consumed).
§Errors
Returns CodecError::InvalidData on malformed frame data.
Sourcepub fn decode_stream(&mut self, data: &[u8]) -> CodecResult<Vec<i32>>
pub fn decode_stream(&mut self, data: &[u8]) -> CodecResult<Vec<i32>>
Decode all frames from a complete FLAC byte stream (header + frames).
Returns interleaved i32 PCM samples for the entire stream.
§Errors
Returns CodecError::InvalidData if the stream is malformed.
Auto Trait Implementations§
impl Freeze for FlacDecoder
impl RefUnwindSafe for FlacDecoder
impl Send for FlacDecoder
impl Sync for FlacDecoder
impl Unpin for FlacDecoder
impl UnsafeUnpin for FlacDecoder
impl UnwindSafe for FlacDecoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more