diff --git a/pkg/rtc/datatrack.go b/pkg/rtc/datatrack.go index f00ae2a90..acf5f51dc 100644 --- a/pkg/rtc/datatrack.go +++ b/pkg/rtc/datatrack.go @@ -57,12 +57,12 @@ func NewDataTrack(params DataTrackParams, dti *livekit.DataTrackInfo) *DataTrack Logger: params.Logger, }), } - d.params.Logger.Infow("created data track", "id", d.ID(), "name", d.Name()) + d.params.Logger.Infow("created data track", "name", d.Name()) return d } func (d *DataTrack) Close() { - d.params.Logger.Infow("closing data track", "id", d.ID(), "name", d.Name()) + d.params.Logger.Infow("closing data track", "name", d.Name()) d.closed.Break() } diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index e5c2f2cf3..cda2ca01a 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -52,7 +52,6 @@ import ( "github.com/livekit/livekit-server/pkg/config" "github.com/livekit/livekit-server/pkg/metric" "github.com/livekit/livekit-server/pkg/routing" - "github.com/livekit/livekit-server/pkg/rtc/datatrack" "github.com/livekit/livekit-server/pkg/rtc/signalling" "github.com/livekit/livekit-server/pkg/rtc/supervisor" "github.com/livekit/livekit-server/pkg/rtc/transport" @@ -192,6 +191,7 @@ type ParticipantParams struct { TCPFallbackRTTThreshold int AllowUDPUnstableFallback bool TURNSEnabled bool + ParticipantListener types.LocalParticipantListener ParticipantHelper types.LocalParticipantHelper DisableSupervisor bool ReconnectOnPublicationError bool @@ -228,8 +228,9 @@ type ParticipantImpl struct { params ParticipantParams - participantHelper atomic.Value // types.LocalParticipantHelper - id atomic.Value // types.ParticipantID + participantListener atomic.Pointer[types.LocalParticipantListener] + participantHelper atomic.Value // types.LocalParticipantHelper + id atomic.Value // types.ParticipantID isClosed atomic.Bool closeReason atomic.Value // types.ParticipantCloseReason @@ -295,25 +296,6 @@ type ParticipantImpl struct { dirty atomic.Bool version atomic.Uint32 - // callbacks & handlers - onTrackPublished func(types.Participant, types.MediaTrack) - onTrackUpdated func(types.Participant, types.MediaTrack) - onTrackUnpublished func(types.Participant, types.MediaTrack) - onStateChange func(p types.LocalParticipant) - onSubscriberReady func(p types.LocalParticipant) - onMigrateStateChange func(p types.LocalParticipant, migrateState types.MigrateState) - onParticipantUpdate func(types.LocalParticipant) - onDataPacket func(types.LocalParticipant, livekit.DataPacket_Kind, *livekit.DataPacket) - onDataMessage func(types.LocalParticipant, []byte) - onDataTrackMessage func(types.LocalParticipant, []byte, *datatrack.Packet) - onMetrics func(types.Participant, *livekit.DataPacket) - onUpdateSubscriptions func(types.LocalParticipant, []livekit.TrackID, []*livekit.ParticipantTracks, bool) - onUpdateSubscriptionPermission func(types.LocalParticipant, *livekit.SubscriptionPermission) error - onUpdateDataSubscriptions func(types.LocalParticipant, *livekit.UpdateDataSubscription) - onSyncState func(types.LocalParticipant, *livekit.SyncState) error - onSimulateScenario func(types.LocalParticipant, *livekit.SimulateScenario) error - onLeave func(types.LocalParticipant, types.ParticipantCloseReason) - migrateState atomic.Value // types.MigrateState migratedTracksPublishedFuse core.Fuse @@ -391,6 +373,7 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) { params.Reporter, ) p.reliableDataInfo.lastPubReliableSeq.Store(params.LastPubReliableSeq) + p.setListener(params.ParticipantListener) p.participantHelper.Store(params.ParticipantHelper) if !params.DisableSupervisor { p.supervisor = supervisor.NewParticipantSupervisor(supervisor.ParticipantSupervisorParams{Logger: params.Logger}) @@ -443,6 +426,29 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) { return p, nil } +func (p *ParticipantImpl) setListener(listener types.LocalParticipantListener) { + if listener == nil { + p.participantListener.Store(nil) + return + } + p.participantListener.Store(&listener) +} + +func (p *ParticipantImpl) listener() types.LocalParticipantListener { + if l := p.participantListener.Load(); l != nil { + return *l + } + return &types.NullLocalParticipantListener{} +} + +func (p *ParticipantImpl) GetParticipantListener() types.ParticipantListener { + return p.listener() +} + +func (p *ParticipantImpl) ClearParticipantListener() { + p.setListener(nil) +} + func (p *ParticipantImpl) GetCountry() string { return p.params.Country } @@ -668,13 +674,11 @@ func (p *ParticipantImpl) SetName(name string) { p.grants.Store(grants) p.dirty.Store(true) - onParticipantUpdate := p.onParticipantUpdate onClaimsChanged := p.onClaimsChanged p.lock.Unlock() - if onParticipantUpdate != nil { - onParticipantUpdate(p) - } + p.listener().OnParticipantUpdate(p) + if onClaimsChanged != nil { onClaimsChanged(p) } @@ -695,13 +699,11 @@ func (p *ParticipantImpl) SetMetadata(metadata string) { p.requireBroadcast = p.requireBroadcast || metadata != "" p.dirty.Store(true) - onParticipantUpdate := p.onParticipantUpdate onClaimsChanged := p.onClaimsChanged p.lock.Unlock() - if onParticipantUpdate != nil { - onParticipantUpdate(p) - } + p.listener().OnParticipantUpdate(p) + if onClaimsChanged != nil { onClaimsChanged(p) } @@ -732,13 +734,11 @@ func (p *ParticipantImpl) SetAttributes(attrs map[string]string) { p.requireBroadcast = true // already checked above p.dirty.Store(true) - onParticipantUpdate := p.onParticipantUpdate onClaimsChanged := p.onClaimsChanged p.lock.Unlock() - if onParticipantUpdate != nil { - onParticipantUpdate(p) - } + p.listener().OnParticipantUpdate(p) + if onClaimsChanged != nil { onClaimsChanged(p) } @@ -770,7 +770,6 @@ func (p *ParticipantImpl) SetPermission(permission *livekit.ParticipantPermissio canPublish := grants.Video.GetCanPublish() canSubscribe := grants.Video.GetCanSubscribe() - onParticipantUpdate := p.onParticipantUpdate onClaimsChanged := p.onClaimsChanged isPublisher := canPublish && p.TransportManager.IsPublisherEstablished() @@ -803,9 +802,8 @@ func (p *ParticipantImpl) SetPermission(permission *livekit.ParticipantPermissio // update isPublisher attribute p.isPublisher.Store(isPublisher) - if onParticipantUpdate != nil { - onParticipantUpdate(p) - } + p.listener().OnParticipantUpdate(p) + if onClaimsChanged != nil { onClaimsChanged(p) } @@ -908,194 +906,6 @@ func (p *ParticipantImpl) TelemetryGuard() *telemetry.ReferenceGuard { return p.telemetryGuard } -// callbacks for clients - -func (p *ParticipantImpl) OnTrackPublished(callback func(types.Participant, types.MediaTrack)) { - p.lock.Lock() - p.onTrackPublished = callback - p.lock.Unlock() -} - -func (p *ParticipantImpl) getOnTrackPublished() func(types.Participant, types.MediaTrack) { - p.lock.RLock() - defer p.lock.RUnlock() - return p.onTrackPublished -} - -func (p *ParticipantImpl) OnTrackUnpublished(callback func(types.Participant, types.MediaTrack)) { - p.lock.Lock() - p.onTrackUnpublished = callback - p.lock.Unlock() -} - -func (p *ParticipantImpl) getOnTrackUnpublished() func(types.Participant, types.MediaTrack) { - p.lock.RLock() - defer p.lock.RUnlock() - return p.onTrackUnpublished -} - -func (p *ParticipantImpl) OnStateChange(callback func(p types.LocalParticipant)) { - p.lock.Lock() - p.onStateChange = callback - p.lock.Unlock() -} - -func (p *ParticipantImpl) getOnStateChange() func(p types.LocalParticipant) { - p.lock.RLock() - defer p.lock.RUnlock() - return p.onStateChange -} - -func (p *ParticipantImpl) OnSubscriberReady(callback func(p types.LocalParticipant)) { - p.lock.Lock() - p.onSubscriberReady = callback - p.lock.Unlock() -} - -func (p *ParticipantImpl) getOnSubscriberReady() func(p types.LocalParticipant) { - p.lock.RLock() - defer p.lock.RUnlock() - return p.onSubscriberReady -} - -func (p *ParticipantImpl) OnMigrateStateChange(callback func(p types.LocalParticipant, state types.MigrateState)) { - p.lock.Lock() - p.onMigrateStateChange = callback - p.lock.Unlock() -} - -func (p *ParticipantImpl) getOnMigrateStateChange() func(p types.LocalParticipant, state types.MigrateState) { - p.lock.RLock() - defer p.lock.RUnlock() - return p.onMigrateStateChange -} - -func (p *ParticipantImpl) OnTrackUpdated(callback func(types.Participant, types.MediaTrack)) { - p.lock.Lock() - p.onTrackUpdated = callback - p.lock.Unlock() -} - -func (p *ParticipantImpl) getOnTrackUpdated() func(types.Participant, types.MediaTrack) { - p.lock.RLock() - defer p.lock.RUnlock() - return p.onTrackUpdated -} - -func (p *ParticipantImpl) OnParticipantUpdate(callback func(types.LocalParticipant)) { - p.lock.Lock() - p.onParticipantUpdate = callback - p.lock.Unlock() -} - -func (p *ParticipantImpl) OnDataPacket(callback func(types.LocalParticipant, livekit.DataPacket_Kind, *livekit.DataPacket)) { - p.lock.Lock() - p.onDataPacket = callback - p.lock.Unlock() -} - -func (p *ParticipantImpl) getOnDataPacket() func(types.LocalParticipant, livekit.DataPacket_Kind, *livekit.DataPacket) { - p.lock.RLock() - defer p.lock.RUnlock() - return p.onDataPacket -} - -func (p *ParticipantImpl) OnDataMessage(callback func(types.LocalParticipant, []byte)) { - p.lock.Lock() - p.onDataMessage = callback - p.lock.Unlock() -} - -func (p *ParticipantImpl) getOnDataMessage() func(types.LocalParticipant, []byte) { - p.lock.RLock() - defer p.lock.RUnlock() - return p.onDataMessage -} - -func (p *ParticipantImpl) OnDataTrackMessage(callback func(types.LocalParticipant, []byte, *datatrack.Packet)) { - p.lock.Lock() - p.onDataTrackMessage = callback - p.lock.Unlock() -} - -func (p *ParticipantImpl) getOnDataTrackMessage() func(types.LocalParticipant, []byte, *datatrack.Packet) { - p.lock.RLock() - defer p.lock.RUnlock() - return p.onDataTrackMessage -} - -func (p *ParticipantImpl) OnMetrics(callback func(types.Participant, *livekit.DataPacket)) { - p.lock.Lock() - p.onMetrics = callback - p.lock.Unlock() -} - -func (p *ParticipantImpl) getOnMetrics() func(types.Participant, *livekit.DataPacket) { - p.lock.RLock() - defer p.lock.RUnlock() - return p.onMetrics -} - -func (p *ParticipantImpl) OnUpdateSubscriptions(callback func(types.LocalParticipant, []livekit.TrackID, []*livekit.ParticipantTracks, bool)) { - p.lock.Lock() - p.onUpdateSubscriptions = callback - p.lock.Unlock() -} - -func (p *ParticipantImpl) getOnUpdateSubscriptions() func(types.LocalParticipant, []livekit.TrackID, []*livekit.ParticipantTracks, bool) { - p.lock.RLock() - defer p.lock.RUnlock() - return p.onUpdateSubscriptions -} - -func (p *ParticipantImpl) OnUpdateSubscriptionPermission(callback func(types.LocalParticipant, *livekit.SubscriptionPermission) error) { - p.lock.Lock() - p.onUpdateSubscriptionPermission = callback - p.lock.Unlock() -} - -func (p *ParticipantImpl) getOnUpdateSubscriptionPermission() func(types.LocalParticipant, *livekit.SubscriptionPermission) error { - p.lock.RLock() - defer p.lock.RUnlock() - return p.onUpdateSubscriptionPermission -} - -func (p *ParticipantImpl) OnSyncState(callback func(types.LocalParticipant, *livekit.SyncState) error) { - p.lock.Lock() - p.onSyncState = callback - p.lock.Unlock() -} - -func (p *ParticipantImpl) getOnSyncState() func(types.LocalParticipant, *livekit.SyncState) error { - p.lock.RLock() - defer p.lock.RUnlock() - return p.onSyncState -} - -func (p *ParticipantImpl) OnSimulateScenario(callback func(types.LocalParticipant, *livekit.SimulateScenario) error) { - p.lock.Lock() - p.onSimulateScenario = callback - p.lock.Unlock() -} - -func (p *ParticipantImpl) getOnSimulateScenario() func(types.LocalParticipant, *livekit.SimulateScenario) error { - p.lock.RLock() - defer p.lock.RUnlock() - return p.onSimulateScenario -} - -func (p *ParticipantImpl) OnLeave(callback func(types.LocalParticipant, types.ParticipantCloseReason)) { - p.lock.Lock() - p.onLeave = callback - p.lock.Unlock() -} - -func (p *ParticipantImpl) getOnLeave() func(types.LocalParticipant, types.ParticipantCloseReason) { - p.lock.RLock() - defer p.lock.RUnlock() - return p.onLeave -} - func (p *ParticipantImpl) AddOnClose(key string, callback func(types.LocalParticipant)) { if p.isClosed.Load() { go callback(p) @@ -1315,9 +1125,7 @@ func (p *ParticipantImpl) HandleOffer(sd *livekit.SessionDescription) error { } if p.params.UseOneShotSignallingMode { - if onSubscriberReady := p.getOnSubscriberReady(); onSubscriberReady != nil { - go onSubscriberReady(p) - } + go p.listener().OnSubscriberReady(p) } p.handlePendingRemoteTracks() @@ -1784,9 +1592,7 @@ func (p *ParticipantImpl) SetMigrateState(s types.MigrateState) { <-p.migratedTracksPublishedFuse.Watch() } - if onMigrateStateChange := p.getOnMigrateStateChange(); onMigrateStateChange != nil { - onMigrateStateChange(p, s) - } + p.listener().OnMigrateStateChange(p, s) }() } @@ -2171,9 +1977,7 @@ func (p *ParticipantImpl) setupUpTrackManager() { p.UpTrackManager.OnPublishedTrackUpdated(func(track types.MediaTrack) { p.dirty.Store(true) - if onTrackUpdated := p.getOnTrackUpdated(); onTrackUpdated != nil { - onTrackUpdated(p, track) - } + p.listener().OnTrackUpdated(p, track) }) p.UpTrackManager.OnUpTrackManagerClose(p.onUpTrackManagerClose) @@ -2219,14 +2023,12 @@ func (p *ParticipantImpl) MetricsCollectorTimeToCollectMetrics() { } func (p *ParticipantImpl) MetricsCollectorBatchReady(mb *livekit.MetricsBatch) { - if onMetrics := p.getOnMetrics(); onMetrics != nil { - onMetrics(p, &livekit.DataPacket{ - ParticipantIdentity: string(p.Identity()), - Value: &livekit.DataPacket_Metrics{ - Metrics: mb, - }, - }) - } + p.listener().OnMetrics(p, &livekit.DataPacket{ + ParticipantIdentity: string(p.Identity()), + Value: &livekit.DataPacket_Metrics{ + Metrics: mb, + }, + }) } func (p *ParticipantImpl) MetricsReporterBatchReady(mb *livekit.MetricsBatch) { @@ -2286,9 +2088,7 @@ func (p *ParticipantImpl) updateState(state livekit.ParticipantInfo_State) { p.params.Logger.Debugw("updating participant state", "state", state.String()) p.dirty.Store(true) - if onStateChange := p.getOnStateChange(); onStateChange != nil { - go onStateChange(p) - } + go p.listener().OnStateChange(p) if state == livekit.ParticipantInfo_DISCONNECTED && oldState == livekit.ParticipantInfo_ACTIVE { p.disconnectedAt.Store(pointer.To(time.Now())) @@ -2309,13 +2109,7 @@ func (p *ParticipantImpl) setIsPublisher(isPublisher bool) { // trigger update as well if participant is already fully connected if p.State() == livekit.ParticipantInfo_ACTIVE { - p.lock.RLock() - onParticipantUpdate := p.onParticipantUpdate - p.lock.RUnlock() - - if onParticipantUpdate != nil { - onParticipantUpdate(p) - } + p.listener().OnParticipantUpdate(p) } } @@ -2434,9 +2228,7 @@ func (p *ParticipantImpl) onMediaTrack(rtcTrack *webrtc.TrackRemote, rtpReceiver ) if !isNewTrack && !publishedTrack.HasPendingCodec() && p.IsReady() { - if onTrackUpdated := p.getOnTrackUpdated(); onTrackUpdated != nil { - onTrackUpdated(p, publishedTrack) - } + p.listener().OnTrackUpdated(p, publishedTrack) } } @@ -2656,14 +2448,10 @@ func (p *ParticipantImpl) handleReceivedDataMessage(kind livekit.DataPacket_Kind } if shouldForwardData { - if onDataPacket := p.getOnDataPacket(); onDataPacket != nil { - onDataPacket(p, kind, dp) - } + p.listener().OnDataPacket(p, kind, dp) } if shouldForwardMetrics { - if onMetrics := p.getOnMetrics(); onMetrics != nil { - onMetrics(p, dp) - } + p.listener().OnMetrics(p, dp) } } @@ -2674,9 +2462,7 @@ func (p *ParticipantImpl) onReceivedDataMessageUnlabeled(data []byte) { p.dataChannelStats.AddBytes(uint64(len(data)), false) - if onDataMessage := p.getOnDataMessage(); onDataMessage != nil { - onDataMessage(p, data) - } + p.listener().OnDataMessage(p, data) } func (p *ParticipantImpl) onICECandidate(c *webrtc.ICECandidate, target livekit.SignalTarget) error { @@ -3533,18 +3319,14 @@ func (p *ParticipantImpl) addMediaTrack(signalCid string, ti *livekit.TrackInfo) "expectedToResume", isExpectedToResume, "track", logger.Proto(ti), ) - if onTrackUnpublished := p.getOnTrackUnpublished(); onTrackUnpublished != nil { - onTrackUnpublished(p, mt) - } + p.listener().OnTrackUnpublished(p, mt) }) return mt } func (p *ParticipantImpl) handleTrackPublished(track types.MediaTrack, isMigrated bool) { - if onTrackPublished := p.getOnTrackPublished(); onTrackPublished != nil { - onTrackPublished(p, track) - } + p.listener().OnTrackPublished(p, track) // send webhook after callbacks are complete, persistence and state handling happens // in `onTrackPublished` cb @@ -4196,6 +3978,7 @@ func (p *ParticipantImpl) MoveToRoom(params types.MoveToRoomParams) { p.params.LoggerResolver.Reset() p.params.ReporterResolver.Reset() + p.setListener(params.Listener) p.participantHelper.Store(params.Helper) p.SubscriptionManager.ClearAllSubscriptions() p.id.Store(params.ParticipantID) @@ -4220,39 +4003,23 @@ func (p *ParticipantImpl) HandleUpdateSubscriptions( participantTracks []*livekit.ParticipantTracks, subscribe bool, ) { - if onUpdateSubscriptions := p.getOnUpdateSubscriptions(); onUpdateSubscriptions != nil { - onUpdateSubscriptions(p, trackIDs, participantTracks, subscribe) - } + p.listener().OnUpdateSubscriptions(p, trackIDs, participantTracks, subscribe) } func (p *ParticipantImpl) HandleUpdateSubscriptionPermission(subscriptionPermission *livekit.SubscriptionPermission) error { - if onUpdateSubscriptionPermission := p.getOnUpdateSubscriptionPermission(); onUpdateSubscriptionPermission != nil { - return onUpdateSubscriptionPermission(p, subscriptionPermission) - } - - return errors.New("no handler") + return p.listener().OnUpdateSubscriptionPermission(p, subscriptionPermission) } func (p *ParticipantImpl) HandleSyncState(syncState *livekit.SyncState) error { - if onSyncState := p.getOnSyncState(); onSyncState != nil { - return onSyncState(p, syncState) - } - - return errors.New("no handler") + return p.listener().OnSyncState(p, syncState) } func (p *ParticipantImpl) HandleSimulateScenario(simulateScenario *livekit.SimulateScenario) error { - if onSimulateScenario := p.getOnSimulateScenario(); onSimulateScenario != nil { - return onSimulateScenario(p, simulateScenario) - } - - return errors.New("no handler") + return p.listener().OnSimulateScenario(p, simulateScenario) } func (p *ParticipantImpl) HandleLeaveRequest(reason types.ParticipantCloseReason) { - if onLeave := p.getOnLeave(); onLeave != nil { - onLeave(p, reason) - } + p.listener().OnLeave(p, reason) } func (p *ParticipantImpl) HandleSignalMessage(msg proto.Message) error { diff --git a/pkg/rtc/participant_data_track.go b/pkg/rtc/participant_data_track.go index 63e6e1a36..f2ecb5353 100644 --- a/pkg/rtc/participant_data_track.go +++ b/pkg/rtc/participant_data_track.go @@ -16,25 +16,12 @@ package rtc import ( "github.com/livekit/livekit-server/pkg/rtc/datatrack" - "github.com/livekit/livekit-server/pkg/rtc/types" "github.com/livekit/protocol/livekit" "github.com/livekit/protocol/logger" "github.com/livekit/protocol/utils" "github.com/livekit/protocol/utils/guid" ) -func (p *ParticipantImpl) OnUpdateDataSubscriptions(callback func(types.LocalParticipant, *livekit.UpdateDataSubscription)) { - p.lock.Lock() - p.onUpdateDataSubscriptions = callback - p.lock.Unlock() -} - -func (p *ParticipantImpl) getOnUpdateDataSubscriptions() func(types.LocalParticipant, *livekit.UpdateDataSubscription) { - p.lock.RLock() - defer p.lock.RUnlock() - return p.onUpdateDataSubscriptions -} - func (p *ParticipantImpl) HandlePublishDataTrackRequest(req *livekit.PublishDataTrackRequest) { if !p.CanPublishData() || !p.params.EnableDataTracks { p.pubLogger.Warnw("no permission to publish data track", nil, "req", logger.Proto(req)) @@ -138,9 +125,7 @@ func (p *ParticipantImpl) HandleUnpublishDataTrackRequest(req *livekit.Unpublish } func (p *ParticipantImpl) HandleUpdateDataSubscription(req *livekit.UpdateDataSubscription) { - if onUpdateDataSubscriptions := p.getOnUpdateDataSubscriptions(); onUpdateDataSubscriptions != nil { - onUpdateDataSubscriptions(p, req) - } + p.listener().OnUpdateDataSubscriptions(p, req) } func (p *ParticipantImpl) onReceivedDataTrackMessage(data []byte) { @@ -152,7 +137,5 @@ func (p *ParticipantImpl) onReceivedDataTrackMessage(data []byte) { p.UpDataTrackManager.HandleReceivedDataTrackMessage(data, &packet) - if onDataTrackMessage := p.getOnDataTrackMessage(); onDataTrackMessage != nil { - onDataTrackMessage(p, data, &packet) - } + p.listener().OnDataTrackMessage(p, data, &packet) } diff --git a/pkg/rtc/participant_internal_test.go b/pkg/rtc/participant_internal_test.go index bf99850aa..2f4a0dbfa 100644 --- a/pkg/rtc/participant_internal_test.go +++ b/pkg/rtc/participant_internal_test.go @@ -84,10 +84,10 @@ func TestTrackPublishing(t *testing.T) { track.IDReturns("id") published := false updated := false - p.OnTrackUpdated(func(p types.Participant, track types.MediaTrack) { + p.listener().(*typesfakes.FakeLocalParticipantListener).OnTrackUpdatedCalls(func(p types.Participant, track types.MediaTrack) { updated = true }) - p.OnTrackPublished(func(p types.Participant, track types.MediaTrack) { + p.listener().(*typesfakes.FakeLocalParticipantListener).OnTrackPublishedCalls(func(p types.Participant, track types.MediaTrack) { published = true }) p.UpTrackManager.AddPublishedTrack(track) @@ -814,6 +814,7 @@ func newParticipantForTestWithOpts(identity livekit.ParticipantIdentity, opts *p Reporter: roomobs.NewNoopParticipantSessionReporter(), Telemetry: &telemetryfakes.FakeTelemetryService{}, VersionGenerator: utils.NewDefaultTimedVersionGenerator(), + ParticipantListener: &typesfakes.FakeLocalParticipantListener{}, ParticipantHelper: &typesfakes.FakeLocalParticipantHelper{}, }) p.isPublisher.Store(opts.publisher) diff --git a/pkg/rtc/room.go b/pkg/rtc/room.go index 4ec597571..85a1477c9 100644 --- a/pkg/rtc/room.go +++ b/pkg/rtc/room.go @@ -39,6 +39,7 @@ import ( "github.com/livekit/livekit-server/pkg/agent" "github.com/livekit/livekit-server/pkg/config" "github.com/livekit/livekit-server/pkg/routing" + "github.com/livekit/livekit-server/pkg/rtc/datatrack" "github.com/livekit/livekit-server/pkg/rtc/types" "github.com/livekit/livekit-server/pkg/sfu" "github.com/livekit/livekit-server/pkg/sfu/buffer" @@ -145,6 +146,9 @@ type Room struct { userPacketDeduper *UserPacketDeduper dataMessageCache *utils.TimeSizeCache[types.DataMessageCache] + + onStateChangeMu sync.Mutex + localParticipantListener types.LocalParticipantListener } type ParticipantOptions struct { @@ -280,6 +284,7 @@ func NewRoom( MaxSize: dataMessageCacheSize, }), } + r.localParticipantListener = &localParticipantListener{room: r} if r.protoRoom.EmptyTimeout == 0 { r.protoRoom.EmptyTimeout = roomConfig.EmptyTimeout @@ -460,111 +465,6 @@ func (r *Room) Join( r.joinedAt.Store(time.Now().Unix()) } - var onStateChangeMu sync.Mutex - participant.OnStateChange(func(p types.LocalParticipant) { - if r.onParticipantChanged != nil { - r.onParticipantChanged(p) - } - r.broadcastParticipantState(p, broadcastOptions{skipSource: true}) - - onStateChangeMu.Lock() - defer onStateChangeMu.Unlock() - if state := p.State(); state == livekit.ParticipantInfo_ACTIVE { - // subscribe participant to existing published tracks - r.subscribeToExistingTracks(p, false) - - connectTime := time.Since(p.ConnectedAt()) - meta := &livekit.AnalyticsClientMeta{ - ClientConnectTime: uint32(connectTime.Milliseconds()), - } - infos := p.GetICEConnectionInfo() - var connectionType roomobs.ConnectionType - for _, info := range infos { - if info.Type != types.ICEConnectionTypeUnknown { - meta.ConnectionType = info.Type.String() - connectionType = info.Type.ReporterType() - break - } - } - r.telemetry.ParticipantActive(context.Background(), - r.ToProto(), - p.ToProto(), - meta, - false, - participant.TelemetryGuard(), - ) - - participant.GetReporter().Tx(func(tx roomobs.ParticipantSessionTx) { - tx.ReportClientConnectTime(uint16(connectTime.Milliseconds())) - tx.ReportConnectResult(roomobs.ConnectionResultSuccess) - tx.ReportConnectionType(connectionType) - }) - - fields := append( - connectionDetailsFields(infos), - "clientInfo", logger.Proto(sutils.ClientInfoWithoutAddress(p.GetClientInfo())), - "connectTime", connectTime, - ) - p.GetLogger().Infow("participant active", fields...) - } else if state == livekit.ParticipantInfo_DISCONNECTED { - // remove participant from room - go r.RemoveParticipant(p.Identity(), p.ID(), p.CloseReason()) - } - }) - participant.OnSubscriberReady(func(p types.LocalParticipant) { - r.subscribeToExistingTracks(p, false) - }) - // it's important to set this before connection, we don't want to miss out on any published tracks - participant.OnTrackPublished(r.onTrackPublished) - participant.OnTrackUpdated(r.onTrackUpdated) - participant.OnTrackUnpublished(r.onTrackUnpublished) - participant.OnDataTrackPublished(r.onDataTrackPublished) - participant.OnDataTrackUnpublished(r.onDataTrackUnpublished) - participant.OnParticipantUpdate(r.onParticipantUpdate) - participant.OnDataPacket(r.onDataPacket) - participant.OnDataMessage(r.onDataMessage) - participant.OnMetrics(r.onMetrics) - participant.OnSubscribeStatusChanged(func(publisherID livekit.ParticipantID, subscribed bool) { - if subscribed { - pub := r.GetParticipantByID(publisherID) - if pub != nil && pub.State() == livekit.ParticipantInfo_ACTIVE { - // when a participant subscribes to another participant, - // send speaker update if the subscribed to participant is active. - level, active := pub.GetAudioLevel() - if active { - _ = participant.SendSpeakerUpdate([]*livekit.SpeakerInfo{ - { - Sid: string(pub.ID()), - Level: float32(level), - Active: active, - }, - }, false) - } - - if cq := pub.GetConnectionQuality(); cq != nil { - update := &livekit.ConnectionQualityUpdate{} - update.Updates = append(update.Updates, cq) - _ = participant.SendConnectionQualityUpdate(update) - } - } - } else { - // no longer subscribed to the publisher, clear speaker status - _ = participant.SendSpeakerUpdate([]*livekit.SpeakerInfo{ - { - Sid: string(publisherID), - Level: 0, - Active: false, - }, - }, true) - } - }) - participant.OnUpdateSubscriptions(r.onUpdateSubscriptions) - participant.OnUpdateSubscriptionPermission(r.onUpdateSubscriptionPermission) - participant.OnUpdateDataSubscriptions(r.onUpdateDataSubscriptions) - participant.OnSyncState(r.onSyncState) - participant.OnSimulateScenario(r.onSimulateScenario) - participant.OnLeave(r.onLeave) - r.launchTargetAgents(maps.Values(r.agentDispatches), participant, livekit.JobType_JT_PARTICIPANT) r.logger.Debugw( @@ -1291,7 +1191,7 @@ func (r *Room) onDataTrackUnpublished(p types.Participant, dt types.DataTrack) { } } -func (r *Room) onParticipantUpdate(p types.LocalParticipant) { +func (r *Room) onParticipantUpdate(p types.Participant) { r.protoProxy.MarkDirty(false) // immediately notify when permissions or metadata changed r.broadcastParticipantState(p, broadcastOptions{immediate: true}) @@ -1300,6 +1200,59 @@ func (r *Room) onParticipantUpdate(p types.LocalParticipant) { } } +func (r *Room) onStateChange(p types.LocalParticipant) { + if r.onParticipantChanged != nil { + r.onParticipantChanged(p) + } + r.broadcastParticipantState(p, broadcastOptions{skipSource: true}) + + r.onStateChangeMu.Lock() + defer r.onStateChangeMu.Unlock() + + switch p.State() { + case livekit.ParticipantInfo_ACTIVE: + // subscribe participant to existing published tracks + r.subscribeToExistingTracks(p, false) + + connectTime := time.Since(p.ConnectedAt()) + meta := &livekit.AnalyticsClientMeta{ + ClientConnectTime: uint32(connectTime.Milliseconds()), + } + infos := p.GetICEConnectionInfo() + var connectionType roomobs.ConnectionType + for _, info := range infos { + if info.Type != types.ICEConnectionTypeUnknown { + meta.ConnectionType = info.Type.String() + connectionType = info.Type.ReporterType() + break + } + } + r.telemetry.ParticipantActive(context.Background(), + r.ToProto(), + p.ToProto(), + meta, + false, + p.TelemetryGuard(), + ) + + p.GetReporter().Tx(func(tx roomobs.ParticipantSessionTx) { + tx.ReportClientConnectTime(uint16(connectTime.Milliseconds())) + tx.ReportConnectResult(roomobs.ConnectionResultSuccess) + tx.ReportConnectionType(connectionType) + }) + + fields := append( + connectionDetailsFields(infos), + "clientInfo", logger.Proto(sutils.ClientInfoWithoutAddress(p.GetClientInfo())), + "connectTime", connectTime, + ) + p.GetLogger().Infow("participant active", fields...) + + case livekit.ParticipantInfo_DISCONNECTED: + // remove participant from room + go r.RemoveParticipant(p.Identity(), p.ID(), p.CloseReason()) + } +} func (r *Room) onDataPacket(source types.LocalParticipant, kind livekit.DataPacket_Kind, dp *livekit.DataPacket) { if kind == livekit.DataPacket_RELIABLE && source != nil && dp.GetSequence() > 0 { data, err := proto.Marshal(dp) @@ -1325,6 +1278,41 @@ func (r *Room) onMetrics(source types.Participant, dp *livekit.DataPacket) { BroadcastMetricsForRoom(r, source, dp, r.logger) } +func (r *Room) onSubscribeStatusChanged(participant types.LocalParticipant, publisherID livekit.ParticipantID, subscribed bool) { + if subscribed { + pub := r.GetParticipantByID(publisherID) + if pub != nil && pub.State() == livekit.ParticipantInfo_ACTIVE { + // when a participant subscribes to another participant, + // send speaker update if the subscribed to participant is active. + level, active := pub.GetAudioLevel() + if active { + _ = participant.SendSpeakerUpdate([]*livekit.SpeakerInfo{ + { + Sid: string(pub.ID()), + Level: float32(level), + Active: active, + }, + }, false) + } + + if cq := pub.GetConnectionQuality(); cq != nil { + update := &livekit.ConnectionQualityUpdate{} + update.Updates = append(update.Updates, cq) + _ = participant.SendConnectionQualityUpdate(update) + } + } + } else { + // no longer subscribed to the publisher, clear speaker status + _ = participant.SendSpeakerUpdate([]*livekit.SpeakerInfo{ + { + Sid: string(publisherID), + Level: 0, + Active: false, + }, + }, true) + } +} + func (r *Room) onUpdateSubscriptions( participant types.LocalParticipant, trackIDs []livekit.TrackID, @@ -1456,24 +1444,7 @@ func (r *Room) RemoveParticipant( }() } - p.OnTrackUpdated(nil) - p.OnTrackPublished(nil) - p.OnTrackUnpublished(nil) - p.OnDataTrackPublished(nil) - p.OnDataTrackUnpublished(nil) - p.OnStateChange(nil) - p.OnSubscriberReady(nil) - p.OnParticipantUpdate(nil) - p.OnDataPacket(nil) - p.OnDataMessage(nil) - p.OnMetrics(nil) - p.OnSubscribeStatusChanged(nil) - p.OnUpdateSubscriptions(nil) - p.OnUpdateSubscriptionPermission(nil) - p.OnUpdateDataSubscriptions(nil) - p.OnSyncState(nil) - p.OnSimulateScenario(nil) - p.OnLeave(nil) + p.ClearParticipantListener() // close participant as well _ = p.Close(true, reason, false) @@ -1902,6 +1873,101 @@ func (r *Room) GetCachedReliableDataMessage(seqs map[livekit.ParticipantID]uint3 return msgs } +func (r *Room) LocalParticipantListener() types.LocalParticipantListener { + return r.localParticipantListener +} + +// ------------------------------------------------------------ + +var _ types.LocalParticipantListener = (*localParticipantListener)(nil) + +type localParticipantListener struct { + room *Room +} + +func (l *localParticipantListener) OnParticipantUpdate(p types.Participant) { + l.room.onParticipantUpdate(p) +} + +func (l *localParticipantListener) OnTrackPublished(p types.Participant, track types.MediaTrack) { + l.room.onTrackPublished(p, track) +} + +func (l *localParticipantListener) OnTrackUpdated(p types.Participant, track types.MediaTrack) { + l.room.onTrackUpdated(p, track) +} + +func (l *localParticipantListener) OnTrackUnpublished(p types.Participant, track types.MediaTrack) { + l.room.onTrackUnpublished(p, track) +} + +func (l *localParticipantListener) OnDataTrackPublished(p types.Participant, track types.DataTrack) { + l.room.onDataTrackPublished(p, track) +} + +func (l *localParticipantListener) OnDataTrackUnpublished(p types.Participant, track types.DataTrack) { + l.room.onDataTrackUnpublished(p, track) +} + +func (l *localParticipantListener) OnMetrics(p types.Participant, dp *livekit.DataPacket) { + l.room.onMetrics(p, dp) +} + +func (l *localParticipantListener) OnStateChange(p types.LocalParticipant) { + l.room.onStateChange(p) +} + +func (l *localParticipantListener) OnSubscriberReady(p types.LocalParticipant) { + l.room.subscribeToExistingTracks(p, false) +} + +func (l *localParticipantListener) OnMigrateStateChange(_p types.LocalParticipant, _migrateState types.MigrateState) { +} + +func (l *localParticipantListener) OnDataPacket(p types.LocalParticipant, kind livekit.DataPacket_Kind, dp *livekit.DataPacket) { + l.room.onDataPacket(p, kind, dp) +} + +func (l *localParticipantListener) OnDataMessage(p types.LocalParticipant, data []byte) { + l.room.onDataMessage(p, data) +} + +func (l *localParticipantListener) OnDataTrackMessage(_p types.LocalParticipant, _data []byte, _packet *datatrack.Packet) { +} + +func (l *localParticipantListener) OnSubscribeStatusChanged(p types.LocalParticipant, publisherID livekit.ParticipantID, subscribed bool) { + l.room.onSubscribeStatusChanged(p, publisherID, subscribed) +} + +func (l *localParticipantListener) OnUpdateSubscriptions( + p types.LocalParticipant, + trackIDs []livekit.TrackID, + participantTracks []*livekit.ParticipantTracks, + subscribe bool, +) { + l.room.onUpdateSubscriptions(p, trackIDs, participantTracks, subscribe) +} + +func (l *localParticipantListener) OnUpdateSubscriptionPermission(p types.LocalParticipant, subscriptionPermission *livekit.SubscriptionPermission) error { + return l.room.onUpdateSubscriptionPermission(p, subscriptionPermission) +} + +func (l *localParticipantListener) OnUpdateDataSubscriptions(p types.LocalParticipant, req *livekit.UpdateDataSubscription) { + l.room.onUpdateDataSubscriptions(p, req) +} + +func (l *localParticipantListener) OnSyncState(p types.LocalParticipant, state *livekit.SyncState) error { + return l.room.onSyncState(p, state) +} + +func (l *localParticipantListener) OnSimulateScenario(p types.LocalParticipant, simulateScenario *livekit.SimulateScenario) error { + return l.room.onSimulateScenario(p, simulateScenario) +} + +func (l *localParticipantListener) OnLeave(p types.LocalParticipant, closeReason types.ParticipantCloseReason) { + l.room.onLeave(p, closeReason) +} + // ------------------------------------------------------------ func BroadcastDataPacketForRoom( diff --git a/pkg/rtc/room_test.go b/pkg/rtc/room_test.go index 0cce9950b..646e8a193 100644 --- a/pkg/rtc/room_test.go +++ b/pkg/rtc/room_test.go @@ -90,7 +90,7 @@ func TestJoinedState(t *testing.T) { func TestRoomJoin(t *testing.T) { t.Run("joining returns existing participant data", func(t *testing.T) { rm := newRoomWithParticipants(t, testRoomOpts{num: numParticipants}) - pNew := NewMockParticipant("new", types.CurrentProtocol, false, false) + pNew := NewMockParticipant("new", types.CurrentProtocol, false, false, rm.LocalParticipantListener()) _ = rm.Join(pNew, nil, nil, iceServersForRoom) @@ -105,15 +105,14 @@ func TestRoomJoin(t *testing.T) { t.Run("subscribe to existing channels upon join", func(t *testing.T) { numExisting := 3 rm := newRoomWithParticipants(t, testRoomOpts{num: numExisting}) - p := NewMockParticipant("new", types.CurrentProtocol, false, false) + lpl := rm.LocalParticipantListener() + p := NewMockParticipant("new", types.CurrentProtocol, false, false, lpl) err := rm.Join(p, nil, &ParticipantOptions{AutoSubscribe: true}, iceServersForRoom) require.NoError(t, err) - stateChangeCB := p.OnStateChangeArgsForCall(0) - require.NotNil(t, stateChangeCB) p.StateReturns(livekit.ParticipantInfo_ACTIVE) - stateChangeCB(p) + lpl.OnStateChange(p) // it should become a subscriber when connectivity changes numTracks := 0 @@ -161,7 +160,7 @@ func TestRoomJoin(t *testing.T) { rm.lock.Lock() rm.protoRoom.MaxParticipants = 1 rm.lock.Unlock() - p := NewMockParticipant("second", types.ProtocolVersion(0), false, false) + p := NewMockParticipant("second", types.ProtocolVersion(0), false, false, rm.LocalParticipantListener()) err := rm.Join(p, nil, nil, iceServersForRoom) require.Equal(t, ErrMaxParticipantsExceeded, err) @@ -427,6 +426,8 @@ func TestRoomClosure(t *testing.T) { func TestNewTrack(t *testing.T) { t.Run("new track should be added to ready participants", func(t *testing.T) { rm := newRoomWithParticipants(t, testRoomOpts{num: 3}) + lpl := rm.LocalParticipantListener() + participants := rm.GetParticipants() p0 := participants[0].(*typesfakes.FakeLocalParticipant) p0.StateReturns(livekit.ParticipantInfo_JOINED) @@ -437,9 +438,8 @@ func TestNewTrack(t *testing.T) { // pub adds track track := NewMockTrack(livekit.TrackType_VIDEO, "webcam") - trackCB := pub.OnTrackPublishedArgsForCall(0) - require.NotNil(t, trackCB) - trackCB(pub, track) + lpl.OnTrackPublished(pub, track) + // only p1 should've been subscribed to require.Equal(t, 0, p0.SubscribeToTrackCallCount()) require.Equal(t, 1, p1.SubscribeToTrackCallCount()) @@ -528,6 +528,7 @@ func TestActiveSpeakers(t *testing.T) { t.Run("audio level is smoothed", func(t *testing.T) { rm := newRoomWithParticipants(t, testRoomOpts{num: 2, protocol: 3, audioSmoothIntervals: 3}) defer rm.Close(types.ParticipantCloseReasonNone) + participants := rm.GetParticipants() p := participants[0].(*typesfakes.FakeLocalParticipant) op := participants[1].(*typesfakes.FakeLocalParticipant) @@ -621,6 +622,9 @@ func TestDataChannel(t *testing.T) { t.Run(modeNames[mode], func(t *testing.T) { rm := newRoomWithParticipants(t, testRoomOpts{num: 3}) defer rm.Close(types.ParticipantCloseReasonNone) + + lpl := rm.LocalParticipantListener() + participants := rm.GetParticipants() p := participants[0].(*typesfakes.FakeLocalParticipant) @@ -641,7 +645,7 @@ func TestDataChannel(t *testing.T) { } encoded, _ := proto.Marshal(packetExp) - p.OnDataPacketArgsForCall(0)(p, packet.Kind, packet) + lpl.OnDataPacket(p, packet.Kind, packet) // ensure everyone has received the packet for _, op := range participants { @@ -664,6 +668,9 @@ func TestDataChannel(t *testing.T) { t.Run(modeNames[mode], func(t *testing.T) { rm := newRoomWithParticipants(t, testRoomOpts{num: 4}) defer rm.Close(types.ParticipantCloseReasonNone) + + lpl := rm.LocalParticipantListener() + participants := rm.GetParticipants() p := participants[0].(*typesfakes.FakeLocalParticipant) p1 := participants[1].(*typesfakes.FakeLocalParticipant) @@ -688,7 +695,7 @@ func TestDataChannel(t *testing.T) { } encoded, _ := proto.Marshal(packetExp) - p.OnDataPacketArgsForCall(0)(p, packet.Kind, packet) + lpl.OnDataPacket(p, packet.Kind, packet) // only p1 should receive the data for _, op := range participants { @@ -707,6 +714,7 @@ func TestDataChannel(t *testing.T) { t.Run("publishing disallowed", func(t *testing.T) { rm := newRoomWithParticipants(t, testRoomOpts{num: 2}) defer rm.Close(types.ParticipantCloseReasonNone) + participants := rm.GetParticipants() p := participants[0].(*typesfakes.FakeLocalParticipant) p.CanPublishDataReturns(false) @@ -720,7 +728,8 @@ func TestDataChannel(t *testing.T) { }, } if p.CanPublishData() { - p.OnDataPacketArgsForCall(0)(p, packet.Kind, &packet) + lpl := rm.LocalParticipantListener() + lpl.OnDataPacket(p, packet.Kind, &packet) } // no one should've been sent packet @@ -736,7 +745,7 @@ func TestHiddenParticipants(t *testing.T) { rm := newRoomWithParticipants(t, testRoomOpts{num: 2, numHidden: 1}) defer rm.Close(types.ParticipantCloseReasonNone) - pNew := NewMockParticipant("new", types.CurrentProtocol, false, false) + pNew := NewMockParticipant("new", types.CurrentProtocol, false, false, rm.LocalParticipantListener()) rm.Join(pNew, nil, nil, iceServersForRoom) // expect new participant to get a JoinReply @@ -750,15 +759,14 @@ func TestHiddenParticipants(t *testing.T) { t.Run("hidden participant subscribes to tracks", func(t *testing.T) { rm := newRoomWithParticipants(t, testRoomOpts{num: 2}) - hidden := NewMockParticipant("hidden", types.CurrentProtocol, true, false) + lpl := rm.LocalParticipantListener() + hidden := NewMockParticipant("hidden", types.CurrentProtocol, true, false, lpl) err := rm.Join(hidden, nil, &ParticipantOptions{AutoSubscribe: true}, iceServersForRoom) require.NoError(t, err) - stateChangeCB := hidden.OnStateChangeArgsForCall(0) - require.NotNil(t, stateChangeCB) hidden.StateReturns(livekit.ParticipantInfo_ACTIVE) - stateChangeCB(hidden) + lpl.OnStateChange(hidden) require.Eventually(t, func() bool { return hidden.SubscribeToTrackCallCount() == 2 }, 5*time.Second, 10*time.Millisecond) }) @@ -772,7 +780,7 @@ func TestRoomUpdate(t *testing.T) { p1 := rm.GetParticipants()[0].(*typesfakes.FakeLocalParticipant) require.Equal(t, 0, p1.SendRoomUpdateCallCount()) - p2 := NewMockParticipant("p2", types.CurrentProtocol, false, false) + p2 := NewMockParticipant("p2", types.CurrentProtocol, false, false, rm.LocalParticipantListener()) require.NoError(t, rm.Join(p2, nil, nil, iceServersForRoom)) // p1 should have received an update @@ -838,7 +846,7 @@ func newRoomWithParticipants(t *testing.T, opts testRoomOpts) *Room { ) for i := 0; i < opts.num+opts.numHidden; i++ { identity := livekit.ParticipantIdentity(fmt.Sprintf("p%d", i)) - participant := NewMockParticipant(identity, opts.protocol, i >= opts.num, true) + participant := NewMockParticipant(identity, opts.protocol, i >= opts.num, true, rm.LocalParticipantListener()) err := rm.Join(participant, nil, &ParticipantOptions{AutoSubscribe: true}, iceServersForRoom) require.NoError(t, err) participant.StateReturns(livekit.ParticipantInfo_ACTIVE) diff --git a/pkg/rtc/testutils.go b/pkg/rtc/testutils.go index 904956873..085582113 100644 --- a/pkg/rtc/testutils.go +++ b/pkg/rtc/testutils.go @@ -25,7 +25,13 @@ import ( "github.com/livekit/livekit-server/pkg/rtc/types/typesfakes" ) -func NewMockParticipant(identity livekit.ParticipantIdentity, protocol types.ProtocolVersion, hidden bool, publisher bool) *typesfakes.FakeLocalParticipant { +func NewMockParticipant( + identity livekit.ParticipantIdentity, + protocol types.ProtocolVersion, + hidden bool, + publisher bool, + participantListener types.LocalParticipantListener, +) *typesfakes.FakeLocalParticipant { p := &typesfakes.FakeLocalParticipant{} sid := guid.New(utils.ParticipantPrefix) p.IDReturns(livekit.ParticipantID(sid)) @@ -50,22 +56,10 @@ func NewMockParticipant(identity livekit.ParticipantIdentity, protocol types.Pro }, utils.TimedVersion(0)) p.SetMetadataCalls(func(m string) { - var f func(participant types.LocalParticipant) - if p.OnParticipantUpdateCallCount() > 0 { - f = p.OnParticipantUpdateArgsForCall(p.OnParticipantUpdateCallCount() - 1) - } - if f != nil { - f(p) - } + participantListener.OnParticipantUpdate(p) }) updateTrack := func() { - var f func(participant types.Participant, track types.MediaTrack) - if p.OnTrackUpdatedCallCount() > 0 { - f = p.OnTrackUpdatedArgsForCall(p.OnTrackUpdatedCallCount() - 1) - } - if f != nil { - f(p, NewMockTrack(livekit.TrackType_VIDEO, "testcam")) - } + participantListener.OnTrackUpdated(p, NewMockTrack(livekit.TrackType_VIDEO, "testcam")) } p.SetTrackMutedCalls(func(mute *livekit.MuteTrackRequest, fromServer bool) *livekit.TrackInfo { diff --git a/pkg/rtc/types/interfaces.go b/pkg/rtc/types/interfaces.go index 76bcbb5aa..cc5bb4a9c 100644 --- a/pkg/rtc/types/interfaces.go +++ b/pkg/rtc/types/interfaces.go @@ -329,17 +329,9 @@ type Participant interface { DebugInfo() map[string]any - // OnTrackPublished - remote added a track - OnTrackPublished(func(Participant, MediaTrack)) - // OnTrackUpdated - one of its publishedTracks changed in status - OnTrackUpdated(callback func(Participant, MediaTrack)) - // OnTrackUnpublished - a track was unpublished - OnTrackUnpublished(callback func(Participant, MediaTrack)) - OnDataTrackPublished(func(Participant, DataTrack)) - OnDataTrackUnpublished(func(Participant, DataTrack)) - OnMetrics(callback func(Participant, *livekit.DataPacket)) - HandleReceivedDataTrackMessage([]byte, *datatrack.Packet) + + GetParticipantListener() ParticipantListener } // ------------------------------------------------------- @@ -352,6 +344,7 @@ type AddTrackParams struct { type MoveToRoomParams struct { RoomName livekit.RoomName ParticipantID livekit.ParticipantID + Listener LocalParticipantListener Helper LocalParticipantHelper } @@ -485,28 +478,8 @@ type LocalParticipant interface { SendRoomMovedResponse(moved *livekit.RoomMovedResponse) error SendDataTrackSubscriberHandles(handles map[uint32]*livekit.DataTrackSubscriberHandles_PublishedDataTrack) error - // callbacks - OnStateChange(func(p LocalParticipant)) - OnSubscriberReady(callback func(LocalParticipant)) - OnMigrateStateChange(func(p LocalParticipant, migrateState MigrateState)) - OnParticipantUpdate(callback func(LocalParticipant)) - OnDataPacket(callback func(LocalParticipant, livekit.DataPacket_Kind, *livekit.DataPacket)) - OnDataMessage(callback func(LocalParticipant, []byte)) - OnDataTrackMessage(callback func(LocalParticipant, []byte, *datatrack.Packet)) - OnSubscribeStatusChanged(fn func(publisherID livekit.ParticipantID, subscribed bool)) AddOnClose(key string, callback func(LocalParticipant)) OnClaimsChanged(callback func(LocalParticipant)) - OnUpdateSubscriptions(func( - LocalParticipant, - []livekit.TrackID, - []*livekit.ParticipantTracks, - bool, - )) - OnUpdateSubscriptionPermission(func(LocalParticipant, *livekit.SubscriptionPermission) error) - OnUpdateDataSubscriptions(func(LocalParticipant, *livekit.UpdateDataSubscription)) - OnSyncState(func(LocalParticipant, *livekit.SyncState) error) - OnSimulateScenario(func(LocalParticipant, *livekit.SimulateScenario) error) - OnLeave(func(LocalParticipant, ParticipantCloseReason)) HandleReceiverReport(dt *sfu.DownTrack, report *rtcp.ReceiverReport) @@ -568,8 +541,99 @@ type LocalParticipant interface { PerformRpc(req *livekit.PerformRpcRequest, resultCh chan string, errorCh chan error) GetDataTrackTransport() DataTrackTransport + + ClearParticipantListener() } +// --------------------------------------------- + +//counterfeiter:generate . ParticipantListener +type ParticipantListener interface { + OnParticipantUpdate(Participant) + OnTrackPublished(Participant, MediaTrack) + OnTrackUpdated(Participant, MediaTrack) + OnTrackUnpublished(Participant, MediaTrack) + OnDataTrackPublished(Participant, DataTrack) + OnDataTrackUnpublished(Participant, DataTrack) + OnMetrics(Participant, *livekit.DataPacket) +} + +var _ ParticipantListener = (*NullParticipantListener)(nil) + +type NullParticipantListener struct{} + +func (*NullParticipantListener) OnParticipantUpdate(Participant) {} +func (*NullParticipantListener) OnTrackPublished(Participant, MediaTrack) {} +func (*NullParticipantListener) OnTrackUpdated(Participant, MediaTrack) {} +func (*NullParticipantListener) OnTrackUnpublished(Participant, MediaTrack) {} +func (*NullParticipantListener) OnDataTrackPublished(Participant, DataTrack) {} +func (*NullParticipantListener) OnDataTrackUnpublished(Participant, DataTrack) {} +func (*NullParticipantListener) OnMetrics(Participant, *livekit.DataPacket) {} + +// --------------------------------------------- + +//counterfeiter:generate . LocalParticipantListener +type LocalParticipantListener interface { + ParticipantListener + + OnStateChange(LocalParticipant) + OnSubscriberReady(LocalParticipant) + OnMigrateStateChange(LocalParticipant, MigrateState) + OnDataPacket(LocalParticipant, livekit.DataPacket_Kind, *livekit.DataPacket) + OnDataMessage(LocalParticipant, []byte) + OnDataTrackMessage(LocalParticipant, []byte, *datatrack.Packet) + OnSubscribeStatusChanged(LocalParticipant, livekit.ParticipantID, bool) + OnUpdateSubscriptions( + LocalParticipant, + []livekit.TrackID, + []*livekit.ParticipantTracks, + bool, + ) + OnUpdateSubscriptionPermission(LocalParticipant, *livekit.SubscriptionPermission) error + OnUpdateDataSubscriptions(LocalParticipant, *livekit.UpdateDataSubscription) + OnSyncState(LocalParticipant, *livekit.SyncState) error + OnSimulateScenario(LocalParticipant, *livekit.SimulateScenario) error + OnLeave(LocalParticipant, ParticipantCloseReason) +} + +var _ LocalParticipantListener = (*NullLocalParticipantListener)(nil) + +type NullLocalParticipantListener struct { + NullParticipantListener +} + +func (*NullLocalParticipantListener) OnStateChange(LocalParticipant) {} +func (*NullLocalParticipantListener) OnSubscriberReady(LocalParticipant) {} +func (*NullLocalParticipantListener) OnMigrateStateChange(LocalParticipant, MigrateState) {} +func (*NullLocalParticipantListener) OnDataPacket(LocalParticipant, livekit.DataPacket_Kind, *livekit.DataPacket) { +} +func (*NullLocalParticipantListener) OnDataMessage(LocalParticipant, []byte) {} +func (*NullLocalParticipantListener) OnDataTrackMessage(LocalParticipant, []byte, *datatrack.Packet) { +} +func (*NullLocalParticipantListener) OnSubscribeStatusChanged(LocalParticipant, livekit.ParticipantID, bool) { +} +func (*NullLocalParticipantListener) OnUpdateSubscriptions( + LocalParticipant, + []livekit.TrackID, + []*livekit.ParticipantTracks, + bool, +) { +} +func (*NullLocalParticipantListener) OnUpdateSubscriptionPermission(LocalParticipant, *livekit.SubscriptionPermission) error { + return nil +} +func (*NullLocalParticipantListener) OnUpdateDataSubscriptions(LocalParticipant, *livekit.UpdateDataSubscription) { +} +func (*NullLocalParticipantListener) OnSyncState(LocalParticipant, *livekit.SyncState) error { + return nil +} +func (*NullLocalParticipantListener) OnSimulateScenario(LocalParticipant, *livekit.SimulateScenario) error { + return nil +} +func (*NullLocalParticipantListener) OnLeave(LocalParticipant, ParticipantCloseReason) {} + +// --------------------------------------------- + // Room is a container of participants, and can provide room-level actions // //counterfeiter:generate . Room diff --git a/pkg/rtc/types/typesfakes/fake_local_participant.go b/pkg/rtc/types/typesfakes/fake_local_participant.go index ea3595c50..5493cdac3 100644 --- a/pkg/rtc/types/typesfakes/fake_local_participant.go +++ b/pkg/rtc/types/typesfakes/fake_local_participant.go @@ -134,6 +134,10 @@ type FakeLocalParticipant struct { claimGrantsReturnsOnCall map[int]struct { result1 *auth.ClaimGrants } + ClearParticipantListenerStub func() + clearParticipantListenerMutex sync.RWMutex + clearParticipantListenerArgsForCall []struct { + } CloseStub func(bool, types.ParticipantCloseReason, bool) error closeMutex sync.RWMutex closeArgsForCall []struct { @@ -382,6 +386,16 @@ type FakeLocalParticipant struct { getPacerReturnsOnCall map[int]struct { result1 pacer.Pacer } + GetParticipantListenerStub func() types.ParticipantListener + getParticipantListenerMutex sync.RWMutex + getParticipantListenerArgsForCall []struct { + } + getParticipantListenerReturns struct { + result1 types.ParticipantListener + } + getParticipantListenerReturnsOnCall map[int]struct { + result1 types.ParticipantListener + } GetPendingTrackStub func(livekit.TrackID) *livekit.TrackInfo getPendingTrackMutex sync.RWMutex getPendingTrackArgsForCall []struct { @@ -909,111 +923,11 @@ type FakeLocalParticipant struct { onClaimsChangedArgsForCall []struct { arg1 func(types.LocalParticipant) } - OnDataMessageStub func(func(types.LocalParticipant, []byte)) - onDataMessageMutex sync.RWMutex - onDataMessageArgsForCall []struct { - arg1 func(types.LocalParticipant, []byte) - } - OnDataPacketStub func(func(types.LocalParticipant, livekit.DataPacket_Kind, *livekit.DataPacket)) - onDataPacketMutex sync.RWMutex - onDataPacketArgsForCall []struct { - arg1 func(types.LocalParticipant, livekit.DataPacket_Kind, *livekit.DataPacket) - } - OnDataTrackMessageStub func(func(types.LocalParticipant, []byte, *datatrack.Packet)) - onDataTrackMessageMutex sync.RWMutex - onDataTrackMessageArgsForCall []struct { - arg1 func(types.LocalParticipant, []byte, *datatrack.Packet) - } - OnDataTrackPublishedStub func(func(types.Participant, types.DataTrack)) - onDataTrackPublishedMutex sync.RWMutex - onDataTrackPublishedArgsForCall []struct { - arg1 func(types.Participant, types.DataTrack) - } - OnDataTrackUnpublishedStub func(func(types.Participant, types.DataTrack)) - onDataTrackUnpublishedMutex sync.RWMutex - onDataTrackUnpublishedArgsForCall []struct { - arg1 func(types.Participant, types.DataTrack) - } OnICEConfigChangedStub func(func(participant types.LocalParticipant, iceConfig *livekit.ICEConfig)) onICEConfigChangedMutex sync.RWMutex onICEConfigChangedArgsForCall []struct { arg1 func(participant types.LocalParticipant, iceConfig *livekit.ICEConfig) } - OnLeaveStub func(func(types.LocalParticipant, types.ParticipantCloseReason)) - onLeaveMutex sync.RWMutex - onLeaveArgsForCall []struct { - arg1 func(types.LocalParticipant, types.ParticipantCloseReason) - } - OnMetricsStub func(func(types.Participant, *livekit.DataPacket)) - onMetricsMutex sync.RWMutex - onMetricsArgsForCall []struct { - arg1 func(types.Participant, *livekit.DataPacket) - } - OnMigrateStateChangeStub func(func(p types.LocalParticipant, migrateState types.MigrateState)) - onMigrateStateChangeMutex sync.RWMutex - onMigrateStateChangeArgsForCall []struct { - arg1 func(p types.LocalParticipant, migrateState types.MigrateState) - } - OnParticipantUpdateStub func(func(types.LocalParticipant)) - onParticipantUpdateMutex sync.RWMutex - onParticipantUpdateArgsForCall []struct { - arg1 func(types.LocalParticipant) - } - OnSimulateScenarioStub func(func(types.LocalParticipant, *livekit.SimulateScenario) error) - onSimulateScenarioMutex sync.RWMutex - onSimulateScenarioArgsForCall []struct { - arg1 func(types.LocalParticipant, *livekit.SimulateScenario) error - } - OnStateChangeStub func(func(p types.LocalParticipant)) - onStateChangeMutex sync.RWMutex - onStateChangeArgsForCall []struct { - arg1 func(p types.LocalParticipant) - } - OnSubscribeStatusChangedStub func(func(publisherID livekit.ParticipantID, subscribed bool)) - onSubscribeStatusChangedMutex sync.RWMutex - onSubscribeStatusChangedArgsForCall []struct { - arg1 func(publisherID livekit.ParticipantID, subscribed bool) - } - OnSubscriberReadyStub func(func(types.LocalParticipant)) - onSubscriberReadyMutex sync.RWMutex - onSubscriberReadyArgsForCall []struct { - arg1 func(types.LocalParticipant) - } - OnSyncStateStub func(func(types.LocalParticipant, *livekit.SyncState) error) - onSyncStateMutex sync.RWMutex - onSyncStateArgsForCall []struct { - arg1 func(types.LocalParticipant, *livekit.SyncState) error - } - OnTrackPublishedStub func(func(types.Participant, types.MediaTrack)) - onTrackPublishedMutex sync.RWMutex - onTrackPublishedArgsForCall []struct { - arg1 func(types.Participant, types.MediaTrack) - } - OnTrackUnpublishedStub func(func(types.Participant, types.MediaTrack)) - onTrackUnpublishedMutex sync.RWMutex - onTrackUnpublishedArgsForCall []struct { - arg1 func(types.Participant, types.MediaTrack) - } - OnTrackUpdatedStub func(func(types.Participant, types.MediaTrack)) - onTrackUpdatedMutex sync.RWMutex - onTrackUpdatedArgsForCall []struct { - arg1 func(types.Participant, types.MediaTrack) - } - OnUpdateDataSubscriptionsStub func(func(types.LocalParticipant, *livekit.UpdateDataSubscription)) - onUpdateDataSubscriptionsMutex sync.RWMutex - onUpdateDataSubscriptionsArgsForCall []struct { - arg1 func(types.LocalParticipant, *livekit.UpdateDataSubscription) - } - OnUpdateSubscriptionPermissionStub func(func(types.LocalParticipant, *livekit.SubscriptionPermission) error) - onUpdateSubscriptionPermissionMutex sync.RWMutex - onUpdateSubscriptionPermissionArgsForCall []struct { - arg1 func(types.LocalParticipant, *livekit.SubscriptionPermission) error - } - OnUpdateSubscriptionsStub func(func(types.LocalParticipant, []livekit.TrackID, []*livekit.ParticipantTracks, bool)) - onUpdateSubscriptionsMutex sync.RWMutex - onUpdateSubscriptionsArgsForCall []struct { - arg1 func(types.LocalParticipant, []livekit.TrackID, []*livekit.ParticipantTracks, bool) - } PerformRpcStub func(*livekit.PerformRpcRequest, chan string, chan error) performRpcMutex sync.RWMutex performRpcArgsForCall []struct { @@ -2125,6 +2039,30 @@ func (fake *FakeLocalParticipant) ClaimGrantsReturnsOnCall(i int, result1 *auth. }{result1} } +func (fake *FakeLocalParticipant) ClearParticipantListener() { + fake.clearParticipantListenerMutex.Lock() + fake.clearParticipantListenerArgsForCall = append(fake.clearParticipantListenerArgsForCall, struct { + }{}) + stub := fake.ClearParticipantListenerStub + fake.recordInvocation("ClearParticipantListener", []interface{}{}) + fake.clearParticipantListenerMutex.Unlock() + if stub != nil { + fake.ClearParticipantListenerStub() + } +} + +func (fake *FakeLocalParticipant) ClearParticipantListenerCallCount() int { + fake.clearParticipantListenerMutex.RLock() + defer fake.clearParticipantListenerMutex.RUnlock() + return len(fake.clearParticipantListenerArgsForCall) +} + +func (fake *FakeLocalParticipant) ClearParticipantListenerCalls(stub func()) { + fake.clearParticipantListenerMutex.Lock() + defer fake.clearParticipantListenerMutex.Unlock() + fake.ClearParticipantListenerStub = stub +} + func (fake *FakeLocalParticipant) Close(arg1 bool, arg2 types.ParticipantCloseReason, arg3 bool) error { fake.closeMutex.Lock() ret, specificReturn := fake.closeReturnsOnCall[len(fake.closeArgsForCall)] @@ -3414,6 +3352,59 @@ func (fake *FakeLocalParticipant) GetPacerReturnsOnCall(i int, result1 pacer.Pac }{result1} } +func (fake *FakeLocalParticipant) GetParticipantListener() types.ParticipantListener { + fake.getParticipantListenerMutex.Lock() + ret, specificReturn := fake.getParticipantListenerReturnsOnCall[len(fake.getParticipantListenerArgsForCall)] + fake.getParticipantListenerArgsForCall = append(fake.getParticipantListenerArgsForCall, struct { + }{}) + stub := fake.GetParticipantListenerStub + fakeReturns := fake.getParticipantListenerReturns + fake.recordInvocation("GetParticipantListener", []interface{}{}) + fake.getParticipantListenerMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeLocalParticipant) GetParticipantListenerCallCount() int { + fake.getParticipantListenerMutex.RLock() + defer fake.getParticipantListenerMutex.RUnlock() + return len(fake.getParticipantListenerArgsForCall) +} + +func (fake *FakeLocalParticipant) GetParticipantListenerCalls(stub func() types.ParticipantListener) { + fake.getParticipantListenerMutex.Lock() + defer fake.getParticipantListenerMutex.Unlock() + fake.GetParticipantListenerStub = stub +} + +func (fake *FakeLocalParticipant) GetParticipantListenerReturns(result1 types.ParticipantListener) { + fake.getParticipantListenerMutex.Lock() + defer fake.getParticipantListenerMutex.Unlock() + fake.GetParticipantListenerStub = nil + fake.getParticipantListenerReturns = struct { + result1 types.ParticipantListener + }{result1} +} + +func (fake *FakeLocalParticipant) GetParticipantListenerReturnsOnCall(i int, result1 types.ParticipantListener) { + fake.getParticipantListenerMutex.Lock() + defer fake.getParticipantListenerMutex.Unlock() + fake.GetParticipantListenerStub = nil + if fake.getParticipantListenerReturnsOnCall == nil { + fake.getParticipantListenerReturnsOnCall = make(map[int]struct { + result1 types.ParticipantListener + }) + } + fake.getParticipantListenerReturnsOnCall[i] = struct { + result1 types.ParticipantListener + }{result1} +} + func (fake *FakeLocalParticipant) GetPendingTrack(arg1 livekit.TrackID) *livekit.TrackInfo { fake.getPendingTrackMutex.Lock() ret, specificReturn := fake.getPendingTrackReturnsOnCall[len(fake.getPendingTrackArgsForCall)] @@ -6294,166 +6285,6 @@ func (fake *FakeLocalParticipant) OnClaimsChangedArgsForCall(i int) func(types.L return argsForCall.arg1 } -func (fake *FakeLocalParticipant) OnDataMessage(arg1 func(types.LocalParticipant, []byte)) { - fake.onDataMessageMutex.Lock() - fake.onDataMessageArgsForCall = append(fake.onDataMessageArgsForCall, struct { - arg1 func(types.LocalParticipant, []byte) - }{arg1}) - stub := fake.OnDataMessageStub - fake.recordInvocation("OnDataMessage", []interface{}{arg1}) - fake.onDataMessageMutex.Unlock() - if stub != nil { - fake.OnDataMessageStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnDataMessageCallCount() int { - fake.onDataMessageMutex.RLock() - defer fake.onDataMessageMutex.RUnlock() - return len(fake.onDataMessageArgsForCall) -} - -func (fake *FakeLocalParticipant) OnDataMessageCalls(stub func(func(types.LocalParticipant, []byte))) { - fake.onDataMessageMutex.Lock() - defer fake.onDataMessageMutex.Unlock() - fake.OnDataMessageStub = stub -} - -func (fake *FakeLocalParticipant) OnDataMessageArgsForCall(i int) func(types.LocalParticipant, []byte) { - fake.onDataMessageMutex.RLock() - defer fake.onDataMessageMutex.RUnlock() - argsForCall := fake.onDataMessageArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeLocalParticipant) OnDataPacket(arg1 func(types.LocalParticipant, livekit.DataPacket_Kind, *livekit.DataPacket)) { - fake.onDataPacketMutex.Lock() - fake.onDataPacketArgsForCall = append(fake.onDataPacketArgsForCall, struct { - arg1 func(types.LocalParticipant, livekit.DataPacket_Kind, *livekit.DataPacket) - }{arg1}) - stub := fake.OnDataPacketStub - fake.recordInvocation("OnDataPacket", []interface{}{arg1}) - fake.onDataPacketMutex.Unlock() - if stub != nil { - fake.OnDataPacketStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnDataPacketCallCount() int { - fake.onDataPacketMutex.RLock() - defer fake.onDataPacketMutex.RUnlock() - return len(fake.onDataPacketArgsForCall) -} - -func (fake *FakeLocalParticipant) OnDataPacketCalls(stub func(func(types.LocalParticipant, livekit.DataPacket_Kind, *livekit.DataPacket))) { - fake.onDataPacketMutex.Lock() - defer fake.onDataPacketMutex.Unlock() - fake.OnDataPacketStub = stub -} - -func (fake *FakeLocalParticipant) OnDataPacketArgsForCall(i int) func(types.LocalParticipant, livekit.DataPacket_Kind, *livekit.DataPacket) { - fake.onDataPacketMutex.RLock() - defer fake.onDataPacketMutex.RUnlock() - argsForCall := fake.onDataPacketArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeLocalParticipant) OnDataTrackMessage(arg1 func(types.LocalParticipant, []byte, *datatrack.Packet)) { - fake.onDataTrackMessageMutex.Lock() - fake.onDataTrackMessageArgsForCall = append(fake.onDataTrackMessageArgsForCall, struct { - arg1 func(types.LocalParticipant, []byte, *datatrack.Packet) - }{arg1}) - stub := fake.OnDataTrackMessageStub - fake.recordInvocation("OnDataTrackMessage", []interface{}{arg1}) - fake.onDataTrackMessageMutex.Unlock() - if stub != nil { - fake.OnDataTrackMessageStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnDataTrackMessageCallCount() int { - fake.onDataTrackMessageMutex.RLock() - defer fake.onDataTrackMessageMutex.RUnlock() - return len(fake.onDataTrackMessageArgsForCall) -} - -func (fake *FakeLocalParticipant) OnDataTrackMessageCalls(stub func(func(types.LocalParticipant, []byte, *datatrack.Packet))) { - fake.onDataTrackMessageMutex.Lock() - defer fake.onDataTrackMessageMutex.Unlock() - fake.OnDataTrackMessageStub = stub -} - -func (fake *FakeLocalParticipant) OnDataTrackMessageArgsForCall(i int) func(types.LocalParticipant, []byte, *datatrack.Packet) { - fake.onDataTrackMessageMutex.RLock() - defer fake.onDataTrackMessageMutex.RUnlock() - argsForCall := fake.onDataTrackMessageArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeLocalParticipant) OnDataTrackPublished(arg1 func(types.Participant, types.DataTrack)) { - fake.onDataTrackPublishedMutex.Lock() - fake.onDataTrackPublishedArgsForCall = append(fake.onDataTrackPublishedArgsForCall, struct { - arg1 func(types.Participant, types.DataTrack) - }{arg1}) - stub := fake.OnDataTrackPublishedStub - fake.recordInvocation("OnDataTrackPublished", []interface{}{arg1}) - fake.onDataTrackPublishedMutex.Unlock() - if stub != nil { - fake.OnDataTrackPublishedStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnDataTrackPublishedCallCount() int { - fake.onDataTrackPublishedMutex.RLock() - defer fake.onDataTrackPublishedMutex.RUnlock() - return len(fake.onDataTrackPublishedArgsForCall) -} - -func (fake *FakeLocalParticipant) OnDataTrackPublishedCalls(stub func(func(types.Participant, types.DataTrack))) { - fake.onDataTrackPublishedMutex.Lock() - defer fake.onDataTrackPublishedMutex.Unlock() - fake.OnDataTrackPublishedStub = stub -} - -func (fake *FakeLocalParticipant) OnDataTrackPublishedArgsForCall(i int) func(types.Participant, types.DataTrack) { - fake.onDataTrackPublishedMutex.RLock() - defer fake.onDataTrackPublishedMutex.RUnlock() - argsForCall := fake.onDataTrackPublishedArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeLocalParticipant) OnDataTrackUnpublished(arg1 func(types.Participant, types.DataTrack)) { - fake.onDataTrackUnpublishedMutex.Lock() - fake.onDataTrackUnpublishedArgsForCall = append(fake.onDataTrackUnpublishedArgsForCall, struct { - arg1 func(types.Participant, types.DataTrack) - }{arg1}) - stub := fake.OnDataTrackUnpublishedStub - fake.recordInvocation("OnDataTrackUnpublished", []interface{}{arg1}) - fake.onDataTrackUnpublishedMutex.Unlock() - if stub != nil { - fake.OnDataTrackUnpublishedStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnDataTrackUnpublishedCallCount() int { - fake.onDataTrackUnpublishedMutex.RLock() - defer fake.onDataTrackUnpublishedMutex.RUnlock() - return len(fake.onDataTrackUnpublishedArgsForCall) -} - -func (fake *FakeLocalParticipant) OnDataTrackUnpublishedCalls(stub func(func(types.Participant, types.DataTrack))) { - fake.onDataTrackUnpublishedMutex.Lock() - defer fake.onDataTrackUnpublishedMutex.Unlock() - fake.OnDataTrackUnpublishedStub = stub -} - -func (fake *FakeLocalParticipant) OnDataTrackUnpublishedArgsForCall(i int) func(types.Participant, types.DataTrack) { - fake.onDataTrackUnpublishedMutex.RLock() - defer fake.onDataTrackUnpublishedMutex.RUnlock() - argsForCall := fake.onDataTrackUnpublishedArgsForCall[i] - return argsForCall.arg1 -} - func (fake *FakeLocalParticipant) OnICEConfigChanged(arg1 func(participant types.LocalParticipant, iceConfig *livekit.ICEConfig)) { fake.onICEConfigChangedMutex.Lock() fake.onICEConfigChangedArgsForCall = append(fake.onICEConfigChangedArgsForCall, struct { @@ -6486,486 +6317,6 @@ func (fake *FakeLocalParticipant) OnICEConfigChangedArgsForCall(i int) func(part return argsForCall.arg1 } -func (fake *FakeLocalParticipant) OnLeave(arg1 func(types.LocalParticipant, types.ParticipantCloseReason)) { - fake.onLeaveMutex.Lock() - fake.onLeaveArgsForCall = append(fake.onLeaveArgsForCall, struct { - arg1 func(types.LocalParticipant, types.ParticipantCloseReason) - }{arg1}) - stub := fake.OnLeaveStub - fake.recordInvocation("OnLeave", []interface{}{arg1}) - fake.onLeaveMutex.Unlock() - if stub != nil { - fake.OnLeaveStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnLeaveCallCount() int { - fake.onLeaveMutex.RLock() - defer fake.onLeaveMutex.RUnlock() - return len(fake.onLeaveArgsForCall) -} - -func (fake *FakeLocalParticipant) OnLeaveCalls(stub func(func(types.LocalParticipant, types.ParticipantCloseReason))) { - fake.onLeaveMutex.Lock() - defer fake.onLeaveMutex.Unlock() - fake.OnLeaveStub = stub -} - -func (fake *FakeLocalParticipant) OnLeaveArgsForCall(i int) func(types.LocalParticipant, types.ParticipantCloseReason) { - fake.onLeaveMutex.RLock() - defer fake.onLeaveMutex.RUnlock() - argsForCall := fake.onLeaveArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeLocalParticipant) OnMetrics(arg1 func(types.Participant, *livekit.DataPacket)) { - fake.onMetricsMutex.Lock() - fake.onMetricsArgsForCall = append(fake.onMetricsArgsForCall, struct { - arg1 func(types.Participant, *livekit.DataPacket) - }{arg1}) - stub := fake.OnMetricsStub - fake.recordInvocation("OnMetrics", []interface{}{arg1}) - fake.onMetricsMutex.Unlock() - if stub != nil { - fake.OnMetricsStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnMetricsCallCount() int { - fake.onMetricsMutex.RLock() - defer fake.onMetricsMutex.RUnlock() - return len(fake.onMetricsArgsForCall) -} - -func (fake *FakeLocalParticipant) OnMetricsCalls(stub func(func(types.Participant, *livekit.DataPacket))) { - fake.onMetricsMutex.Lock() - defer fake.onMetricsMutex.Unlock() - fake.OnMetricsStub = stub -} - -func (fake *FakeLocalParticipant) OnMetricsArgsForCall(i int) func(types.Participant, *livekit.DataPacket) { - fake.onMetricsMutex.RLock() - defer fake.onMetricsMutex.RUnlock() - argsForCall := fake.onMetricsArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeLocalParticipant) OnMigrateStateChange(arg1 func(p types.LocalParticipant, migrateState types.MigrateState)) { - fake.onMigrateStateChangeMutex.Lock() - fake.onMigrateStateChangeArgsForCall = append(fake.onMigrateStateChangeArgsForCall, struct { - arg1 func(p types.LocalParticipant, migrateState types.MigrateState) - }{arg1}) - stub := fake.OnMigrateStateChangeStub - fake.recordInvocation("OnMigrateStateChange", []interface{}{arg1}) - fake.onMigrateStateChangeMutex.Unlock() - if stub != nil { - fake.OnMigrateStateChangeStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnMigrateStateChangeCallCount() int { - fake.onMigrateStateChangeMutex.RLock() - defer fake.onMigrateStateChangeMutex.RUnlock() - return len(fake.onMigrateStateChangeArgsForCall) -} - -func (fake *FakeLocalParticipant) OnMigrateStateChangeCalls(stub func(func(p types.LocalParticipant, migrateState types.MigrateState))) { - fake.onMigrateStateChangeMutex.Lock() - defer fake.onMigrateStateChangeMutex.Unlock() - fake.OnMigrateStateChangeStub = stub -} - -func (fake *FakeLocalParticipant) OnMigrateStateChangeArgsForCall(i int) func(p types.LocalParticipant, migrateState types.MigrateState) { - fake.onMigrateStateChangeMutex.RLock() - defer fake.onMigrateStateChangeMutex.RUnlock() - argsForCall := fake.onMigrateStateChangeArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeLocalParticipant) OnParticipantUpdate(arg1 func(types.LocalParticipant)) { - fake.onParticipantUpdateMutex.Lock() - fake.onParticipantUpdateArgsForCall = append(fake.onParticipantUpdateArgsForCall, struct { - arg1 func(types.LocalParticipant) - }{arg1}) - stub := fake.OnParticipantUpdateStub - fake.recordInvocation("OnParticipantUpdate", []interface{}{arg1}) - fake.onParticipantUpdateMutex.Unlock() - if stub != nil { - fake.OnParticipantUpdateStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnParticipantUpdateCallCount() int { - fake.onParticipantUpdateMutex.RLock() - defer fake.onParticipantUpdateMutex.RUnlock() - return len(fake.onParticipantUpdateArgsForCall) -} - -func (fake *FakeLocalParticipant) OnParticipantUpdateCalls(stub func(func(types.LocalParticipant))) { - fake.onParticipantUpdateMutex.Lock() - defer fake.onParticipantUpdateMutex.Unlock() - fake.OnParticipantUpdateStub = stub -} - -func (fake *FakeLocalParticipant) OnParticipantUpdateArgsForCall(i int) func(types.LocalParticipant) { - fake.onParticipantUpdateMutex.RLock() - defer fake.onParticipantUpdateMutex.RUnlock() - argsForCall := fake.onParticipantUpdateArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeLocalParticipant) OnSimulateScenario(arg1 func(types.LocalParticipant, *livekit.SimulateScenario) error) { - fake.onSimulateScenarioMutex.Lock() - fake.onSimulateScenarioArgsForCall = append(fake.onSimulateScenarioArgsForCall, struct { - arg1 func(types.LocalParticipant, *livekit.SimulateScenario) error - }{arg1}) - stub := fake.OnSimulateScenarioStub - fake.recordInvocation("OnSimulateScenario", []interface{}{arg1}) - fake.onSimulateScenarioMutex.Unlock() - if stub != nil { - fake.OnSimulateScenarioStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnSimulateScenarioCallCount() int { - fake.onSimulateScenarioMutex.RLock() - defer fake.onSimulateScenarioMutex.RUnlock() - return len(fake.onSimulateScenarioArgsForCall) -} - -func (fake *FakeLocalParticipant) OnSimulateScenarioCalls(stub func(func(types.LocalParticipant, *livekit.SimulateScenario) error)) { - fake.onSimulateScenarioMutex.Lock() - defer fake.onSimulateScenarioMutex.Unlock() - fake.OnSimulateScenarioStub = stub -} - -func (fake *FakeLocalParticipant) OnSimulateScenarioArgsForCall(i int) func(types.LocalParticipant, *livekit.SimulateScenario) error { - fake.onSimulateScenarioMutex.RLock() - defer fake.onSimulateScenarioMutex.RUnlock() - argsForCall := fake.onSimulateScenarioArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeLocalParticipant) OnStateChange(arg1 func(p types.LocalParticipant)) { - fake.onStateChangeMutex.Lock() - fake.onStateChangeArgsForCall = append(fake.onStateChangeArgsForCall, struct { - arg1 func(p types.LocalParticipant) - }{arg1}) - stub := fake.OnStateChangeStub - fake.recordInvocation("OnStateChange", []interface{}{arg1}) - fake.onStateChangeMutex.Unlock() - if stub != nil { - fake.OnStateChangeStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnStateChangeCallCount() int { - fake.onStateChangeMutex.RLock() - defer fake.onStateChangeMutex.RUnlock() - return len(fake.onStateChangeArgsForCall) -} - -func (fake *FakeLocalParticipant) OnStateChangeCalls(stub func(func(p types.LocalParticipant))) { - fake.onStateChangeMutex.Lock() - defer fake.onStateChangeMutex.Unlock() - fake.OnStateChangeStub = stub -} - -func (fake *FakeLocalParticipant) OnStateChangeArgsForCall(i int) func(p types.LocalParticipant) { - fake.onStateChangeMutex.RLock() - defer fake.onStateChangeMutex.RUnlock() - argsForCall := fake.onStateChangeArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeLocalParticipant) OnSubscribeStatusChanged(arg1 func(publisherID livekit.ParticipantID, subscribed bool)) { - fake.onSubscribeStatusChangedMutex.Lock() - fake.onSubscribeStatusChangedArgsForCall = append(fake.onSubscribeStatusChangedArgsForCall, struct { - arg1 func(publisherID livekit.ParticipantID, subscribed bool) - }{arg1}) - stub := fake.OnSubscribeStatusChangedStub - fake.recordInvocation("OnSubscribeStatusChanged", []interface{}{arg1}) - fake.onSubscribeStatusChangedMutex.Unlock() - if stub != nil { - fake.OnSubscribeStatusChangedStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnSubscribeStatusChangedCallCount() int { - fake.onSubscribeStatusChangedMutex.RLock() - defer fake.onSubscribeStatusChangedMutex.RUnlock() - return len(fake.onSubscribeStatusChangedArgsForCall) -} - -func (fake *FakeLocalParticipant) OnSubscribeStatusChangedCalls(stub func(func(publisherID livekit.ParticipantID, subscribed bool))) { - fake.onSubscribeStatusChangedMutex.Lock() - defer fake.onSubscribeStatusChangedMutex.Unlock() - fake.OnSubscribeStatusChangedStub = stub -} - -func (fake *FakeLocalParticipant) OnSubscribeStatusChangedArgsForCall(i int) func(publisherID livekit.ParticipantID, subscribed bool) { - fake.onSubscribeStatusChangedMutex.RLock() - defer fake.onSubscribeStatusChangedMutex.RUnlock() - argsForCall := fake.onSubscribeStatusChangedArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeLocalParticipant) OnSubscriberReady(arg1 func(types.LocalParticipant)) { - fake.onSubscriberReadyMutex.Lock() - fake.onSubscriberReadyArgsForCall = append(fake.onSubscriberReadyArgsForCall, struct { - arg1 func(types.LocalParticipant) - }{arg1}) - stub := fake.OnSubscriberReadyStub - fake.recordInvocation("OnSubscriberReady", []interface{}{arg1}) - fake.onSubscriberReadyMutex.Unlock() - if stub != nil { - fake.OnSubscriberReadyStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnSubscriberReadyCallCount() int { - fake.onSubscriberReadyMutex.RLock() - defer fake.onSubscriberReadyMutex.RUnlock() - return len(fake.onSubscriberReadyArgsForCall) -} - -func (fake *FakeLocalParticipant) OnSubscriberReadyCalls(stub func(func(types.LocalParticipant))) { - fake.onSubscriberReadyMutex.Lock() - defer fake.onSubscriberReadyMutex.Unlock() - fake.OnSubscriberReadyStub = stub -} - -func (fake *FakeLocalParticipant) OnSubscriberReadyArgsForCall(i int) func(types.LocalParticipant) { - fake.onSubscriberReadyMutex.RLock() - defer fake.onSubscriberReadyMutex.RUnlock() - argsForCall := fake.onSubscriberReadyArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeLocalParticipant) OnSyncState(arg1 func(types.LocalParticipant, *livekit.SyncState) error) { - fake.onSyncStateMutex.Lock() - fake.onSyncStateArgsForCall = append(fake.onSyncStateArgsForCall, struct { - arg1 func(types.LocalParticipant, *livekit.SyncState) error - }{arg1}) - stub := fake.OnSyncStateStub - fake.recordInvocation("OnSyncState", []interface{}{arg1}) - fake.onSyncStateMutex.Unlock() - if stub != nil { - fake.OnSyncStateStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnSyncStateCallCount() int { - fake.onSyncStateMutex.RLock() - defer fake.onSyncStateMutex.RUnlock() - return len(fake.onSyncStateArgsForCall) -} - -func (fake *FakeLocalParticipant) OnSyncStateCalls(stub func(func(types.LocalParticipant, *livekit.SyncState) error)) { - fake.onSyncStateMutex.Lock() - defer fake.onSyncStateMutex.Unlock() - fake.OnSyncStateStub = stub -} - -func (fake *FakeLocalParticipant) OnSyncStateArgsForCall(i int) func(types.LocalParticipant, *livekit.SyncState) error { - fake.onSyncStateMutex.RLock() - defer fake.onSyncStateMutex.RUnlock() - argsForCall := fake.onSyncStateArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeLocalParticipant) OnTrackPublished(arg1 func(types.Participant, types.MediaTrack)) { - fake.onTrackPublishedMutex.Lock() - fake.onTrackPublishedArgsForCall = append(fake.onTrackPublishedArgsForCall, struct { - arg1 func(types.Participant, types.MediaTrack) - }{arg1}) - stub := fake.OnTrackPublishedStub - fake.recordInvocation("OnTrackPublished", []interface{}{arg1}) - fake.onTrackPublishedMutex.Unlock() - if stub != nil { - fake.OnTrackPublishedStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnTrackPublishedCallCount() int { - fake.onTrackPublishedMutex.RLock() - defer fake.onTrackPublishedMutex.RUnlock() - return len(fake.onTrackPublishedArgsForCall) -} - -func (fake *FakeLocalParticipant) OnTrackPublishedCalls(stub func(func(types.Participant, types.MediaTrack))) { - fake.onTrackPublishedMutex.Lock() - defer fake.onTrackPublishedMutex.Unlock() - fake.OnTrackPublishedStub = stub -} - -func (fake *FakeLocalParticipant) OnTrackPublishedArgsForCall(i int) func(types.Participant, types.MediaTrack) { - fake.onTrackPublishedMutex.RLock() - defer fake.onTrackPublishedMutex.RUnlock() - argsForCall := fake.onTrackPublishedArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeLocalParticipant) OnTrackUnpublished(arg1 func(types.Participant, types.MediaTrack)) { - fake.onTrackUnpublishedMutex.Lock() - fake.onTrackUnpublishedArgsForCall = append(fake.onTrackUnpublishedArgsForCall, struct { - arg1 func(types.Participant, types.MediaTrack) - }{arg1}) - stub := fake.OnTrackUnpublishedStub - fake.recordInvocation("OnTrackUnpublished", []interface{}{arg1}) - fake.onTrackUnpublishedMutex.Unlock() - if stub != nil { - fake.OnTrackUnpublishedStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnTrackUnpublishedCallCount() int { - fake.onTrackUnpublishedMutex.RLock() - defer fake.onTrackUnpublishedMutex.RUnlock() - return len(fake.onTrackUnpublishedArgsForCall) -} - -func (fake *FakeLocalParticipant) OnTrackUnpublishedCalls(stub func(func(types.Participant, types.MediaTrack))) { - fake.onTrackUnpublishedMutex.Lock() - defer fake.onTrackUnpublishedMutex.Unlock() - fake.OnTrackUnpublishedStub = stub -} - -func (fake *FakeLocalParticipant) OnTrackUnpublishedArgsForCall(i int) func(types.Participant, types.MediaTrack) { - fake.onTrackUnpublishedMutex.RLock() - defer fake.onTrackUnpublishedMutex.RUnlock() - argsForCall := fake.onTrackUnpublishedArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeLocalParticipant) OnTrackUpdated(arg1 func(types.Participant, types.MediaTrack)) { - fake.onTrackUpdatedMutex.Lock() - fake.onTrackUpdatedArgsForCall = append(fake.onTrackUpdatedArgsForCall, struct { - arg1 func(types.Participant, types.MediaTrack) - }{arg1}) - stub := fake.OnTrackUpdatedStub - fake.recordInvocation("OnTrackUpdated", []interface{}{arg1}) - fake.onTrackUpdatedMutex.Unlock() - if stub != nil { - fake.OnTrackUpdatedStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnTrackUpdatedCallCount() int { - fake.onTrackUpdatedMutex.RLock() - defer fake.onTrackUpdatedMutex.RUnlock() - return len(fake.onTrackUpdatedArgsForCall) -} - -func (fake *FakeLocalParticipant) OnTrackUpdatedCalls(stub func(func(types.Participant, types.MediaTrack))) { - fake.onTrackUpdatedMutex.Lock() - defer fake.onTrackUpdatedMutex.Unlock() - fake.OnTrackUpdatedStub = stub -} - -func (fake *FakeLocalParticipant) OnTrackUpdatedArgsForCall(i int) func(types.Participant, types.MediaTrack) { - fake.onTrackUpdatedMutex.RLock() - defer fake.onTrackUpdatedMutex.RUnlock() - argsForCall := fake.onTrackUpdatedArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeLocalParticipant) OnUpdateDataSubscriptions(arg1 func(types.LocalParticipant, *livekit.UpdateDataSubscription)) { - fake.onUpdateDataSubscriptionsMutex.Lock() - fake.onUpdateDataSubscriptionsArgsForCall = append(fake.onUpdateDataSubscriptionsArgsForCall, struct { - arg1 func(types.LocalParticipant, *livekit.UpdateDataSubscription) - }{arg1}) - stub := fake.OnUpdateDataSubscriptionsStub - fake.recordInvocation("OnUpdateDataSubscriptions", []interface{}{arg1}) - fake.onUpdateDataSubscriptionsMutex.Unlock() - if stub != nil { - fake.OnUpdateDataSubscriptionsStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnUpdateDataSubscriptionsCallCount() int { - fake.onUpdateDataSubscriptionsMutex.RLock() - defer fake.onUpdateDataSubscriptionsMutex.RUnlock() - return len(fake.onUpdateDataSubscriptionsArgsForCall) -} - -func (fake *FakeLocalParticipant) OnUpdateDataSubscriptionsCalls(stub func(func(types.LocalParticipant, *livekit.UpdateDataSubscription))) { - fake.onUpdateDataSubscriptionsMutex.Lock() - defer fake.onUpdateDataSubscriptionsMutex.Unlock() - fake.OnUpdateDataSubscriptionsStub = stub -} - -func (fake *FakeLocalParticipant) OnUpdateDataSubscriptionsArgsForCall(i int) func(types.LocalParticipant, *livekit.UpdateDataSubscription) { - fake.onUpdateDataSubscriptionsMutex.RLock() - defer fake.onUpdateDataSubscriptionsMutex.RUnlock() - argsForCall := fake.onUpdateDataSubscriptionsArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeLocalParticipant) OnUpdateSubscriptionPermission(arg1 func(types.LocalParticipant, *livekit.SubscriptionPermission) error) { - fake.onUpdateSubscriptionPermissionMutex.Lock() - fake.onUpdateSubscriptionPermissionArgsForCall = append(fake.onUpdateSubscriptionPermissionArgsForCall, struct { - arg1 func(types.LocalParticipant, *livekit.SubscriptionPermission) error - }{arg1}) - stub := fake.OnUpdateSubscriptionPermissionStub - fake.recordInvocation("OnUpdateSubscriptionPermission", []interface{}{arg1}) - fake.onUpdateSubscriptionPermissionMutex.Unlock() - if stub != nil { - fake.OnUpdateSubscriptionPermissionStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnUpdateSubscriptionPermissionCallCount() int { - fake.onUpdateSubscriptionPermissionMutex.RLock() - defer fake.onUpdateSubscriptionPermissionMutex.RUnlock() - return len(fake.onUpdateSubscriptionPermissionArgsForCall) -} - -func (fake *FakeLocalParticipant) OnUpdateSubscriptionPermissionCalls(stub func(func(types.LocalParticipant, *livekit.SubscriptionPermission) error)) { - fake.onUpdateSubscriptionPermissionMutex.Lock() - defer fake.onUpdateSubscriptionPermissionMutex.Unlock() - fake.OnUpdateSubscriptionPermissionStub = stub -} - -func (fake *FakeLocalParticipant) OnUpdateSubscriptionPermissionArgsForCall(i int) func(types.LocalParticipant, *livekit.SubscriptionPermission) error { - fake.onUpdateSubscriptionPermissionMutex.RLock() - defer fake.onUpdateSubscriptionPermissionMutex.RUnlock() - argsForCall := fake.onUpdateSubscriptionPermissionArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeLocalParticipant) OnUpdateSubscriptions(arg1 func(types.LocalParticipant, []livekit.TrackID, []*livekit.ParticipantTracks, bool)) { - fake.onUpdateSubscriptionsMutex.Lock() - fake.onUpdateSubscriptionsArgsForCall = append(fake.onUpdateSubscriptionsArgsForCall, struct { - arg1 func(types.LocalParticipant, []livekit.TrackID, []*livekit.ParticipantTracks, bool) - }{arg1}) - stub := fake.OnUpdateSubscriptionsStub - fake.recordInvocation("OnUpdateSubscriptions", []interface{}{arg1}) - fake.onUpdateSubscriptionsMutex.Unlock() - if stub != nil { - fake.OnUpdateSubscriptionsStub(arg1) - } -} - -func (fake *FakeLocalParticipant) OnUpdateSubscriptionsCallCount() int { - fake.onUpdateSubscriptionsMutex.RLock() - defer fake.onUpdateSubscriptionsMutex.RUnlock() - return len(fake.onUpdateSubscriptionsArgsForCall) -} - -func (fake *FakeLocalParticipant) OnUpdateSubscriptionsCalls(stub func(func(types.LocalParticipant, []livekit.TrackID, []*livekit.ParticipantTracks, bool))) { - fake.onUpdateSubscriptionsMutex.Lock() - defer fake.onUpdateSubscriptionsMutex.Unlock() - fake.OnUpdateSubscriptionsStub = stub -} - -func (fake *FakeLocalParticipant) OnUpdateSubscriptionsArgsForCall(i int) func(types.LocalParticipant, []livekit.TrackID, []*livekit.ParticipantTracks, bool) { - fake.onUpdateSubscriptionsMutex.RLock() - defer fake.onUpdateSubscriptionsMutex.RUnlock() - argsForCall := fake.onUpdateSubscriptionsArgsForCall[i] - return argsForCall.arg1 -} - func (fake *FakeLocalParticipant) PerformRpc(arg1 *livekit.PerformRpcRequest, arg2 chan string, arg3 chan error) { fake.performRpcMutex.Lock() fake.performRpcArgsForCall = append(fake.performRpcArgsForCall, struct { diff --git a/pkg/rtc/types/typesfakes/fake_local_participant_listener.go b/pkg/rtc/types/typesfakes/fake_local_participant_listener.go new file mode 100644 index 000000000..7e41f45a7 --- /dev/null +++ b/pkg/rtc/types/typesfakes/fake_local_participant_listener.go @@ -0,0 +1,948 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package typesfakes + +import ( + "sync" + + "github.com/livekit/livekit-server/pkg/rtc/datatrack" + "github.com/livekit/livekit-server/pkg/rtc/types" + "github.com/livekit/protocol/livekit" +) + +type FakeLocalParticipantListener struct { + OnDataMessageStub func(types.LocalParticipant, []byte) + onDataMessageMutex sync.RWMutex + onDataMessageArgsForCall []struct { + arg1 types.LocalParticipant + arg2 []byte + } + OnDataPacketStub func(types.LocalParticipant, livekit.DataPacket_Kind, *livekit.DataPacket) + onDataPacketMutex sync.RWMutex + onDataPacketArgsForCall []struct { + arg1 types.LocalParticipant + arg2 livekit.DataPacket_Kind + arg3 *livekit.DataPacket + } + OnDataTrackMessageStub func(types.LocalParticipant, []byte, *datatrack.Packet) + onDataTrackMessageMutex sync.RWMutex + onDataTrackMessageArgsForCall []struct { + arg1 types.LocalParticipant + arg2 []byte + arg3 *datatrack.Packet + } + OnDataTrackPublishedStub func(types.Participant, types.DataTrack) + onDataTrackPublishedMutex sync.RWMutex + onDataTrackPublishedArgsForCall []struct { + arg1 types.Participant + arg2 types.DataTrack + } + OnDataTrackUnpublishedStub func(types.Participant, types.DataTrack) + onDataTrackUnpublishedMutex sync.RWMutex + onDataTrackUnpublishedArgsForCall []struct { + arg1 types.Participant + arg2 types.DataTrack + } + OnLeaveStub func(types.LocalParticipant, types.ParticipantCloseReason) + onLeaveMutex sync.RWMutex + onLeaveArgsForCall []struct { + arg1 types.LocalParticipant + arg2 types.ParticipantCloseReason + } + OnMetricsStub func(types.Participant, *livekit.DataPacket) + onMetricsMutex sync.RWMutex + onMetricsArgsForCall []struct { + arg1 types.Participant + arg2 *livekit.DataPacket + } + OnMigrateStateChangeStub func(types.LocalParticipant, types.MigrateState) + onMigrateStateChangeMutex sync.RWMutex + onMigrateStateChangeArgsForCall []struct { + arg1 types.LocalParticipant + arg2 types.MigrateState + } + OnParticipantUpdateStub func(types.Participant) + onParticipantUpdateMutex sync.RWMutex + onParticipantUpdateArgsForCall []struct { + arg1 types.Participant + } + OnSimulateScenarioStub func(types.LocalParticipant, *livekit.SimulateScenario) error + onSimulateScenarioMutex sync.RWMutex + onSimulateScenarioArgsForCall []struct { + arg1 types.LocalParticipant + arg2 *livekit.SimulateScenario + } + onSimulateScenarioReturns struct { + result1 error + } + onSimulateScenarioReturnsOnCall map[int]struct { + result1 error + } + OnStateChangeStub func(types.LocalParticipant) + onStateChangeMutex sync.RWMutex + onStateChangeArgsForCall []struct { + arg1 types.LocalParticipant + } + OnSubscribeStatusChangedStub func(types.LocalParticipant, livekit.ParticipantID, bool) + onSubscribeStatusChangedMutex sync.RWMutex + onSubscribeStatusChangedArgsForCall []struct { + arg1 types.LocalParticipant + arg2 livekit.ParticipantID + arg3 bool + } + OnSubscriberReadyStub func(types.LocalParticipant) + onSubscriberReadyMutex sync.RWMutex + onSubscriberReadyArgsForCall []struct { + arg1 types.LocalParticipant + } + OnSyncStateStub func(types.LocalParticipant, *livekit.SyncState) error + onSyncStateMutex sync.RWMutex + onSyncStateArgsForCall []struct { + arg1 types.LocalParticipant + arg2 *livekit.SyncState + } + onSyncStateReturns struct { + result1 error + } + onSyncStateReturnsOnCall map[int]struct { + result1 error + } + OnTrackPublishedStub func(types.Participant, types.MediaTrack) + onTrackPublishedMutex sync.RWMutex + onTrackPublishedArgsForCall []struct { + arg1 types.Participant + arg2 types.MediaTrack + } + OnTrackUnpublishedStub func(types.Participant, types.MediaTrack) + onTrackUnpublishedMutex sync.RWMutex + onTrackUnpublishedArgsForCall []struct { + arg1 types.Participant + arg2 types.MediaTrack + } + OnTrackUpdatedStub func(types.Participant, types.MediaTrack) + onTrackUpdatedMutex sync.RWMutex + onTrackUpdatedArgsForCall []struct { + arg1 types.Participant + arg2 types.MediaTrack + } + OnUpdateDataSubscriptionsStub func(types.LocalParticipant, *livekit.UpdateDataSubscription) + onUpdateDataSubscriptionsMutex sync.RWMutex + onUpdateDataSubscriptionsArgsForCall []struct { + arg1 types.LocalParticipant + arg2 *livekit.UpdateDataSubscription + } + OnUpdateSubscriptionPermissionStub func(types.LocalParticipant, *livekit.SubscriptionPermission) error + onUpdateSubscriptionPermissionMutex sync.RWMutex + onUpdateSubscriptionPermissionArgsForCall []struct { + arg1 types.LocalParticipant + arg2 *livekit.SubscriptionPermission + } + onUpdateSubscriptionPermissionReturns struct { + result1 error + } + onUpdateSubscriptionPermissionReturnsOnCall map[int]struct { + result1 error + } + OnUpdateSubscriptionsStub func(types.LocalParticipant, []livekit.TrackID, []*livekit.ParticipantTracks, bool) + onUpdateSubscriptionsMutex sync.RWMutex + onUpdateSubscriptionsArgsForCall []struct { + arg1 types.LocalParticipant + arg2 []livekit.TrackID + arg3 []*livekit.ParticipantTracks + arg4 bool + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeLocalParticipantListener) OnDataMessage(arg1 types.LocalParticipant, arg2 []byte) { + var arg2Copy []byte + if arg2 != nil { + arg2Copy = make([]byte, len(arg2)) + copy(arg2Copy, arg2) + } + fake.onDataMessageMutex.Lock() + fake.onDataMessageArgsForCall = append(fake.onDataMessageArgsForCall, struct { + arg1 types.LocalParticipant + arg2 []byte + }{arg1, arg2Copy}) + stub := fake.OnDataMessageStub + fake.recordInvocation("OnDataMessage", []interface{}{arg1, arg2Copy}) + fake.onDataMessageMutex.Unlock() + if stub != nil { + fake.OnDataMessageStub(arg1, arg2) + } +} + +func (fake *FakeLocalParticipantListener) OnDataMessageCallCount() int { + fake.onDataMessageMutex.RLock() + defer fake.onDataMessageMutex.RUnlock() + return len(fake.onDataMessageArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnDataMessageCalls(stub func(types.LocalParticipant, []byte)) { + fake.onDataMessageMutex.Lock() + defer fake.onDataMessageMutex.Unlock() + fake.OnDataMessageStub = stub +} + +func (fake *FakeLocalParticipantListener) OnDataMessageArgsForCall(i int) (types.LocalParticipant, []byte) { + fake.onDataMessageMutex.RLock() + defer fake.onDataMessageMutex.RUnlock() + argsForCall := fake.onDataMessageArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeLocalParticipantListener) OnDataPacket(arg1 types.LocalParticipant, arg2 livekit.DataPacket_Kind, arg3 *livekit.DataPacket) { + fake.onDataPacketMutex.Lock() + fake.onDataPacketArgsForCall = append(fake.onDataPacketArgsForCall, struct { + arg1 types.LocalParticipant + arg2 livekit.DataPacket_Kind + arg3 *livekit.DataPacket + }{arg1, arg2, arg3}) + stub := fake.OnDataPacketStub + fake.recordInvocation("OnDataPacket", []interface{}{arg1, arg2, arg3}) + fake.onDataPacketMutex.Unlock() + if stub != nil { + fake.OnDataPacketStub(arg1, arg2, arg3) + } +} + +func (fake *FakeLocalParticipantListener) OnDataPacketCallCount() int { + fake.onDataPacketMutex.RLock() + defer fake.onDataPacketMutex.RUnlock() + return len(fake.onDataPacketArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnDataPacketCalls(stub func(types.LocalParticipant, livekit.DataPacket_Kind, *livekit.DataPacket)) { + fake.onDataPacketMutex.Lock() + defer fake.onDataPacketMutex.Unlock() + fake.OnDataPacketStub = stub +} + +func (fake *FakeLocalParticipantListener) OnDataPacketArgsForCall(i int) (types.LocalParticipant, livekit.DataPacket_Kind, *livekit.DataPacket) { + fake.onDataPacketMutex.RLock() + defer fake.onDataPacketMutex.RUnlock() + argsForCall := fake.onDataPacketArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +} + +func (fake *FakeLocalParticipantListener) OnDataTrackMessage(arg1 types.LocalParticipant, arg2 []byte, arg3 *datatrack.Packet) { + var arg2Copy []byte + if arg2 != nil { + arg2Copy = make([]byte, len(arg2)) + copy(arg2Copy, arg2) + } + fake.onDataTrackMessageMutex.Lock() + fake.onDataTrackMessageArgsForCall = append(fake.onDataTrackMessageArgsForCall, struct { + arg1 types.LocalParticipant + arg2 []byte + arg3 *datatrack.Packet + }{arg1, arg2Copy, arg3}) + stub := fake.OnDataTrackMessageStub + fake.recordInvocation("OnDataTrackMessage", []interface{}{arg1, arg2Copy, arg3}) + fake.onDataTrackMessageMutex.Unlock() + if stub != nil { + fake.OnDataTrackMessageStub(arg1, arg2, arg3) + } +} + +func (fake *FakeLocalParticipantListener) OnDataTrackMessageCallCount() int { + fake.onDataTrackMessageMutex.RLock() + defer fake.onDataTrackMessageMutex.RUnlock() + return len(fake.onDataTrackMessageArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnDataTrackMessageCalls(stub func(types.LocalParticipant, []byte, *datatrack.Packet)) { + fake.onDataTrackMessageMutex.Lock() + defer fake.onDataTrackMessageMutex.Unlock() + fake.OnDataTrackMessageStub = stub +} + +func (fake *FakeLocalParticipantListener) OnDataTrackMessageArgsForCall(i int) (types.LocalParticipant, []byte, *datatrack.Packet) { + fake.onDataTrackMessageMutex.RLock() + defer fake.onDataTrackMessageMutex.RUnlock() + argsForCall := fake.onDataTrackMessageArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +} + +func (fake *FakeLocalParticipantListener) OnDataTrackPublished(arg1 types.Participant, arg2 types.DataTrack) { + fake.onDataTrackPublishedMutex.Lock() + fake.onDataTrackPublishedArgsForCall = append(fake.onDataTrackPublishedArgsForCall, struct { + arg1 types.Participant + arg2 types.DataTrack + }{arg1, arg2}) + stub := fake.OnDataTrackPublishedStub + fake.recordInvocation("OnDataTrackPublished", []interface{}{arg1, arg2}) + fake.onDataTrackPublishedMutex.Unlock() + if stub != nil { + fake.OnDataTrackPublishedStub(arg1, arg2) + } +} + +func (fake *FakeLocalParticipantListener) OnDataTrackPublishedCallCount() int { + fake.onDataTrackPublishedMutex.RLock() + defer fake.onDataTrackPublishedMutex.RUnlock() + return len(fake.onDataTrackPublishedArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnDataTrackPublishedCalls(stub func(types.Participant, types.DataTrack)) { + fake.onDataTrackPublishedMutex.Lock() + defer fake.onDataTrackPublishedMutex.Unlock() + fake.OnDataTrackPublishedStub = stub +} + +func (fake *FakeLocalParticipantListener) OnDataTrackPublishedArgsForCall(i int) (types.Participant, types.DataTrack) { + fake.onDataTrackPublishedMutex.RLock() + defer fake.onDataTrackPublishedMutex.RUnlock() + argsForCall := fake.onDataTrackPublishedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeLocalParticipantListener) OnDataTrackUnpublished(arg1 types.Participant, arg2 types.DataTrack) { + fake.onDataTrackUnpublishedMutex.Lock() + fake.onDataTrackUnpublishedArgsForCall = append(fake.onDataTrackUnpublishedArgsForCall, struct { + arg1 types.Participant + arg2 types.DataTrack + }{arg1, arg2}) + stub := fake.OnDataTrackUnpublishedStub + fake.recordInvocation("OnDataTrackUnpublished", []interface{}{arg1, arg2}) + fake.onDataTrackUnpublishedMutex.Unlock() + if stub != nil { + fake.OnDataTrackUnpublishedStub(arg1, arg2) + } +} + +func (fake *FakeLocalParticipantListener) OnDataTrackUnpublishedCallCount() int { + fake.onDataTrackUnpublishedMutex.RLock() + defer fake.onDataTrackUnpublishedMutex.RUnlock() + return len(fake.onDataTrackUnpublishedArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnDataTrackUnpublishedCalls(stub func(types.Participant, types.DataTrack)) { + fake.onDataTrackUnpublishedMutex.Lock() + defer fake.onDataTrackUnpublishedMutex.Unlock() + fake.OnDataTrackUnpublishedStub = stub +} + +func (fake *FakeLocalParticipantListener) OnDataTrackUnpublishedArgsForCall(i int) (types.Participant, types.DataTrack) { + fake.onDataTrackUnpublishedMutex.RLock() + defer fake.onDataTrackUnpublishedMutex.RUnlock() + argsForCall := fake.onDataTrackUnpublishedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeLocalParticipantListener) OnLeave(arg1 types.LocalParticipant, arg2 types.ParticipantCloseReason) { + fake.onLeaveMutex.Lock() + fake.onLeaveArgsForCall = append(fake.onLeaveArgsForCall, struct { + arg1 types.LocalParticipant + arg2 types.ParticipantCloseReason + }{arg1, arg2}) + stub := fake.OnLeaveStub + fake.recordInvocation("OnLeave", []interface{}{arg1, arg2}) + fake.onLeaveMutex.Unlock() + if stub != nil { + fake.OnLeaveStub(arg1, arg2) + } +} + +func (fake *FakeLocalParticipantListener) OnLeaveCallCount() int { + fake.onLeaveMutex.RLock() + defer fake.onLeaveMutex.RUnlock() + return len(fake.onLeaveArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnLeaveCalls(stub func(types.LocalParticipant, types.ParticipantCloseReason)) { + fake.onLeaveMutex.Lock() + defer fake.onLeaveMutex.Unlock() + fake.OnLeaveStub = stub +} + +func (fake *FakeLocalParticipantListener) OnLeaveArgsForCall(i int) (types.LocalParticipant, types.ParticipantCloseReason) { + fake.onLeaveMutex.RLock() + defer fake.onLeaveMutex.RUnlock() + argsForCall := fake.onLeaveArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeLocalParticipantListener) OnMetrics(arg1 types.Participant, arg2 *livekit.DataPacket) { + fake.onMetricsMutex.Lock() + fake.onMetricsArgsForCall = append(fake.onMetricsArgsForCall, struct { + arg1 types.Participant + arg2 *livekit.DataPacket + }{arg1, arg2}) + stub := fake.OnMetricsStub + fake.recordInvocation("OnMetrics", []interface{}{arg1, arg2}) + fake.onMetricsMutex.Unlock() + if stub != nil { + fake.OnMetricsStub(arg1, arg2) + } +} + +func (fake *FakeLocalParticipantListener) OnMetricsCallCount() int { + fake.onMetricsMutex.RLock() + defer fake.onMetricsMutex.RUnlock() + return len(fake.onMetricsArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnMetricsCalls(stub func(types.Participant, *livekit.DataPacket)) { + fake.onMetricsMutex.Lock() + defer fake.onMetricsMutex.Unlock() + fake.OnMetricsStub = stub +} + +func (fake *FakeLocalParticipantListener) OnMetricsArgsForCall(i int) (types.Participant, *livekit.DataPacket) { + fake.onMetricsMutex.RLock() + defer fake.onMetricsMutex.RUnlock() + argsForCall := fake.onMetricsArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeLocalParticipantListener) OnMigrateStateChange(arg1 types.LocalParticipant, arg2 types.MigrateState) { + fake.onMigrateStateChangeMutex.Lock() + fake.onMigrateStateChangeArgsForCall = append(fake.onMigrateStateChangeArgsForCall, struct { + arg1 types.LocalParticipant + arg2 types.MigrateState + }{arg1, arg2}) + stub := fake.OnMigrateStateChangeStub + fake.recordInvocation("OnMigrateStateChange", []interface{}{arg1, arg2}) + fake.onMigrateStateChangeMutex.Unlock() + if stub != nil { + fake.OnMigrateStateChangeStub(arg1, arg2) + } +} + +func (fake *FakeLocalParticipantListener) OnMigrateStateChangeCallCount() int { + fake.onMigrateStateChangeMutex.RLock() + defer fake.onMigrateStateChangeMutex.RUnlock() + return len(fake.onMigrateStateChangeArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnMigrateStateChangeCalls(stub func(types.LocalParticipant, types.MigrateState)) { + fake.onMigrateStateChangeMutex.Lock() + defer fake.onMigrateStateChangeMutex.Unlock() + fake.OnMigrateStateChangeStub = stub +} + +func (fake *FakeLocalParticipantListener) OnMigrateStateChangeArgsForCall(i int) (types.LocalParticipant, types.MigrateState) { + fake.onMigrateStateChangeMutex.RLock() + defer fake.onMigrateStateChangeMutex.RUnlock() + argsForCall := fake.onMigrateStateChangeArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeLocalParticipantListener) OnParticipantUpdate(arg1 types.Participant) { + fake.onParticipantUpdateMutex.Lock() + fake.onParticipantUpdateArgsForCall = append(fake.onParticipantUpdateArgsForCall, struct { + arg1 types.Participant + }{arg1}) + stub := fake.OnParticipantUpdateStub + fake.recordInvocation("OnParticipantUpdate", []interface{}{arg1}) + fake.onParticipantUpdateMutex.Unlock() + if stub != nil { + fake.OnParticipantUpdateStub(arg1) + } +} + +func (fake *FakeLocalParticipantListener) OnParticipantUpdateCallCount() int { + fake.onParticipantUpdateMutex.RLock() + defer fake.onParticipantUpdateMutex.RUnlock() + return len(fake.onParticipantUpdateArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnParticipantUpdateCalls(stub func(types.Participant)) { + fake.onParticipantUpdateMutex.Lock() + defer fake.onParticipantUpdateMutex.Unlock() + fake.OnParticipantUpdateStub = stub +} + +func (fake *FakeLocalParticipantListener) OnParticipantUpdateArgsForCall(i int) types.Participant { + fake.onParticipantUpdateMutex.RLock() + defer fake.onParticipantUpdateMutex.RUnlock() + argsForCall := fake.onParticipantUpdateArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeLocalParticipantListener) OnSimulateScenario(arg1 types.LocalParticipant, arg2 *livekit.SimulateScenario) error { + fake.onSimulateScenarioMutex.Lock() + ret, specificReturn := fake.onSimulateScenarioReturnsOnCall[len(fake.onSimulateScenarioArgsForCall)] + fake.onSimulateScenarioArgsForCall = append(fake.onSimulateScenarioArgsForCall, struct { + arg1 types.LocalParticipant + arg2 *livekit.SimulateScenario + }{arg1, arg2}) + stub := fake.OnSimulateScenarioStub + fakeReturns := fake.onSimulateScenarioReturns + fake.recordInvocation("OnSimulateScenario", []interface{}{arg1, arg2}) + fake.onSimulateScenarioMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeLocalParticipantListener) OnSimulateScenarioCallCount() int { + fake.onSimulateScenarioMutex.RLock() + defer fake.onSimulateScenarioMutex.RUnlock() + return len(fake.onSimulateScenarioArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnSimulateScenarioCalls(stub func(types.LocalParticipant, *livekit.SimulateScenario) error) { + fake.onSimulateScenarioMutex.Lock() + defer fake.onSimulateScenarioMutex.Unlock() + fake.OnSimulateScenarioStub = stub +} + +func (fake *FakeLocalParticipantListener) OnSimulateScenarioArgsForCall(i int) (types.LocalParticipant, *livekit.SimulateScenario) { + fake.onSimulateScenarioMutex.RLock() + defer fake.onSimulateScenarioMutex.RUnlock() + argsForCall := fake.onSimulateScenarioArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeLocalParticipantListener) OnSimulateScenarioReturns(result1 error) { + fake.onSimulateScenarioMutex.Lock() + defer fake.onSimulateScenarioMutex.Unlock() + fake.OnSimulateScenarioStub = nil + fake.onSimulateScenarioReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeLocalParticipantListener) OnSimulateScenarioReturnsOnCall(i int, result1 error) { + fake.onSimulateScenarioMutex.Lock() + defer fake.onSimulateScenarioMutex.Unlock() + fake.OnSimulateScenarioStub = nil + if fake.onSimulateScenarioReturnsOnCall == nil { + fake.onSimulateScenarioReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.onSimulateScenarioReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeLocalParticipantListener) OnStateChange(arg1 types.LocalParticipant) { + fake.onStateChangeMutex.Lock() + fake.onStateChangeArgsForCall = append(fake.onStateChangeArgsForCall, struct { + arg1 types.LocalParticipant + }{arg1}) + stub := fake.OnStateChangeStub + fake.recordInvocation("OnStateChange", []interface{}{arg1}) + fake.onStateChangeMutex.Unlock() + if stub != nil { + fake.OnStateChangeStub(arg1) + } +} + +func (fake *FakeLocalParticipantListener) OnStateChangeCallCount() int { + fake.onStateChangeMutex.RLock() + defer fake.onStateChangeMutex.RUnlock() + return len(fake.onStateChangeArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnStateChangeCalls(stub func(types.LocalParticipant)) { + fake.onStateChangeMutex.Lock() + defer fake.onStateChangeMutex.Unlock() + fake.OnStateChangeStub = stub +} + +func (fake *FakeLocalParticipantListener) OnStateChangeArgsForCall(i int) types.LocalParticipant { + fake.onStateChangeMutex.RLock() + defer fake.onStateChangeMutex.RUnlock() + argsForCall := fake.onStateChangeArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeLocalParticipantListener) OnSubscribeStatusChanged(arg1 types.LocalParticipant, arg2 livekit.ParticipantID, arg3 bool) { + fake.onSubscribeStatusChangedMutex.Lock() + fake.onSubscribeStatusChangedArgsForCall = append(fake.onSubscribeStatusChangedArgsForCall, struct { + arg1 types.LocalParticipant + arg2 livekit.ParticipantID + arg3 bool + }{arg1, arg2, arg3}) + stub := fake.OnSubscribeStatusChangedStub + fake.recordInvocation("OnSubscribeStatusChanged", []interface{}{arg1, arg2, arg3}) + fake.onSubscribeStatusChangedMutex.Unlock() + if stub != nil { + fake.OnSubscribeStatusChangedStub(arg1, arg2, arg3) + } +} + +func (fake *FakeLocalParticipantListener) OnSubscribeStatusChangedCallCount() int { + fake.onSubscribeStatusChangedMutex.RLock() + defer fake.onSubscribeStatusChangedMutex.RUnlock() + return len(fake.onSubscribeStatusChangedArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnSubscribeStatusChangedCalls(stub func(types.LocalParticipant, livekit.ParticipantID, bool)) { + fake.onSubscribeStatusChangedMutex.Lock() + defer fake.onSubscribeStatusChangedMutex.Unlock() + fake.OnSubscribeStatusChangedStub = stub +} + +func (fake *FakeLocalParticipantListener) OnSubscribeStatusChangedArgsForCall(i int) (types.LocalParticipant, livekit.ParticipantID, bool) { + fake.onSubscribeStatusChangedMutex.RLock() + defer fake.onSubscribeStatusChangedMutex.RUnlock() + argsForCall := fake.onSubscribeStatusChangedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3 +} + +func (fake *FakeLocalParticipantListener) OnSubscriberReady(arg1 types.LocalParticipant) { + fake.onSubscriberReadyMutex.Lock() + fake.onSubscriberReadyArgsForCall = append(fake.onSubscriberReadyArgsForCall, struct { + arg1 types.LocalParticipant + }{arg1}) + stub := fake.OnSubscriberReadyStub + fake.recordInvocation("OnSubscriberReady", []interface{}{arg1}) + fake.onSubscriberReadyMutex.Unlock() + if stub != nil { + fake.OnSubscriberReadyStub(arg1) + } +} + +func (fake *FakeLocalParticipantListener) OnSubscriberReadyCallCount() int { + fake.onSubscriberReadyMutex.RLock() + defer fake.onSubscriberReadyMutex.RUnlock() + return len(fake.onSubscriberReadyArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnSubscriberReadyCalls(stub func(types.LocalParticipant)) { + fake.onSubscriberReadyMutex.Lock() + defer fake.onSubscriberReadyMutex.Unlock() + fake.OnSubscriberReadyStub = stub +} + +func (fake *FakeLocalParticipantListener) OnSubscriberReadyArgsForCall(i int) types.LocalParticipant { + fake.onSubscriberReadyMutex.RLock() + defer fake.onSubscriberReadyMutex.RUnlock() + argsForCall := fake.onSubscriberReadyArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeLocalParticipantListener) OnSyncState(arg1 types.LocalParticipant, arg2 *livekit.SyncState) error { + fake.onSyncStateMutex.Lock() + ret, specificReturn := fake.onSyncStateReturnsOnCall[len(fake.onSyncStateArgsForCall)] + fake.onSyncStateArgsForCall = append(fake.onSyncStateArgsForCall, struct { + arg1 types.LocalParticipant + arg2 *livekit.SyncState + }{arg1, arg2}) + stub := fake.OnSyncStateStub + fakeReturns := fake.onSyncStateReturns + fake.recordInvocation("OnSyncState", []interface{}{arg1, arg2}) + fake.onSyncStateMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeLocalParticipantListener) OnSyncStateCallCount() int { + fake.onSyncStateMutex.RLock() + defer fake.onSyncStateMutex.RUnlock() + return len(fake.onSyncStateArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnSyncStateCalls(stub func(types.LocalParticipant, *livekit.SyncState) error) { + fake.onSyncStateMutex.Lock() + defer fake.onSyncStateMutex.Unlock() + fake.OnSyncStateStub = stub +} + +func (fake *FakeLocalParticipantListener) OnSyncStateArgsForCall(i int) (types.LocalParticipant, *livekit.SyncState) { + fake.onSyncStateMutex.RLock() + defer fake.onSyncStateMutex.RUnlock() + argsForCall := fake.onSyncStateArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeLocalParticipantListener) OnSyncStateReturns(result1 error) { + fake.onSyncStateMutex.Lock() + defer fake.onSyncStateMutex.Unlock() + fake.OnSyncStateStub = nil + fake.onSyncStateReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeLocalParticipantListener) OnSyncStateReturnsOnCall(i int, result1 error) { + fake.onSyncStateMutex.Lock() + defer fake.onSyncStateMutex.Unlock() + fake.OnSyncStateStub = nil + if fake.onSyncStateReturnsOnCall == nil { + fake.onSyncStateReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.onSyncStateReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeLocalParticipantListener) OnTrackPublished(arg1 types.Participant, arg2 types.MediaTrack) { + fake.onTrackPublishedMutex.Lock() + fake.onTrackPublishedArgsForCall = append(fake.onTrackPublishedArgsForCall, struct { + arg1 types.Participant + arg2 types.MediaTrack + }{arg1, arg2}) + stub := fake.OnTrackPublishedStub + fake.recordInvocation("OnTrackPublished", []interface{}{arg1, arg2}) + fake.onTrackPublishedMutex.Unlock() + if stub != nil { + fake.OnTrackPublishedStub(arg1, arg2) + } +} + +func (fake *FakeLocalParticipantListener) OnTrackPublishedCallCount() int { + fake.onTrackPublishedMutex.RLock() + defer fake.onTrackPublishedMutex.RUnlock() + return len(fake.onTrackPublishedArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnTrackPublishedCalls(stub func(types.Participant, types.MediaTrack)) { + fake.onTrackPublishedMutex.Lock() + defer fake.onTrackPublishedMutex.Unlock() + fake.OnTrackPublishedStub = stub +} + +func (fake *FakeLocalParticipantListener) OnTrackPublishedArgsForCall(i int) (types.Participant, types.MediaTrack) { + fake.onTrackPublishedMutex.RLock() + defer fake.onTrackPublishedMutex.RUnlock() + argsForCall := fake.onTrackPublishedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeLocalParticipantListener) OnTrackUnpublished(arg1 types.Participant, arg2 types.MediaTrack) { + fake.onTrackUnpublishedMutex.Lock() + fake.onTrackUnpublishedArgsForCall = append(fake.onTrackUnpublishedArgsForCall, struct { + arg1 types.Participant + arg2 types.MediaTrack + }{arg1, arg2}) + stub := fake.OnTrackUnpublishedStub + fake.recordInvocation("OnTrackUnpublished", []interface{}{arg1, arg2}) + fake.onTrackUnpublishedMutex.Unlock() + if stub != nil { + fake.OnTrackUnpublishedStub(arg1, arg2) + } +} + +func (fake *FakeLocalParticipantListener) OnTrackUnpublishedCallCount() int { + fake.onTrackUnpublishedMutex.RLock() + defer fake.onTrackUnpublishedMutex.RUnlock() + return len(fake.onTrackUnpublishedArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnTrackUnpublishedCalls(stub func(types.Participant, types.MediaTrack)) { + fake.onTrackUnpublishedMutex.Lock() + defer fake.onTrackUnpublishedMutex.Unlock() + fake.OnTrackUnpublishedStub = stub +} + +func (fake *FakeLocalParticipantListener) OnTrackUnpublishedArgsForCall(i int) (types.Participant, types.MediaTrack) { + fake.onTrackUnpublishedMutex.RLock() + defer fake.onTrackUnpublishedMutex.RUnlock() + argsForCall := fake.onTrackUnpublishedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeLocalParticipantListener) OnTrackUpdated(arg1 types.Participant, arg2 types.MediaTrack) { + fake.onTrackUpdatedMutex.Lock() + fake.onTrackUpdatedArgsForCall = append(fake.onTrackUpdatedArgsForCall, struct { + arg1 types.Participant + arg2 types.MediaTrack + }{arg1, arg2}) + stub := fake.OnTrackUpdatedStub + fake.recordInvocation("OnTrackUpdated", []interface{}{arg1, arg2}) + fake.onTrackUpdatedMutex.Unlock() + if stub != nil { + fake.OnTrackUpdatedStub(arg1, arg2) + } +} + +func (fake *FakeLocalParticipantListener) OnTrackUpdatedCallCount() int { + fake.onTrackUpdatedMutex.RLock() + defer fake.onTrackUpdatedMutex.RUnlock() + return len(fake.onTrackUpdatedArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnTrackUpdatedCalls(stub func(types.Participant, types.MediaTrack)) { + fake.onTrackUpdatedMutex.Lock() + defer fake.onTrackUpdatedMutex.Unlock() + fake.OnTrackUpdatedStub = stub +} + +func (fake *FakeLocalParticipantListener) OnTrackUpdatedArgsForCall(i int) (types.Participant, types.MediaTrack) { + fake.onTrackUpdatedMutex.RLock() + defer fake.onTrackUpdatedMutex.RUnlock() + argsForCall := fake.onTrackUpdatedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeLocalParticipantListener) OnUpdateDataSubscriptions(arg1 types.LocalParticipant, arg2 *livekit.UpdateDataSubscription) { + fake.onUpdateDataSubscriptionsMutex.Lock() + fake.onUpdateDataSubscriptionsArgsForCall = append(fake.onUpdateDataSubscriptionsArgsForCall, struct { + arg1 types.LocalParticipant + arg2 *livekit.UpdateDataSubscription + }{arg1, arg2}) + stub := fake.OnUpdateDataSubscriptionsStub + fake.recordInvocation("OnUpdateDataSubscriptions", []interface{}{arg1, arg2}) + fake.onUpdateDataSubscriptionsMutex.Unlock() + if stub != nil { + fake.OnUpdateDataSubscriptionsStub(arg1, arg2) + } +} + +func (fake *FakeLocalParticipantListener) OnUpdateDataSubscriptionsCallCount() int { + fake.onUpdateDataSubscriptionsMutex.RLock() + defer fake.onUpdateDataSubscriptionsMutex.RUnlock() + return len(fake.onUpdateDataSubscriptionsArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnUpdateDataSubscriptionsCalls(stub func(types.LocalParticipant, *livekit.UpdateDataSubscription)) { + fake.onUpdateDataSubscriptionsMutex.Lock() + defer fake.onUpdateDataSubscriptionsMutex.Unlock() + fake.OnUpdateDataSubscriptionsStub = stub +} + +func (fake *FakeLocalParticipantListener) OnUpdateDataSubscriptionsArgsForCall(i int) (types.LocalParticipant, *livekit.UpdateDataSubscription) { + fake.onUpdateDataSubscriptionsMutex.RLock() + defer fake.onUpdateDataSubscriptionsMutex.RUnlock() + argsForCall := fake.onUpdateDataSubscriptionsArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeLocalParticipantListener) OnUpdateSubscriptionPermission(arg1 types.LocalParticipant, arg2 *livekit.SubscriptionPermission) error { + fake.onUpdateSubscriptionPermissionMutex.Lock() + ret, specificReturn := fake.onUpdateSubscriptionPermissionReturnsOnCall[len(fake.onUpdateSubscriptionPermissionArgsForCall)] + fake.onUpdateSubscriptionPermissionArgsForCall = append(fake.onUpdateSubscriptionPermissionArgsForCall, struct { + arg1 types.LocalParticipant + arg2 *livekit.SubscriptionPermission + }{arg1, arg2}) + stub := fake.OnUpdateSubscriptionPermissionStub + fakeReturns := fake.onUpdateSubscriptionPermissionReturns + fake.recordInvocation("OnUpdateSubscriptionPermission", []interface{}{arg1, arg2}) + fake.onUpdateSubscriptionPermissionMutex.Unlock() + if stub != nil { + return stub(arg1, arg2) + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeLocalParticipantListener) OnUpdateSubscriptionPermissionCallCount() int { + fake.onUpdateSubscriptionPermissionMutex.RLock() + defer fake.onUpdateSubscriptionPermissionMutex.RUnlock() + return len(fake.onUpdateSubscriptionPermissionArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnUpdateSubscriptionPermissionCalls(stub func(types.LocalParticipant, *livekit.SubscriptionPermission) error) { + fake.onUpdateSubscriptionPermissionMutex.Lock() + defer fake.onUpdateSubscriptionPermissionMutex.Unlock() + fake.OnUpdateSubscriptionPermissionStub = stub +} + +func (fake *FakeLocalParticipantListener) OnUpdateSubscriptionPermissionArgsForCall(i int) (types.LocalParticipant, *livekit.SubscriptionPermission) { + fake.onUpdateSubscriptionPermissionMutex.RLock() + defer fake.onUpdateSubscriptionPermissionMutex.RUnlock() + argsForCall := fake.onUpdateSubscriptionPermissionArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeLocalParticipantListener) OnUpdateSubscriptionPermissionReturns(result1 error) { + fake.onUpdateSubscriptionPermissionMutex.Lock() + defer fake.onUpdateSubscriptionPermissionMutex.Unlock() + fake.OnUpdateSubscriptionPermissionStub = nil + fake.onUpdateSubscriptionPermissionReturns = struct { + result1 error + }{result1} +} + +func (fake *FakeLocalParticipantListener) OnUpdateSubscriptionPermissionReturnsOnCall(i int, result1 error) { + fake.onUpdateSubscriptionPermissionMutex.Lock() + defer fake.onUpdateSubscriptionPermissionMutex.Unlock() + fake.OnUpdateSubscriptionPermissionStub = nil + if fake.onUpdateSubscriptionPermissionReturnsOnCall == nil { + fake.onUpdateSubscriptionPermissionReturnsOnCall = make(map[int]struct { + result1 error + }) + } + fake.onUpdateSubscriptionPermissionReturnsOnCall[i] = struct { + result1 error + }{result1} +} + +func (fake *FakeLocalParticipantListener) OnUpdateSubscriptions(arg1 types.LocalParticipant, arg2 []livekit.TrackID, arg3 []*livekit.ParticipantTracks, arg4 bool) { + var arg2Copy []livekit.TrackID + if arg2 != nil { + arg2Copy = make([]livekit.TrackID, len(arg2)) + copy(arg2Copy, arg2) + } + var arg3Copy []*livekit.ParticipantTracks + if arg3 != nil { + arg3Copy = make([]*livekit.ParticipantTracks, len(arg3)) + copy(arg3Copy, arg3) + } + fake.onUpdateSubscriptionsMutex.Lock() + fake.onUpdateSubscriptionsArgsForCall = append(fake.onUpdateSubscriptionsArgsForCall, struct { + arg1 types.LocalParticipant + arg2 []livekit.TrackID + arg3 []*livekit.ParticipantTracks + arg4 bool + }{arg1, arg2Copy, arg3Copy, arg4}) + stub := fake.OnUpdateSubscriptionsStub + fake.recordInvocation("OnUpdateSubscriptions", []interface{}{arg1, arg2Copy, arg3Copy, arg4}) + fake.onUpdateSubscriptionsMutex.Unlock() + if stub != nil { + fake.OnUpdateSubscriptionsStub(arg1, arg2, arg3, arg4) + } +} + +func (fake *FakeLocalParticipantListener) OnUpdateSubscriptionsCallCount() int { + fake.onUpdateSubscriptionsMutex.RLock() + defer fake.onUpdateSubscriptionsMutex.RUnlock() + return len(fake.onUpdateSubscriptionsArgsForCall) +} + +func (fake *FakeLocalParticipantListener) OnUpdateSubscriptionsCalls(stub func(types.LocalParticipant, []livekit.TrackID, []*livekit.ParticipantTracks, bool)) { + fake.onUpdateSubscriptionsMutex.Lock() + defer fake.onUpdateSubscriptionsMutex.Unlock() + fake.OnUpdateSubscriptionsStub = stub +} + +func (fake *FakeLocalParticipantListener) OnUpdateSubscriptionsArgsForCall(i int) (types.LocalParticipant, []livekit.TrackID, []*livekit.ParticipantTracks, bool) { + fake.onUpdateSubscriptionsMutex.RLock() + defer fake.onUpdateSubscriptionsMutex.RUnlock() + argsForCall := fake.onUpdateSubscriptionsArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3, argsForCall.arg4 +} + +func (fake *FakeLocalParticipantListener) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeLocalParticipantListener) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ types.LocalParticipantListener = new(FakeLocalParticipantListener) diff --git a/pkg/rtc/types/typesfakes/fake_participant.go b/pkg/rtc/types/typesfakes/fake_participant.go index 32863c28b..901aef727 100644 --- a/pkg/rtc/types/typesfakes/fake_participant.go +++ b/pkg/rtc/types/typesfakes/fake_participant.go @@ -88,6 +88,16 @@ type FakeParticipant struct { getLoggerReturnsOnCall map[int]struct { result1 logger.Logger } + GetParticipantListenerStub func() types.ParticipantListener + getParticipantListenerMutex sync.RWMutex + getParticipantListenerArgsForCall []struct { + } + getParticipantListenerReturns struct { + result1 types.ParticipantListener + } + getParticipantListenerReturnsOnCall map[int]struct { + result1 types.ParticipantListener + } GetPublishedDataTrackStub func(uint16) types.DataTrack getPublishedDataTrackMutex sync.RWMutex getPublishedDataTrackArgsForCall []struct { @@ -258,36 +268,6 @@ type FakeParticipant struct { migrateStateReturnsOnCall map[int]struct { result1 types.MigrateState } - OnDataTrackPublishedStub func(func(types.Participant, types.DataTrack)) - onDataTrackPublishedMutex sync.RWMutex - onDataTrackPublishedArgsForCall []struct { - arg1 func(types.Participant, types.DataTrack) - } - OnDataTrackUnpublishedStub func(func(types.Participant, types.DataTrack)) - onDataTrackUnpublishedMutex sync.RWMutex - onDataTrackUnpublishedArgsForCall []struct { - arg1 func(types.Participant, types.DataTrack) - } - OnMetricsStub func(func(types.Participant, *livekit.DataPacket)) - onMetricsMutex sync.RWMutex - onMetricsArgsForCall []struct { - arg1 func(types.Participant, *livekit.DataPacket) - } - OnTrackPublishedStub func(func(types.Participant, types.MediaTrack)) - onTrackPublishedMutex sync.RWMutex - onTrackPublishedArgsForCall []struct { - arg1 func(types.Participant, types.MediaTrack) - } - OnTrackUnpublishedStub func(func(types.Participant, types.MediaTrack)) - onTrackUnpublishedMutex sync.RWMutex - onTrackUnpublishedArgsForCall []struct { - arg1 func(types.Participant, types.MediaTrack) - } - OnTrackUpdatedStub func(func(types.Participant, types.MediaTrack)) - onTrackUpdatedMutex sync.RWMutex - onTrackUpdatedArgsForCall []struct { - arg1 func(types.Participant, types.MediaTrack) - } RemovePublishedDataTrackStub func(types.DataTrack) removePublishedDataTrackMutex sync.RWMutex removePublishedDataTrackArgsForCall []struct { @@ -754,6 +734,59 @@ func (fake *FakeParticipant) GetLoggerReturnsOnCall(i int, result1 logger.Logger }{result1} } +func (fake *FakeParticipant) GetParticipantListener() types.ParticipantListener { + fake.getParticipantListenerMutex.Lock() + ret, specificReturn := fake.getParticipantListenerReturnsOnCall[len(fake.getParticipantListenerArgsForCall)] + fake.getParticipantListenerArgsForCall = append(fake.getParticipantListenerArgsForCall, struct { + }{}) + stub := fake.GetParticipantListenerStub + fakeReturns := fake.getParticipantListenerReturns + fake.recordInvocation("GetParticipantListener", []interface{}{}) + fake.getParticipantListenerMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeParticipant) GetParticipantListenerCallCount() int { + fake.getParticipantListenerMutex.RLock() + defer fake.getParticipantListenerMutex.RUnlock() + return len(fake.getParticipantListenerArgsForCall) +} + +func (fake *FakeParticipant) GetParticipantListenerCalls(stub func() types.ParticipantListener) { + fake.getParticipantListenerMutex.Lock() + defer fake.getParticipantListenerMutex.Unlock() + fake.GetParticipantListenerStub = stub +} + +func (fake *FakeParticipant) GetParticipantListenerReturns(result1 types.ParticipantListener) { + fake.getParticipantListenerMutex.Lock() + defer fake.getParticipantListenerMutex.Unlock() + fake.GetParticipantListenerStub = nil + fake.getParticipantListenerReturns = struct { + result1 types.ParticipantListener + }{result1} +} + +func (fake *FakeParticipant) GetParticipantListenerReturnsOnCall(i int, result1 types.ParticipantListener) { + fake.getParticipantListenerMutex.Lock() + defer fake.getParticipantListenerMutex.Unlock() + fake.GetParticipantListenerStub = nil + if fake.getParticipantListenerReturnsOnCall == nil { + fake.getParticipantListenerReturnsOnCall = make(map[int]struct { + result1 types.ParticipantListener + }) + } + fake.getParticipantListenerReturnsOnCall[i] = struct { + result1 types.ParticipantListener + }{result1} +} + func (fake *FakeParticipant) GetPublishedDataTrack(arg1 uint16) types.DataTrack { fake.getPublishedDataTrackMutex.Lock() ret, specificReturn := fake.getPublishedDataTrackReturnsOnCall[len(fake.getPublishedDataTrackArgsForCall)] @@ -1665,198 +1698,6 @@ func (fake *FakeParticipant) MigrateStateReturnsOnCall(i int, result1 types.Migr }{result1} } -func (fake *FakeParticipant) OnDataTrackPublished(arg1 func(types.Participant, types.DataTrack)) { - fake.onDataTrackPublishedMutex.Lock() - fake.onDataTrackPublishedArgsForCall = append(fake.onDataTrackPublishedArgsForCall, struct { - arg1 func(types.Participant, types.DataTrack) - }{arg1}) - stub := fake.OnDataTrackPublishedStub - fake.recordInvocation("OnDataTrackPublished", []interface{}{arg1}) - fake.onDataTrackPublishedMutex.Unlock() - if stub != nil { - fake.OnDataTrackPublishedStub(arg1) - } -} - -func (fake *FakeParticipant) OnDataTrackPublishedCallCount() int { - fake.onDataTrackPublishedMutex.RLock() - defer fake.onDataTrackPublishedMutex.RUnlock() - return len(fake.onDataTrackPublishedArgsForCall) -} - -func (fake *FakeParticipant) OnDataTrackPublishedCalls(stub func(func(types.Participant, types.DataTrack))) { - fake.onDataTrackPublishedMutex.Lock() - defer fake.onDataTrackPublishedMutex.Unlock() - fake.OnDataTrackPublishedStub = stub -} - -func (fake *FakeParticipant) OnDataTrackPublishedArgsForCall(i int) func(types.Participant, types.DataTrack) { - fake.onDataTrackPublishedMutex.RLock() - defer fake.onDataTrackPublishedMutex.RUnlock() - argsForCall := fake.onDataTrackPublishedArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeParticipant) OnDataTrackUnpublished(arg1 func(types.Participant, types.DataTrack)) { - fake.onDataTrackUnpublishedMutex.Lock() - fake.onDataTrackUnpublishedArgsForCall = append(fake.onDataTrackUnpublishedArgsForCall, struct { - arg1 func(types.Participant, types.DataTrack) - }{arg1}) - stub := fake.OnDataTrackUnpublishedStub - fake.recordInvocation("OnDataTrackUnpublished", []interface{}{arg1}) - fake.onDataTrackUnpublishedMutex.Unlock() - if stub != nil { - fake.OnDataTrackUnpublishedStub(arg1) - } -} - -func (fake *FakeParticipant) OnDataTrackUnpublishedCallCount() int { - fake.onDataTrackUnpublishedMutex.RLock() - defer fake.onDataTrackUnpublishedMutex.RUnlock() - return len(fake.onDataTrackUnpublishedArgsForCall) -} - -func (fake *FakeParticipant) OnDataTrackUnpublishedCalls(stub func(func(types.Participant, types.DataTrack))) { - fake.onDataTrackUnpublishedMutex.Lock() - defer fake.onDataTrackUnpublishedMutex.Unlock() - fake.OnDataTrackUnpublishedStub = stub -} - -func (fake *FakeParticipant) OnDataTrackUnpublishedArgsForCall(i int) func(types.Participant, types.DataTrack) { - fake.onDataTrackUnpublishedMutex.RLock() - defer fake.onDataTrackUnpublishedMutex.RUnlock() - argsForCall := fake.onDataTrackUnpublishedArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeParticipant) OnMetrics(arg1 func(types.Participant, *livekit.DataPacket)) { - fake.onMetricsMutex.Lock() - fake.onMetricsArgsForCall = append(fake.onMetricsArgsForCall, struct { - arg1 func(types.Participant, *livekit.DataPacket) - }{arg1}) - stub := fake.OnMetricsStub - fake.recordInvocation("OnMetrics", []interface{}{arg1}) - fake.onMetricsMutex.Unlock() - if stub != nil { - fake.OnMetricsStub(arg1) - } -} - -func (fake *FakeParticipant) OnMetricsCallCount() int { - fake.onMetricsMutex.RLock() - defer fake.onMetricsMutex.RUnlock() - return len(fake.onMetricsArgsForCall) -} - -func (fake *FakeParticipant) OnMetricsCalls(stub func(func(types.Participant, *livekit.DataPacket))) { - fake.onMetricsMutex.Lock() - defer fake.onMetricsMutex.Unlock() - fake.OnMetricsStub = stub -} - -func (fake *FakeParticipant) OnMetricsArgsForCall(i int) func(types.Participant, *livekit.DataPacket) { - fake.onMetricsMutex.RLock() - defer fake.onMetricsMutex.RUnlock() - argsForCall := fake.onMetricsArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeParticipant) OnTrackPublished(arg1 func(types.Participant, types.MediaTrack)) { - fake.onTrackPublishedMutex.Lock() - fake.onTrackPublishedArgsForCall = append(fake.onTrackPublishedArgsForCall, struct { - arg1 func(types.Participant, types.MediaTrack) - }{arg1}) - stub := fake.OnTrackPublishedStub - fake.recordInvocation("OnTrackPublished", []interface{}{arg1}) - fake.onTrackPublishedMutex.Unlock() - if stub != nil { - fake.OnTrackPublishedStub(arg1) - } -} - -func (fake *FakeParticipant) OnTrackPublishedCallCount() int { - fake.onTrackPublishedMutex.RLock() - defer fake.onTrackPublishedMutex.RUnlock() - return len(fake.onTrackPublishedArgsForCall) -} - -func (fake *FakeParticipant) OnTrackPublishedCalls(stub func(func(types.Participant, types.MediaTrack))) { - fake.onTrackPublishedMutex.Lock() - defer fake.onTrackPublishedMutex.Unlock() - fake.OnTrackPublishedStub = stub -} - -func (fake *FakeParticipant) OnTrackPublishedArgsForCall(i int) func(types.Participant, types.MediaTrack) { - fake.onTrackPublishedMutex.RLock() - defer fake.onTrackPublishedMutex.RUnlock() - argsForCall := fake.onTrackPublishedArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeParticipant) OnTrackUnpublished(arg1 func(types.Participant, types.MediaTrack)) { - fake.onTrackUnpublishedMutex.Lock() - fake.onTrackUnpublishedArgsForCall = append(fake.onTrackUnpublishedArgsForCall, struct { - arg1 func(types.Participant, types.MediaTrack) - }{arg1}) - stub := fake.OnTrackUnpublishedStub - fake.recordInvocation("OnTrackUnpublished", []interface{}{arg1}) - fake.onTrackUnpublishedMutex.Unlock() - if stub != nil { - fake.OnTrackUnpublishedStub(arg1) - } -} - -func (fake *FakeParticipant) OnTrackUnpublishedCallCount() int { - fake.onTrackUnpublishedMutex.RLock() - defer fake.onTrackUnpublishedMutex.RUnlock() - return len(fake.onTrackUnpublishedArgsForCall) -} - -func (fake *FakeParticipant) OnTrackUnpublishedCalls(stub func(func(types.Participant, types.MediaTrack))) { - fake.onTrackUnpublishedMutex.Lock() - defer fake.onTrackUnpublishedMutex.Unlock() - fake.OnTrackUnpublishedStub = stub -} - -func (fake *FakeParticipant) OnTrackUnpublishedArgsForCall(i int) func(types.Participant, types.MediaTrack) { - fake.onTrackUnpublishedMutex.RLock() - defer fake.onTrackUnpublishedMutex.RUnlock() - argsForCall := fake.onTrackUnpublishedArgsForCall[i] - return argsForCall.arg1 -} - -func (fake *FakeParticipant) OnTrackUpdated(arg1 func(types.Participant, types.MediaTrack)) { - fake.onTrackUpdatedMutex.Lock() - fake.onTrackUpdatedArgsForCall = append(fake.onTrackUpdatedArgsForCall, struct { - arg1 func(types.Participant, types.MediaTrack) - }{arg1}) - stub := fake.OnTrackUpdatedStub - fake.recordInvocation("OnTrackUpdated", []interface{}{arg1}) - fake.onTrackUpdatedMutex.Unlock() - if stub != nil { - fake.OnTrackUpdatedStub(arg1) - } -} - -func (fake *FakeParticipant) OnTrackUpdatedCallCount() int { - fake.onTrackUpdatedMutex.RLock() - defer fake.onTrackUpdatedMutex.RUnlock() - return len(fake.onTrackUpdatedArgsForCall) -} - -func (fake *FakeParticipant) OnTrackUpdatedCalls(stub func(func(types.Participant, types.MediaTrack))) { - fake.onTrackUpdatedMutex.Lock() - defer fake.onTrackUpdatedMutex.Unlock() - fake.OnTrackUpdatedStub = stub -} - -func (fake *FakeParticipant) OnTrackUpdatedArgsForCall(i int) func(types.Participant, types.MediaTrack) { - fake.onTrackUpdatedMutex.RLock() - defer fake.onTrackUpdatedMutex.RUnlock() - argsForCall := fake.onTrackUpdatedArgsForCall[i] - return argsForCall.arg1 -} - func (fake *FakeParticipant) RemovePublishedDataTrack(arg1 types.DataTrack) { fake.removePublishedDataTrackMutex.Lock() fake.removePublishedDataTrackArgsForCall = append(fake.removePublishedDataTrackArgsForCall, struct { diff --git a/pkg/rtc/types/typesfakes/fake_participant_listener.go b/pkg/rtc/types/typesfakes/fake_participant_listener.go new file mode 100644 index 000000000..09edd2413 --- /dev/null +++ b/pkg/rtc/types/typesfakes/fake_participant_listener.go @@ -0,0 +1,309 @@ +// Code generated by counterfeiter. DO NOT EDIT. +package typesfakes + +import ( + "sync" + + "github.com/livekit/livekit-server/pkg/rtc/types" + "github.com/livekit/protocol/livekit" +) + +type FakeParticipantListener struct { + OnDataTrackPublishedStub func(types.Participant, types.DataTrack) + onDataTrackPublishedMutex sync.RWMutex + onDataTrackPublishedArgsForCall []struct { + arg1 types.Participant + arg2 types.DataTrack + } + OnDataTrackUnpublishedStub func(types.Participant, types.DataTrack) + onDataTrackUnpublishedMutex sync.RWMutex + onDataTrackUnpublishedArgsForCall []struct { + arg1 types.Participant + arg2 types.DataTrack + } + OnMetricsStub func(types.Participant, *livekit.DataPacket) + onMetricsMutex sync.RWMutex + onMetricsArgsForCall []struct { + arg1 types.Participant + arg2 *livekit.DataPacket + } + OnParticipantUpdateStub func(types.Participant) + onParticipantUpdateMutex sync.RWMutex + onParticipantUpdateArgsForCall []struct { + arg1 types.Participant + } + OnTrackPublishedStub func(types.Participant, types.MediaTrack) + onTrackPublishedMutex sync.RWMutex + onTrackPublishedArgsForCall []struct { + arg1 types.Participant + arg2 types.MediaTrack + } + OnTrackUnpublishedStub func(types.Participant, types.MediaTrack) + onTrackUnpublishedMutex sync.RWMutex + onTrackUnpublishedArgsForCall []struct { + arg1 types.Participant + arg2 types.MediaTrack + } + OnTrackUpdatedStub func(types.Participant, types.MediaTrack) + onTrackUpdatedMutex sync.RWMutex + onTrackUpdatedArgsForCall []struct { + arg1 types.Participant + arg2 types.MediaTrack + } + invocations map[string][][]interface{} + invocationsMutex sync.RWMutex +} + +func (fake *FakeParticipantListener) OnDataTrackPublished(arg1 types.Participant, arg2 types.DataTrack) { + fake.onDataTrackPublishedMutex.Lock() + fake.onDataTrackPublishedArgsForCall = append(fake.onDataTrackPublishedArgsForCall, struct { + arg1 types.Participant + arg2 types.DataTrack + }{arg1, arg2}) + stub := fake.OnDataTrackPublishedStub + fake.recordInvocation("OnDataTrackPublished", []interface{}{arg1, arg2}) + fake.onDataTrackPublishedMutex.Unlock() + if stub != nil { + fake.OnDataTrackPublishedStub(arg1, arg2) + } +} + +func (fake *FakeParticipantListener) OnDataTrackPublishedCallCount() int { + fake.onDataTrackPublishedMutex.RLock() + defer fake.onDataTrackPublishedMutex.RUnlock() + return len(fake.onDataTrackPublishedArgsForCall) +} + +func (fake *FakeParticipantListener) OnDataTrackPublishedCalls(stub func(types.Participant, types.DataTrack)) { + fake.onDataTrackPublishedMutex.Lock() + defer fake.onDataTrackPublishedMutex.Unlock() + fake.OnDataTrackPublishedStub = stub +} + +func (fake *FakeParticipantListener) OnDataTrackPublishedArgsForCall(i int) (types.Participant, types.DataTrack) { + fake.onDataTrackPublishedMutex.RLock() + defer fake.onDataTrackPublishedMutex.RUnlock() + argsForCall := fake.onDataTrackPublishedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeParticipantListener) OnDataTrackUnpublished(arg1 types.Participant, arg2 types.DataTrack) { + fake.onDataTrackUnpublishedMutex.Lock() + fake.onDataTrackUnpublishedArgsForCall = append(fake.onDataTrackUnpublishedArgsForCall, struct { + arg1 types.Participant + arg2 types.DataTrack + }{arg1, arg2}) + stub := fake.OnDataTrackUnpublishedStub + fake.recordInvocation("OnDataTrackUnpublished", []interface{}{arg1, arg2}) + fake.onDataTrackUnpublishedMutex.Unlock() + if stub != nil { + fake.OnDataTrackUnpublishedStub(arg1, arg2) + } +} + +func (fake *FakeParticipantListener) OnDataTrackUnpublishedCallCount() int { + fake.onDataTrackUnpublishedMutex.RLock() + defer fake.onDataTrackUnpublishedMutex.RUnlock() + return len(fake.onDataTrackUnpublishedArgsForCall) +} + +func (fake *FakeParticipantListener) OnDataTrackUnpublishedCalls(stub func(types.Participant, types.DataTrack)) { + fake.onDataTrackUnpublishedMutex.Lock() + defer fake.onDataTrackUnpublishedMutex.Unlock() + fake.OnDataTrackUnpublishedStub = stub +} + +func (fake *FakeParticipantListener) OnDataTrackUnpublishedArgsForCall(i int) (types.Participant, types.DataTrack) { + fake.onDataTrackUnpublishedMutex.RLock() + defer fake.onDataTrackUnpublishedMutex.RUnlock() + argsForCall := fake.onDataTrackUnpublishedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeParticipantListener) OnMetrics(arg1 types.Participant, arg2 *livekit.DataPacket) { + fake.onMetricsMutex.Lock() + fake.onMetricsArgsForCall = append(fake.onMetricsArgsForCall, struct { + arg1 types.Participant + arg2 *livekit.DataPacket + }{arg1, arg2}) + stub := fake.OnMetricsStub + fake.recordInvocation("OnMetrics", []interface{}{arg1, arg2}) + fake.onMetricsMutex.Unlock() + if stub != nil { + fake.OnMetricsStub(arg1, arg2) + } +} + +func (fake *FakeParticipantListener) OnMetricsCallCount() int { + fake.onMetricsMutex.RLock() + defer fake.onMetricsMutex.RUnlock() + return len(fake.onMetricsArgsForCall) +} + +func (fake *FakeParticipantListener) OnMetricsCalls(stub func(types.Participant, *livekit.DataPacket)) { + fake.onMetricsMutex.Lock() + defer fake.onMetricsMutex.Unlock() + fake.OnMetricsStub = stub +} + +func (fake *FakeParticipantListener) OnMetricsArgsForCall(i int) (types.Participant, *livekit.DataPacket) { + fake.onMetricsMutex.RLock() + defer fake.onMetricsMutex.RUnlock() + argsForCall := fake.onMetricsArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeParticipantListener) OnParticipantUpdate(arg1 types.Participant) { + fake.onParticipantUpdateMutex.Lock() + fake.onParticipantUpdateArgsForCall = append(fake.onParticipantUpdateArgsForCall, struct { + arg1 types.Participant + }{arg1}) + stub := fake.OnParticipantUpdateStub + fake.recordInvocation("OnParticipantUpdate", []interface{}{arg1}) + fake.onParticipantUpdateMutex.Unlock() + if stub != nil { + fake.OnParticipantUpdateStub(arg1) + } +} + +func (fake *FakeParticipantListener) OnParticipantUpdateCallCount() int { + fake.onParticipantUpdateMutex.RLock() + defer fake.onParticipantUpdateMutex.RUnlock() + return len(fake.onParticipantUpdateArgsForCall) +} + +func (fake *FakeParticipantListener) OnParticipantUpdateCalls(stub func(types.Participant)) { + fake.onParticipantUpdateMutex.Lock() + defer fake.onParticipantUpdateMutex.Unlock() + fake.OnParticipantUpdateStub = stub +} + +func (fake *FakeParticipantListener) OnParticipantUpdateArgsForCall(i int) types.Participant { + fake.onParticipantUpdateMutex.RLock() + defer fake.onParticipantUpdateMutex.RUnlock() + argsForCall := fake.onParticipantUpdateArgsForCall[i] + return argsForCall.arg1 +} + +func (fake *FakeParticipantListener) OnTrackPublished(arg1 types.Participant, arg2 types.MediaTrack) { + fake.onTrackPublishedMutex.Lock() + fake.onTrackPublishedArgsForCall = append(fake.onTrackPublishedArgsForCall, struct { + arg1 types.Participant + arg2 types.MediaTrack + }{arg1, arg2}) + stub := fake.OnTrackPublishedStub + fake.recordInvocation("OnTrackPublished", []interface{}{arg1, arg2}) + fake.onTrackPublishedMutex.Unlock() + if stub != nil { + fake.OnTrackPublishedStub(arg1, arg2) + } +} + +func (fake *FakeParticipantListener) OnTrackPublishedCallCount() int { + fake.onTrackPublishedMutex.RLock() + defer fake.onTrackPublishedMutex.RUnlock() + return len(fake.onTrackPublishedArgsForCall) +} + +func (fake *FakeParticipantListener) OnTrackPublishedCalls(stub func(types.Participant, types.MediaTrack)) { + fake.onTrackPublishedMutex.Lock() + defer fake.onTrackPublishedMutex.Unlock() + fake.OnTrackPublishedStub = stub +} + +func (fake *FakeParticipantListener) OnTrackPublishedArgsForCall(i int) (types.Participant, types.MediaTrack) { + fake.onTrackPublishedMutex.RLock() + defer fake.onTrackPublishedMutex.RUnlock() + argsForCall := fake.onTrackPublishedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeParticipantListener) OnTrackUnpublished(arg1 types.Participant, arg2 types.MediaTrack) { + fake.onTrackUnpublishedMutex.Lock() + fake.onTrackUnpublishedArgsForCall = append(fake.onTrackUnpublishedArgsForCall, struct { + arg1 types.Participant + arg2 types.MediaTrack + }{arg1, arg2}) + stub := fake.OnTrackUnpublishedStub + fake.recordInvocation("OnTrackUnpublished", []interface{}{arg1, arg2}) + fake.onTrackUnpublishedMutex.Unlock() + if stub != nil { + fake.OnTrackUnpublishedStub(arg1, arg2) + } +} + +func (fake *FakeParticipantListener) OnTrackUnpublishedCallCount() int { + fake.onTrackUnpublishedMutex.RLock() + defer fake.onTrackUnpublishedMutex.RUnlock() + return len(fake.onTrackUnpublishedArgsForCall) +} + +func (fake *FakeParticipantListener) OnTrackUnpublishedCalls(stub func(types.Participant, types.MediaTrack)) { + fake.onTrackUnpublishedMutex.Lock() + defer fake.onTrackUnpublishedMutex.Unlock() + fake.OnTrackUnpublishedStub = stub +} + +func (fake *FakeParticipantListener) OnTrackUnpublishedArgsForCall(i int) (types.Participant, types.MediaTrack) { + fake.onTrackUnpublishedMutex.RLock() + defer fake.onTrackUnpublishedMutex.RUnlock() + argsForCall := fake.onTrackUnpublishedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeParticipantListener) OnTrackUpdated(arg1 types.Participant, arg2 types.MediaTrack) { + fake.onTrackUpdatedMutex.Lock() + fake.onTrackUpdatedArgsForCall = append(fake.onTrackUpdatedArgsForCall, struct { + arg1 types.Participant + arg2 types.MediaTrack + }{arg1, arg2}) + stub := fake.OnTrackUpdatedStub + fake.recordInvocation("OnTrackUpdated", []interface{}{arg1, arg2}) + fake.onTrackUpdatedMutex.Unlock() + if stub != nil { + fake.OnTrackUpdatedStub(arg1, arg2) + } +} + +func (fake *FakeParticipantListener) OnTrackUpdatedCallCount() int { + fake.onTrackUpdatedMutex.RLock() + defer fake.onTrackUpdatedMutex.RUnlock() + return len(fake.onTrackUpdatedArgsForCall) +} + +func (fake *FakeParticipantListener) OnTrackUpdatedCalls(stub func(types.Participant, types.MediaTrack)) { + fake.onTrackUpdatedMutex.Lock() + defer fake.onTrackUpdatedMutex.Unlock() + fake.OnTrackUpdatedStub = stub +} + +func (fake *FakeParticipantListener) OnTrackUpdatedArgsForCall(i int) (types.Participant, types.MediaTrack) { + fake.onTrackUpdatedMutex.RLock() + defer fake.onTrackUpdatedMutex.RUnlock() + argsForCall := fake.onTrackUpdatedArgsForCall[i] + return argsForCall.arg1, argsForCall.arg2 +} + +func (fake *FakeParticipantListener) Invocations() map[string][][]interface{} { + fake.invocationsMutex.RLock() + defer fake.invocationsMutex.RUnlock() + copiedInvocations := map[string][][]interface{}{} + for key, value := range fake.invocations { + copiedInvocations[key] = value + } + return copiedInvocations +} + +func (fake *FakeParticipantListener) recordInvocation(key string, args []interface{}) { + fake.invocationsMutex.Lock() + defer fake.invocationsMutex.Unlock() + if fake.invocations == nil { + fake.invocations = map[string][][]interface{}{} + } + if fake.invocations[key] == nil { + fake.invocations[key] = [][]interface{}{} + } + fake.invocations[key] = append(fake.invocations[key], args) +} + +var _ types.ParticipantListener = new(FakeParticipantListener) diff --git a/pkg/rtc/updatatrackmanager.go b/pkg/rtc/updatatrackmanager.go index 354126282..5ceea707f 100644 --- a/pkg/rtc/updatatrackmanager.go +++ b/pkg/rtc/updatatrackmanager.go @@ -46,38 +46,12 @@ func NewUpDataTrackManager(params UpDataTrackManagerParams) *UpDataTrackManager } } -func (u *UpDataTrackManager) OnDataTrackPublished(callback func(types.Participant, types.DataTrack)) { - u.lock.Lock() - u.onDataTrackPublished = callback - u.lock.Unlock() -} - -func (u *UpDataTrackManager) GetOnDataTrackPublished() func(types.Participant, types.DataTrack) { - u.lock.RLock() - defer u.lock.RUnlock() - return u.onDataTrackPublished -} - -func (u *UpDataTrackManager) OnDataTrackUnpublished(callback func(types.Participant, types.DataTrack)) { - u.lock.Lock() - u.onDataTrackUnpublished = callback - u.lock.Unlock() -} - -func (u *UpDataTrackManager) GetOnDataTrackUnpublished() func(types.Participant, types.DataTrack) { - u.lock.RLock() - defer u.lock.RUnlock() - return u.onDataTrackUnpublished -} - func (u *UpDataTrackManager) AddPublishedDataTrack(dt types.DataTrack) { u.lock.Lock() u.dataTracks[dt.PubHandle()] = dt u.lock.Unlock() - if onDataTrackPublished := u.GetOnDataTrackPublished(); onDataTrackPublished != nil { - onDataTrackPublished(u.params.Participant, dt) - } + u.params.Participant.GetParticipantListener().OnDataTrackPublished(u.params.Participant, dt) } func (u *UpDataTrackManager) RemovePublishedDataTrack(dt types.DataTrack) { @@ -93,9 +67,7 @@ func (u *UpDataTrackManager) RemovePublishedDataTrack(dt types.DataTrack) { if found { dt.Close() - if onDataTrackUnpublished := u.GetOnDataTrackUnpublished(); onDataTrackUnpublished != nil { - onDataTrackUnpublished(u.params.Participant, dt) - } + u.params.Participant.GetParticipantListener().OnDataTrackUnpublished(u.params.Participant, dt) } } diff --git a/pkg/service/roommanager.go b/pkg/service/roommanager.go index bdf34e250..0bdbf66e9 100644 --- a/pkg/service/roommanager.go +++ b/pkg/service/roommanager.go @@ -481,6 +481,7 @@ func (r *RoomManager) StartSession( AdaptiveStream: pi.AdaptiveStream, AllowTCPFallback: allowFallback, TURNSEnabled: r.config.IsTURNSEnabled(), + ParticipantListener: room.LocalParticipantListener(), ParticipantHelper: &roomManagerParticipantHelper{ room: room, codecRegressionThreshold: r.config.Video.CodecRegressionThreshold, diff --git a/pkg/sfu/buffer/buffer.go b/pkg/sfu/buffer/buffer.go index cf6f809bd..045d8b1f1 100644 --- a/pkg/sfu/buffer/buffer.go +++ b/pkg/sfu/buffer/buffer.go @@ -385,6 +385,8 @@ func (b *Buffer) createFrameRateCalculator() { } // Write adds an RTP Packet, ordering is not guaranteed, newer packets may arrive later +// +//go:noinline func (b *Buffer) Write(pkt []byte) (n int, err error) { var rtpPacket rtp.Packet err = rtpPacket.Unmarshal(pkt)