Skip to main content

Crate snapcast_server

Crate snapcast_server 

Source
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:

  • SnapServer is the main entry point
  • ServerEvent flows from server → consumer (client connected, stream status, custom messages)
  • ServerCommand flows 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) = SnapServer::new(config);
let _audio_tx = server.add_stream("default");
let cmd = server.command_sender();

tokio::spawn(async move {
    while let Some(event) = events.recv().await {
        match event {
            ServerEvent::ClientConnected { id, ref hello } => {
                tracing::info!(id, name = hello.host_name, "Client connected");
            }
            _ => {}
        }
    }
});

server.run().await?;

Modules§

auth
Streaming client authentication.
status
Re-exported from snapcast_proto::status.
time
Time utilities — server timestamp generation using monotonic clock.

Structs§

AudioFrame
A timestamped audio frame for server input.
ClientSettingsUpdate
Settings update pushed to a streaming client via binary protocol.
CustomMessage
Custom message for application-defined protocol extensions (type 9+).
F32AudioSender
Buffered sender for F32 audio that handles chunking, timestamping, and gap detection.
Hello
Hello message JSON payload.
SampleFormat
Audio sample format: rate, bit depth, and channel count.
ServerConfig
Server configuration for the embeddable library.
SnapServer
The embeddable Snapcast server.
StreamConfig
Per-stream configuration. If None, inherits from ServerConfig.
WireChunkData
An encoded audio chunk ready to be sent to clients.

Enums§

AudioData
Audio data pushed by the consumer — either f32 or raw PCM.
ServerCommand
Commands the consumer sends to the server.
ServerEvent
Events emitted by the server to the consumer.

Constants§

DEFAULT_ENCRYPTION_PSK
Default pre-shared key for f32lz4e (encrypted f32lz4) codec.
DEFAULT_SAMPLE_FORMAT
Default sample format: 48000 Hz, 16-bit, stereo.
DEFAULT_STREAM_PORT
Default TCP port for binary protocol (streaming clients).