Allow cooperative allocation (#309)
This commit is contained in:
+15
-21
@@ -715,13 +715,8 @@ func (s *StreamAllocator) allocateTrack(track *Track) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// downgrade, giving back bits
|
||||||
// One of
|
if transition.from.GreaterThan(transition.to) {
|
||||||
// - downgrade, giving back bits, commit the allocation.
|
|
||||||
// - if not a downgrade, the stream was paused and trying to restart.
|
|
||||||
// If pause is disallowed, commit the allocation to get stream started again.
|
|
||||||
//
|
|
||||||
if !s.params.Config.AllowPause || transition.from.GreaterThan(transition.to) {
|
|
||||||
allocation := track.ProvisionalAllocateCommit()
|
allocation := track.ProvisionalAllocateCommit()
|
||||||
|
|
||||||
update := NewStreamStateUpdate()
|
update := NewStreamStateUpdate()
|
||||||
@@ -768,23 +763,22 @@ func (s *StreamAllocator) allocateTrack(track *Track) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if bandwidthAcquired < transition.bandwidthDelta {
|
|
||||||
// could not get enough from other tracks, let probing deal with starting the track
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// commit the tracks that contributed
|
|
||||||
update := NewStreamStateUpdate()
|
update := NewStreamStateUpdate()
|
||||||
for _, t := range contributingTracks {
|
if bandwidthAcquired >= transition.bandwidthDelta {
|
||||||
allocation := t.ProvisionalAllocateCommit()
|
// commit the tracks that contributed
|
||||||
update.HandleStreamingChange(allocation.change, t)
|
for _, t := range contributingTracks {
|
||||||
|
allocation := t.ProvisionalAllocateCommit()
|
||||||
|
update.HandleStreamingChange(allocation.change, t)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LK-TODO if got too much extra, can potentially give it to some deficient track
|
||||||
}
|
}
|
||||||
|
|
||||||
// commit the track that needs change
|
// commit the track that needs change if enough could be acquired or pause not allowed
|
||||||
allocation := track.ProvisionalAllocateCommit()
|
if !s.params.Config.AllowPause || bandwidthAcquired >= transition.bandwidthDelta {
|
||||||
update.HandleStreamingChange(allocation.change, track)
|
allocation := track.ProvisionalAllocateCommit()
|
||||||
|
update.HandleStreamingChange(allocation.change, track)
|
||||||
// LK-TODO if got too much extra, can potentially give it to some deficient track
|
}
|
||||||
|
|
||||||
s.maybeSendUpdate(update)
|
s.maybeSendUpdate(update)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user