pub struct Inlet { /* private fields */ }Expand description
A connected inlet.
A background thread reads the socket and decodes samples into a bounded queue. The application pulls from that queue.
The split matters. A reader that decoded inside pull would leave the
socket unread while the application worked, so a loss would land in the
outlet’s queue instead of this one. liblsl runs the same background thread
(src/data_receiver.h).
Implementations§
Source§impl Inlet
impl Inlet
Sourcepub fn open(info: &StreamInfo, timeout: Duration) -> Result<Self>
pub fn open(info: &StreamInfo, timeout: Duration) -> Result<Self>
Open a feed to a resolved stream. SPEC.md 4 and 6.
The call runs the whole handshake, including the two test pattern samples that open every feed.
Sourcepub fn open_with_buffer(
info: &StreamInfo,
timeout: Duration,
buffer_samples: i32,
) -> Result<Self>
pub fn open_with_buffer( info: &StreamInfo, timeout: Duration, buffer_samples: i32, ) -> Result<Self>
Open a feed and choose the size of the queue, in samples.
The value also goes out in Max-Buffer-Length, which carries a count of
samples. A caller that thinks in seconds converts first. SPEC.md 8.6.
Sourcepub fn open_recovering(
info: &StreamInfo,
timeout: Duration,
buffer_samples: i32,
) -> Result<Self>
pub fn open_recovering( info: &StreamInfo, timeout: Duration, buffer_samples: i32, ) -> Result<Self>
Open a feed and choose whether the inlet finds the stream again after a restart of its source. SPEC.md 10.1.
liblsl enables recovery by default (include/lsl_cpp.h:915).
Sourcepub fn set_postprocessing(&mut self, options: u32)
pub fn set_postprocessing(&mut self, options: u32)
Choose the post-processing stages. SPEC.md 8.5.
The default applies none, so a timestamp arrives as the sender wrote it.
Sourcepub fn set_postprocessing_all(&mut self)
pub fn set_postprocessing_all(&mut self)
Apply every stage: clock sync, then jitter removal, then the clamp.
Sourcepub fn time_correction(&self) -> Option<f64>
pub fn time_correction(&self) -> Option<f64>
The measured offset between the two clocks, or None before the first
burst finishes.
Add this value to a timestamp to move it onto the local clock. The
CLOCKSYNC stage does that on its own.
Sourcepub fn wait_for_time_correction(&self, timeout: Duration) -> Option<f64>
pub fn wait_for_time_correction(&self, timeout: Duration) -> Option<f64>
Wait for a first offset measurement.
Sourcepub fn time_uncertainty(&self) -> Option<f64>
pub fn time_uncertainty(&self) -> Option<f64>
The round-trip time of the estimate that the offset came from.
Sourcepub fn info(&self) -> &StreamInfo
pub fn info(&self) -> &StreamInfo
The description of the connected stream.
This is the short description that discovery returned. It carries an
empty description tree. Call Inlet::fullinfo for the tree.
Sourcepub fn fullinfo(&self, timeout: Duration) -> Result<StreamInfo>
pub fn fullinfo(&self, timeout: Duration) -> Result<StreamInfo>
Read the whole description, with the description tree.
The short description that a discovery answer carries has no tree
(src/stream_info_impl.cpp:160). The tree travels on the data port.
This opens its own connection, the way info_receiver does
(src/info_receiver.cpp:60), and leaves the feed connection alone.
Sourcepub fn pull(&mut self, timeout: Duration) -> Result<Option<Sample>>
pub fn pull(&mut self, timeout: Duration) -> Result<Option<Sample>>
Read one sample.
Returns Ok(None) when the timeout passes with no whole sample.
The timestamp passes through the post-processing stages that
Inlet::set_postprocessing selected. With none selected the value is
the one that the sender wrote.
Sourcepub fn pull_chunk(
&mut self,
out: &mut Vec<Sample>,
max: usize,
timeout: Duration,
) -> Result<usize>
pub fn pull_chunk( &mut self, out: &mut Vec<Sample>, max: usize, timeout: Duration, ) -> Result<usize>
Read every sample that waits, up to max, with one lock.
The samples go to the end of out. The call gives how many it added.
Every timestamp passes through the stages that
Inlet::set_postprocessing selected, in the order of one
Inlet::pull for each sample.
The timeout applies to the first sample only. The call never waits for
max samples, because a program that shows live signals must show what
arrived.
This is the call for a fast stream. Inlet::pull takes the queue lock
and reads the clock for each sample. A stream of 8 channels at 1000 Hz
therefore costs 1000 locks each second with pull, and one lock for each
block here.
Sourcepub fn samples_available(&self) -> usize
pub fn samples_available(&self) -> usize
How many samples wait for the application.
Sourcepub fn samples_dropped(&self) -> u64
pub fn samples_dropped(&self) -> u64
How many samples the queue has dropped.
Nothing on the wire carries this number, so a peer cannot learn it. SPEC.md 8.7. This exists for a local report only.
Sourcepub fn buffer_capacity(&self) -> usize
pub fn buffer_capacity(&self) -> usize
The size of the queue, in samples.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
True once the connection ended and every sample has been pulled.
Source§impl Inlet
impl Inlet
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
True while the reader is attached to a source.
A recovery sets this to false until the stream is found again.
Sourcepub fn recoveries(&self) -> u64
pub fn recoveries(&self) -> u64
How many times the connection has been rebuilt. SPEC.md 10.1.
Sourcepub fn current_info(&self) -> StreamInfo
pub fn current_info(&self) -> StreamInfo
The stream that the reader is attached to now.
A recovery replaces this, and the instance identifier changes while the name and the source identifier stay.