Skip to main content

Mp3Encoder

Struct Mp3Encoder 

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

高级MP3编码器

Implementations§

Source§

impl Mp3Encoder

Source

pub fn new(config: Mp3EncoderConfig) -> Result<Self, EncoderError>

创建新的MP3编码器

Source

pub fn config(&self) -> &Mp3EncoderConfig

获取编码器配置

Source

pub fn samples_per_frame(&self) -> usize

获取每帧需要的样本数

Source

pub fn shine_config(&mut self) -> &mut ShineGlobalConfig

获取底层shine配置(用于高级用户直接访问)

Source

pub fn encode_interleaved( &mut self, pcm_data: &[i16], ) -> Result<Vec<Vec<u8>>, EncoderError>

编码PCM音频数据(交错格式)

§参数
  • pcm_data: 交错格式的PCM数据 (左右声道交替)
§返回值

返回编码后的MP3数据块的向量

Source

pub fn encode_separate_channels( &mut self, left_channel: &[i16], right_channel: Option<&[i16]>, ) -> Result<Vec<Vec<u8>>, EncoderError>

编码PCM音频数据(分离声道格式)

§参数
  • left_channel: 左声道数据
  • right_channel: 右声道数据(单声道时可为None)
§返回值

返回编码后的MP3数据块的向量

Source

pub fn finish(&mut self) -> Result<Vec<u8>, EncoderError>

完成编码并获取剩余数据

§返回值

返回最后的MP3数据块

Source

pub fn buffered_samples(&self) -> usize

获取缓冲区中剩余的样本数

Source

pub fn is_finished(&self) -> bool

检查编码器是否已完成

Trait Implementations§

Source§

impl Debug for Mp3Encoder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Mp3Encoder

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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.