mirror of
https://github.com/livekit/livekit.git
synced 2026-03-30 17:45:40 +00:00
Fix incorrect accounting for track published/subscribed stats. (#1336)
It was not getting decremented in certain cases.
This commit is contained in:
@@ -1611,16 +1611,13 @@ func (p *ParticipantImpl) addMediaTrack(signalCid string, sdpCid string, ti *liv
|
||||
p.supervisor.ClearPublishedTrack(livekit.TrackID(ti.Sid), mt)
|
||||
|
||||
// not logged when closing
|
||||
if !p.isClosed.Load() {
|
||||
p.params.Telemetry.TrackUnpublished(
|
||||
context.Background(),
|
||||
p.ID(),
|
||||
p.Identity(),
|
||||
mt.ToProto(),
|
||||
true,
|
||||
)
|
||||
}
|
||||
p.MigrateState()
|
||||
p.params.Telemetry.TrackUnpublished(
|
||||
context.Background(),
|
||||
p.ID(),
|
||||
p.Identity(),
|
||||
mt.ToProto(),
|
||||
!p.IsClosed(),
|
||||
)
|
||||
|
||||
// re-use track sid
|
||||
p.pendingTracksLock.Lock()
|
||||
|
||||
@@ -512,14 +512,16 @@ func (m *SubscriptionManager) handleSubscribedTrackClose(s *trackSubscription, w
|
||||
s.setSubscribedTrack(nil)
|
||||
go m.params.OnTrackUnsubscribed(subTrack)
|
||||
|
||||
// always trigger to decrement unsubscribed counter. However, only log an analytics event when
|
||||
// * the participant isn't closing
|
||||
// * it's not a migration
|
||||
m.params.Telemetry.TrackUnsubscribed(
|
||||
context.Background(),
|
||||
m.params.Participant.ID(),
|
||||
&livekit.TrackInfo{Sid: string(s.trackID), Type: subTrack.MediaTrack().Kind()},
|
||||
!willBeResumed && !m.params.Participant.IsClosed(),
|
||||
)
|
||||
if !willBeResumed {
|
||||
m.params.Telemetry.TrackUnsubscribed(
|
||||
context.Background(),
|
||||
m.params.Participant.ID(),
|
||||
&livekit.TrackInfo{Sid: string(s.trackID), Type: subTrack.MediaTrack().Kind()},
|
||||
!m.params.Participant.IsClosed(),
|
||||
)
|
||||
|
||||
sender := subTrack.RTPSender()
|
||||
if sender != nil {
|
||||
m.params.Logger.Debugw("removing PeerConnection track",
|
||||
|
||||
Reference in New Issue
Block a user