handle SyncState in join request (#3839)

* handle SyncState in join request

* check for nil in function
This commit is contained in:
Raja Subramanian
2025-08-08 10:14:02 +05:30
committed by GitHub
parent 5d44cf6d57
commit f275f592ed
5 changed files with 33 additions and 6 deletions
+4
View File
@@ -199,6 +199,7 @@ type ParticipantInit struct {
CreateRoom *livekit.CreateRoomRequest
AddTrackRequests []*livekit.AddTrackRequest
PublisherOffer *livekit.SessionDescription
SyncState *livekit.SyncState
}
func (pi *ParticipantInit) MarshalLogObject(e zapcore.ObjectEncoder) error {
@@ -228,6 +229,7 @@ func (pi *ParticipantInit) MarshalLogObject(e zapcore.ObjectEncoder) error {
e.AddObject("CreateRoom", logger.Proto(pi.CreateRoom))
e.AddArray("AddTrackRequests", logger.ProtoSlice(pi.AddTrackRequests))
e.AddObject("PublisherOffer", logger.Proto(pi.PublisherOffer))
e.AddObject("SyncState", logger.Proto(pi.SyncState))
return nil
}
@@ -253,6 +255,7 @@ func (pi *ParticipantInit) ToStartSession(roomName livekit.RoomName, connectionI
CreateRoom: pi.CreateRoom,
AddTrackRequests: pi.AddTrackRequests,
PublisherOffer: pi.PublisherOffer,
SyncState: pi.SyncState,
}
if pi.SubscriberAllowPause != nil {
subscriberAllowPause := *pi.SubscriberAllowPause
@@ -283,6 +286,7 @@ func ParticipantInitFromStartSession(ss *livekit.StartSession, region string) (*
CreateRoom: ss.CreateRoom,
AddTrackRequests: ss.AddTrackRequests,
PublisherOffer: ss.PublisherOffer,
SyncState: ss.SyncState,
}
if ss.SubscriberAllowPause != nil {
subscriberAllowPause := *ss.SubscriberAllowPause
+8
View File
@@ -696,6 +696,14 @@ func (r *Room) ResumeParticipant(
return nil
}
func (r *Room) HandleSyncState(participant types.LocalParticipant, state *livekit.SyncState) error {
if state != nil {
return r.onSyncState(participant, state)
}
return nil
}
func (r *Room) onSyncState(participant types.LocalParticipant, state *livekit.SyncState) error {
pLogger := participant.GetLogger()
pLogger.Infow("setting sync state", "state", logger.Proto(state))
+3
View File
@@ -359,6 +359,9 @@ func (r *RoomManager) StartSession(
return err
}
r.telemetry.ParticipantResumed(ctx, room.ToProto(), participant.ToProto(), r.currentNode.NodeID(), pi.ReconnectReason)
go room.HandleSyncState(participant, pi.SyncState)
go r.rtcSessionWorker(room, participant, requestSource)
return nil
}