Add pixelpass --doctor environment diagnostic
Screen-share failures are usually environment gaps, not pixelpass bugs — most often a GPU/driver with no working VA-API H.264 encoder, so the default vah264enc pipeline produces no video and the viewer "can't connect." doctor probes the whole chain and prints one actionable report so a remote tester can read it over a call instead of us guessing from logs, and it validates any X11/Wayland test environment we stand up. Checks (each a ✓/!/✗ line with a distro-aware install hint): - display server (Wayland/X11 + session env), and the X server vendor/ version so an xlibre server is distinguishable from stock Xorg - capture: gst tools + the backend's source element (pipewiresrc/ximagesrc) - encode: hardware H.264 (vah264enc + DRM render node + a VA-API H.264 *encode* entrypoint parsed from vainfo) and the software x264 fallback - mux/audio tail + pactl - viewer player (mpv/vlc) - network: binds a real endpoint and checks relay reachability Unlike deps::check_host_binaries (bails on first miss), doctor runs every check and reports them together. Closes with a specific hosting verdict and exits non-zero on any hard failure so scripts/CI can gate. Pure seams (vainfo entrypoint parse, summary tally, hosting verdict) are unit-tested; deps.rs gained pub(crate) which/gst_element_exists/install-hint/distro helpers so doctor reuses the same package-name knowledge. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+15
-10
@@ -56,12 +56,7 @@ fn require(bin: &str) -> Result<PathBuf> {
|
||||
}
|
||||
|
||||
fn require_gst_element(name: &str) -> Result<()> {
|
||||
let ok = Command::new("gst-inspect-1.0")
|
||||
.args(["--exists", name])
|
||||
.status()
|
||||
.map(|s| s.success())
|
||||
.unwrap_or(false);
|
||||
if !ok {
|
||||
if !gst_element_exists(name) {
|
||||
bail!(
|
||||
"GStreamer element `{name}` not available.\n{}",
|
||||
install_hint_for_gst_element(name)
|
||||
@@ -70,7 +65,17 @@ fn require_gst_element(name: &str) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn which(bin: &str) -> Option<PathBuf> {
|
||||
/// Whether a GStreamer element is registered, via `gst-inspect-1.0 --exists`.
|
||||
/// Non-bailing counterpart to [`require_gst_element`] for the `doctor` report.
|
||||
pub(crate) fn gst_element_exists(name: &str) -> bool {
|
||||
Command::new("gst-inspect-1.0")
|
||||
.args(["--exists", name])
|
||||
.status()
|
||||
.map(|s| s.success())
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub(crate) fn which(bin: &str) -> Option<PathBuf> {
|
||||
let path = std::env::var_os("PATH")?;
|
||||
for dir in std::env::split_paths(&path) {
|
||||
let candidate = dir.join(bin);
|
||||
@@ -81,7 +86,7 @@ fn which(bin: &str) -> Option<PathBuf> {
|
||||
None
|
||||
}
|
||||
|
||||
fn install_hint_for_bin(bin: &str) -> String {
|
||||
pub(crate) fn install_hint_for_bin(bin: &str) -> String {
|
||||
let distro = detect_distro();
|
||||
let pkg = match bin {
|
||||
"gst-launch-1.0" | "gst-inspect-1.0" => match distro.as_deref() {
|
||||
@@ -113,7 +118,7 @@ fn install_hint_for_bin(bin: &str) -> String {
|
||||
install_command(&distro, pkg)
|
||||
}
|
||||
|
||||
fn install_hint_for_gst_element(name: &str) -> String {
|
||||
pub(crate) fn install_hint_for_gst_element(name: &str) -> String {
|
||||
let distro = detect_distro();
|
||||
let pkg = match name {
|
||||
"pipewiresrc" => match distro.as_deref() {
|
||||
@@ -210,7 +215,7 @@ fn install_command(distro: &Option<String>, pkg: &str) -> String {
|
||||
format!("Install hint: {cmd}")
|
||||
}
|
||||
|
||||
fn detect_distro() -> Option<String> {
|
||||
pub(crate) fn detect_distro() -> Option<String> {
|
||||
let contents = std::fs::read_to_string("/etc/os-release").ok()?;
|
||||
for line in contents.lines() {
|
||||
if let Some(rest) = line.strip_prefix("ID=") {
|
||||
|
||||
Reference in New Issue
Block a user