Get next higher using bit rate. (#1960)
This commit is contained in:
@@ -1220,7 +1220,10 @@ func (f *Forwarder) GetNextHigherTransition(brs Bitrates, allowOvershoot bool) (
|
|||||||
for s := minSpatial; s <= maxSpatial; s++ {
|
for s := minSpatial; s <= maxSpatial; s++ {
|
||||||
for t := minTemporal; t <= maxTemporal; t++ {
|
for t := minTemporal; t <= maxTemporal; t++ {
|
||||||
bandwidthRequested := brs[s][t]
|
bandwidthRequested := brs[s][t]
|
||||||
if bandwidthRequested == 0 {
|
// traverse till finding a layer requiring more bits.
|
||||||
|
// NOTE: it possible that higher temporal layer of lower spatial layer
|
||||||
|
// could use more bits than lower temporal layer of higher spatial layer.
|
||||||
|
if bandwidthRequested == 0 || bandwidthRequested < alreadyAllocated {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -852,24 +852,19 @@ func (s *StreamAllocator) allocateTrack(track *Track) {
|
|||||||
//
|
//
|
||||||
// For both cases, do
|
// For both cases, do
|
||||||
// a. Find cooperative transition from track that needs allocation.
|
// a. Find cooperative transition from track that needs allocation.
|
||||||
// b. If track is currently streaming at minimum, do not do anything.
|
// b. If track is giving back bits, apply the transition and use bits given
|
||||||
// c. If track is giving back bits, apply the transition and use bits given
|
|
||||||
// back to boost any deficient track(s).
|
// back to boost any deficient track(s).
|
||||||
//
|
//
|
||||||
// If track needs more bits, i.e. upward transition (may need resume or higher layer subscription),
|
// If track needs more bits, i.e. upward transition (may need resume or higher layer subscription),
|
||||||
// a. Try to allocate using existing headroom. This can be tried to get the best
|
// a. Try to allocate using existing headroom. This can be tried to get the best
|
||||||
// possible fit for the available headroom.
|
// possible fit for the available headroom.
|
||||||
// b. If there is not enough headroom to allocate anything, ask for best offer from
|
// b. If there is not enough headroom to allocate anything, ask for best offer from
|
||||||
// other tracks that are currently streaming and try to use it.
|
// other tracks that are currently streaming and try to use it. This is done only if the
|
||||||
|
// track needing change is not currently streaming, i. e. it has to be resumed.
|
||||||
//
|
//
|
||||||
track.ProvisionalAllocatePrepare()
|
track.ProvisionalAllocatePrepare()
|
||||||
transition := track.ProvisionalAllocateGetCooperativeTransition(FlagAllowOvershootWhileDeficient)
|
transition := track.ProvisionalAllocateGetCooperativeTransition(FlagAllowOvershootWhileDeficient)
|
||||||
|
|
||||||
// track is currently streaming at minimum
|
|
||||||
if transition.BandwidthDelta == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// downgrade, giving back bits
|
// downgrade, giving back bits
|
||||||
if transition.From.GreaterThan(transition.To) {
|
if transition.From.GreaterThan(transition.To) {
|
||||||
allocation := track.ProvisionalAllocateCommit()
|
allocation := track.ProvisionalAllocateCommit()
|
||||||
@@ -928,6 +923,11 @@ func (s *StreamAllocator) allocateTrack(track *Track) {
|
|||||||
transition = track.ProvisionalAllocateGetCooperativeTransition(FlagAllowOvershootWhileDeficient) // get transition again to reset above allocation attempt using available headroom
|
transition = track.ProvisionalAllocateGetCooperativeTransition(FlagAllowOvershootWhileDeficient) // get transition again to reset above allocation attempt using available headroom
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// track is currently streaming at minimum
|
||||||
|
if transition.BandwidthDelta == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// if there is not enough headroom, try to redistribute starting with tracks that are closest to their desired.
|
// if there is not enough headroom, try to redistribute starting with tracks that are closest to their desired.
|
||||||
bandwidthAcquired := int64(0)
|
bandwidthAcquired := int64(0)
|
||||||
var contributingTracks []*Track
|
var contributingTracks []*Track
|
||||||
|
|||||||
Reference in New Issue
Block a user