Skip to content

Commit 6128a7d

Browse files
authored
Removes duplicated unwrapper code
Reuse unwrapper code for RFC8888 implementation.
1 parent 3436288 commit 6128a7d

File tree

4 files changed

+12
-102
lines changed

4 files changed

+12
-102
lines changed

internal/sequencenumber/unwrapper_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ func TestUnwrapper(t *testing.T) {
8383
input: []uint16{32767, 0},
8484
expected: []int64{32767, 0},
8585
},
86+
{
87+
input: []uint16{0, 1, 4, 3, 2, 5},
88+
expected: []int64{0, 1, 4, 3, 2, 5},
89+
},
90+
{
91+
input: []uint16{65534, 0, 1, 65535, 4, 3, 2, 5},
92+
expected: []int64{65534, 65536, 65537, 65535, 65540, 65539, 65538, 65541},
93+
},
8694
{
8795
input: []uint16{
8896
0, 32767, 32768, 32769, 32770,

pkg/rfc8888/stream_log.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ package rfc8888
66
import (
77
"time"
88

9+
"github.com/pion/interceptor/internal/sequencenumber"
910
"github.com/pion/rtcp"
1011
)
1112

1213
const maxReportsPerReportBlock = 16384
1314

1415
type streamLog struct {
1516
ssrc uint32
16-
sequence unwrapper
17+
sequence sequencenumber.Unwrapper
1718
init bool
1819
nextSequenceNumberToReport int64 // next to report
1920
lastSequenceNumberReceived int64 // highest received
@@ -23,7 +24,7 @@ type streamLog struct {
2324
func newStreamLog(ssrc uint32) *streamLog {
2425
return &streamLog{
2526
ssrc: ssrc,
26-
sequence: unwrapper{},
27+
sequence: sequencenumber.Unwrapper{},
2728
init: false,
2829
nextSequenceNumberToReport: 0,
2930
lastSequenceNumberReceived: 0,
@@ -32,7 +33,7 @@ func newStreamLog(ssrc uint32) *streamLog {
3233
}
3334

3435
func (l *streamLog) add(ts time.Time, sequenceNumber uint16, ecn uint8) {
35-
unwrappedSequenceNumber := l.sequence.unwrap(sequenceNumber)
36+
unwrappedSequenceNumber := l.sequence.Unwrap(sequenceNumber)
3637
if !l.init {
3738
l.init = true
3839
l.nextSequenceNumberToReport = unwrappedSequenceNumber

pkg/rfc8888/unwrapper.go

Lines changed: 0 additions & 42 deletions
This file was deleted.

pkg/rfc8888/unwrapper_test.go

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)