Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not force reconnect on resume if there is a pending track #2081

Merged
merged 2 commits into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkg/rtc/participant.go
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,19 @@ func (p *ParticipantImpl) addPendingTrackLocked(req *livekit.AddTrackRequest) *l
return ti
}

func (p *ParticipantImpl) GetPendingTrack(trackID livekit.TrackID) *livekit.TrackInfo {
p.pendingTracksLock.RLock()
defer p.pendingTracksLock.RUnlock()

for _, t := range p.pendingTracks {
if livekit.TrackID(t.trackInfos[0].Sid) == trackID {
return t.trackInfos[0]
}
}

return nil
}

func (p *ParticipantImpl) sendTrackPublished(cid string, ti *livekit.TrackInfo) {
p.pubLogger.Debugw("sending track published", "cid", cid, "trackInfo", ti.String())
_ = p.writeMessage(&livekit.SignalResponse{
Expand Down
4 changes: 4 additions & 0 deletions pkg/rtc/room.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,10 @@ func (r *Room) SyncState(participant types.LocalParticipant, state *livekit.Sync
break
}
}
if !found {
// is there a pending track?
found = participant.GetPendingTrack(livekit.TrackID(ti.Sid)) != nil
}
if !found {
pLogger.Warnw("unknown track during resume", nil, "trackID", ti.Sid)
shouldReconnect = true
Expand Down
3 changes: 2 additions & 1 deletion pkg/rtc/types/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ type Participant interface {
SetMetadata(metadata string)

IsPublisher() bool
GetPublishedTrack(sid livekit.TrackID) MediaTrack
GetPublishedTrack(trackID livekit.TrackID) MediaTrack
GetPublishedTracks() []MediaTrack
RemovePublishedTrack(track MediaTrack, willBeResumed bool, shouldClose bool)

Expand Down Expand Up @@ -315,6 +315,7 @@ type LocalParticipant interface {
GetICEConnectionType() ICEConnectionType
GetBufferFactory() *buffer.Factory
GetPlayoutDelayConfig() *livekit.PlayoutDelay
GetPendingTrack(trackID livekit.TrackID) *livekit.TrackInfo

SetResponseSink(sink routing.MessageSink)
CloseSignalConnection(reason SignallingCloseReason)
Expand Down
74 changes: 74 additions & 0 deletions pkg/rtc/types/typesfakes/fake_local_participant.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.