diff --git a/pkg/sfu/forwarder.go b/pkg/sfu/forwarder.go index 26e980b11..771036631 100644 --- a/pkg/sfu/forwarder.go +++ b/pkg/sfu/forwarder.go @@ -582,11 +582,13 @@ func (f *Forwarder) AllocateOptimal(availableLayers []int32, brs Bitrates, allow } } alloc.targetLayers.Temporal = DefaultMaxLayerTemporal + + alloc.requestLayerSpatial = alloc.targetLayers.Spatial } else { // opportunistically latch on to anything opportunisticAlloc() + alloc.requestLayerSpatial = int32(math.Min(float64(f.maxLayers.Spatial), float64(f.maxPublishedLayer))) } - alloc.requestLayerSpatial = int32(math.Min(float64(f.maxLayers.Spatial), float64(f.maxPublishedLayer))) } if !alloc.targetLayers.IsValid() { diff --git a/pkg/sfu/forwarder_test.go b/pkg/sfu/forwarder_test.go index 78d82f263..31ee32bde 100644 --- a/pkg/sfu/forwarder_test.go +++ b/pkg/sfu/forwarder_test.go @@ -370,7 +370,7 @@ func TestForwarderAllocateOptimal(t *testing.T) { bandwidthDelta: 0, bitrates: emptyBitrates, targetLayers: expectedTargetLayers, - requestLayerSpatial: 0, + requestLayerSpatial: 1, maxLayers: expectedMaxLayers, distanceToDesired: 0, }