sipx_audio/lib.rs
1//! Telephony audio primitives: G.711 (ยต-law and A-law), L16, linear PCM conversion and
2//! resampling, WAV reading and writing, and Opus behind the `opus` feature.
3//!
4//! Codecs are pure Rust by default. Opus lives behind the `opus` feature because it binds
5//! to C.
6//!
7//! **G.722 remains absent** (`X-26`). G.722 and resampling were named in this crate's description
8//! from the commit that scaffolded the workspace, although neither existed when `X-26` removed
9//! those claims. `M-43` deliberately restores only the explicit resampling claim below. The
10//! wideband slot G.722 would have filled is Opus's (`M-13`), and the rest of the stack has always
11//! agreed โ `Codec::from_payload_type(9)` returns `None` and an offer of G.722 alone is refused.
12//!
13//! **Resampling is now explicit and supported** (`M-43`). [`PcmFormat`] names unsigned 8-bit or
14//! signed 16-bit mono PCM and a rate from 1 through 384,000 Hz; [`LinearResampler`] converts that
15//! stream to another stated rate without guessing either fact from a buffer. The diagnostic CLI
16//! uses this same boundary for WAV and device audio rather than maintaining a private resampler.
17//!
18//! RFC 4733 DTMF is not here either, and never was: telephone-events are an RTP payload format
19//! rather than audio samples, and they live in `sipx-rtp`.
20//!
21//! `scripts/check-audio-claims.py` holds the summary above, the package description and the
22//! website's crate table to what this crate implements, so the next codec named here has to
23//! exist before the gate goes green.
24//!
25//! # Stability
26//!
27//! sipx is pre-1.0, so **neither word below means frozen**. `1.0.0` is what freezes an API, and its
28//! predicates are in `docs/roadmap.md`. Until then:
29//!
30//! - **Supported** โ meant to be depended on. Breaking changes get a `CHANGELOG.md` entry saying what
31//! to do instead. New enum variants and new struct fields may still appear in a minor release, so a
32//! downstream `match` should carry a `_` arm.
33//! - **Experimental** โ may change shape or be removed without a migration note. Depend on it only if
34//! you are prepared to follow it.
35//!
36//!
37//! **Supported.** G.711 and L16 both ways, linear PCM conversion/resampling, mixing and WAV. Opus is behind the off-by-default `opus` feature
38//! and remains **Experimental** at this crate boundary. `sipx-call` and an Opus-enabled diagnostic
39//! CLI can select it, but no default shipped application enables its native dependency. Cargo's
40//! normalized package manifests are checked with the feature off and on, including a clean packaged
41//! CLI build and run. `M-39` supplies rate-correct bidirectional CLI audio and independent-peer
42//! evidence in both SIP roles. Optional RFC 7587 `fmtp` controls are not implemented.
43
44pub mod g711;
45pub mod l16;
46pub mod mix;
47#[cfg(feature = "opus")]
48pub mod opus;
49pub mod pcm;
50pub mod wav;
51
52pub use g711::{alaw_decode, alaw_encode, ulaw_decode, ulaw_encode};
53pub use mix::{mix_excluding, mix_into};
54pub use pcm::{LinearResampler, Pcm, PcmEncoding, PcmError, PcmFormat, PcmSamples, resample_i16};
55pub use wav::{Wav, read_wav, write_wav};