Skip to main content

Encoder

Struct Encoder 

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

LAME Encoder.

Implementations§

Source§

impl Encoder

Source

pub fn sample_rate(&self) -> u32

Returns sample rate.

Source

pub fn num_channels(&self) -> u8

Returns number of channels.

Source

pub fn is_lame_tag_written(&self) -> bool

Returns indication whether encoder is configured to write LAME tag

Source

pub fn id3v2_tag_size(&self) -> usize

Returns size of ths Id3Tag written, if any

Source

pub fn lame_tag_size(&self) -> usize

Retrieves size of the lame tag

Source

pub fn lame_tag_encode( &self, output: &mut [MaybeUninit<u8>], ) -> Option<NonZeroUsize>

Attempts to write lame tag into output returning number of written bytes in case of success

Note that if you write Id3Tag you must not write this tag at the start. Instead you must insert Lame Tag after Id3Tag position.

To determine where Id3Tag ends in output stream, you can use Encoder::id3v2_tag_size which returns full size of Id3Tag metadata written (therefore indicating where actual mp3 content is starting)

Source

pub fn lame_tag_encode_to_vec( &self, output: &mut Vec<u8>, ) -> Option<NonZeroUsize>

Attempts to write lame tag into output returning number of written bytes in case of success

Refer to Encoder::lame_tag_encode for details

Source

pub fn encode( &mut self, input: impl EncoderInput, output: &mut [MaybeUninit<u8>], ) -> Result<usize, EncodeError>

Attempts to encode PCM data, writing whatever available onto output buffer

§Arguments:
§Result:

On success, returns number of bytes written (can be 0). Otherwise returns error indicating potential issue.

Source

pub fn encode_to_vec( &mut self, input: impl EncoderInput, output: &mut Vec<u8>, ) -> Result<usize, EncodeError>

Attempts to encode PCM data, writing whatever available onto output buffer

output size is adjusted on success only

Refer for details to encode()

Source

pub fn flush<T: EncoderFlush>( &mut self, output: &mut [MaybeUninit<u8>], ) -> Result<usize, EncodeError>

Attempts flush all data, writing whatever available onto output buffer Padding with 0 to complete MP3

§Type:
  • FlushNoGap - performs flush, using ancillary data to fill gaps;
  • FlushGap - performs flush, padding with 0;
§Arguments:
  • output - Output buffer to write into. As it is final action, you need at least 7200 bytes to hold at MP3 data.
§Result:

On success, returns number of bytes written (can be 0). Otherwise returns error indicating potential issue.

Source

pub fn flush_to_vec<T: EncoderFlush>( &mut self, output: &mut Vec<u8>, ) -> Result<usize, EncodeError>

Attempts flush all data, writing whatever available onto output buffer.

output size is adjusted on success only

Refer for details to flush()

Trait Implementations§

Source§

impl Drop for Encoder

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Encoder

According to LAME 3.99.5 HACKING, it is thread-safe.

Source§

impl Sync for Encoder

According to LAME 3.99.5 HACKING, it is thread-safe.

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.