Skip to content
Draft
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
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
module github.com/pion/interceptor

go 1.21.0
go 1.24.0

Check failure on line 3 in go.mod

View workflow job for this annotation

GitHub Actions / lint / Metadata

Invalid Go version

Found 1.24.0. Expected 1.21

require (
github.com/pion/bwe v0.0.0-20260204132927-94cf8ba60868
github.com/pion/logging v0.2.4
github.com/pion/rtcp v1.2.16
github.com/pion/rtp v1.10.1
github.com/pion/transport/v3 v3.1.1
github.com/stretchr/testify v1.11.1
golang.org/x/time v0.10.0
golang.org/x/time v0.14.0
)

require (
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pion/bwe v0.0.0-20260204132927-94cf8ba60868 h1:XbdptYjCt5Im8ilmIK3srO0VF7tm5NYKqwkdyShgplY=
github.com/pion/bwe v0.0.0-20260204132927-94cf8ba60868/go.mod h1:k5nSfHOk0AeVIKKqtsAykZDaUwk7iAwbMkeQqbHb7Ag=
github.com/pion/logging v0.2.4 h1:tTew+7cmQ+Mc1pTBLKH2puKsOvhm32dROumOZ655zB8=
github.com/pion/logging v0.2.4/go.mod h1:DffhXTKYdNZU+KtJ5pyQDjvOAh/GsNSyv1lbkFbe3so=
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
Expand All @@ -14,10 +16,10 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
golang.org/x/time v0.10.0 h1:3usCWA8tQn0L8+hFJQNgzpWbd89begxN66o1Ojdn5L4=
golang.org/x/time v0.10.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
46 changes: 43 additions & 3 deletions pkg/cc/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,35 @@

// Package cc implements an interceptor for bandwidth estimation that can be
// used with different BandwidthEstimators.
//
// Deprecated: Directly use the bwe implementation in
// https://github.com/pion/bwe instead.
package cc

import (
"fmt"

"github.com/pion/interceptor"
"github.com/pion/interceptor/pkg/gcc"
"github.com/pion/interceptor/pkg/gcc" //nolint
"github.com/pion/interceptor/pkg/rtpfb"
"github.com/pion/rtcp"
)

// Option can be used to set initial options on CC interceptors.
//
// Deprecated: See package comment.
type Option func(*Interceptor) error

// BandwidthEstimatorFactory creates new BandwidthEstimators.
//
// Deprecated: See package comment.
type BandwidthEstimatorFactory func() (BandwidthEstimator, error)

// BandwidthEstimator is the interface that will be returned by a
// NewPeerConnectionCallback and can be used to query current bandwidth
// metrics and add feedback manually.
//
// Deprecated: See package comment.
type BandwidthEstimator interface {
AddStream(*interceptor.StreamInfo, interceptor.RTPWriter) interceptor.RTPWriter
WriteRTCP([]rtcp.Packet, interceptor.Attributes) error
Expand All @@ -31,37 +43,53 @@ type BandwidthEstimator interface {

// NewPeerConnectionCallback returns the BandwidthEstimator for the
// PeerConnection with id.
//
// Deprecated: See package comment.
type NewPeerConnectionCallback func(id string, estimator BandwidthEstimator)

// InterceptorFactory is a factory for CC interceptors.
//
// Deprecated: See package comment.
type InterceptorFactory struct {
opts []Option
bweFactory func() (BandwidthEstimator, error)
addPeerConnection NewPeerConnectionCallback
rtpfbFactory *rtpfb.InterceptorFactory
}

// NewInterceptor returns a new CC interceptor factory.
//
// Deprecated: See package comment.
func NewInterceptor(factory BandwidthEstimatorFactory, opts ...Option) (*InterceptorFactory, error) {
if factory == nil {
factory = func() (BandwidthEstimator, error) {
return gcc.NewSendSideBWE()
}
}
fbi, err := rtpfb.NewInterceptor()
if err != nil {
return nil, fmt.Errorf("failed to create rtp feedback interceptor factory: %w", err)
}

return &InterceptorFactory{
opts: opts,
bweFactory: factory,
addPeerConnection: nil,
rtpfbFactory: fbi,
}, nil
}

// OnNewPeerConnection sets a callback that is called when a new CC interceptor
// is created.
//
// Deprecated: See package comment.
func (f *InterceptorFactory) OnNewPeerConnection(cb NewPeerConnectionCallback) {
f.addPeerConnection = cb
}

// NewInterceptor returns a new CC interceptor.
//
// Deprecated: See package comment.
func (f *InterceptorFactory) NewInterceptor(id string) (interceptor.Interceptor, error) {
bwe, err := f.bweFactory()
if err != nil {
Expand All @@ -75,19 +103,25 @@ func (f *InterceptorFactory) NewInterceptor(id string) (interceptor.Interceptor,
}

for _, opt := range f.opts {
if err := opt(interceptorInstance); err != nil {
if err = opt(interceptorInstance); err != nil {
return nil, err
}
}

if f.addPeerConnection != nil {
f.addPeerConnection(id, interceptorInstance.estimator)
}
fbi, err := f.rtpfbFactory.NewInterceptor(id)
if err != nil {
return nil, err
}

return interceptorInstance, nil
return interceptor.NewChain([]interceptor.Interceptor{fbi, interceptorInstance}), nil
}

// Interceptor implements Google Congestion Control.
//
// Deprecated: See package comment.
type Interceptor struct {
interceptor.NoOp
estimator BandwidthEstimator
Expand All @@ -98,6 +132,8 @@ type Interceptor struct {
// BindRTCPReader lets you modify any incoming RTCP packets. It is called once
// per sender/receiver, however this might change in the future. The returned
// method will be called once per packet batch.
//
// Deprecated: See package comment.
func (c *Interceptor) BindRTCPReader(reader interceptor.RTCPReader) interceptor.RTCPReader {
return interceptor.RTCPReaderFunc(func(b []byte, a interceptor.Attributes) (int, interceptor.Attributes, error) {
i, attr, err := reader.Read(b, a)
Expand Down Expand Up @@ -126,13 +162,17 @@ func (c *Interceptor) BindRTCPReader(reader interceptor.RTCPReader) interceptor.

// BindLocalStream lets you modify any outgoing RTP packets. It is called once
// for per LocalStream. The returned method will be called once per rtp packet.
//
// Deprecated: See package comment.
func (c *Interceptor) BindLocalStream(
info *interceptor.StreamInfo, writer interceptor.RTPWriter,
) interceptor.RTPWriter {
return c.estimator.AddStream(info, writer)
}

// Close closes the interceptor and the associated bandwidth estimator.
//
// Deprecated: See package comment.
func (c *Interceptor) Close() error {
return c.estimator.Close()
}
106 changes: 0 additions & 106 deletions pkg/gcc/adaptive_threshold.go

This file was deleted.

Loading
Loading