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>
101 lines
3.0 KiB
Rust
101 lines
3.0 KiB
Rust
mod cli;
|
|
mod common;
|
|
mod doctor;
|
|
#[cfg(feature = "gui")]
|
|
mod gui;
|
|
mod host;
|
|
mod interactive;
|
|
mod repair;
|
|
mod viewer;
|
|
|
|
use anyhow::Result;
|
|
use clap::Parser;
|
|
use cli::Cli;
|
|
use iroh_tickets::endpoint::EndpointTicket;
|
|
use tracing_subscriber::EnvFilter;
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<()> {
|
|
let cli = Cli::parse();
|
|
init_tracing(cli.verbose);
|
|
|
|
if matches!(cli.output, Some(cli::OutputFormat::Json)) {
|
|
common::output::set_json(true);
|
|
}
|
|
|
|
if cli.gui {
|
|
#[cfg(feature = "gui")]
|
|
{
|
|
return gui::run(cli.relay);
|
|
}
|
|
#[cfg(not(feature = "gui"))]
|
|
{
|
|
anyhow::bail!(
|
|
"this binary was built without GUI support. Rebuild with \
|
|
`cargo build --release --features gui` to use --gui."
|
|
);
|
|
}
|
|
}
|
|
|
|
// Diagnostics run before pipewire::init() (they don't need it) and work
|
|
// regardless of the `gui` feature, so a headless tester can probe their box.
|
|
if cli.doctor {
|
|
let relay = common::endpoint::relay_override(cli.relay.as_deref());
|
|
return doctor::run(relay).await;
|
|
}
|
|
|
|
// libpipewire requires global init before any pw_* call. Idempotent;
|
|
// safe to call even when the per-app audio thread never spawns.
|
|
pipewire::init();
|
|
|
|
if cli.repair {
|
|
return repair::run().await;
|
|
}
|
|
|
|
if cli.reconfigure {
|
|
return interactive::run_reconfigure().await;
|
|
}
|
|
|
|
if cli.host {
|
|
if cli.ticket.is_some() {
|
|
anyhow::bail!(
|
|
"--host and a ticket argument are mutually exclusive: --host shares your \
|
|
screen, a ticket views someone else's."
|
|
);
|
|
}
|
|
return host::run(cli.into_host_opts(false)).await;
|
|
}
|
|
|
|
match cli.ticket.as_deref() {
|
|
Some(s) => {
|
|
let ticket: EndpointTicket = s.parse().map_err(|e| {
|
|
anyhow::anyhow!(
|
|
"argument doesn't look like a pixelpass ticket ({e}).\n\
|
|
Run with no arguments for the interactive menu, or pass a ticket to view."
|
|
)
|
|
})?;
|
|
viewer::run(ticket, cli.into_viewer_opts(false)).await
|
|
}
|
|
None => interactive::run(cli).await,
|
|
}
|
|
}
|
|
|
|
fn init_tracing(verbose: bool) {
|
|
let default = if verbose {
|
|
"pixelpass=trace,iroh=info"
|
|
} else {
|
|
"pixelpass=info,iroh=warn"
|
|
};
|
|
let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(default));
|
|
// Tracing MUST write to stderr. `tracing_subscriber::fmt()` defaults its
|
|
// writer to stdout, but with `--output json` stdout carries the JSON event
|
|
// stream the `--gui` front-end parses (see `common::output`) — logging there
|
|
// interleaves log lines into that stream (corrupting events and starving the
|
|
// GUI's stderr-tail diagnostics). Pin it to stderr to honor that contract.
|
|
tracing_subscriber::fmt()
|
|
.with_writer(std::io::stderr)
|
|
.with_env_filter(filter)
|
|
.with_target(false)
|
|
.init();
|
|
}
|