Expand description
Snapcast server library — embeddable synchronized multiroom audio server.
See also: snapcast-client for the client library.
§Architecture
The server is built around a channel-based API matching snapcast-client:
SnapServeris the main entry pointServerEventflows from server → consumer (client connected, stream status, custom messages)ServerCommandflows from consumer → server (typed mutations, custom messages, stop)
§Example
use snapcast_server::{SnapServer, ServerConfig, ServerEvent, ServerCommand};
let config = ServerConfig::default();
let (mut server, mut events, _audio_tx) = SnapServer::new(config);
let cmd = server.command_sender();
tokio::spawn(async move {
while let Some(event) = events.recv().await {
match event {
ServerEvent::ClientConnected { id, name } => {
tracing::info!(id, name, "Client connected");
}
_ => {}
}
}
});
server.run().await?;Modules§
- auth
- Streaming client authentication.
- encoder
- Audio encoders — PCM, FLAC, Opus, Vorbis.
- mdns
- mDNS service advertisement.
- session
- Client session management — binary protocol server for snapclients.
- state
- Server state model — clients, groups, streams with JSON persistence.
- stream
- Stream management — encoding and distribution.
- time
- Time utilities — server timestamp generation using monotonic clock.
Structs§
- Audio
Frame - Interleaved f32 audio frame for server input.
- Client
Settings Update - Settings update pushed to a streaming client via binary protocol.
- Sample
Format - Audio sample format: rate, bit depth, and channel count.
- Server
Config - Server configuration for the embeddable library.
- Snap
Server - The embeddable Snapcast server.
Enums§
- Server
Command - Commands the consumer sends to the server.
- Server
Event - Events emitted by the server to the consumer.
Constants§
- DEFAULT_
SAMPLE_ FORMAT - Default sample format: 48000 Hz, 16-bit, stereo.
- DEFAULT_
STREAM_ PORT - Default TCP port for binary protocol (streaming clients).