A pure-Elixir snapcast server: speak snapcast's binary protocol directly to snapclients, owning the audio clock and timestamping every chunk, so there is no external snapserver and no ffmpeg/snapserver pacing to fight.
Public entry points + the stream format. The server currently uses PCM as the
compatibility transport while encoded Snap transport (opus/flac) is developed
behind an explicit per-play/3 :transport_codec option.
Configuration
Settings are read from the :snapcast application environment, e.g.:
config :snapcast,
enabled: true,
port: 1704,
bind_ip: {0, 0, 0, 0},
format: {48_000, 16, 2},
listener: MyApp.SnapcastListenerformat is the default PCM output format {sample_rate, bits_per_sample, channels}. play/3 can override it with a per-stream :format.
Supervision
Add Snapcast.children() to your supervision tree; it returns the server
subtree when enabled: true, or [] otherwise.
Lifecycle events
Configure a Snapcast.Listener (via :listener) to receive client
connect/disconnect and playback progress/ended notifications.
Summary
Functions
Whether to advertise the server over mDNS/DNS-SD.
mDNS service name advertised for the server.
TCP address to bind the server to.
End-to-end buffer (ms): clients play each chunk this long after its timestamp.
The server's supervision subtree, gated by enabled?/0.
Chunk duration in milliseconds.
List connected clients.
Path to the DNS-SD publisher executable, if available.
Whether the server is started in the supervision tree.
Path to the ffmpeg executable used to decode sources to PCM.
FLAC compression level used by ffmpeg for Snapcast FLAC transport.
Default PCM stream format {rate, bits, channels}.
The configured Snapcast.Listener module, if any.
Whether to supervise a local snapclient for this machine.
Stable host id for the supervised local snapclient.
snapclient log filter used by the supervised local client.
URL used by the supervised local snapclient.
Normalize a PCM format to {sample_rate, bits_per_sample, channels}.
Normalize a transport codec name to :pcm | :opus | :flac (or nil).
Default bitrate used when transcoding speech/long-form sources to Opus.
Play a source to the given client ids.
TCP port to listen on (snapclients default to 1704).
Path to the local snapclient executable, if available.
Stop the current stream.
Functions
Whether to advertise the server over mDNS/DNS-SD.
mDNS service name advertised for the server.
TCP address to bind the server to.
End-to-end buffer (ms): clients play each chunk this long after its timestamp.
The server's supervision subtree, gated by enabled?/0.
Returns the SessionSupervisor + Server (plus the mDNS advertiser and a local
snapclient when configured), or [] when not enabled.
Chunk duration in milliseconds.
List connected clients.
Path to the DNS-SD publisher executable, if available.
Whether the server is started in the supervision tree.
Path to the ffmpeg executable used to decode sources to PCM.
FLAC compression level used by ffmpeg for Snapcast FLAC transport.
Default PCM stream format {rate, bits, channels}.
The configured Snapcast.Listener module, if any.
Whether to supervise a local snapclient for this machine.
Stable host id for the supervised local snapclient.
snapclient log filter used by the supervised local client.
URL used by the supervised local snapclient.
Normalize a PCM format to {sample_rate, bits_per_sample, channels}.
Normalize a transport codec name to :pcm | :opus | :flac (or nil).
Default bitrate used when transcoding speech/long-form sources to Opus.
Play a source to the given client ids.
source is either a binary path/URL (decoded by ffmpeg) or a 0-arity function
returning one, resolved lazily when the stream starts (e.g. for short-lived URLs).
opts: :position_ms, :endpoint (opaque term echoed back in listener events),
:duration_ms, :transport_codec, :format.
TCP port to listen on (snapclients default to 1704).
Path to the local snapclient executable, if available.
Stop the current stream.