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:
@@ -105,14 +105,13 @@ func TestPacketDropped(t *testing.T) {
|
||||
|
||||
// drop a head packet and check offset increases
|
||||
params = &testutils.TestExtPacketParams{
|
||||
IsHead: true,
|
||||
SequenceNumber: 44444,
|
||||
Timestamp: 0xabcdef,
|
||||
SSRC: 0x12345678,
|
||||
}
|
||||
extPkt, _ = testutils.GetTestExtPacket(params)
|
||||
r.highestIncomingSN = 44444
|
||||
r.PacketDropped(extPkt)
|
||||
require.Equal(t, r.highestIncomingSN, uint16(44444))
|
||||
require.Equal(t, r.lastSN, uint16(44443))
|
||||
require.Equal(t, uint16(1), r.snOffset)
|
||||
}
|
||||
@@ -124,15 +123,18 @@ func TestOutOfOrderSequenceNumber(t *testing.T) {
|
||||
SequenceNumber: 23333,
|
||||
Timestamp: 0xabcdef,
|
||||
SSRC: 0x12345678,
|
||||
PayloadSize: 10,
|
||||
}
|
||||
extPkt, _ := testutils.GetTestExtPacket(params)
|
||||
r.SetLastSnTs(extPkt)
|
||||
r.UpdateAndGetSnTs(extPkt)
|
||||
|
||||
// out-of-order sequence number not in the missing sequence number cache
|
||||
params = &testutils.TestExtPacketParams{
|
||||
SequenceNumber: 23332,
|
||||
Timestamp: 0xabcdef,
|
||||
SSRC: 0x12345678,
|
||||
PayloadSize: 10,
|
||||
}
|
||||
extPkt, _ = testutils.GetTestExtPacket(params)
|
||||
|
||||
@@ -164,7 +166,6 @@ func TestDuplicateSequenceNumber(t *testing.T) {
|
||||
r := newRTPMunger()
|
||||
|
||||
params := &testutils.TestExtPacketParams{
|
||||
IsHead: true,
|
||||
SequenceNumber: 23333,
|
||||
Timestamp: 0xabcdef,
|
||||
SSRC: 0x12345678,
|
||||
@@ -190,7 +191,6 @@ func TestPaddingOnlyPacket(t *testing.T) {
|
||||
r := newRTPMunger()
|
||||
|
||||
params := &testutils.TestExtPacketParams{
|
||||
IsHead: true,
|
||||
SequenceNumber: 23333,
|
||||
Timestamp: 0xabcdef,
|
||||
SSRC: 0x12345678,
|
||||
@@ -213,7 +213,6 @@ func TestPaddingOnlyPacket(t *testing.T) {
|
||||
|
||||
// padding only packet with a gap should not report an error
|
||||
params = &testutils.TestExtPacketParams{
|
||||
IsHead: true,
|
||||
SequenceNumber: 23335,
|
||||
Timestamp: 0xabcdef,
|
||||
SSRC: 0x12345678,
|
||||
@@ -238,7 +237,6 @@ func TestGapInSequenceNumber(t *testing.T) {
|
||||
r := newRTPMunger()
|
||||
|
||||
params := &testutils.TestExtPacketParams{
|
||||
IsHead: true,
|
||||
SequenceNumber: 65533,
|
||||
Timestamp: 0xabcdef,
|
||||
SSRC: 0x12345678,
|
||||
@@ -252,7 +250,6 @@ func TestGapInSequenceNumber(t *testing.T) {
|
||||
|
||||
// three lost packets
|
||||
params = &testutils.TestExtPacketParams{
|
||||
IsHead: true,
|
||||
SequenceNumber: 1,
|
||||
Timestamp: 0xabcdef,
|
||||
SSRC: 0x12345678,
|
||||
@@ -287,7 +284,6 @@ func TestUpdateAndGetPaddingSnTs(t *testing.T) {
|
||||
r := newRTPMunger()
|
||||
|
||||
params := &testutils.TestExtPacketParams{
|
||||
IsHead: true,
|
||||
SequenceNumber: 23333,
|
||||
Timestamp: 0xabcdef,
|
||||
SSRC: 0x12345678,
|
||||
@@ -333,7 +329,6 @@ func TestIsOnFrameBoundary(t *testing.T) {
|
||||
r := newRTPMunger()
|
||||
|
||||
params := &testutils.TestExtPacketParams{
|
||||
IsHead: true,
|
||||
SequenceNumber: 23333,
|
||||
Timestamp: 0xabcdef,
|
||||
SSRC: 0x12345678,
|
||||
@@ -349,7 +344,6 @@ func TestIsOnFrameBoundary(t *testing.T) {
|
||||
|
||||
// packet with RTP marker
|
||||
params = &testutils.TestExtPacketParams{
|
||||
IsHead: true,
|
||||
SetMarker: true,
|
||||
SequenceNumber: 23334,
|
||||
Timestamp: 0xabcdef,
|
||||
|
||||
Reference in New Issue
Block a user