Audit where Voelin negotiates, and document the new ladders

architecture.md gets "Negotiation: best first, then fall back": every
place Voelin agrees on parameters with a peer or a system component
(codecs both ways, H.264 profile and level, SRTP, DTLS, ICE, the stream
connection, simulcast, feedback, socket buffers, loss repair, Opus, WHIP,
the gateway, the client version, capture and encoder backends), its
ladder, what counts as not accepted (refused in the negotiation or found
failing at runtime), and whether it was already so, changed now, or not
done and why. The transport section describes the stall checks and the
mDNS candidates.

AES-GCM first and DTLS 1.3 stay off, with the evidence: both work with
headless Chromium 152 and the SRTP fallback is proven to trigger, but
the streamer's half needs the official viewer to answer a reconnectOffer
it did not ask for, which nothing shows yet. The protocol notes say how
to find out with the official client; they and the interop README record
the Chromium findings (mDNS responder, DTLS 1.3, receiver reports when
SRTP fails).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
selikhovandClaude Opus 5.5 committed 2026-10-03 23:30:04 +03:00
1 parent d7940f846a
commit 6dbaa8bcf4
3 files changed
+122 -5

No files matched your search

+76
View File
@@ -246,6 +246,27 @@ Transport details of our stream (`voelin-stream`):
patch for it (`VOELIN-PATCH.md`). The order is a setting
(`Streams::set_srtp_profiles`, `Command::SetSrtpProfiles`) and applies to
new connections.
- **Media that does not get through**: a connection can come up and carry
nothing (an SRTP library that negotiates a profile it cannot use, a
streamer without an encoder for the codec the answer took). Each peer
checks once per connection: a viewer's reports `PeerEvent::NoVideo`
(with whether audio came) when no video arrived within
`PeerConfig::stall_timeout` (5 s); a streamer's reports
`PeerEvent::NoFeedback` when, after twice that, no receiver report (or
REMB) of the viewer mentioned our video. Keyframe requests do not count:
a viewer that gets nothing keeps asking. The sessions then ask for a new
connection with the next lower set and log the step: without the SRTP
profile that was negotiated (both AEAD profiles when it was one of
them), or without the video codec when audio came and video did not. A
viewer sends `reconnect`; a streamer sends a `reconnectOffer` of its own,
for viewers that do not step down (it waits twice as long, so a Voelin
viewer goes first). What was left out stays out for that viewer or
watched stream; when nothing is left, that is logged and nothing loops.
- **mDNS candidates**: host candidates behind `<uuid>.local` names (how
browsers and other libwebrtc builds hide host addresses) are resolved by
a multicast DNS query (`voelin_stream::mdns`, from port 5353 shared with
the system's responder: Chromium's answers nothing else) and added as
plain candidates, from offers, answers and trickled candidates alike.
- **Losses**: each peer socket asks for 4 MB of receive and send buffer
(`PeerConfig::udp_buffer`; Linux caps it at `net.core.rmem_max`, and
what was granted is logged, with a hint when it is less): the default
@@ -310,6 +331,61 @@ does not answer. Our own stream registers itself in the directory when it
goes live (title, kind, channel, client), updates its viewer count, and is
removed when it ends.
## Negotiation: best first, then fall back
Wherever Voelin agrees on parameters with a peer or a system component, it
tries the best choice first and steps down towards the most compatible one
when the better one is not accepted. "Not accepted" is either refused in
the negotiation itself (SDP, handshake, a backend's start) or found failing
at runtime. The second matters: the official client answers H.264 it
cannot decode and then shows nothing, so for codecs "accepted" is not
"works", and a streamer cannot see a viewer's decoder. Audit of
2026-10-03:
| Point | Ladder (best → most compatible) | Not accepted means | State |
|---|---|---|---|
| Video codec, streamer offer | stream codec (configured, else the first of the encoder preference every TeamSpeak client decodes) → AV1, VP9, VP8 of hardware encoders and VP8 of libvpx → H.264 of hardware → HEVC | SDP: the answer lists what the viewer takes; our first one it took is sent (`PeerEvent::VideoCodec`), one encoder per format. At runtime undetectable for the official client: without OpenH264 it answers H.264, decodes nothing and reports success (libwebrtc's `NullVideoDecoder`, no PLI) | already so; deliberately not best-first for H.264: codecs every client decodes come before it, because the streamer cannot see that failure |
| Video codec, viewer answer | the offer's order, limited to what we decode (the decoder ladder is separate work) | SDP: no codec in common → refused with the reason (`PeerError::NoCommonCodec`); an official streamer that does not encode our pick re-offers on the same connection (`Peer::renegotiate`). Runtime: audio comes, video does not for `stall_timeout` (`PeerEvent::NoVideo { audio: true }`) → `reconnect` without that codec | renegotiation already so; runtime step **changed now** (`viewer_falls_back_to_another_codec`) |
| H.264 profile | Constrained High (PT 112) → Constrained Baseline (PT 108) | SDP: the answer takes only the Baseline entry (headless Chromium 152) → that viewer's frames come from an encoder in Constrained Baseline | **changed now** (`a_baseline_only_viewer_gets_the_fallback_profile`, `an_encoder_per_h264_profile_viewers_chose`, browser: 90 of 90 frames, SPS profile 66). Android's MediaCodec encoder makes High only |
| H.264 level, packetization | the level the stream needs (at least 3.1); packetization mode 1 | `level-asymmetry-allowed=1`; a peer without mode 1 does not take H.264 and gets the next codec | level: unchanged, not a ladder. The app offers 3.1 whatever the share's size (its peer configuration is made before the share starts; `voelinctl` sets the level): open issue |
| SRTP profile | AES_CM_128_HMAC_SHA1_80 → AEAD_AES_128_GCM → AEAD_AES_256_GCM | handshake: the DTLS server (we are, with official clients and browsers) takes the first of its order the client offers. Runtime: connected, nothing gets through (`NoVideo { audio: false }` at the viewer, `NoFeedback` at the streamer) → a new connection without the negotiated profile (without both AEAD ones if it was AEAD) | runtime ladder **changed now** (`viewer_falls_back_when_srtp_fails`, `streamer_falls_back_when_its_viewer_gets_nothing`, `browser_srtp_failure_is_noticed`). The order stays most-compatible-first, see below |
| DTLS version, cipher suite | 1.2 (str0m's default); ECDHE-ECDSA AES-128-GCM, AES-256-GCM (dimpl) | in the handshake: Chromium 152 offers 1.3 and 1.2 and gets 1.2; the server picks the suite from the client's list | already so; 1.3 not turned on, see below |
| ICE | host (configured, else the primary IPv4) → server-reflexive (TeamSpeak's STUN, trickled) → peer-reflexive; remote `<uuid>.local` names resolved by mDNS | pairs that fail their checks drop out, the best working pair is used; an mDNS name nobody answers within 3 s is dropped (debug log) | mDNS **changed now** (`browser_mdns_candidates_connect`); the rest already so. No TURN (TeamSpeak runs none), no IPv6 gathering |
| Stream connection | renegotiation on the running connection (a new `offer` signal) → a new connection (`reconnect` / `reconnectOffer`), each fallback step one more → the watch ends | a viewer whose connection closes asks again, three times, then the watch ends with `Failed`; fallback steps do not count against those three | renegotiation and reconnect already so, fallback steps **changed now**; no automatic `joinstreamrequest` again: a streamer may have to accept it by hand, so the user decides |
| Simulcast | one layer per viewer by its bandwidth estimate (TeamSpeak); RID simulcast only with `PeerConfig::simulcast` (SFU, WHIP) | an answer without `a=simulcast` leaves a RID peer without video | not changed: RID is opt-in and only `voelinctl --simulcast` turns it on; offer it only to peers that take it |
| Bandwidth feedback | transport-cc → REMB | a viewer without transport-cc feedback: its REMB estimates are used | already so |
| Socket buffers | 4 MB → what the system grants (`rmem_max`) | the kernel caps `SO_RCVBUF`; logged, once with a hint | **changed now** (`high_bitrate_bursts`: 118-209 drops per 5 s before, none after) |
| Loss repair | NACK + retransmission → after 30 complete frames, the frame is handed over non-contiguous → keyframe request | the depacketizer gives up waiting | already so, verified now (`losses_are_repaired_by_retransmission`) |
| Opus | 48 kHz stereo, 128 kbit/s music mode, 20 ms, in-band FEC on (5 %), DTX off; SDP `minptime=10;useinbandfec=1` | fmtp differences do not refuse a codec (str0m scores the match), and every Opus decoder takes every mode | already so, no ladder needed. Our answers lack `stereo=1`, so libwebrtc streamers send us mono; our playback is mono anyway |
| WHIP output | the studio's one codec + Opus; one host candidate | the service refuses → the output fails with its answer | not changed: a second codec would need a second encode; no STUN/TURN yet ([studio.md](studio.md)) |
| Gateway protocol | subprotocol `tsgw.v1+json`; features by `capabilities` | a gateway without a feature: the client hides it; unknown fields are ignored, unknown message types answered `unknown_type` | already so; a `v2` would be offered first as a second subprotocol once it exists |
| TeamSpeak client version | the configured signed version, else the vendored default (`Windows_3_X_X__1`); the legacy UDP protocol on TS3 and TS6 | a server that refuses the version ends the connection with its error | not done: no server here refuses the default; retrying with the newest signed version (`Versions.csv`, only `voelinctl` reads it) needs that refusal recognised first. TS6's protobuf transport is not implemented |
| Capture buffers | DMA-BUF in the sink's tiled modifiers → LINEAR DMA-BUF → shared memory | the compositor fixates the format; a LINEAR mapping slower than 1 ns per pixel over 30 frames renegotiates to shared memory; a failed GPU conversion or an encoder that needs frames in memory declines DMA-BUFs | already so |
| Capture backend | Android's provider → the ScreenCast portal (Wayland) → X11 (`DISPLAY`) → Windows Graphics Capture; or the backend set | the backend that cannot start fails the share with its reason; a cancelled portal dialog is not a failure | not changed: falling back from the portal to X11 on Wayland would capture XWayland only (black for Wayland windows); wlroots screencopy is the candidate for compositors without a portal |
| Encoder backend | the preference: hardware (VA-API, NVENC, Quick Sync, AMF, VideoToolbox, Media Foundation, MediaCodec) → libvpx VP8 → x264, OpenH264 → libvpx VP9 → SVT-AV1, libaom; a named backend first | at start-up each backend's self-test (one keyframe) leaves out what fails, with the reason; at runtime an encoder that fails logs and tries again with the next frame | start-up already so; switching backends after runtime failures not done |
Not turned on, with the evidence:
- **AEAD-first SRTP order.** AES-GCM is the better profile, and the
fallback works: when SRTP fails after an AES-GCM handshake, our streamer
notices (`NoFeedback`, also with headless Chromium as the viewer) and
offers AES_CM_128_HMAC_SHA1_80, and our viewer asks for it. But the
streamer's half needs the viewer to answer a `reconnectOffer` it did not
ask for, and nothing shows that the official client does; how official
clients failed with AES-256-GCM is only reported; and streams between
official clients reportedly use AES_CM_128_HMAC_SHA1_80, which suggests
they offer nothing else, where the order changes nothing. The gain (a
cheaper cipher) does not justify the risk until the official client is
tried (steps under the open questions of
[protocol-notes/ts6-streaming.md](protocol-notes/ts6-streaming.md#open-questions)).
- **DTLS 1.3.** With dimpl allowed to (str0m's `DtlsVersion::Auto`),
headless Chromium 152 negotiates DTLS 1.3 (`FEFC`, `TLS_AES_128_GCM_SHA256`)
and decodes 90 of 90 frames, and its ClientHello also offers 1.2, which
is what our 1.2-only peers get. But a DTLS handshake that fails closes
the connection without a version step (a reconnect uses the same
settings), the official client's DTLS 1.3 is untried, and 1.3 gains a
round trip at connect, nothing for the stream. It stays off.
## Settings
`voelin-core::settings::Settings` is the settings service. Keys are typed
+32 -3
View File
@@ -248,9 +248,14 @@ libwebrtc, the stack the official client is built on:
strings (e.g. `fhs`), not `0`. Our `iceCandidate` signals use the peer's
first mid and `sdpMLineIndex` 0; Chromium's `addIceCandidate` accepts them.
- Without camera/microphone permission Chromium hides host candidates behind
mDNS names (`<uuid>.local`), which str0m cannot resolve. The test disables
that; the official client may send mDNS candidates, which would then need a
resolver (or its server-reflexive candidates) on our side.
mDNS names (`<uuid>.local`), which str0m cannot use. Our peers resolve them
with a multicast DNS query (`voelin_stream::mdns`, 2026-10-03). Chromium
152's responder answers queries sent from port 5353 (with multicast
answers on every interface) and ignores "legacy" queries from other
ports, so the query goes out from 5353, shared with the system's
responder. `browser_mdns_candidates_connect` keeps our candidates from the
browser, so only a resolved name can connect: it does, both ways. The
official client may send such names too.
- str0m answers in its own codec order and the offerer sends the answer's
first codec, so `Peer::answer` orders the viewer's codecs like the offer.
- SRTP profile: libwebrtc answers our `setup:actpass` offer as DTLS client
@@ -263,6 +268,18 @@ libwebrtc, the stack the official client is built on:
`srtpCipher: AES_CM_128_HMAC_SHA1_80` (DTLS 1.2,
`TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256`). Whether this was what broke the
official client is still to be confirmed with it.
- When SRTP fails after the handshake (a relay that lets STUN and DTLS
through and drops SRTP once AES-GCM was selected), Chromium 152 decodes
nothing and its receiver reports never mention our video; our streamer
peer reports that (`PeerEvent::NoFeedback`) and the session offers a new
connection without AES-GCM (`browser_srtp_failure_is_noticed`; the
AES_CM_128_HMAC_SHA1_80 connection then decodes 90 of 90 frames). A
working connection raises no such report.
- DTLS: Chromium 152's ClientHello offers 1.3 and 1.2. Our peers use 1.2
(str0m's default) and get it; allowed 1.3, dimpl negotiates it with
Chromium 152 (`FEFC`, `TLS_AES_128_GCM_SHA256`) and the stream decodes
(tried 2026-10-03, not turned on: see "Negotiation" in
[architecture.md](../architecture.md)).
- With bandwidth estimation on our streamer peer, Chromium's transport-cc
feedback gives estimates; the offer is the same as without (str0m always
offers transport-cc and abs-send-time).
@@ -331,6 +348,18 @@ VP9 on the same connection; VP9 frames arrive).
- [ ] Interop with the official TS6 client (its offer/answer details, whether
it trickles candidates, mDNS host candidates). The codecs it picks and
decodes are known (see above); Chromium's WebRTC stack interoperates.
- [ ] Whether the official client, as a viewer, answers a `reconnectOffer`
it did not ask for (our streamer sends one when the viewer's receiver
reports show none of our video), and whether it offers AES-GCM at all.
To find out: Voelin streams to it with
`voelinctl ... stream start --synthetic --auto-accept --srtp
AEAD_AES_128_GCM,AES_CM_128_HMAC_SHA1_80` and `RUST_LOG=voelin_stream=debug`;
the viewer list prints the SRTP profile per viewer. AES-GCM selected
and a picture: the official client handles it, and AEAD-first could
become the default. AES_CM_128_HMAC_SHA1_80 selected: it does not
offer AES-GCM, and the order does not matter. No picture: after 10 s
the log says "offering a new connection without SRTP"; a picture after
that proves it answers our `reconnectOffer`.
- [ ] 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).
+14 -2
View File
@@ -16,6 +16,8 @@ TeamSpeak server is involved.
| `share_offer_picks_a_codec_every_client_decodes` (voelin-core) | The offer a share makes on this machine (`preferred_codec`, `peer_config`): the browser, answering with the first codec of the offer it lists as the official client does, must pick one every TeamSpeak client decodes (`decoded_everywhere`), and decode it |
| `browser_renegotiates_with_rust` | Chromium streams VP8, then sends a new offer on the same connection with VP9 first (as the official client re-offers when it does not encode the codec we chose); `Peer::renegotiate` answers on the same peer, in the new offer's codec order; VP9 frames must arrive |
| `trickled_candidates_reach_browser` | A server-reflexive candidate (from a fake STUN server) as our sessions trickle it (`iceCandidate` signal with the peer's mid) is accepted by `addIceCandidate` |
| `browser_mdns_candidates_connect` | Chromium with its host addresses behind mDNS names (`VOELIN_BROWSER_MDNS=1`, see below) and our candidates kept from it, so only resolving its names can connect: our streamer (names in its answer) and our viewer (names in its offer) connect and the media flows |
| `browser_srtp_failure_is_noticed` | The relay of `crates/voelin-stream/tests/relay` between our streamer peer and Chromium drops SRTP once AES-GCM was selected: Chromium decodes nothing, our peer reports `NoFeedback`; the next connection with AES_CM_128_HMAC_SHA1_80 only decodes and reports nothing |
## Running
@@ -41,8 +43,12 @@ defaults to `npm root -g` so a global Playwright is found.
Chromium is started with `--disable-features=WebRtcHideLocalIpsWithMdns`:
without camera/microphone permission it would hide host candidates behind
mDNS names (`<uuid>.local`), which str0m cannot resolve. The official client
may do the same; see `docs/protocol-notes/ts6-streaming.md`.
mDNS names (`<uuid>.local`). Our peers resolve those (`voelin_stream::mdns`),
which `browser_mdns_candidates_connect` tests with the feature left on
(`Browser::start_with_mdns`, `VOELIN_BROWSER_MDNS=1` for the driver). That
test needs a network interface with multicast (the browser's responder
answers on it) and port 5353 shareable (`SO_REUSEADDR`). The official client
may hide its addresses the same way; see `docs/protocol-notes/ts6-streaming.md`.
## Findings
@@ -76,6 +82,12 @@ may do the same; see `docs/protocol-notes/ts6-streaming.md`.
entry and decodes what an encoder in Constrained Baseline makes
(`h264_vaapi`, also from DMA-BUFs, and `libx264`: 90 of 90 frames,
2026-10-03).
- Chromium 152 offers DTLS 1.3 and 1.2; our peers (1.2) get 1.2. Allowed
1.3, dimpl negotiates it with Chromium 152 (`tlsVersion` `FEFC`,
`TLS_AES_128_GCM_SHA256`) and the stream decodes; it is not turned on
(see "Negotiation" in `docs/architecture.md`).
- When SRTP fails after the handshake, Chromium sends no receiver report
that mentions our video: what `PeerEvent::NoFeedback` waits for.
- With str0m's bandwidth estimation and pacer on our streamer peer, Chromium's
transport-cc feedback yields estimates within the first second (about
640 kbit/s rising towards the desired bitrate with the 720 kbit/s synthetic