mirror of
https://github.com/livekit/livekit.git
synced 2026-05-25 01:35:39 +00:00
Include pending migrate tracks in ParticipantInfo. (#2493)
It is possible that participant state and migration state updates are racing. And a participant update could end up with no tracks when migration is being processed.
This commit is contained in:
@@ -514,8 +514,37 @@ func (p *ParticipantImpl) ToProtoWithVersion() (*livekit.ParticipantInfo, utils.
|
||||
IsPublisher: p.IsPublisher(),
|
||||
}
|
||||
p.lock.RUnlock()
|
||||
|
||||
p.pendingTracksLock.RLock()
|
||||
pi.Tracks = p.UpTrackManager.ToProto()
|
||||
|
||||
// add any pending migrating tracks, else an update could delete/unsubscribe from yet to be published, migrating tracks
|
||||
maybeAdd := func(pti *pendingTrackInfo) {
|
||||
if !pti.migrated {
|
||||
return
|
||||
}
|
||||
|
||||
found := false
|
||||
for _, ti := range pi.Tracks {
|
||||
if ti.Sid == pti.trackInfos[0].Sid {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
pi.Tracks = append(pi.Tracks, pti.trackInfos[0])
|
||||
}
|
||||
}
|
||||
|
||||
for _, pt := range p.pendingTracks {
|
||||
maybeAdd(pt)
|
||||
}
|
||||
for _, ppt := range p.pendingPublishingTracks {
|
||||
maybeAdd(ppt)
|
||||
}
|
||||
p.pendingTracksLock.RUnlock()
|
||||
|
||||
return pi, piv
|
||||
}
|
||||
|
||||
@@ -748,6 +777,10 @@ func (p *ParticipantImpl) SetMigrateInfo(
|
||||
}
|
||||
p.pendingTracksLock.Unlock()
|
||||
|
||||
if len(mediaTracks) != 0 {
|
||||
p.setIsPublisher(true)
|
||||
}
|
||||
|
||||
p.TransportManager.SetMigrateInfo(previousOffer, previousAnswer, dataChannels)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user