pub struct G711Codec { /* private fields */ }Expand description
G.711 codec implementation
Implementations§
Source§impl G711Codec
impl G711Codec
Sourcepub const fn new(variant: G711Variant) -> Self
pub const 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
§Errors
Returns an error when the configuration uses a sample rate, channel count, or frame duration unsupported by G.711.
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
§Errors
Returns an error when config is not a supported G.711 configuration.
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
§Errors
Returns an error when config is not a supported G.711 configuration.
Sourcepub const fn variant(&self) -> G711Variant
pub const 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
§Errors
This implementation is infallible; the result type is retained for API compatibility with other codecs.
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
§Errors
This implementation is infallible; the result type is retained for API compatibility with other codecs.
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
§Errors
This implementation is infallible; the result type is retained for API compatibility.
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
§Errors
This implementation is infallible; the result type is retained for API compatibility.
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
§Errors
This implementation is infallible; the result type is retained for API compatibility.
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
§Errors
This implementation is infallible; the result type is retained for API compatibility.