pub struct G711Codec { /* private fields */ }Expand description
G.711 codec implementation
Implementations§
Source§impl G711Codec
impl G711Codec
Sourcepub fn new(variant: G711Variant) -> Self
pub fn new(variant: G711Variant) -> Self
Create a new G.711 codec with the specified variant
Sourcepub fn new_with_config(
variant: G711Variant,
config: CodecConfig,
) -> Result<Self, CodecError>
pub fn new_with_config( variant: G711Variant, config: CodecConfig, ) -> Result<Self, CodecError>
Create a new G.711 codec with configuration
Sourcepub fn new_pcmu(config: CodecConfig) -> Result<Self, CodecError>
pub fn new_pcmu(config: CodecConfig) -> Result<Self, CodecError>
Create a new G.711 μ-law (PCMU) codec
Sourcepub fn new_pcma(config: CodecConfig) -> Result<Self, CodecError>
pub fn new_pcma(config: CodecConfig) -> Result<Self, CodecError>
Create a new G.711 A-law (PCMA) codec
Sourcepub fn variant(&self) -> G711Variant
pub fn variant(&self) -> G711Variant
Get the codec variant
Sourcepub fn compress(&self, samples: &[i16]) -> Result<Vec<u8>, CodecError>
pub fn compress(&self, samples: &[i16]) -> Result<Vec<u8>, CodecError>
Compress samples using the configured variant
Sourcepub fn expand(&self, compressed: &[u8]) -> Result<Vec<i16>, CodecError>
pub fn expand(&self, compressed: &[u8]) -> Result<Vec<i16>, CodecError>
Expand samples using the configured variant
Sourcepub fn compress_alaw(&self, samples: &[i16]) -> Result<Vec<u8>, CodecError>
pub fn compress_alaw(&self, samples: &[i16]) -> Result<Vec<u8>, CodecError>
Compress samples using A-law
Sourcepub fn expand_alaw(&self, compressed: &[u8]) -> Result<Vec<i16>, CodecError>
pub fn expand_alaw(&self, compressed: &[u8]) -> Result<Vec<i16>, CodecError>
Expand A-law samples
Sourcepub fn compress_ulaw(&self, samples: &[i16]) -> Result<Vec<u8>, CodecError>
pub fn compress_ulaw(&self, samples: &[i16]) -> Result<Vec<u8>, CodecError>
Compress samples using μ-law
Sourcepub fn expand_ulaw(&self, compressed: &[u8]) -> Result<Vec<i16>, CodecError>
pub fn expand_ulaw(&self, compressed: &[u8]) -> Result<Vec<i16>, CodecError>
Expand μ-law samples
Trait Implementations§
Source§impl AudioCodec for G711Codec
impl AudioCodec for G711Codec
Source§fn encode(&mut self, samples: &[i16]) -> Result<Vec<u8>, CodecError>
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>
fn decode(&mut self, data: &[u8]) -> Result<Vec<i16>, CodecError>
Decode compressed data to audio samples Read more
Source§fn frame_size(&self) -> usize
fn frame_size(&self) -> usize
Get the expected frame size in samples
Source§fn supports_variable_frame_size(&self) -> bool
fn supports_variable_frame_size(&self) -> bool
Check if the codec supports variable frame sizes
Source§impl AudioCodecExt for G711Codec
impl AudioCodecExt for G711Codec
Source§fn encode_to_buffer(
&mut self,
samples: &[i16],
output: &mut [u8],
) -> Result<usize, CodecError>
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>
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
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
fn max_decoded_size(&self, input_bytes: usize) -> usize
Get maximum decoded size for a given input size
Auto Trait Implementations§
impl Freeze for G711Codec
impl RefUnwindSafe for G711Codec
impl Send for G711Codec
impl Sync for G711Codec
impl Unpin for G711Codec
impl UnwindSafe for G711Codec
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