Skip to main content

Config

Struct Config 

Source
#[non_exhaustive]
pub struct Config { pub profile: u8, pub sample_rate: u32, pub channel_count: u32, }
Expand description

Typed AAC configuration mirroring the relevant fields of an AudioSpecificConfig.

Marked #[non_exhaustive]: build one with new or parse.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§profile: u8

The leading audioObjectType: 2 for AAC-LC, 5 for HE-AAC (SBR), 29 for HE-AACv2 (PS).

§sample_rate: u32

The decoded output rate: under SBR, the extension rate rather than the core’s.

§channel_count: u32

The decoded output channels: two under PS, which a mono core carries.

Implementations§

Source§

impl Config

Source

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.

Source

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.

Source

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

Source§

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.

Source§

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more