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
+41
View File
@@ -180,6 +180,8 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) {
p.subscriber.OnOffer(p.onOffer)
p.subscriber.OnStreamedTracksChange(p.onStreamedTracksChange)
return p, nil
}
@@ -804,6 +806,8 @@ func (p *ParticipantImpl) AddSubscribedTrack(subTrack types.SubscribedTrack) {
p.lock.Lock()
p.subscribedTracks[subTrack.ID()] = subTrack
p.lock.Unlock()
p.subscriber.AddTrack(subTrack)
p.subscribedTo.Store(subTrack.PublisherIdentity(), struct{}{})
}
@@ -811,6 +815,9 @@ func (p *ParticipantImpl) AddSubscribedTrack(subTrack types.SubscribedTrack) {
func (p *ParticipantImpl) RemoveSubscribedTrack(subTrack types.SubscribedTrack) {
p.params.Logger.Debugw("removed subscribedTrack", "publisher", subTrack.PublisherIdentity(),
"participant", p.Identity(), "track", subTrack.ID(), "kind", subTrack.DownTrack().Kind())
p.subscriber.RemoveTrack(subTrack)
p.lock.Lock()
delete(p.subscribedTracks, subTrack.ID())
// remove from subscribed map
@@ -1307,6 +1314,40 @@ func (p *ParticipantImpl) configureReceiverDTX() {
}
}
func (p *ParticipantImpl) onStreamedTracksChange(paused map[string][]string, resumed map[string][]string) error {
if len(paused) == 0 && len(resumed) == 0 {
return nil
}
streamedTracksUpdate := &livekit.StreamedTracksUpdate{}
if len(paused) != 0 {
for participantId, trackIds := range paused {
for _, trackId := range trackIds {
streamedTracksUpdate.Paused = append(streamedTracksUpdate.Paused, &livekit.StreamedTrack{
ParticipantSid: participantId,
TrackSid: trackId,
})
}
}
}
if len(resumed) != 0 {
for participantId, trackIds := range paused {
for _, trackId := range trackIds {
streamedTracksUpdate.Resumed = append(streamedTracksUpdate.Resumed, &livekit.StreamedTrack{
ParticipantSid: participantId,
TrackSid: trackId,
})
}
}
}
return p.writeMessage(&livekit.SignalResponse{
Message: &livekit.SignalResponse_StreamedTracksUpdate{
StreamedTracksUpdate: streamedTracksUpdate,
},
})
}
func (p *ParticipantImpl) DebugInfo() map[string]interface{} {
info := map[string]interface{}{
"ID": p.id,