Add StreamingFlacSink for multi-client HTTP streaming

Implements a new sink for broadcasting FLAC audio to multiple concurrent
HTTP clients (UPnP renderers, web players, etc.) with dynamic metadata updates.

Key features:
- Lazy encoder initialization (auto-detects sample rate from first chunk)
- Broadcast architecture: one encoder, multiple concurrent clients
- Dual streaming modes:
  * Pure FLAC mode (standard HTTP streaming)
  * ICY metadata mode (Icecast/Shoutcast protocol with "Now Playing")
- Automatic lifecycle management (starts on first client, stops when last disconnects)
- Full metadata support via TrackBoundary sync markers

Architecture:
  AudioSegments → PCM conversion → FLAC encoder → Broadcaster task
                                                        ↓
                                              broadcast::channel
                                                        ↓
                                     Multiple clients (FlacClientStream/IcyClientStream)

New components:
- StreamingFlacSink: Terminal sink node for audio pipeline
- StreamHandle: Clonable handle for HTTP handlers to subscribe clients
- FlacClientStream: Pure FLAC AsyncRead implementation
- IcyClientStream: ICY-wrapped FLAC with metadata injection
- MetadataSnapshot: Serializable metadata for SSE/JSON endpoints

Feature: http-stream (requires pmoflac, pmometadata, bytes, serde)
This commit is contained in:
Claude
2025-11-11 19:27:39 +00:00
parent 419bc35a46
commit b25a4f9fb3
4 changed files with 928 additions and 1 deletions

2
Cargo.lock generated
View File

@@ -2867,6 +2867,7 @@ name = "pmoaudio-ext"
version = "0.1.0"
dependencies = [
"async-trait",
"bytes",
"pmoaudio",
"pmoaudiocache",
"pmocache",
@@ -2874,6 +2875,7 @@ dependencies = [
"pmoflac",
"pmometadata",
"pmoplaylist",
"serde",
"tokio",
"tokio-util",
"tracing",