resolveByPredicate method
Resolves streams by a predicate function.
The predicate
parameter is an
XPath 1.0 predicate
e.g. name='MyStream' and type='EEG'
or starts-with(name, 'My')
.
The waitTime
parameter determines how long to wait for streams to
resolve, if the value is 0, the default of forever will be used, and will
only return when the minStreamCount
is met.
The minStreamCount
parameter is the minimum number of streams to
resolve, it must be greater than 0.
Implementation
Future<List<LSLStreamInfo>> resolveByPredicate({
required String predicate,
double waitTime = 5.0,
int minStreamCount = 0,
}) async {
if (!created) {
throw LSLException('Resolver not created');
}
final streamCount = lsl_resolve_bypred(
_streamInfoBuffer!,
maxStreams,
predicate.toNativeUtf8(allocator: allocate).cast<Char>(),
minStreamCount,
waitTime,
);
if (streamCount < 0) {
throw LSLException('Error resolving streams by predicate: $streamCount');
}
final streams = <LSLStreamInfo>[];
for (var i = 0; i < streamCount; i++) {
final streamInfo = LSLStreamInfo.fromStreamInfo(_streamInfoBuffer![i]);
streams.add(streamInfo);
}
return streams;
}