This repository has no description

viewers: count WHEP sessions only once connected master

WebRTCPlayback2 incremented the viewer count as soon as the SDP answer was minted, so handshakes that never established — the web player churns through several peer connections while loading or before falling back to HLS — each counted as a viewer until ICE failure detection fired seconds later. That's the "count jumps +4-5 then settles" spike. Count on PeerConnectionStateConnected instead, with the increment/decrement paired under a mutex so a connect racing teardown can't leak a count. Also point ViewerDec's per-protocol branch at ViewersTotal — it was updating/deleting the per-streamer gauge with a protocol label. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>


+35 -5
2 changed files