Expand description
Pure Rust AirPlay server library.
shairplay is a complete reimplementation of the shairplay
C library in safe Rust. It provides an AirPlay (RAOP) server that can receive audio streams
from Apple devices on the local network.
§Quick Start
use std::sync::Arc;
use shairplay::{RaopServer, AudioHandler, AudioSession, AudioFormat};
struct MyHandler;
impl AudioHandler for MyHandler {
fn audio_init(&self, format: AudioFormat) -> Box<dyn AudioSession> {
Box::new(MySession)
}
}
struct MySession;
impl AudioSession for MySession {
fn audio_process(&mut self, samples: &[f32]) {
// F32 interleaved PCM — same format for AP1 and AP2
}
}
let handler = Arc::new(MyHandler);
let mut server = RaopServer::builder()
.name("My Speaker")
.hwaddr([0x48, 0x5d, 0x60, 0x7c, 0xee, 0x22])
.port(5000)
.build(handler)?;
server.start().await?;
// Server is now discoverable via AirPlay on the local network§Architecture
- [
raop] — RAOP/AirPlay server, RTSP handlers, RTP streaming, audio buffering - [
crypto] — RSA, Ed25519/Curve25519 pairing, AES-CTR, FairPlay DRM, ChaCha20-Poly1305 - [
codec] — Audio decoders (ALAC, AAC) and resampling - [
proto] — SDP, HTTP/RTSP, binary plist, HTTP Digest auth - [
net] — Async TCP server (tokio), mDNS service registration, PTP timing error— Error types
§Feature Flags
ap2— AirPlay 2 support (SRP-6a pairing, buffered AAC, encrypted transport)video— Experimental screen mirroring (impliesap2)
Re-exports§
pub use error::ShairplayError;
Modules§
- dacp
- DACP (Digital Audio Control Protocol) client for remote-controlling Apple devices.
- error
- Error types for the shairplay library.
Structs§
- AirPlay
Service Info - mDNS service information for AirPlay network discovery.
- Audio
Format - Audio format descriptor passed to
AudioHandler::audio_init. - Bind
Config - Controls how the server binds to network addresses.
- Raop
Server - The main AirPlay/RAOP server.
- Raop
Server Builder - Builder for
RaopServer. - Track
Metadata - Parsed track metadata from DMAP.
Enums§
- Audio
Codec - Audio codec type.
- Remote
Command - Playback command to send to the source device.
Traits§
- Audio
Handler - Trait for receiving AirPlay events and creating audio sessions.
- Audio
Session - Per-connection audio session — hot path only.
- Remote
Control - Unified remote control interface for AP1 (DACP) and AP2 (MediaRemote).