Skip to content

feat: add opt-in Opus codec support for SIP media negotiation#738

Open
thetillhoff wants to merge 11 commits into
livekit:mainfrom
thetillhoff:feature/opus-codec-support
Open

feat: add opt-in Opus codec support for SIP media negotiation#738
thetillhoff wants to merge 11 commits into
livekit:mainfrom
thetillhoff:feature/opus-codec-support

Conversation

@thetillhoff

@thetillhoff thetillhoff commented Jul 2, 2026

Copy link
Copy Markdown

Summary

  • Opus is disabled by default (enable_opus: false) — zero behavior change for existing deployments
  • Set enable_opus: true to offer opus/48000/2 (48 kHz mono, priority 10 > G722 > G711)
  • Optional opus: block tunes bitrate, complexity, and FEC per deployment
  • Replaces panic on codec init failure with error log + return nil
  • Adds non-CGo stub so builds without libopus compile cleanly

The go.mod currently has a local replace directive pointing at a fork of media-sdk that adds EncodeWith. This will be replaced with a proper version pin once livekit/media-sdk#69 merges.

Related

Register Opus (48kHz, mono) as an audio codec for SIP SDP
offer/answer negotiation. Opus is enabled by default alongside
G711 and G722, providing higher audio quality for peers that
support it (e.g., WhatsApp Business Calling API).

Changes:
- Register Opus codec via media-sdk's NewAudioCodec (CGo-only)
- Add Opus to the default codec set
- Fix codecSet to resolve multi-part SDP names (opus/48000/2)
- Fix test SDP name parsing for 3-part codec names

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@thetillhoff thetillhoff force-pushed the feature/opus-codec-support branch 2 times, most recently from bff3b8c to b6ace8f Compare July 3, 2026 10:22
thetillhoff and others added 4 commits July 3, 2026 12:30
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.31915% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.09%. Comparing base (0460b40) to head (e6fe0c2).
⚠️ Report is 319 commits behind head on main.

Files with missing lines Patch % Lines
pkg/sip/media_codecs_opus.go 48.14% 14 Missing ⚠️
pkg/sip/service.go 12.50% 6 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #738      +/-   ##
==========================================
+ Coverage   65.25%   66.09%   +0.84%     
==========================================
  Files          51       42       -9     
  Lines        6588     7831    +1243     
==========================================
+ Hits         4299     5176     +877     
- Misses       1915     2183     +268     
- Partials      374      472      +98     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@thetillhoff thetillhoff force-pushed the feature/opus-codec-support branch from b6ace8f to 2b02d64 Compare July 3, 2026 10:31
thetillhoff and others added 2 commits July 3, 2026 12:38
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…uppercase encoder labels

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@thetillhoff thetillhoff force-pushed the feature/opus-codec-support branch from 2b02d64 to bfb5ef8 Compare July 3, 2026 10:38
thetillhoff and others added 3 commits July 3, 2026 13:45
Opus is lossy/perceptual; waveform fidelity assertions don't hold.
Covered by media_codecs_opus_test.go instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Matches the AMR-WB pattern: codec is registered but opt-in.
Previously Opus was absent from the map entirely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds OpusEncodeOptions and OpusConfig so deployments can tune bitrate,
complexity, and FEC without rebuilding. Encoder option application is
stubbed pending livekit/media-sdk#69 (EncodeWith).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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