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>
79 lines
2.4 KiB
Rust
79 lines
2.4 KiB
Rust
//! The Node.js side of the browser interop tests (headless Chromium through
|
|
//! `tests/interop/browser-peer.cjs`), shared by the tests of several crates
|
|
//! with `#[path = ".../tests/interop/browser.rs"] mod browser;`.
|
|
|
|
use std::path::Path;
|
|
use std::process::Stdio;
|
|
use std::time::Duration;
|
|
|
|
use serde_json::{Value, json};
|
|
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader, Lines};
|
|
use tokio::process::{Child, ChildStdin, ChildStdout, Command};
|
|
use tokio::time::timeout;
|
|
|
|
/// The tests run only with `VOELIN_INTEROP=1` (see `tests/interop/README.md`).
|
|
pub fn enabled() -> bool {
|
|
std::env::var("VOELIN_INTEROP").is_ok_and(|v| v == "1")
|
|
}
|
|
|
|
/// Headless Chromium, driven over stdin/stdout.
|
|
pub struct Browser {
|
|
_child: Child,
|
|
stdin: ChildStdin,
|
|
stdout: Lines<BufReader<ChildStdout>>,
|
|
}
|
|
|
|
impl Browser {
|
|
pub async fn start() -> Self {
|
|
let script = Path::new(env!("CARGO_MANIFEST_DIR"))
|
|
.join("../../tests/interop/browser-peer.cjs")
|
|
.canonicalize()
|
|
.expect("tests/interop/browser-peer.cjs");
|
|
let node = std::env::var("VOELIN_NODE").unwrap_or_else(|_| "node".into());
|
|
let mut command = Command::new(node);
|
|
command
|
|
.arg(script)
|
|
.stdin(Stdio::piped())
|
|
.stdout(Stdio::piped())
|
|
.stderr(Stdio::inherit())
|
|
.kill_on_drop(true);
|
|
// Playwright is usually installed globally.
|
|
if std::env::var_os("NODE_PATH").is_none()
|
|
&& let Ok(out) = std::process::Command::new("npm").args(["root", "-g"]).output()
|
|
{
|
|
command.env("NODE_PATH", String::from_utf8_lossy(&out.stdout).trim());
|
|
}
|
|
let mut child = command.spawn().expect("cannot start node (set VOELIN_NODE)");
|
|
let stdin = child.stdin.take().unwrap();
|
|
let stdout = BufReader::new(child.stdout.take().unwrap()).lines();
|
|
let mut browser = Self { _child: child, stdin, stdout };
|
|
let ready = browser.read().await;
|
|
eprintln!("browser: {}", ready["userAgent"]);
|
|
browser
|
|
}
|
|
|
|
async fn read(&mut self) -> Value {
|
|
let line = timeout(Duration::from_secs(60), self.stdout.next_line())
|
|
.await
|
|
.expect("browser did not answer")
|
|
.unwrap()
|
|
.expect("browser exited");
|
|
let value: Value = serde_json::from_str(&line).unwrap();
|
|
if let Some(error) = value.get("error") {
|
|
panic!("browser: {error}");
|
|
}
|
|
value
|
|
}
|
|
|
|
pub async fn call(&mut self, command: Value) -> Value {
|
|
let mut line = command.to_string();
|
|
line.push('\n');
|
|
self.stdin.write_all(line.as_bytes()).await.unwrap();
|
|
self.read().await
|
|
}
|
|
|
|
pub async fn quit(mut self) {
|
|
let _ = self.call(json!({ "op": "quit" })).await;
|
|
}
|
|
}
|