Skip to content

feat: add G.722 wideband codec - #34

Merged
wavekat-eason merged 2 commits into
mainfrom
feat/g722
Nov 13, 2026
Merged

wavekat-eason merged 2 commits into
mainfrom
feat/g722

Conversation

@wavekat-eason

Copy link
Copy Markdown
Contributor

What

Adds codec::g722: a pure-Rust G.722 encoder and decoder (64 kbit/s, mode 1). G.722 carries 16 kHz speech in the same bitrate as G.711, and it is the wideband codec most SIP providers accept when they refuse Opus.

  • G722Encoder / G722Decoder: 320 samples in, 160 bytes out per 20 ms frame. Stateful, one per stream.
  • Constants for the payload type (9), the 16 kHz PCM rate and the 8 kHz RTP clock (the RFC 3551 quirk).
  • Encoder::G722 / Decoder::G722 on the per-call codec seam. Loss recovery is a no-op, as for G.711.
  • No new dependency and no feature flag.

Why

A downstream caller could only send narrowband audio on SIP lines that refuse Opus. With G.722 the same line carries wideband.

Testing

  • The encoder and decoder match an independent G.722 implementation bit for bit on 20 s of mixed test audio (sweeps, noise, loud bursts, silence). A short reference vector from that run is pinned in the tests.
  • Round-trip tests for a low-band and a high-band tone, full-scale input, framing, and odd sample counts.
  • Tried on a real SIP line: the provider selected G.722 and the audio was clearly better than G.711 on the same line.
  • cargo test --workspace --all-features: 88 passed. Clippy is clean.

Notes

  • cargo doc with -D warnings already fails on main (unresolved CoreError::Audio links in audio.rs). This PR does not touch that.
  • A second, spec-derived crate did not agree with either this code or the implementation it matches. That was not investigated further.

A pure-Rust G.722 encoder and decoder (64 kbit/s, 16 kHz audio) in codec::g722, and G722 variants on the Encoder/Decoder seam. Output is pinned by a reference vector from an independent implementation.
The runner image now ships CMake 4, which rejects the vendored libopus CMakeLists without a minimum policy version. Set it for every cargo invocation, local and CI.
@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.19820% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/wavekat-core/src/codec/g722.rs 98.04% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

@wavekat-eason
wavekat-eason marked this pull request as ready for review November 13, 2026 21:09
@wavekat-eason
wavekat-eason merged commit 2874f76 into main Nov 13, 2026
3 checks passed
@wavekat-eason
wavekat-eason deleted the feat/g722 branch November 13, 2026 21:09
@github-actions github-actions Bot mentioned this pull request Nov 13, 2026
wavekat-eason pushed a commit that referenced this pull request Nov 13, 2026
## 🤖 New release

* `wavekat-core`: 0.0.14 -> 0.0.15 (⚠ API breaking changes)

### ⚠ `wavekat-core` breaking changes

```text
--- failure enum_variant_added: enum variant added on exhaustive enum ---

Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.51.0/src/lints/enum_variant_added.ron

Failed in:
  variant Encoder:G722 in /tmp/.tmpgyl9mm/wavekat-core/crates/wavekat-core/src/codec/mod.rs:47
  variant Decoder:G722 in /tmp/.tmpgyl9mm/wavekat-core/crates/wavekat-core/src/codec/mod.rs:104
```

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[0.0.15](v0.0.14...v0.0.15)
- 2026-11-13

### Added

- add G.722 wideband codec
([#34](#34))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant