Repository navigation
This release completes the full labstream feature roadmap (steps 0 to 18) while
keeping wire compatibility with liblsl. Highlights include dropout-free resume/1
and disk store-and-forward, UDP datagrams (dgram/1), shared memory (shm/1),
lossless wire compression (comp/1), channel and rate selection (select/1),
live metadata (meta/1), opt-in transport encryption (enc/1), opt-in drift
clock and device-delay calibration, browser reach (WebSocket and WebAssembly),
CLI tools (doctor, top, play, relay, calibrate), and real-time
multi-stream sync (SyncGroup).
Added
- Seven standalone interactive demos under
demos/(demos/README.md) with
browser dashboards and PNG export:demo1_dropout(Wi-Fi dropout recovery
against C++ liblsl with CRC32 proof),demo2_hypersync(SyncGroup
phase-lock),demo3_bandwidth(comp/1+select/1),demo4_shm_ipc
(cross-processshm/1vs TCP loopback),demo5_browser_meta(labstream-wasmWsBridge+ livemeta/1),demo6_encryption(enc/1live TCP wire
sniffer), anddemo7_multimodal_sync(multi-modalSyncGroupfusion with
gap_mask).
- Real-time multi-stream sync and resampler (
docs/roadmap.md, step 18):
labstream_time::sync::StreamAlignerandlabstream_net::SyncGroup
(re-exported aslabstream::SyncGroup) alignNasynchronous numeric
inlets onto one strictly monotonic common time grid using Blackman-windowed
sinc fractional-delay interpolation with bounded lookahead and bounded
per-stream buffers, automatic opt-inCLOCKSYNC | DRIFT | DEVICE_DELAY, and
explicit per-stream gap bitmasks (AlignedSample::gap_mask). Adds C
functionslabstream_sync_create,labstream_sync_total_channels,
labstream_sync_pull, andlabstream_sync_destroy. - Opt-in negotiated transport encryption via
enc/1(docs/roadmap.md, step
14,docs/extensions.md, sectionenc): off by default, enabled via
labstream.Features(enc),labstream.RequireEncryption = 1, or
labstream::enc::set_runtime_policy/labstream_set_encryption. Uses the
reviewedringcrate (gated behind Cargo featureencryption) for
ephemeral X25519 key exchange (RFC 7748), HKDF-SHA256 (RFC 5869) with
optional pre-shared key (labstream.EncryptionKey), and length-prefixed
ChaCha20-Poly1305 AEAD framing (RFC 8439). AddsInlet::is_encrypted,
InletHealth::encrypted,labstream_inlet_encrypted, and
labstream_set_encryption, verified bycrates/labstream-net/tests/enc_live.rs. - Browser reach via opt-in WebSocket bridge and WebAssembly decoder
(docs/roadmap.md, step 13):labstream_net::ws::WsBridge(re-exported in
labstream::ws) andlabstream relay(--ws-port,--ws-bind,
--ws-allow,--ws-marker-stream) expose a zero-dependency RFC 6455
WebSocket endpoint (off by default, loopback-only unless configured) that
forwards exact LSL wire samples in binary frames and publishes browser
markers onto live LSL marker outlets.crates/labstream-wasmcompiles
labstream-wiretowasm32-unknown-unknownwithweb/labstream.jsand
web/index.html, andlabstream-capiaddslabstream_ws_bridge_start,
labstream_ws_bridge_port, andlabstream_ws_bridge_stop. - In-band live metadata via
meta/1(docs/roadmap.md, step 16,
docs/extensions.md, sectionmeta):labstream_proto::metaadds the
0xFCrecord (seq,timestamp,key,value) on the TCP feed channel
across TCP,dgram/1, andshm/1transports while leaving liblsl inlets
unchanged. AddsOutlet::{push_metadata, push_metadata_at, metadata},
Inlet::{has_live_metadata, pull_metadata, metadata}, and C functions
labstream_outlet_push_metadata,labstream_inlet_has_live_metadata,
labstream_inlet_metadata_count, andlabstream_inlet_pull_metadata. - Opt-in linear offset-and-drift clock model (
docs/roadmap.md, step 17):
labstream_time::DriftModelandDriftFitfit a 64-burst RTT-weighted line
with Huber outlier down-weighting from each time-sync burst midpoint.
flags::DRIFT(16,Post::DRIFT,LABSTREAM_POST_DRIFT) removes the 2 s
burst step while defaultflags::CLOCKSYNCstays bit-exact with liblsl.
AddsInlet::clock_drift,Inlet::smooth_time_correction,
InletHealth::clock_drift,labstream_inlet_clock_drift, and
labstream_inlet_smooth_time_correction. - Device-delay calibration (
docs/roadmap.md, step 15):
labstream_net::calibrate(re-exported inlabstream::calibrate) and
labstream calibrate(crates/labstream-cli) measure fixed device delay
against a reference marker or trigger stream via sub-sample edge
interpolation.StreamInfo::set_device_delayandStreamInfo::device_delay
store and read<desc><synchronization><offset_mean>(XDF-retained). Opt-in
flags::DEVICE_DELAY(32,Post::DEVICE_DELAY,
LABSTREAM_POST_DEVICE_DELAY) subtracts the delay on the inlet, with C
functionslabstream_streaminfo_set_device_delay,
labstream_streaminfo_device_delay,labstream_inlet_set_device_delay, and
labstream_inlet_device_delay. - Lossless wire compression via
comp/1(docs/roadmap.md, step 7,
docs/extensions.md, sectioncomp):labstream_proto::comp(CompState,
DgramCompEncoder,decode_dgram_payload) applies bit-exact channel deltas
(with an order-preserving IEEE-754 bijection for floats), ZigZag folding, and
adaptive LSB-first Golomb-Rice codes over TCP (0xF9/0xFAwith
zero-overhead plain fallback) and self-contained UDPDATA_COMP(type5)
datagrams. AddsInlet::is_compressedandInlet::compression_ratio
(labstream-netandlabstream),InletHealth::{compressed, compression_ratio},labstream_inlet_compressedand
labstream_inlet_compression_ratio(labstream-capi), live tests
(crates/labstream-net/tests/comp_live.rs),comp-reportEEG benchmark, and
the 1 Mbit/s netns and 4000 Hz CPU test (conformance/oracle/comp_test.py). - Same-machine shared-memory transport via
shm/1(docs/roadmap.md, step 9,
docs/extensions.md, sectionshm):ShmParamnegotiation in
labstream-proto, owner-only lock-free seqlock SPSC ring in
labstream-net(shm.rs, Linuxshm_open/SYS_futexwith predictive
pre-wake, macOS POSIX shm, WindowsCreateFileMappingW/CreateEventW),
zero-hopFanoutwrites and zero-allocationOutlet::push_numeric_raw,
Outlet::push_chunk_numeric_raw, andInlet::pull_numeric_intopaths,
Inlet::on_shm(labstream-net,labstream),InletHealth::on_shm(shown
asSHMinlabstream top), andlabstream_inlet_on_shmin
labstream-capi. At 4000 Hz x 64 channels, chunk 1,oracle/latency.py
measures 1 us p50 latency and 15.0 % total CPU (down from ~38 % baseline and
51.5 % liblsl). Verified withcrates/labstream-net/tests/shm_live.rsand
conformance/oracle/shm_container_test.py(isolated/dev/shmTCP fallback). - Channel and rate selection via
select/1(docs/roadmap.md, step 6,
docs/extensions.md, sectionselect):SelectParam,fir_taps,
project_packed, andStreamSelectorinlabstream-proto(bit-exact
channel projection and named Hamming-windowed sinc low-pass FIR decimator),
StreamInfo::apply_selection,Inlet::open_selected, and
Inlet::selectioninlabstream-net,InletBuilder::{channels, decimate, rate}inlabstream, andlabstream_create_inlet_selectedin
labstream-capi. Verified with unit tests, live tests in
crates/labstream-net/tests/select_live.rs, and the 1 Mbit/s netns test
conformance/oracle/select_test.py(4000 Hz x 64 ch to 250 Hz with 0 lost). - Local-to-network LSL stream relay (
docs/roadmap.md, step 4):
labstream_net::relay::{StreamRelay, RelayOptions, is_relayed, build_relayed_info}(re-exported inlabstream::relay), the
labstream relaycommand inlabstream-cli(with--disk-mbfor
store-and-forward), andlabstream_streaminfo_is_relayedin
labstream-capi. Verified with live tests in
crates/labstream-net/tests/relay_live.rs, CLI tests in
crates/labstream-cli/src/relay.rs, and the real liblsl oracle netns
cut testconformance/oracle/relay_test.py(0 lost across an 8 s cut). - Disk-backed store-and-forward for
resume/1(docs/roadmap.md, step 3).
Whenlabstream.ResumeDisk(in MiB, default 0) is above zero,History
spills oldest samples from RAM into bounded immutable segment files on
disk (optional directorylabstream.ResumeDiskPath, default system
temporary directory) while keeping RAM withinlabstream.ResumeMemory.
Fanout::read_history_packedreads disk segments outside theFanout
lock so resends do not delay live consumers. The outlet removes all spool
files and its temporary directory on drop. Outlet::new_with_limits,Outlet::history_ram_bytes, and
Outlet::history_disk_bytesinlabstream-net(plus RAM and disk byte
getters onlabstream::Outlet), and C functions
labstream_outlet_history_ram_bytesand
labstream_outlet_history_disk_bytesinlabstream-capi, with live tests
incrates/labstream-net/tests/store_and_forward_live.rs.- Flat typed chunk methods
push_chunk_{f32,f64,i32,i16,i8,i64}on
Outletandpull_chunk_{f32,f64,i32,i16,i8,i64}onInletin both
labstreamandlabstream-net(docs/roadmap.md, step 8). PackedSampleandPackedValuesinlabstream-wire, with
Codec::encode_packed,Codec::encode_packed_at, and
Codec::decode_packed. Numeric samples share oneArc<[u8]>payload
across consumer queues and theresumehistory with zero payload copies,
and cutresumehistory memory by 7.6x for 64-channelf32streams.- Fast
PackedSamplepaths acrossSampleQueue,Fanout,History,
dgram_out,dgram_in, and the numeric C ABI push and pull calls in
labstream-capi, with live tests in
crates/labstream-net/tests/flat_shared_live.rs. - The
seq/1feature between two labstream peers (docs/extensions.md). A
labstream inlet offers it in the request headerLabstream-Features, and
a labstream outlet answers it. liblsl ignores the header on both sides.
The outlet numbers its samples, and the inlet counts the samples that
never arrived: from a full outlet queue, and from a lost connection. Inlet::lostinlabstreamandInlet::samples_lostinlabstream-net.
The value isNonewhen the connection does not useseq/1.- The configuration key
labstream.Features. The value{}turns every
labstream feature off. labstream_proto::featuresandlabstream_proto::seq, with
FeedParams::to_wire_with,FeedClient::start_with,
FeedClient::featuresandAccepted::to_wire_with.SampleQueue::with_first_number,SampleQueue::pop_many_numberedand
Fanout::next_number.docs/latency.mdandconformance/oracle/latency.py, with
conformance/oracle/latency.c. They measure the time from a push to a pull,
and the CPU of each side, for liblsl and labstream.docs/extensions.md, a proposal for a feature header between two labstream
peers, with theseqandresumefeatures.conformance/oracle/headerprobe.py. It makes sure that the header changes
nothing else on an outlet, also with aresume/1parameter.docs/repository.md. It gives the layout of the repository, how the
workspace joins the crates, the daily commands, CI, and the dependency
updates.docs/releasing.md. It gives each step of a release to crates.io and to
GitHub, a test of the pipeline with no publish, the recovery for each
failure, a publish by hand, and a checklist.Outlet::push_samples, which sends a block with one timestamp for each
sample.SampleQueue::push_owned, which moves a block into a queue with no copy.ClockState::reset_offset,ClockState::retarget,ClockState::is_running,
andclock::FIRST_OFFSET_TIMEOUT.clock::FIRST_PROBE_INTERVALandclock::FIRST_RETRY.- The
resume/1feature between two labstream peers (docs/extensions.md,
sectionresume). After a lost connection, the outlet sends the samples
of the dropout again from a history, with their original timestamps.
A 3 s cut at 512 Hz x 8 channels, at 4000 Hz x 64 channels, or on a
marker stream loses no sample. The feature needsseq/1, and a liblsl
peer or an older labstream peer gives plain LSL. - The configuration keys
labstream.ResumeSeconds(default 30 s, 0 turns
the history off) andlabstream.ResumeMemory(default 64 MiB). The
default oflabstream.Featuresis now{seq, resume}. Inlet::resentinlabstream,Inlet::samples_resentin
labstream-net, andOutlet::history_leninlabstream-net.- Two C functions that liblsl does not have:
labstream_samples_lostand
labstream_samples_resent. Each returns -1 when the count is unknown. labstream_proto::features::{ResumeParam, ResumeRequest, offer_resume, resume_request, resume_answer},labstream_net::history,
Fanout::with_rate,Fanout::start_history,Fanout::read_history,
Fanout::add_resumable,SampleQueue::with_deducerand
SampleQueue::pop_many_full.docs/roadmap.md, the order of the labstream-only features.conformance/oracle/resumeprobe.py. It cuts the connection of an inlet
against outlets of each version.- The
dgram/1feature, on by default (docs/extensions.md, section
dgram). The default oflabstream.Featuresis now
{seq, resume, dgram}. Between two labstream peers, the samples go in
UDP datagrams with copies. The count of copies follows the loss that the
inlet measures, from 0 on a clean link to 8 at heavy loss. The inlet asks
for small gaps in feedback datagrams on UDP, and the outlet sends them
again on UDP. The TCP connection carries the resends of large gaps and
the path records. With 20 ms delay and 1 % loss, the p99 latency at
512 Hz drops from about 71 ms to about 22 ms, with no lost sample.
Inlet::on_udpshows the path. labstream_proto::dgram: the datagrams and records,Packer,
Reorder,CopyControl, andLossMeter.SampleQueue::wake, and
seq::Counter::resync.conformance/oracle/lossylink.py. It measures the latency over a slow,
lossy, or cut link between two network namespaces, with no root.
oracle/latency.chas new options--timeoutand--irregular. The
runner takes loads, markers, a configuration for each library, and rules
for heavy loss (also from the start of a run), a dead UDP path, and a UDP
path that comes back. A run whose inlet cannot connect gives the result
no connect.labstream_net::netifand cross-platform interface enumeration (getifaddrs
on Linux and macOS,GetIpAddrTableandGetIpNetTableon Windows).
Before, interface enumeration read/proc/net/fib_trieand returned no
interface on Windows and macOS.- Fallback discovery (
labstream.FallbackDiscovery = autoby default,
docs/discovery.md). When multicast wave 1 finds no stream, the resolver
tries directed subnet broadcast, ARP neighbor unicast, a local/24
unicast probe, and TCPLSL:shortinfoforlab.KnownPeers. All paths use
standard LSL packets and find bothlabstreamandliblsloutlets. labstream_net::doctor(re-exported aslabstream::doctor), the
labstream-clicrate (labstream doctor [--peer IP[,IP]] [--timeout S] [--json]), and the C functionlabstream_doctor_json.conformance/oracle/doctor_net.py. It blocks multicast, broadcast, and UDP
in two network namespaces against bothlabstreamandliblsloutlets.- Stream health API (
docs/health.md, roadmap step 11):Inlet::health,
Inlet::gaps,Inlet::take_gaps, andOutlet::healthin both
labstream-netandlabstream, withInletHealth,OutletHealth,
ConsumerHealth,Gap, andGapKind. - Four C functions in
labstream-capi:labstream_inlet_health,
labstream_inlet_gaps,labstream_inlet_take_gaps, and
labstream_outlet_consumers. - Loss-aware dejitter (roadmap step 2). On connections that negotiate
seq/1,
Inlet::pullandInlet::pull_chunkadvancePostProcessor::skip_samples
at the exact position of each lost or dropped gap so the first smoothed
timestamp after a gap stays within one sample interval. Plain LSL
connections withoutseq/1, and streams with zero loss, keep bit-exact
liblsl timestamps. labstream topandlabstream playincrates/labstream-cli
(docs/tools.md, roadmap step 12).topshows each live stream with its
measured rate, path, latency, and health counts fromInlet::healthonce
each second (text table or JSON).playreads an XDF 1.0 file and replays
its streams as live outlets with exact sample bits and file timestamp
intervals.
Fixed
-
When an outlet closes a
dgram/1consumer session, it now shuts down the
shared TCP socket so the request reader thread exits at once and the inlet
receives TCP FIN without waiting for the 15 s watchdog. -
Unicast discovery queries now leave from the receive socket so the reply
returns on the same port and passes stateful firewalls such as Windows
Defender Firewall with no inbound rule. -
An inlet with
CLOCKSYNCwaits up to 5 s for the first clock offset, as
liblsl does. Before, the first timestamps used an offset of 0, and the real
offset arrived about 0.6 s later as a step. If no offset arrives in 5 s, the
samples continue with no correction. liblsl raises a timeout error there. -
A recovering inlet connects again to the same outlet after its TCP
connection closes. Before, the stream stopped with no error while the
outlet still ran. After a restart of the outlet, the clock probes now go to
the new service port, and the offset resets. -
A consumer connection writes the samples of one push call with one socket
write. Before, each sample had its own write, and a partial chunk could
wait 200 ms. -
The inlet reader moves its buffer once for each read, and takes the queue
lock once for each read. Before, it did both once for each sample. -
A discovery query uses the multicast TTL of the configuration. Before, it
always used 1.
Changed
README.mdgives how to download the built C library from a GitHub release,
for each of the three platforms. It no longer says that only the tests of
labstream-netneed a network, because the tests oflabstreambind sockets
too.docs/versioning.mdgives only what a version number means. Its release
steps are now indocs/releasing.md.- Without a clock offset, an inlet sends its clock probes 4 ms apart, and
the burst stops when each probe has its answer. The first offset on
loopback now arrives in about 40 ms. Before, it took about 370 ms. A burst
that finds no offset tries again after 250 ms. The later bursts keep the
configured cadence. - Each read in a clock probe slot waits only for the time that is left in the
slot. Before, a fixed 40 ms read timeout ended a 64 ms slot early. - Each data connection uses TCP keepalive: a first probe after 2 s without
traffic, then one each second, and an end after 3 probes without an
answer. On Linux, data without an acknowledgement for 6 s also ends the
connection. A connection that died with no close now ends in about 5 s,
and a recovering inlet connects again. Before, an inlet waited for the
15 s watchdog, and kept the dead socket while the outlet was visible. - On Unix, a read that gives
ETIMEDOUTends the connection. A read timeout
givesEAGAINthere. socket2now uses itsallfeature.release.ymlpublishes only the crates that crates.io does not hold at the
version. A release that stops partway now completes when a person reruns the
failed jobs. Before, the workflow refused a partial state, and a person had
to publish the rest by hand.docs/releasing.mdgives the recovery.
Fixed
crates/labstream-net/src/dgram_in.rs: preserve IPv6 link-localscope_id
when building thedgram/1UDP peer address from the TCP peer socket. Before,
SocketAddr::new(peer.ip(), param.port)zeroedscope_id, sodgram/1UDP
hello failed over IPv6 link-local Wi-Fi links.
Install
cargo add labstreamlabstream is the API for a Rust program. labstream-core gives the
protocol crates for a program that needs a lower level.
The C library for each platform is below. crates.io carries
source and not a binary, so labstream-capi is not there.