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).
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
Upper bound on the number of bytes that
encode_into will write
for an input of n_samples samples.Source§fn sample_rate(&self) -> u32
fn sample_rate(&self) -> u32
Get the sample rate expected for input samples.
Auto Trait Implementations§
impl Freeze for OpusEncoder
impl RefUnwindSafe for OpusEncoder
impl Send for OpusEncoder
impl Sync for OpusEncoder
impl Unpin for OpusEncoder
impl UnsafeUnpin for OpusEncoder
impl UnwindSafe for OpusEncoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more