Offer the codecs every TeamSpeak client decodes before H.264

The official client could not show a Voelin stream: its decoder was
libwebrtc's NullVideoDecoder. Its log says why. On a machine with a
hardware H.264 encoder our offer put H.264 first, with every H.264
variant str0m knows; the client answered H.264 42e01f, then had no
decoder for it, because it decodes H.264 only with an OpenH264 library it
downloads at start-up, and that download failed (HTTP 403). Its SDP
capabilities list H.264 either way. VP8, VP9 and AV1 it always decodes:
FFmpeg's decoders, dav1d and libaom are built into it.

- The hardware encoder order, the automatic stream codec
  (`preferred_codec`) and the offer (`offer_codecs`) now put the codecs
  every client decodes (`decoded_everywhere`: AV1, VP9, VP8) before
  H.264, HEVC last. A viewer answers with the first codec of the offer it
  lists, so official clients take one they can decode; H.264 stays
  offered for peers that want it, and `stream.codec` can still choose it
  (its description now says what that means for official clients).
- A streamer offers H.264 only as it encodes it (Constrained High,
  packetization mode 1), not str0m's other variants, which let a viewer
  answer a profile, or packetization mode 0, we never send. Viewers still
  accept every variant.

Tests: `crates/voelin-core/tests/browser_codecs.rs` (VOELIN_INTEROP=1)
streams the test pattern through every encoder this machine has, VA-API
also from DMA-BUFs, to headless Chromium's libwebrtc: VA-API H.264 and
AV1, libvpx VP8 and VP9, x264, SVT-AV1 and libaom all decode at
1280x720. A second test makes the offer a share makes here
([AV1, VP8, H264, H265]) and checks the browser picks and decodes a
codec every client decodes. The browser driver now takes playwright-core
with a system Chromium (VOELIN_CHROMIUM), which decodes H.264, and the
interop tests accept Chromium 152's name for the SRTP cipher. The
official client itself could not be run here (its beta needs a
myTeamSpeak sign-in on first start).

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:37 +03:00
1 parent a9a12bb4db
commit 630ff848b2
13 files changed
+431 -116

No files matched your search

+14 -6
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,