Issue #1 only: Fix spatial layer initialization in Forwarder (#4003)

When SetMaxSpatialLayer() is called with target/current layers in
InvalidLayerSpatial state, opportunistically initialize the target
layer to avoid dropped packets during async stream allocator
initialization.

Guards:
- Only sets target if not congestion-throttled (isDeficientLocked)
- Does not set current layer (deferred to keyframe-based forwarder start)
- Logs at Debug level to avoid log noise

This prevents undefined layer state during manual subscription
with immediate quality upgrades (WithAutoSubscribe(false) +
SetVideoQuality(HIGH)).
This commit is contained in:
Alexey Sokolov
2025-10-21 12:54:05 +05:30
committed by GitHub
parent 2afbf0e8ca
commit c039769607
2 changed files with 15 additions and 1 deletions
+6 -1
View File
@@ -556,7 +556,12 @@ func (f *Forwarder) SetMaxSpatialLayer(spatialLayer int32) (bool, buffer.VideoLa
f.logger.Debugw("setting max spatial layer", "layer", spatialLayer)
f.vls.SetMaxSpatial(spatialLayer)
return true, f.vls.GetMax()
newMax := f.vls.GetMax()
if f.vls.GetTarget().Spatial == buffer.InvalidLayerSpatial && !f.isDeficientLocked() {
f.logger.Debugw("opportunistically setting target spatial layer", "layer", newMax.Spatial)
f.vls.SetTarget(newMax)
}
return true, newMax
}
func (f *Forwarder) SetMaxTemporalLayer(temporalLayer int32) (bool, buffer.VideoLayer) {