pub struct OpusEncoder { /* private fields */ }Implementations§
Source§impl OpusEncoder
impl OpusEncoder
pub fn new_with_application( sample_rate: u32, channels: u16, application: Application, ) -> Self
Sourcepub fn new(sample_rate: u32, channels: u16) -> Self
pub fn new(sample_rate: u32, channels: u16) -> Self
Create a new Opus encoder instance.
Keep backward-compatible defaults with pre-0.3.31 behavior:
- VoIP application
- caller can provide mono PCM even when encoder is configured as stereo;
encode()duplicates mono samples to stereo.
Sourcepub fn new_default() -> Self
pub fn new_default() -> Self
Create a default Opus encoder (48kHz, stereo)
Sourcepub fn set_bitrate(&mut self, bitrate_bps: i32)
pub fn set_bitrate(&mut self, bitrate_bps: i32)
Set the encoder bitrate in bits per second.
Sourcepub fn set_complexity(&mut self, complexity: i32)
pub fn set_complexity(&mut self, complexity: i32)
Set the encoder complexity (0-10).
Sourcepub fn set_inband_fec(&mut self, enabled: bool)
pub fn set_inband_fec(&mut self, enabled: bool)
Enable or disable in-band FEC: SILK frames also carry a low-bitrate
copy of the previous frame, which a decoder can rebuild a lost packet
from (Decoder::recover_into). Only coded when the expected packet
loss (set_packet_loss_perc) is above zero and the bitrate leaves
room for it (e.g. 32 kb/s for wideband speech).
Sourcepub fn set_packet_loss_perc(&mut self, percent: i32)
pub fn set_packet_loss_perc(&mut self, percent: i32)
Set the packet loss the encoder expects, in percent (0-100). It trades bitrate for robustness, and gates in-band FEC.
Trait Implementations§
Source§impl Encoder for OpusEncoder
impl Encoder for OpusEncoder
Source§fn encode(&mut self, samples: &[Sample]) -> Vec<u8> ⓘ
fn encode(&mut self, samples: &[Sample]) -> Vec<u8> ⓘ
Override the default to preserve back-comat mono→stereo upmix
when the encoder was configured with channels == 2.
Source§fn encode_into(
&mut self,
samples: &[Sample],
out: &mut [u8],
) -> Result<usize, CodecError>
fn encode_into( &mut self, samples: &[Sample], out: &mut [u8], ) -> Result<usize, CodecError>
Source§fn max_encode_bytes(&self, _n_samples: usize) -> usize
fn max_encode_bytes(&self, _n_samples: usize) -> usize
encode_into will write
for an input of n_samples samples.