Fix a case of changing video quality not succeeding. (#1483)

In the following order, got the wrong layer
- Max layer is 0, max published is 0, request layer is 0
- Current locks to 0.
- Max changes to 1. Nothing changes as 1 is not published yet.
- Max published changes to 1.
- As curernt layer is valid, available and locked to request layer, it
  was kept. But, it should have checked if the request layer changed
  and updated accordingly.
This commit is contained in:
Raja Subramanian
2023-03-01 11:12:54 +05:30
committed by GitHub
parent ab098d951e
commit a35eecd03d
2 changed files with 27 additions and 7 deletions
+24 -1
View File
@@ -354,6 +354,7 @@ func TestForwarderAllocateOptimal(t *testing.T) {
require.Equal(t, expectedResult, f.lastAllocation)
// stays the same if feed is not dry and current is valid, available and locked
f.maxLayers = VideoLayers{Spatial: 0, Temporal: 1}
f.currentLayers = VideoLayers{Spatial: 0, Temporal: 1}
f.requestLayerSpatial = 0
expectedTargetLayers = VideoLayers{
@@ -367,7 +368,29 @@ func TestForwarderAllocateOptimal(t *testing.T) {
bitrates: emptyBitrates,
targetLayers: expectedTargetLayers,
requestLayerSpatial: 0,
maxLayers: DefaultMaxLayers,
maxLayers: f.maxLayers,
distanceToDesired: 0,
}
result = f.AllocateOptimal([]int32{0, 1}, emptyBitrates, true)
require.Equal(t, expectedResult, result)
require.Equal(t, expectedResult, f.lastAllocation)
// opportunistic if feed is not dry and current is valid, but request layer has changed
f.maxLayers = VideoLayers{Spatial: 2, Temporal: 1}
f.currentLayers = VideoLayers{Spatial: 0, Temporal: 1}
f.requestLayerSpatial = 0
expectedTargetLayers = VideoLayers{
Spatial: 2,
Temporal: 3,
}
expectedResult = VideoAllocation{
pauseReason: VideoPauseReasonFeedDry,
bandwidthRequested: 0,
bandwidthDelta: 0,
bitrates: emptyBitrates,
targetLayers: expectedTargetLayers,
requestLayerSpatial: 2,
maxLayers: f.maxLayers,
distanceToDesired: 0,
}
result = f.AllocateOptimal([]int32{0, 1}, emptyBitrates, true)