chore(cast): remove AirPlay subsystem (dead code)

AirPlay was scaffolded in both crates/qbz-cast/src/airplay and
src-tauri/src/cast/airplay but never worked at runtime: the RAOP
sender required an Apple MFi-licensed stack with no free/open
alternative, and the backend state was already disabled via the
commented `.manage(airplay_state)` line in src-tauri/src/lib.rs.
The CastPicker UI already hid the AirPlay tab pending streaming
support that was never going to ship.

Delete:
- crates/qbz-cast/src/airplay/        (entire directory)
- src-tauri/src/cast/airplay/         (entire directory)
- 10x v2_airplay_* commands from commands_v2/library.rs + their
  tauri::generate_handler entries
- AirPlayError from qbz-cast errors
- 'airplay' from CastProtocol + every case arm in castStore.ts,
  CastPicker.svelte, AudioOutputBadges.svelte
- Corresponding i18n keys if present

Zero behavior change for Chromecast / DLNA / QConnect / MPRIS. If
AirPlay ever becomes feasible we'll revisit from scratch with a
real streaming backend.

cc
This commit is contained in:
vicrodh committed 2026-04-16 19:04:56 -06:00
1 parent 27ab2c8bea
commit edededcf8c
18 files changed
+17 -658

No files matched your search

-88
View File
@@ -1,88 +0,0 @@
//! AirPlay device connection and streaming (placeholder)
use serde::{Deserialize, Serialize};
use crate::airplay::DiscoveredAirPlayDevice;
use crate::AirPlayError;
/// Metadata for AirPlay playback
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AirPlayMetadata {
pub title: String,
pub artist: String,
pub album: String,
pub artwork_url: Option<String>,
pub duration_secs: Option<u64>,
}
/// AirPlay device status (minimal for now)
#[derive(Debug, Clone, Serialize)]
pub struct AirPlayStatus {
pub device_id: String,
pub device_name: String,
pub is_connected: bool,
}
/// AirPlay connection stub (RAOP sender integration pending)
pub struct AirPlayConnection {
device: DiscoveredAirPlayDevice,
connected: bool,
}
impl AirPlayConnection {
/// Connect to an AirPlay device
pub fn connect(device: DiscoveredAirPlayDevice) -> Result<Self, AirPlayError> {
Ok(Self {
device,
connected: true,
})
}
/// Disconnect from the device
pub fn disconnect(&mut self) -> Result<(), AirPlayError> {
self.connected = false;
Ok(())
}
/// Current connection status
pub fn get_status(&self) -> AirPlayStatus {
AirPlayStatus {
device_id: self.device.id.clone(),
device_name: self.device.name.clone(),
is_connected: self.connected,
}
}
/// Load media (requires RAOP sender integration)
pub fn load_media(&mut self, _metadata: AirPlayMetadata) -> Result<(), AirPlayError> {
Err(AirPlayError::NotImplemented(
"RAOP sender integration not implemented".to_string(),
))
}
/// Play/pause/stop controls
pub fn play(&mut self) -> Result<(), AirPlayError> {
Err(AirPlayError::NotImplemented(
"RAOP sender integration not implemented".to_string(),
))
}
pub fn pause(&mut self) -> Result<(), AirPlayError> {
Err(AirPlayError::NotImplemented(
"RAOP sender integration not implemented".to_string(),
))
}
pub fn stop(&mut self) -> Result<(), AirPlayError> {
Err(AirPlayError::NotImplemented(
"RAOP sender integration not implemented".to_string(),
))
}
/// Volume control (0.0 - 1.0)
pub fn set_volume(&mut self, _volume: f32) -> Result<(), AirPlayError> {
Err(AirPlayError::NotImplemented(
"RAOP sender integration not implemented".to_string(),
))
}
}
-216
View File
@@ -1,216 +0,0 @@
//! AirPlay device discovery via mDNS
use std::collections::HashMap;
use std::net::IpAddr;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
use std::thread::{self, JoinHandle};
use mdns_sd::{ServiceDaemon, ServiceEvent};
use serde::Serialize;
use crate::AirPlayError;
const SERVICE_RAOP: &str = "_raop._tcp.local.";
const SERVICE_AIRPLAY: &str = "_airplay._tcp.local.";
/// Discovered AirPlay device
#[derive(Debug, Clone, Serialize)]
pub struct DiscoveredAirPlayDevice {
pub id: String,
pub name: String,
pub model: String,
pub ip: String,
pub port: u16,
pub service: String,
pub requires_password: bool,
}
#[derive(Default)]
struct DiscoveryState {
devices: HashMap<String, DiscoveredAirPlayDevice>,
fullname_to_id: HashMap<String, String>,
}
/// Discovery manager for AirPlay devices
pub struct AirPlayDiscovery {
state: Arc<Mutex<DiscoveryState>>,
running: Arc<AtomicBool>,
handles: Vec<JoinHandle<()>>,
daemon: Option<ServiceDaemon>,
}
impl AirPlayDiscovery {
pub fn new() -> Self {
Self {
state: Arc::new(Mutex::new(DiscoveryState::default())),
running: Arc::new(AtomicBool::new(false)),
handles: Vec::new(),
daemon: None,
}
}
/// Start mDNS discovery in background
pub fn start_discovery(&mut self) -> Result<(), AirPlayError> {
if self.running.load(Ordering::SeqCst) {
return Ok(());
}
let mdns = ServiceDaemon::new()
.map_err(|e| AirPlayError::Discovery(format!("Failed to create mDNS daemon: {}", e)))?;
let raop_rx = mdns.browse(SERVICE_RAOP).map_err(|e| {
AirPlayError::Discovery(format!("Failed to browse RAOP services: {}", e))
})?;
let airplay_rx = mdns.browse(SERVICE_AIRPLAY).map_err(|e| {
AirPlayError::Discovery(format!("Failed to browse AirPlay services: {}", e))
})?;
self.running.store(true, Ordering::SeqCst);
let state = self.state.clone();
let running = self.running.clone();
self.handles.push(spawn_receiver(
"raop",
raop_rx,
state.clone(),
running.clone(),
));
self.handles
.push(spawn_receiver("airplay", airplay_rx, state, running));
self.daemon = Some(mdns);
Ok(())
}
/// Stop discovery and release resources
pub fn stop_discovery(&mut self) -> Result<(), AirPlayError> {
self.running.store(false, Ordering::SeqCst);
if let Some(daemon) = self.daemon.take() {
daemon
.shutdown()
.map_err(|e| AirPlayError::Discovery(format!("Failed to shutdown mDNS: {}", e)))?;
}
for handle in self.handles.drain(..) {
let _ = handle.join();
}
Ok(())
}
/// Return list of discovered devices
pub fn get_discovered_devices(&self) -> Vec<DiscoveredAirPlayDevice> {
self.state
.lock()
.map(|state| state.devices.values().cloned().collect())
.unwrap_or_default()
}
/// Get a specific device by ID
pub fn get_device(&self, device_id: &str) -> Option<DiscoveredAirPlayDevice> {
self.state
.lock()
.ok()
.and_then(|state| state.devices.get(device_id).cloned())
}
}
impl Default for AirPlayDiscovery {
fn default() -> Self {
Self::new()
}
}
fn spawn_receiver(
service_label: &'static str,
receiver: mdns_sd::Receiver<ServiceEvent>,
state: Arc<Mutex<DiscoveryState>>,
running: Arc<AtomicBool>,
) -> JoinHandle<()> {
thread::spawn(move || {
for event in receiver.iter() {
if !running.load(Ordering::SeqCst) {
break;
}
match event {
ServiceEvent::ServiceResolved(info) => {
let fullname = info.get_fullname().to_string();
let id = device_id_from_info(&fullname, &info);
let name = device_name_from_info(&fullname, &info, &id);
let model = info
.get_property_val_str("am")
.or_else(|| info.get_property_val_str("model"))
.unwrap_or("Unknown")
.to_string();
let requires_password = parse_password_required(&info);
let ip =
pick_ip(info.get_addresses()).unwrap_or_else(|| "127.0.0.1".to_string());
let device = DiscoveredAirPlayDevice {
id: id.clone(),
name,
model,
ip,
port: info.get_port(),
service: service_label.to_string(),
requires_password,
};
let key = format!("{}|{}", service_label, fullname);
if let Ok(mut state) = state.lock() {
state.fullname_to_id.insert(key, id.clone());
state.devices.insert(id, device);
}
}
ServiceEvent::ServiceRemoved(_, fullname) => {
let key = format!("{}|{}", service_label, fullname);
if let Ok(mut state) = state.lock() {
if let Some(id) = state.fullname_to_id.remove(&key) {
state.devices.remove(&id);
}
}
}
_ => {}
}
}
})
}
fn device_id_from_info(fullname: &str, info: &mdns_sd::ServiceInfo) -> String {
if let Some(id) = info.get_property_val_str("deviceid") {
return id.to_string();
}
if let Some(id) = info.get_property_val_str("id") {
return id.to_string();
}
if let Some((prefix, _)) = fullname.split_once('@') {
return prefix.to_string();
}
fullname.to_string()
}
fn device_name_from_info(fullname: &str, info: &mdns_sd::ServiceInfo, fallback: &str) -> String {
if let Some(name) = info.get_property_val_str("fn") {
return name.to_string();
}
if let Some((_, name)) = fullname.split_once('@') {
return name.to_string();
}
fallback.to_string()
}
fn parse_password_required(info: &mdns_sd::ServiceInfo) -> bool {
match info.get_property_val_str("pw") {
Some(value) => matches!(value, "1" | "true" | "yes" | "on"),
None => false,
}
}
fn pick_ip(addresses: &std::collections::HashSet<IpAddr>) -> Option<String> {
let ipv4 = addresses.iter().find(|addr| addr.is_ipv4());
let ip = ipv4.or_else(|| addresses.iter().next())?;
Some(ip.to_string())
}
-8
View File
@@ -1,8 +0,0 @@
//! AirPlay casting module (discovery + scaffolding)
pub mod device;
pub mod discovery;
pub use crate::AirPlayError;
pub use device::{AirPlayConnection, AirPlayMetadata, AirPlayStatus};
pub use discovery::{AirPlayDiscovery, DiscoveredAirPlayDevice};
-22
View File
@@ -30,28 +30,6 @@ pub enum CastError {
InvalidRequest(String),
}
/// AirPlay casting errors
#[derive(Error, Debug)]
pub enum AirPlayError {
#[error("Discovery error: {0}")]
Discovery(String),
#[error("Connection error: {0}")]
Connection(String),
#[error("Playback error: {0}")]
Playback(String),
#[error("Not connected")]
NotConnected,
#[error("Device not found: {0}")]
DeviceNotFound(String),
#[error("Not implemented: {0}")]
NotImplemented(String),
}
/// DLNA/UPnP casting errors
#[derive(Error, Debug)]
pub enum DlnaError {
+2 -10
View File
@@ -1,6 +1,6 @@
//! qbz-cast - Casting support for QBZ
//!
//! Provides casting capabilities for Chromecast, AirPlay (scaffolded), and DLNA devices.
//! Provides casting capabilities for Chromecast and DLNA devices.
//! This crate is Tauri-agnostic and can be used by any Rust application.
//!
//! # Architecture
@@ -8,21 +8,18 @@
//! - **Chromecast**: Full implementation using rust-cast. Uses a dedicated thread
//! for connection management due to rust-cast's use of Rc (not thread-safe).
//!
//! - **AirPlay**: Discovery implemented, playback scaffolded (RAOP sender integration pending).
//!
//! - **DLNA/UPnP**: Full implementation using rupnp for AVTransport/RenderingControl.
//!
//! - **MediaServer**: Local HTTP server for streaming audio to cast devices.
//! Supports byte-range requests for seeking.
pub mod airplay;
pub mod chromecast;
pub mod dlna;
pub mod errors;
pub mod media_server;
// Re-export error types at root
pub use errors::{AirPlayError, CastError, DlnaError};
pub use errors::{CastError, DlnaError};
// Re-export media server
pub use media_server::MediaServer;
@@ -33,11 +30,6 @@ pub use chromecast::{
ChromecastHandle, DeviceDiscovery, DiscoveredDevice, MediaMetadata,
};
// Re-export AirPlay types
pub use airplay::{
AirPlayConnection, AirPlayDiscovery, AirPlayMetadata, AirPlayStatus, DiscoveredAirPlayDevice,
};
// Re-export DLNA types
pub use dlna::{
DiscoveredDlnaDevice, DlnaConnection, DlnaDiscovery, DlnaMetadata, DlnaPositionInfo, DlnaStatus,