Prevent subscribing to track that's closing (#1454)

Due to the order of events in MediaTrackReceiver and friends, SubscribedTrack
will be closed before the track is removed from RoomTrackManager.

Because of this, when a track is unpublished, it's possible to be subscribed
to the track as it's closing.

By introducing a closing state, we'd prevent accidental subscription to
closing tracks.
This commit is contained in:
David Zhao
2023-02-22 01:14:49 -08:00
committed by GitHub
parent 1b3d6fad54
commit e855620379
6 changed files with 159 additions and 1 deletions
+2
View File
@@ -242,6 +242,7 @@ func (t *MediaTrack) AddReceiver(receiver *webrtc.RTPReceiver, track *webrtc.Tra
)
newWR.SetRTCPCh(t.params.RTCPChan)
newWR.OnCloseHandler(func() {
t.MediaTrackReceiver.SetClosing()
t.MediaTrackReceiver.ClearReceiver(mime, false)
if t.MediaTrackReceiver.TryClose() {
if t.dynacastManager != nil {
@@ -349,6 +350,7 @@ func (t *MediaTrack) Restart() {
}
func (t *MediaTrack) Close(willBeResumed bool) {
t.MediaTrackReceiver.SetClosing()
if t.dynacastManager != nil {
t.dynacastManager.Close()
}