The product is Voelin (app id io.github.faumaray.Voelin), everywhere: - crates tsc-* -> voelin-* (and voelin-fuzz), the desktop binary tsc-desktop -> voelin, the development CLI tsctl -> voelinctl; - the Android app: applicationId, Kotlin package io.github.faumaray.voelin, VoelinApp, libvoelin_android.so (JNI class names follow); - TSC_* environment variables -> VOELIN_*, Gradle properties tsc.* -> voelin.*, signing secrets VOELIN_SIGNING_*; - the data/config/cache/state folder tsc -> voelin, the keyring service, thread names, the dev compose project; - desktop file, metainfo, icon, Flatpak manifest, NSIS installer, docs. The gateway keeps its name: bin tsgw (crate voelin-gateway), TSGW_* env vars, the tsgw.v1+json protocol, the tsgw image. The window title and the About page show "Voelin <version>" from voelin_platform::APP_NAME. Packages (scripts/package.sh): the app only (voelin, voelin.exe, APKs, Flatpak). voelinctl is a development tool and in no package. tsgw is for servers and now its own Linux package, tsgw_<v>_amd64.deb and tsgw-<v>-linux-x86_64.tar.gz, with a sandboxed systemd unit (packaging/linux/tsgw.service; /etc/tsgw config, /var/lib/tsgw state) and dependencies of its own (no GUI libraries). docs/gateway-admin.md has an Install section. Fixes: - package-windows: makensis on Windows found no file through "D:/a/..." paths; pass Windows paths (cygpath -w). - StartupWMClass is the app id, which the app sets as its X11 WM_CLASS (it was the binary name, so desktops could not match the window). - Gradle wrapper download timeout 10 s -> 60 s (slow proxies). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
102 lines
3.8 KiB
Rust
102 lines
3.8 KiB
Rust
//! Synthetic capture -> encoder -> decoder, through the public API.
|
|
#![cfg(feature = "vpx")]
|
|
|
|
use std::time::Duration;
|
|
|
|
use voelin_media::capture::synthetic::{BACKGROUND, RECT_COLOR, SyntheticScreen, TEXT_COLOR};
|
|
use voelin_media::{
|
|
CaptureOptions, Codec, Codecs, EncoderBackend, EncoderConfig, ScreenCapture, SourceId,
|
|
VideoFrame, convert,
|
|
};
|
|
|
|
const W: u32 = 320;
|
|
const H: u32 = 240;
|
|
const FPS: u32 = 30;
|
|
|
|
fn rgb_at(frame: &VideoFrame, x: u32, y: u32) -> [u8; 3] {
|
|
let rgba = convert::to_rgba_vec(frame).unwrap();
|
|
let i = ((y * frame.width + x) * 4) as usize;
|
|
[rgba[i], rgba[i + 1], rgba[i + 2]]
|
|
}
|
|
|
|
fn assert_close(actual: [u8; 3], expected: [u8; 3], tolerance: i32, what: &str) {
|
|
let ok = (0..3).all(|c| (i32::from(actual[c]) - i32::from(expected[c])).abs() <= tolerance);
|
|
assert!(ok, "{what}: got {actual:?}, expected {expected:?} ±{tolerance}");
|
|
}
|
|
|
|
/// Encode 30 frames of the pattern, force a keyframe midway, lower the
|
|
/// bitrate, and check every decoded frame.
|
|
fn roundtrip(codec: Codec) {
|
|
let codecs = Codecs::new();
|
|
let screen = SyntheticScreen::new(W, H);
|
|
let config = EncoderConfig { fps: FPS, bitrate_bps: 1_500_000, ..EncoderConfig::default() };
|
|
let mut encoder = codecs.new_encoder(codec, config).unwrap();
|
|
assert_eq!(encoder.backend(), EncoderBackend::Libvpx);
|
|
let mut decoder = codecs.new_decoder(codec).unwrap();
|
|
let mut worst = f64::INFINITY;
|
|
for n in 0..30 {
|
|
if n == 20 {
|
|
encoder.set_bitrate(600_000).unwrap();
|
|
}
|
|
let source = screen.frame(n, FPS);
|
|
let encoded = encoder.encode(&source, n == 15).unwrap();
|
|
assert_eq!(encoded.len(), 1, "{codec} frame {n}");
|
|
let encoded = &encoded[0];
|
|
assert_eq!(encoded.keyframe, n == 0 || n == 15, "{codec} frame {n}");
|
|
assert_eq!(encoded.pts_90khz, source.pts_90khz());
|
|
let decoded = decoder.decode(&encoded.data).unwrap().expect("a picture per frame");
|
|
assert_eq!((decoded.width, decoded.height), (W, H));
|
|
worst = worst.min(convert::psnr(&source, &decoded).unwrap());
|
|
|
|
// The rectangle is where the pattern put it, in its colour.
|
|
let (x, y, w, h) = screen.rect(n);
|
|
assert_close(rgb_at(&decoded, x + w / 2, y + h / 2), RECT_COLOR, 16, "rectangle");
|
|
assert_close(rgb_at(&decoded, W - 10, H - 10), BACKGROUND, 16, "background");
|
|
}
|
|
assert!(worst > 30.0, "{codec}: worst PSNR {worst:.1} dB");
|
|
}
|
|
|
|
#[test]
|
|
fn vp8_synthetic_roundtrip() {
|
|
roundtrip(Codec::Vp8);
|
|
}
|
|
|
|
#[test]
|
|
fn vp9_synthetic_roundtrip() {
|
|
roundtrip(Codec::Vp9);
|
|
}
|
|
|
|
/// Frames from the capture thread go through encode / decode in order.
|
|
#[tokio::test]
|
|
async fn capture_thread_to_decoder() {
|
|
let codecs = Codecs::new();
|
|
let mut screen = SyntheticScreen::new(W, H);
|
|
let options = CaptureOptions { fps: 60, cursor: false, queue: 8 };
|
|
let mut frames = screen.start(&SourceId::Synthetic, &options).await.unwrap();
|
|
let config = EncoderConfig { fps: 60, bitrate_bps: 1_000_000, ..EncoderConfig::default() };
|
|
let mut encoder = codecs.new_encoder(Codec::Vp8, config).unwrap();
|
|
let mut decoder = codecs.new_decoder(Codec::Vp8).unwrap();
|
|
let mut last_pts = None;
|
|
for _ in 0..10 {
|
|
let frame =
|
|
tokio::time::timeout(Duration::from_secs(5), frames.recv()).await.unwrap().unwrap();
|
|
let encoded = encoder.encode(&frame, false).unwrap();
|
|
for e in &encoded {
|
|
assert!(last_pts.is_none_or(|p| e.pts_90khz > p));
|
|
last_pts = Some(e.pts_90khz);
|
|
let decoded = decoder.decode(&e.data).unwrap().unwrap();
|
|
// The counter's first digit (3x5 cells of 5 px) sits at (10, 10).
|
|
let rgba = convert::to_rgba_vec(&decoded).unwrap();
|
|
let lit = (10..25u32)
|
|
.flat_map(|x| (10..35u32).map(move |y| (x, y)))
|
|
.filter(|&(x, y)| {
|
|
let p = &rgba[((y * W + x) * 4) as usize..][..3];
|
|
(0..3).all(|c| (i32::from(p[c]) - i32::from(TEXT_COLOR[c])).abs() < 60)
|
|
})
|
|
.count();
|
|
assert!(lit >= 25, "counter digit missing ({lit} lit pixels)");
|
|
}
|
|
}
|
|
screen.stop();
|
|
}
|