weirdnet-audio-stream
General-purpose audio streaming for Weirdnet: publish and subscribe to live or recorded streams of codec-agnostic frames, many listeners with their own bounded queues, seeking, arrival statistics and per-subscription authorisation.
Part of Weirdnet by Weird Brains. BSD-3-Clause.
What it does
- Publish and subscribe: a
Publishersends frames of one stream to any number of listeners, in process or over the network.sendnever blocks; each listener has its own bounded queue with an overflow policy (drop oldest, skip to the next key frame, or disconnect), so a slow listener never slows the others. - Live and recorded: a late live listener starts at the next key frame; a recorded stream (
Recordinginto aMemorySource) plays from the start or from a position, starting at the key frame at or before it. - Codec-agnostic: frames carry bytes, a timestamp in ticks of the stream's clock and a key flag; the stream names its codec and decoder parameters. Raw PCM works with no codec (
StreamInfo::pcm_f32,Frame::pcm_f32). Streams and frames carry optional opaque app metadata the crate never reads. - Over Weirdnet:
net::serveoffers aHubof streams on a weirdnet-net node, asking aStreamAuthabout each subscription;net::Subscriberconnects to one and keepsStats(frames, loss, relative arrival delay, jitter). - Clocks:
clock::serve_clockandclock::measurefind another node's clock offset (the exchange with the shortest round trip wins);clock::DriftFitfits offsets over time for the offset at any moment and the drift in ppm. - Remote routing (feature
route):remote::RemoteExecutoris a weirdnet-audio-route executor for the connections between a weirdnet-audio-engine router and other nodes. A sent port feeds a router tap streamed as raw PCM; a received port is subscribed, resampled to the router's rate, held at a playout level (40 ms by default) with a trim that follows the sender's audio clock, and routed in with the connection's gain. Withalign_msevery received link aims at one whole delay, so audio made at the same moment on different nodes lines up. Each link reports its state (a refused subscription isDenied), transit time, buffer, whole delay, clock offset, drift and trim.
The wire format is a length-prefixed message per frame on one weirdnet-net stream (see the wire module).