Prevent track subscriptions/adding receivers after close (#924)

* Prevent track subscriptions/adding receivers after close

With subscribe/unsubscribe queuing, a subscribe may be
attempted after a call to `RemoveAllSubscribers`.
So, renaming `RemoveAllSubscribers` to `InitiateClose`
and maintaining state that track is in the process of closing.

* Mime specific remove

* Remove unused error

* do not add receiver when closing
This commit is contained in:
Raja Subramanian
2022-08-17 13:07:59 +05:30
committed by GitHub
parent d9059f4f3b
commit f5627c3859
7 changed files with 156 additions and 86 deletions
+2 -2
View File
@@ -68,7 +68,7 @@ func (u *UpTrackManager) Close(willBeResumed bool) {
// remove all subscribers
for _, t := range u.GetPublishedTracks() {
t.RemoveAllSubscribers(willBeResumed)
t.InitiateClose(willBeResumed)
}
if notify && u.onClose != nil {
@@ -317,7 +317,7 @@ func (u *UpTrackManager) AddPublishedTrack(track types.MediaTrack) {
}
func (u *UpTrackManager) RemovePublishedTrack(track types.MediaTrack, willBeResumed bool) {
track.RemoveAllSubscribers(willBeResumed)
track.InitiateClose(willBeResumed)
u.lock.Lock()
delete(u.publishedTracks, track.ID())
u.lock.Unlock()