diff --git a/pkg/config/config.go b/pkg/config/config.go index 456a1ebef..17bbd0490 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -87,10 +87,11 @@ type PLIThrottleConfig struct { } type CongestionControlConfig struct { - Enabled bool `yaml:"enabled"` - AllowPause bool `yaml:"allow_pause"` - UseSendSideBWE bool `yaml:"send_side_bandwidth_estimation,omitempty"` - ProbeMode CongestionControlProbeMode `yaml:"padding_mode,omitempty"` + Enabled bool `yaml:"enabled"` + AllowPause bool `yaml:"allow_pause"` + UseSendSideBWE bool `yaml:"send_side_bandwidth_estimation,omitempty"` + ProbeMode CongestionControlProbeMode `yaml:"padding_mode,omitempty"` + MinChannelCapacity int64 `yaml:"min_channel_capacity,omitempty"` } type InterfacesConfig struct { diff --git a/pkg/sfu/streamallocator.go b/pkg/sfu/streamallocator.go index 90486d743..c495a29d1 100644 --- a/pkg/sfu/streamallocator.go +++ b/pkg/sfu/streamallocator.go @@ -850,7 +850,16 @@ func (s *StreamAllocator) finalizeProbe() { } func (s *StreamAllocator) maybeBoostDeficientTracks() { - availableChannelCapacity := s.committedChannelCapacity - s.getExpectedBandwidthUsage() + committedChannelCapacity := s.committedChannelCapacity + if s.params.Config.MinChannelCapacity > committedChannelCapacity { + committedChannelCapacity = s.params.Config.MinChannelCapacity + s.params.Logger.Debugw( + "overriding channel capacity", + "actual", s.committedChannelCapacity, + "override", committedChannelCapacity, + ) + } + availableChannelCapacity := committedChannelCapacity - s.getExpectedBandwidthUsage() if availableChannelCapacity <= 0 { return } @@ -897,6 +906,14 @@ func (s *StreamAllocator) allocateAllTracks() { update := NewStreamStateUpdate() availableChannelCapacity := s.committedChannelCapacity + if s.params.Config.MinChannelCapacity > availableChannelCapacity { + availableChannelCapacity = s.params.Config.MinChannelCapacity + s.params.Logger.Debugw( + "overriding channel capacity", + "actual", s.committedChannelCapacity, + "override", availableChannelCapacity, + ) + } // // This pass is find out if there is any leftover channel capacity after allocating exempt tracks. @@ -1011,8 +1028,9 @@ func (s *StreamAllocator) initProbe(probeRateBps int64) { s.probeChannelObserver = NewChannelObserver("probe", s.params.Logger, NumRequiredEstimatesProbe, NackRatioThresholdProbe) s.probeChannelObserver.SeedEstimate(s.lastReceivedEstimate) + desiredRateBps := int(probeRateBps) + int(math.Max(float64(s.committedChannelCapacity), float64(expectedBandwidthUsage))) s.probeClusterId = s.prober.AddCluster( - int(s.committedChannelCapacity+probeRateBps), + desiredRateBps, int(expectedBandwidthUsage), ProbeMinDuration, ProbeMaxDuration,