ProjectionEncoder

Struct ProjectionEncoder 

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

Safe wrapper around OpusProjectionEncoder.

Implementations§

Source§

impl ProjectionEncoder

Source

pub fn size(channels: u8, mapping_family: i32) -> Result<usize>

Size in bytes of a projection encoder state for external allocation.

§Errors

Returns Error::BadArg if the channel/mapping configuration is invalid.

Source

pub unsafe fn init_in_place( ptr: *mut OpusProjectionEncoder, sample_rate: SampleRate, channels: u8, mapping_family: i32, application: Application, ) -> Result<(u8, u8)>

Initialize a previously allocated projection encoder state.

§Safety

The caller must provide a valid pointer to ProjectionEncoder::size() bytes, aligned to at least align_of::<usize>() (malloc-style alignment).

§Errors

Returns Error::BadArg for invalid inputs or a mapped libopus error.

Source

pub fn new( sample_rate: SampleRate, channels: u8, mapping_family: i32, application: Application, ) -> Result<Self>

Create a new projection encoder using the ambisonics helper.

Returns Error::BadArg for unsupported channel/mapping combinations or propagates libopus allocation failures.

§Errors

Returns Error::BadArg for invalid arguments or the libopus error produced by the underlying create call; Error::AllocFail if libopus returns a null handle.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub const fn streams(&self) -> u8

Number of coded streams.

Source

pub const fn coupled_streams(&self) -> u8

Number of coupled (stereo) coded streams.

Source

pub const fn channels(&self) -> u8

Input channels passed to the encoder.

Source

pub const fn sample_rate(&self) -> SampleRate

Encoder sample rate.

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

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

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.