Compile in send-side bandwidth estimation. (#351)
Still not using it. But, now that Pion has merged the initial version of GCC (Google Congestion Control) for send side bandwidth estimation, we can integrate it. We will enable once we have tested and feel comfortable.
This commit is contained in:
@@ -20,7 +20,7 @@ require (
|
|||||||
github.com/mitchellh/go-homedir v1.1.0
|
github.com/mitchellh/go-homedir v1.1.0
|
||||||
github.com/olekukonko/tablewriter v0.0.5
|
github.com/olekukonko/tablewriter v0.0.5
|
||||||
github.com/pion/ice/v2 v2.1.18
|
github.com/pion/ice/v2 v2.1.18
|
||||||
github.com/pion/interceptor v0.1.4
|
github.com/pion/interceptor v0.1.6
|
||||||
github.com/pion/logging v0.2.2
|
github.com/pion/logging v0.2.2
|
||||||
github.com/pion/rtcp v1.2.9
|
github.com/pion/rtcp v1.2.9
|
||||||
github.com/pion/rtp v1.7.4
|
github.com/pion/rtp v1.7.4
|
||||||
|
|||||||
@@ -175,8 +175,9 @@ github.com/pion/dtls/v2 v2.1.0 h1:g6gtKVNLp6URDkv9OijFJl16kqGHzVzZG+Fa4A38GTY=
|
|||||||
github.com/pion/dtls/v2 v2.1.0/go.mod h1:qG3gA7ZPZemBqpEFqRKyURYdKEwFZQCGb7gv9T3ON3Y=
|
github.com/pion/dtls/v2 v2.1.0/go.mod h1:qG3gA7ZPZemBqpEFqRKyURYdKEwFZQCGb7gv9T3ON3Y=
|
||||||
github.com/pion/ice/v2 v2.1.18 h1:mDzd+iPKJmU30p4Kb+RPjK9olORLqJmQdiTUnVba50g=
|
github.com/pion/ice/v2 v2.1.18 h1:mDzd+iPKJmU30p4Kb+RPjK9olORLqJmQdiTUnVba50g=
|
||||||
github.com/pion/ice/v2 v2.1.18/go.mod h1:9jDr0iIUg8P6+0Jq8QJ/eFSkX3JnsPd293TjCdkfpTs=
|
github.com/pion/ice/v2 v2.1.18/go.mod h1:9jDr0iIUg8P6+0Jq8QJ/eFSkX3JnsPd293TjCdkfpTs=
|
||||||
github.com/pion/interceptor v0.1.4 h1:qL2xrdR6taLkVxEQj39btwEPRO3i9yd/olEw6+20dag=
|
|
||||||
github.com/pion/interceptor v0.1.4/go.mod h1:Lh3JSl/cbJ2wP8I3ccrjh1K/deRGRn3UlSPuOTiHb6U=
|
github.com/pion/interceptor v0.1.4/go.mod h1:Lh3JSl/cbJ2wP8I3ccrjh1K/deRGRn3UlSPuOTiHb6U=
|
||||||
|
github.com/pion/interceptor v0.1.6 h1:ZTXN9fApUDmFqifG64g+ar57XY7vlnXUs7/0DjHVtLo=
|
||||||
|
github.com/pion/interceptor v0.1.6/go.mod h1:Lh3JSl/cbJ2wP8I3ccrjh1K/deRGRn3UlSPuOTiHb6U=
|
||||||
github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY=
|
github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY=
|
||||||
github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms=
|
github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms=
|
||||||
github.com/pion/mdns v0.0.5 h1:Q2oj/JB3NqfzY9xGZ1fPzZzK7sDSD8rZPOvcIQ10BCw=
|
github.com/pion/mdns v0.0.5 h1:Q2oj/JB3NqfzY9xGZ1fPzZzK7sDSD8rZPOvcIQ10BCw=
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ import (
|
|||||||
"github.com/livekit/protocol/livekit"
|
"github.com/livekit/protocol/livekit"
|
||||||
"github.com/livekit/protocol/logger"
|
"github.com/livekit/protocol/logger"
|
||||||
"github.com/pion/interceptor"
|
"github.com/pion/interceptor"
|
||||||
|
"github.com/pion/interceptor/pkg/cc"
|
||||||
|
"github.com/pion/interceptor/pkg/gcc"
|
||||||
|
"github.com/pion/interceptor/pkg/twcc"
|
||||||
"github.com/pion/sdp/v3"
|
"github.com/pion/sdp/v3"
|
||||||
"github.com/pion/webrtc/v3"
|
"github.com/pion/webrtc/v3"
|
||||||
|
|
||||||
@@ -71,8 +74,7 @@ type TransportParams struct {
|
|||||||
SimTracks map[uint32]SimulcastTrackInfo
|
SimTracks map[uint32]SimulcastTrackInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// LK-TODO-SSBWE func newPeerConnection(params TransportParams, onBandwidthEstimator func(estimator cc.BandwidthEstimator)) (*webrtc.PeerConnection, *webrtc.MediaEngine, error) {
|
func newPeerConnection(params TransportParams, onBandwidthEstimator func(estimator cc.BandwidthEstimator)) (*webrtc.PeerConnection, *webrtc.MediaEngine, error) {
|
||||||
func newPeerConnection(params TransportParams) (*webrtc.PeerConnection, *webrtc.MediaEngine, error) {
|
|
||||||
var directionConfig DirectionConfig
|
var directionConfig DirectionConfig
|
||||||
if params.Target == livekit.SignalTarget_PUBLISHER {
|
if params.Target == livekit.SignalTarget_PUBLISHER {
|
||||||
directionConfig = params.Config.Publisher
|
directionConfig = params.Config.Publisher
|
||||||
@@ -108,7 +110,6 @@ func newPeerConnection(params TransportParams) (*webrtc.PeerConnection, *webrtc.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if isSendSideBWE {
|
if isSendSideBWE {
|
||||||
/* LK-TODO-SSBWE
|
|
||||||
gf, err := cc.NewInterceptor(func() (cc.BandwidthEstimator, error) {
|
gf, err := cc.NewInterceptor(func() (cc.BandwidthEstimator, error) {
|
||||||
return gcc.NewSendSideBWE(
|
return gcc.NewSendSideBWE(
|
||||||
gcc.SendSideBWEInitialBitrate(1*1000*1000),
|
gcc.SendSideBWEInitialBitrate(1*1000*1000),
|
||||||
@@ -128,7 +129,6 @@ func newPeerConnection(params TransportParams) (*webrtc.PeerConnection, *webrtc.
|
|||||||
ir.Add(tf)
|
ir.Add(tf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(params.SimTracks) > 0 {
|
if len(params.SimTracks) > 0 {
|
||||||
@@ -149,13 +149,10 @@ func newPeerConnection(params TransportParams) (*webrtc.PeerConnection, *webrtc.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewPCTransport(params TransportParams) (*PCTransport, error) {
|
func NewPCTransport(params TransportParams) (*PCTransport, error) {
|
||||||
/* LK-TODO-SSBWE
|
|
||||||
var bwe cc.BandwidthEstimator
|
var bwe cc.BandwidthEstimator
|
||||||
pc, me, err := newPeerConnection(params, func(estimator cc.BandwidthEstimator) {
|
pc, me, err := newPeerConnection(params, func(estimator cc.BandwidthEstimator) {
|
||||||
bwe = estimator
|
bwe = estimator
|
||||||
})
|
})
|
||||||
*/
|
|
||||||
pc, me, err := newPeerConnection(params)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -173,11 +170,9 @@ func NewPCTransport(params TransportParams) (*PCTransport, error) {
|
|||||||
Logger: params.Logger,
|
Logger: params.Logger,
|
||||||
})
|
})
|
||||||
t.streamAllocator.Start()
|
t.streamAllocator.Start()
|
||||||
/* LK-TODO-SSBWE
|
|
||||||
if bwe != nil {
|
if bwe != nil {
|
||||||
t.streamAllocator.SetBandwidthEstimator(bwe)
|
t.streamAllocator.SetBandwidthEstimator(bwe)
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
t.pc.OnICEGatheringStateChange(func(state webrtc.ICEGathererState) {
|
t.pc.OnICEGatheringStateChange(func(state webrtc.ICEGathererState) {
|
||||||
if state == webrtc.ICEGathererStateComplete {
|
if state == webrtc.ICEGathererStateComplete {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/livekit/protocol/livekit"
|
"github.com/livekit/protocol/livekit"
|
||||||
"github.com/livekit/protocol/logger"
|
"github.com/livekit/protocol/logger"
|
||||||
|
"github.com/pion/interceptor/pkg/cc"
|
||||||
"github.com/pion/rtcp"
|
"github.com/pion/rtcp"
|
||||||
"github.com/pion/webrtc/v3"
|
"github.com/pion/webrtc/v3"
|
||||||
|
|
||||||
@@ -121,7 +122,7 @@ type StreamAllocator struct {
|
|||||||
|
|
||||||
rembTrackingSSRC uint32
|
rembTrackingSSRC uint32
|
||||||
|
|
||||||
// LK-TODO-SSBWE bwe cc.BandwidthEstimator
|
bwe cc.BandwidthEstimator
|
||||||
|
|
||||||
committedChannelCapacity int64
|
committedChannelCapacity int64
|
||||||
lastCommitTime time.Time
|
lastCommitTime time.Time
|
||||||
@@ -183,14 +184,12 @@ func (s *StreamAllocator) OnStreamStateChange(f func(update *StreamStateUpdate)
|
|||||||
s.onStreamStateChange = f
|
s.onStreamStateChange = f
|
||||||
}
|
}
|
||||||
|
|
||||||
/* LK-TODO-SSBWE
|
|
||||||
func (s *StreamAllocator) SetBandwidthEstimator(bwe cc.BandwidthEstimator) {
|
func (s *StreamAllocator) SetBandwidthEstimator(bwe cc.BandwidthEstimator) {
|
||||||
if bwe != nil {
|
if bwe != nil {
|
||||||
bwe.OnTargetBitrateChange(s.onTargetBitrateChange)
|
bwe.OnTargetBitrateChange(s.onTargetBitrateChange)
|
||||||
}
|
}
|
||||||
s.bwe = bwe
|
s.bwe = bwe
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
type AddTrackParams struct {
|
type AddTrackParams struct {
|
||||||
Source livekit.TrackSource
|
Source livekit.TrackSource
|
||||||
@@ -242,11 +241,9 @@ func (s *StreamAllocator) onREMB(downTrack *DownTrack, remb *rtcp.ReceiverEstima
|
|||||||
|
|
||||||
// called when a new transport-cc feedback is received
|
// called when a new transport-cc feedback is received
|
||||||
func (s *StreamAllocator) onTransportCCFeedback(downTrack *DownTrack, fb *rtcp.TransportLayerCC) {
|
func (s *StreamAllocator) onTransportCCFeedback(downTrack *DownTrack, fb *rtcp.TransportLayerCC) {
|
||||||
/* LK-TODO-SSBWE
|
|
||||||
if s.bwe != nil {
|
if s.bwe != nil {
|
||||||
s.bwe.WriteRTCP([]rtcp.Packet{fb}, nil)
|
s.bwe.WriteRTCP([]rtcp.Packet{fb}, nil)
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// called when target bitrate changes
|
// called when target bitrate changes
|
||||||
|
|||||||
Reference in New Issue
Block a user