-
Notifications
You must be signed in to change notification settings - Fork 209
sip: redirect RTP destination on re-INVITE port change #728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
VictorUvarov
wants to merge
11
commits into
livekit:main
Choose a base branch
from
VictorUvarov:vu/issue-661
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+107
−8
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4a56a79
sip: add MediaPort.UpdateRemote and RemoteAddr for re-INVITE redirect
VictorUvarov feeb412
sip: redirect RTP destination on inbound re-INVITE port change
VictorUvarov dcaf53b
sip: redirect RTP destination on outbound re-INVITE port change
VictorUvarov 539ade5
sip: replace deprecated sdp.Parse with sdp.ParseWith
VictorUvarov 4f91d03
sip: guard UpdateRemote against unspecified addr; add body-absent re-…
VictorUvarov 27281ab
sip: extract updateRemoteFromSDP helper to reduce re-INVITE nesting
VictorUvarov f96381d
sip: address review findings from re-INVITE redirect implementation
VictorUvarov 28281e0
sip: fix nil pointer panic in SetDst log when first destination is set
VictorUvarov c71b97f
sip: fix nil pointer panic in Read log when first source is seen
VictorUvarov a823feb
sip: fix nil pointer panic when logging body-less re-INVITE
VictorUvarov 60cb302
sip: drop prev field from first-set log messages in udpConn
VictorUvarov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -312,6 +312,26 @@ func (s *Server) handleInviteAuth(tid traceid.ID, log logger.Logger, req *sip.Re | |
| return true, false | ||
| } | ||
|
|
||
| func sdpBodyFromRequest(req *sip.Request) []byte { | ||
| ct := req.ContentType() | ||
| if ct != nil && ct.Value() != "application/sdp" { | ||
| return nil | ||
| } | ||
| return req.Body() | ||
| } | ||
|
|
||
| func updateRemoteFromSDP(media *MediaPort, log logger.Logger, body []byte) { | ||
| if len(body) == 0 || media == nil { | ||
| return | ||
| } | ||
| desc, err := sdp.ParseWith(msdk.GlobalCodecs(), body) | ||
| if err != nil { | ||
| log.Warnw("failed to parse re-INVITE SDP, RTP destination not updated", err) | ||
| return | ||
| } | ||
| media.UpdateRemote(desc.Addr) | ||
| } | ||
|
|
||
| func (s *Server) onInvite(log *slog.Logger, req *sip.Request, tx sip.ServerTransaction) { | ||
| // Error processed in defer | ||
| _ = s.processInvite(req, tx) | ||
|
|
@@ -380,19 +400,21 @@ func (s *Server) processInvite(req *sip.Request, tx sip.ServerTransaction) (retE | |
| existing := s.byLocalTag[cc.ID()] | ||
| s.cmu.RUnlock() | ||
| if existing != nil && existing.cc.InviteCSeq() < cc.InviteCSeq() { | ||
| existing.log().Infow("reinvite", "content-type", req.ContentType(), "content-length", req.ContentLength(), "cseq", cc.InviteCSeq()) | ||
| existing.log().Infow("reinvite", "content-length", req.ContentLength(), "cseq", cc.InviteCSeq()) | ||
| updateRemoteFromSDP(existing.media, existing.log(), sdpBodyFromRequest(req)) | ||
| cc.AcceptAsKeepAlive(existing.cc.OwnSDP()) | ||
| return nil | ||
| } | ||
| if s.cli != nil { // Process reinvite for existing outbound calls | ||
| oc := s.cli.getActiveCall(cc.ID()) | ||
| newCSeq := cc.InviteCSeq() | ||
| if oc != nil && oc.cc != nil && oc.cc.InviteCSeq() < newCSeq { | ||
| sdp := oc.cc.LocalSDP() | ||
| if len(sdp) != 0 { | ||
| oc.log.Infow("accepting reinvite", "content-type", req.ContentType(), "content-length", req.ContentLength(), "cseq", cc.InviteCSeq()) | ||
| localSDP := oc.cc.LocalSDP() | ||
| if len(localSDP) != 0 { | ||
| oc.log.Infow("accepting reinvite", "content-length", req.ContentLength(), "cseq", cc.InviteCSeq()) | ||
| updateRemoteFromSDP(oc.media, oc.log, sdpBodyFromRequest(req)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it might be better to make a separate method on both inbound and outbound call types that call |
||
| oc.cc.RecordInvite(newCSeq) | ||
| cc.AcceptAsKeepAlive(sdp) | ||
| cc.AcceptAsKeepAlive(localSDP) | ||
| return nil | ||
| } | ||
| } | ||
|
|
||
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msdk.GlobalCodecs()is incorrect in this context. It should use the CodecSet for that particular call.