pub struct Muxer { /* private fields */ }Expand description
Writes MPEG-1/2/2.5 Layer III frame headers for a fixed FrameHeader.
This crate frames already-encoded MPEG audio data — it does not encode PCM
into Layer III bitstreams (that is a codec’s job, out of scope for a
container/framing crate). Muxer::write_frame validates that frame_body’s
length matches what the header’s bitrate/sample-rate/padding combination
requires, so a caller cannot silently write a frame that desyncs a real decoder.
Implementations§
Source§impl Muxer
impl Muxer
Sourcepub fn new(header: FrameHeader) -> Result<Self, Error>
pub fn new(header: FrameHeader) -> Result<Self, Error>
Validate header (bitrate/sample rate must be standard Layer III values
for header.version) and start a mux session.
Sourcepub fn write_frame(
&self,
frame_body: &[u8],
padding: bool,
out: &mut Vec<u8>,
) -> Result<(), Error>
pub fn write_frame( &self, frame_body: &[u8], padding: bool, out: &mut Vec<u8>, ) -> Result<(), Error>
Append one Layer III frame (4-byte header + frame_body) to out.
frame_body must be exactly header.frame_len(padding) - 4 bytes — the
already-encoded Layer III payload for this bitrate/sample-rate/padding
combination.