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:
1 parent
a9a12bb4db
commit
630ff848b2
13 files changed
+431
-116
No files matched your search
@@ -9,7 +9,9 @@
|
||||
//! disable it (see docs/media.md).
|
||||
//!
|
||||
//! TeamSpeak clients only decode H.264 Constrained High; OpenH264 encodes
|
||||
//! without B-frames, so its High profile output qualifies.
|
||||
//! without B-frames, so its High profile output qualifies. The official
|
||||
//! client decodes H.264 only once it downloaded OpenH264 itself, so streams
|
||||
//! prefer codecs it always decodes (`voelin_core::media::decoded_everywhere`).
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
|
||||
@@ -406,10 +406,12 @@ fn unavailable(codec: Codec, reason: impl Into<String>) -> Error {
|
||||
Error::CodecUnavailable { codec, reason: reason.into() }
|
||||
}
|
||||
|
||||
/// Order of codecs among hardware encoders: H.264 (every viewer decodes
|
||||
/// it), AV1, VP9, VP8, and HEVC last (only for peers that take nothing
|
||||
/// else).
|
||||
const HARDWARE_ORDER: [Codec; 5] = [Codec::H264, Codec::Av1, Codec::Vp9, Codec::Vp8, Codec::H265];
|
||||
/// Order of codecs among hardware encoders: the ones every TeamSpeak
|
||||
/// client decodes first (AV1, VP9, VP8: the official client's WebRTC stack
|
||||
/// has their decoders built in), then H.264 (the official client decodes it
|
||||
/// only with an OpenH264 library it downloads at start-up and may not get),
|
||||
/// and HEVC last (only for peers that take nothing else).
|
||||
const HARDWARE_ORDER: [Codec; 5] = [Codec::Av1, Codec::Vp9, Codec::Vp8, Codec::H264, Codec::H265];
|
||||
|
||||
/// An encoder backend in the base order (before the preference applies).
|
||||
struct Candidate {
|
||||
@@ -868,8 +870,8 @@ mod tests {
|
||||
codecs.encoders_for(&preference).iter().map(|(_, b)| b.name()).collect()
|
||||
};
|
||||
let auto = names(EncoderPreference::default());
|
||||
// Hardware in codec order (HEVC last), then software.
|
||||
assert_eq!(auto[..3], ["h264_gpu", "vp8_gpu", "hevc_gpu"]);
|
||||
// Hardware in codec order (H.264 after VP8, HEVC last), then software.
|
||||
assert_eq!(auto[..3], ["vp8_gpu", "h264_gpu", "hevc_gpu"]);
|
||||
let position = |list: &[&str], name| list.iter().position(|n| *n == name).unwrap();
|
||||
assert!(position(&auto, "x264") < position(&auto, "av1_sw"));
|
||||
#[cfg(feature = "vpx")]
|
||||
@@ -886,7 +888,7 @@ mod tests {
|
||||
assert!(!named[1..].iter().any(|n| n.ends_with("_gpu")));
|
||||
// The codecs follow the preference.
|
||||
codecs.set_preference(EncoderPreference::default());
|
||||
assert_eq!(codecs.encoder_codecs()[..3], [Codec::H264, Codec::Vp8, Codec::H265]);
|
||||
assert_eq!(codecs.encoder_codecs()[..3], [Codec::Vp8, Codec::H264, Codec::H265]);
|
||||
// The report ranks what the preference uses.
|
||||
let report = codecs.report();
|
||||
let openh264 = report.encoders.iter().find(|e| e.name == "openh264").unwrap();
|
||||
|
||||
Reference in new issue
Block a user