From 995c1e86766ac10c62db5a888781d0a02c017483 Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Mon, 3 Jan 2022 12:43:58 +0530 Subject: [PATCH] type aliases -> type definitions (#312) * type alias -> type definition * participantSid -> participantID in a comment * Update protocol --- go.mod | 2 +- go.sum | 4 +- pkg/routing/localrouter.go | 2 +- pkg/routing/redisrouter.go | 8 +- pkg/routing/routingfakes/fake_router.go | 24 +-- pkg/routing/utils.go | 4 +- pkg/rtc/helper_test.go | 4 +- pkg/rtc/mediatrack.go | 8 +- pkg/rtc/mediatrack_test.go | 18 +- pkg/rtc/participant.go | 27 +-- pkg/rtc/participant_internal_test.go | 2 +- pkg/rtc/room.go | 20 +-- pkg/rtc/room_test.go | 14 +- pkg/rtc/signalhandler.go | 8 +- pkg/rtc/subscribedtrack.go | 4 +- pkg/rtc/types/typesfakes/fake_media_track.go | 98 +++++------ pkg/rtc/types/typesfakes/fake_participant.go | 160 +++++++++--------- .../types/typesfakes/fake_published_track.go | 98 +++++------ pkg/rtc/types/typesfakes/fake_room.go | 16 +- .../types/typesfakes/fake_subscribed_track.go | 60 +++---- pkg/rtc/uptrackmanager.go | 18 +- pkg/rtc/utils.go | 14 +- pkg/rtc/utils_test.go | 9 +- pkg/service/localroomstore.go | 2 +- pkg/service/redisroomstore.go | 4 +- pkg/service/redisroomstore_test.go | 6 +- pkg/service/roommanager.go | 4 +- pkg/service/roomservice.go | 14 +- pkg/service/rtcservice.go | 4 +- pkg/service/servicefakes/fake_room_store.go | 24 +-- pkg/service/servicefakes/fake_roroom_store.go | 12 +- pkg/sfu/downtrack.go | 13 +- pkg/sfu/receiver.go | 31 ++-- pkg/sfu/streamallocator.go | 58 ++++--- pkg/telemetry/statsworker.go | 16 +- .../telemetryserviceinternalevents.go | 26 +-- pkg/telemetry/test/telemetry_service_test.go | 94 +++++----- test/client/client.go | 40 ++--- test/scenarios.go | 2 +- 39 files changed, 490 insertions(+), 482 deletions(-) diff --git a/go.mod b/go.mod index 0183be5a..4f80fdf5 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/google/wire v0.5.0 github.com/gorilla/websocket v1.4.2 github.com/hashicorp/golang-lru v0.5.4 - github.com/livekit/protocol v0.11.8-0.20220102040102-feaea540b8df + github.com/livekit/protocol v0.11.8-0.20220103045453-c441eb5f03c8 github.com/magefile/mage v1.11.0 github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0 github.com/mitchellh/go-homedir v1.1.0 diff --git a/go.sum b/go.sum index cf21333d..a33092c7 100644 --- a/go.sum +++ b/go.sum @@ -132,8 +132,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lithammer/shortuuid/v3 v3.0.6 h1:pr15YQyvhiSX/qPxncFtqk+v4xLEpOZObbsY/mKrcvA= github.com/lithammer/shortuuid/v3 v3.0.6/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts= -github.com/livekit/protocol v0.11.8-0.20220102040102-feaea540b8df h1:4cqTGvQXH0Tb104eX2oIM7kUvtbX1JB0rtP0Sjf8Ct8= -github.com/livekit/protocol v0.11.8-0.20220102040102-feaea540b8df/go.mod h1:YoHW9YbWbPnuVsgwBB4hAINKT+V68jmfh9zXBSSn6Wg= +github.com/livekit/protocol v0.11.8-0.20220103045453-c441eb5f03c8 h1:eo4OOUKLgNguaHEmcItTfk2IzVC2s2r6/WXqFfj5HjE= +github.com/livekit/protocol v0.11.8-0.20220103045453-c441eb5f03c8/go.mod h1:YoHW9YbWbPnuVsgwBB4hAINKT+V68jmfh9zXBSSn6Wg= github.com/magefile/mage v1.11.0 h1:C/55Ywp9BpgVVclD3lRnSYCwXTYxmSppIgLeDYlNuls= github.com/magefile/mage v1.11.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= diff --git a/pkg/routing/localrouter.go b/pkg/routing/localrouter.go index 7739dada..e8cbebf2 100644 --- a/pkg/routing/localrouter.go +++ b/pkg/routing/localrouter.go @@ -107,7 +107,7 @@ func (r *LocalRouter) StartParticipantSignal(ctx context.Context, roomName livek // response sink resChan, ) - return pi.Identity, reqChan, resChan, nil + return string(pi.Identity), reqChan, resChan, nil } func (r *LocalRouter) WriteParticipantRTC(_ context.Context, roomName livekit.RoomName, identity livekit.ParticipantIdentity, msg *livekit.RTCNodeMessage) error { diff --git a/pkg/routing/redisrouter.go b/pkg/routing/redisrouter.go index d5b14aca..6fff9a15 100644 --- a/pkg/routing/redisrouter.go +++ b/pkg/routing/redisrouter.go @@ -149,9 +149,9 @@ func (r *RedisRouter) StartParticipantSignal(ctx context.Context, roomName livek // sends a message to start session err = sink.WriteMessage(&livekit.StartSession{ RoomName: string(roomName), - Identity: pi.Identity, + Identity: string(pi.Identity), Metadata: pi.Metadata, - Name: pi.Name, + Name: string(pi.Name), // connection id is to allow the RTC node to identify where to route the message back to ConnectionId: connectionID, Reconnect: pi.Reconnect, @@ -239,9 +239,9 @@ func (r *RedisRouter) startParticipantRTC(ss *livekit.StartSession, participantK } pi := ParticipantInit{ - Identity: ss.Identity, + Identity: livekit.ParticipantIdentity(ss.Identity), Metadata: ss.Metadata, - Name: ss.Name, + Name: livekit.ParticipantName(ss.Name), Reconnect: ss.Reconnect, Permission: ss.Permission, Client: ss.Client, diff --git a/pkg/routing/routingfakes/fake_router.go b/pkg/routing/routingfakes/fake_router.go index 70188075..0366a7bf 100644 --- a/pkg/routing/routingfakes/fake_router.go +++ b/pkg/routing/routingfakes/fake_router.go @@ -138,12 +138,12 @@ type FakeRouter struct { unregisterNodeReturnsOnCall map[int]struct { result1 error } - WriteParticipantRTCStub func(context.Context, livekit.RoomName, string, *livekit.RTCNodeMessage) error + WriteParticipantRTCStub func(context.Context, livekit.RoomName, livekit.ParticipantIdentity, *livekit.RTCNodeMessage) error writeParticipantRTCMutex sync.RWMutex writeParticipantRTCArgsForCall []struct { arg1 context.Context arg2 livekit.RoomName - arg3 string + arg3 livekit.ParticipantIdentity arg4 *livekit.RTCNodeMessage } writeParticipantRTCReturns struct { @@ -152,12 +152,12 @@ type FakeRouter struct { writeParticipantRTCReturnsOnCall map[int]struct { result1 error } - WriteRoomRTCStub func(context.Context, livekit.RoomName, string, *livekit.RTCNodeMessage) error + WriteRoomRTCStub func(context.Context, livekit.RoomName, livekit.ParticipantIdentity, *livekit.RTCNodeMessage) error writeRoomRTCMutex sync.RWMutex writeRoomRTCArgsForCall []struct { arg1 context.Context arg2 livekit.RoomName - arg3 string + arg3 livekit.ParticipantIdentity arg4 *livekit.RTCNodeMessage } writeRoomRTCReturns struct { @@ -812,13 +812,13 @@ func (fake *FakeRouter) UnregisterNodeReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeRouter) WriteParticipantRTC(arg1 context.Context, arg2 livekit.RoomName, arg3 string, arg4 *livekit.RTCNodeMessage) error { +func (fake *FakeRouter) WriteParticipantRTC(arg1 context.Context, arg2 livekit.RoomName, arg3 livekit.ParticipantIdentity, arg4 *livekit.RTCNodeMessage) error { fake.writeParticipantRTCMutex.Lock() ret, specificReturn := fake.writeParticipantRTCReturnsOnCall[len(fake.writeParticipantRTCArgsForCall)] fake.writeParticipantRTCArgsForCall = append(fake.writeParticipantRTCArgsForCall, struct { arg1 context.Context arg2 livekit.RoomName - arg3 string + arg3 livekit.ParticipantIdentity arg4 *livekit.RTCNodeMessage }{arg1, arg2, arg3, arg4}) stub := fake.WriteParticipantRTCStub @@ -840,13 +840,13 @@ func (fake *FakeRouter) WriteParticipantRTCCallCount() int { return len(fake.writeParticipantRTCArgsForCall) } -func (fake *FakeRouter) WriteParticipantRTCCalls(stub func(context.Context, livekit.RoomName, string, *livekit.RTCNodeMessage) error) { +func (fake *FakeRouter) WriteParticipantRTCCalls(stub func(context.Context, livekit.RoomName, livekit.ParticipantIdentity, *livekit.RTCNodeMessage) error) { fake.writeParticipantRTCMutex.Lock() defer fake.writeParticipantRTCMutex.Unlock() fake.WriteParticipantRTCStub = stub } -func (fake *FakeRouter) WriteParticipantRTCArgsForCall(i int) (context.Context, livekit.RoomName, string, *livekit.RTCNodeMessage) { +func (fake *FakeRouter) WriteParticipantRTCArgsForCall(i int) (context.Context, livekit.RoomName, livekit.ParticipantIdentity, *livekit.RTCNodeMessage) { fake.writeParticipantRTCMutex.RLock() defer fake.writeParticipantRTCMutex.RUnlock() argsForCall := fake.writeParticipantRTCArgsForCall[i] @@ -876,13 +876,13 @@ func (fake *FakeRouter) WriteParticipantRTCReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeRouter) WriteRoomRTC(arg1 context.Context, arg2 livekit.RoomName, arg3 string, arg4 *livekit.RTCNodeMessage) error { +func (fake *FakeRouter) WriteRoomRTC(arg1 context.Context, arg2 livekit.RoomName, arg3 livekit.ParticipantIdentity, arg4 *livekit.RTCNodeMessage) error { fake.writeRoomRTCMutex.Lock() ret, specificReturn := fake.writeRoomRTCReturnsOnCall[len(fake.writeRoomRTCArgsForCall)] fake.writeRoomRTCArgsForCall = append(fake.writeRoomRTCArgsForCall, struct { arg1 context.Context arg2 livekit.RoomName - arg3 string + arg3 livekit.ParticipantIdentity arg4 *livekit.RTCNodeMessage }{arg1, arg2, arg3, arg4}) stub := fake.WriteRoomRTCStub @@ -904,13 +904,13 @@ func (fake *FakeRouter) WriteRoomRTCCallCount() int { return len(fake.writeRoomRTCArgsForCall) } -func (fake *FakeRouter) WriteRoomRTCCalls(stub func(context.Context, livekit.RoomName, string, *livekit.RTCNodeMessage) error) { +func (fake *FakeRouter) WriteRoomRTCCalls(stub func(context.Context, livekit.RoomName, livekit.ParticipantIdentity, *livekit.RTCNodeMessage) error) { fake.writeRoomRTCMutex.Lock() defer fake.writeRoomRTCMutex.Unlock() fake.WriteRoomRTCStub = stub } -func (fake *FakeRouter) WriteRoomRTCArgsForCall(i int) (context.Context, livekit.RoomName, string, *livekit.RTCNodeMessage) { +func (fake *FakeRouter) WriteRoomRTCArgsForCall(i int) (context.Context, livekit.RoomName, livekit.ParticipantIdentity, *livekit.RTCNodeMessage) { fake.writeRoomRTCMutex.RLock() defer fake.writeRoomRTCMutex.RUnlock() argsForCall := fake.writeRoomRTCArgsForCall[i] diff --git a/pkg/routing/utils.go b/pkg/routing/utils.go index d4b87a9f..0da5cda8 100644 --- a/pkg/routing/utils.go +++ b/pkg/routing/utils.go @@ -8,7 +8,7 @@ import ( ) func participantKey(roomName livekit.RoomName, identity livekit.ParticipantIdentity) string { - return string(roomName) + "|" + identity + return string(roomName) + "|" + string(identity) } func parseParticipantKey(pkey string) (roomName livekit.RoomName, identity livekit.ParticipantIdentity, err error) { @@ -18,5 +18,5 @@ func parseParticipantKey(pkey string) (roomName livekit.RoomName, identity livek return } - return livekit.RoomName(parts[0]), parts[1], nil + return livekit.RoomName(parts[0]), livekit.ParticipantIdentity(parts[1]), nil } diff --git a/pkg/rtc/helper_test.go b/pkg/rtc/helper_test.go index 97c7f261..5d3e4314 100644 --- a/pkg/rtc/helper_test.go +++ b/pkg/rtc/helper_test.go @@ -10,7 +10,7 @@ import ( func newMockParticipant(identity livekit.ParticipantIdentity, protocol types.ProtocolVersion, hidden bool) *typesfakes.FakeParticipant { p := &typesfakes.FakeParticipant{} - p.IDReturns(utils.NewGuid(utils.ParticipantPrefix)) + p.IDReturns(livekit.ParticipantID(utils.NewGuid(utils.ParticipantPrefix))) p.IdentityReturns(identity) p.StateReturns(livekit.ParticipantInfo_JOINED) p.ProtocolVersionReturns(protocol) @@ -50,7 +50,7 @@ func newMockParticipant(identity livekit.ParticipantIdentity, protocol types.Pro func newMockTrack(kind livekit.TrackType, name string) *typesfakes.FakePublishedTrack { t := &typesfakes.FakePublishedTrack{} - t.IDReturns(utils.NewGuid(utils.TrackPrefix)) + t.IDReturns(livekit.TrackID(utils.NewGuid(utils.TrackPrefix))) t.KindReturns(kind) t.NameReturns(name) return t diff --git a/pkg/rtc/mediatrack.go b/pkg/rtc/mediatrack.go index 323a6c64..c9ac7491 100644 --- a/pkg/rtc/mediatrack.go +++ b/pkg/rtc/mediatrack.go @@ -47,7 +47,7 @@ type MediaTrack struct { lock sync.RWMutex // map of target participantID -> types.SubscribedTrack - subscribedTracks sync.Map // participantSid => types.SubscribedTrack + subscribedTracks sync.Map // participantID => types.SubscribedTrack twcc *twcc.Responder audioLevel *AudioLevel receiver sfu.Receiver @@ -120,7 +120,7 @@ func NewMediaTrack(track *webrtc.TrackRemote, params MediaTrackParams) *MediaTra } func (t *MediaTrack) ID() livekit.TrackID { - return t.params.TrackInfo.Sid + return livekit.TrackID(t.params.TrackInfo.Sid) } func (t *MediaTrack) SignalCid() string { @@ -209,7 +209,7 @@ func (t *MediaTrack) AddSubscriber(sub types.Participant) error { codec := t.receiver.Codec() // using DownTrack from ion-sfu - streamId := t.params.ParticipantID + streamId := string(t.params.ParticipantID) if sub.ProtocolVersion().SupportsPackedStreamId() { // when possible, pack both IDs in streamID to allow new streams to be generated // react-native-webrtc still uses stream based APIs and require this @@ -500,7 +500,7 @@ func (t *MediaTrack) RevokeDisallowedSubscribers(allowedSubscriberIDs []livekit. var revokedSubscriberIDs []livekit.ParticipantID // LK-TODO: large number of subscribers needs to be solved for this loop t.subscribedTracks.Range(func(key interface{}, val interface{}) bool { - if subID, ok := key.(string); ok { + if subID, ok := key.(livekit.ParticipantID); ok { found := false for _, allowedID := range allowedSubscriberIDs { if subID == allowedID { diff --git a/pkg/rtc/mediatrack_test.go b/pkg/rtc/mediatrack_test.go index 297603e0..cf3daa6c 100644 --- a/pkg/rtc/mediatrack_test.go +++ b/pkg/rtc/mediatrack_test.go @@ -28,7 +28,7 @@ func TestTrackInfo(t *testing.T) { require.Equal(t, ti.Muted, outInfo.Muted) require.Equal(t, ti.Name, outInfo.Name) require.Equal(t, ti.Name, mt.Name()) - require.Equal(t, ti.Sid, mt.ID()) + require.Equal(t, livekit.TrackID(ti.Sid), mt.ID()) require.Equal(t, ti.Type, outInfo.Type) require.Equal(t, ti.Type, mt.Kind()) require.Equal(t, ti.Source, outInfo.Source) @@ -128,7 +128,7 @@ func TestSubscribedMaxQuality(t *testing.T) { mt.NotifySubscriberMaxQuality("s1", livekit.VideoQuality_HIGH) - actualTrackID := "" + actualTrackID := livekit.TrackID("") actualSubscribedQualities := []*livekit.SubscribedQuality{} mt.OnSubscribedMaxQualityChange(func(trackID livekit.TrackID, subscribedQualities []*livekit.SubscribedQuality) error { actualTrackID = trackID @@ -144,7 +144,7 @@ func TestSubscribedMaxQuality(t *testing.T) { &livekit.SubscribedQuality{Quality: livekit.VideoQuality_MEDIUM, Enabled: false}, &livekit.SubscribedQuality{Quality: livekit.VideoQuality_HIGH, Enabled: false}, } - require.Equal(t, "v1", actualTrackID) + require.Equal(t, livekit.TrackID("v1"), actualTrackID) require.EqualValues(t, expectedSubscribedQualities, actualSubscribedQualities) }) @@ -173,7 +173,7 @@ func TestSubscribedMaxQuality(t *testing.T) { }, }}) - actualTrackID := "" + actualTrackID := livekit.TrackID("") actualSubscribedQualities := []*livekit.SubscribedQuality{} mt.OnSubscribedMaxQualityChange(func(trackID livekit.TrackID, subscribedQualities []*livekit.SubscribedQuality) error { actualTrackID = trackID @@ -189,7 +189,7 @@ func TestSubscribedMaxQuality(t *testing.T) { &livekit.SubscribedQuality{Quality: livekit.VideoQuality_MEDIUM, Enabled: true}, &livekit.SubscribedQuality{Quality: livekit.VideoQuality_HIGH, Enabled: true}, } - require.Equal(t, "v1", actualTrackID) + require.Equal(t, livekit.TrackID("v1"), actualTrackID) require.EqualValues(t, expectedSubscribedQualities, actualSubscribedQualities) // "s1" dropping to MEDIUM should disable HIGH layer @@ -200,7 +200,7 @@ func TestSubscribedMaxQuality(t *testing.T) { &livekit.SubscribedQuality{Quality: livekit.VideoQuality_MEDIUM, Enabled: true}, &livekit.SubscribedQuality{Quality: livekit.VideoQuality_HIGH, Enabled: false}, } - require.Equal(t, "v1", actualTrackID) + require.Equal(t, livekit.TrackID("v1"), actualTrackID) require.EqualValues(t, expectedSubscribedQualities, actualSubscribedQualities) // "s1" and "s1" dropping to LOW should disable HIGH & MEDIUM @@ -212,7 +212,7 @@ func TestSubscribedMaxQuality(t *testing.T) { &livekit.SubscribedQuality{Quality: livekit.VideoQuality_MEDIUM, Enabled: false}, &livekit.SubscribedQuality{Quality: livekit.VideoQuality_HIGH, Enabled: false}, } - require.Equal(t, "v1", actualTrackID) + require.Equal(t, livekit.TrackID("v1"), actualTrackID) require.EqualValues(t, expectedSubscribedQualities, actualSubscribedQualities) // muting "s2" only should not disable all qualities @@ -223,7 +223,7 @@ func TestSubscribedMaxQuality(t *testing.T) { &livekit.SubscribedQuality{Quality: livekit.VideoQuality_MEDIUM, Enabled: false}, &livekit.SubscribedQuality{Quality: livekit.VideoQuality_HIGH, Enabled: false}, } - require.Equal(t, "v1", actualTrackID) + require.Equal(t, livekit.TrackID("v1"), actualTrackID) require.EqualValues(t, expectedSubscribedQualities, actualSubscribedQualities) // muting "s1" also should disable all qualities @@ -234,7 +234,7 @@ func TestSubscribedMaxQuality(t *testing.T) { &livekit.SubscribedQuality{Quality: livekit.VideoQuality_MEDIUM, Enabled: false}, &livekit.SubscribedQuality{Quality: livekit.VideoQuality_HIGH, Enabled: false}, } - require.Equal(t, "v1", actualTrackID) + require.Equal(t, livekit.TrackID("v1"), actualTrackID) require.EqualValues(t, expectedSubscribedQualities, actualSubscribedQualities) // unmuting "s1" should enable previously set max quality diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index ace91534..44e54f1a 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -228,9 +228,9 @@ func (p *ParticipantImpl) SetPermission(permission *livekit.ParticipantPermissio func (p *ParticipantImpl) ToProto() *livekit.ParticipantInfo { info := &livekit.ParticipantInfo{ - Sid: p.params.SID, - Identity: p.params.Identity, - Name: p.params.Name, + Sid: string(p.params.SID), + Identity: string(p.params.Identity), + Name: string(p.params.Name), Metadata: p.metadata, State: p.State(), JoinedAt: p.ConnectedAt().Unix(), @@ -513,7 +513,8 @@ func (p *ParticipantImpl) SendSpeakerUpdate(speakers []*livekit.SpeakerInfo) err var scopedSpeakers []*livekit.SpeakerInfo for _, s := range speakers { - if p.IsSubscribedTo(s.Sid) || s.Sid == p.ID() { + participantID := livekit.ParticipantID(s.Sid) + if p.IsSubscribedTo(participantID) || participantID == p.ID() { scopedSpeakers = append(scopedSpeakers, s) } } @@ -586,7 +587,7 @@ func (p *ParticipantImpl) SetTrackMuted(trackID livekit.TrackID, muted bool, fro _ = p.writeMessage(&livekit.SignalResponse{ Message: &livekit.SignalResponse_Mute{ Mute: &livekit.MuteTrackRequest{ - Sid: trackID, + Sid: string(trackID), Muted: muted, }, }, @@ -622,7 +623,7 @@ func (p *ParticipantImpl) GetConnectionQuality() *livekit.ConnectionQualityInfo rating := connectionquality.Score2Rating(avgScore) return &livekit.ConnectionQualityInfo{ - ParticipantSid: p.ID(), + ParticipantSid: string(p.ID()), Quality: rating, Score: float32(avgScore), } @@ -755,8 +756,8 @@ func (p *ParticipantImpl) SubscriptionPermissionUpdate(publisherID livekit.Parti err := p.writeMessage(&livekit.SignalResponse{ Message: &livekit.SignalResponse_SubscriptionPermissionUpdate{ SubscriptionPermissionUpdate: &livekit.SubscriptionPermissionUpdate{ - ParticipantSid: publisherID, - TrackSid: trackID, + ParticipantSid: string(publisherID), + TrackSid: string(trackID), Allowed: allowed, }, }, @@ -927,7 +928,7 @@ func (p *ParticipantImpl) handleDataMessage(kind livekit.DataPacket_Kind, data [ switch payload := dp.Value.(type) { case *livekit.DataPacket_User: if p.onDataPacket != nil { - payload.User.ParticipantSid = p.params.SID + payload.User.ParticipantSid = string(p.params.SID) p.onDataPacket(p, &dp) } default: @@ -1108,8 +1109,8 @@ func (p *ParticipantImpl) onStreamStateChange(update *sfu.StreamStateUpdate) err state = livekit.StreamState_PAUSED } streamStateUpdate.StreamStates = append(streamStateUpdate.StreamStates, &livekit.StreamStateInfo{ - ParticipantSid: streamStateInfo.ParticipantSid, - TrackSid: streamStateInfo.TrackSid, + ParticipantSid: string(streamStateInfo.ParticipantID), + TrackSid: string(streamStateInfo.TrackID), State: state, }) } @@ -1127,7 +1128,7 @@ func (p *ParticipantImpl) onSubscribedMaxQualityChange(trackID livekit.TrackID, } subscribedQualityUpdate := &livekit.SubscribedQualityUpdate{ - TrackSid: trackID, + TrackSid: string(trackID), SubscribedQualities: subscribedQualities, } @@ -1146,7 +1147,7 @@ func (p *ParticipantImpl) DebugInfo() map[string]interface{} { uptrackManagerInfo := p.uptrackManager.DebugInfo() - subscribedTrackInfo := make(map[string]interface{}) + subscribedTrackInfo := make(map[livekit.TrackID]interface{}) p.lock.RLock() for _, track := range p.subscribedTracks { dt := track.DownTrack().DebugInfo() diff --git a/pkg/rtc/participant_internal_test.go b/pkg/rtc/participant_internal_test.go index 98845f7b..ba0d2835 100644 --- a/pkg/rtc/participant_internal_test.go +++ b/pkg/rtc/participant_internal_test.go @@ -222,7 +222,7 @@ func TestMuteSetting(t *testing.T) { ti := &livekit.TrackInfo{Sid: "testTrack"} p.uptrackManager.pendingTracks["cid"] = ti - p.SetTrackMuted(ti.Sid, true, false) + p.SetTrackMuted(livekit.TrackID(ti.Sid), true, false) require.True(t, ti.Muted) }) diff --git a/pkg/rtc/room.go b/pkg/rtc/room.go index f9dc0bfd..3446f363 100644 --- a/pkg/rtc/room.go +++ b/pkg/rtc/room.go @@ -124,7 +124,7 @@ func (r *Room) GetActiveSpeakers() []*livekit.SpeakerInfo { continue } speakers = append(speakers, &livekit.SpeakerInfo{ - Sid: p.ID(), + Sid: string(p.ID()), Level: ConvertAudioLevel(level), Active: active, }) @@ -355,11 +355,11 @@ func (r *Room) UpdateSubscriptions( } for _, pt := range participantTracks { - p := r.GetParticipantBySid(pt.ParticipantSid) + p := r.GetParticipantBySid(livekit.ParticipantID(pt.ParticipantSid)) if p == nil { continue } - for _, trackID := range pt.TrackSids { + for _, trackID := range livekit.StringsAsTrackIDs(pt.TrackSids) { trackPublishers[trackID] = p } } @@ -580,7 +580,7 @@ func (r *Room) onDataPacket(source types.Participant, dp *livekit.DataPacket) { if len(dest) > 0 { found := false for _, dID := range dest { - if op.ID() == dID { + if op.ID() == livekit.ParticipantID(dID) { found = true break } @@ -701,7 +701,7 @@ func (r *Room) audioUpdateWorker() { activeSpeakers := r.GetActiveSpeakers() if smoothValues != nil { for _, speaker := range activeSpeakers { - sid := speaker.Sid + sid := livekit.ParticipantID(speaker.Sid) level := smoothValues[sid] delete(smoothValues, sid) // exponential moving average (EMA) @@ -715,7 +715,7 @@ func (r *Room) audioUpdateWorker() { level += -level * smoothFactor if level > activeThreshold { activeSpeakers = append(activeSpeakers, &livekit.SpeakerInfo{ - Sid: sid, + Sid: string(sid), Level: level, Active: true, }) @@ -724,7 +724,7 @@ func (r *Room) audioUpdateWorker() { // smoothValues map is drained, now repopulate it back for _, speaker := range activeSpeakers { - smoothValues[speaker.Sid] = speaker.Level + smoothValues[livekit.ParticipantID(speaker.Sid)] = speaker.Level } sort.Slice(activeSpeakers, func(i, j int) bool { @@ -740,11 +740,11 @@ func (r *Room) audioUpdateWorker() { changedSpeakers := make([]*livekit.SpeakerInfo, 0, len(activeSpeakers)) nextActiveMap := make(map[livekit.ParticipantID]*livekit.SpeakerInfo, len(activeSpeakers)) for _, speaker := range activeSpeakers { - prev := lastActiveMap[speaker.Sid] + prev := lastActiveMap[livekit.ParticipantID(speaker.Sid)] if prev == nil || prev.Level != speaker.Level { changedSpeakers = append(changedSpeakers, speaker) } - nextActiveMap[speaker.Sid] = speaker + nextActiveMap[livekit.ParticipantID(speaker.Sid)] = speaker } // changedSpeakers need to include previous speakers that are no longer speaking for sid, speaker := range lastActiveMap { @@ -818,7 +818,7 @@ func (r *Room) DebugInfo() map[string]interface{} { participants := r.GetParticipants() participantInfo := make(map[string]interface{}) for _, p := range participants { - participantInfo[p.Identity()] = p.DebugInfo() + participantInfo[string(p.Identity())] = p.DebugInfo() } info["Participants"] = participantInfo diff --git a/pkg/rtc/room_test.go b/pkg/rtc/room_test.go index 2682f7f0..4c8525b7 100644 --- a/pkg/rtc/room_test.go +++ b/pkg/rtc/room_test.go @@ -307,8 +307,8 @@ func TestActiveSpeakers(t *testing.T) { speakers := rm.GetActiveSpeakers() require.Len(t, speakers, 2) - require.Equal(t, p.ID(), speakers[0].Sid) - require.Equal(t, p2.ID(), speakers[1].Sid) + require.Equal(t, string(p.ID()), speakers[0].Sid) + require.Equal(t, string(p2.ID()), speakers[1].Sid) }) t.Run("participants are getting audio updates (protocol 2)", func(t *testing.T) { @@ -321,7 +321,7 @@ func TestActiveSpeakers(t *testing.T) { speakers := rm.GetActiveSpeakers() require.NotEmpty(t, speakers) - require.Equal(t, p.ID(), speakers[0].Sid) + require.Equal(t, string(p.ID()), speakers[0].Sid) testutils.WithTimeout(t, "ensure everyone has gotten an audio update", func() bool { for _, op := range participants { @@ -412,7 +412,7 @@ func TestDataChannel(t *testing.T) { Kind: livekit.DataPacket_RELIABLE, Value: &livekit.DataPacket_User{ User: &livekit.UserPacket{ - ParticipantSid: p.ID(), + ParticipantSid: string(p.ID()), Payload: []byte("message.."), }, }, @@ -442,9 +442,9 @@ func TestDataChannel(t *testing.T) { Kind: livekit.DataPacket_RELIABLE, Value: &livekit.DataPacket_User{ User: &livekit.UserPacket{ - ParticipantSid: p.ID(), + ParticipantSid: string(p.ID()), Payload: []byte("message to p1.."), - DestinationSids: []string{p1.ID()}, + DestinationSids: []string{string(p1.ID())}, }, }, } @@ -561,7 +561,7 @@ func newRoomWithParticipants(t *testing.T, opts testRoomOpts) *rtc.Room { telemetry.NewTelemetryService(nil, nil), ) for i := 0; i < opts.num+opts.numHidden; i++ { - identity := fmt.Sprintf("p%d", i) + identity := livekit.ParticipantIdentity(fmt.Sprintf("p%d", i)) participant := newMockParticipant(identity, opts.protocol, i >= opts.num) err := rm.Join(participant, &rtc.ParticipantOptions{AutoSubscribe: true}, iceServersForRoom) participant.StateReturns(livekit.ParticipantInfo_ACTIVE) diff --git a/pkg/rtc/signalhandler.go b/pkg/rtc/signalhandler.go index bd0aed65..9723ec98 100644 --- a/pkg/rtc/signalhandler.go +++ b/pkg/rtc/signalhandler.go @@ -35,13 +35,13 @@ func HandleParticipantSignal(room types.Room, participant types.Participant, req pLogger.Warnw("could not handle trickle", err) } case *livekit.SignalRequest_Mute: - participant.SetTrackMuted(msg.Mute.Sid, msg.Mute.Muted, false) + participant.SetTrackMuted(livekit.TrackID(msg.Mute.Sid), msg.Mute.Muted, false) case *livekit.SignalRequest_Subscription: var err error if participant.CanSubscribe() { updateErr := room.UpdateSubscriptions( participant, - msg.Subscription.TrackSids, + livekit.StringsAsTrackIDs(msg.Subscription.TrackSids), msg.Subscription.ParticipantTracks, msg.Subscription.Subscribe, ) @@ -57,7 +57,7 @@ func HandleParticipantSignal(room types.Room, participant types.Participant, req "subscribe", msg.Subscription.Subscribe) } case *livekit.SignalRequest_TrackSetting: - for _, sid := range msg.TrackSetting.TrackSids { + for _, sid := range livekit.StringsAsTrackIDs(msg.TrackSetting.TrackSids) { subTrack := participant.GetSubscribedTrack(sid) if subTrack == nil { pLogger.Warnw("unable to find SubscribedTrack", nil, @@ -71,7 +71,7 @@ func HandleParticipantSignal(room types.Room, participant types.Participant, req subTrack.UpdateSubscriberSettings(msg.TrackSetting) } case *livekit.SignalRequest_UpdateLayers: - track := participant.GetPublishedTrack(msg.UpdateLayers.TrackSid) + track := participant.GetPublishedTrack(livekit.TrackID(msg.UpdateLayers.TrackSid)) if track == nil { pLogger.Warnw("could not find published track", nil, "track", msg.UpdateLayers.TrackSid) diff --git a/pkg/rtc/subscribedtrack.go b/pkg/rtc/subscribedtrack.go index 7cf2f9d8..90a7b219 100644 --- a/pkg/rtc/subscribedtrack.go +++ b/pkg/rtc/subscribedtrack.go @@ -52,8 +52,8 @@ func (t *SubscribedTrack) Bound() { } } -func (t *SubscribedTrack) ID() string { - return t.params.DownTrack.ID() +func (t *SubscribedTrack) ID() livekit.TrackID { + return livekit.TrackID(t.params.DownTrack.ID()) } func (t *SubscribedTrack) PublisherID() livekit.ParticipantID { diff --git a/pkg/rtc/types/typesfakes/fake_media_track.go b/pkg/rtc/types/typesfakes/fake_media_track.go index e3e31403..128a750f 100644 --- a/pkg/rtc/types/typesfakes/fake_media_track.go +++ b/pkg/rtc/types/typesfakes/fake_media_track.go @@ -32,15 +32,15 @@ type FakeMediaTrack struct { getQualityForDimensionReturnsOnCall map[int]struct { result1 livekit.VideoQuality } - IDStub func() string + IDStub func() livekit.TrackID iDMutex sync.RWMutex iDArgsForCall []struct { } iDReturns struct { - result1 string + result1 livekit.TrackID } iDReturnsOnCall map[int]struct { - result1 string + result1 livekit.TrackID } IsMutedStub func() bool isMutedMutex sync.RWMutex @@ -62,10 +62,10 @@ type FakeMediaTrack struct { isSimulcastReturnsOnCall map[int]struct { result1 bool } - IsSubscriberStub func(string) bool + IsSubscriberStub func(livekit.ParticipantID) bool isSubscriberMutex sync.RWMutex isSubscriberArgsForCall []struct { - arg1 string + arg1 livekit.ParticipantID } isSubscriberReturns struct { result1 bool @@ -93,36 +93,36 @@ type FakeMediaTrack struct { nameReturnsOnCall map[int]struct { result1 string } - NotifySubscriberMaxQualityStub func(string, livekit.VideoQuality) + NotifySubscriberMaxQualityStub func(livekit.ParticipantID, livekit.VideoQuality) notifySubscriberMaxQualityMutex sync.RWMutex notifySubscriberMaxQualityArgsForCall []struct { - arg1 string + arg1 livekit.ParticipantID arg2 livekit.VideoQuality } - NotifySubscriberMuteStub func(string) + NotifySubscriberMuteStub func(livekit.ParticipantID) notifySubscriberMuteMutex sync.RWMutex notifySubscriberMuteArgsForCall []struct { - arg1 string + arg1 livekit.ParticipantID } RemoveAllSubscribersStub func() removeAllSubscribersMutex sync.RWMutex removeAllSubscribersArgsForCall []struct { } - RemoveSubscriberStub func(string) + RemoveSubscriberStub func(livekit.ParticipantID) removeSubscriberMutex sync.RWMutex removeSubscriberArgsForCall []struct { - arg1 string + arg1 livekit.ParticipantID } - RevokeDisallowedSubscribersStub func([]string) []string + RevokeDisallowedSubscribersStub func([]livekit.ParticipantID) []livekit.ParticipantID revokeDisallowedSubscribersMutex sync.RWMutex revokeDisallowedSubscribersArgsForCall []struct { - arg1 []string + arg1 []livekit.ParticipantID } revokeDisallowedSubscribersReturns struct { - result1 []string + result1 []livekit.ParticipantID } revokeDisallowedSubscribersReturnsOnCall map[int]struct { - result1 []string + result1 []livekit.ParticipantID } SetMutedStub func(bool) setMutedMutex sync.RWMutex @@ -271,7 +271,7 @@ func (fake *FakeMediaTrack) GetQualityForDimensionReturnsOnCall(i int, result1 l }{result1} } -func (fake *FakeMediaTrack) ID() string { +func (fake *FakeMediaTrack) ID() livekit.TrackID { fake.iDMutex.Lock() ret, specificReturn := fake.iDReturnsOnCall[len(fake.iDArgsForCall)] fake.iDArgsForCall = append(fake.iDArgsForCall, struct { @@ -295,32 +295,32 @@ func (fake *FakeMediaTrack) IDCallCount() int { return len(fake.iDArgsForCall) } -func (fake *FakeMediaTrack) IDCalls(stub func() string) { +func (fake *FakeMediaTrack) IDCalls(stub func() livekit.TrackID) { fake.iDMutex.Lock() defer fake.iDMutex.Unlock() fake.IDStub = stub } -func (fake *FakeMediaTrack) IDReturns(result1 string) { +func (fake *FakeMediaTrack) IDReturns(result1 livekit.TrackID) { fake.iDMutex.Lock() defer fake.iDMutex.Unlock() fake.IDStub = nil fake.iDReturns = struct { - result1 string + result1 livekit.TrackID }{result1} } -func (fake *FakeMediaTrack) IDReturnsOnCall(i int, result1 string) { +func (fake *FakeMediaTrack) IDReturnsOnCall(i int, result1 livekit.TrackID) { fake.iDMutex.Lock() defer fake.iDMutex.Unlock() fake.IDStub = nil if fake.iDReturnsOnCall == nil { fake.iDReturnsOnCall = make(map[int]struct { - result1 string + result1 livekit.TrackID }) } fake.iDReturnsOnCall[i] = struct { - result1 string + result1 livekit.TrackID }{result1} } @@ -430,11 +430,11 @@ func (fake *FakeMediaTrack) IsSimulcastReturnsOnCall(i int, result1 bool) { }{result1} } -func (fake *FakeMediaTrack) IsSubscriber(arg1 string) bool { +func (fake *FakeMediaTrack) IsSubscriber(arg1 livekit.ParticipantID) bool { fake.isSubscriberMutex.Lock() ret, specificReturn := fake.isSubscriberReturnsOnCall[len(fake.isSubscriberArgsForCall)] fake.isSubscriberArgsForCall = append(fake.isSubscriberArgsForCall, struct { - arg1 string + arg1 livekit.ParticipantID }{arg1}) stub := fake.IsSubscriberStub fakeReturns := fake.isSubscriberReturns @@ -455,13 +455,13 @@ func (fake *FakeMediaTrack) IsSubscriberCallCount() int { return len(fake.isSubscriberArgsForCall) } -func (fake *FakeMediaTrack) IsSubscriberCalls(stub func(string) bool) { +func (fake *FakeMediaTrack) IsSubscriberCalls(stub func(livekit.ParticipantID) bool) { fake.isSubscriberMutex.Lock() defer fake.isSubscriberMutex.Unlock() fake.IsSubscriberStub = stub } -func (fake *FakeMediaTrack) IsSubscriberArgsForCall(i int) string { +func (fake *FakeMediaTrack) IsSubscriberArgsForCall(i int) livekit.ParticipantID { fake.isSubscriberMutex.RLock() defer fake.isSubscriberMutex.RUnlock() argsForCall := fake.isSubscriberArgsForCall[i] @@ -597,10 +597,10 @@ func (fake *FakeMediaTrack) NameReturnsOnCall(i int, result1 string) { }{result1} } -func (fake *FakeMediaTrack) NotifySubscriberMaxQuality(arg1 string, arg2 livekit.VideoQuality) { +func (fake *FakeMediaTrack) NotifySubscriberMaxQuality(arg1 livekit.ParticipantID, arg2 livekit.VideoQuality) { fake.notifySubscriberMaxQualityMutex.Lock() fake.notifySubscriberMaxQualityArgsForCall = append(fake.notifySubscriberMaxQualityArgsForCall, struct { - arg1 string + arg1 livekit.ParticipantID arg2 livekit.VideoQuality }{arg1, arg2}) stub := fake.NotifySubscriberMaxQualityStub @@ -617,23 +617,23 @@ func (fake *FakeMediaTrack) NotifySubscriberMaxQualityCallCount() int { return len(fake.notifySubscriberMaxQualityArgsForCall) } -func (fake *FakeMediaTrack) NotifySubscriberMaxQualityCalls(stub func(string, livekit.VideoQuality)) { +func (fake *FakeMediaTrack) NotifySubscriberMaxQualityCalls(stub func(livekit.ParticipantID, livekit.VideoQuality)) { fake.notifySubscriberMaxQualityMutex.Lock() defer fake.notifySubscriberMaxQualityMutex.Unlock() fake.NotifySubscriberMaxQualityStub = stub } -func (fake *FakeMediaTrack) NotifySubscriberMaxQualityArgsForCall(i int) (string, livekit.VideoQuality) { +func (fake *FakeMediaTrack) NotifySubscriberMaxQualityArgsForCall(i int) (livekit.ParticipantID, livekit.VideoQuality) { fake.notifySubscriberMaxQualityMutex.RLock() defer fake.notifySubscriberMaxQualityMutex.RUnlock() argsForCall := fake.notifySubscriberMaxQualityArgsForCall[i] return argsForCall.arg1, argsForCall.arg2 } -func (fake *FakeMediaTrack) NotifySubscriberMute(arg1 string) { +func (fake *FakeMediaTrack) NotifySubscriberMute(arg1 livekit.ParticipantID) { fake.notifySubscriberMuteMutex.Lock() fake.notifySubscriberMuteArgsForCall = append(fake.notifySubscriberMuteArgsForCall, struct { - arg1 string + arg1 livekit.ParticipantID }{arg1}) stub := fake.NotifySubscriberMuteStub fake.recordInvocation("NotifySubscriberMute", []interface{}{arg1}) @@ -649,13 +649,13 @@ func (fake *FakeMediaTrack) NotifySubscriberMuteCallCount() int { return len(fake.notifySubscriberMuteArgsForCall) } -func (fake *FakeMediaTrack) NotifySubscriberMuteCalls(stub func(string)) { +func (fake *FakeMediaTrack) NotifySubscriberMuteCalls(stub func(livekit.ParticipantID)) { fake.notifySubscriberMuteMutex.Lock() defer fake.notifySubscriberMuteMutex.Unlock() fake.NotifySubscriberMuteStub = stub } -func (fake *FakeMediaTrack) NotifySubscriberMuteArgsForCall(i int) string { +func (fake *FakeMediaTrack) NotifySubscriberMuteArgsForCall(i int) livekit.ParticipantID { fake.notifySubscriberMuteMutex.RLock() defer fake.notifySubscriberMuteMutex.RUnlock() argsForCall := fake.notifySubscriberMuteArgsForCall[i] @@ -686,10 +686,10 @@ func (fake *FakeMediaTrack) RemoveAllSubscribersCalls(stub func()) { fake.RemoveAllSubscribersStub = stub } -func (fake *FakeMediaTrack) RemoveSubscriber(arg1 string) { +func (fake *FakeMediaTrack) RemoveSubscriber(arg1 livekit.ParticipantID) { fake.removeSubscriberMutex.Lock() fake.removeSubscriberArgsForCall = append(fake.removeSubscriberArgsForCall, struct { - arg1 string + arg1 livekit.ParticipantID }{arg1}) stub := fake.RemoveSubscriberStub fake.recordInvocation("RemoveSubscriber", []interface{}{arg1}) @@ -705,29 +705,29 @@ func (fake *FakeMediaTrack) RemoveSubscriberCallCount() int { return len(fake.removeSubscriberArgsForCall) } -func (fake *FakeMediaTrack) RemoveSubscriberCalls(stub func(string)) { +func (fake *FakeMediaTrack) RemoveSubscriberCalls(stub func(livekit.ParticipantID)) { fake.removeSubscriberMutex.Lock() defer fake.removeSubscriberMutex.Unlock() fake.RemoveSubscriberStub = stub } -func (fake *FakeMediaTrack) RemoveSubscriberArgsForCall(i int) string { +func (fake *FakeMediaTrack) RemoveSubscriberArgsForCall(i int) livekit.ParticipantID { fake.removeSubscriberMutex.RLock() defer fake.removeSubscriberMutex.RUnlock() argsForCall := fake.removeSubscriberArgsForCall[i] return argsForCall.arg1 } -func (fake *FakeMediaTrack) RevokeDisallowedSubscribers(arg1 []string) []string { - var arg1Copy []string +func (fake *FakeMediaTrack) RevokeDisallowedSubscribers(arg1 []livekit.ParticipantID) []livekit.ParticipantID { + var arg1Copy []livekit.ParticipantID if arg1 != nil { - arg1Copy = make([]string, len(arg1)) + arg1Copy = make([]livekit.ParticipantID, len(arg1)) copy(arg1Copy, arg1) } fake.revokeDisallowedSubscribersMutex.Lock() ret, specificReturn := fake.revokeDisallowedSubscribersReturnsOnCall[len(fake.revokeDisallowedSubscribersArgsForCall)] fake.revokeDisallowedSubscribersArgsForCall = append(fake.revokeDisallowedSubscribersArgsForCall, struct { - arg1 []string + arg1 []livekit.ParticipantID }{arg1Copy}) stub := fake.RevokeDisallowedSubscribersStub fakeReturns := fake.revokeDisallowedSubscribersReturns @@ -748,39 +748,39 @@ func (fake *FakeMediaTrack) RevokeDisallowedSubscribersCallCount() int { return len(fake.revokeDisallowedSubscribersArgsForCall) } -func (fake *FakeMediaTrack) RevokeDisallowedSubscribersCalls(stub func([]string) []string) { +func (fake *FakeMediaTrack) RevokeDisallowedSubscribersCalls(stub func([]livekit.ParticipantID) []livekit.ParticipantID) { fake.revokeDisallowedSubscribersMutex.Lock() defer fake.revokeDisallowedSubscribersMutex.Unlock() fake.RevokeDisallowedSubscribersStub = stub } -func (fake *FakeMediaTrack) RevokeDisallowedSubscribersArgsForCall(i int) []string { +func (fake *FakeMediaTrack) RevokeDisallowedSubscribersArgsForCall(i int) []livekit.ParticipantID { fake.revokeDisallowedSubscribersMutex.RLock() defer fake.revokeDisallowedSubscribersMutex.RUnlock() argsForCall := fake.revokeDisallowedSubscribersArgsForCall[i] return argsForCall.arg1 } -func (fake *FakeMediaTrack) RevokeDisallowedSubscribersReturns(result1 []string) { +func (fake *FakeMediaTrack) RevokeDisallowedSubscribersReturns(result1 []livekit.ParticipantID) { fake.revokeDisallowedSubscribersMutex.Lock() defer fake.revokeDisallowedSubscribersMutex.Unlock() fake.RevokeDisallowedSubscribersStub = nil fake.revokeDisallowedSubscribersReturns = struct { - result1 []string + result1 []livekit.ParticipantID }{result1} } -func (fake *FakeMediaTrack) RevokeDisallowedSubscribersReturnsOnCall(i int, result1 []string) { +func (fake *FakeMediaTrack) RevokeDisallowedSubscribersReturnsOnCall(i int, result1 []livekit.ParticipantID) { fake.revokeDisallowedSubscribersMutex.Lock() defer fake.revokeDisallowedSubscribersMutex.Unlock() fake.RevokeDisallowedSubscribersStub = nil if fake.revokeDisallowedSubscribersReturnsOnCall == nil { fake.revokeDisallowedSubscribersReturnsOnCall = make(map[int]struct { - result1 []string + result1 []livekit.ParticipantID }) } fake.revokeDisallowedSubscribersReturnsOnCall[i] = struct { - result1 []string + result1 []livekit.ParticipantID }{result1} } diff --git a/pkg/rtc/types/typesfakes/fake_participant.go b/pkg/rtc/types/typesfakes/fake_participant.go index d8a01660..2ff751ac 100644 --- a/pkg/rtc/types/typesfakes/fake_participant.go +++ b/pkg/rtc/types/typesfakes/fake_participant.go @@ -130,10 +130,10 @@ type FakeParticipant struct { getConnectionQualityReturnsOnCall map[int]struct { result1 *livekit.ConnectionQualityInfo } - GetPublishedTrackStub func(string) types.PublishedTrack + GetPublishedTrackStub func(livekit.TrackID) types.PublishedTrack getPublishedTrackMutex sync.RWMutex getPublishedTrackArgsForCall []struct { - arg1 string + arg1 livekit.TrackID } getPublishedTrackReturns struct { result1 types.PublishedTrack @@ -161,20 +161,20 @@ type FakeParticipant struct { getResponseSinkReturnsOnCall map[int]struct { result1 routing.MessageSink } - GetSubscribedParticipantsStub func() []string + GetSubscribedParticipantsStub func() []livekit.ParticipantID getSubscribedParticipantsMutex sync.RWMutex getSubscribedParticipantsArgsForCall []struct { } getSubscribedParticipantsReturns struct { - result1 []string + result1 []livekit.ParticipantID } getSubscribedParticipantsReturnsOnCall map[int]struct { - result1 []string + result1 []livekit.ParticipantID } - GetSubscribedTrackStub func(string) types.SubscribedTrack + GetSubscribedTrackStub func(livekit.TrackID) types.SubscribedTrack getSubscribedTrackMutex sync.RWMutex getSubscribedTrackArgsForCall []struct { - arg1 string + arg1 livekit.TrackID } getSubscribedTrackReturns struct { result1 types.SubscribedTrack @@ -236,25 +236,25 @@ type FakeParticipant struct { iCERestartReturnsOnCall map[int]struct { result1 error } - IDStub func() string + IDStub func() livekit.ParticipantID iDMutex sync.RWMutex iDArgsForCall []struct { } iDReturns struct { - result1 string + result1 livekit.ParticipantID } iDReturnsOnCall map[int]struct { - result1 string + result1 livekit.ParticipantID } - IdentityStub func() string + IdentityStub func() livekit.ParticipantIdentity identityMutex sync.RWMutex identityArgsForCall []struct { } identityReturns struct { - result1 string + result1 livekit.ParticipantIdentity } identityReturnsOnCall map[int]struct { - result1 string + result1 livekit.ParticipantIdentity } IsReadyStub func() bool isReadyMutex sync.RWMutex @@ -276,10 +276,10 @@ type FakeParticipant struct { isRecorderReturnsOnCall map[int]struct { result1 bool } - IsSubscribedToStub func(string) bool + IsSubscribedToStub func(livekit.ParticipantID) bool isSubscribedToMutex sync.RWMutex isSubscribedToArgsForCall []struct { - arg1 string + arg1 livekit.ParticipantID } isSubscribedToReturns struct { result1 bool @@ -291,10 +291,10 @@ type FakeParticipant struct { negotiateMutex sync.RWMutex negotiateArgsForCall []struct { } - OnCloseStub func(func(types.Participant, map[string]string)) + OnCloseStub func(func(types.Participant, map[livekit.TrackID]livekit.ParticipantID)) onCloseMutex sync.RWMutex onCloseArgsForCall []struct { - arg1 func(types.Participant, map[string]string) + arg1 func(types.Participant, map[livekit.TrackID]livekit.ParticipantID) } OnDataPacketStub func(func(types.Participant, *livekit.DataPacket)) onDataPacketMutex sync.RWMutex @@ -336,11 +336,11 @@ type FakeParticipant struct { removeSubscribedTrackArgsForCall []struct { arg1 types.SubscribedTrack } - RemoveSubscriberStub func(types.Participant, string) + RemoveSubscriberStub func(types.Participant, livekit.TrackID) removeSubscriberMutex sync.RWMutex removeSubscriberArgsForCall []struct { arg1 types.Participant - arg2 string + arg2 livekit.TrackID } SendConnectionQualityUpdateStub func(*livekit.ConnectionQualityUpdate) error sendConnectionQualityUpdateMutex sync.RWMutex @@ -426,10 +426,10 @@ type FakeParticipant struct { setResponseSinkArgsForCall []struct { arg1 routing.MessageSink } - SetTrackMutedStub func(string, bool, bool) + SetTrackMutedStub func(livekit.TrackID, bool, bool) setTrackMutedMutex sync.RWMutex setTrackMutedArgsForCall []struct { - arg1 string + arg1 livekit.TrackID arg2 bool arg3 bool } @@ -477,11 +477,11 @@ type FakeParticipant struct { subscriberPCReturnsOnCall map[int]struct { result1 *webrtc.PeerConnection } - SubscriptionPermissionUpdateStub func(string, string, bool) + SubscriptionPermissionUpdateStub func(livekit.ParticipantID, livekit.TrackID, bool) subscriptionPermissionUpdateMutex sync.RWMutex subscriptionPermissionUpdateArgsForCall []struct { - arg1 string - arg2 string + arg1 livekit.ParticipantID + arg2 livekit.TrackID arg3 bool } ToProtoStub func() *livekit.ParticipantInfo @@ -494,11 +494,11 @@ type FakeParticipant struct { toProtoReturnsOnCall map[int]struct { result1 *livekit.ParticipantInfo } - UpdateSubscriptionPermissionsStub func(*livekit.UpdateSubscriptionPermissions, func(participantID string) types.Participant) error + UpdateSubscriptionPermissionsStub func(*livekit.UpdateSubscriptionPermissions, func(participantID livekit.ParticipantID) types.Participant) error updateSubscriptionPermissionsMutex sync.RWMutex updateSubscriptionPermissionsArgsForCall []struct { arg1 *livekit.UpdateSubscriptionPermissions - arg2 func(participantID string) types.Participant + arg2 func(participantID livekit.ParticipantID) types.Participant } updateSubscriptionPermissionsReturns struct { result1 error @@ -1128,11 +1128,11 @@ func (fake *FakeParticipant) GetConnectionQualityReturnsOnCall(i int, result1 *l }{result1} } -func (fake *FakeParticipant) GetPublishedTrack(arg1 string) types.PublishedTrack { +func (fake *FakeParticipant) GetPublishedTrack(arg1 livekit.TrackID) types.PublishedTrack { fake.getPublishedTrackMutex.Lock() ret, specificReturn := fake.getPublishedTrackReturnsOnCall[len(fake.getPublishedTrackArgsForCall)] fake.getPublishedTrackArgsForCall = append(fake.getPublishedTrackArgsForCall, struct { - arg1 string + arg1 livekit.TrackID }{arg1}) stub := fake.GetPublishedTrackStub fakeReturns := fake.getPublishedTrackReturns @@ -1153,13 +1153,13 @@ func (fake *FakeParticipant) GetPublishedTrackCallCount() int { return len(fake.getPublishedTrackArgsForCall) } -func (fake *FakeParticipant) GetPublishedTrackCalls(stub func(string) types.PublishedTrack) { +func (fake *FakeParticipant) GetPublishedTrackCalls(stub func(livekit.TrackID) types.PublishedTrack) { fake.getPublishedTrackMutex.Lock() defer fake.getPublishedTrackMutex.Unlock() fake.GetPublishedTrackStub = stub } -func (fake *FakeParticipant) GetPublishedTrackArgsForCall(i int) string { +func (fake *FakeParticipant) GetPublishedTrackArgsForCall(i int) livekit.TrackID { fake.getPublishedTrackMutex.RLock() defer fake.getPublishedTrackMutex.RUnlock() argsForCall := fake.getPublishedTrackArgsForCall[i] @@ -1295,7 +1295,7 @@ func (fake *FakeParticipant) GetResponseSinkReturnsOnCall(i int, result1 routing }{result1} } -func (fake *FakeParticipant) GetSubscribedParticipants() []string { +func (fake *FakeParticipant) GetSubscribedParticipants() []livekit.ParticipantID { fake.getSubscribedParticipantsMutex.Lock() ret, specificReturn := fake.getSubscribedParticipantsReturnsOnCall[len(fake.getSubscribedParticipantsArgsForCall)] fake.getSubscribedParticipantsArgsForCall = append(fake.getSubscribedParticipantsArgsForCall, struct { @@ -1319,40 +1319,40 @@ func (fake *FakeParticipant) GetSubscribedParticipantsCallCount() int { return len(fake.getSubscribedParticipantsArgsForCall) } -func (fake *FakeParticipant) GetSubscribedParticipantsCalls(stub func() []string) { +func (fake *FakeParticipant) GetSubscribedParticipantsCalls(stub func() []livekit.ParticipantID) { fake.getSubscribedParticipantsMutex.Lock() defer fake.getSubscribedParticipantsMutex.Unlock() fake.GetSubscribedParticipantsStub = stub } -func (fake *FakeParticipant) GetSubscribedParticipantsReturns(result1 []string) { +func (fake *FakeParticipant) GetSubscribedParticipantsReturns(result1 []livekit.ParticipantID) { fake.getSubscribedParticipantsMutex.Lock() defer fake.getSubscribedParticipantsMutex.Unlock() fake.GetSubscribedParticipantsStub = nil fake.getSubscribedParticipantsReturns = struct { - result1 []string + result1 []livekit.ParticipantID }{result1} } -func (fake *FakeParticipant) GetSubscribedParticipantsReturnsOnCall(i int, result1 []string) { +func (fake *FakeParticipant) GetSubscribedParticipantsReturnsOnCall(i int, result1 []livekit.ParticipantID) { fake.getSubscribedParticipantsMutex.Lock() defer fake.getSubscribedParticipantsMutex.Unlock() fake.GetSubscribedParticipantsStub = nil if fake.getSubscribedParticipantsReturnsOnCall == nil { fake.getSubscribedParticipantsReturnsOnCall = make(map[int]struct { - result1 []string + result1 []livekit.ParticipantID }) } fake.getSubscribedParticipantsReturnsOnCall[i] = struct { - result1 []string + result1 []livekit.ParticipantID }{result1} } -func (fake *FakeParticipant) GetSubscribedTrack(arg1 string) types.SubscribedTrack { +func (fake *FakeParticipant) GetSubscribedTrack(arg1 livekit.TrackID) types.SubscribedTrack { fake.getSubscribedTrackMutex.Lock() ret, specificReturn := fake.getSubscribedTrackReturnsOnCall[len(fake.getSubscribedTrackArgsForCall)] fake.getSubscribedTrackArgsForCall = append(fake.getSubscribedTrackArgsForCall, struct { - arg1 string + arg1 livekit.TrackID }{arg1}) stub := fake.GetSubscribedTrackStub fakeReturns := fake.getSubscribedTrackReturns @@ -1373,13 +1373,13 @@ func (fake *FakeParticipant) GetSubscribedTrackCallCount() int { return len(fake.getSubscribedTrackArgsForCall) } -func (fake *FakeParticipant) GetSubscribedTrackCalls(stub func(string) types.SubscribedTrack) { +func (fake *FakeParticipant) GetSubscribedTrackCalls(stub func(livekit.TrackID) types.SubscribedTrack) { fake.getSubscribedTrackMutex.Lock() defer fake.getSubscribedTrackMutex.Unlock() fake.GetSubscribedTrackStub = stub } -func (fake *FakeParticipant) GetSubscribedTrackArgsForCall(i int) string { +func (fake *FakeParticipant) GetSubscribedTrackArgsForCall(i int) livekit.TrackID { fake.getSubscribedTrackMutex.RLock() defer fake.getSubscribedTrackMutex.RUnlock() argsForCall := fake.getSubscribedTrackArgsForCall[i] @@ -1693,7 +1693,7 @@ func (fake *FakeParticipant) ICERestartReturnsOnCall(i int, result1 error) { }{result1} } -func (fake *FakeParticipant) ID() string { +func (fake *FakeParticipant) ID() livekit.ParticipantID { fake.iDMutex.Lock() ret, specificReturn := fake.iDReturnsOnCall[len(fake.iDArgsForCall)] fake.iDArgsForCall = append(fake.iDArgsForCall, struct { @@ -1717,36 +1717,36 @@ func (fake *FakeParticipant) IDCallCount() int { return len(fake.iDArgsForCall) } -func (fake *FakeParticipant) IDCalls(stub func() string) { +func (fake *FakeParticipant) IDCalls(stub func() livekit.ParticipantID) { fake.iDMutex.Lock() defer fake.iDMutex.Unlock() fake.IDStub = stub } -func (fake *FakeParticipant) IDReturns(result1 string) { +func (fake *FakeParticipant) IDReturns(result1 livekit.ParticipantID) { fake.iDMutex.Lock() defer fake.iDMutex.Unlock() fake.IDStub = nil fake.iDReturns = struct { - result1 string + result1 livekit.ParticipantID }{result1} } -func (fake *FakeParticipant) IDReturnsOnCall(i int, result1 string) { +func (fake *FakeParticipant) IDReturnsOnCall(i int, result1 livekit.ParticipantID) { fake.iDMutex.Lock() defer fake.iDMutex.Unlock() fake.IDStub = nil if fake.iDReturnsOnCall == nil { fake.iDReturnsOnCall = make(map[int]struct { - result1 string + result1 livekit.ParticipantID }) } fake.iDReturnsOnCall[i] = struct { - result1 string + result1 livekit.ParticipantID }{result1} } -func (fake *FakeParticipant) Identity() string { +func (fake *FakeParticipant) Identity() livekit.ParticipantIdentity { fake.identityMutex.Lock() ret, specificReturn := fake.identityReturnsOnCall[len(fake.identityArgsForCall)] fake.identityArgsForCall = append(fake.identityArgsForCall, struct { @@ -1770,32 +1770,32 @@ func (fake *FakeParticipant) IdentityCallCount() int { return len(fake.identityArgsForCall) } -func (fake *FakeParticipant) IdentityCalls(stub func() string) { +func (fake *FakeParticipant) IdentityCalls(stub func() livekit.ParticipantIdentity) { fake.identityMutex.Lock() defer fake.identityMutex.Unlock() fake.IdentityStub = stub } -func (fake *FakeParticipant) IdentityReturns(result1 string) { +func (fake *FakeParticipant) IdentityReturns(result1 livekit.ParticipantIdentity) { fake.identityMutex.Lock() defer fake.identityMutex.Unlock() fake.IdentityStub = nil fake.identityReturns = struct { - result1 string + result1 livekit.ParticipantIdentity }{result1} } -func (fake *FakeParticipant) IdentityReturnsOnCall(i int, result1 string) { +func (fake *FakeParticipant) IdentityReturnsOnCall(i int, result1 livekit.ParticipantIdentity) { fake.identityMutex.Lock() defer fake.identityMutex.Unlock() fake.IdentityStub = nil if fake.identityReturnsOnCall == nil { fake.identityReturnsOnCall = make(map[int]struct { - result1 string + result1 livekit.ParticipantIdentity }) } fake.identityReturnsOnCall[i] = struct { - result1 string + result1 livekit.ParticipantIdentity }{result1} } @@ -1905,11 +1905,11 @@ func (fake *FakeParticipant) IsRecorderReturnsOnCall(i int, result1 bool) { }{result1} } -func (fake *FakeParticipant) IsSubscribedTo(arg1 string) bool { +func (fake *FakeParticipant) IsSubscribedTo(arg1 livekit.ParticipantID) bool { fake.isSubscribedToMutex.Lock() ret, specificReturn := fake.isSubscribedToReturnsOnCall[len(fake.isSubscribedToArgsForCall)] fake.isSubscribedToArgsForCall = append(fake.isSubscribedToArgsForCall, struct { - arg1 string + arg1 livekit.ParticipantID }{arg1}) stub := fake.IsSubscribedToStub fakeReturns := fake.isSubscribedToReturns @@ -1930,13 +1930,13 @@ func (fake *FakeParticipant) IsSubscribedToCallCount() int { return len(fake.isSubscribedToArgsForCall) } -func (fake *FakeParticipant) IsSubscribedToCalls(stub func(string) bool) { +func (fake *FakeParticipant) IsSubscribedToCalls(stub func(livekit.ParticipantID) bool) { fake.isSubscribedToMutex.Lock() defer fake.isSubscribedToMutex.Unlock() fake.IsSubscribedToStub = stub } -func (fake *FakeParticipant) IsSubscribedToArgsForCall(i int) string { +func (fake *FakeParticipant) IsSubscribedToArgsForCall(i int) livekit.ParticipantID { fake.isSubscribedToMutex.RLock() defer fake.isSubscribedToMutex.RUnlock() argsForCall := fake.isSubscribedToArgsForCall[i] @@ -1990,10 +1990,10 @@ func (fake *FakeParticipant) NegotiateCalls(stub func()) { fake.NegotiateStub = stub } -func (fake *FakeParticipant) OnClose(arg1 func(types.Participant, map[string]string)) { +func (fake *FakeParticipant) OnClose(arg1 func(types.Participant, map[livekit.TrackID]livekit.ParticipantID)) { fake.onCloseMutex.Lock() fake.onCloseArgsForCall = append(fake.onCloseArgsForCall, struct { - arg1 func(types.Participant, map[string]string) + arg1 func(types.Participant, map[livekit.TrackID]livekit.ParticipantID) }{arg1}) stub := fake.OnCloseStub fake.recordInvocation("OnClose", []interface{}{arg1}) @@ -2009,13 +2009,13 @@ func (fake *FakeParticipant) OnCloseCallCount() int { return len(fake.onCloseArgsForCall) } -func (fake *FakeParticipant) OnCloseCalls(stub func(func(types.Participant, map[string]string))) { +func (fake *FakeParticipant) OnCloseCalls(stub func(func(types.Participant, map[livekit.TrackID]livekit.ParticipantID))) { fake.onCloseMutex.Lock() defer fake.onCloseMutex.Unlock() fake.OnCloseStub = stub } -func (fake *FakeParticipant) OnCloseArgsForCall(i int) func(types.Participant, map[string]string) { +func (fake *FakeParticipant) OnCloseArgsForCall(i int) func(types.Participant, map[livekit.TrackID]livekit.ParticipantID) { fake.onCloseMutex.RLock() defer fake.onCloseMutex.RUnlock() argsForCall := fake.onCloseArgsForCall[i] @@ -2267,11 +2267,11 @@ func (fake *FakeParticipant) RemoveSubscribedTrackArgsForCall(i int) types.Subsc return argsForCall.arg1 } -func (fake *FakeParticipant) RemoveSubscriber(arg1 types.Participant, arg2 string) { +func (fake *FakeParticipant) RemoveSubscriber(arg1 types.Participant, arg2 livekit.TrackID) { fake.removeSubscriberMutex.Lock() fake.removeSubscriberArgsForCall = append(fake.removeSubscriberArgsForCall, struct { arg1 types.Participant - arg2 string + arg2 livekit.TrackID }{arg1, arg2}) stub := fake.RemoveSubscriberStub fake.recordInvocation("RemoveSubscriber", []interface{}{arg1, arg2}) @@ -2287,13 +2287,13 @@ func (fake *FakeParticipant) RemoveSubscriberCallCount() int { return len(fake.removeSubscriberArgsForCall) } -func (fake *FakeParticipant) RemoveSubscriberCalls(stub func(types.Participant, string)) { +func (fake *FakeParticipant) RemoveSubscriberCalls(stub func(types.Participant, livekit.TrackID)) { fake.removeSubscriberMutex.Lock() defer fake.removeSubscriberMutex.Unlock() fake.RemoveSubscriberStub = stub } -func (fake *FakeParticipant) RemoveSubscriberArgsForCall(i int) (types.Participant, string) { +func (fake *FakeParticipant) RemoveSubscriberArgsForCall(i int) (types.Participant, livekit.TrackID) { fake.removeSubscriberMutex.RLock() defer fake.removeSubscriberMutex.RUnlock() argsForCall := fake.removeSubscriberArgsForCall[i] @@ -2785,10 +2785,10 @@ func (fake *FakeParticipant) SetResponseSinkArgsForCall(i int) routing.MessageSi return argsForCall.arg1 } -func (fake *FakeParticipant) SetTrackMuted(arg1 string, arg2 bool, arg3 bool) { +func (fake *FakeParticipant) SetTrackMuted(arg1 livekit.TrackID, arg2 bool, arg3 bool) { fake.setTrackMutedMutex.Lock() fake.setTrackMutedArgsForCall = append(fake.setTrackMutedArgsForCall, struct { - arg1 string + arg1 livekit.TrackID arg2 bool arg3 bool }{arg1, arg2, arg3}) @@ -2806,13 +2806,13 @@ func (fake *FakeParticipant) SetTrackMutedCallCount() int { return len(fake.setTrackMutedArgsForCall) } -func (fake *FakeParticipant) SetTrackMutedCalls(stub func(string, bool, bool)) { +func (fake *FakeParticipant) SetTrackMutedCalls(stub func(livekit.TrackID, bool, bool)) { fake.setTrackMutedMutex.Lock() defer fake.setTrackMutedMutex.Unlock() fake.SetTrackMutedStub = stub } -func (fake *FakeParticipant) SetTrackMutedArgsForCall(i int) (string, bool, bool) { +func (fake *FakeParticipant) SetTrackMutedArgsForCall(i int) (livekit.TrackID, bool, bool) { fake.setTrackMutedMutex.RLock() defer fake.setTrackMutedMutex.RUnlock() argsForCall := fake.setTrackMutedArgsForCall[i] @@ -3055,11 +3055,11 @@ func (fake *FakeParticipant) SubscriberPCReturnsOnCall(i int, result1 *webrtc.Pe }{result1} } -func (fake *FakeParticipant) SubscriptionPermissionUpdate(arg1 string, arg2 string, arg3 bool) { +func (fake *FakeParticipant) SubscriptionPermissionUpdate(arg1 livekit.ParticipantID, arg2 livekit.TrackID, arg3 bool) { fake.subscriptionPermissionUpdateMutex.Lock() fake.subscriptionPermissionUpdateArgsForCall = append(fake.subscriptionPermissionUpdateArgsForCall, struct { - arg1 string - arg2 string + arg1 livekit.ParticipantID + arg2 livekit.TrackID arg3 bool }{arg1, arg2, arg3}) stub := fake.SubscriptionPermissionUpdateStub @@ -3076,13 +3076,13 @@ func (fake *FakeParticipant) SubscriptionPermissionUpdateCallCount() int { return len(fake.subscriptionPermissionUpdateArgsForCall) } -func (fake *FakeParticipant) SubscriptionPermissionUpdateCalls(stub func(string, string, bool)) { +func (fake *FakeParticipant) SubscriptionPermissionUpdateCalls(stub func(livekit.ParticipantID, livekit.TrackID, bool)) { fake.subscriptionPermissionUpdateMutex.Lock() defer fake.subscriptionPermissionUpdateMutex.Unlock() fake.SubscriptionPermissionUpdateStub = stub } -func (fake *FakeParticipant) SubscriptionPermissionUpdateArgsForCall(i int) (string, string, bool) { +func (fake *FakeParticipant) SubscriptionPermissionUpdateArgsForCall(i int) (livekit.ParticipantID, livekit.TrackID, bool) { fake.subscriptionPermissionUpdateMutex.RLock() defer fake.subscriptionPermissionUpdateMutex.RUnlock() argsForCall := fake.subscriptionPermissionUpdateArgsForCall[i] @@ -3142,12 +3142,12 @@ func (fake *FakeParticipant) ToProtoReturnsOnCall(i int, result1 *livekit.Partic }{result1} } -func (fake *FakeParticipant) UpdateSubscriptionPermissions(arg1 *livekit.UpdateSubscriptionPermissions, arg2 func(participantID string) types.Participant) error { +func (fake *FakeParticipant) UpdateSubscriptionPermissions(arg1 *livekit.UpdateSubscriptionPermissions, arg2 func(participantID livekit.ParticipantID) types.Participant) error { fake.updateSubscriptionPermissionsMutex.Lock() ret, specificReturn := fake.updateSubscriptionPermissionsReturnsOnCall[len(fake.updateSubscriptionPermissionsArgsForCall)] fake.updateSubscriptionPermissionsArgsForCall = append(fake.updateSubscriptionPermissionsArgsForCall, struct { arg1 *livekit.UpdateSubscriptionPermissions - arg2 func(participantID string) types.Participant + arg2 func(participantID livekit.ParticipantID) types.Participant }{arg1, arg2}) stub := fake.UpdateSubscriptionPermissionsStub fakeReturns := fake.updateSubscriptionPermissionsReturns @@ -3168,13 +3168,13 @@ func (fake *FakeParticipant) UpdateSubscriptionPermissionsCallCount() int { return len(fake.updateSubscriptionPermissionsArgsForCall) } -func (fake *FakeParticipant) UpdateSubscriptionPermissionsCalls(stub func(*livekit.UpdateSubscriptionPermissions, func(participantID string) types.Participant) error) { +func (fake *FakeParticipant) UpdateSubscriptionPermissionsCalls(stub func(*livekit.UpdateSubscriptionPermissions, func(participantID livekit.ParticipantID) types.Participant) error) { fake.updateSubscriptionPermissionsMutex.Lock() defer fake.updateSubscriptionPermissionsMutex.Unlock() fake.UpdateSubscriptionPermissionsStub = stub } -func (fake *FakeParticipant) UpdateSubscriptionPermissionsArgsForCall(i int) (*livekit.UpdateSubscriptionPermissions, func(participantID string) types.Participant) { +func (fake *FakeParticipant) UpdateSubscriptionPermissionsArgsForCall(i int) (*livekit.UpdateSubscriptionPermissions, func(participantID livekit.ParticipantID) types.Participant) { fake.updateSubscriptionPermissionsMutex.RLock() defer fake.updateSubscriptionPermissionsMutex.RUnlock() argsForCall := fake.updateSubscriptionPermissionsArgsForCall[i] diff --git a/pkg/rtc/types/typesfakes/fake_published_track.go b/pkg/rtc/types/typesfakes/fake_published_track.go index 63f5cf1f..1cd1ab58 100644 --- a/pkg/rtc/types/typesfakes/fake_published_track.go +++ b/pkg/rtc/types/typesfakes/fake_published_track.go @@ -48,15 +48,15 @@ type FakePublishedTrack struct { getQualityForDimensionReturnsOnCall map[int]struct { result1 livekit.VideoQuality } - IDStub func() string + IDStub func() livekit.TrackID iDMutex sync.RWMutex iDArgsForCall []struct { } iDReturns struct { - result1 string + result1 livekit.TrackID } iDReturnsOnCall map[int]struct { - result1 string + result1 livekit.TrackID } IsMutedStub func() bool isMutedMutex sync.RWMutex @@ -78,10 +78,10 @@ type FakePublishedTrack struct { isSimulcastReturnsOnCall map[int]struct { result1 bool } - IsSubscriberStub func(string) bool + IsSubscriberStub func(livekit.ParticipantID) bool isSubscriberMutex sync.RWMutex isSubscriberArgsForCall []struct { - arg1 string + arg1 livekit.ParticipantID } isSubscriberReturns struct { result1 bool @@ -109,16 +109,16 @@ type FakePublishedTrack struct { nameReturnsOnCall map[int]struct { result1 string } - NotifySubscriberMaxQualityStub func(string, livekit.VideoQuality) + NotifySubscriberMaxQualityStub func(livekit.ParticipantID, livekit.VideoQuality) notifySubscriberMaxQualityMutex sync.RWMutex notifySubscriberMaxQualityArgsForCall []struct { - arg1 string + arg1 livekit.ParticipantID arg2 livekit.VideoQuality } - NotifySubscriberMuteStub func(string) + NotifySubscriberMuteStub func(livekit.ParticipantID) notifySubscriberMuteMutex sync.RWMutex notifySubscriberMuteArgsForCall []struct { - arg1 string + arg1 livekit.ParticipantID } NumUpTracksStub func() (uint32, uint32) numUpTracksMutex sync.RWMutex @@ -156,21 +156,21 @@ type FakePublishedTrack struct { removeAllSubscribersMutex sync.RWMutex removeAllSubscribersArgsForCall []struct { } - RemoveSubscriberStub func(string) + RemoveSubscriberStub func(livekit.ParticipantID) removeSubscriberMutex sync.RWMutex removeSubscriberArgsForCall []struct { - arg1 string + arg1 livekit.ParticipantID } - RevokeDisallowedSubscribersStub func([]string) []string + RevokeDisallowedSubscribersStub func([]livekit.ParticipantID) []livekit.ParticipantID revokeDisallowedSubscribersMutex sync.RWMutex revokeDisallowedSubscribersArgsForCall []struct { - arg1 []string + arg1 []livekit.ParticipantID } revokeDisallowedSubscribersReturns struct { - result1 []string + result1 []livekit.ParticipantID } revokeDisallowedSubscribersReturnsOnCall map[int]struct { - result1 []string + result1 []livekit.ParticipantID } SdpCidStub func() string sdpCidMutex sync.RWMutex @@ -434,7 +434,7 @@ func (fake *FakePublishedTrack) GetQualityForDimensionReturnsOnCall(i int, resul }{result1} } -func (fake *FakePublishedTrack) ID() string { +func (fake *FakePublishedTrack) ID() livekit.TrackID { fake.iDMutex.Lock() ret, specificReturn := fake.iDReturnsOnCall[len(fake.iDArgsForCall)] fake.iDArgsForCall = append(fake.iDArgsForCall, struct { @@ -458,32 +458,32 @@ func (fake *FakePublishedTrack) IDCallCount() int { return len(fake.iDArgsForCall) } -func (fake *FakePublishedTrack) IDCalls(stub func() string) { +func (fake *FakePublishedTrack) IDCalls(stub func() livekit.TrackID) { fake.iDMutex.Lock() defer fake.iDMutex.Unlock() fake.IDStub = stub } -func (fake *FakePublishedTrack) IDReturns(result1 string) { +func (fake *FakePublishedTrack) IDReturns(result1 livekit.TrackID) { fake.iDMutex.Lock() defer fake.iDMutex.Unlock() fake.IDStub = nil fake.iDReturns = struct { - result1 string + result1 livekit.TrackID }{result1} } -func (fake *FakePublishedTrack) IDReturnsOnCall(i int, result1 string) { +func (fake *FakePublishedTrack) IDReturnsOnCall(i int, result1 livekit.TrackID) { fake.iDMutex.Lock() defer fake.iDMutex.Unlock() fake.IDStub = nil if fake.iDReturnsOnCall == nil { fake.iDReturnsOnCall = make(map[int]struct { - result1 string + result1 livekit.TrackID }) } fake.iDReturnsOnCall[i] = struct { - result1 string + result1 livekit.TrackID }{result1} } @@ -593,11 +593,11 @@ func (fake *FakePublishedTrack) IsSimulcastReturnsOnCall(i int, result1 bool) { }{result1} } -func (fake *FakePublishedTrack) IsSubscriber(arg1 string) bool { +func (fake *FakePublishedTrack) IsSubscriber(arg1 livekit.ParticipantID) bool { fake.isSubscriberMutex.Lock() ret, specificReturn := fake.isSubscriberReturnsOnCall[len(fake.isSubscriberArgsForCall)] fake.isSubscriberArgsForCall = append(fake.isSubscriberArgsForCall, struct { - arg1 string + arg1 livekit.ParticipantID }{arg1}) stub := fake.IsSubscriberStub fakeReturns := fake.isSubscriberReturns @@ -618,13 +618,13 @@ func (fake *FakePublishedTrack) IsSubscriberCallCount() int { return len(fake.isSubscriberArgsForCall) } -func (fake *FakePublishedTrack) IsSubscriberCalls(stub func(string) bool) { +func (fake *FakePublishedTrack) IsSubscriberCalls(stub func(livekit.ParticipantID) bool) { fake.isSubscriberMutex.Lock() defer fake.isSubscriberMutex.Unlock() fake.IsSubscriberStub = stub } -func (fake *FakePublishedTrack) IsSubscriberArgsForCall(i int) string { +func (fake *FakePublishedTrack) IsSubscriberArgsForCall(i int) livekit.ParticipantID { fake.isSubscriberMutex.RLock() defer fake.isSubscriberMutex.RUnlock() argsForCall := fake.isSubscriberArgsForCall[i] @@ -760,10 +760,10 @@ func (fake *FakePublishedTrack) NameReturnsOnCall(i int, result1 string) { }{result1} } -func (fake *FakePublishedTrack) NotifySubscriberMaxQuality(arg1 string, arg2 livekit.VideoQuality) { +func (fake *FakePublishedTrack) NotifySubscriberMaxQuality(arg1 livekit.ParticipantID, arg2 livekit.VideoQuality) { fake.notifySubscriberMaxQualityMutex.Lock() fake.notifySubscriberMaxQualityArgsForCall = append(fake.notifySubscriberMaxQualityArgsForCall, struct { - arg1 string + arg1 livekit.ParticipantID arg2 livekit.VideoQuality }{arg1, arg2}) stub := fake.NotifySubscriberMaxQualityStub @@ -780,23 +780,23 @@ func (fake *FakePublishedTrack) NotifySubscriberMaxQualityCallCount() int { return len(fake.notifySubscriberMaxQualityArgsForCall) } -func (fake *FakePublishedTrack) NotifySubscriberMaxQualityCalls(stub func(string, livekit.VideoQuality)) { +func (fake *FakePublishedTrack) NotifySubscriberMaxQualityCalls(stub func(livekit.ParticipantID, livekit.VideoQuality)) { fake.notifySubscriberMaxQualityMutex.Lock() defer fake.notifySubscriberMaxQualityMutex.Unlock() fake.NotifySubscriberMaxQualityStub = stub } -func (fake *FakePublishedTrack) NotifySubscriberMaxQualityArgsForCall(i int) (string, livekit.VideoQuality) { +func (fake *FakePublishedTrack) NotifySubscriberMaxQualityArgsForCall(i int) (livekit.ParticipantID, livekit.VideoQuality) { fake.notifySubscriberMaxQualityMutex.RLock() defer fake.notifySubscriberMaxQualityMutex.RUnlock() argsForCall := fake.notifySubscriberMaxQualityArgsForCall[i] return argsForCall.arg1, argsForCall.arg2 } -func (fake *FakePublishedTrack) NotifySubscriberMute(arg1 string) { +func (fake *FakePublishedTrack) NotifySubscriberMute(arg1 livekit.ParticipantID) { fake.notifySubscriberMuteMutex.Lock() fake.notifySubscriberMuteArgsForCall = append(fake.notifySubscriberMuteArgsForCall, struct { - arg1 string + arg1 livekit.ParticipantID }{arg1}) stub := fake.NotifySubscriberMuteStub fake.recordInvocation("NotifySubscriberMute", []interface{}{arg1}) @@ -812,13 +812,13 @@ func (fake *FakePublishedTrack) NotifySubscriberMuteCallCount() int { return len(fake.notifySubscriberMuteArgsForCall) } -func (fake *FakePublishedTrack) NotifySubscriberMuteCalls(stub func(string)) { +func (fake *FakePublishedTrack) NotifySubscriberMuteCalls(stub func(livekit.ParticipantID)) { fake.notifySubscriberMuteMutex.Lock() defer fake.notifySubscriberMuteMutex.Unlock() fake.NotifySubscriberMuteStub = stub } -func (fake *FakePublishedTrack) NotifySubscriberMuteArgsForCall(i int) string { +func (fake *FakePublishedTrack) NotifySubscriberMuteArgsForCall(i int) livekit.ParticipantID { fake.notifySubscriberMuteMutex.RLock() defer fake.notifySubscriberMuteMutex.RUnlock() argsForCall := fake.notifySubscriberMuteArgsForCall[i] @@ -1011,10 +1011,10 @@ func (fake *FakePublishedTrack) RemoveAllSubscribersCalls(stub func()) { fake.RemoveAllSubscribersStub = stub } -func (fake *FakePublishedTrack) RemoveSubscriber(arg1 string) { +func (fake *FakePublishedTrack) RemoveSubscriber(arg1 livekit.ParticipantID) { fake.removeSubscriberMutex.Lock() fake.removeSubscriberArgsForCall = append(fake.removeSubscriberArgsForCall, struct { - arg1 string + arg1 livekit.ParticipantID }{arg1}) stub := fake.RemoveSubscriberStub fake.recordInvocation("RemoveSubscriber", []interface{}{arg1}) @@ -1030,29 +1030,29 @@ func (fake *FakePublishedTrack) RemoveSubscriberCallCount() int { return len(fake.removeSubscriberArgsForCall) } -func (fake *FakePublishedTrack) RemoveSubscriberCalls(stub func(string)) { +func (fake *FakePublishedTrack) RemoveSubscriberCalls(stub func(livekit.ParticipantID)) { fake.removeSubscriberMutex.Lock() defer fake.removeSubscriberMutex.Unlock() fake.RemoveSubscriberStub = stub } -func (fake *FakePublishedTrack) RemoveSubscriberArgsForCall(i int) string { +func (fake *FakePublishedTrack) RemoveSubscriberArgsForCall(i int) livekit.ParticipantID { fake.removeSubscriberMutex.RLock() defer fake.removeSubscriberMutex.RUnlock() argsForCall := fake.removeSubscriberArgsForCall[i] return argsForCall.arg1 } -func (fake *FakePublishedTrack) RevokeDisallowedSubscribers(arg1 []string) []string { - var arg1Copy []string +func (fake *FakePublishedTrack) RevokeDisallowedSubscribers(arg1 []livekit.ParticipantID) []livekit.ParticipantID { + var arg1Copy []livekit.ParticipantID if arg1 != nil { - arg1Copy = make([]string, len(arg1)) + arg1Copy = make([]livekit.ParticipantID, len(arg1)) copy(arg1Copy, arg1) } fake.revokeDisallowedSubscribersMutex.Lock() ret, specificReturn := fake.revokeDisallowedSubscribersReturnsOnCall[len(fake.revokeDisallowedSubscribersArgsForCall)] fake.revokeDisallowedSubscribersArgsForCall = append(fake.revokeDisallowedSubscribersArgsForCall, struct { - arg1 []string + arg1 []livekit.ParticipantID }{arg1Copy}) stub := fake.RevokeDisallowedSubscribersStub fakeReturns := fake.revokeDisallowedSubscribersReturns @@ -1073,39 +1073,39 @@ func (fake *FakePublishedTrack) RevokeDisallowedSubscribersCallCount() int { return len(fake.revokeDisallowedSubscribersArgsForCall) } -func (fake *FakePublishedTrack) RevokeDisallowedSubscribersCalls(stub func([]string) []string) { +func (fake *FakePublishedTrack) RevokeDisallowedSubscribersCalls(stub func([]livekit.ParticipantID) []livekit.ParticipantID) { fake.revokeDisallowedSubscribersMutex.Lock() defer fake.revokeDisallowedSubscribersMutex.Unlock() fake.RevokeDisallowedSubscribersStub = stub } -func (fake *FakePublishedTrack) RevokeDisallowedSubscribersArgsForCall(i int) []string { +func (fake *FakePublishedTrack) RevokeDisallowedSubscribersArgsForCall(i int) []livekit.ParticipantID { fake.revokeDisallowedSubscribersMutex.RLock() defer fake.revokeDisallowedSubscribersMutex.RUnlock() argsForCall := fake.revokeDisallowedSubscribersArgsForCall[i] return argsForCall.arg1 } -func (fake *FakePublishedTrack) RevokeDisallowedSubscribersReturns(result1 []string) { +func (fake *FakePublishedTrack) RevokeDisallowedSubscribersReturns(result1 []livekit.ParticipantID) { fake.revokeDisallowedSubscribersMutex.Lock() defer fake.revokeDisallowedSubscribersMutex.Unlock() fake.RevokeDisallowedSubscribersStub = nil fake.revokeDisallowedSubscribersReturns = struct { - result1 []string + result1 []livekit.ParticipantID }{result1} } -func (fake *FakePublishedTrack) RevokeDisallowedSubscribersReturnsOnCall(i int, result1 []string) { +func (fake *FakePublishedTrack) RevokeDisallowedSubscribersReturnsOnCall(i int, result1 []livekit.ParticipantID) { fake.revokeDisallowedSubscribersMutex.Lock() defer fake.revokeDisallowedSubscribersMutex.Unlock() fake.RevokeDisallowedSubscribersStub = nil if fake.revokeDisallowedSubscribersReturnsOnCall == nil { fake.revokeDisallowedSubscribersReturnsOnCall = make(map[int]struct { - result1 []string + result1 []livekit.ParticipantID }) } fake.revokeDisallowedSubscribersReturnsOnCall[i] = struct { - result1 []string + result1 []livekit.ParticipantID }{result1} } diff --git a/pkg/rtc/types/typesfakes/fake_room.go b/pkg/rtc/types/typesfakes/fake_room.go index a088f497..940d4bdf 100644 --- a/pkg/rtc/types/typesfakes/fake_room.go +++ b/pkg/rtc/types/typesfakes/fake_room.go @@ -31,11 +31,11 @@ type FakeRoom struct { updateSubscriptionPermissionsReturnsOnCall map[int]struct { result1 error } - UpdateSubscriptionsStub func(types.Participant, []string, []*livekit.ParticipantTracks, bool) error + UpdateSubscriptionsStub func(types.Participant, []livekit.TrackID, []*livekit.ParticipantTracks, bool) error updateSubscriptionsMutex sync.RWMutex updateSubscriptionsArgsForCall []struct { arg1 types.Participant - arg2 []string + arg2 []livekit.TrackID arg3 []*livekit.ParticipantTracks arg4 bool } @@ -164,10 +164,10 @@ func (fake *FakeRoom) UpdateSubscriptionPermissionsReturnsOnCall(i int, result1 }{result1} } -func (fake *FakeRoom) UpdateSubscriptions(arg1 types.Participant, arg2 []string, arg3 []*livekit.ParticipantTracks, arg4 bool) error { - var arg2Copy []string +func (fake *FakeRoom) UpdateSubscriptions(arg1 types.Participant, arg2 []livekit.TrackID, arg3 []*livekit.ParticipantTracks, arg4 bool) error { + var arg2Copy []livekit.TrackID if arg2 != nil { - arg2Copy = make([]string, len(arg2)) + arg2Copy = make([]livekit.TrackID, len(arg2)) copy(arg2Copy, arg2) } var arg3Copy []*livekit.ParticipantTracks @@ -179,7 +179,7 @@ func (fake *FakeRoom) UpdateSubscriptions(arg1 types.Participant, arg2 []string, ret, specificReturn := fake.updateSubscriptionsReturnsOnCall[len(fake.updateSubscriptionsArgsForCall)] fake.updateSubscriptionsArgsForCall = append(fake.updateSubscriptionsArgsForCall, struct { arg1 types.Participant - arg2 []string + arg2 []livekit.TrackID arg3 []*livekit.ParticipantTracks arg4 bool }{arg1, arg2Copy, arg3Copy, arg4}) @@ -202,13 +202,13 @@ func (fake *FakeRoom) UpdateSubscriptionsCallCount() int { return len(fake.updateSubscriptionsArgsForCall) } -func (fake *FakeRoom) UpdateSubscriptionsCalls(stub func(types.Participant, []string, []*livekit.ParticipantTracks, bool) error) { +func (fake *FakeRoom) UpdateSubscriptionsCalls(stub func(types.Participant, []livekit.TrackID, []*livekit.ParticipantTracks, bool) error) { fake.updateSubscriptionsMutex.Lock() defer fake.updateSubscriptionsMutex.Unlock() fake.UpdateSubscriptionsStub = stub } -func (fake *FakeRoom) UpdateSubscriptionsArgsForCall(i int) (types.Participant, []string, []*livekit.ParticipantTracks, bool) { +func (fake *FakeRoom) UpdateSubscriptionsArgsForCall(i int) (types.Participant, []livekit.TrackID, []*livekit.ParticipantTracks, bool) { fake.updateSubscriptionsMutex.RLock() defer fake.updateSubscriptionsMutex.RUnlock() argsForCall := fake.updateSubscriptionsArgsForCall[i] diff --git a/pkg/rtc/types/typesfakes/fake_subscribed_track.go b/pkg/rtc/types/typesfakes/fake_subscribed_track.go index 512df321..edf80a1d 100644 --- a/pkg/rtc/types/typesfakes/fake_subscribed_track.go +++ b/pkg/rtc/types/typesfakes/fake_subscribed_track.go @@ -20,15 +20,15 @@ type FakeSubscribedTrack struct { downTrackReturnsOnCall map[int]struct { result1 *sfu.DownTrack } - IDStub func() string + IDStub func() livekit.TrackID iDMutex sync.RWMutex iDArgsForCall []struct { } iDReturns struct { - result1 string + result1 livekit.TrackID } iDReturnsOnCall map[int]struct { - result1 string + result1 livekit.TrackID } IsMutedStub func() bool isMutedMutex sync.RWMutex @@ -55,25 +55,25 @@ type FakeSubscribedTrack struct { onBindArgsForCall []struct { arg1 func() } - PublisherIDStub func() string + PublisherIDStub func() livekit.ParticipantID publisherIDMutex sync.RWMutex publisherIDArgsForCall []struct { } publisherIDReturns struct { - result1 string + result1 livekit.ParticipantID } publisherIDReturnsOnCall map[int]struct { - result1 string + result1 livekit.ParticipantID } - PublisherIdentityStub func() string + PublisherIdentityStub func() livekit.ParticipantIdentity publisherIdentityMutex sync.RWMutex publisherIdentityArgsForCall []struct { } publisherIdentityReturns struct { - result1 string + result1 livekit.ParticipantIdentity } publisherIdentityReturnsOnCall map[int]struct { - result1 string + result1 livekit.ParticipantIdentity } SetPublisherMutedStub func(bool) setPublisherMutedMutex sync.RWMutex @@ -146,7 +146,7 @@ func (fake *FakeSubscribedTrack) DownTrackReturnsOnCall(i int, result1 *sfu.Down }{result1} } -func (fake *FakeSubscribedTrack) ID() string { +func (fake *FakeSubscribedTrack) ID() livekit.TrackID { fake.iDMutex.Lock() ret, specificReturn := fake.iDReturnsOnCall[len(fake.iDArgsForCall)] fake.iDArgsForCall = append(fake.iDArgsForCall, struct { @@ -170,32 +170,32 @@ func (fake *FakeSubscribedTrack) IDCallCount() int { return len(fake.iDArgsForCall) } -func (fake *FakeSubscribedTrack) IDCalls(stub func() string) { +func (fake *FakeSubscribedTrack) IDCalls(stub func() livekit.TrackID) { fake.iDMutex.Lock() defer fake.iDMutex.Unlock() fake.IDStub = stub } -func (fake *FakeSubscribedTrack) IDReturns(result1 string) { +func (fake *FakeSubscribedTrack) IDReturns(result1 livekit.TrackID) { fake.iDMutex.Lock() defer fake.iDMutex.Unlock() fake.IDStub = nil fake.iDReturns = struct { - result1 string + result1 livekit.TrackID }{result1} } -func (fake *FakeSubscribedTrack) IDReturnsOnCall(i int, result1 string) { +func (fake *FakeSubscribedTrack) IDReturnsOnCall(i int, result1 livekit.TrackID) { fake.iDMutex.Lock() defer fake.iDMutex.Unlock() fake.IDStub = nil if fake.iDReturnsOnCall == nil { fake.iDReturnsOnCall = make(map[int]struct { - result1 string + result1 livekit.TrackID }) } fake.iDReturnsOnCall[i] = struct { - result1 string + result1 livekit.TrackID }{result1} } @@ -337,7 +337,7 @@ func (fake *FakeSubscribedTrack) OnBindArgsForCall(i int) func() { return argsForCall.arg1 } -func (fake *FakeSubscribedTrack) PublisherID() string { +func (fake *FakeSubscribedTrack) PublisherID() livekit.ParticipantID { fake.publisherIDMutex.Lock() ret, specificReturn := fake.publisherIDReturnsOnCall[len(fake.publisherIDArgsForCall)] fake.publisherIDArgsForCall = append(fake.publisherIDArgsForCall, struct { @@ -361,36 +361,36 @@ func (fake *FakeSubscribedTrack) PublisherIDCallCount() int { return len(fake.publisherIDArgsForCall) } -func (fake *FakeSubscribedTrack) PublisherIDCalls(stub func() string) { +func (fake *FakeSubscribedTrack) PublisherIDCalls(stub func() livekit.ParticipantID) { fake.publisherIDMutex.Lock() defer fake.publisherIDMutex.Unlock() fake.PublisherIDStub = stub } -func (fake *FakeSubscribedTrack) PublisherIDReturns(result1 string) { +func (fake *FakeSubscribedTrack) PublisherIDReturns(result1 livekit.ParticipantID) { fake.publisherIDMutex.Lock() defer fake.publisherIDMutex.Unlock() fake.PublisherIDStub = nil fake.publisherIDReturns = struct { - result1 string + result1 livekit.ParticipantID }{result1} } -func (fake *FakeSubscribedTrack) PublisherIDReturnsOnCall(i int, result1 string) { +func (fake *FakeSubscribedTrack) PublisherIDReturnsOnCall(i int, result1 livekit.ParticipantID) { fake.publisherIDMutex.Lock() defer fake.publisherIDMutex.Unlock() fake.PublisherIDStub = nil if fake.publisherIDReturnsOnCall == nil { fake.publisherIDReturnsOnCall = make(map[int]struct { - result1 string + result1 livekit.ParticipantID }) } fake.publisherIDReturnsOnCall[i] = struct { - result1 string + result1 livekit.ParticipantID }{result1} } -func (fake *FakeSubscribedTrack) PublisherIdentity() string { +func (fake *FakeSubscribedTrack) PublisherIdentity() livekit.ParticipantIdentity { fake.publisherIdentityMutex.Lock() ret, specificReturn := fake.publisherIdentityReturnsOnCall[len(fake.publisherIdentityArgsForCall)] fake.publisherIdentityArgsForCall = append(fake.publisherIdentityArgsForCall, struct { @@ -414,32 +414,32 @@ func (fake *FakeSubscribedTrack) PublisherIdentityCallCount() int { return len(fake.publisherIdentityArgsForCall) } -func (fake *FakeSubscribedTrack) PublisherIdentityCalls(stub func() string) { +func (fake *FakeSubscribedTrack) PublisherIdentityCalls(stub func() livekit.ParticipantIdentity) { fake.publisherIdentityMutex.Lock() defer fake.publisherIdentityMutex.Unlock() fake.PublisherIdentityStub = stub } -func (fake *FakeSubscribedTrack) PublisherIdentityReturns(result1 string) { +func (fake *FakeSubscribedTrack) PublisherIdentityReturns(result1 livekit.ParticipantIdentity) { fake.publisherIdentityMutex.Lock() defer fake.publisherIdentityMutex.Unlock() fake.PublisherIdentityStub = nil fake.publisherIdentityReturns = struct { - result1 string + result1 livekit.ParticipantIdentity }{result1} } -func (fake *FakeSubscribedTrack) PublisherIdentityReturnsOnCall(i int, result1 string) { +func (fake *FakeSubscribedTrack) PublisherIdentityReturnsOnCall(i int, result1 livekit.ParticipantIdentity) { fake.publisherIdentityMutex.Lock() defer fake.publisherIdentityMutex.Unlock() fake.PublisherIdentityStub = nil if fake.publisherIdentityReturnsOnCall == nil { fake.publisherIdentityReturnsOnCall = make(map[int]struct { - result1 string + result1 livekit.ParticipantIdentity }) } fake.publisherIdentityReturnsOnCall[i] = struct { - result1 string + result1 livekit.ParticipantIdentity }{result1} } diff --git a/pkg/rtc/uptrackmanager.go b/pkg/rtc/uptrackmanager.go index 1baacc58..73990c6d 100644 --- a/pkg/rtc/uptrackmanager.go +++ b/pkg/rtc/uptrackmanager.go @@ -16,8 +16,8 @@ import ( ) type UptrackManagerParams struct { - Identity string - SID string + Identity livekit.ParticipantIdentity + SID livekit.ParticipantID Config *WebRTCConfig AudioConfig config.AudioConfig Telemetry telemetry.TelemetryService @@ -200,7 +200,7 @@ func (u *UptrackManager) SetTrackMuted(trackID livekit.TrackID, muted bool) { isPending := false u.lock.RLock() for _, ti := range u.pendingTracks { - if ti.Sid == trackID { + if livekit.TrackID(ti.Sid) == trackID { ti.Muted = muted isPending = true } @@ -470,7 +470,7 @@ func (u *UptrackManager) updateSubscriptionPermissions(permissions *livekit.Upda // per participant permissions u.subscriptionPermissions = make(map[livekit.ParticipantID]*livekit.TrackPermission) for _, trackPerms := range permissions.TrackPermissions { - u.subscriptionPermissions[trackPerms.ParticipantSid] = trackPerms + u.subscriptionPermissions[livekit.ParticipantID(trackPerms.ParticipantSid)] = trackPerms } } @@ -489,7 +489,7 @@ func (u *UptrackManager) hasPermission(trackID livekit.TrackID, subscriberID liv } for _, sid := range perms.TrackSids { - if sid == trackID { + if livekit.TrackID(sid) == trackID { return true } } @@ -497,12 +497,12 @@ func (u *UptrackManager) hasPermission(trackID livekit.TrackID, subscriberID liv return false } -func (u *UptrackManager) getAllowedSubscribers(trackID livekit.TrackID) []string { +func (u *UptrackManager) getAllowedSubscribers(trackID livekit.TrackID) []livekit.ParticipantID { if u.subscriptionPermissions == nil { return nil } - allowed := []string{} + allowed := []livekit.ParticipantID{} for subscriberID, perms := range u.subscriptionPermissions { if perms.AllTracks { allowed = append(allowed, subscriberID) @@ -510,7 +510,7 @@ func (u *UptrackManager) getAllowedSubscribers(trackID livekit.TrackID) []string } for _, sid := range perms.TrackSids { - if sid == trackID { + if livekit.TrackID(sid) == trackID { allowed = append(allowed, subscriberID) break } @@ -651,7 +651,7 @@ func (u *UptrackManager) rtcpSendWorker() { func (u *UptrackManager) DebugInfo() map[string]interface{} { info := map[string]interface{}{} - publishedTrackInfo := make(map[string]interface{}) + publishedTrackInfo := make(map[livekit.TrackID]interface{}) pendingTrackInfo := make(map[string]interface{}) u.lock.RLock() diff --git a/pkg/rtc/utils.go b/pkg/rtc/utils.go index c5288458..ebc2c653 100644 --- a/pkg/rtc/utils.go +++ b/pkg/rtc/utils.go @@ -21,26 +21,26 @@ const ( func UnpackStreamID(packed string) (participantID livekit.ParticipantID, trackID livekit.TrackID) { parts := strings.Split(packed, trackIdSeparator) if len(parts) > 1 { - return parts[0], packed[len(parts[0])+1:] + return livekit.ParticipantID(parts[0]), livekit.TrackID(packed[len(parts[0])+1:]) } - return packed, "" + return livekit.ParticipantID(packed), "" } func PackStreamID(participantID livekit.ParticipantID, trackID livekit.TrackID) string { - return participantID + trackIdSeparator + trackID + return string(participantID) + trackIdSeparator + string(trackID) } func PackDataTrackLabel(participantID livekit.ParticipantID, trackID livekit.TrackID, label string) string { - return participantID + trackIdSeparator + trackID + trackIdSeparator + label + return string(participantID) + trackIdSeparator + string(trackID) + trackIdSeparator + label } func UnpackDataTrackLabel(packed string) (peerID livekit.ParticipantID, trackID livekit.TrackID, label string) { parts := strings.Split(packed, trackIdSeparator) if len(parts) != 3 { - return "", packed, "" + return "", livekit.TrackID(packed), "" } - peerID = parts[0] - trackID = parts[1] + peerID = livekit.ParticipantID(parts[0]) + trackID = livekit.TrackID(parts[1]) label = parts[2] return } diff --git a/pkg/rtc/utils_test.go b/pkg/rtc/utils_test.go index 58b253cc..b93637b5 100644 --- a/pkg/rtc/utils_test.go +++ b/pkg/rtc/utils_test.go @@ -3,21 +3,22 @@ package rtc import ( "testing" + "github.com/livekit/protocol/livekit" "github.com/stretchr/testify/require" ) func TestPackStreamId(t *testing.T) { packed := "PA_123abc|uuid-id" pID, trackID := UnpackStreamID(packed) - require.Equal(t, "PA_123abc", pID) - require.Equal(t, "uuid-id", trackID) + require.Equal(t, livekit.ParticipantID("PA_123abc"), pID) + require.Equal(t, livekit.TrackID("uuid-id"), trackID) require.Equal(t, packed, PackStreamID(pID, trackID)) } func TestPackDataTrackLabel(t *testing.T) { - pID := "PA_123abc" - trackID := "TR_b3da25" + pID := livekit.ParticipantID("PA_123abc") + trackID := livekit.TrackID("TR_b3da25") label := "trackLabel" packed := "PA_123abc|TR_b3da25|trackLabel" require.Equal(t, packed, PackDataTrackLabel(pID, trackID, label)) diff --git a/pkg/service/localroomstore.go b/pkg/service/localroomstore.go index 443ec787..4bbe6bdb 100644 --- a/pkg/service/localroomstore.go +++ b/pkg/service/localroomstore.go @@ -95,7 +95,7 @@ func (p *LocalRoomStore) StoreParticipant(_ context.Context, roomName livekit.Ro roomParticipants = make(map[livekit.ParticipantIdentity]*livekit.ParticipantInfo) p.participants[roomName] = roomParticipants } - roomParticipants[participant.Identity] = participant + roomParticipants[livekit.ParticipantIdentity(participant.Identity)] = participant return nil } diff --git a/pkg/service/redisroomstore.go b/pkg/service/redisroomstore.go index 3c6a4494..679e10d0 100644 --- a/pkg/service/redisroomstore.go +++ b/pkg/service/redisroomstore.go @@ -176,7 +176,7 @@ func (p *RedisRoomStore) StoreParticipant(_ context.Context, roomName livekit.Ro func (p *RedisRoomStore) LoadParticipant(_ context.Context, roomName livekit.RoomName, identity livekit.ParticipantIdentity) (*livekit.ParticipantInfo, error) { key := RoomParticipantsPrefix + string(roomName) - data, err := p.rc.HGet(p.ctx, key, identity).Result() + data, err := p.rc.HGet(p.ctx, key, string(identity)).Result() if err == redis.Nil { return nil, ErrParticipantNotFound } else if err != nil { @@ -213,5 +213,5 @@ func (p *RedisRoomStore) ListParticipants(_ context.Context, roomName livekit.Ro func (p *RedisRoomStore) DeleteParticipant(_ context.Context, roomName livekit.RoomName, identity livekit.ParticipantIdentity) error { key := RoomParticipantsPrefix + string(roomName) - return p.rc.HDel(p.ctx, key, identity).Err() + return p.rc.HDel(p.ctx, key, string(identity)).Err() } diff --git a/pkg/service/redisroomstore_test.go b/pkg/service/redisroomstore_test.go index 38d30778..a3138ab1 100644 --- a/pkg/service/redisroomstore_test.go +++ b/pkg/service/redisroomstore_test.go @@ -37,7 +37,7 @@ func TestParticipantPersistence(t *testing.T) { require.NoError(t, rs.StoreParticipant(ctx, roomName, p)) // result should match - pGet, err := rs.LoadParticipant(ctx, roomName, p.Identity) + pGet, err := rs.LoadParticipant(ctx, roomName, livekit.ParticipantIdentity(p.Identity)) require.NoError(t, err) require.Equal(t, p.Identity, pGet.Identity) require.Equal(t, len(p.Tracks), len(pGet.Tracks)) @@ -49,14 +49,14 @@ func TestParticipantPersistence(t *testing.T) { require.Len(t, participants, 1) // deleting participant should return back to normal - require.NoError(t, rs.DeleteParticipant(ctx, roomName, p.Identity)) + require.NoError(t, rs.DeleteParticipant(ctx, roomName, livekit.ParticipantIdentity(p.Identity))) participants, err = rs.ListParticipants(ctx, roomName) require.NoError(t, err) require.Len(t, participants, 0) // shouldn't be able to get it - _, err = rs.LoadParticipant(ctx, roomName, p.Identity) + _, err = rs.LoadParticipant(ctx, roomName, livekit.ParticipantIdentity(p.Identity)) require.Equal(t, err, service.ErrParticipantNotFound) } diff --git a/pkg/service/roommanager.go b/pkg/service/roommanager.go index 7873df4a..46bb4957 100644 --- a/pkg/service/roommanager.go +++ b/pkg/service/roommanager.go @@ -226,7 +226,7 @@ func (r *RoomManager) StartSession(ctx context.Context, roomName livekit.RoomNam pv := types.ProtocolVersion(pi.Client.Protocol) rtcConf := *r.rtcConfig rtcConf.SetBufferFactory(room.GetBufferFactory()) - sid := utils.NewGuid(utils.ParticipantPrefix) + sid := livekit.ParticipantID(utils.NewGuid(utils.ParticipantPrefix)) pLogger := rtc.LoggerWithParticipant(room.Logger, pi.Identity, sid) participant, err = rtc.NewParticipant(rtc.ParticipantParams{ Identity: pi.Identity, @@ -443,7 +443,7 @@ func (r *RoomManager) handleRTCMessage(_ context.Context, roomName livekit.RoomN pLogger.Debugw("updating participant subscriptions") if err := room.UpdateSubscriptions( participant, - rm.UpdateSubscriptions.TrackSids, + livekit.StringsAsTrackIDs(rm.UpdateSubscriptions.TrackSids), rm.UpdateSubscriptions.ParticipantTracks, rm.UpdateSubscriptions.Subscribe, ); err != nil { diff --git a/pkg/service/roomservice.go b/pkg/service/roomservice.go index 40986c8a..0717cf84 100644 --- a/pkg/service/roomservice.go +++ b/pkg/service/roomservice.go @@ -99,7 +99,7 @@ func (s *RoomService) GetParticipant(ctx context.Context, req *livekit.RoomParti return nil, twirpAuthError(err) } - participant, err := s.roomStore.LoadParticipant(ctx, livekit.RoomName(req.Room), req.Identity) + participant, err := s.roomStore.LoadParticipant(ctx, livekit.RoomName(req.Room), livekit.ParticipantIdentity(req.Identity)) if err != nil { return } @@ -109,7 +109,7 @@ func (s *RoomService) GetParticipant(ctx context.Context, req *livekit.RoomParti } func (s *RoomService) RemoveParticipant(ctx context.Context, req *livekit.RoomParticipantIdentity) (res *livekit.RemoveParticipantResponse, err error) { - err = s.writeRoomMessage(ctx, livekit.RoomName(req.Room), req.Identity, &livekit.RTCNodeMessage{ + err = s.writeRoomMessage(ctx, livekit.RoomName(req.Room), livekit.ParticipantIdentity(req.Identity), &livekit.RTCNodeMessage{ Message: &livekit.RTCNodeMessage_RemoveParticipant{ RemoveParticipant: req, }, @@ -127,7 +127,7 @@ func (s *RoomService) MutePublishedTrack(ctx context.Context, req *livekit.MuteR return nil, twirpAuthError(err) } - participant, err := s.roomStore.LoadParticipant(ctx, livekit.RoomName(req.Room), req.Identity) + participant, err := s.roomStore.LoadParticipant(ctx, livekit.RoomName(req.Room), livekit.ParticipantIdentity(req.Identity)) if err != nil { return nil, err } @@ -139,7 +139,7 @@ func (s *RoomService) MutePublishedTrack(ctx context.Context, req *livekit.MuteR return nil, twirp.NotFoundError(ErrTrackNotFound.Error()) } - err = s.writeParticipantMessage(ctx, livekit.RoomName(req.Room), req.Identity, &livekit.RTCNodeMessage{ + err = s.writeParticipantMessage(ctx, livekit.RoomName(req.Room), livekit.ParticipantIdentity(req.Identity), &livekit.RTCNodeMessage{ Message: &livekit.RTCNodeMessage_MuteTrack{ MuteTrack: req, }, @@ -157,7 +157,7 @@ func (s *RoomService) MutePublishedTrack(ctx context.Context, req *livekit.MuteR } func (s *RoomService) UpdateParticipant(ctx context.Context, req *livekit.UpdateParticipantRequest) (*livekit.ParticipantInfo, error) { - err := s.writeRoomMessage(ctx, livekit.RoomName(req.Room), req.Identity, &livekit.RTCNodeMessage{ + err := s.writeRoomMessage(ctx, livekit.RoomName(req.Room), livekit.ParticipantIdentity(req.Identity), &livekit.RTCNodeMessage{ Message: &livekit.RTCNodeMessage_UpdateParticipant{ UpdateParticipant: req, }, @@ -166,7 +166,7 @@ func (s *RoomService) UpdateParticipant(ctx context.Context, req *livekit.Update return nil, err } - participant, err := s.roomStore.LoadParticipant(ctx, livekit.RoomName(req.Room), req.Identity) + participant, err := s.roomStore.LoadParticipant(ctx, livekit.RoomName(req.Room), livekit.ParticipantIdentity(req.Identity)) if err != nil { return nil, err } @@ -176,7 +176,7 @@ func (s *RoomService) UpdateParticipant(ctx context.Context, req *livekit.Update } func (s *RoomService) UpdateSubscriptions(ctx context.Context, req *livekit.UpdateSubscriptionsRequest) (*livekit.UpdateSubscriptionsResponse, error) { - err := s.writeRoomMessage(ctx, livekit.RoomName(req.Room), req.Identity, &livekit.RTCNodeMessage{ + err := s.writeRoomMessage(ctx, livekit.RoomName(req.Room), livekit.ParticipantIdentity(req.Identity), &livekit.RTCNodeMessage{ Message: &livekit.RTCNodeMessage_UpdateSubscriptions{ UpdateSubscriptions: req, }, diff --git a/pkg/service/rtcservice.go b/pkg/service/rtcservice.go index 624e5884..f08e4eed 100644 --- a/pkg/service/rtcservice.go +++ b/pkg/service/rtcservice.go @@ -99,8 +99,8 @@ func (s *RTCService) validate(r *http.Request) (livekit.RoomName, routing.Partic pi := routing.ParticipantInit{ Reconnect: boolValue(reconnectParam), - Identity: claims.Identity, - Name: claims.Name, + Identity: livekit.ParticipantIdentity(claims.Identity), + Name: livekit.ParticipantName(claims.Name), AutoSubscribe: true, Metadata: claims.Metadata, Hidden: claims.Video.Hidden, diff --git a/pkg/service/servicefakes/fake_room_store.go b/pkg/service/servicefakes/fake_room_store.go index 76e411be..09372e45 100644 --- a/pkg/service/servicefakes/fake_room_store.go +++ b/pkg/service/servicefakes/fake_room_store.go @@ -11,12 +11,12 @@ import ( ) type FakeRoomStore struct { - DeleteParticipantStub func(context.Context, livekit.RoomName, string) error + DeleteParticipantStub func(context.Context, livekit.RoomName, livekit.ParticipantIdentity) error deleteParticipantMutex sync.RWMutex deleteParticipantArgsForCall []struct { arg1 context.Context arg2 livekit.RoomName - arg3 string + arg3 livekit.ParticipantIdentity } deleteParticipantReturns struct { result1 error @@ -64,12 +64,12 @@ type FakeRoomStore struct { result1 []*livekit.Room result2 error } - LoadParticipantStub func(context.Context, livekit.RoomName, string) (*livekit.ParticipantInfo, error) + LoadParticipantStub func(context.Context, livekit.RoomName, livekit.ParticipantIdentity) (*livekit.ParticipantInfo, error) loadParticipantMutex sync.RWMutex loadParticipantArgsForCall []struct { arg1 context.Context arg2 livekit.RoomName - arg3 string + arg3 livekit.ParticipantIdentity } loadParticipantReturns struct { result1 *livekit.ParticipantInfo @@ -150,13 +150,13 @@ type FakeRoomStore struct { invocationsMutex sync.RWMutex } -func (fake *FakeRoomStore) DeleteParticipant(arg1 context.Context, arg2 livekit.RoomName, arg3 string) error { +func (fake *FakeRoomStore) DeleteParticipant(arg1 context.Context, arg2 livekit.RoomName, arg3 livekit.ParticipantIdentity) error { fake.deleteParticipantMutex.Lock() ret, specificReturn := fake.deleteParticipantReturnsOnCall[len(fake.deleteParticipantArgsForCall)] fake.deleteParticipantArgsForCall = append(fake.deleteParticipantArgsForCall, struct { arg1 context.Context arg2 livekit.RoomName - arg3 string + arg3 livekit.ParticipantIdentity }{arg1, arg2, arg3}) stub := fake.DeleteParticipantStub fakeReturns := fake.deleteParticipantReturns @@ -177,13 +177,13 @@ func (fake *FakeRoomStore) DeleteParticipantCallCount() int { return len(fake.deleteParticipantArgsForCall) } -func (fake *FakeRoomStore) DeleteParticipantCalls(stub func(context.Context, livekit.RoomName, string) error) { +func (fake *FakeRoomStore) DeleteParticipantCalls(stub func(context.Context, livekit.RoomName, livekit.ParticipantIdentity) error) { fake.deleteParticipantMutex.Lock() defer fake.deleteParticipantMutex.Unlock() fake.DeleteParticipantStub = stub } -func (fake *FakeRoomStore) DeleteParticipantArgsForCall(i int) (context.Context, livekit.RoomName, string) { +func (fake *FakeRoomStore) DeleteParticipantArgsForCall(i int) (context.Context, livekit.RoomName, livekit.ParticipantIdentity) { fake.deleteParticipantMutex.RLock() defer fake.deleteParticipantMutex.RUnlock() argsForCall := fake.deleteParticipantArgsForCall[i] @@ -410,13 +410,13 @@ func (fake *FakeRoomStore) ListRoomsReturnsOnCall(i int, result1 []*livekit.Room }{result1, result2} } -func (fake *FakeRoomStore) LoadParticipant(arg1 context.Context, arg2 livekit.RoomName, arg3 string) (*livekit.ParticipantInfo, error) { +func (fake *FakeRoomStore) LoadParticipant(arg1 context.Context, arg2 livekit.RoomName, arg3 livekit.ParticipantIdentity) (*livekit.ParticipantInfo, error) { fake.loadParticipantMutex.Lock() ret, specificReturn := fake.loadParticipantReturnsOnCall[len(fake.loadParticipantArgsForCall)] fake.loadParticipantArgsForCall = append(fake.loadParticipantArgsForCall, struct { arg1 context.Context arg2 livekit.RoomName - arg3 string + arg3 livekit.ParticipantIdentity }{arg1, arg2, arg3}) stub := fake.LoadParticipantStub fakeReturns := fake.loadParticipantReturns @@ -437,13 +437,13 @@ func (fake *FakeRoomStore) LoadParticipantCallCount() int { return len(fake.loadParticipantArgsForCall) } -func (fake *FakeRoomStore) LoadParticipantCalls(stub func(context.Context, livekit.RoomName, string) (*livekit.ParticipantInfo, error)) { +func (fake *FakeRoomStore) LoadParticipantCalls(stub func(context.Context, livekit.RoomName, livekit.ParticipantIdentity) (*livekit.ParticipantInfo, error)) { fake.loadParticipantMutex.Lock() defer fake.loadParticipantMutex.Unlock() fake.LoadParticipantStub = stub } -func (fake *FakeRoomStore) LoadParticipantArgsForCall(i int) (context.Context, livekit.RoomName, string) { +func (fake *FakeRoomStore) LoadParticipantArgsForCall(i int) (context.Context, livekit.RoomName, livekit.ParticipantIdentity) { fake.loadParticipantMutex.RLock() defer fake.loadParticipantMutex.RUnlock() argsForCall := fake.loadParticipantArgsForCall[i] diff --git a/pkg/service/servicefakes/fake_roroom_store.go b/pkg/service/servicefakes/fake_roroom_store.go index 1ebc67ac..29548fa4 100644 --- a/pkg/service/servicefakes/fake_roroom_store.go +++ b/pkg/service/servicefakes/fake_roroom_store.go @@ -38,12 +38,12 @@ type FakeRORoomStore struct { result1 []*livekit.Room result2 error } - LoadParticipantStub func(context.Context, livekit.RoomName, string) (*livekit.ParticipantInfo, error) + LoadParticipantStub func(context.Context, livekit.RoomName, livekit.ParticipantIdentity) (*livekit.ParticipantInfo, error) loadParticipantMutex sync.RWMutex loadParticipantArgsForCall []struct { arg1 context.Context arg2 livekit.RoomName - arg3 string + arg3 livekit.ParticipantIdentity } loadParticipantReturns struct { result1 *livekit.ParticipantInfo @@ -206,13 +206,13 @@ func (fake *FakeRORoomStore) ListRoomsReturnsOnCall(i int, result1 []*livekit.Ro }{result1, result2} } -func (fake *FakeRORoomStore) LoadParticipant(arg1 context.Context, arg2 livekit.RoomName, arg3 string) (*livekit.ParticipantInfo, error) { +func (fake *FakeRORoomStore) LoadParticipant(arg1 context.Context, arg2 livekit.RoomName, arg3 livekit.ParticipantIdentity) (*livekit.ParticipantInfo, error) { fake.loadParticipantMutex.Lock() ret, specificReturn := fake.loadParticipantReturnsOnCall[len(fake.loadParticipantArgsForCall)] fake.loadParticipantArgsForCall = append(fake.loadParticipantArgsForCall, struct { arg1 context.Context arg2 livekit.RoomName - arg3 string + arg3 livekit.ParticipantIdentity }{arg1, arg2, arg3}) stub := fake.LoadParticipantStub fakeReturns := fake.loadParticipantReturns @@ -233,13 +233,13 @@ func (fake *FakeRORoomStore) LoadParticipantCallCount() int { return len(fake.loadParticipantArgsForCall) } -func (fake *FakeRORoomStore) LoadParticipantCalls(stub func(context.Context, livekit.RoomName, string) (*livekit.ParticipantInfo, error)) { +func (fake *FakeRORoomStore) LoadParticipantCalls(stub func(context.Context, livekit.RoomName, livekit.ParticipantIdentity) (*livekit.ParticipantInfo, error)) { fake.loadParticipantMutex.Lock() defer fake.loadParticipantMutex.Unlock() fake.LoadParticipantStub = stub } -func (fake *FakeRORoomStore) LoadParticipantArgsForCall(i int) (context.Context, livekit.RoomName, string) { +func (fake *FakeRORoomStore) LoadParticipantArgsForCall(i int) (context.Context, livekit.RoomName, livekit.ParticipantIdentity) { fake.loadParticipantMutex.RLock() defer fake.loadParticipantMutex.RUnlock() argsForCall := fake.loadParticipantArgsForCall[i] diff --git a/pkg/sfu/downtrack.go b/pkg/sfu/downtrack.go index 0add39bc..2fa6cb61 100644 --- a/pkg/sfu/downtrack.go +++ b/pkg/sfu/downtrack.go @@ -11,6 +11,7 @@ import ( "time" "github.com/livekit/livekit-server/pkg/sfu/connectionquality" + "github.com/livekit/protocol/livekit" "github.com/pion/rtcp" "github.com/pion/rtp" @@ -33,7 +34,7 @@ type TrackSender interface { // ID is the globally unique identifier for this Track. ID() string Codec() webrtc.RTPCodecCapability - PeerID() string + PeerID() livekit.ParticipantID } const ( @@ -74,8 +75,8 @@ type PacketStats struct { // to SFU Subscriber, the track handle the packets for simple, simulcast // and SVC Publisher. type DownTrack struct { - id string - peerID string + id livekit.TrackID + peerID livekit.ParticipantID bound atomicBool kind webrtc.RTPCodecType mime string @@ -136,7 +137,7 @@ type DownTrack struct { } // NewDownTrack returns a DownTrack. -func NewDownTrack(c webrtc.RTPCodecCapability, r TrackReceiver, bf *buffer.Factory, peerID string, mt int) (*DownTrack, error) { +func NewDownTrack(c webrtc.RTPCodecCapability, r TrackReceiver, bf *buffer.Factory, peerID livekit.ParticipantID, mt int) (*DownTrack, error) { var kind webrtc.RTPCodecType switch { case strings.HasPrefix(c.MimeType, "audio/"): @@ -208,7 +209,7 @@ func (d *DownTrack) Unbind(_ webrtc.TrackLocalContext) error { // ID is the unique identifier for this Track. This should be unique for the // stream, but doesn't have to globally unique. A common example would be 'audio' or 'video' // and StreamID would be 'desktop' or 'webcam' -func (d *DownTrack) ID() string { return d.id } +func (d *DownTrack) ID() string { return string(d.id) } // Codec returns current track codec capability func (d *DownTrack) Codec() webrtc.RTPCodecCapability { return d.codec } @@ -216,7 +217,7 @@ func (d *DownTrack) Codec() webrtc.RTPCodecCapability { return d.codec } // StreamID is the group this track belongs too. This must be unique func (d *DownTrack) StreamID() string { return d.streamID } -func (d *DownTrack) PeerID() string { return d.peerID } +func (d *DownTrack) PeerID() livekit.ParticipantID { return d.peerID } // Sets RTP header extensions for this track func (d *DownTrack) SetRTPHeaderExtensions(rtpHeaderExtensions []webrtc.RTPHeaderExtensionParameter) { diff --git a/pkg/sfu/receiver.go b/pkg/sfu/receiver.go index 1820c359..db9084e9 100644 --- a/pkg/sfu/receiver.go +++ b/pkg/sfu/receiver.go @@ -14,18 +14,19 @@ import ( "github.com/rs/zerolog/log" "github.com/livekit/livekit-server/pkg/sfu/buffer" + "github.com/livekit/protocol/livekit" ) type Bitrates [DefaultMaxLayerSpatial + 1][DefaultMaxLayerTemporal + 1]int64 // TrackReceiver defines an interface receive media from remote peer type TrackReceiver interface { - TrackID() string + TrackID() livekit.TrackID StreamID() string GetBitrateTemporalCumulative() Bitrates ReadRTP(buf []byte, layer uint8, sn uint16) (int, error) AddDownTrack(track TrackSender) - DeleteDownTrack(peerID string) + DeleteDownTrack(peerID livekit.ParticipantID) SendPLI(layer int32) GetSenderReportTime(layer int32) (rtpTS uint32, ntpTS uint64) Codec() webrtc.RTPCodecCapability @@ -33,7 +34,7 @@ type TrackReceiver interface { // Receiver defines an interface for a track receivers type Receiver interface { - TrackID() string + TrackID() livekit.TrackID StreamID() string Codec() webrtc.RTPCodecCapability AddUpTrack(track *webrtc.TrackRemote, buffer *buffer.Buffer) @@ -43,7 +44,7 @@ type Receiver interface { NumAvailableSpatialLayers() int GetBitrateTemporalCumulative() Bitrates ReadRTP(buf []byte, layer uint8, sn uint16) (int, error) - DeleteDownTrack(peerID string) + DeleteDownTrack(peerID livekit.ParticipantID) OnCloseHandler(fn func()) SendPLI(layer int32) SetRTCPCh(ch chan []rtcp.Packet) @@ -54,8 +55,8 @@ type Receiver interface { // WebRTCReceiver receives a video track type WebRTCReceiver struct { - peerID string - trackID string + peerID livekit.ParticipantID + trackID livekit.TrackID streamID string kind webrtc.RTPCodecType receiver *webrtc.RTPReceiver @@ -82,7 +83,7 @@ type WebRTCReceiver struct { downTrackMu sync.RWMutex downTracks []TrackSender - index map[string]int + index map[livekit.ParticipantID]int free map[int]struct{} numProcs int lbThreshold int @@ -119,11 +120,11 @@ func WithLoadBalanceThreshold(downTracks int) ReceiverOpts { } // NewWebRTCReceiver creates a new webrtc track receivers -func NewWebRTCReceiver(receiver *webrtc.RTPReceiver, track *webrtc.TrackRemote, pid string, opts ...ReceiverOpts) Receiver { +func NewWebRTCReceiver(receiver *webrtc.RTPReceiver, track *webrtc.TrackRemote, pid livekit.ParticipantID, opts ...ReceiverOpts) Receiver { w := &WebRTCReceiver{ peerID: pid, receiver: receiver, - trackID: track.ID(), + trackID: livekit.TrackID(track.ID()), streamID: track.StreamID(), codec: track.Codec(), kind: track.Kind(), @@ -132,7 +133,7 @@ func NewWebRTCReceiver(receiver *webrtc.RTPReceiver, track *webrtc.TrackRemote, maxExpectedLayer: DefaultMaxLayerSpatial, pliThrottle: 500e6, downTracks: make([]TrackSender, 0), - index: make(map[string]int), + index: make(map[livekit.ParticipantID]int), free: make(map[int]struct{}), numProcs: runtime.NumCPU(), } @@ -145,7 +146,7 @@ func NewWebRTCReceiver(receiver *webrtc.RTPReceiver, track *webrtc.TrackRemote, return w } -func (w *WebRTCReceiver) SetTrackMeta(trackID, streamID string) { +func (w *WebRTCReceiver) SetTrackMeta(trackID livekit.TrackID, streamID string) { w.streamID = streamID w.trackID = trackID } @@ -154,7 +155,7 @@ func (w *WebRTCReceiver) StreamID() string { return w.streamID } -func (w *WebRTCReceiver) TrackID() string { +func (w *WebRTCReceiver) TrackID() livekit.TrackID { return w.trackID } @@ -407,7 +408,7 @@ func (w *WebRTCReceiver) OnCloseHandler(fn func()) { } // DeleteDownTrack removes a DownTrack from a Receiver -func (w *WebRTCReceiver) DeleteDownTrack(peerID string) { +func (w *WebRTCReceiver) DeleteDownTrack(peerID livekit.ParticipantID) { if w.closed.get() { return } @@ -544,7 +545,7 @@ func (w *WebRTCReceiver) forwardRTP(layer int32) { func (w *WebRTCReceiver) writeRTP(layer int32, dt TrackSender, pkt *buffer.ExtPacket) { if err := dt.WriteRTP(pkt, layer); err != nil { - log.Error().Err(err).Str("id", dt.ID()).Msg("Error writing to down track") + log.Error().Err(err).Str("id", string(dt.ID())).Msg("Error writing to down track") } } @@ -557,7 +558,7 @@ func (w *WebRTCReceiver) closeTracks() { } } w.downTracks = make([]TrackSender, 0) - w.index = make(map[string]int) + w.index = make(map[livekit.ParticipantID]int) w.free = make(map[int]struct{}) w.downTrackMu.Unlock() diff --git a/pkg/sfu/streamallocator.go b/pkg/sfu/streamallocator.go index 73bf3d57..ff4c03c5 100644 --- a/pkg/sfu/streamallocator.go +++ b/pkg/sfu/streamallocator.go @@ -132,8 +132,8 @@ type StreamAllocator struct { lastGratuitousProbeTime time.Time - audioTracks map[string]*Track - videoTracks map[string]*Track + audioTracks map[livekit.TrackID]*Track + videoTracks map[livekit.TrackID]*Track exemptVideoTracksSorted TrackSorter managedVideoTracksSorted TrackSorter @@ -149,8 +149,8 @@ type StreamAllocator struct { func NewStreamAllocator(params StreamAllocatorParams) *StreamAllocator { s := &StreamAllocator{ params: params, - audioTracks: make(map[string]*Track), - videoTracks: make(map[string]*Track), + audioTracks: make(map[livekit.TrackID]*Track), + videoTracks: make(map[livekit.TrackID]*Track), prober: NewProber(ProberParams{ Logger: params.Logger, }), @@ -374,11 +374,12 @@ func (s *StreamAllocator) handleSignalAddTrack(event *Event) { isManaged := (params.Source != livekit.TrackSource_SCREEN_SHARE && params.Source != livekit.TrackSource_SCREEN_SHARE_AUDIO) || params.IsSimulcast track := newTrack(event.DownTrack, isManaged) + trackID := livekit.TrackID(event.DownTrack.ID()) switch event.DownTrack.Kind() { case webrtc.RTPCodecTypeAudio: - s.audioTracks[event.DownTrack.ID()] = track + s.audioTracks[trackID] = track case webrtc.RTPCodecTypeVideo: - s.videoTracks[event.DownTrack.ID()] = track + s.videoTracks[trackID] = track if isManaged { s.managedVideoTracksSorted = append(s.managedVideoTracksSorted, track) @@ -393,20 +394,21 @@ func (s *StreamAllocator) handleSignalAddTrack(event *Event) { } func (s *StreamAllocator) handleSignalRemoveTrack(event *Event) { + trackID := livekit.TrackID(event.DownTrack.ID()) switch event.DownTrack.Kind() { case webrtc.RTPCodecTypeAudio: - if _, ok := s.audioTracks[event.DownTrack.ID()]; !ok { + if _, ok := s.audioTracks[trackID]; !ok { return } - delete(s.audioTracks, event.DownTrack.ID()) + delete(s.audioTracks, trackID) case webrtc.RTPCodecTypeVideo: - track, ok := s.videoTracks[event.DownTrack.ID()] + track, ok := s.videoTracks[trackID] if !ok { return } - delete(s.videoTracks, event.DownTrack.ID()) + delete(s.videoTracks, trackID) if track.IsManaged() { n := len(s.managedVideoTracksSorted) @@ -548,11 +550,13 @@ func (s *StreamAllocator) handleSignalTargetBitrate(event *Event) { func (s *StreamAllocator) handleSignalReceiverReport(event *Event) { var track *Track ok := false + + trackID := livekit.TrackID(event.DownTrack.ID()) switch event.DownTrack.Kind() { case webrtc.RTPCodecTypeAudio: - track, ok = s.audioTracks[event.DownTrack.ID()] + track, ok = s.audioTracks[trackID] case webrtc.RTPCodecTypeVideo: - track, ok = s.videoTracks[event.DownTrack.ID()] + track, ok = s.videoTracks[trackID] } if !ok { return @@ -563,7 +567,7 @@ func (s *StreamAllocator) handleSignalReceiverReport(event *Event) { } func (s *StreamAllocator) handleSignalAvailableLayersChange(event *Event) { - track, ok := s.videoTracks[event.DownTrack.ID()] + track, ok := s.videoTracks[livekit.TrackID(event.DownTrack.ID())] if !ok { return } @@ -572,7 +576,7 @@ func (s *StreamAllocator) handleSignalAvailableLayersChange(event *Event) { } func (s *StreamAllocator) handleSignalSubscriptionChange(event *Event) { - track, ok := s.videoTracks[event.DownTrack.ID()] + track, ok := s.videoTracks[livekit.TrackID(event.DownTrack.ID())] if !ok { return } @@ -581,7 +585,7 @@ func (s *StreamAllocator) handleSignalSubscriptionChange(event *Event) { } func (s *StreamAllocator) handleSignalSubscribedLayersChange(event *Event) { - track, ok := s.videoTracks[event.DownTrack.ID()] + track, ok := s.videoTracks[livekit.TrackID(event.DownTrack.ID())] if !ok { return } @@ -1034,9 +1038,9 @@ const ( ) type StreamStateInfo struct { - ParticipantSid string - TrackSid string - State StreamState + ParticipantID livekit.ParticipantID + TrackID livekit.TrackID + State StreamState } type StreamStateUpdate struct { @@ -1051,15 +1055,15 @@ func (s *StreamStateUpdate) HandleStreamingChange(change VideoStreamingChange, t switch change { case VideoStreamingChangePausing: s.StreamStates = append(s.StreamStates, &StreamStateInfo{ - ParticipantSid: track.PeerID(), - TrackSid: track.ID(), - State: StreamStatePaused, + ParticipantID: track.PeerID(), + TrackID: track.ID(), + State: StreamStatePaused, }) case VideoStreamingChangeResuming: s.StreamStates = append(s.StreamStates, &StreamStateInfo{ - ParticipantSid: track.PeerID(), - TrackSid: track.ID(), - State: StreamStateActive, + ParticipantID: track.PeerID(), + TrackID: track.ID(), + State: StreamStateActive, }) } } @@ -1100,11 +1104,11 @@ func (t *Track) IsManaged() bool { return t.isManaged } -func (t *Track) ID() string { - return t.downTrack.ID() +func (t *Track) ID() livekit.TrackID { + return livekit.TrackID(t.downTrack.ID()) } -func (t *Track) PeerID() string { +func (t *Track) PeerID() livekit.ParticipantID { return t.downTrack.PeerID() } diff --git a/pkg/telemetry/statsworker.go b/pkg/telemetry/statsworker.go index 03d4273b..e43d412c 100644 --- a/pkg/telemetry/statsworker.go +++ b/pkg/telemetry/statsworker.go @@ -64,8 +64,8 @@ func (s *StatsWorker) getOrCreateOutgoingStatsIfEmpty(trackID livekit.TrackID) * if s.outgoingPerTrack[trackID] == nil { s.outgoingPerTrack[trackID] = &Stats{next: &livekit.AnalyticsStat{ Kind: livekit.StreamType_DOWNSTREAM, - RoomId: s.roomID, - ParticipantId: s.participantID, + RoomId: string(s.roomID), + ParticipantId: string(s.participantID), RoomName: string(s.roomName), }} } @@ -76,8 +76,8 @@ func (s *StatsWorker) getOrCreateIncomingStatsIfEmpty(trackID livekit.TrackID) * if s.incomingPerTrack[trackID] == nil { s.incomingPerTrack[trackID] = &Stats{next: &livekit.AnalyticsStat{ Kind: livekit.StreamType_UPSTREAM, - RoomId: s.roomID, - ParticipantId: s.participantID, + RoomId: string(s.roomID), + ParticipantId: string(s.participantID), RoomName: string(s.roomName), }} } @@ -129,7 +129,7 @@ func (s *StatsWorker) collectDownstreamStats(ts *timestamppb.Timestamp, stats [] for trackID, trackDownStreamStats := range s.outgoingPerTrack { analyticsStat := s.update(trackDownStreamStats, ts) if analyticsStat != nil { - analyticsStat.TrackId = trackID + analyticsStat.TrackId = string(trackID) stats = append(stats, analyticsStat) } } @@ -145,7 +145,7 @@ func (s *StatsWorker) collectUpstreamStats(ts *timestamppb.Timestamp, stats []*l analyticsStats := s.update(s.incomingPerTrack[trackID], ts) if analyticsStats != nil { - analyticsStats.TrackId = trackID + analyticsStats.TrackId = string(trackID) stats = append(stats, analyticsStats) } } @@ -168,8 +168,8 @@ func (s *StatsWorker) update(stats *Stats, ts *timestamppb.Timestamp) *livekit.A next := stats.next stats.next = &livekit.AnalyticsStat{ Kind: next.Kind, - RoomId: s.roomID, - ParticipantId: s.participantID, + RoomId: string(s.roomID), + ParticipantId: string(s.participantID), RoomName: string(s.roomName), } diff --git a/pkg/telemetry/telemetryserviceinternalevents.go b/pkg/telemetry/telemetryserviceinternalevents.go index 8304659f..87752317 100644 --- a/pkg/telemetry/telemetryserviceinternalevents.go +++ b/pkg/telemetry/telemetryserviceinternalevents.go @@ -46,7 +46,7 @@ func (t *telemetryServiceInternal) RoomEnded(ctx context.Context, room *livekit. func (t *telemetryServiceInternal) ParticipantJoined(ctx context.Context, room *livekit.Room, participant *livekit.ParticipantInfo, clientInfo *livekit.ClientInfo) { - t.workers[participant.Sid] = newStatsWorker(ctx, t, room.Sid, livekit.RoomName(room.Name), participant.Sid) + t.workers[livekit.ParticipantID(participant.Sid)] = newStatsWorker(ctx, t, livekit.RoomID(room.Sid), livekit.RoomName(room.Name), livekit.ParticipantID(participant.Sid)) prometheus.AddParticipant() @@ -68,9 +68,9 @@ func (t *telemetryServiceInternal) ParticipantJoined(ctx context.Context, room * } func (t *telemetryServiceInternal) ParticipantLeft(ctx context.Context, room *livekit.Room, participant *livekit.ParticipantInfo) { - if w := t.workers[participant.Sid]; w != nil { + if w := t.workers[livekit.ParticipantID(participant.Sid)]; w != nil { w.Close() - delete(t.workers, participant.Sid) + delete(t.workers, livekit.ParticipantID(participant.Sid)) } prometheus.SubParticipant() @@ -97,20 +97,20 @@ func (t *telemetryServiceInternal) TrackPublished(ctx context.Context, participa t.analytics.SendEvent(ctx, &livekit.AnalyticsEvent{ Type: livekit.AnalyticsEventType_TRACK_PUBLISHED, Timestamp: timestamppb.Now(), - RoomId: roomID, - ParticipantId: participantID, + RoomId: string(roomID), + ParticipantId: string(participantID), Track: track, Room: &livekit.Room{Name: string(roomName)}, }) } func (t *telemetryServiceInternal) TrackUnpublished(ctx context.Context, participantID livekit.ParticipantID, track *livekit.TrackInfo, ssrc uint32) { - roomID := "" + roomID := livekit.RoomID("") roomName := livekit.RoomName("") w := t.workers[participantID] if w != nil { roomID = w.roomID - w.RemoveBuffer(track.GetSid()) + w.RemoveBuffer(livekit.TrackID(track.GetSid())) roomName = w.roomName } @@ -119,8 +119,8 @@ func (t *telemetryServiceInternal) TrackUnpublished(ctx context.Context, partici t.analytics.SendEvent(ctx, &livekit.AnalyticsEvent{ Type: livekit.AnalyticsEventType_TRACK_UNPUBLISHED, Timestamp: timestamppb.Now(), - RoomId: roomID, - ParticipantId: participantID, + RoomId: string(roomID), + ParticipantId: string(participantID), TrackId: track.Sid, Room: &livekit.Room{Name: string(roomName)}, }) @@ -133,8 +133,8 @@ func (t *telemetryServiceInternal) TrackSubscribed(ctx context.Context, particip t.analytics.SendEvent(ctx, &livekit.AnalyticsEvent{ Type: livekit.AnalyticsEventType_TRACK_SUBSCRIBED, Timestamp: timestamppb.Now(), - RoomId: roomID, - ParticipantId: participantID, + RoomId: string(roomID), + ParticipantId: string(participantID), TrackId: track.Sid, Room: &livekit.Room{Name: string(roomName)}, }) @@ -147,8 +147,8 @@ func (t *telemetryServiceInternal) TrackUnsubscribed(ctx context.Context, partic t.analytics.SendEvent(ctx, &livekit.AnalyticsEvent{ Type: livekit.AnalyticsEventType_TRACK_UNSUBSCRIBED, Timestamp: timestamppb.Now(), - RoomId: roomID, - ParticipantId: participantID, + RoomId: string(roomID), + ParticipantId: string(participantID), TrackId: track.Sid, Room: &livekit.Room{Name: string(roomName)}, }) diff --git a/pkg/telemetry/test/telemetry_service_test.go b/pkg/telemetry/test/telemetry_service_test.go index aa994729..c2de65d0 100644 --- a/pkg/telemetry/test/telemetry_service_test.go +++ b/pkg/telemetry/test/telemetry_service_test.go @@ -30,9 +30,9 @@ func Test_ParticipantAndRoomDataAreSentWithAnalytics(t *testing.T) { //prepare room := &livekit.Room{Sid: "RoomSid", Name: "RoomName"} - partSID := "part1" + partSID := livekit.ParticipantID("part1") clientInfo := &livekit.ClientInfo{Sdk: 2} - participantInfo := &livekit.ParticipantInfo{Sid: partSID} + participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} fixture.sut.ParticipantJoined(context.Background(), room, participantInfo, clientInfo) //do @@ -45,7 +45,7 @@ func Test_ParticipantAndRoomDataAreSentWithAnalytics(t *testing.T) { _, stats := fixture.analytics.SendStatsArgsForCall(0) require.Equal(t, 1, len(stats)) require.Equal(t, livekit.StreamType_DOWNSTREAM, stats[0].Kind) - require.Equal(t, partSID, stats[0].ParticipantId) + require.Equal(t, string(partSID), stats[0].ParticipantId) require.Equal(t, room.Sid, stats[0].RoomId) require.Equal(t, room.Name, stats[0].RoomName) } @@ -55,16 +55,16 @@ func Test_OnDownstreamPackets(t *testing.T) { //prepare room := &livekit.Room{} - partSID := "part1" + partSID := livekit.ParticipantID("part1") clientInfo := &livekit.ClientInfo{Sdk: 2} - participantInfo := &livekit.ParticipantInfo{Sid: partSID} + participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} fixture.sut.ParticipantJoined(context.Background(), room, participantInfo, clientInfo) //do packets := []int{33, 23} totalBytes := packets[0] + packets[1] totalPackets := len(packets) - trackID := "trackID" + trackID := livekit.TrackID("trackID") for i := range packets { fixture.sut.OnDownstreamPacket(partSID, trackID, packets[i]) } @@ -77,7 +77,7 @@ func Test_OnDownstreamPackets(t *testing.T) { require.Equal(t, livekit.StreamType_DOWNSTREAM, stats[0].Kind) require.Equal(t, totalBytes, int(stats[0].TotalBytes)) require.Equal(t, totalPackets, int(stats[0].TotalPackets)) - require.Equal(t, trackID, stats[0].TrackId) + require.Equal(t, string(trackID), stats[0].TrackId) } func Test_OnDownstreamPackets_SeveralTracks(t *testing.T) { @@ -85,16 +85,16 @@ func Test_OnDownstreamPackets_SeveralTracks(t *testing.T) { //prepare room := &livekit.Room{} - partSID := "part1" + partSID := livekit.ParticipantID("part1") clientInfo := &livekit.ClientInfo{Sdk: 2} - participantInfo := &livekit.ParticipantInfo{Sid: partSID} + participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} fixture.sut.ParticipantJoined(context.Background(), room, participantInfo, clientInfo) //do packet1 := 33 - trackID1 := "trackID1" + trackID1 := livekit.TrackID("trackID1") packet2 := 23 - trackID2 := "trackID2" + trackID2 := livekit.TrackID("trackID2") fixture.sut.OnDownstreamPacket(partSID, trackID1, packet1) fixture.sut.OnDownstreamPacket(partSID, trackID2, packet2) fixture.sut.SendAnalytics() @@ -107,11 +107,11 @@ func Test_OnDownstreamPackets_SeveralTracks(t *testing.T) { found1 := false found2 := false for _, sentStat := range stats { - if sentStat.TrackId == trackID1 { + if livekit.TrackID(sentStat.TrackId) == trackID1 { found1 = true require.Equal(t, packet1, int(sentStat.TotalBytes)) require.Equal(t, 1, int(sentStat.TotalPackets)) - } else if sentStat.TrackId == trackID2 { + } else if livekit.TrackID(sentStat.TrackId) == trackID2 { found2 = true require.Equal(t, packet2, int(sentStat.TotalBytes)) require.Equal(t, 1, int(sentStat.TotalPackets)) @@ -126,8 +126,8 @@ func Test_OnDownStreamRTCP(t *testing.T) { //prepare room := &livekit.Room{} - partSID := "part1" - participantInfo := &livekit.ParticipantInfo{Sid: partSID} + partSID := livekit.ParticipantID("part1") + participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} fixture.sut.ParticipantJoined(context.Background(), room, participantInfo, nil) //do @@ -142,7 +142,7 @@ func Test_OnDownStreamRTCP(t *testing.T) { }, }, } - trackID := "trackID1" + trackID := livekit.TrackID("trackID1") fixture.sut.OnDownstreamPacket(partSID, trackID, 1) // there should be bytes reported so that stats are sent fixture.sut.HandleRTCP(livekit.StreamType_DOWNSTREAM, partSID, trackID, pkts) fixture.sut.SendAnalytics() @@ -158,7 +158,7 @@ func Test_OnDownStreamRTCP(t *testing.T) { require.Equal(t, 0, int(stats[0].Rtt)) // TODO: test for RTT require.Equal(t, 5, int(stats[0].Jitter)) // max of jitter, see list of rtcp.ReceptionReport above require.Equal(t, 4, int(stats[0].PacketLost)) // last reported packets lost, see list of rtcp.ReceptionReport above - require.Equal(t, trackID, stats[0].TrackId) + require.Equal(t, string(trackID), stats[0].TrackId) } func Test_PacketLostDiffShouldBeSentToTelemetry(t *testing.T) { @@ -166,8 +166,8 @@ func Test_PacketLostDiffShouldBeSentToTelemetry(t *testing.T) { //prepare room := &livekit.Room{} - partSID := "part1" - participantInfo := &livekit.ParticipantInfo{Sid: partSID} + partSID := livekit.ParticipantID("part1") + participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} fixture.sut.ParticipantJoined(context.Background(), room, participantInfo, nil) //do @@ -185,7 +185,7 @@ func Test_PacketLostDiffShouldBeSentToTelemetry(t *testing.T) { }, }, } - trackID := "trackID1" + trackID := livekit.TrackID("trackID1") fixture.sut.OnDownstreamPacket(partSID, trackID, 1) // there should be bytes reported so that stats are sent fixture.sut.HandleRTCP(livekit.StreamType_DOWNSTREAM, partSID, trackID, pkts1) fixture.sut.SendAnalytics() @@ -210,8 +210,8 @@ func Test_OnDownStreamRTCP_SeveralTracks(t *testing.T) { //prepare room := &livekit.Room{} - partSID := "part1" - participantInfo := &livekit.ParticipantInfo{Sid: partSID} + partSID := livekit.ParticipantID("part1") + participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} fixture.sut.ParticipantJoined(context.Background(), room, participantInfo, nil) //do @@ -221,8 +221,8 @@ func Test_OnDownStreamRTCP_SeveralTracks(t *testing.T) { pkts2 := []rtcp.Packet{ &rtcp.FullIntraRequest{}, } - trackID1 := "trackID1" - trackID2 := "trackID2" + trackID1 := livekit.TrackID("trackID1") + trackID2 := livekit.TrackID("trackID2") fixture.sut.OnDownstreamPacket(partSID, trackID1, 1) // there should be bytes reported so that stats are sent fixture.sut.HandleRTCP(livekit.StreamType_DOWNSTREAM, partSID, trackID1, pkts1) fixture.sut.OnDownstreamPacket(partSID, trackID2, 1) // there should be bytes reported so that stats are sent @@ -237,11 +237,11 @@ func Test_OnDownStreamRTCP_SeveralTracks(t *testing.T) { found1 := false found2 := false for _, sentStat := range stats { - if sentStat.TrackId == trackID1 { + if livekit.TrackID(sentStat.TrackId) == trackID1 { found1 = true require.Equal(t, livekit.StreamType_DOWNSTREAM, sentStat.Kind) require.Equal(t, 1, int(sentStat.NackCount)) // see pkts1 above - } else if sentStat.TrackId == trackID2 { + } else if livekit.TrackID(sentStat.TrackId) == trackID2 { found2 = true require.Equal(t, livekit.StreamType_DOWNSTREAM, sentStat.Kind) require.Equal(t, 1, int(sentStat.FirCount)) // see pkts2 above @@ -255,8 +255,8 @@ func Test_OnUpstreamRTCP(t *testing.T) { //prepare room := &livekit.Room{} - partSID := "part1" - participantInfo := &livekit.ParticipantInfo{Sid: partSID} + partSID := livekit.ParticipantID("part1") + participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} fixture.sut.ParticipantJoined(context.Background(), room, participantInfo, nil) //do @@ -277,7 +277,7 @@ func Test_OnUpstreamRTCP(t *testing.T) { PacketCount: 1, TotalByte: 1, }) - trackID := "trackID" + trackID := livekit.TrackID("trackID") fixture.sut.AddUpTrack(partSID, trackID, buf) fixture.sut.HandleRTCP(livekit.StreamType_UPSTREAM, partSID, trackID, pkts) fixture.sut.SendAnalytics() @@ -293,7 +293,7 @@ func Test_OnUpstreamRTCP(t *testing.T) { require.Equal(t, 0, int(stats[0].Rtt)) // TODO: test for RTT require.Equal(t, 5, int(stats[0].Jitter)) // max of jitter, see list of rtcp.ReceptionReport above require.Equal(t, 4, int(stats[0].PacketLost)) // last reported packets lost, see list of rtcp.ReceptionReport above - require.Equal(t, trackID, stats[0].TrackId) + require.Equal(t, string(trackID), stats[0].TrackId) } func Test_OnUpstreamRTCP_SeveralTracks(t *testing.T) { @@ -301,8 +301,8 @@ func Test_OnUpstreamRTCP_SeveralTracks(t *testing.T) { //prepare room := &livekit.Room{} - partSID := "part1" - participantInfo := &livekit.ParticipantInfo{Sid: partSID} + partSID := livekit.ParticipantID("part1") + participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} fixture.sut.ParticipantJoined(context.Background(), room, participantInfo, nil) // there should be bytes reported so that stats are sent @@ -313,8 +313,8 @@ func Test_OnUpstreamRTCP_SeveralTracks(t *testing.T) { PacketCount: uint32(tolalPackets), TotalByte: uint64(totalBytes), }) - trackID1 := "trackID1" - trackID2 := "trackID2" + trackID1 := livekit.TrackID("trackID1") + trackID2 := livekit.TrackID("trackID2") fixture.sut.AddUpTrack(partSID, trackID1, buf) fixture.sut.AddUpTrack(partSID, trackID2, buf) //using same buffer is not correct but for test it is fine pkts1 := []rtcp.Packet{ @@ -336,11 +336,11 @@ func Test_OnUpstreamRTCP_SeveralTracks(t *testing.T) { found1 := false found2 := false for _, sentStat := range stats { - if sentStat.TrackId == trackID1 { + if livekit.TrackID(sentStat.TrackId) == trackID1 { found1 = true require.Equal(t, livekit.StreamType_UPSTREAM, sentStat.Kind) require.Equal(t, 1, int(sentStat.NackCount)) // see pkts1 above - } else if sentStat.TrackId == trackID2 { + } else if livekit.TrackID(sentStat.TrackId) == trackID2 { found2 = true require.Equal(t, livekit.StreamType_UPSTREAM, sentStat.Kind) require.Equal(t, 1, int(sentStat.FirCount)) // see pkts2 above @@ -352,7 +352,7 @@ func Test_OnUpstreamRTCP_SeveralTracks(t *testing.T) { require.True(t, found2) //remove 1 buffer - fixture.sut.TrackUnpublished(context.Background(), partSID, &livekit.TrackInfo{Sid: trackID2}, 0) + fixture.sut.TrackUnpublished(context.Background(), partSID, &livekit.TrackInfo{Sid: string(trackID2)}, 0) fixture.sut.SendAnalytics() require.Equal(t, 2, fixture.analytics.SendStatsCallCount()) _, stats = fixture.analytics.SendStatsArgsForCall(1) @@ -386,8 +386,8 @@ func Test_AddUpTrack(t *testing.T) { //prepare room := &livekit.Room{} - partSID := "part1" - participantInfo := &livekit.ParticipantInfo{Sid: partSID} + partSID := livekit.ParticipantID("part1") + participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} fixture.sut.ParticipantJoined(context.Background(), room, participantInfo, nil) //do @@ -399,7 +399,7 @@ func Test_AddUpTrack(t *testing.T) { TotalByte: totalBytes, } buf.SetStatsTestOnly(bufferStats) - trackID := "trackID" + trackID := livekit.TrackID("trackID") fixture.sut.AddUpTrack(partSID, trackID, buf) fixture.sut.SendAnalytics() @@ -410,7 +410,7 @@ func Test_AddUpTrack(t *testing.T) { require.Equal(t, livekit.StreamType_UPSTREAM, stats[0].Kind) require.Equal(t, totalBytes, stats[0].TotalBytes) require.Equal(t, totalPackets, uint32(stats[0].TotalPackets)) - require.Equal(t, trackID, stats[0].TrackId) + require.Equal(t, string(trackID), stats[0].TrackId) } func Test_AddUpTrack_SeveralBuffers_Simulcast(t *testing.T) { @@ -418,11 +418,11 @@ func Test_AddUpTrack_SeveralBuffers_Simulcast(t *testing.T) { //prepare room := &livekit.Room{} - partSID := "part1" - participantInfo := &livekit.ParticipantInfo{Sid: partSID} + partSID := livekit.ParticipantID("part1") + participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} fixture.sut.ParticipantJoined(context.Background(), room, participantInfo, nil) //do - trackID := "trackID" + trackID := livekit.TrackID("trackID") //buffer 1 buf1 := &buffer.Buffer{} buf1.SetStatsTestOnly(buffer.Stats{ @@ -447,7 +447,7 @@ func Test_AddUpTrack_SeveralBuffers_Simulcast(t *testing.T) { require.Equal(t, livekit.StreamType_UPSTREAM, stats[0].Kind) require.Equal(t, totalBytes, stats[0].TotalBytes) require.Equal(t, totalPackets, uint32(stats[0].TotalPackets)) - require.Equal(t, trackID, stats[0].TrackId) + require.Equal(t, string(trackID), stats[0].TrackId) } func Test_BothDownstreamAndUpstreamStatsAreSentTogether(t *testing.T) { @@ -455,8 +455,8 @@ func Test_BothDownstreamAndUpstreamStatsAreSentTogether(t *testing.T) { //prepare room := &livekit.Room{} - partSID := "part1" - participantInfo := &livekit.ParticipantInfo{Sid: partSID} + partSID := livekit.ParticipantID("part1") + participantInfo := &livekit.ParticipantInfo{Sid: string(partSID)} fixture.sut.ParticipantJoined(context.Background(), room, participantInfo, nil) //do diff --git a/test/client/client.go b/test/client/client.go index 6ad8acd3..d3fb8105 100644 --- a/test/client/client.go +++ b/test/client/client.go @@ -30,7 +30,7 @@ const ( ) type RTCClient struct { - id string + id livekit.ParticipantID conn *websocket.Conn publisher *rtc.PCTransport subscriber *rtc.PCTransport @@ -43,9 +43,9 @@ type RTCClient struct { connected utils.AtomicFlag iceConnected utils.AtomicFlag me *webrtc.MediaEngine // optional, populated only when receiving tracks - subscribedTracks map[string][]*webrtc.TrackRemote + subscribedTracks map[livekit.ParticipantID][]*webrtc.TrackRemote localParticipant *livekit.ParticipantInfo - remoteParticipants map[string]*livekit.ParticipantInfo + remoteParticipants map[livekit.ParticipantID]*livekit.ParticipantInfo reliableDC *webrtc.DataChannel reliableDCSub *webrtc.DataChannel @@ -61,9 +61,9 @@ type RTCClient struct { OnConnected func() OnDataReceived func(data []byte, sid string) - // map of track ID and last packet - lastPackets map[string]*rtp.Packet - bytesReceived map[string]uint64 + // map of livekit.ParticipantID and last packet + lastPackets map[livekit.ParticipantID]*rtp.Packet + bytesReceived map[livekit.ParticipantID]uint64 } var ( @@ -115,11 +115,11 @@ func NewRTCClient(conn *websocket.Conn) (*RTCClient, error) { conn: conn, localTracks: make(map[string]webrtc.TrackLocal), pendingPublishedTracks: make(map[string]*livekit.TrackInfo), - subscribedTracks: make(map[string][]*webrtc.TrackRemote), - remoteParticipants: make(map[string]*livekit.ParticipantInfo), + subscribedTracks: make(map[livekit.ParticipantID][]*webrtc.TrackRemote), + remoteParticipants: make(map[livekit.ParticipantID]*livekit.ParticipantInfo), me: &webrtc.MediaEngine{}, - lastPackets: make(map[string]*rtp.Packet), - bytesReceived: make(map[string]uint64), + lastPackets: make(map[livekit.ParticipantID]*rtp.Packet), + bytesReceived: make(map[livekit.ParticipantID]uint64), } c.ctx, c.cancel = context.WithCancel(context.Background()) @@ -241,7 +241,7 @@ func NewRTCClient(conn *websocket.Conn) (*RTCClient, error) { return c, nil } -func (c *RTCClient) ID() string { +func (c *RTCClient) ID() livekit.ParticipantID { return c.id } @@ -266,10 +266,10 @@ func (c *RTCClient) Run() error { switch msg := res.Message.(type) { case *livekit.SignalResponse_Join: c.localParticipant = msg.Join.Participant - c.id = msg.Join.Participant.Sid + c.id = livekit.ParticipantID(msg.Join.Participant.Sid) c.lock.Lock() for _, p := range msg.Join.OtherParticipants { - c.remoteParticipants[p.Sid] = p + c.remoteParticipants[livekit.ParticipantID(p.Sid)] = p } c.lock.Unlock() // if publish only, negotiate @@ -309,9 +309,9 @@ func (c *RTCClient) Run() error { c.lock.Lock() for _, p := range msg.Update.Participants { if p.State != livekit.ParticipantInfo_DISCONNECTED { - c.remoteParticipants[p.Sid] = p + c.remoteParticipants[livekit.ParticipantID(p.Sid)] = p } else { - delete(c.remoteParticipants, p.Sid) + delete(c.remoteParticipants, livekit.ParticipantID(p.Sid)) } } c.lock.Unlock() @@ -332,7 +332,7 @@ func (c *RTCClient) WaitUntilConnected() error { for { select { case <-ctx.Done(): - id := c.ID() + id := string(c.ID()) if c.localParticipant != nil { id = c.localParticipant.Identity } @@ -372,11 +372,11 @@ func (c *RTCClient) ReadResponse() (*livekit.SignalResponse, error) { } } -func (c *RTCClient) SubscribedTracks() map[string][]*webrtc.TrackRemote { +func (c *RTCClient) SubscribedTracks() map[livekit.ParticipantID][]*webrtc.TrackRemote { // create a copy of this c.lock.Lock() defer c.lock.Unlock() - tracks := make(map[string][]*webrtc.TrackRemote, len(c.subscribedTracks)) + tracks := make(map[livekit.ParticipantID][]*webrtc.TrackRemote, len(c.subscribedTracks)) for key, val := range c.subscribedTracks { tracks[key] = val } @@ -389,7 +389,7 @@ func (c *RTCClient) RemoteParticipants() []*livekit.ParticipantInfo { return funk.Values(c.remoteParticipants).([]*livekit.ParticipantInfo) } -func (c *RTCClient) GetRemoteParticipant(sid string) *livekit.ParticipantInfo { +func (c *RTCClient) GetRemoteParticipant(sid livekit.ParticipantID) *livekit.ParticipantInfo { c.lock.Lock() defer c.lock.Unlock() return c.remoteParticipants[sid] @@ -659,7 +659,7 @@ func (c *RTCClient) processTrack(track *webrtc.TrackRemote) { lastUpdate := time.Time{} pId, trackId := rtc.UnpackStreamID(track.StreamID()) if trackId == "" { - trackId = track.ID() + trackId = livekit.TrackID(track.ID()) } c.lock.Lock() c.subscribedTracks[pId] = append(c.subscribedTracks[pId], track) diff --git a/test/scenarios.go b/test/scenarios.go index 6960a405..e997db67 100644 --- a/test/scenarios.go +++ b/test/scenarios.go @@ -129,7 +129,7 @@ func scenarioDataPublish(t *testing.T) { received := utils.AtomicFlag{} c2.OnDataReceived = func(data []byte, sid string) { - if string(data) == payload && sid == c1.ID() { + if string(data) == payload && livekit.ParticipantID(sid) == c1.ID() { received.TrySet(true) } }