Publish/Unpublish counter match. (#4173)

Published counter was bumped up only when not migrating in, but it was
decremented when a migrating participant leaves without expectation to
resume. That could have resulted in negative counts.

Always change counters irrespective of migration or expected to resume
on leave. Control events send based on migration/resume.
This commit is contained in:
Raja Subramanian
2025-12-18 10:16:27 +05:30
committed by GitHub
parent fb849edc6a
commit cbb2c61787
4 changed files with 29 additions and 26 deletions
+14 -17
View File
@@ -3299,15 +3299,13 @@ func (p *ParticipantImpl) addMediaTrack(signalCid string, ti *livekit.TrackInfo)
p.supervisor.ClearPublishedTrack(trackID, mt)
}
if !isExpectedToResume {
p.params.Telemetry.TrackUnpublished(
context.Background(),
p.ID(),
p.Identity(),
mt.ToProto(),
true,
)
}
p.params.Telemetry.TrackUnpublished(
context.Background(),
p.ID(),
p.Identity(),
mt.ToProto(),
!isExpectedToResume,
)
p.pendingTracksLock.Lock()
if pti := p.pendingTracks[signalCid]; pti != nil {
@@ -3336,14 +3334,13 @@ func (p *ParticipantImpl) handleTrackPublished(track types.MediaTrack, isMigrate
// send webhook after callbacks are complete, persistence and state handling happens
// in `onTrackPublished` cb
if !isMigrated {
p.params.Telemetry.TrackPublished(
context.Background(),
p.ID(),
p.Identity(),
track.ToProto(),
)
}
p.params.Telemetry.TrackPublished(
context.Background(),
p.ID(),
p.Identity(),
track.ToProto(),
!isMigrated,
)
p.pendingTracksLock.Lock()
delete(p.pendingPublishingTracks, track.ID())