Close down track before closing subscriber peer connection (#981)
* Close down track before closing subscriber peer connection * plural
This commit is contained in:
+19
-1
@@ -662,7 +662,7 @@ func (p *ParticipantImpl) Close(sendLeave bool, reason types.ParticipantCloseRea
|
|||||||
}
|
}
|
||||||
|
|
||||||
// remove all down tracks
|
// remove all down tracks
|
||||||
var downTracksToClose []*sfu.DownTrack
|
downTracksToClose := make([]*sfu.DownTrack, 0, len(p.subscribedTracks))
|
||||||
for _, st := range p.subscribedTracks {
|
for _, st := range p.subscribedTracks {
|
||||||
downTracksToClose = append(downTracksToClose, st.DownTrack())
|
downTracksToClose = append(downTracksToClose, st.DownTrack())
|
||||||
}
|
}
|
||||||
@@ -740,6 +740,24 @@ func (p *ParticipantImpl) MaybeStartMigration(force bool, onStart func()) bool {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
p.params.Logger.Infow("closing subscriber peer connection to aid migration")
|
p.params.Logger.Infow("closing subscriber peer connection to aid migration")
|
||||||
|
|
||||||
|
//
|
||||||
|
// Close all down tracks before closing subscriber peer connection.
|
||||||
|
// Closing subscriber peer connection will call `Unbind` on all down tracks.
|
||||||
|
// DownTrack close has checks to handle the case of closing before bind.
|
||||||
|
// So, an `Unbind` before close would bypass that logic.
|
||||||
|
//
|
||||||
|
p.lock.Lock()
|
||||||
|
downTracksToClose := make([]*sfu.DownTrack, 0, len(p.subscribedTracks))
|
||||||
|
for _, st := range p.subscribedTracks {
|
||||||
|
downTracksToClose = append(downTracksToClose, st.DownTrack())
|
||||||
|
}
|
||||||
|
p.lock.Unlock()
|
||||||
|
|
||||||
|
for _, dt := range downTracksToClose {
|
||||||
|
dt.CloseWithFlush(false)
|
||||||
|
}
|
||||||
|
|
||||||
p.TransportManager.SubscriberClose()
|
p.TransportManager.SubscriberClose()
|
||||||
})
|
})
|
||||||
p.lock.Unlock()
|
p.lock.Unlock()
|
||||||
|
|||||||
Reference in New Issue
Block a user