Fix incorrect accounting for track published/subscribed stats. (#1336)

It was not getting decremented in certain cases.
This commit is contained in:
David Zhao
2023-01-26 16:07:04 -08:00
committed by GitHub
parent 2fa46e2df4
commit 2d6c896bba
2 changed files with 16 additions and 17 deletions
+9 -7
View File
@@ -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",