chunk room updates (#3880)
* chunk room updates * move to config * typo * default
This commit is contained in:
+15
-9
@@ -106,6 +106,7 @@ type Room struct {
|
||||
logger logger.Logger
|
||||
|
||||
config WebRTCConfig
|
||||
roomConfig config.RoomConfig
|
||||
audioConfig *sfu.AudioConfig
|
||||
serverInfo *livekit.ServerInfo
|
||||
telemetry telemetry.TelemetryService
|
||||
@@ -253,6 +254,7 @@ func NewRoom(
|
||||
livekit.RoomID(room.Sid),
|
||||
),
|
||||
config: config,
|
||||
roomConfig: roomConfig,
|
||||
audioConfig: audioConfig,
|
||||
telemetry: telemetry,
|
||||
egressLauncher: egressLauncher,
|
||||
@@ -1431,7 +1433,7 @@ func (r *Room) broadcastParticipantState(p types.LocalParticipant, opts broadcas
|
||||
r.batchedUpdatesMu.Unlock()
|
||||
if len(updates) != 0 {
|
||||
selfSent = true
|
||||
SendParticipantUpdates(updates, r.GetParticipants())
|
||||
SendParticipantUpdates(updates, r.GetParticipants(), r.roomConfig.UpdateBatchTargetSize)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1488,7 +1490,7 @@ func (r *Room) changeUpdateWorker() {
|
||||
r.batchedUpdates = make(map[livekit.ParticipantIdentity]*ParticipantUpdate)
|
||||
r.batchedUpdatesMu.Unlock()
|
||||
|
||||
SendParticipantUpdates(maps.Values(updatesMap), r.GetParticipants())
|
||||
SendParticipantUpdates(maps.Values(updatesMap), r.GetParticipants(), r.roomConfig.UpdateBatchTargetSize)
|
||||
|
||||
case <-cleanDataMessageTicker.C:
|
||||
r.dataMessageCache.Prune()
|
||||
@@ -1968,7 +1970,7 @@ func PushAndDequeueUpdates(
|
||||
return updates
|
||||
}
|
||||
|
||||
func SendParticipantUpdates(updates []*ParticipantUpdate, participants []types.LocalParticipant) {
|
||||
func SendParticipantUpdates(updates []*ParticipantUpdate, participants []types.LocalParticipant, batchTargetSize int) {
|
||||
if len(updates) == 0 {
|
||||
return
|
||||
}
|
||||
@@ -1992,15 +1994,19 @@ func SendParticipantUpdates(updates []*ParticipantUpdate, participants []types.L
|
||||
fullUpdates = append(fullUpdates, update.ParticipantInfo)
|
||||
}
|
||||
|
||||
filteredUpdateChunks := ChunkProtoBatch(filteredUpdates, batchTargetSize)
|
||||
fullUpdateChunks := ChunkProtoBatch(fullUpdates, batchTargetSize)
|
||||
|
||||
for _, op := range participants {
|
||||
var err error
|
||||
updateChunks := fullUpdateChunks
|
||||
if op.ProtocolVersion().SupportsIdentityBasedReconnection() {
|
||||
err = op.SendParticipantUpdate(filteredUpdates)
|
||||
} else {
|
||||
err = op.SendParticipantUpdate(fullUpdates)
|
||||
updateChunks = filteredUpdateChunks
|
||||
}
|
||||
if err != nil {
|
||||
op.GetLogger().Errorw("could not send update to participant", err)
|
||||
for _, chunk := range updateChunks {
|
||||
if err := op.SendParticipantUpdate(chunk); err != nil {
|
||||
op.GetLogger().Errorw("could not send update to participant", err)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user