downstream allocator (#155)

* WIP branch to hash out down stream allocator.

* Plug more bits of stream allocator

* update protocol

* remove SignalRequest_Simulcast (#154)

* Plug more bits of stream allocator

* Handle simulcast track available layers change

* WIP branch to hash out down stream allocator.

* Plug more bits of stream allocator

* Handle simulcast track available layers change

* Adopt signature of call to AdjustAllocation

* Move StreamAllocator to PCTransport and allocate only for subscriber.

* Move streamallocator to ion-sfu

* Start/Stop of streamallocator

* Use StreamAllocator for subscriber bandwidth management.

* Do not allocate in ADD_TRACK

* Set payload in constructor

* - Add some logging
- Protocol message to notify clients of paused/resumed streams

* named return

* oops correct sense of isPausing

* Update pkg/sfu/streamallocator.go

Committing David's suggestion.

Co-authored-by: David Zhao <david@davidzhao.com>

* - Log estimate changes/commits.
- Catch more than epsilon change oscillating for long time.

Co-authored-by: David Colburn <xero73@gmail.com>
Co-authored-by: David Zhao <david@davidzhao.com>
This commit is contained in:
Raja Subramanian
2021-11-26 09:11:04 +05:30
committed by GitHub
co-authored by David Colburn David Zhao
parent 9aff9af690
commit 98695cdd22
11 changed files with 470 additions and 318 deletions
+4 -16
View File
@@ -293,7 +293,7 @@ func (t *MediaTrack) AddSubscriber(sub types.Participant) error {
t.subscribedTracks[sub.ID()] = subTrack
subTrack.SetPublisherMuted(t.IsMuted())
t.receiver.AddDownTrack(downTrack, t.shouldStartWithBestQuality())
t.receiver.AddDownTrack(downTrack)
// since sub will lock, run it in a goroutine to avoid deadlocks
go func() {
sub.AddSubscribedTrack(subTrack)
@@ -306,16 +306,10 @@ func (t *MediaTrack) AddSubscriber(sub types.Participant) error {
func (t *MediaTrack) NumUpTracks() (uint32, uint32) {
numRegistered := atomic.LoadUint32(&t.numUpTracks)
numPublishing := uint32(0)
var numPublishing uint32
if t.simulcasted.Get() {
t.lock.RLock()
if t.receiver != nil {
for i := int32(0); i < 3; i++ {
if t.receiver.HasSpatialLayer(i) {
numPublishing += 1
}
}
}
numPublishing = uint32(t.receiver.NumAvailableSpatialLayers())
t.lock.RUnlock()
} else {
numPublishing = 1
@@ -392,7 +386,7 @@ func (t *MediaTrack) AddReceiver(receiver *webrtc.RTPReceiver, track *webrtc.Tra
}
}
t.receiver.AddUpTrack(track, buff, t.shouldStartWithBestQuality())
t.receiver.AddUpTrack(track, buff)
t.params.Telemetry.AddUpTrack(t.params.ParticipantID, buff)
atomic.AddUint32(&t.numUpTracks, 1)
@@ -463,12 +457,6 @@ func (t *MediaTrack) GetQualityForDimension(width, height uint32) livekit.VideoQ
return quality
}
// LK-TODO: this should probably left up to auto size management and StreamAllocator
// this function assumes caller holds lock
func (t *MediaTrack) shouldStartWithBestQuality() bool {
return len(t.subscribedTracks) < 10
}
// TODO: send for all downtracks from the source participant
// https://tools.ietf.org/html/rfc7941
func (t *MediaTrack) sendDownTrackBindingReports(sub types.Participant) {