weirdnet-audio-stream 0.2.0

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.
Documentation

weirdnet-audio-stream

crates.io docs.rs

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 Publisher sends frames of one stream to any number of listeners, in process or over the network. send never 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 (Recording into a MemorySource) 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::serve offers a Hub of streams on a weirdnet-net node, asking a StreamAuth about each subscription; net::Subscriber connects to one and keeps Stats (frames, loss, relative arrival delay, jitter).
  • Clocks: clock::serve_clock and clock::measure find another node's clock offset (the exchange with the shortest round trip wins); clock::DriftFit fits offsets over time for the offset at any moment and the drift in ppm.
  • Remote routing (feature route): remote::RemoteExecutor is 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. Each link reports its state (a refused subscription is Denied), transit time, buffer, whole delay, clock offset, drift and trim.
cargo run --example tone

The wire format is a length-prefixed message per frame on one weirdnet-net stream (see the wire module).