Files
qbz/third-party/rupnp/examples/search_and_action.rs
T
vicrodh 3aed91fa0a fix(cast): localize UPnP URL compatibility and harden crash diagnostics
Keep http 1.5 and tolerate empty or relative service URLs in a local rupnp patch. Cover standard DLNA SOAP requests and malformed descriptions.

Avoid logger locks in fatal handlers, flush emitted log batches, and preserve CI symbols after smoke failures.

cx
2026-09-08 12:08:53 -06:00

28 lines
948 B
Rust

use futures::prelude::*;
use rupnp::ssdp::{SearchTarget, URN};
use std::time::Duration;
const RENDERING_CONTROL: URN = URN::service("schemas-upnp-org", "RenderingControl", 1);
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let search_target = SearchTarget::URN(RENDERING_CONTROL);
let devices = rupnp::discover(&search_target, Duration::from_secs(3), None).await?;
let mut devices = std::pin::pin!(devices);
while let Some(device) = devices.try_next().await? {
let service = device
.find_service(&RENDERING_CONTROL)
.expect("searched for RenderingControl, got something else");
let args = "<InstanceID>0</InstanceID><Channel>Master</Channel>";
let response = service.action(device.url(), "GetVolume", args).await?;
let volume = response.get("CurrentVolume").unwrap();
println!("'{}' is at volume {}", device.friendly_name(), volume);
}
Ok(())
}