Skip to main content

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.

src/examples/ex_lsl/main.cpp
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:


~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:


have_consumers()​

Check whether any consumers are currently connected.

Returns:

  • bool — True if at least one inlet is connected.

Example​

Used in examples​

ex_lsl​

LSL library: publish a stream, discover it and receive its samples over loopback.

src/examples/ex_lsl/main.cpp, line 73
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​