baseOptions method
Allocates native base options backed by this scope.
Implementation
ffi.Pointer<bindings.MpBaseOptions> baseOptions(BaseOptions options) {
final ffi.Pointer<bindings.MpBaseOptions> result = _arena<bindings.MpBaseOptions>();
final bindings.MpBaseOptions value = result.ref;
value
..model_asset_buffer = ffi.nullptr
..model_asset_buffer_count = 0
..model_asset_path = ffi.nullptr
..file_descriptor = -1
..delegate = _delegate(options.delegate)
..host_environment = _hostEnvironment()
..host_system = _hostSystem()
// The host version reaches MediaPipe's usage-logging path, so send a
// stable SDK label rather than the Dart VM's full version string, which
// also embeds OS details. See the privacy guide for the full contract.
..host_version = string('mp-dart-1')
..ca_bundle_path = ffi.nullptr
..app_id = ffi.nullptr
..app_version = ffi.nullptr;
switch (options.modelAsset) {
case ModelAssetPath(path: final String path):
value.model_asset_path = string(path);
case ModelAssetBytes(bytes: final Uint8List bytes):
final ffi.Pointer<ffi.Uint8> buffer = _arena<ffi.Uint8>(bytes.length);
buffer.asTypedList(bytes.length).setAll(0, bytes);
value
..model_asset_buffer = buffer.cast<ffi.Char>()
..model_asset_buffer_count = bytes.length;
case ModelAssetUri():
throw const MpException(
MpStatus.failedPrecondition,
'Resolve URI-backed model assets before creating native options.',
);
}
return result;
}