Skip to content

feat: register Opus codec in media-sdk opus package#69

Open
thetillhoff wants to merge 2 commits into
livekit:mainfrom
thetillhoff:feature/register-opus-codec
Open

feat: register Opus codec in media-sdk opus package#69
thetillhoff wants to merge 2 commits into
livekit:mainfrom
thetillhoff:feature/register-opus-codec

Conversation

@thetillhoff

@thetillhoff thetillhoff commented Jul 2, 2026

Copy link
Copy Markdown

Summary

  • Mirrors the g711/g722/dtmf pattern: init() in the codec's own package calls RegisterCodec so importers get the codec registered by side-effect
  • CGo-gated (//go:build cgo) — requires libopus
  • Disabled: true — opt-in; callers enable via msdk.CodecSetEnabled("opus/48000/2", true)
  • Exports SDPName = "opus/48000/2" constant for callers

Related

Mirrors the g711/g722/dtmf pattern: an init() in the codec's own
package calls RegisterCodec so importers get the codec registered
by side-effect. Opus is registered Disabled:true (opt-in) since
SIP infrastructure interoperability varies; callers enable it via
msdk.CodecSetEnabled.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
thetillhoff added a commit to thetillhoff/sip that referenced this pull request Jul 3, 2026
Adds OpusEncodeOptions and OpusConfig so deployments can tune
bitrate, complexity, and FEC without rebuilding. The go.mod replace
directive pointing at a local media-sdk fork (which adds EncodeWith)
is temporary and will be removed once livekit/media-sdk#69 merges.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
thetillhoff added a commit to thetillhoff/sip that referenced this pull request Jul 3, 2026
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>
@inechay

inechay commented Jul 10, 2026

Copy link
Copy Markdown

👍 for this approach. I independently ran into #281, built the same media-sdk registration plus a companion sip change, and only then found this was already in flight — I've closed my duplicate (#72) and won't open a competing sip PR against #738.

One data point in case it's useful: I built this registration into a custom livekit-sip image and ran it on a live inbound call from a softphone (Zoiper, Opus offered above G722). The SIP leg negotiated Opus cleanly:

  • SDP answer a=rtpmap:106 opus/48000/2, log using codecs … audio-codec=opus/48000/2
  • clean 48 kHz media over a ~5 min call: expected_pcm_hz=48000, packets_failed=0, write_errors=0, no decode errors
  • DTMF / telephone-event intact

So the opus package registration + the generic RTP path (rtp.EncodePCM / rtp.DecodePCM) work end to end on the SIP leg with no per-codec wiring.

One optional enhancement for the SIP encode path, as a follow-up if you think it fits: a telephony-tuned encoder — inband FEC + a packet-loss estimate so lossy mobile paths (wifi↔LTE handoff, phone in pocket) degrade gracefully, plus higher bitrate/complexity for a richer narrator/music-bed sound. I kept it in a separate sipEncode from the shared Encode so the WebRTC leg (its own bandwidth estimation) stays untouched. Glad to send it on top of this once it merges.

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.

2 participants