Struct Encoder

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

An Opus encoder with associated state.

Implementations§

Source§

impl Encoder

Source

pub fn new( sample_rate: u32, channels: Channels, mode: Application, ) -> Result<Encoder>

Create and initialize an encoder.

Source

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

Encode an Opus frame.

Source

pub fn encode_float( &mut self, input: &[f32], output: &mut [u8], ) -> Result<usize>

Encode an Opus frame from floating point input.

Source

pub fn encode_vec(&mut self, input: &[i16], max_size: usize) -> Result<Vec<u8>>

Encode an Opus frame to a new buffer.

Source

pub fn encode_vec_float( &mut self, input: &[f32], max_size: usize, ) -> Result<Vec<u8>>

Encode an Opus frame from floating point input to a new buffer.

Source

pub fn reset_state(&mut self) -> Result<()>

Reset the codec state to be equivalent to a freshly initialized state.

Source

pub fn get_final_range(&mut self) -> Result<u32>

Get the final range of the codec’s entropy coder.

Source

pub fn get_bandwidth(&mut self) -> Result<Bandwidth>

Get the encoder’s configured bandpass.

Source

pub fn get_sample_rate(&mut self) -> Result<u32>

Get the samping rate the encoder was intialized with.

Source

pub fn set_bitrate(&mut self, value: Bitrate) -> Result<()>

Set the encoder’s bitrate.

Source

pub fn get_bitrate(&mut self) -> Result<Bitrate>

Get the encoder’s bitrate.

Source

pub fn set_vbr(&mut self, vbr: bool) -> Result<()>

Enable or disable variable bitrate.

Source

pub fn get_vbr(&mut self) -> Result<bool>

Determine if variable bitrate is enabled.

Source

pub fn set_vbr_constraint(&mut self, vbr: bool) -> Result<()>

Enable or disable constrained VBR.

Source

pub fn get_vbr_constraint(&mut self) -> Result<bool>

Determine if constrained VBR is enabled.

Source

pub fn set_inband_fec(&mut self, value: bool) -> Result<()>

Configures the encoder’s use of inband forward error correction (FEC).

Source

pub fn get_inband_fec(&mut self) -> Result<bool>

Gets encoder’s configured use of inband forward error correction.

Source

pub fn set_packet_loss_perc(&mut self, value: i32) -> Result<()>

Sets the encoder’s expected packet loss percentage.

Source

pub fn get_packet_loss_perc(&mut self) -> Result<i32>

Gets the encoder’s expected packet loss percentage.

Source

pub fn get_lookahead(&mut self) -> Result<i32>

Gets the total samples of delay added by the entire codec.

Trait Implementations§

Source§

impl Debug for Encoder

Source§

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

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

impl Drop for Encoder

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Encoder

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.