stream_outlet
Namespace: LSLLIB · Library: LSL Library
#include <lsl/lsl_stream_outlet.h>
class LSLLIB::stream_outlet
Server-side LSL endpoint: binds a TCP data server, advertises the stream on the LSL discovery multicast group, and fans samples out to every connected inlet.
stream_info info("ex_lsl_eeg", "EEG", 3, 250.0, ChannelFormat::Float32, "ex_lsl"); // name, type, channels, Hz
stream_outlet outlet(info); // starts serving immediately
Public Methods
stream_outlet(info)
Construct a stream_outlet for the given stream_info.
This immediately starts the TCP data server and begins UDP discovery broadcasts.
Parameters:
- info : const stream_info &
The
stream_infodescribing this outlet's stream.
~stream_outlet()
Destructor.
Stops broadcasting and closes all connections.
push_sample(sample)
Push a single multichannel sample into the outlet.
Parameters:
- sample : const std::vector< float > & A vector of channel values (must match the stream's channel_count).
push_chunk(chunk)
Push a chunk of multichannel samples into the outlet.
Parameters:
- chunk : const std::vector< std::vector< float > > & A vector of samples, where each sample is a vector of channel values.
info()
Get the stream_info associated with this outlet (including the assigned data port).
Returns:
- stream_info — The
stream_infofor this outlet.
have_consumers()
Check whether any consumers are currently connected.
Returns:
- bool — True if at least one inlet is connected.
Example
- Full source:
src/examples/ex_lsl/main.cpp - Build target:
ex_lsl(runs under CTest)
Used in examples
ex_lsl
LSL library: publish a stream, discover it and receive its samples over loopback.
stream_info info("ex_lsl_eeg", "EEG", 3, 250.0, ChannelFormat::Float32, "ex_lsl"); // name, type, channels, Hz
stream_outlet outlet(info); // starts serving immediately
ok &= expect(outlet.info().name() == "ex_lsl_eeg" && outlet.info().channel_count() == 3 && outlet.info().nominal_srate() == 250.0 && outlet.info().data_port() > 0 && !outlet.info().uid().empty(),
QString("stream_info: 3 channels at 250 Hz, served on port %1").arg(outlet.info().data_port()));
Authors of this file
- Christoph Dinh <christoph.dinh@mne-cpp.org>