Skip to content

WIP: simplify interface to TWCC 3/4 #298

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 2 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
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 @@
}

// 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
7 changes: 6 additions & 1 deletion registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@
}

// Build constructs a single Interceptor from a InterceptorRegistry
func (r *Registry) Build(id string) (Interceptor, error) {
// The extra interceptors are added to the chain before the ones specified
// by the registry.
func (r *Registry) Build(id string, extra... Interceptor) (Interceptor, error) {

Check warning on line 19 in registry.go

View check run for this annotation

Codecov / codecov/patch

registry.go#L19

Added line #L19 was not covered by tests
if len(r.factories) == 0 {
return &NoOp{}, nil
}

interceptors := []Interceptor{}

interceptors = append(interceptors, extra...)

Check warning on line 27 in registry.go

View check run for this annotation

Codecov / codecov/patch

registry.go#L25-L27

Added lines #L25 - L27 were not covered by tests
for _, f := range r.factories {
i, err := f.NewInterceptor(id)
if err != nil {
Expand Down
Loading