Handle stopped streams, live bandwidth, and rework the upscaling tiers

When the server owner stops a stream, Plex cuts the connection and repeats
the termination in every timeline reply to the client until it reports a
stop. The player now reads those replies (also when playback stalls or
fails), stops mpv, shows the owner's message and acknowledges it; a
termination on a session's first reply is left over from an earlier stream
and is cleared instead of cancelling the new one. Each title also starts
unpaused, as mpv keeps pause across files.

The dashboard's bandwidth graph refreshes every second. Plex's real-time
samples are bytes per second with idle seconds omitted, so they are laid on
a gap-free per-second axis (they were divided by six before).

Upscaling: Balanced is now the strongest shader chain, light nlmeans,
FSRCNNX 16, KrigBilateral and debanding. Measured against 1080p references
shrunk to 480p it beat FSRCNNX 8, two network passes, RAVU and
SSimSuperRes. The denoiser is AN3223's light profile with luma strength at
60%, which keeps texture the default profile smoothed away. Quality is now
NVIDIA RTX Video Super Resolution through mpv's d3d11vpp filter, sized to
the window and re-applied when it changes; it is offered only on Windows
with an NVIDIA RTX GPU (app_info now lists the adapters), runs Balanced for
HDR or at native size, and drops a tier if the driver refuses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-10-31 12:09:34 -07:00
parent ac5048f0b2
commit d9e22dde2e
17 changed files with 316 additions and 524 deletions

View file

@ -26,6 +26,11 @@ impl VideoSurface {
pub fn set_rect<R: Runtime>(&mut self, _: &WebviewWindow<R>, _: Option<&Mpv>, _: Option<(i32, i32, i32, i32)>) {}
}
/// Not needed yet: the only GPU-specific tier (RTX Video) is Windows-only.
pub fn gpu_names() -> Vec<String> {
Vec::new()
}
pub fn hold_awake(rx: std::sync::mpsc::Receiver<()>) {
// TODO(Linux): org.freedesktop.ScreenSaver.Inhibit over D-Bus.
let _ = rx.recv();

View file

@ -26,6 +26,11 @@ impl VideoSurface {
pub fn set_rect<R: Runtime>(&mut self, _: &WebviewWindow<R>, _: Option<&Mpv>, _: Option<(i32, i32, i32, i32)>) {}
}
/// Not needed yet: the only GPU-specific tier (RTX Video) is Windows-only.
pub fn gpu_names() -> Vec<String> {
Vec::new()
}
pub fn hold_awake(rx: std::sync::mpsc::Receiver<()>) {
// TODO(macOS): IOPMAssertionCreateWithName(PreventUserIdleDisplaySleep).
let _ = rx.recv();

View file

@ -6,6 +6,7 @@
//! - `SURFACE_PROPERTIES`: mpv properties the surface observes.
//! - `MPV_LIBRARIES`: libmpv file names to look for.
//! - `hold_awake`: prevents display sleep until the receiver closes.
//! - `gpu_names`: the graphics adapters, by name.
#[cfg(target_os = "windows")]
mod windows;

View file

@ -142,6 +142,29 @@ pub const SURFACE_PROPERTIES: &[&str] = &["display-swapchain"];
pub const MPV_LIBRARIES: &[&str] = &["libmpv-2.dll", "mpv-2.dll"];
/// Keeps the display awake until `rx` closes or receives.
/// Hardware graphics adapters as DXGI names them (e.g. "NVIDIA GeForce RTX 4080").
pub fn gpu_names() -> Vec<String> {
use ::windows::Win32::Graphics::Dxgi::*;
let mut names = Vec::new();
unsafe {
let Ok(factory) = CreateDXGIFactory1::<IDXGIFactory1>() else { return names };
let mut i = 0;
while let Ok(adapter) = factory.EnumAdapters1(i) {
i += 1;
let Ok(desc) = adapter.GetDesc1() else { continue };
if desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE.0 as u32 != 0 {
continue;
}
let len = desc.Description.iter().position(|&c| c == 0).unwrap_or(desc.Description.len());
let name = String::from_utf16_lossy(&desc.Description[..len]);
if !names.contains(&name) {
names.push(name);
}
}
}
names
}
pub fn hold_awake(rx: std::sync::mpsc::Receiver<()>) {
use ::windows::Win32::System::Power::*;
unsafe {

View file

@ -44,6 +44,8 @@ pub struct AppInfo {
default_download_dir: String,
platform: String,
device_name: String,
/// Graphics adapters by name (decides which upscaling tiers are offered).
gpus: Vec<String>,
}
#[tauri::command]
@ -62,6 +64,7 @@ pub fn app_info<R: Runtime>(app: AppHandle<R>) -> AppInfo {
default_download_dir: downloads,
platform: std::env::consts::OS.to_string(),
device_name: std::env::var("COMPUTERNAME").unwrap_or_else(|_| "Windows PC".into()),
gpus: crate::platform::gpu_names(),
}
}