diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index 87b6befe1..d1efcc04c 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -284,7 +284,7 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) { }), pendingTracks: make(map[string]*pendingTrackInfo), pendingPublishingTracks: make(map[livekit.TrackID]*pendingTrackInfo), - connectedAt: time.Now(), + connectedAt: time.Now().Truncate(time.Millisecond), rttUpdatedAt: time.Now(), cachedDownTracks: make(map[livekit.TrackID]*downTrackState), dataChannelStats: telemetry.NewBytesTrackStats( diff --git a/pkg/rtc/types/interfaces.go b/pkg/rtc/types/interfaces.go index 73cd073d4..6741a0a45 100644 --- a/pkg/rtc/types/interfaces.go +++ b/pkg/rtc/types/interfaces.go @@ -264,6 +264,7 @@ type Participant interface { ID() livekit.ParticipantID Identity() livekit.ParticipantIdentity State() livekit.ParticipantInfo_State + ConnectedAt() time.Time CloseReason() ParticipantCloseReason Kind() livekit.ParticipantInfo_Kind IsRecorder() bool @@ -324,7 +325,6 @@ type LocalParticipant interface { ProtocolVersion() ProtocolVersion SupportsSyncStreamID() bool SupportsTransceiverReuse() bool - ConnectedAt() time.Time IsClosed() bool IsReady() bool IsDisconnected() bool diff --git a/pkg/rtc/types/typesfakes/fake_participant.go b/pkg/rtc/types/typesfakes/fake_participant.go index 7418a5df9..9ec45f43b 100644 --- a/pkg/rtc/types/typesfakes/fake_participant.go +++ b/pkg/rtc/types/typesfakes/fake_participant.go @@ -3,6 +3,7 @@ package typesfakes import ( "sync" + "time" "github.com/livekit/livekit-server/pkg/rtc/types" "github.com/livekit/protocol/livekit" @@ -43,6 +44,16 @@ type FakeParticipant struct { closeReasonReturnsOnCall map[int]struct { result1 types.ParticipantCloseReason } + ConnectedAtStub func() time.Time + connectedAtMutex sync.RWMutex + connectedAtArgsForCall []struct { + } + connectedAtReturns struct { + result1 time.Time + } + connectedAtReturnsOnCall map[int]struct { + result1 time.Time + } DebugInfoStub func() map[string]interface{} debugInfoMutex sync.RWMutex debugInfoArgsForCall []struct { @@ -418,6 +429,59 @@ func (fake *FakeParticipant) CloseReasonReturnsOnCall(i int, result1 types.Parti }{result1} } +func (fake *FakeParticipant) ConnectedAt() time.Time { + fake.connectedAtMutex.Lock() + ret, specificReturn := fake.connectedAtReturnsOnCall[len(fake.connectedAtArgsForCall)] + fake.connectedAtArgsForCall = append(fake.connectedAtArgsForCall, struct { + }{}) + stub := fake.ConnectedAtStub + fakeReturns := fake.connectedAtReturns + fake.recordInvocation("ConnectedAt", []interface{}{}) + fake.connectedAtMutex.Unlock() + if stub != nil { + return stub() + } + if specificReturn { + return ret.result1 + } + return fakeReturns.result1 +} + +func (fake *FakeParticipant) ConnectedAtCallCount() int { + fake.connectedAtMutex.RLock() + defer fake.connectedAtMutex.RUnlock() + return len(fake.connectedAtArgsForCall) +} + +func (fake *FakeParticipant) ConnectedAtCalls(stub func() time.Time) { + fake.connectedAtMutex.Lock() + defer fake.connectedAtMutex.Unlock() + fake.ConnectedAtStub = stub +} + +func (fake *FakeParticipant) ConnectedAtReturns(result1 time.Time) { + fake.connectedAtMutex.Lock() + defer fake.connectedAtMutex.Unlock() + fake.ConnectedAtStub = nil + fake.connectedAtReturns = struct { + result1 time.Time + }{result1} +} + +func (fake *FakeParticipant) ConnectedAtReturnsOnCall(i int, result1 time.Time) { + fake.connectedAtMutex.Lock() + defer fake.connectedAtMutex.Unlock() + fake.ConnectedAtStub = nil + if fake.connectedAtReturnsOnCall == nil { + fake.connectedAtReturnsOnCall = make(map[int]struct { + result1 time.Time + }) + } + fake.connectedAtReturnsOnCall[i] = struct { + result1 time.Time + }{result1} +} + func (fake *FakeParticipant) DebugInfo() map[string]interface{} { fake.debugInfoMutex.Lock() ret, specificReturn := fake.debugInfoReturnsOnCall[len(fake.debugInfoArgsForCall)] @@ -1480,6 +1544,8 @@ func (fake *FakeParticipant) Invocations() map[string][][]interface{} { defer fake.closeMutex.RUnlock() fake.closeReasonMutex.RLock() defer fake.closeReasonMutex.RUnlock() + fake.connectedAtMutex.RLock() + defer fake.connectedAtMutex.RUnlock() fake.debugInfoMutex.RLock() defer fake.debugInfoMutex.RUnlock() fake.getAudioLevelMutex.RLock()