LSLStreamInfo.fromStreamInfo constructor
LSLStreamInfo.fromStreamInfo(
- lsl_streaminfo streamInfo
Creates a new LSLStreamInfo object from an existing lsl_streaminfo.
When constructing inlets, this creates the LSLStreamInfo object based on an existing lsl_streaminfo object, which can be retrieved from a stream resolver.
Implementation
factory LSLStreamInfo.fromStreamInfo(lsl_streaminfo streamInfo) {
final Pointer<Utf8> streamName = lsl_get_name(streamInfo) as Pointer<Utf8>;
final Pointer<Utf8> streamType = lsl_get_type(streamInfo) as Pointer<Utf8>;
final int channelCount = lsl_get_channel_count(streamInfo);
final double sampleRate = lsl_get_nominal_srate(streamInfo);
final lsl_channel_format_t channelFormat = lsl_get_channel_format(
streamInfo,
);
final Pointer<Utf8> sourceId =
lsl_get_source_id(streamInfo) as Pointer<Utf8>;
final String streamTypeString = streamType.toDartString();
final info = LSLStreamInfo(
streamName: streamName.toDartString(),
streamType: LSLContentType.values.firstWhere(
(e) => e.value == streamTypeString,
orElse: () => LSLContentType.custom(
streamTypeString,
), // Default to custom if not found
),
channelCount: channelCount,
sampleRate: sampleRate,
channelFormat: LSLChannelFormat.values.firstWhere(
(e) => e.lslFormat == channelFormat,
orElse: () =>
LSLChannelFormat.float32, // Default to float32 if not found
),
sourceId: sourceId.toDartString(),
streamInfo: streamInfo,
);
return info;
}