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
+29
View File
@@ -15,11 +15,17 @@
package rtc
import (
"fmt"
"math/rand/v2"
"strings"
"testing"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/utils/guid"
)
func TestPackStreamId(t *testing.T) {
@@ -43,3 +49,26 @@ func TestPackDataTrackLabel(t *testing.T) {
require.Equal(t, trackID, tr)
require.Equal(t, label, l)
}
func TestChunkProtoBatch(t *testing.T) {
rng := rand.New(rand.NewPCG(1, 2))
var updates []*livekit.ParticipantInfo
for range 32 {
updates = append(updates, &livekit.ParticipantInfo{
Sid: guid.New(guid.ParticipantPrefix),
Identity: uuid.NewString(),
Metadata: strings.Repeat("x", rng.IntN(128*1024)),
})
}
target := 64 * 1024
batches := ChunkProtoBatch(updates, target)
for _, b := range batches {
var sum int
for _, m := range b {
sum += proto.Size(m)
}
require.True(t, sum < target || len(b) == 1, "batch size exceeds target")
}
fmt.Println(len(batches))
}