#[non_exhaustive]pub struct Config {
pub profile: u8,
pub sample_rate: u32,
pub channel_count: u32,
}Expand description
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.profile: u8The leading audioObjectType: 2 for AAC-LC, 5 for HE-AAC (SBR), 29 for HE-AACv2 (PS).
sample_rate: u32The decoded output rate: under SBR, the extension rate rather than the core’s.
channel_count: u32The decoded output channels: two under PS, which a mono core carries.
Implementations§
Source§impl Config
impl Config
Sourcepub fn new(profile: u8, sample_rate: u32, channel_count: u32) -> Self
pub fn new(profile: u8, sample_rate: u32, channel_count: u32) -> Self
A config for profile (the audioObjectType) at the decoded sample_rate and channel_count.
Sourcepub fn parse<T: Buf>(buf: &mut T) -> Result<Self>
pub fn parse<T: Buf>(buf: &mut T) -> Result<Self>
Parse an AudioSpecificConfig buffer.
Handles basic formats (object_type < 31), extended formats (object_type == 31), and explicit sample rates (freq_index == 15). The fields are bit-packed and not byte-aligned, so a bit reader is required: with an explicit 24-bit rate the channelConfiguration lands mid-byte after it. A channelConfiguration of 0 takes the count from the program config element that follows, and a reserved one is refused.
Explicit SBR and PS report what the stream plays as, the extension rate and stereo, not their AAC-LC core, whether signaled hierarchically (audioObjectType 5 or 29) or by a backward-compatible sync extension, which then reports profile 5 or 29 too. Implicit SBR, found only in band, reports the core, as does a sync extension behind fields this parser doesn’t follow. The whole buffer is consumed.
Sourcepub fn encode(&self) -> Result<Bytes>
pub fn encode(&self) -> Result<Bytes>
Encode this configuration as an AudioSpecificConfig (ISO 14496-3 §1.6.2.1).
Standard sample rates produce 2 bytes; non-standard rates fall back to the 5-byte form with an explicit 24-bit frequency. SBR and PS are signaled explicitly over an AAC-LC core at half the output rate, mono under PS. A channel count that does not pick a channelConfiguration is refused rather than written as another layout.
Trait Implementations§
Source§impl TryFrom<Config> for AudioConfig
impl TryFrom<Config> for AudioConfig
Source§fn try_from(config: Config) -> Result<Self, Self::Error>
fn try_from(config: Config) -> Result<Self, Self::Error>
Build a catalog config from a config resolved out of band (an ADTS header, gstreamer caps),
synthesizing the AudioSpecificConfig description since no verbatim bytes are available.
Refuses a channel count that does not pick a channelConfiguration, rather than describing it as another layout.