pub struct Encoder { /* private fields */ }
Expand description
An Opus encoder with associated state.
Implementations§
Source§impl Encoder
impl Encoder
Sourcepub fn new(
sample_rate: u32,
channels: Channels,
mode: Application,
) -> Result<Encoder>
pub fn new( sample_rate: u32, channels: Channels, mode: Application, ) -> Result<Encoder>
Create and initialize an encoder.
Sourcepub fn encode(&mut self, input: &[i16], output: &mut [u8]) -> Result<usize>
pub fn encode(&mut self, input: &[i16], output: &mut [u8]) -> Result<usize>
Encode an Opus frame.
Sourcepub fn encode_float(
&mut self,
input: &[f32],
output: &mut [u8],
) -> Result<usize>
pub fn encode_float( &mut self, input: &[f32], output: &mut [u8], ) -> Result<usize>
Encode an Opus frame from floating point input.
Sourcepub fn encode_vec(&mut self, input: &[i16], max_size: usize) -> Result<Vec<u8>>
pub fn encode_vec(&mut self, input: &[i16], max_size: usize) -> Result<Vec<u8>>
Encode an Opus frame to a new buffer.
Sourcepub fn encode_vec_float(
&mut self,
input: &[f32],
max_size: usize,
) -> Result<Vec<u8>>
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.
Sourcepub fn reset_state(&mut self) -> Result<()>
pub fn reset_state(&mut self) -> Result<()>
Reset the codec state to be equivalent to a freshly initialized state.
Sourcepub fn get_final_range(&mut self) -> Result<u32>
pub fn get_final_range(&mut self) -> Result<u32>
Get the final range of the codec’s entropy coder.
Sourcepub fn get_bandwidth(&mut self) -> Result<Bandwidth>
pub fn get_bandwidth(&mut self) -> Result<Bandwidth>
Get the encoder’s configured bandpass.
Sourcepub fn get_sample_rate(&mut self) -> Result<u32>
pub fn get_sample_rate(&mut self) -> Result<u32>
Get the samping rate the encoder was intialized with.
Sourcepub fn set_bitrate(&mut self, value: Bitrate) -> Result<()>
pub fn set_bitrate(&mut self, value: Bitrate) -> Result<()>
Set the encoder’s bitrate.
Sourcepub fn get_bitrate(&mut self) -> Result<Bitrate>
pub fn get_bitrate(&mut self) -> Result<Bitrate>
Get the encoder’s bitrate.
Sourcepub fn set_vbr_constraint(&mut self, vbr: bool) -> Result<()>
pub fn set_vbr_constraint(&mut self, vbr: bool) -> Result<()>
Enable or disable constrained VBR.
Sourcepub fn get_vbr_constraint(&mut self) -> Result<bool>
pub fn get_vbr_constraint(&mut self) -> Result<bool>
Determine if constrained VBR is enabled.
Sourcepub fn set_inband_fec(&mut self, value: bool) -> Result<()>
pub fn set_inband_fec(&mut self, value: bool) -> Result<()>
Configures the encoder’s use of inband forward error correction (FEC).
Sourcepub fn get_inband_fec(&mut self) -> Result<bool>
pub fn get_inband_fec(&mut self) -> Result<bool>
Gets encoder’s configured use of inband forward error correction.
Sourcepub fn set_packet_loss_perc(&mut self, value: i32) -> Result<()>
pub fn set_packet_loss_perc(&mut self, value: i32) -> Result<()>
Sets the encoder’s expected packet loss percentage.
Sourcepub fn get_packet_loss_perc(&mut self) -> Result<i32>
pub fn get_packet_loss_perc(&mut self) -> Result<i32>
Gets the encoder’s expected packet loss percentage.
Sourcepub fn get_lookahead(&mut self) -> Result<i32>
pub fn get_lookahead(&mut self) -> Result<i32>
Gets the total samples of delay added by the entire codec.