reset subscription time when downtrack closed and expect resume (#3083)
This commit is contained in:
@@ -721,6 +721,9 @@ func (m *SubscriptionManager) handleSubscribedTrackClose(s *trackSubscription, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
m.params.Participant.Negotiate(false)
|
m.params.Participant.Negotiate(false)
|
||||||
|
} else {
|
||||||
|
t := time.Now()
|
||||||
|
s.subscribeAt.Store(&t)
|
||||||
}
|
}
|
||||||
if relieveFromLimits {
|
if relieveFromLimits {
|
||||||
m.queueReconcile(trackIDForReconcileSubscriptions)
|
m.queueReconcile(trackIDForReconcileSubscriptions)
|
||||||
@@ -755,16 +758,19 @@ type trackSubscription struct {
|
|||||||
// this timestamp determines when failures are reported
|
// this timestamp determines when failures are reported
|
||||||
subStartedAt atomic.Pointer[time.Time]
|
subStartedAt atomic.Pointer[time.Time]
|
||||||
|
|
||||||
createAt time.Time
|
// the timestamp when the subscription was started, will be reset when downtrack is closed with expected resume
|
||||||
|
subscribeAt atomic.Pointer[time.Time]
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTrackSubscription(subscriberID livekit.ParticipantID, trackID livekit.TrackID, l logger.Logger) *trackSubscription {
|
func newTrackSubscription(subscriberID livekit.ParticipantID, trackID livekit.TrackID, l logger.Logger) *trackSubscription {
|
||||||
return &trackSubscription{
|
s := &trackSubscription{
|
||||||
subscriberID: subscriberID,
|
subscriberID: subscriberID,
|
||||||
trackID: trackID,
|
trackID: trackID,
|
||||||
logger: l,
|
logger: l,
|
||||||
createAt: time.Now(),
|
|
||||||
}
|
}
|
||||||
|
t := time.Now()
|
||||||
|
s.subscribeAt.Store(&t)
|
||||||
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *trackSubscription) setPublisher(publisherIdentity livekit.ParticipantIdentity, publisherID livekit.ParticipantID) {
|
func (s *trackSubscription) setPublisher(publisherIdentity livekit.ParticipantIdentity, publisherID livekit.ParticipantID) {
|
||||||
@@ -790,6 +796,7 @@ func (s *trackSubscription) setDesired(desired bool) bool {
|
|||||||
// we'll reset the timer so it has sufficient time to reconcile
|
// we'll reset the timer so it has sufficient time to reconcile
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
s.subStartedAt.Store(&t)
|
s.subStartedAt.Store(&t)
|
||||||
|
s.subscribeAt.Store(&t)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.desired == desired {
|
if s.desired == desired {
|
||||||
@@ -822,6 +829,7 @@ func (s *trackSubscription) setHasPermission(perm bool) bool {
|
|||||||
// when permission is granted, reset the timer so it has sufficient time to reconcile
|
// when permission is granted, reset the timer so it has sufficient time to reconcile
|
||||||
t := time.Now()
|
t := time.Now()
|
||||||
s.subStartedAt.Store(&t)
|
s.subStartedAt.Store(&t)
|
||||||
|
s.subscribeAt.Store(&t)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -992,7 +1000,7 @@ func (s *trackSubscription) maybeRecordSuccess(ts telemetry.TelemetryService, pI
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
d := time.Since(s.createAt)
|
d := time.Since(*s.subscribeAt.Load())
|
||||||
s.logger.Debugw("track subscribed", "cost", d.Milliseconds())
|
s.logger.Debugw("track subscribed", "cost", d.Milliseconds())
|
||||||
subscriber := subTrack.Subscriber()
|
subscriber := subTrack.Subscriber()
|
||||||
prometheus.RecordSubscribeTime(mediaTrack.Source(), mediaTrack.Kind(), d, subscriber.GetClientInfo().GetSdk(), subscriber.Kind())
|
prometheus.RecordSubscribeTime(mediaTrack.Source(), mediaTrack.Kind(), d, subscriber.GetClientInfo().GetSdk(), subscriber.Kind())
|
||||||
|
|||||||
Reference in New Issue
Block a user