mirror of
https://github.com/livekit/livekit.git
synced 2026-05-24 21:15:36 +00:00
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 t := minTemporal; t <= maxTemporal; 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
|
||||
}
|
||||
|
||||
|
||||
@@ -852,24 +852,19 @@ func (s *StreamAllocator) allocateTrack(track *Track) {
|
||||
//
|
||||
// For both cases, do
|
||||
// a. Find cooperative transition from track that needs allocation.
|
||||
// b. If track is currently streaming at minimum, do not do anything.
|
||||
// c. If track is giving back bits, apply the transition and use bits given
|
||||
// b. If track is giving back bits, apply the transition and use bits given
|
||||
// back to boost any deficient track(s).
|
||||
//
|
||||
// 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
|
||||
// possible fit for the available headroom.
|
||||
// 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()
|
||||
transition := track.ProvisionalAllocateGetCooperativeTransition(FlagAllowOvershootWhileDeficient)
|
||||
|
||||
// track is currently streaming at minimum
|
||||
if transition.BandwidthDelta == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
// downgrade, giving back bits
|
||||
if transition.From.GreaterThan(transition.To) {
|
||||
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
|
||||
}
|
||||
|
||||
// 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.
|
||||
bandwidthAcquired := int64(0)
|
||||
var contributingTracks []*Track
|
||||
|
||||
Reference in New Issue
Block a user