Skip to content

Commit 561a285

Browse files
committed
Try to make the linters happy
1 parent abbd5eb commit 561a285

File tree

7 files changed

+44
-18
lines changed

7 files changed

+44
-18
lines changed

internal/test/mock_stream.go

+1
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

+7-1
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

+1-1
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

+3-1
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

+5-5
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

+26-10
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,65 @@ 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

6164
func ccfbConverterFactory(f func(ts time.Time, feedback *rtcp.CCFeedbackReport) (time.Time, map[uint32][]acknowledgement)) Option {
6265
return func(i *Interceptor) error {
6366
i.convertCCFB = f
67+
6468
return nil
6569
}
6670
}
6771

6872
func twccConverterFactory(f func(feedback *rtcp.TransportLayerCC) (time.Time, map[uint32][]acknowledgement)) Option {
6973
return func(i *Interceptor) error {
7074
i.convertTWCC = f
75+
7176
return nil
7277
}
7378
}
7479

75-
// InterceptorFactory is a factory for CCFB interceptors
80+
// InterceptorFactory is a factory for CCFB interceptors.
7681
type InterceptorFactory struct {
7782
opts []Option
7883
}
7984

80-
// NewInterceptor returns a new CCFB InterceptorFactory
85+
// NewInterceptor returns a new CCFB InterceptorFactory.
8186
func NewInterceptor(opts ...Option) (*InterceptorFactory, error) {
8287
return &InterceptorFactory{
8388
opts: opts,
8489
}, nil
8590
}
8691

87-
// NewInterceptor returns a new ccfb.Interceptor
92+
// NewInterceptor returns a new ccfb.Interceptor.
8893
func (f *InterceptorFactory) NewInterceptor(_ string) (interceptor.Interceptor, error) {
89-
i := &Interceptor{
94+
in := &Interceptor{
9095
NoOp: interceptor.NoOp{},
9196
lock: sync.Mutex{},
9297
log: logging.NewDefaultLoggerFactory().NewLogger("ccfb_interceptor"),
@@ -100,11 +105,12 @@ func (f *InterceptorFactory) NewInterceptor(_ string) (interceptor.Interceptor,
100105
},
101106
}
102107
for _, opt := range f.opts {
103-
if err := opt(i); err != nil {
108+
if err := opt(in); err != nil {
104109
return nil, err
105110
}
106111
}
107-
return i, nil
112+
113+
return in, nil
108114
}
109115

110116
// Interceptor implements a congestion control feedback receiver. It keeps track
@@ -129,13 +135,17 @@ type Interceptor struct {
129135
}
130136

131137
// BindLocalStream implements interceptor.Interceptor.
132-
func (i *Interceptor) BindLocalStream(info *interceptor.StreamInfo, writer interceptor.RTPWriter) interceptor.RTPWriter {
138+
func (i *Interceptor) BindLocalStream(
139+
info *interceptor.StreamInfo,
140+
writer interceptor.RTPWriter,
141+
) interceptor.RTPWriter {
133142
var twccHdrExtID uint8
134143
var useTWCC bool
135144
for _, e := range info.RTPHeaderExtensions {
136145
if e.URI == transportCCURI {
137146
twccHdrExtID = uint8(e.ID) // nolint:gosec
138147
useTWCC = true
148+
139149
break
140150
}
141151
}
@@ -162,7 +172,11 @@ func (i *Interceptor) BindLocalStream(info *interceptor.StreamInfo, writer inter
162172
if useTWCC {
163173
var twccHdrExt rtp.TransportCCExtension
164174
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)
175+
i.log.Warnf(
176+
"CCFB configured for TWCC, but failed to get TWCC header extension from outgoing packet."+
177+
"Falling back to saving history for CCFB feedback reports. err: %v",
178+
err,
179+
)
166180
if _, ok := i.ssrcToHistory[ssrc]; !ok {
167181
i.ssrcToHistory[ssrc] = i.historyFactory(i.historySize)
168182
}
@@ -174,6 +188,7 @@ func (i *Interceptor) BindLocalStream(info *interceptor.StreamInfo, writer inter
174188
if err := i.ssrcToHistory[ssrc].add(seqNr, header.MarshalSize()+len(payload), i.timestamp()); err != nil {
175189
return 0, err
176190
}
191+
177192
return writer.Write(header, payload, attributes)
178193
})
179194
}
@@ -226,6 +241,7 @@ func (i *Interceptor) BindRTCPReader(reader interceptor.RTCPReader) interceptor.
226241
})
227242
}
228243
attr.Set(CCFBAttributesKey, res)
244+
229245
return n, attr, err
230246
})
231247
}

pkg/ccfb/interceptor_test.go

+1
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

0 commit comments

Comments
 (0)