Skip to content

Commit 5d46b4b

Browse files
committed
Implement cc.NewSingleInterceptor
Creates a single interceptor without going through a factory.
1 parent 1a82ea1 commit 5d46b4b

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

pkg/cc/interceptor.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,37 @@ func (f *InterceptorFactory) OnNewPeerConnection(cb NewPeerConnectionCallback) {
6161
}
6262

6363
// NewInterceptor returns a new CC interceptor
64+
// Don't call this, call [NewSingleInterceptor] instead.
6465
func (f *InterceptorFactory) NewInterceptor(id string) (interceptor.Interceptor, error) {
6566
bwe, err := f.bweFactory()
6667
if err != nil {
6768
return nil, err
6869
}
70+
i, err := NewSingleInterceptor(bwe, f.opts...)
71+
if err != nil {
72+
return nil, err
73+
}
74+
75+
if f.addPeerConnection != nil {
76+
f.addPeerConnection(id, i.estimator)
77+
}
78+
return i, nil
79+
}
80+
81+
// NewSingleInterceptor returns a new CC interceptor
82+
func NewSingleInterceptor(bwe BandwidthEstimator, options ...Option) (*Interceptor, error) {
6983
i := &Interceptor{
7084
NoOp: interceptor.NoOp{},
7185
estimator: bwe,
7286
feedback: make(chan []rtcp.Packet),
7387
close: make(chan struct{}),
7488
}
7589

76-
for _, opt := range f.opts {
90+
for _, opt := range options {
7791
if err := opt(i); err != nil {
7892
return nil, err
7993
}
8094
}
81-
82-
if f.addPeerConnection != nil {
83-
f.addPeerConnection(id, i.estimator)
84-
}
8595
return i, nil
8696
}
8797

0 commit comments

Comments
 (0)