mirror of
https://github.com/livekit/livekit.git
synced 2026-11-12 20:49:07 +00:00
rtc: match publisher m-sections by mid, not by position (#5122)
* rtc: match publisher m-sections by mid, not by position A client that stops a transceiver lets the next one recycle its m-line (JSEP 5.2.2), so a new m-section can come before negotiated ones. GetUnmatchMediaForOffer stopped at the last answered mid and missed it, so its codec preferences were never applied. Bump the protocol so clients know they can stop transceivers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Update protocol_version.go * Remove comments from GetUnmatchMediaForOffer function Removed comments explaining the GetUnmatchMediaForOffer function. --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
13b23fa722
commit
0d762b4e50
2 files changed
+10
-12
No files matched your search
@@ -538,7 +538,7 @@ func (t *TransportManager) createDataChannelsForSubscriber(pendingDataChannels [
|
||||
}
|
||||
|
||||
func (t *TransportManager) GetUnmatchMediaForOffer(parsedOffer *sdp.SessionDescription, mediaType string) (unmatched []*sdp.MediaDescription, err error) {
|
||||
var lastMatchedMid string
|
||||
matchedMids := make(map[string]struct{})
|
||||
if lastAnswer := t.publisher.CurrentLocalDescription(); lastAnswer != nil {
|
||||
parsedAnswer, err1 := lastAnswer.Unmarshal()
|
||||
if err1 != nil {
|
||||
@@ -547,22 +547,20 @@ func (t *TransportManager) GetUnmatchMediaForOffer(parsedOffer *sdp.SessionDescr
|
||||
return unmatched, err1
|
||||
}
|
||||
|
||||
for i := len(parsedAnswer.MediaDescriptions) - 1; i >= 0; i-- {
|
||||
media := parsedAnswer.MediaDescriptions[i]
|
||||
if media.MediaName.Media == mediaType {
|
||||
lastMatchedMid, _ = media.Attribute(sdp.AttrKeyMID)
|
||||
break
|
||||
for _, media := range parsedAnswer.MediaDescriptions {
|
||||
if mid, ok := media.Attribute(sdp.AttrKeyMID); ok {
|
||||
matchedMids[mid] = struct{}{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for i := len(parsedOffer.MediaDescriptions) - 1; i >= 0; i-- {
|
||||
media := parsedOffer.MediaDescriptions[i]
|
||||
if media.MediaName.Media == mediaType {
|
||||
mid, _ := media.Attribute(sdp.AttrKeyMID)
|
||||
if mid == lastMatchedMid {
|
||||
break
|
||||
}
|
||||
if media.MediaName.Media != mediaType {
|
||||
continue
|
||||
}
|
||||
mid, _ := media.Attribute(sdp.AttrKeyMID)
|
||||
if _, ok := matchedMids[mid]; !ok {
|
||||
unmatched = append(unmatched, media)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ package types
|
||||
|
||||
type ProtocolVersion int
|
||||
|
||||
const CurrentProtocol = 18
|
||||
const CurrentProtocol = 19
|
||||
|
||||
func (v ProtocolVersion) SupportsPackedStreamId() bool {
|
||||
return v > 0
|
||||
|
||||
Reference in new issue
Block a user