Struct G711Codec

Source
pub struct G711Codec { /* private fields */ }
Expand description

G.711 codec implementation

Implementations§

Source§

impl G711Codec

Source

pub fn new(variant: G711Variant) -> Self

Create a new G.711 codec with the specified variant

Source

pub fn new_with_config( variant: G711Variant, config: CodecConfig, ) -> Result<Self, CodecError>

Create a new G.711 codec with configuration

Source

pub fn new_pcmu(config: CodecConfig) -> Result<Self, CodecError>

Create a new G.711 μ-law (PCMU) codec

Source

pub fn new_pcma(config: CodecConfig) -> Result<Self, CodecError>

Create a new G.711 A-law (PCMA) codec

Source

pub fn variant(&self) -> G711Variant

Get the codec variant

Source

pub fn compress(&self, samples: &[i16]) -> Result<Vec<u8>, CodecError>

Compress samples using the configured variant

Source

pub fn expand(&self, compressed: &[u8]) -> Result<Vec<i16>, CodecError>

Expand samples using the configured variant

Source

pub fn compress_alaw(&self, samples: &[i16]) -> Result<Vec<u8>, CodecError>

Compress samples using A-law

Source

pub fn expand_alaw(&self, compressed: &[u8]) -> Result<Vec<i16>, CodecError>

Expand A-law samples

Source

pub fn compress_ulaw(&self, samples: &[i16]) -> Result<Vec<u8>, CodecError>

Compress samples using μ-law

Source

pub fn expand_ulaw(&self, compressed: &[u8]) -> Result<Vec<i16>, CodecError>

Expand μ-law samples

Trait Implementations§

Source§

impl AudioCodec for G711Codec

Source§

fn encode(&mut self, samples: &[i16]) -> Result<Vec<u8>, CodecError>

Encode audio samples to compressed data Read more
Source§

fn decode(&mut self, data: &[u8]) -> Result<Vec<i16>, CodecError>

Decode compressed data to audio samples Read more
Source§

fn info(&self) -> CodecInfo

Get codec information
Source§

fn reset(&mut self) -> Result<(), CodecError>

Reset codec state Read more
Source§

fn frame_size(&self) -> usize

Get the expected frame size in samples
Source§

fn supports_variable_frame_size(&self) -> bool

Check if the codec supports variable frame sizes
Source§

impl AudioCodecExt for G711Codec

Source§

fn encode_to_buffer( &mut self, samples: &[i16], output: &mut [u8], ) -> Result<usize, CodecError>

Encode with pre-allocated output buffer (zero-copy) Read more
Source§

fn decode_to_buffer( &mut self, data: &[u8], output: &mut [i16], ) -> Result<usize, CodecError>

Decode with pre-allocated output buffer (zero-copy) Read more
Source§

fn max_encoded_size(&self, input_samples: usize) -> usize

Get maximum encoded size for a given input size
Source§

fn max_decoded_size(&self, input_bytes: usize) -> usize

Get maximum decoded size for a given input size

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more