M7 (part 1): tsc-stream signalling and str0m peers

New crate tsc-stream for TeamSpeak 6 streams:
- proto: typed StreamNotification from the notifystream* messages and
  builders for setupstream, joinstreamrequest, respondjoinstreamrequest,
  streamsignaling, removeclientfromstream and stopstream
- signal: the JSON messages inside streamsignaling (offer, answer,
  iceCandidate, reconnect), accepting the known key spellings
- stun: minimal STUN binding client for server-reflexive candidates
- peer: a str0m peer connection driven by a tokio task, one UDP socket per
  host address; STUN lookups run in the background and found candidates are
  reported for trickling

Declarations (verified against 6.0.0-beta13.1): joinstreamrequest; stopstream
and removeclientfromstream require `reason`; is_remove/reason/return_code on
the notifications.

Tests: two peers over loopback exchange VP8 and Opus frames; with TSC_LIVE=1 a
whole stream runs through the TS6 dev server (setup, join, offer, answer,
media, kick, stop). it-smoke.sh runs it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
This commit is contained in:
Claude committed 2026-09-25 19:22:05 +00:00
1 parent 4c5f90b66b
commit 81ecb53100
16 files changed
+1974 -37

No files matched your search

+21 -23
View File
@@ -48,32 +48,30 @@ the admin grants them to the guest query group.
## Workspace layout
Present today:
```
crates/proto/ vendored tsclientlib (tsproto, tsproto-packets, tsproto-types,
tsproto-structs + declarations, ts-bookkeeping, tsclientlib)
tools/tsctl headless CLI
dev/ docker-compose TS3 + TS6 servers
scripts/ it-smoke.sh
crates/proto/ vendored tsclientlib (tsproto, tsproto-packets, tsproto-types,
tsproto-structs + declarations, ts-bookkeeping, tsclientlib)
crates/<tsc-*> our crates (table below)
tools/tsctl headless CLI
dev/ docker-compose TS3 + TS6 servers, gateway configs
scripts/ it-smoke.sh, own-crates.sh
fuzz/ cargo-fuzz targets
```
Planned crates:
| Crate | Responsibility |
|---|---|
| `tsc-model` | UI-facing domain model (servers, channels, clients, chat, capabilities), no IO |
| `tsc-query` | ServerQuery codec and transports: raw TCP, SSH (russh), HTTP WebQuery |
| `tsc-observer` | Presence tracker + chat relay pool over `tsc-query` |
| `tsc-gateway-proto`, `tsc-gateway` (`tsgw`) | Companion service for server admins: identity-challenge auth, permission-mirroring authorization, presence stream, chat relay, SQLite history, WebSocket + JSON (`tsgw.v1+json`) |
| `tsc-store` | Identities, bookmarks, settings, chat cache, secrets (keyring / Android Keystore) |
| `tsc-audio` | Capture/playback, Opus, echo cancellation, resampling, jitter buffer, mixer, VAD/push-to-talk |
| `tsc-media` | Screen and system-audio capture backends (PipeWire portal, X11, Windows Graphics Capture, Android MediaProjection), video codecs |
| `tsc-stream` | TS6 stream signalling state machine, str0m peer connections |
| `tsc-core` | Engine: runtime, per-server sessions, merge of voice/gateway/query sources, event bus, command API |
| `tsc-platform` | Global hotkeys, notifications, paths, Android JNI glue |
| `tsc-ui` | Slint UI and the desktop binary |
| `tsc-android` + `android/` | Android library + Gradle/Kotlin app (foreground services for voice and screen capture) |
| Crate | Responsibility | State |
|---|---|---|
| `tsc-model` | UI-facing domain model (servers, channels, clients, chat, capabilities), no IO | done |
| `tsc-query` | ServerQuery codec and transports: raw TCP, SSH (russh), HTTP WebQuery | done |
| `tsc-observer` | Presence tracker + chat relay pool over `tsc-query` | done |
| `tsc-gateway-proto`, `tsc-gateway` (`tsgw`) | Companion service for server admins: identity-challenge auth, permission-mirroring authorization, presence stream, chat relay, SQLite history, WebSocket + JSON (`tsgw.v1+json`) | done |
| `tsc-store` | Identities, bookmarks, settings, chat cache, secrets (keyring / Android Keystore) | done |
| `tsc-audio` | Capture/playback, Opus, echo cancellation, resampling, jitter buffer, mixer, VAD/push-to-talk | v0 (no AEC yet) |
| `tsc-stream` | TS6 stream commands, JSON signalling, str0m peer connections, host/STUN candidates | signalling + transport |
| `tsc-core` | Engine: runtime, per-server sessions, merge of voice/gateway/query sources, event bus, command API | done (no streams yet) |
| `tsc-ui` | Slint UI and the desktop binary | done (no streams yet) |
| `tsc-media` | Screen and system-audio capture backends (PipeWire portal, X11, Windows Graphics Capture, Android MediaProjection), video codecs | planned |
| `tsc-platform` | Global hotkeys, notifications, paths | planned |
| `tsc-android` + `android/` | Android library + Gradle/Kotlin app (foreground services for voice and screen capture) | planned |
## Merging sources
+37 -4
View File
@@ -49,8 +49,9 @@ which uses a TS3-signed client version over the legacy UDP transport):
| C→S | `setupstream` | `name type bitrate accessibility mode viewer_limit audio` (bot defaults: `type=3 bitrate=4608 accessibility=1 mode=1 viewer_limit=0 audio=1`) |
| C→S | `respondjoinstreamrequest` | `id clid msg offer=<SDP> decision=1\|0` |
| C→S | `streamsignaling` | `id clid json={"cmd":…,"args":{…}}` (answer, ICE candidates `candidate`/`sdpMid`/`sdpMlineIndex`, reconnect) |
| C→S | `stopstream` | `id`? |
| C→S | `removeclientfromstream` | `id clid`? |
| C→S | `joinstreamrequest` | `id clid msg is_remove` (viewer; confirmed, see below) |
| C→S | `stopstream` | `id reason` (confirmed) |
| C→S | `removeclientfromstream` | `id clid reason` (confirmed) |
| S→C | `notifystreamstarted`, `notifystreamstopped`, `notifystreaminfo` | |
| S→C | `notifyjoinstreamrequest`, `notifyrespondjoinstreamrequest` | |
| S→C | `notifystreamsignaling` | |
@@ -101,6 +102,35 @@ the viewer disconnects. Found by testing candidate parameter names from the
server binary against a live stream (`is_remove` matches the
`JoinStreamRequestEvent.is_remove` protobuf field).
### End-to-end stream (confirmed, 6.0.0-beta13.1, 2026-09-25)
`crates/tsc-stream/tests/live_ts6.rs` runs a whole stream between two of our
clients through the server, with str0m on both ends:
```
streamer -> setupstream name=live\stest type=3 bitrate=4608 accessibility=1 mode=1 viewer_limit=0 audio=1
streamer <- notifystreamstarted clid=<s> id=<uuid> ... return_code=... (viewer gets it without return_code)
viewer -> joinstreamrequest id=<uuid> clid=<s> msg=... is_remove=0
streamer <- notifyjoinstreamrequest clid=<v> id=<uuid> msg=... is_remove=0
streamer -> respondjoinstreamrequest id=<uuid> clid=<v> msg offer=<SDP offer> decision=1
viewer <- notifyrespondjoinstreamrequest id=<uuid> ... offer=<SDP, unchanged> decision=1
viewer -> streamsignaling id=<uuid> clid=<s> json={"cmd":"answer","args":{"answer":<SDP>}}
streamer <- notifystreamsignaling id=<uuid> clid=<v> json=<unchanged>
ICE + DTLS directly between the peers; VP8 video and Opus audio flow
streamer -> removeclientfromstream id=<uuid> clid=<v> reason=5
viewer <- notifystreamclientleft id=<uuid> clid=<v> reason=5 (streamer: + return_code)
streamer -> stopstream id=<uuid> reason=1
viewer <- notifystreamstopped id=<uuid>
```
- `stopstream id=<uuid>` alone and `stopstream id clid` fail with
`ParameterMissing`; `stopstream id reason` works. `removeclientfromstream id clid`
fails the same way; it needs `reason` too. Reasons are `StreamLeaveReason` values.
- The server passes SDP and JSON through unchanged (escaped as usual).
- Host candidates embedded in the SDP are enough on one machine; trickled
candidates use `{"cmd":"iceCandidate","args":{"candidate","sdpMid","sdpMLineIndex"}}`
(the parser also accepts `sdp`/`mid`/`mLine`).
### Schema embedded in the server (confirmed)
The server binary embeds the protobuf descriptors of the new binary protocol
@@ -141,9 +171,12 @@ permissions") has been seen; no stream permission names are documented.
- [x] Viewer side: `joinstreamrequest id clid msg is_remove` (see above).
- [x] Meaning of `setupstream` `type`, `accessibility` and `mode` values (enums above).
- [ ] Parameters of `stopstream` (more than `id`) and `removeclientfromstream`.
- [x] Parameters of `stopstream` and `removeclientfromstream` (`reason` is required).
- [ ] Which permission gates `setupstream` (error 2568).
- [ ] Contents of `notifystreaminfo` and `notifystreamstarted`.
- [x] Contents of `notifystreamstarted` (see probe results).
- [ ] Contents of `notifystreaminfo` (`requeststreaminfo`).
- [ ] Interop with the official TS6 client (its offer/answer details, codecs it
actually picks, whether it trickles candidates).
- [ ] Whether stream audio can be sent without video.
- [ ] The WebRTC/protobuf transport some TS6 clients use on UDP 9987
(`client_protocol_format=proto`, reported in community reverse engineering).