pub struct Encoder { /* private fields */ }Expand description
LAME Encoder.
Implementations§
Source§impl Encoder
impl Encoder
Sourcepub fn sample_rate(&self) -> u32
pub fn sample_rate(&self) -> u32
Returns sample rate.
Sourcepub fn num_channels(&self) -> u8
pub fn num_channels(&self) -> u8
Returns number of channels.
Sourcepub fn is_lame_tag_written(&self) -> bool
pub fn is_lame_tag_written(&self) -> bool
Returns indication whether encoder is configured to write LAME tag
Sourcepub fn id3v2_tag_size(&self) -> usize
pub fn id3v2_tag_size(&self) -> usize
Returns size of ths Id3Tag written, if any
Sourcepub fn lame_tag_size(&self) -> usize
pub fn lame_tag_size(&self) -> usize
Retrieves size of the lame tag
Sourcepub fn lame_tag_encode(
&self,
output: &mut [MaybeUninit<u8>],
) -> Option<NonZeroUsize>
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)
Sourcepub fn lame_tag_encode_to_vec(
&self,
output: &mut Vec<u8>,
) -> Option<NonZeroUsize>
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
Sourcepub fn encode(
&mut self,
input: impl EncoderInput,
output: &mut [MaybeUninit<u8>],
) -> Result<usize, EncodeError>
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:
input- Data input. Can be MonoPcm, DualPcm or InterleavedPcmoutput- Output buffer to write into.
§Result:
On success, returns number of bytes written (can be 0). Otherwise returns error indicating potential issue.
Sourcepub fn encode_to_vec(
&mut self,
input: impl EncoderInput,
output: &mut Vec<u8>,
) -> Result<usize, EncodeError>
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()
Sourcepub fn flush<T: EncoderFlush>(
&mut self,
output: &mut [MaybeUninit<u8>],
) -> Result<usize, EncodeError>
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.
Sourcepub fn flush_to_vec<T: EncoderFlush>(
&mut self,
output: &mut Vec<u8>,
) -> Result<usize, EncodeError>
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§
impl Send for Encoder
According to LAME 3.99.5 HACKING, it is thread-safe.
impl Sync for Encoder
According to LAME 3.99.5 HACKING, it is thread-safe.