Skip to content

Commit 842f423

Browse files
committed
Try to make the linters happy
1 parent abbd5eb commit 842f423

File tree

8 files changed

+48
-18
lines changed

8 files changed

+48
-18
lines changed

internal/test/mock_stream.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ func NewMockStream(info *interceptor.StreamInfo, i interceptor.Interceptor) *Moc
134134
pkts, err := rtcp.Unmarshal(buf[:i])
135135
if err != nil {
136136
mockStream.rtcpInModified <- RTCPWithError{Attr: attr, Err: err}
137+
137138
return
138139
}
139140

pkg/ccfb/ccfb_receiver.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,15 @@ func convertCCFB(ts time.Time, feedback *rtcp.CCFeedbackReport) (time.Time, map[
2323
for _, rb := range feedback.ReportBlocks {
2424
result[rb.MediaSSRC] = convertMetricBlock(referenceTime, rb.BeginSequence, rb.MetricBlocks)
2525
}
26+
2627
return referenceTime, result
2728
}
2829

29-
func convertMetricBlock(reference time.Time, seqNrOffset uint16, blocks []rtcp.CCFeedbackMetricBlock) []acknowledgement {
30+
func convertMetricBlock(
31+
reference time.Time,
32+
seqNrOffset uint16,
33+
blocks []rtcp.CCFeedbackMetricBlock,
34+
) []acknowledgement {
3035
reports := make([]acknowledgement, len(blocks))
3136
for i, mb := range blocks {
3237
if mb.Received {
@@ -55,5 +60,6 @@ func convertMetricBlock(reference time.Time, seqNrOffset uint16, blocks []rtcp.C
5560
}
5661
}
5762
}
63+
5864
return reports
5965
}

pkg/ccfb/duplicate_ack_filter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ type DuplicateAckFilter struct {
55
highestAckedBySSRC map[uint32]int64
66
}
77

8-
// NewDuplicateAckFilter creates a new DuplicateAckFilter
8+
// NewDuplicateAckFilter creates a new DuplicateAckFilter.
99
func NewDuplicateAckFilter() *DuplicateAckFilter {
1010
return &DuplicateAckFilter{
1111
highestAckedBySSRC: make(map[uint32]int64),

pkg/ccfb/history.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ func (h *historyList) add(seqNr uint16, size int, departure time.Time) error {
7070
if h.evictList.Len() > h.size {
7171
h.removeOldest()
7272
}
73+
7374
return nil
7475
}
7576

76-
// Must be called while holding the lock
77+
// Must be called while holding the lock.
7778
func (h *historyList) removeOldest() {
7879
if ent := h.evictList.Front(); ent != nil {
7980
v := h.evictList.Remove(ent)
@@ -106,5 +107,6 @@ func (h *historyList) getReportForAck(acks []acknowledgement) []PacketReport {
106107
}
107108
}
108109
}
110+
109111
return reports
110112
}

pkg/ccfb/history_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ func TestHistory(t *testing.T) {
9191
})
9292

9393
t.Run("garbageCollection", func(t *testing.T) {
94-
h := newHistoryList(200)
94+
hist := newHistoryList(200)
9595

9696
for i := uint16(0); i < 300; i++ {
97-
assert.NoError(t, h.add(i, 1200, time.Time{}.Add(time.Duration(i)*time.Millisecond)))
97+
assert.NoError(t, hist.add(i, 1200, time.Time{}.Add(time.Duration(i)*time.Millisecond)))
9898
}
9999

100100
acks := []acknowledgement{}
@@ -106,9 +106,9 @@ func TestHistory(t *testing.T) {
106106
ecn: 0,
107107
})
108108
}
109-
prl := h.getReportForAck(acks)
109+
prl := hist.getReportForAck(acks)
110110
assert.Len(t, prl, 90)
111-
assert.Equal(t, 200, len(h.seqNrToPacket))
112-
assert.Equal(t, 200, h.evictList.Len())
111+
assert.Equal(t, 200, len(hist.seqNrToPacket))
112+
assert.Equal(t, 200, hist.evictList.Len())
113113
})
114114
}

pkg/ccfb/interceptor.go

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const transportCCURI = "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide
1616
type ccfbAttributesKeyType uint32
1717

1818
// CCFBAttributesKey is the key which can be used to retrieve the Report objects
19-
// from the interceptor.Attributes
19+
// from the interceptor.Attributes.
2020
const CCFBAttributesKey ccfbAttributesKeyType = iota
2121

2222
// A Report contains Arrival and Departure (from the remote end) times of a RTCP
@@ -33,60 +33,66 @@ type history interface {
3333
getReportForAck([]acknowledgement) []PacketReport
3434
}
3535

36-
// Option can be used to set initial options on CCFB interceptors
36+
// Option can be used to set initial options on CCFB interceptors.
3737
type Option func(*Interceptor) error
3838

3939
// HistorySize sets the size of the history of outgoing packets.
4040
func HistorySize(size int) Option {
4141
return func(i *Interceptor) error {
4242
i.historySize = size
43+
4344
return nil
4445
}
4546
}
4647

4748
func timeFactory(f func() time.Time) Option {
4849
return func(i *Interceptor) error {
4950
i.timestamp = f
51+
5052
return nil
5153
}
5254
}
5355

5456
func historyFactory(f func(int) history) Option {
5557
return func(i *Interceptor) error {
5658
i.historyFactory = f
59+
5760
return nil
5861
}
5962
}
6063

64+
// nolint
6165
func ccfbConverterFactory(f func(ts time.Time, feedback *rtcp.CCFeedbackReport) (time.Time, map[uint32][]acknowledgement)) Option {
6266
return func(i *Interceptor) error {
6367
i.convertCCFB = f
68+
6469
return nil
6570
}
6671
}
6772

6873
func twccConverterFactory(f func(feedback *rtcp.TransportLayerCC) (time.Time, map[uint32][]acknowledgement)) Option {
6974
return func(i *Interceptor) error {
7075
i.convertTWCC = f
76+
7177
return nil
7278
}
7379
}
7480

75-
// InterceptorFactory is a factory for CCFB interceptors
81+
// InterceptorFactory is a factory for CCFB interceptors.
7682
type InterceptorFactory struct {
7783
opts []Option
7884
}
7985

80-
// NewInterceptor returns a new CCFB InterceptorFactory
86+
// NewInterceptor returns a new CCFB InterceptorFactory.
8187
func NewInterceptor(opts ...Option) (*InterceptorFactory, error) {
8288
return &InterceptorFactory{
8389
opts: opts,
8490
}, nil
8591
}
8692

87-
// NewInterceptor returns a new ccfb.Interceptor
93+
// NewInterceptor returns a new ccfb.Interceptor.
8894
func (f *InterceptorFactory) NewInterceptor(_ string) (interceptor.Interceptor, error) {
89-
i := &Interceptor{
95+
in := &Interceptor{
9096
NoOp: interceptor.NoOp{},
9197
lock: sync.Mutex{},
9298
log: logging.NewDefaultLoggerFactory().NewLogger("ccfb_interceptor"),
@@ -100,11 +106,12 @@ func (f *InterceptorFactory) NewInterceptor(_ string) (interceptor.Interceptor,
100106
},
101107
}
102108
for _, opt := range f.opts {
103-
if err := opt(i); err != nil {
109+
if err := opt(in); err != nil {
104110
return nil, err
105111
}
106112
}
107-
return i, nil
113+
114+
return in, nil
108115
}
109116

110117
// Interceptor implements a congestion control feedback receiver. It keeps track
@@ -129,13 +136,17 @@ type Interceptor struct {
129136
}
130137

131138
// BindLocalStream implements interceptor.Interceptor.
132-
func (i *Interceptor) BindLocalStream(info *interceptor.StreamInfo, writer interceptor.RTPWriter) interceptor.RTPWriter {
139+
func (i *Interceptor) BindLocalStream(
140+
info *interceptor.StreamInfo,
141+
writer interceptor.RTPWriter,
142+
) interceptor.RTPWriter {
133143
var twccHdrExtID uint8
134144
var useTWCC bool
135145
for _, e := range info.RTPHeaderExtensions {
136146
if e.URI == transportCCURI {
137147
twccHdrExtID = uint8(e.ID) // nolint:gosec
138148
useTWCC = true
149+
139150
break
140151
}
141152
}
@@ -149,6 +160,7 @@ func (i *Interceptor) BindLocalStream(info *interceptor.StreamInfo, writer inter
149160
}
150161
i.ssrcToHistory[ssrc] = i.historyFactory(i.historySize)
151162

163+
// nolint
152164
return interceptor.RTPWriterFunc(func(header *rtp.Header, payload []byte, attributes interceptor.Attributes) (int, error) {
153165
i.lock.Lock()
154166
defer i.lock.Unlock()
@@ -162,7 +174,11 @@ func (i *Interceptor) BindLocalStream(info *interceptor.StreamInfo, writer inter
162174
if useTWCC {
163175
var twccHdrExt rtp.TransportCCExtension
164176
if err := twccHdrExt.Unmarshal(header.GetExtension(twccHdrExtID)); err != nil {
165-
i.log.Warnf("CCFB configured for TWCC, but failed to get TWCC header extension from outgoing packet. Falling back to saving history for CCFB feedback reports. err: %v", err)
177+
i.log.Warnf(
178+
"CCFB configured for TWCC, but failed to get TWCC header extension from outgoing packet."+
179+
"Falling back to saving history for CCFB feedback reports. err: %v",
180+
err,
181+
)
166182
if _, ok := i.ssrcToHistory[ssrc]; !ok {
167183
i.ssrcToHistory[ssrc] = i.historyFactory(i.historySize)
168184
}
@@ -174,6 +190,7 @@ func (i *Interceptor) BindLocalStream(info *interceptor.StreamInfo, writer inter
174190
if err := i.ssrcToHistory[ssrc].add(seqNr, header.MarshalSize()+len(payload), i.timestamp()); err != nil {
175191
return 0, err
176192
}
193+
177194
return writer.Write(header, payload, attributes)
178195
})
179196
}
@@ -226,6 +243,7 @@ func (i *Interceptor) BindRTCPReader(reader interceptor.RTCPReader) interceptor.
226243
})
227244
}
228245
attr.Set(CCFBAttributesKey, res)
246+
229247
return n, attr, err
230248
})
231249
}

pkg/ccfb/interceptor_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func (m *mockHistory) add(seqNr uint16, size int, departure time.Time) error {
3030
size: size,
3131
departure: departure,
3232
})
33+
3334
return nil
3435
}
3536

@@ -38,6 +39,7 @@ func (m *mockHistory) getReportForAck(_ []acknowledgement) []PacketReport {
3839
return m.report
3940
}
4041

42+
// nolint
4143
func TestInterceptor(t *testing.T) {
4244
mockTimestamp := time.Time{}.Add(17 * time.Second)
4345
t.Run("writeRTP", func(t *testing.T) {

pkg/ccfb/twcc_receiver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/pion/rtcp"
77
)
88

9+
// nolint
910
func convertTWCC(feedback *rtcp.TransportLayerCC) (time.Time, map[uint32][]acknowledgement) {
1011
if feedback == nil {
1112
return time.Time{}, nil

0 commit comments

Comments
 (0)