Remove Head field from ExtPacket structure. (#662)

* Remove `Head` field from `ExtPacket` structure.

Although we do not intend to, but if packets get out-of-order
in the forwarding path (maybe reading in multiple goroutines
or using some worker pool to distribute packets), the `Head`
indicator could lead to wrong behaviour. It is possible that
at the receiver, the order is
- Seq Num N, Head = true
- N + 1, Head = true

If the forwarding path sees `N + 1` first, the Head flag
when it sees `N` packet is incorrect and will lead to incorrect
behaviour.

The alternative check is very simple. So, remove `Head` flag.

* Remove unused field
This commit is contained in:
Raja Subramanian
2022-05-02 10:16:17 +05:30
committed by GitHub
parent 3508609bbe
commit d863b45dc1
8 changed files with 11 additions and 52 deletions
+3 -5
View File
@@ -92,11 +92,9 @@ func (r *RTPMunger) UpdateSnTsOffsets(extPkt *buffer.ExtPacket, snAdjust uint16,
}
func (r *RTPMunger) PacketDropped(extPkt *buffer.ExtPacket) {
if !extPkt.Head {
if r.highestIncomingSN != extPkt.Packet.SequenceNumber {
return
}
r.highestIncomingSN = extPkt.Packet.SequenceNumber
r.snOffset += 1
r.lastSN = extPkt.Packet.SequenceNumber - r.snOffset
@@ -109,7 +107,8 @@ func (r *RTPMunger) PacketDropped(extPkt *buffer.ExtPacket) {
func (r *RTPMunger) UpdateAndGetSnTs(extPkt *buffer.ExtPacket) (*TranslationParamsRTP, error) {
// if out-of-order, look up sequence number offset cache
if !extPkt.Head {
diff := extPkt.Packet.SequenceNumber - r.highestIncomingSN
if diff > (1 << 15) {
snOffset, isValid := r.getSnOffset(extPkt.Packet.SequenceNumber)
if !isValid {
return &TranslationParamsRTP{
@@ -126,7 +125,6 @@ func (r *RTPMunger) UpdateAndGetSnTs(extPkt *buffer.ExtPacket) (*TranslationPara
ordering := SequenceNumberOrderingContiguous
diff := extPkt.Packet.SequenceNumber - r.highestIncomingSN
if diff > 1 {
ordering = SequenceNumberOrderingGap
} else {