v2.0.0
Loading...
Searching...
No Matches
LSLLIB::stream_inlet Class Reference

A stream inlet to receive data from a stream_outlet on the network. More...

#include <stream_inlet.h>

Public Member Functions

 stream_inlet (const stream_info &info)
 ~stream_inlet ()
void open_stream ()
void close_stream ()
bool samples_available ()
template<typename T>
std::vector< std::vector< T > > pull_chunk ()
std::vector< std::vector< float > > pull_chunk_float ()

Detailed Description

A stream inlet to receive data from a stream_outlet on the network.

The stream_inlet connects to an outlet (described by a stream_info obtained from resolve_streams) over TCP and reads data from it. Data is received as chunks of multichannel float samples.

This class is API-compatible with the liblsl stream_inlet to serve as a drop-in replacement.

Definition at line 74 of file stream_inlet.h.

Constructor & Destructor Documentation

◆ stream_inlet()

stream_inlet::stream_inlet ( const stream_info & info)
explicit

Construct a new stream_inlet from a resolved stream_info.

Parameters
[in]infoA stream_info object (typically obtained from resolve_streams).

Definition at line 252 of file stream_inlet.cpp.

◆ ~stream_inlet()

stream_inlet::~stream_inlet ( )

Destructor. Closes the connection if still open.

Definition at line 259 of file stream_inlet.cpp.

Member Function Documentation

◆ close_stream()

void stream_inlet::close_stream ( )

Close the TCP connection to the outlet.

Definition at line 273 of file stream_inlet.cpp.

◆ open_stream()

void stream_inlet::open_stream ( )

Open the TCP connection to the outlet and begin receiving data.

Exceptions
std::runtime_errorif the connection cannot be established.

Definition at line 266 of file stream_inlet.cpp.

◆ pull_chunk()

template<typename T>
std::vector< std::vector< T > > LSLLIB::stream_inlet::pull_chunk ( )
inline

Pull a chunk of multichannel data from the inlet.

Returns all complete samples currently in the buffer. Template is provided for API compatibility with liblsl; only float is supported in this implementation.

Template Parameters
TThe data type (must be float).
Returns
A vector of samples, where each sample is a vector of channel values.

Definition at line 126 of file stream_inlet.h.

◆ pull_chunk_float()

std::vector< std::vector< float > > stream_inlet::pull_chunk_float ( )

Pull a chunk of float data (non-template version).

Returns
A vector of samples, where each sample is a vector of float channel values.

Definition at line 287 of file stream_inlet.cpp.

◆ samples_available()

bool stream_inlet::samples_available ( )

Check whether new samples are available in the internal buffer.

Also performs a non-blocking read from the TCP socket to collect any pending data.

Returns
True if at least one complete sample is available.

Definition at line 280 of file stream_inlet.cpp.


The documentation for this class was generated from the following files: