libflo_audio/streaming/
types.rs

1//! Streaming types and enums
2
3/// Streaming decoder state
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum DecoderState {
6    /// Waiting for header data
7    WaitingForHeader,
8    /// Header parsed, waiting for TOC
9    WaitingForToc,
10    /// Ready to decode frames
11    Ready,
12    /// End of stream reached
13    Finished,
14    /// Error state
15    Error,
16}
17
18/// Audio information for streaming
19#[derive(Debug, Clone)]
20pub struct StreamingAudioInfo {
21    /// Sample rate in Hz
22    pub sample_rate: u32,
23    /// Number of channels
24    pub channels: u8,
25    /// Bits per sample
26    pub bit_depth: u8,
27    /// Total frames (if known)
28    pub total_frames: u64,
29    /// Is lossy encoding
30    pub is_lossy: bool,
31}
32
33impl StreamingAudioInfo {
34    /// Calculate duration in seconds
35    pub fn duration_secs(&self) -> f64 {
36        self.total_frames as f64
37    }
38
39    /// Calculate samples per channel
40    pub fn total_samples(&self) -> u64 {
41        self.total_frames * self.sample_rate as u64
42    }
43}