Re-use transceiver (via ReplaceTrack) if a down track is going to be resumed. (#785)

* WIP commit

* Clean up

* spelling mistake

* Run subscribed track onBind in a go routine

* Address comments and more safety net
This commit is contained in:
Raja Subramanian
2022-06-24 15:07:48 +05:30
committed by GitHub
parent 0b630e15b6
commit adf2d191b0
9 changed files with 428 additions and 71 deletions
+3 -1
View File
@@ -240,7 +240,9 @@ func (s *StreamAllocator) AddTrack(downTrack *DownTrack, params AddTrackParams)
func (s *StreamAllocator) RemoveTrack(downTrack *DownTrack) {
s.videoTracksMu.Lock()
delete(s.videoTracks, livekit.TrackID(downTrack.ID()))
if existing := s.videoTracks[livekit.TrackID(downTrack.ID())]; existing != nil && existing.DownTrack() == downTrack {
delete(s.videoTracks, livekit.TrackID(downTrack.ID()))
}
s.videoTracksMu.Unlock()
// LK-TODO: use any saved bandwidth to re-distribute