Merge the development branch: share menu, codec order, segmentation

Brings in the Share button's menu (Share screen / Stream Studio) and the
removal of the separate Stream Studio button from the headers, the
codecs every TeamSpeak client decodes ahead of H.264, the portal fix
and person segmentation.

The phone header keeps this branch's voice-channel button and hides the
bell on the voice screen, and loses the Stream Studio button as the
development branch wants. The studio's test table takes the
segmentation rows and the Android camera row. MediaCodec follows the new
codec order with no code change (Codecs orders every hardware factory's
codecs); its description and docs/media.md now say so, including what
that means on a phone without a hardware VP8, VP9 or AV1 encoder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
selikhovandClaude Opus 5.5 committed 2026-10-03 20:02:47 +03:00
commit 698e5f911e
35 files changed
+24436 -224

No files matched your search

+23 -11
View File
@@ -159,18 +159,26 @@ viewer: Engine::subscribe_frames ─ VideoPipeline (thread) ─ VideoDecoder
- `peer_config(&codecs, config)` makes a viewer accept only what we decode
and a streamer offer its stream codec (the first of `config.video_codecs`
it can encode) followed by `offer_codecs`: the codecs of hardware
encoders, VP8 through libvpx (every TeamSpeak client decodes it), and HEVC
encoders and VP8 through libvpx that every TeamSpeak client decodes
(`decoded_everywhere`: AV1, VP9, VP8), then H.264 from hardware, and HEVC
last. Other software encoders (x264, SVT-AV1, libvpx VP9, ...) are only
ever the stream codec, so a viewer's answer never starts an expensive
second encoder. Answers keep the offer's order, so viewers take the stream
codec when they decode it. `preferred_codec(&codecs, configured)` picks the
stream codec: `stream.codec` if encodable, else the preference's first
(hardware first when enabled, VP8 in software; never HEVC);
`encoder_preference(&settings)` and `configured_codec(&settings)` read the
settings. H.264 is offered as Constrained High at the level the stream
needs (`PeerConfig::set_h264_format(profile, width, height, fps, bitrate)`:
codec every TeamSpeak client decodes (hardware first when enabled, VP8 in
software), else any but HEVC; `encoder_preference(&settings)` and
`configured_codec(&settings)` read the settings. The official client
decodes H.264 only with an OpenH264 library it downloads at start-up; when
that fails it still answers H.264 and shows nothing (see
`docs/protocol-notes/ts6-streaming.md`), so H.264 never comes before a
codec it always decodes. H.264 is offered as one variant, Constrained High
(packetization mode 1) at the level the stream needs
(`PeerConfig::set_h264_format(profile, width, height, fps, bitrate)`:
macroblocks per second and per frame, and bitrate, per H.264 Table A-1;
never below 3.1, the level offered before).
never below 3.1, the level offered before); str0m's other H.264 variants
are only accepted, never offered, so a viewer cannot answer a profile we
do not send.
- `VideoPipeline` decodes on its own thread. It starts at a keyframe, and
after a lost frame (`contiguous == false`, a lagging frame bus, a queue
longer than 30 frames) or a decoder error it skips to the next keyframe,
@@ -488,9 +496,13 @@ takes and returns `VideoFrame`s like the software codecs. Encoders get NV12
`slice-height`, parsed by `codec::image_layout`, which is tested on every
platform); H.264 is High (preferably Constrained High) without B-frames, SPS/PPS
in front of every keyframe, keyframes on request (`request-sync`), bitrate
changes at runtime (`video-bitrate`). Encoder order: the device's hardware
encoders (H.264, VP9, VP8), then Google's software VP8 and H.264. Decoders
return the newest finished picture per `decode` call (NV12 or I420).
changes at runtime (`video-bitrate`). Encoders: the device's hardware ones
(H.264, VP9, VP8, AV1) and Google's software VP8 and H.264 (software VP9 and
AV1 are too slow), ordered by codec like every hardware encoder: the codecs
every TeamSpeak client decodes (AV1, VP9, VP8) before H.264. So a phone
without a hardware VP8, VP9 or AV1 encoder streams Google's software VP8 by
default; a stream codec set to H.264 uses its hardware H.264 encoder.
Decoders return the newest finished picture per `decode` call (NV12 or I420).
The zero-copy path for screen sharing: while it is the only MediaCodec
encoder in the process (one simulcast layer, one codec), an encoder reports a
@@ -929,7 +941,7 @@ has not run on Windows yet.
| OpenH264 download, SHA-256 check, reuse | `tests/openh264.rs -- --ignored` | tested locally (network) |
| H.264 library missing / unknown file | unit + integration tests | tested |
| AV1 decoder construction, garbage input | unit test (`--features av1`) | tested; streams of SVT-AV1, rav1e, libaom, `av1_vaapi` and `av1_amf` decoded (rows below) |
| X11 capture (MIT-SHM and GetImage), sources, window capture → VP8 → decode, cursor | `tests/x11_capture.rs` under Xvfb | tested |
| X11 capture (MIT-SHM and GetImage), sources, window capture → VP8 → decode, cursor | `tests/x11_capture.rs` under Xvfb (`VOELIN_X11_TEST_DISPLAY`) | tested |
| wlroots capture (wlr-screencopy v3): outputs, pixels, a change arriving as a new frame, queue API | `tests/wlroots_capture.rs` against headless sway 1.9 (`VOELIN_WLROOTS_TEST_DISPLAY`) | tested; the ext-image-copy-capture path is untested (sway 1.9 predates it) |
| Converter (strides, unpadded last row, odd sizes, RGBA/I420/NV12), scaler (flat, area average, half), pyramid (sharing, recycling, steady-state pools) | unit tests | tested |
| Simulcast layers (sizes, fps caps, per-layer keyframes), reconfigure (codec, layers, fps) | `voelin-core` `media::tests::simulcast_layers_and_reconfigure` | tested |
@@ -967,7 +979,7 @@ has not run on Windows yet.
| Stream mixer (latency, fade on underrun, drift correction, rate conversion, limiter, levels, live source changes), `BlockClock` | `voelin-media` `mix::tests`, `tests/mix_alloc.rs` (no allocation per block) | tested |
| Application audio on PipeWire: desktop without our own stream, by name, by pid, a new player linked live, a quit one dropped, a restarted one matched again, the app list | `voelin-media/tests/pipewire_apps.rs` (private PipeWire, WirePlumber and D-Bus; tones told apart by frequency) | tested with PipeWire 1.0 and WirePlumber 0.4; skipped without them |
| Streamer audio sources (mix levels, gain, mute, live change, microphone tap, window source error, silence) | `voelin-core` `media::tests::audio_sources_change_live`, `audio_sources_from_settings`, `settings::tests::audio_sources` | tested |
| X11 `_NET_WM_PID` of the shared window | `tests/x11_capture.rs` under Xvfb | tested |
| X11 `_NET_WM_PID` of the shared window | `tests/x11_capture.rs` under Xvfb (`VOELIN_X11_TEST_DISPLAY`) | tested |
| WASAPI per-process loopback, audio sessions, `HWND` owner | – | type-checked for `x86_64-pc-windows-gnu` only |
| Android per-app and all-but-ours playback capture | `cargo ndk -t arm64-v8a clippy`, `gradlew compileDebugKotlin` | compiles only (no device or emulator here) |
| The same through the TeamSpeak 6 server | `voelin-core/tests/media_live.rs` (`VOELIN_LIVE=1`), `voelinctl stream start --synthetic` / `watch --expect-frames` | tested against 6.0.0-beta13.1 |
+35 -4
View File
@@ -38,7 +38,8 @@ Transport (**reported**, TeamSpeak staff on community.teamspeak.com):
Codecs (**reported**, from the ts6-manager bot's working code):
- Video: H.264 Constrained High (the only H.264 profile the TS client decodes),
VP8, VP9, AV1.
VP8, VP9, AV1. H.264 only when the client could download OpenH264 (see
"Codecs the official client decodes" below).
- Audio: Opus, 48 kHz stereo, payload type 111.
Commands over the normal client command channel (**reported**, ts6-manager,
@@ -231,6 +232,36 @@ libwebrtc, the stack the official client is built on:
feedback gives estimates; the offer is the same as without (str0m always
offers transport-cc and abs-send-time).
### Codecs the official client decodes (confirmed, client 6.0.0-beta4.1, 2026-10-03)
From the official Linux client's log (`~/.cache/TeamSpeak/Default/logs/`)
while it watched a Voelin stream, and the symbols of its binary:
- At start-up it downloads Cisco's OpenH264
(`http://ciscobinary.openh264.org/libopenh264-2.6.0-linux64.8.so.bz2`); here
the download failed (`Failed to download openh264 binary http code: 403`).
- Voelin offered H.264 first (the hardware encoder's codec), with every H.264
variant str0m knows. The client answered H.264 `profile-level-id=42e01f`
(packetization mode 1), then could not make a decoder for it: `Trying to
create decoder for unsupported format. Codec name: H264` — libwebrtc's
`NullVideoDecoder`, nothing shown. Its SDP capabilities list H.264 whether
or not OpenH264 loaded.
- Its decoders: `FFmpegDecoderVP8`, `FFmpegDecoderVP9`, `FFmpegDecoderAV1`
(FFmpeg bundled in `/opt/teamspeak`, dav1d and libaom linked in), AMF
hardware decoders for H.264 and AV1, and OpenH264 (`H264DecoderImpl`) once
downloaded. VP8, VP9 and AV1 therefore always decode; H.264 depends on the
download.
- It answers with the first codec of the offer it lists, like Chromium.
Voelin now offers codecs every client decodes first (`decoded_everywhere`)
and H.264 only in the profile it encodes. The real encoders' streams (VA-API
H.264 and AV1, from memory and from DMA-BUFs; libvpx VP8 and VP9; x264,
SVT-AV1, libaom) decode in Chromium 152's libwebrtc at full size
(`crates/voelin-core/tests/browser_codecs.rs`). Watching such a stream with
the official client itself is still to be confirmed: the beta needs a
myTeamSpeak sign-in on first start, so it cannot run from a throwaway
profile.
## Open questions
- [x] Viewer side: `joinstreamrequest id clid msg is_remove` (see above).
@@ -242,9 +273,9 @@ libwebrtc, the stack the official client is built on:
- [x] Whether a client that connects later is told about running streams: no (see above).
- [x] How a client finds running streams after connecting: `requeststreaminfo`
(presumably what the official client does too; not captured from it).
- [ ] Interop with the official TS6 client (its offer/answer details, codecs it
actually picks, whether it trickles candidates, mDNS host candidates).
Chromium's WebRTC stack interoperates (see above).
- [ ] 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 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).
+16 -9
View File
@@ -43,7 +43,7 @@ the UI) and a `background` (replacement, below).
|---|---|---|
| `screen` | `monitor`, `backend` (`portal`, `wlroots`, `x11`, `windows`; none: this session's), `cursor` | a capture backend, frames borrowed and copied into pooled frames |
| `window` | `handle` (X11 id, `HWND`), `backend`, `cursor` | the same |
| `portal` | `restore_token`, `cursor` | the ScreenCast portal's dialog (Wayland); the token is written back so it is asked once |
| `portal` | `restore_token`, `cursor` | the ScreenCast portal's dialog (Wayland); with a `restore_token` the portal may restore its last choice without asking. The UI adds portal sources without one, so the dialog asks each time the source starts |
| `camera` | `device` (a `camera::Camera::id`; empty: the first), `size`, `fps`, `mirror` | see [Cameras](#cameras) |
| `image` | `path` | PNG or JPEG, alpha kept, read once |
| `text` | `text`, `font` (none: the bundled Inter), `size_px`, `colour`, `backdrop`, `align`, `padding` | rasterised once with `ab_glyph` |
@@ -134,13 +134,19 @@ blur is a three-pass box blur (close to a Gaussian), separable, with a
running sum so its cost does not grow with the radius, in bands on a worker
pool over pooled buffers.
**What segments today is not a person.** `segment::Ellipse`, the segmenter
that is always there, is a centred oval about where a person sits in front
of a camera. A person segmentation model (MediaPipe selfie segmentation,
Apache-2.0, through `tract-onnx`) is meant to sit behind the `Segmenter`
trait; it is not in this build, because the model could not be fetched where
this was built (see [Status](#status)). Dropping it in changes nothing on the
frame path.
The person is found by `segment::HumanSeg` (feature `segment`, on by
default): PP-HumanSeg, PaddleSeg's portrait segmentation model as OpenCV Zoo
ships it (`crates/voelin-media/models/`, 6 MB, Apache-2.0, bundled into the
binary), run on the CPU by `tract-onnx`. The frame is squeezed to 192x192 RGB;
the mask is the model's probability of a person per pixel, 192x192, which
the frame path stretches back over the frame (its soft edge is the
feathering). The model is parsed and optimised once per process, on the
segmentation thread when the first mask is due; one mask then takes about
50 ms on one core of a desktop CPU (dev builds optimise tract too), so the
10 masks a second cost about half a core. If the model does not load,
`segment::Ellipse`, a centred oval about where a person sits in front of a
camera, stands in (and builds without `segment` use it). Other models drop
in behind the `Segmenter` trait without changing the frame path.
## Outputs (`studio::output`)
@@ -301,7 +307,8 @@ two threads) takes about 3 ms at its own rate (15 fps by default).
| Real camera through the user's PipeWire (Fifine K420, 1280x720) | `camera::tests::a_real_camera_delivers` (`--ignored`) | tested on one webcam |
| Camera through the XDG Camera portal (sandboxes) | – | compiles only |
| Screen, window and portal sources | the existing capture backends ([media.md](media.md#capture)) | as tested there; not run inside the studio here |
| Background blur, image and colour backdrops on the oval mask | `segment::tests` | tested; **no person segmentation model** (see above) |
| Background blur, image and colour backdrops on the oval mask | `segment::tests` | tested |
| Person segmentation (PP-HumanSeg through tract): loads, 192x192 mask, nobody in an empty room, time per mask | `segment::tests::the_model_finds_nobody_in_an_empty_room` | tested (about 50 ms per mask); on a photo of a person the mask follows the silhouette, arms and legs included (checked by eye, the photo is not in the repository); not yet tried with a camera |
| Android cameras (Camera2): planes borrowed, gathered or turned | `camera::tests::camera_planes_are_borrowed_gathered_and_turned` (the Rust side) | tested on the host; the Camera2 side compiles only (no device here) |
| Windows cameras | – | not implemented: `camera::list()` has only the test pattern there |
| RTMP | – | the seam only (refuses with its reason) |
+3 -1
View File
@@ -149,7 +149,9 @@ Activity tab.
![Stream Studio](screenshots/desktop-studio-live.png)
The studio (mockups 09, 10 and the phone's 04) is a page of the main window
(the radio button in the top bar), a window of its own (the button in its
(the Share button's menu: "Share screen" for a quick share of a screen or
window, "Stream Studio" for the studio; while a share runs the button opens
its dialog), a window of its own (the button in its
header; closing that window brings it back) and a phone page. Its controller
is `src/studio.rs` on the engine's studio ([studio.md](studio.md)): the
studio runs while it is shown, live or recording, and a `Streamer` started