Skip to content

huddle: media state and leave on the /rtc door - #253

Merged
naliyi merged 7 commits into
mainfrom
feat/huddle-media-state
Nov 10, 2026
Merged

naliyi merged 7 commits into
mainfrom
feat/huddle-media-state

Conversation

@naliyi

@naliyi naliyi commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Closes #252

Summary

  • WebRTC peers announce mic/camera/screen live/off and say leave; the relay fans both out, lists each peer's media on joined, and left carries reason (leave, evicted, dropped).
  • WebRTC peers now receive other peers' joined/left; revoking membership closes the WebRTC session.
  • joined.features lets clients detect support; no protocol bump.

Test plan

  • go test ./huddle/...
  • TestHuddleIntegration against the compose relay, incl. StoppedCameraIsAnnounced, MicStateRoundTrip, LeaveVersusDrop, LateJoinerSeesMediaState
  • TestHuddleStress not run (needs localhost:21540, unreachable from the dev container)

wingha added 7 commits November 10, 2026 22:02
The zap ranking cache refreshes in the background, so its totals can change
with no new commit; the stats publisher now also rebuilds when they differ
from the last ones it published.
nmilat closes events and done together on EOSE; selecting on done could
return before the kind 0 still buffered in events was read.
A browser stopping its camera only detaches the track, so to everyone
else the picture just stops -- indistinguishable from packet loss. A
hang-up and a dropped connection looked the same too. Clients had to
guess from silence, and showed "Reconnecting" for both.

Clients now say what they mean over signalling, and the relay fans it
out at once:

- client -> {"type":"media","kind":"mic|camera|screen","state":"live|off"}
  is relayed to the room with the publisher's pubkey and a per-session
  seq, and each peer's media is listed on "joined" for late joiners.
- client -> {"type":"leave"} before hanging up; "left" now carries
  reason leave, evicted or dropped.
- "joined" lists features so a client can tell this relay from an
  older one. Everything is additive; no protocol version bump.

This also fixes WebRTC peers never receiving room control at all: the
SFU built its RTP sink without OnControl, so other peers' joined/left
were discarded for browsers, and membership eviction never closed an
RTC session. Control is queued without blocking the room lock and
written behind the peer's own "joined".

Covered by unit tests in huddle/sfu and four new docker scenarios
(StoppedCameraIsAnnounced, MicStateRoundTrip, LeaveVersusDrop,
LateJoinerSeesMediaState).
@naliyi naliyi mentioned this pull request Nov 10, 2026
2 tasks done
@naliyi
naliyi force-pushed the feat/huddle-media-state branch from 0ba6931 to b8dfcef Compare November 10, 2026 22:55
@naliyi
naliyi merged commit f5dd8d2 into main Nov 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

huddle: tell WebRTC peers about media state and leaving

1 participant