Handle duplicate padding packet in the up stream. (#2012)
* Handle duplicate padding packet in the up stream. The following sequence would have produce incorrect results - Sequence number 39 - regular packet - offset = 0 - Sequence number 40 - padding only - drop - offset = 1 - Sequence number 40 - padding only duplicate - was not dropped (this is the bug) - apply offet - sequence number becomes 39 and clashes with previous packet - Sequence number 41 - regular packet - apply offset - goes through as 40. - Sequence number 40 again - does not get dropped - will pass through as 39. * fix duplicate dropping * fix tests * accept repeat last value as padding injection could cause that * use exclusion ranges * more UT and more specific errors
This commit is contained in:
@@ -62,6 +62,7 @@ type RTPFlowState struct {
|
||||
LossStartInclusive uint64
|
||||
LossEndExclusive uint64
|
||||
|
||||
IsDuplicate bool
|
||||
IsOutOfOrder bool
|
||||
|
||||
ExtSequenceNumber uint64
|
||||
@@ -409,7 +410,6 @@ func (r *RTPStats) Update(rtph *rtp.Header, payloadSize int, paddingSize int, pa
|
||||
|
||||
hdrSize := uint64(rtph.MarshalSize())
|
||||
pktSize := hdrSize + uint64(payloadSize+paddingSize)
|
||||
isDuplicate := false
|
||||
gapSN := int64(resSN.ExtendedVal - resSN.PreExtendedHighest)
|
||||
if gapSN <= 0 { // duplicate OR out-of-order
|
||||
if payloadSize == 0 {
|
||||
@@ -458,7 +458,7 @@ func (r *RTPStats) Update(rtph *rtp.Header, payloadSize int, paddingSize int, pa
|
||||
r.bytesDuplicate += pktSize
|
||||
r.headerBytesDuplicate += hdrSize
|
||||
r.packetsDuplicate++
|
||||
isDuplicate = true
|
||||
flowState.IsDuplicate = true
|
||||
} else {
|
||||
r.packetsLost--
|
||||
r.setSnInfo(resSN.ExtendedVal, resSN.PreExtendedHighest, uint16(pktSize), uint16(hdrSize), uint16(payloadSize), rtph.Marker, true)
|
||||
@@ -492,7 +492,7 @@ func (r *RTPStats) Update(rtph *rtp.Header, payloadSize int, paddingSize int, pa
|
||||
flowState.ExtTimestamp = resTS.ExtendedVal
|
||||
}
|
||||
|
||||
if !isDuplicate {
|
||||
if !flowState.IsDuplicate {
|
||||
if payloadSize == 0 {
|
||||
r.packetsPadding++
|
||||
r.bytesPadding += pktSize
|
||||
|
||||
Reference in New Issue
Block a user