Skip to main content

Crate shairplay

Crate shairplay 

Source
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 (implies ap2)

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§

AirPlayServiceInfo
mDNS service information for AirPlay network discovery.
AudioFormat
Audio format descriptor passed to AudioHandler::audio_init.
BindConfig
Controls how the server binds to network addresses.
RaopServer
The main AirPlay/RAOP server.
RaopServerBuilder
Builder for RaopServer.
TrackMetadata
Parsed track metadata from DMAP.

Enums§

AudioCodec
Audio codec type.
RemoteCommand
Playback command to send to the source device.

Traits§

AudioHandler
Trait for receiving AirPlay events and creating audio sessions.
AudioSession
Per-connection audio session — hot path only.
RemoteControl
Unified remote control interface for AP1 (DACP) and AP2 (MediaRemote).