Skip to content

Commit

Permalink
Implement cc.NewSingleInterceptor
Browse files Browse the repository at this point in the history
Creates a single interceptor without going through a factory.
  • Loading branch information
jech committed Jan 13, 2025
1 parent 1a82ea1 commit 5d46b4b
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions pkg/cc/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,37 @@ func (f *InterceptorFactory) OnNewPeerConnection(cb NewPeerConnectionCallback) {
}

// NewInterceptor returns a new CC interceptor
// Don't call this, call [NewSingleInterceptor] instead.
func (f *InterceptorFactory) NewInterceptor(id string) (interceptor.Interceptor, error) {
bwe, err := f.bweFactory()
if err != nil {
return nil, err
}
i, err := NewSingleInterceptor(bwe, f.opts...)
if err != nil {
return nil, err
}

Check warning on line 73 in pkg/cc/interceptor.go

View check run for this annotation

Codecov / codecov/patch

pkg/cc/interceptor.go#L70-L73

Added lines #L70 - L73 were not covered by tests

if f.addPeerConnection != nil {
f.addPeerConnection(id, i.estimator)
}
return i, nil

Check warning on line 78 in pkg/cc/interceptor.go

View check run for this annotation

Codecov / codecov/patch

pkg/cc/interceptor.go#L75-L78

Added lines #L75 - L78 were not covered by tests
}

// NewSingleInterceptor returns a new CC interceptor
func NewSingleInterceptor(bwe BandwidthEstimator, options ...Option) (*Interceptor, error) {

Check warning on line 82 in pkg/cc/interceptor.go

View check run for this annotation

Codecov / codecov/patch

pkg/cc/interceptor.go#L82

Added line #L82 was not covered by tests
i := &Interceptor{
NoOp: interceptor.NoOp{},
estimator: bwe,
feedback: make(chan []rtcp.Packet),
close: make(chan struct{}),
}

for _, opt := range f.opts {
for _, opt := range options {

Check warning on line 90 in pkg/cc/interceptor.go

View check run for this annotation

Codecov / codecov/patch

pkg/cc/interceptor.go#L90

Added line #L90 was not covered by tests
if err := opt(i); err != nil {
return nil, err
}
}

if f.addPeerConnection != nil {
f.addPeerConnection(id, i.estimator)
}
return i, nil
}

Expand Down

0 comments on commit 5d46b4b

Please sign in to comment.