feat: include room metadata in all room ajacent event

This commit is contained in:
Zomatree
2026-03-03 15:40:33 +00:00
parent ce2ec5ac45
commit beb8eeab15
29 changed files with 72 additions and 59 deletions
@@ -4,8 +4,8 @@ package routingfakes
import (
"sync"
"github.com/stoatchat/livekit-server/pkg/routing"
"github.com/livekit/protocol/livekit"
"github.com/stoatchat/livekit-server/pkg/routing"
"google.golang.org/protobuf/proto"
)
@@ -4,8 +4,8 @@ package routingfakes
import (
"sync"
"github.com/stoatchat/livekit-server/pkg/routing"
"github.com/livekit/protocol/livekit"
"github.com/stoatchat/livekit-server/pkg/routing"
"google.golang.org/protobuf/proto"
)
@@ -5,9 +5,9 @@ import (
"context"
"sync"
"github.com/stoatchat/livekit-server/pkg/routing"
"github.com/livekit/protocol/livekit"
"github.com/livekit/psrpc"
"github.com/stoatchat/livekit-server/pkg/routing"
)
type FakeRoomManagerClient struct {
+1 -1
View File
@@ -5,8 +5,8 @@ import (
"context"
"sync"
"github.com/stoatchat/livekit-server/pkg/routing"
"github.com/livekit/protocol/livekit"
"github.com/stoatchat/livekit-server/pkg/routing"
)
type FakeRouter struct {
@@ -5,8 +5,8 @@ import (
"context"
"sync"
"github.com/stoatchat/livekit-server/pkg/routing"
"github.com/livekit/protocol/livekit"
"github.com/stoatchat/livekit-server/pkg/routing"
)
type FakeSignalClient struct {
+2 -2
View File
@@ -292,7 +292,7 @@ func NewRoom(
r.protoRoom.CreationTime = now.Unix()
r.protoRoom.CreationTimeMs = now.UnixMilli()
}
r.protoProxy = utils.NewProtoProxy(roomUpdateInterval, r.updateProto)
r.protoProxy = utils.NewProtoProxy(roomUpdateInterval, r.UpdateProto)
r.createAgentDispatchesFromRoomAgent()
@@ -1450,7 +1450,7 @@ func (r *Room) sendSpeakerChanges(speakers []*livekit.SpeakerInfo) {
}
}
func (r *Room) updateProto() *livekit.Room {
func (r *Room) UpdateProto() *livekit.Room {
r.lock.RLock()
room := utils.CloneProto(r.protoRoom)
r.lock.RUnlock()
@@ -4,11 +4,11 @@ package transportfakes
import (
"sync"
"github.com/livekit/protocol/livekit"
webrtc "github.com/pion/webrtc/v4"
"github.com/stoatchat/livekit-server/pkg/rtc/transport"
"github.com/stoatchat/livekit-server/pkg/rtc/types"
"github.com/stoatchat/livekit-server/pkg/sfu/streamallocator"
"github.com/livekit/protocol/livekit"
webrtc "github.com/pion/webrtc/v4"
)
type FakeHandler struct {
@@ -4,11 +4,11 @@ package typesfakes
import (
"sync"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/stoatchat/livekit-server/pkg/rtc/types"
"github.com/stoatchat/livekit-server/pkg/sfu"
"github.com/stoatchat/livekit-server/pkg/sfu/mime"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
)
type FakeLocalMediaTrack struct {
@@ -5,12 +5,6 @@ import (
"sync"
"time"
"github.com/stoatchat/livekit-server/pkg/routing"
"github.com/stoatchat/livekit-server/pkg/rtc/types"
"github.com/stoatchat/livekit-server/pkg/sfu"
"github.com/stoatchat/livekit-server/pkg/sfu/buffer"
"github.com/stoatchat/livekit-server/pkg/sfu/pacer"
"github.com/stoatchat/livekit-server/pkg/telemetry"
"github.com/livekit/protocol/auth"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
@@ -18,6 +12,12 @@ import (
"github.com/livekit/protocol/utils"
"github.com/pion/rtcp"
webrtc "github.com/pion/webrtc/v4"
"github.com/stoatchat/livekit-server/pkg/routing"
"github.com/stoatchat/livekit-server/pkg/rtc/types"
"github.com/stoatchat/livekit-server/pkg/sfu"
"github.com/stoatchat/livekit-server/pkg/sfu/buffer"
"github.com/stoatchat/livekit-server/pkg/sfu/pacer"
"github.com/stoatchat/livekit-server/pkg/telemetry"
"google.golang.org/protobuf/proto"
)
@@ -4,8 +4,8 @@ package typesfakes
import (
"sync"
"github.com/stoatchat/livekit-server/pkg/rtc/types"
"github.com/livekit/protocol/livekit"
"github.com/stoatchat/livekit-server/pkg/rtc/types"
)
type FakeLocalParticipantHelper struct {
+2 -2
View File
@@ -4,11 +4,11 @@ package typesfakes
import (
"sync"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/stoatchat/livekit-server/pkg/rtc/types"
"github.com/stoatchat/livekit-server/pkg/sfu"
"github.com/stoatchat/livekit-server/pkg/sfu/mime"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
)
type FakeMediaTrack struct {
+1 -1
View File
@@ -5,9 +5,9 @@ import (
"sync"
"time"
"github.com/stoatchat/livekit-server/pkg/rtc/types"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/utils"
"github.com/stoatchat/livekit-server/pkg/rtc/types"
)
type FakeParticipant struct {
+1 -1
View File
@@ -4,8 +4,8 @@ package typesfakes
import (
"sync"
"github.com/stoatchat/livekit-server/pkg/rtc/types"
"github.com/livekit/protocol/livekit"
"github.com/stoatchat/livekit-server/pkg/rtc/types"
)
type FakeRoom struct {
@@ -4,10 +4,10 @@ package typesfakes
import (
"sync"
"github.com/stoatchat/livekit-server/pkg/rtc/types"
"github.com/stoatchat/livekit-server/pkg/sfu"
"github.com/livekit/protocol/livekit"
webrtc "github.com/pion/webrtc/v4"
"github.com/stoatchat/livekit-server/pkg/rtc/types"
"github.com/stoatchat/livekit-server/pkg/sfu"
)
type FakeSubscribedTrack struct {
+1 -1
View File
@@ -5,8 +5,8 @@ import (
"context"
"sync"
"github.com/stoatchat/livekit-server/pkg/service"
"github.com/livekit/protocol/livekit"
"github.com/stoatchat/livekit-server/pkg/service"
)
type FakeAgentStore struct {
@@ -5,8 +5,8 @@ import (
"context"
"sync"
"github.com/stoatchat/livekit-server/pkg/service"
"github.com/livekit/protocol/livekit"
"github.com/stoatchat/livekit-server/pkg/service"
)
type FakeEgressStore struct {
@@ -5,8 +5,8 @@ import (
"context"
"sync"
"github.com/stoatchat/livekit-server/pkg/service"
"github.com/livekit/protocol/livekit"
"github.com/stoatchat/livekit-server/pkg/service"
)
type FakeIngressStore struct {
+1 -1
View File
@@ -5,9 +5,9 @@ import (
"context"
"sync"
"github.com/stoatchat/livekit-server/pkg/service"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/rpc"
"github.com/stoatchat/livekit-server/pkg/service"
"google.golang.org/protobuf/types/known/emptypb"
)
@@ -6,8 +6,8 @@ import (
"sync"
"time"
"github.com/stoatchat/livekit-server/pkg/service"
"github.com/livekit/protocol/livekit"
"github.com/stoatchat/livekit-server/pkg/service"
)
type FakeObjectStore struct {
@@ -5,8 +5,8 @@ import (
"context"
"sync"
"github.com/stoatchat/livekit-server/pkg/service"
"github.com/livekit/protocol/livekit"
"github.com/stoatchat/livekit-server/pkg/service"
)
type FakeRoomAllocator struct {
@@ -5,8 +5,8 @@ import (
"context"
"sync"
"github.com/stoatchat/livekit-server/pkg/service"
"github.com/livekit/protocol/livekit"
"github.com/stoatchat/livekit-server/pkg/service"
)
type FakeServiceStore struct {
@@ -5,10 +5,10 @@ import (
"context"
"sync"
"github.com/stoatchat/livekit-server/pkg/routing"
"github.com/stoatchat/livekit-server/pkg/service"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/stoatchat/livekit-server/pkg/routing"
"github.com/stoatchat/livekit-server/pkg/service"
)
type FakeSessionHandler struct {
+1 -1
View File
@@ -5,8 +5,8 @@ import (
"context"
"sync"
"github.com/stoatchat/livekit-server/pkg/service"
"github.com/livekit/protocol/livekit"
"github.com/stoatchat/livekit-server/pkg/service"
)
type FakeSIPStore struct {
+5 -1
View File
@@ -87,6 +87,7 @@ func (t *telemetryService) ParticipantJoined(
ctx,
livekit.RoomID(room.Sid),
livekit.RoomName(room.Name),
room.Metadata,
livekit.ParticipantID(participant.Sid),
livekit.ParticipantIdentity(participant.Identity),
guard,
@@ -127,6 +128,7 @@ func (t *telemetryService) ParticipantActive(
ctx,
livekit.RoomID(room.Sid),
livekit.RoomName(room.Name),
room.Metadata,
livekit.ParticipantID(participant.Sid),
livekit.ParticipantIdentity(participant.Identity),
guard,
@@ -164,6 +166,7 @@ func (t *telemetryService) ParticipantResumed(
ctx,
livekit.RoomID(room.Sid),
livekit.RoomName(room.Name),
room.Metadata,
livekit.ParticipantID(participant.Sid),
livekit.ParticipantIdentity(participant.Identity),
nil,
@@ -572,13 +575,14 @@ func (t *telemetryService) Webhook(ctx context.Context, webhookInfo *livekit.Web
})
}
// returns a livekit.Room with only name and sid filled out
// returns a livekit.Room with only name, sid and metadata filled out
// returns nil if room is not found
func (t *telemetryService) getRoomDetails(participantID livekit.ParticipantID) *livekit.Room {
if worker, ok := t.getWorker(participantID); ok {
return &livekit.Room{
Sid: string(worker.roomID),
Name: string(worker.roomName),
Metadata: worker.roomMetadata,
}
}
+3
View File
@@ -59,6 +59,7 @@ type StatsWorker struct {
t TelemetryService
roomID livekit.RoomID
roomName livekit.RoomName
roomMetadata string
participantID livekit.ParticipantID
participantIdentity livekit.ParticipantIdentity
isConnected bool
@@ -75,6 +76,7 @@ func newStatsWorker(
t TelemetryService,
roomID livekit.RoomID,
roomName livekit.RoomName,
roomMetadata string,
participantID livekit.ParticipantID,
identity livekit.ParticipantIdentity,
guard *ReferenceGuard,
@@ -84,6 +86,7 @@ func newStatsWorker(
t: t,
roomID: roomID,
roomName: roomName,
roomMetadata: roomMetadata,
participantID: participantID,
participantIdentity: identity,
outgoingPerTrack: make(map[livekit.TrackID][]*livekit.AnalyticsStat),
+1 -1
View File
@@ -9,7 +9,7 @@ import (
func TestStatsWorker(t *testing.T) {
t.Run("reference counted close works", func(t *testing.T) {
var g0, g1 ReferenceGuard
w := newStatsWorker(t.Context(), nil, "", "", "", "", &g0)
w := newStatsWorker(t.Context(), nil, "", "", "", "", "", &g0)
require.False(t, w.Closed(&g1))
require.False(t, w.Close(&g0))
require.False(t, w.Closed(&g1))
@@ -5,9 +5,9 @@ import (
"context"
"sync"
"github.com/stoatchat/livekit-server/pkg/telemetry"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/observability/roomobs"
"github.com/stoatchat/livekit-server/pkg/telemetry"
)
type FakeAnalyticsService struct {
@@ -5,10 +5,10 @@ import (
"context"
"sync"
"github.com/stoatchat/livekit-server/pkg/sfu/mime"
"github.com/stoatchat/livekit-server/pkg/telemetry"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/observability/roomobs"
"github.com/stoatchat/livekit-server/pkg/sfu/mime"
"github.com/stoatchat/livekit-server/pkg/telemetry"
)
type FakeTelemetryService struct {
@@ -178,12 +178,13 @@ type FakeTelemetryService struct {
arg4 mime.MimeType
arg5 livekit.VideoQuality
}
TrackMutedStub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo)
TrackMutedStub func(context.Context, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo)
trackMutedMutex sync.RWMutex
trackMutedArgsForCall []struct {
arg1 context.Context
arg2 livekit.ParticipantID
arg3 *livekit.TrackInfo
arg3 livekit.ParticipantIdentity
arg4 *livekit.TrackInfo
}
TrackPublishRTPStatsStub func(context.Context, livekit.ParticipantID, livekit.TrackID, mime.MimeType, int, *livekit.RTPStats)
trackPublishRTPStatsMutex sync.RWMutex
@@ -258,12 +259,13 @@ type FakeTelemetryService struct {
arg4 *livekit.ParticipantInfo
arg5 bool
}
TrackUnmutedStub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo)
TrackUnmutedStub func(context.Context, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo)
trackUnmutedMutex sync.RWMutex
trackUnmutedArgsForCall []struct {
arg1 context.Context
arg2 livekit.ParticipantID
arg3 *livekit.TrackInfo
arg3 livekit.ParticipantIdentity
arg4 *livekit.TrackInfo
}
TrackUnpublishedStub func(context.Context, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo, bool)
trackUnpublishedMutex sync.RWMutex
@@ -1127,18 +1129,19 @@ func (fake *FakeTelemetryService) TrackMaxSubscribedVideoQualityArgsForCall(i in
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5
}
func (fake *FakeTelemetryService) TrackMuted(arg1 context.Context, arg2 livekit.ParticipantID, arg3 *livekit.TrackInfo) {
func (fake *FakeTelemetryService) TrackMuted(arg1 context.Context, arg2 livekit.ParticipantID, arg3 livekit.ParticipantIdentity, arg4 *livekit.TrackInfo) {
fake.trackMutedMutex.Lock()
fake.trackMutedArgsForCall = append(fake.trackMutedArgsForCall, struct {
arg1 context.Context
arg2 livekit.ParticipantID
arg3 *livekit.TrackInfo
}{arg1, arg2, arg3})
arg3 livekit.ParticipantIdentity
arg4 *livekit.TrackInfo
}{arg1, arg2, arg3, arg4})
stub := fake.TrackMutedStub
fake.recordInvocation("TrackMuted", []interface{}{arg1, arg2, arg3})
fake.recordInvocation("TrackMuted", []interface{}{arg1, arg2, arg3, arg4})
fake.trackMutedMutex.Unlock()
if stub != nil {
fake.TrackMutedStub(arg1, arg2, arg3)
fake.TrackMutedStub(arg1, arg2, arg3, arg4)
}
}
@@ -1148,17 +1151,17 @@ func (fake *FakeTelemetryService) TrackMutedCallCount() int {
return len(fake.trackMutedArgsForCall)
}
func (fake *FakeTelemetryService) TrackMutedCalls(stub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo)) {
func (fake *FakeTelemetryService) TrackMutedCalls(stub func(context.Context, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo)) {
fake.trackMutedMutex.Lock()
defer fake.trackMutedMutex.Unlock()
fake.TrackMutedStub = stub
}
func (fake *FakeTelemetryService) TrackMutedArgsForCall(i int) (context.Context, livekit.ParticipantID, *livekit.TrackInfo) {
func (fake *FakeTelemetryService) TrackMutedArgsForCall(i int) (context.Context, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo) {
fake.trackMutedMutex.RLock()
defer fake.trackMutedMutex.RUnlock()
argsForCall := fake.trackMutedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4
}
func (fake *FakeTelemetryService) TrackPublishRTPStats(arg1 context.Context, arg2 livekit.ParticipantID, arg3 livekit.TrackID, arg4 mime.MimeType, arg5 int, arg6 *livekit.RTPStats) {
@@ -1477,18 +1480,19 @@ func (fake *FakeTelemetryService) TrackSubscribedArgsForCall(i int) (context.Con
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4, argsForCall.arg5
}
func (fake *FakeTelemetryService) TrackUnmuted(arg1 context.Context, arg2 livekit.ParticipantID, arg3 *livekit.TrackInfo) {
func (fake *FakeTelemetryService) TrackUnmuted(arg1 context.Context, arg2 livekit.ParticipantID, arg3 livekit.ParticipantIdentity, arg4 *livekit.TrackInfo) {
fake.trackUnmutedMutex.Lock()
fake.trackUnmutedArgsForCall = append(fake.trackUnmutedArgsForCall, struct {
arg1 context.Context
arg2 livekit.ParticipantID
arg3 *livekit.TrackInfo
}{arg1, arg2, arg3})
arg3 livekit.ParticipantIdentity
arg4 *livekit.TrackInfo
}{arg1, arg2, arg3, arg4})
stub := fake.TrackUnmutedStub
fake.recordInvocation("TrackUnmuted", []interface{}{arg1, arg2, arg3})
fake.recordInvocation("TrackUnmuted", []interface{}{arg1, arg2, arg3, arg4})
fake.trackUnmutedMutex.Unlock()
if stub != nil {
fake.TrackUnmutedStub(arg1, arg2, arg3)
fake.TrackUnmutedStub(arg1, arg2, arg3, arg4)
}
}
@@ -1498,17 +1502,17 @@ func (fake *FakeTelemetryService) TrackUnmutedCallCount() int {
return len(fake.trackUnmutedArgsForCall)
}
func (fake *FakeTelemetryService) TrackUnmutedCalls(stub func(context.Context, livekit.ParticipantID, *livekit.TrackInfo)) {
func (fake *FakeTelemetryService) TrackUnmutedCalls(stub func(context.Context, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo)) {
fake.trackUnmutedMutex.Lock()
defer fake.trackUnmutedMutex.Unlock()
fake.TrackUnmutedStub = stub
}
func (fake *FakeTelemetryService) TrackUnmutedArgsForCall(i int) (context.Context, livekit.ParticipantID, *livekit.TrackInfo) {
func (fake *FakeTelemetryService) TrackUnmutedArgsForCall(i int) (context.Context, livekit.ParticipantID, livekit.ParticipantIdentity, *livekit.TrackInfo) {
fake.trackUnmutedMutex.RLock()
defer fake.trackUnmutedMutex.RUnlock()
argsForCall := fake.trackUnmutedArgsForCall[i]
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4
}
func (fake *FakeTelemetryService) TrackUnpublished(arg1 context.Context, arg2 livekit.ParticipantID, arg3 livekit.ParticipantIdentity, arg4 *livekit.TrackInfo, arg5 bool) {
+2
View File
@@ -202,6 +202,7 @@ func (t *telemetryService) getOrCreateWorker(
ctx context.Context,
roomID livekit.RoomID,
roomName livekit.RoomName,
roomMetadata string,
participantID livekit.ParticipantID,
participantIdentity livekit.ParticipantIdentity,
guard *ReferenceGuard,
@@ -224,6 +225,7 @@ func (t *telemetryService) getOrCreateWorker(
t,
roomID,
roomName,
roomMetadata,
participantID,
participantIdentity,
guard,