mirror of
https://github.com/pion/webrtc.git
synced 2025-10-13 02:43:48 +08:00
Remove RTX codec if no primary
While adding transceivers from SetRemoteDescription, the filtered codecs could filter out the primart codec and leave the RTX codec in. Generating an answer with that fails `SetRemoteDescription` on remote peer due to an unrecognisable codec. Fix it by filtering out RTX is primary is not there.
This commit is contained in:

committed by
Raja Subramanian

parent
8efd17e592
commit
c82d96cb75
@@ -8,6 +8,7 @@ package webrtc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
@@ -60,6 +61,19 @@ func (t *RTPTransceiver) SetCodecPreferences(codecs []RTPCodecParameters) error
|
||||
}
|
||||
}
|
||||
|
||||
// remove RTX codecs if there is no corresponding primary codec
|
||||
for i := len(codecs) - 1; i >= 0; i-- {
|
||||
c := codecs[i]
|
||||
if !strings.EqualFold(c.MimeType, MimeTypeRTX) {
|
||||
continue
|
||||
}
|
||||
|
||||
if isRTX, primaryExists := primaryPayloadTypeForRTXExists(c, codecs); isRTX && !primaryExists {
|
||||
// no primary for RTX, remove the RTX
|
||||
codecs = append(codecs[:i], codecs[i+1:]...)
|
||||
}
|
||||
}
|
||||
|
||||
t.codecs = codecs
|
||||
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user