From 8ada0217d0f95c66681670303cb10924f6c9df84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Mon, 4 Jul 2022 17:47:04 +0200 Subject: [PATCH] reset counters when closed. --- internal/webrtc/metrics.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/webrtc/metrics.go b/internal/webrtc/metrics.go index 8c1f4143..713b45e7 100644 --- a/internal/webrtc/metrics.go +++ b/internal/webrtc/metrics.go @@ -184,6 +184,19 @@ func (m *metricsCtx) getBySession(session types.Session) metrics { return met } +func (m *metricsCtx) reset(met metrics) { + met.videoIdsMu.Lock() + for _, entry := range met.videoIds { + entry.Set(0) + } + met.videoIdsMu.Unlock() + + met.receiverEstimatedMaximumBitrate.Set(0) + + met.receiverReportDelay.Set(0) + met.receiverReportJitter.Set(0) +} + func (m *metricsCtx) NewConnection(session types.Session) { met := m.getBySession(session) met.connectionCount.Add(1) @@ -219,6 +232,7 @@ func (m *metricsCtx) SetState(session types.Session, state webrtc.PeerConnection met.connectionState.Set(2) case webrtc.PeerConnectionStateClosed: met.connectionState.Set(1) + m.reset(met) default: met.connectionState.Set(-1) }