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:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user