mirror of
https://github.com/pion/webrtc.git
synced 2025-09-27 03:25:58 +08:00
Match codec order of remote peer
Done when creating a transceiver from remote description to respect codec order preference of remote peer. There was a recent change to include partial matches which overwrote same codecs and also rtx was getting magled. Change it by removing codecs from search space as matches are found so that a codec match is applied only once. Also, move RTX matching to separate block to ensure proper RTXes ar matched.
This commit is contained in:

committed by
Raja Subramanian

parent
42b3cfd2ca
commit
c376d0edf9
@@ -630,6 +630,23 @@ func (m *MediaEngine) updateFromRemoteDescription(desc sdp.SessionDescription) e
|
||||
return err
|
||||
}
|
||||
|
||||
addIfNew := func(existingCodecs []RTPCodecParameters, codec RTPCodecParameters) []RTPCodecParameters {
|
||||
found := false
|
||||
for _, existingCodec := range existingCodecs {
|
||||
if existingCodec.PayloadType == codec.PayloadType {
|
||||
found = true
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
existingCodecs = append(existingCodecs, codec)
|
||||
}
|
||||
|
||||
return existingCodecs
|
||||
}
|
||||
|
||||
exactMatches := make([]RTPCodecParameters, 0, len(codecs))
|
||||
partialMatches := make([]RTPCodecParameters, 0, len(codecs))
|
||||
|
||||
@@ -642,9 +659,24 @@ func (m *MediaEngine) updateFromRemoteDescription(desc sdp.SessionDescription) e
|
||||
remoteCodec.RTCPFeedback = rtcpFeedbackIntersection(localCodec.RTCPFeedback, remoteCodec.RTCPFeedback)
|
||||
|
||||
if matchType == codecMatchExact {
|
||||
exactMatches = append(exactMatches, remoteCodec)
|
||||
exactMatches = addIfNew(exactMatches, remoteCodec)
|
||||
} else if matchType == codecMatchPartial {
|
||||
partialMatches = append(partialMatches, remoteCodec)
|
||||
partialMatches = addIfNew(partialMatches, remoteCodec)
|
||||
}
|
||||
}
|
||||
// second pass in case there were missed RTX codecs
|
||||
for _, remoteCodec := range codecs {
|
||||
localCodec, matchType, mErr := m.matchRemoteCodec(remoteCodec, typ, exactMatches, partialMatches)
|
||||
if mErr != nil {
|
||||
return mErr
|
||||
}
|
||||
|
||||
remoteCodec.RTCPFeedback = rtcpFeedbackIntersection(localCodec.RTCPFeedback, remoteCodec.RTCPFeedback)
|
||||
|
||||
if matchType == codecMatchExact {
|
||||
exactMatches = addIfNew(exactMatches, remoteCodec)
|
||||
} else if matchType == codecMatchPartial {
|
||||
partialMatches = addIfNew(partialMatches, remoteCodec)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user