Check for valid layers and also log unexpected target (#1438)
This commit is contained in:
+15
-5
@@ -554,7 +554,17 @@ func (f *Forwarder) BandwidthRequested(brs Bitrates) int64 {
|
|||||||
f.lock.RLock()
|
f.lock.RLock()
|
||||||
defer f.lock.RUnlock()
|
defer f.lock.RUnlock()
|
||||||
|
|
||||||
if f.targetLayers == InvalidLayers {
|
if !f.targetLayers.IsValid() {
|
||||||
|
if f.targetLayers != InvalidLayers {
|
||||||
|
f.logger.Warnw(
|
||||||
|
"unexpected target layers", nil,
|
||||||
|
"target", f.targetLayers,
|
||||||
|
"current", f.currentLayers,
|
||||||
|
"parked", f.parkedLayers,
|
||||||
|
"max", f.maxLayers,
|
||||||
|
"lastAllocation", f.lastAllocation,
|
||||||
|
)
|
||||||
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -762,7 +772,7 @@ func (f *Forwarder) ProvisionalAllocate(availableChannelCapacity int64, layers V
|
|||||||
// 2. a layer above maximum which may or may not fit.
|
// 2. a layer above maximum which may or may not fit.
|
||||||
// In any of those cases, take the lowest possible layer if pause is not allowed
|
// In any of those cases, take the lowest possible layer if pause is not allowed
|
||||||
//
|
//
|
||||||
if !allowPause && (f.provisional.allocatedLayers == InvalidLayers || !layers.GreaterThan(f.provisional.allocatedLayers)) {
|
if !allowPause && (!f.provisional.allocatedLayers.IsValid() || !layers.GreaterThan(f.provisional.allocatedLayers)) {
|
||||||
f.provisional.allocatedLayers = layers
|
f.provisional.allocatedLayers = layers
|
||||||
return requiredBitrate - alreadyAllocatedBitrate
|
return requiredBitrate - alreadyAllocatedBitrate
|
||||||
}
|
}
|
||||||
@@ -874,7 +884,7 @@ func (f *Forwarder) ProvisionalAllocateGetCooperativeTransition(allowOvershoot b
|
|||||||
|
|
||||||
targetLayers := f.targetLayers
|
targetLayers := f.targetLayers
|
||||||
bandwidthRequired := int64(0)
|
bandwidthRequired := int64(0)
|
||||||
if targetLayers == InvalidLayers {
|
if !targetLayers.IsValid() {
|
||||||
// currently not streaming, find minimal
|
// currently not streaming, find minimal
|
||||||
// NOTE: a layer in feed could have paused and there could be other options than going back to minimal,
|
// NOTE: a layer in feed could have paused and there could be other options than going back to minimal,
|
||||||
// but the cooperative scheme knocks things back to minimal
|
// but the cooperative scheme knocks things back to minimal
|
||||||
@@ -893,7 +903,7 @@ func (f *Forwarder) ProvisionalAllocateGetCooperativeTransition(allowOvershoot b
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if nothing available, just leave target at current to enable opportunistic forwarding in case current resumes
|
// if nothing available, just leave target at current to enable opportunistic forwarding in case current resumes
|
||||||
if targetLayers == InvalidLayers {
|
if !targetLayers.IsValid() {
|
||||||
if f.provisional.parkedLayers.IsValid() {
|
if f.provisional.parkedLayers.IsValid() {
|
||||||
targetLayers = f.provisional.parkedLayers
|
targetLayers = f.provisional.parkedLayers
|
||||||
} else {
|
} else {
|
||||||
@@ -1292,7 +1302,7 @@ func (f *Forwarder) updateAllocation(alloc VideoAllocation, reason string) Video
|
|||||||
f.lastAllocation = alloc
|
f.lastAllocation = alloc
|
||||||
|
|
||||||
f.setTargetLayers(f.lastAllocation.targetLayers)
|
f.setTargetLayers(f.lastAllocation.targetLayers)
|
||||||
if f.targetLayers == InvalidLayers {
|
if !f.targetLayers.IsValid() {
|
||||||
f.resyncLocked()
|
f.resyncLocked()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user