Skip to main content

Module mp3

Module mp3 

Source
Expand description

MP3 decoder wrapping the minimp3 crate (FFI to the MIT-licensed minimp3 C library).

Squad-23 calls this through the AudioDecoder trait. The minimp3 crate works against an io::Read source, so we adapt the packet-in / frames-out trait surface with an internal byte buffer the caller appends to with each decode call.

§PTS handling

Each MP3 layer-III frame produces a fixed number of samples per channel — 1152 for MPEG-1, 576 for MPEG-2/2.5 (see ISO/IEC 11172-3 §2.4.1.5 + ISO/IEC 13818-3 §2.4.1.5). We accumulate the per-channel sample count and convert to microseconds using the frame’s reported sample rate. The caller-supplied PTS on the first non-empty decode call seeds the per-stream clock; subsequent samples step forward by frame_samples / sample_rate microseconds.

Structs§

Mp3Decoder