Skip to content

Unmarshal only actually read bytes #257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: pion/.goassets/.github/workflows/test.reusable.yml@master
strategy:
matrix:
go: ["1.22", "1.21"] # auto-update/supported-go-version-list
go: ["1.23", "1.22"] # auto-update/supported-go-version-list
fail-fast: false
with:
go-version: ${{ matrix.go }}
Expand All @@ -33,13 +33,13 @@ jobs:
uses: pion/.goassets/.github/workflows/test-i386.reusable.yml@master
strategy:
matrix:
go: ["1.22", "1.21"] # auto-update/supported-go-version-list
go: ["1.23", "1.22"] # auto-update/supported-go-version-list
fail-fast: false
with:
go-version: ${{ matrix.go }}

test-wasm:
uses: pion/.goassets/.github/workflows/test-wasm.reusable.yml@master
with:
go-version: "1.22" # auto-update/latest-go-version
go-version: "1.23" # auto-update/latest-go-version
secrets: inherit
8 changes: 4 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
# SPDX-License-Identifier: MIT

run:
timeout: 5m

linters-settings:
govet:
enable:
Expand Down Expand Up @@ -48,7 +51,7 @@ linters:
- goconst # Finds repeated strings that could be replaced by a constant
- gocritic # The most opinionated Go source code linter
- godox # Tool for detection of FIXME, TODO and other comment keywords
- goerr113 # Golang linter to check the errors handling expressions
- err113 # Golang linter to check the errors handling expressions
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
- gofumpt # Gofumpt checks whether code was gofumpt-ed.
- goheader # Checks is file header matches to pattern
Expand Down Expand Up @@ -83,17 +86,14 @@ linters:
- depguard # Go linter that checks if package imports are in a list of acceptable packages
- containedctx # containedctx is a linter that detects struct contained context.Context field
- cyclop # checks function and package cyclomatic complexity
- exhaustivestruct # Checks if all struct's fields are initialized
- funlen # Tool for detection of long functions
- gocyclo # Computes and checks the cyclomatic complexity of functions
- godot # Check if comments end in a period
- gomnd # An analyzer to detect magic numbers.
- ifshort # Checks that your code uses short syntax for if-statements whenever possible
- ireturn # Accept Interfaces, Return Concrete Types
- lll # Reports long lines
- maintidx # maintidx measures the maintainability index of each function.
- makezero # Finds slice declarations with non-zero initial length
- maligned # Tool to detect Go structs that would take less memory if their fields were sorted
- nakedret # Finds naked returns in functions greater than a specified function length
- nestif # Reports deeply nested if statements
- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module github.com/pion/interceptor

go 1.19
go 1.20

require (
github.com/pion/logging v0.2.2
github.com/pion/rtcp v1.2.14
github.com/pion/rtp v1.8.6
github.com/pion/transport/v3 v3.0.2
github.com/pion/rtp v1.8.9
github.com/pion/transport/v3 v3.0.7
github.com/stretchr/testify v1.9.0
)

Expand Down
54 changes: 5 additions & 49 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,65 +7,21 @@ github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=
github.com/pion/rtcp v1.2.14 h1:KCkGV3vJ+4DAJmvP0vaQShsb0xkRfWkO540Gy102KyE=
github.com/pion/rtcp v1.2.14/go.mod h1:sn6qjxvnwyAkkPzPULIbVqSKI5Dv54Rv7VG0kNxh9L4=
github.com/pion/rtp v1.8.6 h1:MTmn/b0aWWsAzux2AmP8WGllusBVw4NPYPVFFd7jUPw=
github.com/pion/rtp v1.8.6/go.mod h1:pBGHaFt/yW7bf1jjWAoUjpSNoDnw98KTMg+jWWvziqU=
github.com/pion/transport/v3 v3.0.2 h1:r+40RJR25S9w3jbA6/5uEPTzcdn7ncyU44RWCbHkLg4=
github.com/pion/transport/v3 v3.0.2/go.mod h1:nIToODoOlb5If2jF9y2Igfx3PFYWfuXi37m0IlWa/D0=
github.com/pion/rtp v1.8.9 h1:E2HX740TZKaqdcPmf4pw6ZZuG8u5RlMMt+l3dxeu6Wk=
github.com/pion/rtp v1.8.9/go.mod h1:pBGHaFt/yW7bf1jjWAoUjpSNoDnw98KTMg+jWWvziqU=
github.com/pion/transport/v3 v3.0.7 h1:iRbMH05BzSNwhILHoBoAPxoB9xQgOaJk+591KC9P1o0=
github.com/pion/transport/v3 v3.0.7/go.mod h1:YleKiTZ4vqNxVwh77Z0zytYi7rXHl7j6uPLGhhz9rwo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
8 changes: 4 additions & 4 deletions pkg/gcc/gcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ func maxInt(a, b int) int {
return b
}

func clampInt(b, min, max int) int {
return maxInt(min, minInt(max, b))
func clampInt(b, minVal, maxVal int) int {
return maxInt(minVal, minInt(maxVal, b))
}

func clampDuration(d, min, max time.Duration) time.Duration {
return time.Duration(clampInt(int(d), int(min), int(max)))
func clampDuration(d, minVal, maxVal time.Duration) time.Duration {
return time.Duration(clampInt(int(d), int(minVal), int(maxVal)))
}
6 changes: 3 additions & 3 deletions pkg/gcc/gcc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ func TestClamp(t *testing.T) {
})
t.Run(fmt.Sprintf("duration/%v", i), func(t *testing.T) {
x := time.Duration(tt.x)
min := time.Duration(tt.min)
max := time.Duration(tt.max)
minVal := time.Duration(tt.min)
maxVal := time.Duration(tt.max)
expected := time.Duration(tt.expected)
assert.Equal(t, expected, clampDuration(x, min, max))
assert.Equal(t, expected, clampDuration(x, minVal, maxVal))
})
}
}
5 changes: 5 additions & 0 deletions pkg/jitterbuffer/priority_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func (q *PriorityQueue) Pop() (*rtp.Packet, error) {
return nil, ErrInvalidOperation
}
val := q.next.val
q.next.val = nil
q.length--
q.next = q.next.next
return val, nil
Expand All @@ -126,6 +127,7 @@ func (q *PriorityQueue) PopAt(sqNum uint16) (*rtp.Packet, error) {
}
if q.next.priority == sqNum {
val := q.next.val
q.next.val = nil
q.next = q.next.next
q.length--
return val, nil
Expand All @@ -135,6 +137,7 @@ func (q *PriorityQueue) PopAt(sqNum uint16) (*rtp.Packet, error) {
for pos != nil {
if pos.priority == sqNum {
val := pos.val
pos.val = nil
prev.next = pos.next
if prev.next != nil {
prev.next.prev = prev
Expand All @@ -156,6 +159,7 @@ func (q *PriorityQueue) PopAtTimestamp(timestamp uint32) (*rtp.Packet, error) {
}
if q.next.val.Timestamp == timestamp {
val := q.next.val
q.next.val = nil
q.next = q.next.next
q.length--
return val, nil
Expand All @@ -165,6 +169,7 @@ func (q *PriorityQueue) PopAtTimestamp(timestamp uint32) (*rtp.Packet, error) {
for pos != nil {
if pos.val.Timestamp == timestamp {
val := pos.val
pos.val = nil
prev.next = pos.next
if prev.next != nil {
prev.next.prev = prev
Expand Down
46 changes: 46 additions & 0 deletions pkg/jitterbuffer/priority_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
package jitterbuffer

import (
"runtime"
"sync/atomic"
"testing"
"time"

"github.com/pion/rtp"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -136,3 +139,46 @@ func TestPriorityQueue_Clean(t *testing.T) {
assert.EqualValues(t, 1, packets.Length())
packets.Clear()
}

func TestPriorityQueue_Unreference(t *testing.T) {
packets := NewQueue()

var refs int64
finalizer := func(*rtp.Packet) {
atomic.AddInt64(&refs, -1)
}

numPkts := 100
for i := 0; i < numPkts; i++ {
atomic.AddInt64(&refs, 1)
seq := uint16(i)
p := rtp.Packet{
Header: rtp.Header{
SequenceNumber: seq,
Timestamp: uint32(i + 42),
},
Payload: []byte{byte(i)},
}
runtime.SetFinalizer(&p, finalizer)
packets.Push(&p, seq)
}
for i := 0; i < numPkts-1; i++ {
switch i % 3 {
case 0:
packets.Pop() //nolint
case 1:
packets.PopAt(uint16(i)) //nolint
case 2:
packets.PopAtTimestamp(uint32(i + 42)) //nolint
}
}

runtime.GC()
time.Sleep(10 * time.Millisecond)

remainedRefs := atomic.LoadInt64(&refs)
runtime.KeepAlive(packets)

// only the last packet should be still referenced
assert.Equal(t, int64(1), remainedRefs)
}
6 changes: 3 additions & 3 deletions pkg/jitterbuffer/receiver_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func NewInterceptor(opts ...ReceiverInterceptorOption) (*InterceptorFactory, err
return &InterceptorFactory{opts}, nil
}

// BindRemoteStream lets you modify any incoming RTP packets. It is called once for per RemoteStream. The returned method
// will be called once per rtp packet.
// BindRemoteStream lets you modify any incoming RTP packets. It is called once per
// RemoteStream. The returned method will be called once per rtp packet.
func (i *ReceiverInterceptor) BindRemoteStream(_ *interceptor.StreamInfo, reader interceptor.RTPReader) interceptor.RTPReader {
return interceptor.RTPReaderFunc(func(b []byte, a interceptor.Attributes) (int, interceptor.Attributes, error) {
buf := make([]byte, len(b))
Expand All @@ -74,7 +74,7 @@ func (i *ReceiverInterceptor) BindRemoteStream(_ *interceptor.StreamInfo, reader
return n, attr, err
}
packet := &rtp.Packet{}
if err := packet.Unmarshal(buf); err != nil {
if err := packet.Unmarshal(buf[:n]); err != nil {
return 0, nil, err
}
i.m.Lock()
Expand Down
54 changes: 49 additions & 5 deletions pkg/jitterbuffer/receiver_interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import (
"bytes"
"errors"
"testing"
"time"

Expand All @@ -17,8 +18,6 @@
)

func TestBufferStart(t *testing.T) {
buf := bytes.Buffer{}

factory, err := NewInterceptor(
Log(logging.NewDefaultLoggerFactory().NewLogger("test")),
)
Expand All @@ -27,8 +26,6 @@
i, err := factory.NewInterceptor("")
assert.NoError(t, err)

assert.Zero(t, buf.Len())

stream := test.NewMockStream(&interceptor.StreamInfo{
SSRC: 123456,
ClockRate: 90000,
Expand All @@ -55,7 +52,6 @@
}
err = i.Close()
assert.NoError(t, err)
assert.Zero(t, buf.Len())
}

func TestReceiverBuffersAndPlaysout(t *testing.T) {
Expand Down Expand Up @@ -96,3 +92,51 @@
err = i.Close()
assert.NoError(t, err)
}

type MockRTPReader struct {
readFunc func([]byte, interceptor.Attributes) (int, interceptor.Attributes, error)
}

func (m *MockRTPReader) Read(data []byte, attrs interceptor.Attributes) (int, interceptor.Attributes, error) {
if m.readFunc != nil {
return m.readFunc(data, attrs)
}
return 0, nil, errors.New("mock function not implemented")

Check failure on line 104 in pkg/jitterbuffer/receiver_interceptor_test.go

View workflow job for this annotation

GitHub Actions / lint / Go

do not define dynamic errors, use wrapped static errors instead: "errors.New(\"mock function not implemented\")" (err113)
}

func NewMockRTPReader(readFunc func([]byte, interceptor.Attributes) (int, interceptor.Attributes, error)) *MockRTPReader {
return &MockRTPReader{
readFunc: readFunc,
}
}

func TestReceiverInterceptorHonorsBufferLength(t *testing.T) {
buf := []byte{0x80, 0x88, 0xe6, 0xfd, 0x01, 0x01, 0x01, 0x01, 0x01,
0xde, 0xad, 0xbe, 0xef, 0x01, 0x01, 0x01, 0x01, 0x01}
readBuf := make([]byte, 2048)
copy(readBuf[0:], buf)
copy(readBuf[17:], buf)
factory, err := NewInterceptor(
Log(logging.NewDefaultLoggerFactory().NewLogger("test")),
)
assert.NoError(t, err)

i, err := factory.NewInterceptor("")

Check failure on line 124 in pkg/jitterbuffer/receiver_interceptor_test.go

View workflow job for this annotation

GitHub Actions / lint / Go

ineffectual assignment to err (ineffassign)

rtpReadFn := NewMockRTPReader(func(data []byte, attrs interceptor.Attributes) (int, interceptor.Attributes, error) {
copy(data, readBuf)
return 7, attrs, nil
})
reader := i.BindRemoteStream(&interceptor.StreamInfo{
SSRC: 123456,
ClockRate: 90000,
}, rtpReadFn)

bufLen, _, err := reader.Read(readBuf, interceptor.Attributes{})
assert.Contains(t, err.Error(), "7 < 12")
assert.Equal(t, 0, bufLen)

err = i.Close()
assert.NoError(t, err)

}

Check failure on line 142 in pkg/jitterbuffer/receiver_interceptor_test.go

View workflow job for this annotation

GitHub Actions / lint / Go

unnecessary trailing newline (whitespace)
4 changes: 2 additions & 2 deletions pkg/nack/receive_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ func TestReceivedBuffer(t *testing.T) {
t.Fatalf("%+v", err)
}

all := func(min uint16, max uint16) []uint16 {
all := func(minVal uint16, maxVal uint16) []uint16 {
result := make([]uint16, 0)
for i := min; i != max+1; i++ {
for i := minVal; i != maxVal+1; i++ {
result = append(result, i)
}
return result
Expand Down
Loading
Loading