opus: register Opus as a SIP/SDP codec#72
Closed
inechay wants to merge 1 commit into
Closed
Conversation
Opus is implemented here but only wired into the WebRTC leg; it is never registered as a SIP/SDP codec, so livekit/sip can only offer G711/G722 on the telephone leg (livekit/sip#281). Register it like g722/amrwb: SDPName opus/48000/2, 48 kHz, dynamic payload type, mono encode/decode adapters over the existing Opus impl. The encoder is tuned for telephony (inband FEC + a packet-loss estimate for lossy mobile paths, plus max complexity and a generous bitrate); codec init failures fail the call rather than panicking the process. The RTP media path is already generic over CodecInfo + AudioCodec, so this registration is sufficient end to end. Enabling it in livekit/sip's default codec set is a companion one-line change there. Refs: livekit/sip#281
Author
|
Closing in favor of #69, which takes the same approach (register Opus in the media-sdk I've left notes on #69 with live-test results and an optional telephony encoder tuning that could go on top once it lands. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Register Opus as a SIP/SDP codec so it can be offered and negotiated on the RTP (telephone) leg.
Why
Opus is implemented in this repo (
opus/opus.go) but only wired into the internal WebRTC leg — it is never registered as a SIP/SDP codec (noinit()/RegisterCodec), unlikeg711/g722/amrwb. As a resultlivekit/sipcan only offer G711/G722 on the telephone leg, capping wideband calls at G.722 16 kHz even when the softphone offers Opus.This is the media-sdk side of livekit/sip#281.
Change
opus/opus.go— register Opus the same wayg722.go/amrwb.godo:CodecInfo{SDPName: "opus/48000/2", SampleRate: 48000, RTPClockRate: 48000, RTPIsStatic: false, Priority: 100}Encode/DecodeEncodeso the WebRTC leg (its own bandwidth estimation) is untouchedfailWriter) instead ofpanic-ing the whole processThe RTP media path (
rtp.EncodePCM/rtp.DecodePCM) is already generic overCodecInfo+AudioCodec, so this registration is sufficient end to end — no per-codec wiring. Happy to make the encoder settings configurable / less opinionated if preferred.Companion change
livekit/sipneeds a one-line change to enableopusin its default codec set (pkg/sip/media_codecs.go); I'll open that PR once this lands.Testing
Built into a custom
livekit-sipimage and verified on a live inbound call from a softphone (Zoiper with Opus above G722): SDP answera=rtpmap:106 opus/48000/2, logusing codecs … audio-codec=opus/48000/2, clean 48 kHz media (expected_pcm_hz=48000,packets_failed=0,write_errors=0, no decode errors), DTMF/telephone-event intact, and audibly better than G.722.Refs: livekit/sip#281