voelin-stream: announce at most the 16 bits a TS6 server keeps

Probed against the TeamSpeak 6 dev server (6.0.0-beta13.1): `setupstream`
takes any bitrate and enforces none, but keeps it in 16 bits, so 100000
kbit/s is announced to the channel as 34464 and 4294967296 as 0. A stream
of more than 65.5 Mbit/s would have been announced as a small, wrong
number.

`proto::setup` now announces at most 65535 kbit/s
(`MAX_ANNOUNCED_BITRATE`); a 60 Mbit/s stream is announced as 60000, as
it is. The peers keep sending the real rate: nothing between them reads
the announcement. The probe and its results are in the protocol notes,
and the old "TeamSpeak caps streams at 10 Mbit/s" is corrected where the
code claimed it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
selikhovandClaude Opus 5.5 committed 2026-10-04 03:19:50 +03:00
1 parent 2b1185f84d
commit 297dc2fe5b
3 files changed
+41 -4

No files matched your search

+2 -1
View File
@@ -139,7 +139,8 @@ pub enum H264Profile {
pub struct EncoderConfig {
/// Expected frame rate (rate control; timestamps come from the frames).
pub fps: u32,
/// Target bitrate in bits per second. TeamSpeak caps streams at 10 Mbit/s.
/// Target bitrate in bits per second (no limit; TeamSpeak 6 servers
/// enforce none, see `voelin_stream::proto::MAX_ANNOUNCED_BITRATE`).
pub bitrate_bps: u32,
/// Maximum frames between keyframes; `None` sends keyframes only at the
/// start and on request (PLI), like WebRTC.
+14 -2
View File
@@ -76,12 +76,19 @@ impl LeaveReason {
}
}
/// The most `setupstream` announces, in kbit/s: TeamSpeak 6 servers keep
/// the bitrate in 16 bits and wrap anything above (6.0.0-beta13.1 announced
/// 100000 as 34464), but enforce nothing, so a stream sends its real rate
/// peer to peer whatever the announcement says.
pub const MAX_ANNOUNCED_BITRATE: u32 = u16::MAX as u32;
/// Parameters of `setupstream`.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct StreamSetup {
pub name: String,
pub kind: StreamKind,
/// kbit/s; the server caps streams at 10 Mbit/s.
/// The stream's video bitrate in kbit/s (the single layer's without
/// simulcast); announced as at most [`MAX_ANNOUNCED_BITRATE`].
pub bitrate: u32,
/// `accessibility`: the official client and ts6-manager send 1.
pub accessibility: u8,
@@ -301,7 +308,7 @@ pub fn setup(setup: &StreamSetup) -> OutCommand {
c2s::OutSetupStreamMessage::new(&mut iter::once(c2s::OutSetupStreamPart {
stream_name: Cow::Borrowed(&setup.name),
stream_type: setup.kind.to_u8(),
bitrate: setup.bitrate,
bitrate: setup.bitrate.min(MAX_ANNOUNCED_BITRATE),
access: setup.accessibility,
stream_mode: setup.mode,
viewer_limit: setup.viewer_limit,
@@ -442,6 +449,11 @@ mod tests {
"setupstream name=my\\sscreen type=3 bitrate=4608 accessibility=1 mode=1 viewer_limit=0 \
audio=1"
);
// 60 Mbit/s is announced as it is; beyond 16 bits, the most the
// server keeps instead of a wrapped value.
let fast = |bitrate| text(setup(&StreamSetup { bitrate, ..s.clone() }));
assert!(fast(60_000).contains(" bitrate=60000 "));
assert!(fast(100_000).contains(" bitrate=65535 "));
assert_eq!(
text(join_request("u-1", ClientId(5), "", false)),
"joinstreamrequest id=u-1 clid=5 msg is_remove=0"
+25 -1
View File
@@ -33,7 +33,8 @@ Transport (**reported**, TeamSpeak staff on community.teamspeak.com):
- ICE with STUN only (`turn.teamspeak.com`, `turn2.teamspeak.com`; no TURN relay).
- Media ports: UDP 49152–65535.
- Streams are channel-scoped: "public" means everyone in the streamer's channel.
- Bitrate capped at 10 Mbit/s.
- Bitrate capped at 10 Mbit/s. The server itself enforces no limit, see
[what `setupstream` takes](#what-setupstream-takes-confirmed-600-beta131-2026-10-04).
Codecs (**reported**, from the ts6-manager bot's working code):
@@ -90,6 +91,29 @@ When the streamer disconnects, everyone gets `notifystreamstopped id=<uuid>`.
Stream ids are UUIDs. The notification carries the command's `return_code`, and
the field is named `access` there (not `accessibility`).
### What `setupstream` takes (confirmed, 6.0.0-beta13.1, 2026-10-04)
`bitrate` (kbit/s) is informational: the server stores it in 16 bits and
enforces nothing. Sent with `voelinctl connect 127.0.0.1:9988 --log-commands
raw 'setupstream name=probe type=3 bitrate=<b> accessibility=1 mode=1
viewer_limit=0 audio=1'` (`RUST_LOG=debug` prints the commands), every one
answered `error id=0`, and `notifystreamstarted` announced:
| `bitrate` sent | announced |
|---|---|
| 10000, 10001, 60000 | the same |
| 100000 | 34464 (100000 mod 65536) |
| 1000000 | 16960 |
| 4294967295 | 65535 |
| 4294967296, 0 | 0 |
So 65535 kbit/s is the most a stream can announce, and anything above it
wraps silently. Voelin announces its stream's real bitrate up to 65535
(`proto::MAX_ANNOUNCED_BITRATE`; e.g. 60000 for a 60 Mbit/s stream), and
its peers send whatever the stream needs whatever was announced: nothing
between the peers looks at the announcement. Viewers see the announced
value in `notifystreamstarted` / `notifystreaminfo`.
### Join handshake (confirmed, 6.0.0-beta13.1)
```