chunk room updates (#3880)

* chunk room updates

* move to config

* typo

* default
This commit is contained in:
Paul Wells
2025-08-26 09:16:00 -07:00
committed by GitHub
parent b4e146c5cb
commit 8d270e2a0f
4 changed files with 73 additions and 14 deletions
+21
View File
@@ -21,6 +21,7 @@ import (
"strings"
"github.com/pion/webrtc/v4"
"google.golang.org/protobuf/proto"
"github.com/livekit/livekit-server/pkg/sfu/mime"
"github.com/livekit/protocol/livekit"
@@ -171,3 +172,23 @@ func MaybeTruncateIP(addr string) string {
return addr[:len(addr)-3] + "..."
}
func ChunkProtoBatch[T proto.Message](batch []T, target int) [][]T {
var chunks [][]T
var start, size int
for i, m := range batch {
if s := proto.Size(m); size+s > target {
if start < i {
chunks = append(chunks, batch[start:i])
}
start = i
size = s
} else {
size += s
}
}
if start < len(batch) {
chunks = append(chunks, batch[start:])
}
return chunks
}