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, _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§

AudioFrame
Interleaved f32 audio frame for server input.
ClientSettingsUpdate
Settings update pushed to a streaming client via binary protocol.
SampleFormat
Audio sample format: rate, bit depth, and channel count.
ServerConfig
Server configuration for the embeddable library.
SnapServer
The embeddable Snapcast server.

Enums§

ServerCommand
Commands the consumer sends to the server.
ServerEvent
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).