MultistreamEncoderRef

Struct MultistreamEncoderRef 

Source
pub struct MultistreamEncoderRef<'a> { /* private fields */ }
Expand description

Borrowed wrapper around a multistream encoder.

Implementations§

Source§

impl<'a> MultistreamEncoderRef<'a>

Source

pub unsafe fn from_raw( ptr: *mut OpusMSEncoder, sr: SampleRate, mapping: Mapping<'_>, ) -> Self

Wrap an externally-initialized multistream encoder without taking ownership.

§Safety
  • ptr must point to valid, initialized memory of at least MultistreamEncoder::size() bytes
  • ptr must be aligned to at least align_of::<usize>() (malloc-style alignment)
  • The memory must remain valid for the lifetime 'a
  • Caller is responsible for freeing the memory after this wrapper is dropped

Use MultistreamEncoder::init_in_place to initialize the memory before calling this.

Source

pub fn init_in( buf: &'a mut AlignedBuffer, sr: SampleRate, app: Application, mapping: Mapping<'_>, ) -> Result<Self>

Initialize and wrap an externally allocated buffer.

§Errors

Returns Error::BadArg if the buffer is too small, or a mapped libopus error.

Source

pub fn init_in_surround( buf: &'a mut AlignedBuffer, sr: SampleRate, channels: u8, mapping_family: i32, app: Application, ) -> Result<(Self, Vec<u8>)>

Initialize a surround encoder in an externally allocated buffer.

§Errors

Returns Error::BadArg if the buffer is too small, or a mapped libopus error.

Methods from Deref<Target = MultistreamEncoder>§

Source

pub fn encode( &mut self, pcm: &[i16], frame_size_per_ch: usize, out: &mut [u8], ) -> Result<usize>

Encode interleaved i16 PCM into a multistream Opus packet.

§Errors

Returns Error::InvalidState if the encoder handle is invalid, Error::BadArg for buffer mismatches, or the mapped libopus error code.

Source

pub fn encode_float( &mut self, pcm: &[f32], frame_size_per_ch: usize, out: &mut [u8], ) -> Result<usize>

Encode interleaved f32 PCM into a multistream Opus packet.

§Errors

Returns Error::InvalidState if the encoder handle is invalid, Error::BadArg for buffer mismatches, or the mapped libopus error code.

Source

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

Final RNG state from the last encode.

§Errors

Returns Error::InvalidState when the encoder handle is null or propagates the libopus error.

Source

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

Set target bitrate for the encoder.

§Errors

Returns Error::InvalidState if the encoder handle is null or propagates any error reported by libopus.

Source

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

Query the current bitrate target.

§Errors

Returns Error::InvalidState if the encoder handle is null, Error::InternalError if the returned value cannot be represented, or propagates any error reported by libopus.

Source

pub fn set_complexity(&mut self, complexity: Complexity) -> Result<()>

Set encoder complexity in the range 0..=10.

§Errors

Returns Error::InvalidState if the encoder handle is null or propagates any error reported by libopus.

Source

pub fn complexity(&mut self) -> Result<Complexity>

Query encoder complexity.

§Errors

Returns Error::InvalidState if the encoder handle is null, Error::InternalError if the response is outside the valid range, or propagates any error reported by libopus.

Source

pub fn set_dtx(&mut self, enabled: bool) -> Result<()>

Enable/disable discontinuous transmission (DTX).

§Errors

Returns Error::InvalidState if the encoder handle is null or propagates any error reported by libopus.

Source

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

Query whether DTX is enabled.

§Errors

Returns Error::InvalidState if the encoder handle is null or propagates any error reported by libopus.

Source

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

Query whether the encoder is currently in DTX.

§Errors

Returns Error::InvalidState if the encoder handle is null or propagates any error reported by libopus.

Source

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

Enable/disable in-band FEC generation.

§Errors

Returns Error::InvalidState if the encoder handle is null or propagates any error reported by libopus.

Source

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

Query whether in-band FEC is enabled.

§Errors

Returns Error::InvalidState if the encoder handle is null or propagates any error reported by libopus.

Source

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

Set expected packet loss percentage (0..=100).

§Errors

Returns Error::BadArg when perc is outside 0..=100, Error::InvalidState if the encoder handle is null, or propagates any error reported by libopus.

Source

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

Query expected packet loss percentage.

§Errors

Returns Error::InvalidState if the encoder handle is null or propagates any error reported by libopus.

Source

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

Enable/disable variable bitrate.

§Errors

Returns Error::InvalidState if the encoder handle is null or propagates any error reported by libopus.

Source

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

Query VBR status.

§Errors

Returns Error::InvalidState if the encoder handle is null or propagates any error reported by libopus.

Source

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

Constrain VBR to reduce instantaneous bitrate swings.

§Errors

Returns Error::InvalidState if the encoder handle is null or propagates any error reported by libopus.

Source

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

Query VBR constraint flag.

§Errors

Returns Error::InvalidState if the encoder handle is null or propagates any error reported by libopus.

Source

pub fn set_max_bandwidth(&mut self, bw: Bandwidth) -> Result<()>

Set the maximum bandwidth the encoder may use.

§Errors

Returns Error::InvalidState if the encoder handle is null or propagates any error reported by libopus.

Source

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

Query the configured maximum bandwidth.

§Errors

Returns Error::InvalidState if the encoder handle is null, Error::InternalError if the value cannot be represented, or propagates any error reported by libopus.

Source

pub fn set_bandwidth(&mut self, bw: Bandwidth) -> Result<()>

Force a specific output bandwidth (overrides automatic selection).

§Errors

Returns Error::InvalidState if the encoder handle is null or propagates any error reported by libopus.

Source

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

Query the current forced bandwidth, if any.

§Errors

Returns Error::InvalidState if the encoder handle is null or Error::InternalError if the value is outside the known set, and propagates any error reported by libopus.

Source

pub fn set_force_channels(&mut self, channels: Option<Channels>) -> Result<()>

Force mono/stereo output for coupled streams, or None for automatic.

§Errors

Returns Error::InvalidState if the encoder handle is null or propagates any error reported by libopus.

Source

pub fn force_channels(&mut self) -> Result<Option<Channels>>

Query forced channel configuration (if any).

§Errors

Returns Error::InvalidState if the encoder handle is null or propagates any error reported by libopus.

Source

pub fn set_signal(&mut self, signal: Signal) -> Result<()>

Hint the type of content being encoded (voice/music).

§Errors

Returns Error::InvalidState if the encoder handle is null or propagates any error reported by libopus.

Source

pub fn signal(&mut self) -> Result<Signal>

Query the current signal hint.

§Errors

Returns Error::InvalidState if the encoder handle is null, Error::InternalError if the response is not recognized, or propagates any error reported by libopus.

Source

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

Query the algorithmic lookahead in samples at 48 kHz.

§Errors

Returns Error::InvalidState if the encoder handle is null or propagates any error reported by libopus.

Source

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

Reset the encoder state (retaining configuration).

§Errors

Returns Error::InvalidState if the encoder handle is null or propagates any error reported by libopus.

Source

pub fn channels(&self) -> u8

Channels of this encoder (interleaved input).

Source

pub fn sample_rate(&self) -> SampleRate

Input sampling rate.

Source

pub fn streams(&self) -> u8

Number of mono streams.

Source

pub fn coupled_streams(&self) -> u8

Number of coupled streams.

Source

pub unsafe fn encoder_state_ptr( &mut self, stream_index: i32, ) -> Result<*mut OpusEncoder>

Borrow a pointer to an individual underlying encoder state for CTLs.

§Safety

Caller must not outlive the multistream encoder and must ensure the returned pointer is only used for immediate FFI calls.

§Errors

Returns Error::InvalidState if the encoder handle is invalid or propagates the libopus error if retrieving the state fails.

Trait Implementations§

Source§

impl Deref for MultistreamEncoderRef<'_>

Source§

type Target = MultistreamEncoder

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for MultistreamEncoderRef<'_>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl Send for MultistreamEncoderRef<'_>

Source§

impl Sync for MultistreamEncoderRef<'_>

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.