audio-codec 0.4.13

A collection of VoIP audio codecs in pure Rust, including G.711, G.722, G.729, and Opus.
Documentation
[package]
name = "audio-codec"
version = "0.4.13"
edition = "2024"
# fearless_simd 1.1 requires 1.89.
rust-version = "1.89"
authors = ["jinti<shenjindi@fourz.cn>"]
description = "A collection of VoIP audio codecs in pure Rust, including G.711, G.722, G.729, and Opus."
license = "MIT"
repository = "https://github.com/restsend/audio-codec"
readme = "README.md"
keywords = ["sip", "voip", "telephony", "webrtc", "no-std"]
categories = ["multimedia", "no-std"]

[features]
default = ["std", "opus", "g729"]
# `std` enables the allocating convenience API (`encode`/`decode` returning
# `Vec`, `create_encoder`/`create_decoder` returning `Box`, ...). Without it
# the crate is `#![no_std]`; Opus then needs an `alloc` (its ~250 KB
# encoder/decoder working set is boxed), the other codecs are heap-free.
#
# `std` also enables opus-rs's `heap` feature (requires std there): the
# encoder/decoder codec states are constructed INSIDE a Box instead of on
# the caller's stack. OpusEncoder's inline state is ~250 KB without it, so
# `OpusEncoder::new` alone could consume most of an 8 MB thread stack —
# fatal for deep async call chains in debug builds.
#
# `std` also enables fearless_simd's runtime CPU feature detection, so the
# resamplers pick the best SIMD level available. Without it the SIMD level is
# fixed at compile time (SSE2 on x86_64 unless `-C target-feature` says more).
std = ["g729-sys?/std", "opus-rs?/std", "opus-rs?/heap", "fearless_simd/std"]
# Opus support. On by default. opus-rs uses `libm` for transcendentals when
# `std` is off (no_std build).
opus = ["dep:opus-rs", "opus-rs/libm"]
# G.729 support. On by default. `g729-sys` is pure Rust and works without
# `std`; disabling this feature drops the codec entirely (smaller build).
g729 = ["dep:g729-sys"]

[lib]
crate-type = ["rlib"]

[dependencies]
g729-sys = { version = "0.3.0", optional = true, default-features = false }
opus-rs = { version = "0.1.39", optional = true, default-features = false }
libm = { version = "0.2", default-features = false }
fearless_simd = { version = "1.1", default-features = false, features = ["libm"] }

[dev-dependencies]
criterion = { version = "0.8.2", features = ["html_reports"] }
opusic-sys = "0.7.3"


[[bench]]
name = "codec_bench"
harness = false
required-features = ["std"]

[[example]]
name = "wav_to_opus"
required-features = ["std", "opus"]

[[example]]
name = "filetrack_test"
required-features = ["std", "opus"]