adts_core/error.rs
1//! Public error type.
2
3#![forbid(unsafe_code)]
4
5/// Errors from ADTS mux/demux.
6#[derive(Debug, thiserror::Error)]
7#[non_exhaustive]
8pub enum Error {
9 /// `sample_rate` is not one of the 13 standard ADTS rates.
10 #[error("sample rate {0} has no ADTS sampling_frequency_index")]
11 UnsupportedSampleRate(u32),
12 /// Raw AAC payload is too large: `7 + payload.len()` must fit the 13-bit `aac_frame_length` field (max 8191).
13 #[error(
14 "frame too large for the 13-bit ADTS length field: header + payload = {0} bytes (max 8191)"
15 )]
16 FrameTooLarge(usize),
17 /// The next 2 bytes are not `0xFF F*` (ADTS syncword + MPEG version/layer/protection bits).
18 #[error("bad ADTS sync word")]
19 BadSync,
20 /// `sampling_frequency_index` in the header is reserved (13/14) or "explicit frequency" (15).
21 #[error("reserved/unsupported sampling_frequency_index {0}")]
22 UnsupportedSamplingFrequencyIndex(u8),
23}