pub struct ProjectionEncoderRef<'a> { /* private fields */ }Expand description
Borrowed wrapper around a projection encoder state.
Implementations§
Source§impl<'a> ProjectionEncoderRef<'a>
impl<'a> ProjectionEncoderRef<'a>
Sourcepub unsafe fn from_raw(
ptr: *mut OpusProjectionEncoder,
sample_rate: SampleRate,
channels: u8,
streams: u8,
coupled_streams: u8,
) -> Self
pub unsafe fn from_raw( ptr: *mut OpusProjectionEncoder, sample_rate: SampleRate, channels: u8, streams: u8, coupled_streams: u8, ) -> Self
Wrap an externally-initialized projection encoder without taking ownership.
§Safety
ptrmust point to valid, initialized memory of at leastProjectionEncoder::size()bytesptrmust be aligned to at leastalign_of::<usize>()(malloc-style alignment)- The memory must remain valid for the lifetime
'a - Caller is responsible for freeing the memory after this wrapper is dropped
Use ProjectionEncoder::init_in_place to initialize the memory before calling this.
Sourcepub fn init_in(
buf: &'a mut AlignedBuffer,
sample_rate: SampleRate,
channels: u8,
mapping_family: i32,
application: Application,
) -> Result<Self>
pub fn init_in( buf: &'a mut AlignedBuffer, sample_rate: SampleRate, channels: u8, mapping_family: i32, application: Application, ) -> Result<Self>
Initialize and wrap an externally allocated buffer.
§Errors
Returns Error::BadArg if the buffer is too small, or a mapped libopus error.
Methods from Deref<Target = ProjectionEncoder>§
Sourcepub fn encode(
&mut self,
pcm: &[i16],
frame_size_per_ch: usize,
out: &mut [u8],
) -> Result<usize>
pub fn encode( &mut self, pcm: &[i16], frame_size_per_ch: usize, out: &mut [u8], ) -> Result<usize>
Encode interleaved i16 PCM.
§Errors
Returns Error::InvalidState if the encoder handle was freed, Error::BadArg for
buffer/layout issues, the libopus error mapped via Error::from_code, or
Error::InternalError if libopus reports an impossible packet length.
Sourcepub fn encode_float(
&mut self,
pcm: &[f32],
frame_size_per_ch: usize,
out: &mut [u8],
) -> Result<usize>
pub fn encode_float( &mut self, pcm: &[f32], frame_size_per_ch: usize, out: &mut [u8], ) -> Result<usize>
Encode interleaved f32 PCM.
§Errors
Returns Error::InvalidState if the encoder handle was freed, Error::BadArg for
buffer/layout issues, the libopus error mapped via Error::from_code, or
Error::InternalError if libopus reports an impossible packet length.
Sourcepub fn set_bitrate(&mut self, bitrate: Bitrate) -> Result<()>
pub fn set_bitrate(&mut self, bitrate: Bitrate) -> Result<()>
Set target bitrate for the encoder.
§Errors
Returns Error::InvalidState if the encoder handle is invalid or a mapped libopus error.
Sourcepub fn bitrate(&mut self) -> Result<Bitrate>
pub fn bitrate(&mut self) -> Result<Bitrate>
Query current bitrate configuration.
§Errors
Returns Error::InvalidState if the encoder handle is invalid or a mapped libopus error.
Sourcepub fn demixing_matrix_size(&mut self) -> Result<i32>
pub fn demixing_matrix_size(&mut self) -> Result<i32>
Size in bytes of the current demixing matrix.
§Errors
Returns Error::InvalidState if the encoder handle is invalid or a mapped libopus error.
Sourcepub fn demixing_matrix_gain(&mut self) -> Result<i32>
pub fn demixing_matrix_gain(&mut self) -> Result<i32>
Gain (in Q8 dB) of the demixing matrix.
§Errors
Returns Error::InvalidState if the encoder handle is invalid or a mapped libopus error.
Sourcepub fn write_demixing_matrix(&mut self, out: &mut [u8]) -> Result<usize>
pub fn write_demixing_matrix(&mut self, out: &mut [u8]) -> Result<usize>
Copy the demixing matrix into out and return the number of bytes written.
§Errors
Returns Error::InvalidState if the encoder handle is invalid, Error::BufferTooSmall
when out cannot fit the matrix, a mapped libopus error, or Error::InternalError
when libopus reports an invalid matrix size.
Sourcepub fn demixing_matrix_bytes(&mut self) -> Result<Vec<u8>>
pub fn demixing_matrix_bytes(&mut self) -> Result<Vec<u8>>
Convenience helper returning the demixing matrix as a newly allocated buffer.
§Errors
Propagates errors from Self::demixing_matrix_size and Self::write_demixing_matrix,
including Error::InternalError if libopus reports impossible sizes.
Sourcepub fn coupled_streams(&self) -> u8
pub fn coupled_streams(&self) -> u8
Number of coupled (stereo) coded streams.
Sourcepub fn sample_rate(&self) -> SampleRate
pub fn sample_rate(&self) -> SampleRate
Encoder sample rate.