docs.rs failed to build rvoip-codec-core-0.1.15
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
rvoip-codec-core-0.1.26
Codec-Core: Audio Codec Library for VoIP
A simple implementation of G.711 audio codec for VoIP applications. This library provides ITU-T compliant G.711 μ-law and A-law encoding/decoding with lookup table optimizations.
Features
- ITU-T G.711 Compliant: Passes official compliance tests
- Real Audio Tested: Validated with actual speech samples
- Good Quality: ~37 dB SNR with real speech
- Lookup Table Optimized: Fast O(1) encoding/decoding
Implementation
- Lookup Tables: Pre-computed tables for O(1) operations
- Simple APIs: Straightforward encoding/decoding functions
Usage
Quick Start
use G711Codec;
use ;
// Create a G.711 μ-law codec
let config = new
.with_sample_rate
.with_channels;
let mut codec = new_pcmu?;
// Encode audio samples (20ms at 8kHz = 160 samples)
let samples = vec!;
let encoded = codec.encode?;
// Decode back to samples
let decoded = codec.decode?;
# Ok::
Testing & Validation
The library includes comprehensive testing including real audio validation:
# Run all codec tests including WAV roundtrip tests
# Run only G.711 WAV roundtrip tests (downloads real speech audio)
The WAV roundtrip tests automatically download real speech samples and validate:
- Signal-to-Noise Ratio (SNR) measurement
- Round-trip audio quality preservation
- Proper encoding/decoding with real audio data
- Output WAV files for manual quality assessment
Error Handling
All codec operations return Result types with detailed error information:
use G711Codec;
use ;
use CodecError;
// Handle configuration errors
let config = new
.with_sample_rate // Invalid for G.711
.with_channels;
match new_pcmu
Performance Tips
- Use appropriate frame sizes (160 samples for G.711 at 8kHz/20ms)
Direct G.711 Functions
use ;
// Single sample processing
let sample = 1024i16;
let alaw_encoded = alaw_compress;
let alaw_decoded = alaw_expand;
let ulaw_encoded = ulaw_compress;
let ulaw_decoded = ulaw_expand;
Frame-Based Processing
use ;
let mut codec = new;
// Process 160 samples (20ms at 8kHz)
let input_frame = vec!; // Some test samples
let encoded = codec.compress.unwrap;
// Decode back to samples (same count for G.711)
let decoded = codec.expand.unwrap;
assert_eq!;
# Ok::
Supported Codecs
| Codec | Sample Rate | Channels | Bitrate | Frame Size | Status |
|---|---|---|---|---|---|
| G.711 μ-law (PCMU) | 8 kHz | 1 | 64 kbps | 160 samples | ✅ Production |
| G.711 A-law (PCMA) | 8 kHz | 1 | 64 kbps | 160 samples | ✅ Production |
Quality Metrics
Based on real audio testing with the included WAV roundtrip tests:
- G.711: 37+ dB SNR (excellent quality, industry standard)
Feature Flags
Core Codecs (enabled by default)
g711: G.711 μ-law/A-law codecs