diff --git a/pkg/sfu/forwarder.go b/pkg/sfu/forwarder.go index 487a5d04..219c9b2e 100644 --- a/pkg/sfu/forwarder.go +++ b/pkg/sfu/forwarder.go @@ -1274,17 +1274,12 @@ func (f *Forwarder) AllocateNextHigher(availableChannelCapacity int64, available return f.lastAllocation, false } - // if targets are still pending, don't increase - targetLayer := f.vls.GetTarget() - if targetLayer.IsValid() && targetLayer != f.vls.GetCurrent() { - return f.lastAllocation, false - } - maxLayer := f.vls.GetMax() maxSeenLayer := f.vls.GetMaxSeen() optimalBandwidthNeeded := getOptimalBandwidthNeeded(f.muted, f.pubMuted, maxSeenLayer.Spatial, brs, maxLayer) alreadyAllocated := int64(0) + targetLayer := f.vls.GetTarget() if targetLayer.IsValid() { alreadyAllocated = brs[targetLayer.Spatial][targetLayer.Temporal] } diff --git a/pkg/sfu/streamallocator/streamallocator.go b/pkg/sfu/streamallocator/streamallocator.go index 01bd53c3..ba9a7a5c 100644 --- a/pkg/sfu/streamallocator/streamallocator.go +++ b/pkg/sfu/streamallocator/streamallocator.go @@ -726,6 +726,17 @@ func (s *StreamAllocator) handleSignalPeriodicPing(Event) { } } + // try up allocations in case there is available headroom, + // it is possible that a previous up allocation is waiting to settle, + // so even if there was headroom available while doing previous up allocation + // it may not have used up all available headroom, + // check before probing again as this could use available headroom and + // up allocate all tracks to their desired layers, that would avoid + // an unnecessary probe cluster + if s.state == streamAllocatorStateDeficient { + s.maybeBoostDeficientTracks() + } + // probe if necessary and timing is right if s.state == streamAllocatorStateDeficient { s.maybeProbe()