nativeStream method
This function used to read from streamBufferMaps in stream format. Create a new stream that transform stream from native.
Implementation
Stream<Uint8List> nativeStream(String streamId) async* {
StreamBundle? streamBundle = extract(streamId);
if (streamBundle != null) {
yield Uint8List.fromList(streamBundle.bytesBuffer);
}
slog.d("[Debug Tag $debugTag] get stream bundle first step : $streamBundle working $_working",
tag: _tag);
if (streamBundle?.isEnd ?? false) {
slog.d("[Debug Tag $debugTag] native stream end by extract exist content", tag: _tag);
return;
} else {
while (true && _working) {
waitBufferCompleter = Completer();
await waitBufferCompleter!.future;
streamBundle = extract(streamId);
slog.d("[Debug Tag $debugTag] get stream bundle second step : $streamBundle", tag: _tag);
if (streamBundle != null) {
yield Uint8List.fromList(streamBundle.bytesBuffer);
}
if (streamBundle?.isError ?? false) {
throw Exception('native stream abnormal stop');
}
if (streamBundle?.isEnd ?? false) {
slog.d("[Debug Tag $debugTag] native stream end by completer", tag: _tag);
break;
}
}
}
}