Show TeamSpeak 6's own viewer counts for streams

The streams list and the watch screen showed how many watch a stream only
when a gateway's directory knew it, although TeamSpeak 6 tells the count
itself: `viewer` in `notifystreaminfo`.

StreamInfo gets `viewers`: the server's count from `notifystreaminfo`, 0
for a stream that just started. Probed on the dev server, the server sends
`notifystreamclientjoined` to the whole channel but `notifystreamclientleft`
only to the streamer and the viewer who left, and no `notifystreamupdated`
for either; so the directory counts joins and leaves itself and the engine
asks `requeststreaminfo` again, one stream of another client every 5 s
round robin, which corrects the leaves it was not told about without
flooding the server however many stream. The app shows that count, and the
gateway's where the server gave none; `voelinctl stream list` prints it.

Against the TeamSpeak 6 dev server, a late `stream list` printed
"1 watching" while a viewer watched and "0 watching" after it left.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
selikhovandClaude Opus 5.5 committed 2026-10-03 17:50:35 +03:00
1 parent 8519199c6b
commit 23bf7331c4
12 files changed
+150 -7

No files matched your search

+9
View File
@@ -181,6 +181,14 @@ viewer: Engine::subscribe_frames ─ VideoPipeline (thread) ─ VideoDecoder
- `Viewer` feeds a `VideoPipeline` from the engine and sends
`RequestStreamKeyframe`; `LocalPreview` runs capture → encoder → decoder
without a server (the desktop app's `VOELIN_DEMO_STREAM`).
- Viewer counts come from the server: `StreamInfo::viewers` in
`Event::StreamsChanged` is TeamSpeak 6's own count (`viewer` of
`notifystreaminfo`), counted up from `notifystreamclientjoined` and
refreshed with `requeststreaminfo`, one stream every 5 s, because the
server tells only the streamer and the viewer when someone leaves
([protocol notes](protocol-notes/ts6-streaming.md#viewer-counts-confirmed-600-beta131-2026-10-03)).
The app shows it, and the gateway directory's count where the server
gave none.
- The audio of watched streams does not go through this module: the session
hands the Opus frames to its audio thread, which plays them through the
jitter buffer and mixer under a made-up client id, with its own volume.
@@ -993,6 +1001,7 @@ has not run on Windows yet.
| Zero-copy from a real screen capture | `voelinctl stream bench --source portal --encoder h264_vaapi` | not run yet (a portal capture asks the person at the desktop); everything up to the portal is tested with the test pattern as DMA-BUFs (rows above, and the measurements) |
| Offer [VP9, VP8], a viewer that decodes only VP8 → its own VP8 encoder, VP9 idle, pictures decoded | `voelin-core/tests/media_live.rs` `ts6_viewer_gets_the_codec_it_chose` (`VOELIN_LIVE=1`) | tested against the TeamSpeak 6 dev server (our client on both ends) |
| Several codecs against official TeamSpeak viewers | – | not tested (no official client here) |
| Viewer counts: `viewer` of `notifystreaminfo`, counted up and down from the viewers joining and leaving, refreshed one stream at a time | `voelin-stream` `proto::tests::stream_info_answers`, `session::tests::viewer_counts`; `voelinctl stream list` | tested; against the TeamSpeak 6 dev server `stream list` printed "1 watching" while a viewer watched and "0 watching" after |
| Test pattern → VP8 → decoder, rectangle position and colour | `voelin-core` `media::tests::local_preview_decodes_the_pattern` | tested |
| Test pattern → two engine stream tasks → str0m peers on loopback → decoder | `voelin-core` `stream::tests::test_pattern_through_stream_tasks` | tested |
| Stream audio (RTP time → jitter buffer ids, volume, end) | `voelin-core` `audio::tests::stream_audio_with_volume`, stream task test | tested |
+22
View File
@@ -195,6 +195,28 @@ Full transcript, all the variants tried, and what Voelin does with them:
looks up unannounced streams in its channel with `requeststreaminfo`
(`voelin_stream::discovery`).
### Viewer counts (confirmed, 6.0.0-beta13.1, 2026-10-03)
Streamer A, viewers B and B2, bystander C in one channel, every command
logged (`--log-commands`):
- `viewer` of `notifystreaminfo` is the number of viewers the streamer
accepted: `requeststreaminfo clid=<A>` answered `viewer=1` while B2
watched and `viewer=0` after it left.
- `notifystreamclientjoined clid=<viewer> id=<stream>` goes to everyone in
the channel (C got one for B and one for B2), but not to the viewer who
joined.
- `notifystreamclientleft clid=<viewer> id=<stream> reason=1` goes only to
the streamer and to the viewer who left (`joinstreamrequest ...
is_remove=1`); C got nothing, also not when B left the server.
- No `notifystreamupdated` when viewers come or go (`StreamUpdated` has no
viewer field).
So a client counts joins itself, and asks `requeststreaminfo` again now and
then for the leaves it is not told about: `StreamInfo::viewers`
(`voelin_stream`), kept by `StreamDirectory` and refreshed one stream at a
time every 5 s by the engine (`Streams::refresh_viewer_counts`).
### WebRTC interop with Chromium (confirmed, Chromium 141, 2026-09-26)
`crates/voelin-stream/tests/browser_interop.rs` (`VOELIN_INTEROP=1`, see