Throttle RTX under certain conditions to prevent RTX storm (#440)
* WIP commit * WIP commit * WIP commit * WIP commit * WIP commit * WIP commit * WIP commit * WIP commit * Clean up * Remove debug * Remove unneeded change * fix test * Remove incorrect comment * WIP commit * Reset probe after estimate trends down * WIP commit * variable name change * Clean up * Remove debug logs * gofmt
This commit is contained in:
@@ -18,6 +18,10 @@ const (
|
||||
SequenceNumberOrderingDuplicate
|
||||
)
|
||||
|
||||
const (
|
||||
RtxGateWindow = 2000
|
||||
)
|
||||
|
||||
type TranslationParamsRTP struct {
|
||||
snOrdering SequenceNumberOrdering
|
||||
sequenceNumber uint16
|
||||
@@ -38,6 +42,9 @@ type RTPMungerParams struct {
|
||||
lastMarker bool
|
||||
|
||||
missingSNs map[uint16]uint16
|
||||
|
||||
rtxGateSn uint16
|
||||
isInRtxGateRegion bool
|
||||
}
|
||||
|
||||
type RTPMunger struct {
|
||||
@@ -155,6 +162,15 @@ func (r *RTPMunger) UpdateAndGetSnTs(extPkt *buffer.ExtPacket) (*TranslationPara
|
||||
r.lastTS = mungedTS
|
||||
r.lastMarker = extPkt.Packet.Marker
|
||||
|
||||
if extPkt.KeyFrame {
|
||||
r.rtxGateSn = mungedSN
|
||||
r.isInRtxGateRegion = true
|
||||
}
|
||||
|
||||
if r.isInRtxGateRegion && (mungedSN-r.rtxGateSn) > RtxGateWindow {
|
||||
r.isInRtxGateRegion = false
|
||||
}
|
||||
|
||||
return &TranslationParamsRTP{
|
||||
snOrdering: ordering,
|
||||
sequenceNumber: mungedSN,
|
||||
@@ -162,6 +178,21 @@ func (r *RTPMunger) UpdateAndGetSnTs(extPkt *buffer.ExtPacket) (*TranslationPara
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *RTPMunger) FilterRTX(nacks []uint16) []uint16 {
|
||||
if !r.isInRtxGateRegion {
|
||||
return nacks
|
||||
}
|
||||
|
||||
filtered := make([]uint16, 0, len(nacks))
|
||||
for _, sn := range nacks {
|
||||
if (sn - r.rtxGateSn) < (1 << 15) {
|
||||
filtered = append(filtered, sn)
|
||||
}
|
||||
}
|
||||
|
||||
return filtered
|
||||
}
|
||||
|
||||
func (r *RTPMunger) UpdateAndGetPaddingSnTs(num int, clockRate uint32, frameRate uint32, forceMarker bool) ([]SnTs, error) {
|
||||
tsOffset := 0
|
||||
if !r.lastMarker {
|
||||
|
||||
Reference in New Issue
Block a user