cleaner resync

This commit is contained in:
David Zhao
2021-02-07 22:44:25 -08:00
parent d13a962afd
commit e30c9f706c
3 changed files with 39 additions and 20 deletions
+15 -9
View File
@@ -581,15 +581,7 @@ func (p *ParticipantImpl) onMediaTrack(track *webrtc.TrackRemote, rtpReceiver *w
p.handleTrackPublished(mt)
}
// TODO: video tracks the current participant is subscribed to tends to freeze when the participant adds tracks
// to get around this, we'll trigger a resync on all tracks it's subscribed to
p.lock.RLock()
defer p.lock.RUnlock()
for _, tracks := range p.subscribedTracks {
for _, subTrack := range tracks {
subTrack.Resync()
}
}
p.resyncSubscriptions()
}
func (p *ParticipantImpl) onDataChannel(dc *webrtc.DataChannel) {
@@ -653,6 +645,8 @@ func (p *ParticipantImpl) handleTrackPublished(track types.PublishedTrack) {
if p.IsReady() && p.onTrackUpdated != nil {
p.onTrackUpdated(p, track)
}
track.OnClose(nil)
go p.resyncSubscriptions()
})
if p.onTrackPublished != nil {
@@ -660,6 +654,18 @@ func (p *ParticipantImpl) handleTrackPublished(track types.PublishedTrack) {
}
}
func (p *ParticipantImpl) resyncSubscriptions() {
// TODO: video tracks the current participant is subscribed to tends to freeze when the participant adds/removes tracks
// to get around this, we'll trigger a resync on all tracks it's subscribed to
p.lock.RLock()
defer p.lock.RUnlock()
for _, tracks := range p.subscribedTracks {
for _, subTrack := range tracks {
subTrack.Resync()
}
}
}
// downTracksRTCPWorker sends SenderReports periodically when the participant is subscribed to
// other publishedTracks in the room.
func (p *ParticipantImpl) downTracksRTCPWorker() {