pub(crate) enum PcmEncoder {
Stereo(Encoder),
Multi(MultiOpus),
}Expand description
One encode surface over both Opus APIs: the opus crate for mono/stereo, and
the raw multistream C API for 6/8-channel surround.
Variants§
Implementations§
Source§impl PcmEncoder
impl PcmEncoder
Sourcepub(crate) fn new(
sample_rate: u32,
channels: i32,
vbr: bool,
bitrate: i32,
) -> Result<Self, String>
pub(crate) fn new( sample_rate: u32, channels: i32, vbr: bool, bitrate: i32, ) -> Result<Self, String>
Build the Opus encoder for a channel count, selecting the API by width.
- Mono/stereo (
channels <= 2): the safeopuscrate encoder inLowDelayapplication mode; a failure to apply the initial bitrate or VBR mode is logged but not fatal. - Surround (6/8): the raw multistream C encoder created from
multiopus_layoutinRESTRICTED_LOWDELAY; an unsupported channel count is a hard error.
Bitrate and VBR are applied at creation and can be retuned live via set_bitrate.
Sourcepub(crate) fn encode(
&mut self,
pcm: &[i16],
frame_size_per_channel: usize,
out: &mut [u8],
) -> Result<usize, String>
pub(crate) fn encode( &mut self, pcm: &[i16], frame_size_per_channel: usize, out: &mut [u8], ) -> Result<usize, String>
Encode one interleaved-PCM frame into out, returning the packet byte length.
Dispatches to the opus crate (mono/stereo) or the raw multistream encode (surround,
which needs the explicit frame_size_per_channel). Either error surfaces as a String.
Auto Trait Implementations§
impl !Sync for PcmEncoder
impl Freeze for PcmEncoder
impl RefUnwindSafe for PcmEncoder
impl Send for PcmEncoder
impl Unpin for PcmEncoder
impl UnsafeUnpin for PcmEncoder
impl UnwindSafe for PcmEncoder
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