resolveByProperty method
Future<List<LSLStreamInfo> >
resolveByProperty({
- required LSLStreamProperty property,
- required String value,
- double waitTime = 5.0,
- int minStreamCount = 0,
Resolves streams by a specific property.
The property
parameter is the property to filter by, such as name,
type, channel count, etc.
The value
parameter is the value to filter by.
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.
Returns a list of LSLStreamInfo objects that match the filter.
Throws an LSLException if the resolver is not created or if there is an
error resolving streams.
You may get less streams than the minStreamCount
if there are not enough
streams available AND you have set a waitTime
> 0.
Implementation
Future<List<LSLStreamInfo>> resolveByProperty({
required LSLStreamProperty property,
required String value,
double waitTime = 5.0,
int minStreamCount = 0,
}) async {
if (!created) {
throw LSLException('Resolver not created');
}
final streamCount = lsl_resolve_byprop(
_streamInfoBuffer!,
maxStreams,
property.lslName.toNativeUtf8(allocator: allocate).cast<Char>(),
value.toNativeUtf8(allocator: allocate).cast<Char>(),
minStreamCount,
waitTime,
);
if (streamCount < 0) {
throw LSLException('Error resolving streams by property: $streamCount');
}
final streams = <LSLStreamInfo>[];
for (var i = 0; i < streamCount; i++) {
final streamInfo = LSLStreamInfo.fromStreamInfo(_streamInfoBuffer![i]);
streams.add(streamInfo);
}
return streams;
}