From 87c8ec25b9e8b19ab955022521ebf6be851390dd Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Tue, 21 Jun 2022 23:14:06 +0530 Subject: [PATCH] Check that max layers are valid before allowing overshoot. (#775) --- pkg/sfu/forwarder.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/sfu/forwarder.go b/pkg/sfu/forwarder.go index e0e53ea50..e270ffa4a 100644 --- a/pkg/sfu/forwarder.go +++ b/pkg/sfu/forwarder.go @@ -350,7 +350,7 @@ func (f *Forwarder) getOptimalBandwidthNeeded(brs Bitrates) int64 { return 0 } -func (f *Forwarder) bitrateAvailable(brs Bitrates, availableLayers []int32) bool { +func (f *Forwarder) bitrateAvailable(brs Bitrates) bool { neededLayers := 0 var bitrateAvailableLayers []int32 for _, layer := range f.availableLayers { @@ -442,7 +442,7 @@ func (f *Forwarder) AllocateOptimal(brs Bitrates) VideoAllocation { case len(f.availableLayers) == 0: // feed is dry state = VideoAllocationStateFeedDry - case !f.bitrateAvailable(brs, f.availableLayers): + case !f.bitrateAvailable(brs): // feed bitrate not yet calculated for all available layers state = VideoAllocationStateAwaitingMeasurement @@ -483,7 +483,7 @@ func (f *Forwarder) AllocateOptimal(brs Bitrates) VideoAllocation { } } - if bandwidthRequested == 0 { + if bandwidthRequested == 0 && f.maxLayers.IsValid() { // if we cannot allocate anything below max layer, // look for a layer above. It is okay to overshoot // in optimal allocation (i. e. no bandwidth restricstions).