Check that max layers are valid before allowing overshoot. (#775)

This commit is contained in:
Raja Subramanian authored and GitHub committed 2022-06-21 23:14:06 +05:30
1 parent 45ed8ce85a
commit 87c8ec25b9
1 file changed
+3 -3
+3 -3
View File
@@ -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).