Skip to main content

AacEncoder

Struct AacEncoder 

Source
pub struct AacEncoder { /* private fields */ }
Expand description

AAC-LC encoder (ADTS output). Same interleaved-PCM conventions as Encoder; one encode call consumes samples_per_frame() (1024) samples per channel and returns one ADTS frame. flush returns the two tail frames and must be called at end of stream (encoder delay: 2048 samples; the first frame is a silence priming frame).

Implementations§

Source§

impl AacEncoder

Source

pub fn new( sample_rate: u32, channels: u32, bitrate: u32, quality: u32, ) -> Result<Self, &'static str>

quality: 0 = speed, 1 = normal (default), 2 = best.

Source

pub fn with_options( sample_rate: u32, channels: u32, bitrate: u32, quality: u32, vbr_quality: Option<u32>, ) -> Result<Self, &'static str>

Like AacEncoder::new but with vbr_quality Some(0..9) to select constant-quality VBR (None = CBR at bitrate).

Source

pub fn samples_per_frame(&self) -> usize

Source

pub fn channels(&self) -> usize

Source

pub fn encode(&mut self, pcm: &[i16]) -> Vec<u8> ⓘ

Encode one frame of interleaved 16-bit PCM (zero-padded if short).

Source

pub fn flush(&mut self) -> Vec<u8> ⓘ

Flush the encoder, returning the two tail ADTS frames.

Trait Implementations§

Source§

impl Drop for AacEncoder

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for AacEncoder

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, 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, 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.