Skip to main content
Version: 12 Dec 2024

ml_space.h

Classes

Name
structMLSpaceManagerSettings
A structure containing settings for the space manager. This structure must be initialized by calling MLSpaceManagerSettingsInit before use.
structMLSpace
A structure containing information about a Magic Leap Space. This structure must be initialized by calling MLSpaceInit before use.
structMLSpaceList
A structure containing list of MLSpace. This structure must be initialized by calling MLSpaceListInit before use.
structMLSpaceQueryFilter
A collection of filters for Magic Leap Spaces. This structure must be initialized by calling MLSpaceQueryFilterInit before use. There is no support for filters at this time.
structMLSpaceLocalizationInfo
A collection of parameters to be used for localization request. This structure must be initialized by calling MLSpaceLocalizationInfoInit before use.
structMLSpaceLocalizationResult
A structure containing information about the device's localization state. This structure must be initialized by calling MLSpaceLocalizationResultInit before use.
structMLSpaceCallbacks
A structure containing callbacks for events related to the Space.
structMLSpaceImportInfo
A structure containing information needed to import Magic Leap Space. This structure must be initialized by calling MLSpaceImportInfoInit before use.
structMLSpaceImportOutData
A structure containing information about the imported Space.
structMLSpaceExportInfo
A structure containing information about the Space export settings. This structure must be initialized by calling MLSpaceExportInfoInit before use.
structMLSpaceExportOutData
A structure containing information about the exported Space.

Types

Name
typedef struct MLSpaceManagerSettingsMLSpaceManagerSettings
A structure containing settings for the space manager. This structure must be initialized by calling MLSpaceManagerSettingsInit before use.
typedef struct MLSpaceMLSpace
A structure containing information about a Magic Leap Space. This structure must be initialized by calling MLSpaceInit before use.
typedef struct MLSpaceListMLSpaceList
A structure containing list of MLSpace. This structure must be initialized by calling MLSpaceListInit before use.
typedef struct MLSpaceQueryFilterMLSpaceQueryFilter
A collection of filters for Magic Leap Spaces. This structure must be initialized by calling MLSpaceQueryFilterInit before use. There is no support for filters at this time.
typedef struct MLSpaceLocalizationInfoMLSpaceLocalizationInfo
A collection of parameters to be used for localization request. This structure must be initialized by calling MLSpaceLocalizationInfoInit before use.
typedef struct MLSpaceLocalizationResultMLSpaceLocalizationResult
A structure containing information about the device's localization state. This structure must be initialized by calling MLSpaceLocalizationResultInit before use.
typedef struct MLSpaceCallbacksMLSpaceCallbacks
A structure containing callbacks for events related to the Space.
typedef struct MLSpaceImportInfoMLSpaceImportInfo
A structure containing information needed to import Magic Leap Space. This structure must be initialized by calling MLSpaceImportInfoInit before use.
typedef struct MLSpaceImportOutDataMLSpaceImportOutData
A structure containing information about the imported Space.
typedef struct MLSpaceExportInfoMLSpaceExportInfo
A structure containing information about the Space export settings. This structure must be initialized by calling MLSpaceExportInfoInit before use.
typedef struct MLSpaceExportOutDataMLSpaceExportOutData
A structure containing information about the exported Space.

Enums

Name
enumAnonymous Enum 28
{
MLResultAPIPrefix_Space = ( 0x10cc << 16),
MLSpace_MaxSpaceNameLength = 64
}
enumMLSpaceResult
{
MLSpaceResult_ServerError = MLResultAPIPrefix_Space,
MLSpaceResult_ServiceUnavailable,
MLSpaceResult_UnavailableSpace,
MLSpaceResult_IncompatibleSpace,
MLSpaceResult_SpaceAlreadyExists,
MLSpaceResult_Ensure32Bits = 0x7FFFFFFF
}
Magic Leap Space specific return codes.
enumMLSpaceType
{
MLSpaceType_OnDevice = 0,
MLSpaceType_ARCloud = 1,
MLSpaceType_Ensure32Bits = 0x7FFFFFFF
}
Space type. Indicates the type of the Space.
enumMLSpaceLocalizationStatus
{
MLSpaceLocalizationStatus_NotLocalized = 0,
MLSpaceLocalizationStatus_Localized = 1,
MLSpaceLocalizationStatus_LocalizationPending = 2,
MLSpaceLocalizationStatus_SleepingBeforeRetry = 3,
MLSpaceLocalizationStatus_Ensure32Bits = 0x7FFFFFFF
}
The current localization status.
enumMLSpaceLocalizationConfidence
{
MLSpaceLocalizationConfidence_Poor = 0,
MLSpaceLocalizationConfidence_Fair = 1,
MLSpaceLocalizationConfidence_Good = 2,
MLSpaceLocalizationConfidence_Excellent = 3,
MLSpaceLocalizationConfidence_Ensure32Bits = 0x7FFFFFFF
}
The confidence of the current localization.
enumMLSpaceLocalizationErrorFlag
{
MLSpaceLocalizationErrorFlag_None = 0,
MLSpaceLocalizationErrorFlag_Unknown = 1 << 0,
MLSpaceLocalizationErrorFlag_OutOfMappedArea = 1 << 1,
MLSpaceLocalizationErrorFlag_LowFeatureCount = 1 << 2,
MLSpaceLocalizationErrorFlag_ExcessiveMotion = 1 << 3,
MLSpaceLocalizationErrorFlag_LowLight = 1 << 4,
MLSpaceLocalizationErrorFlag_HeadposeFailure = 1 << 5,
MLSpaceLocalizationErrorFlag_AlgorithmFailure = 1 << 6,
MLSpaceLocalizationErrorFlag_Ensure32Bits = 0x7FFFFFFF
}
A set of possible reasons that a localization attempt may be unsuccessful.

Functions

Name
voidMLSpaceManagerSettingsInit(MLSpaceManagerSettings * inout_info)
Initializes default values for MLSpaceManagerSettings.
voidMLSpaceInit(MLSpace * inout_info)
Initializes default values for MLSpace.
voidMLSpaceListInit(MLSpaceList * inout_info)
Initializes default values for MLSpaceList.
voidMLSpaceQueryFilterInit(MLSpaceQueryFilter * inout_query_filter)
Initializes the default values for a query filter.
voidMLSpaceLocalizationInfoInit(MLSpaceLocalizationInfo * inout_info)
Initializes the default values for localization info.
voidMLSpaceLocalizationResultInit(MLSpaceLocalizationResult * inout_info)
Initialize default values for MLSpaceLocalizationResult.
voidMLSpaceCallbacksInit(MLSpaceCallbacks * inout_callbacks)
Initialize defaults for MLSpaceCallbacks.
voidMLSpaceImportInfoInit(MLSpaceImportInfo * inout_info)
Initialize default values for MLSpaceImportInfo.
voidMLSpaceExportInfoInit(MLSpaceExportInfo * inout_info)
Initialize default values for MLSpaceExportInfo.
const char *MLSpaceGetResultString(MLResult result)
Returns an ASCII string for MLSpaceResult and MLResult codes.
MLResultMLSpaceManagerCreate(const MLSpaceManagerSettings settings, MLHandle out_handle)
Creates a Magic Leap Space manager handle.
MLResultMLSpaceSetCallbacks(MLHandle handle, const MLSpaceCallbacks callbacks, void user_data)
Set the callbacks for events related to the Magic Leap Space.
MLResultMLSpaceGetSpaceList(MLHandle handle, const MLSpaceQueryFilter query_filter, MLSpaceList out_space_list)
Get the list of available spaces.
MLResultMLSpaceReleaseSpaceList(MLHandle handle, MLSpaceList * space_list)
Release the list of available spaces.
MLResultMLSpaceRequestLocalization(MLHandle handle, const MLSpaceLocalizationInfo * localization_info)
Send a request to localize to a given Magic Leap Space.
MLResultMLSpaceGetLocalizationResult(MLHandle handle, MLSpaceLocalizationResult * out_localization_result)
Get the localization results.
MLResultMLSpaceManagerDestroy(MLHandle handle)
Destroys a Space manager handle.
MLResultMLSpaceImportSpace(const MLSpaceImportInfo import_info, MLSpaceImportOutData out_data)
Import a Magic Leap Space.
MLResultMLSpaceExportSpace(const MLSpaceExportInfo export_info, MLSpaceExportOutData out_data)
Export an on device Magic Leap Space.
MLResultMLSpaceReleaseExportData(MLSpaceExportOutData * space_data)
Release resources acquired in MLSpaceExportSpace.

Enums Documentation

Anonymous Enum 28

EnumeratorValueDescription
MLResultAPIPrefix_Space( 0x10cc << 16)Defines the prefix for MLSpaceResult codes.
MLSpace_MaxSpaceNameLength64Maximum size for the name of a Magic Leap Space.

MLSpaceResult

EnumeratorValueDescription
MLSpaceResult_ServerErrorMLResultAPIPrefix_SpaceThere was an error communicating with the server.
MLSpaceResult_ServiceUnavailableThe operation failed because the underlying service is not yet available, retry later.
MLSpaceResult_UnavailableSpaceSpace is not available. This can happen when the selected space is in AR Cloud but the device is configured for On Device spaces or vice-versa.
MLSpaceResult_IncompatibleSpaceSpace is not compatible with the current OS version. This can happen when a space exported from an older version of the OS is imported to a device running a newer version of the OS. Refer to the documentation at the top of this header for more notes on Space compatibility.
MLSpaceResult_SpaceAlreadyExistsThe operation failed because the Space being imported already exists in the device.
MLSpaceResult_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Magic Leap Space specific return codes.

API Level:

  • 26

MLSpaceType

EnumeratorValueDescription
MLSpaceType_OnDevice0On device space.
MLSpaceType_ARCloud1AR Cloud based space.
MLSpaceType_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

Space type. Indicates the type of the Space.

API Level:

  • 26

MLSpaceLocalizationStatus

EnumeratorValueDescription
MLSpaceLocalizationStatus_NotLocalized0The device is currently not localized.
MLSpaceLocalizationStatus_Localized1The device has localized successfully.
MLSpaceLocalizationStatus_LocalizationPending2Localization attempt is currently in progress.
MLSpaceLocalizationStatus_SleepingBeforeRetry3The device will attempt to localize after sleep duration is complete.
MLSpaceLocalizationStatus_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

The current localization status.

API Level:

  • 26

MLSpaceLocalizationConfidence

EnumeratorValueDescription
MLSpaceLocalizationConfidence_Poor0Localization confidence is very poor and should be reattempted.
MLSpaceLocalizationConfidence_Fair1The confidence is low, current environmental conditions may adversely affect localization.
MLSpaceLocalizationConfidence_Good2The confidence is high, persistent content should be stable.
MLSpaceLocalizationConfidence_Excellent3This is a very high-confidence localization, persistent content will be very stable.
MLSpaceLocalizationConfidence_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

The confidence of the current localization.

API Level:

  • 31

MLSpaceLocalizationErrorFlag

EnumeratorValueDescription
MLSpaceLocalizationErrorFlag_None0No error, localization was successful.
MLSpaceLocalizationErrorFlag_Unknown1 << 0Localization failed for an unknown reason.
MLSpaceLocalizationErrorFlag_OutOfMappedArea1 << 1Localization failed becuase the user is outside of the mapped area.
MLSpaceLocalizationErrorFlag_LowFeatureCount1 << 2There are not enough features in the environment to successfully localize.
MLSpaceLocalizationErrorFlag_ExcessiveMotion1 << 3Localization failed due to excessive motion.
MLSpaceLocalizationErrorFlag_LowLight1 << 4Localization failed because the lighting levels are too low in the environment.
MLSpaceLocalizationErrorFlag_HeadposeFailure1 << 5A headpose failure caused localization to be unsuccessful.
MLSpaceLocalizationErrorFlag_AlgorithmFailure1 << 6There was an internal algorithm failure that prevented localization.
MLSpaceLocalizationErrorFlag_Ensure32Bits0x7FFFFFFFEnsure enum is represented as 32 bits.

A set of possible reasons that a localization attempt may be unsuccessful.

API Level:

  • 31

Types Documentation

MLSpaceManagerSettings

typedef struct MLSpaceManagerSettings MLSpaceManagerSettings;

A structure containing settings for the space manager. This structure must be initialized by calling MLSpaceManagerSettingsInit before use.

More Info

API Level:

  • 26

MLSpace

typedef struct MLSpace MLSpace;

A structure containing information about a Magic Leap Space. This structure must be initialized by calling MLSpaceInit before use.

More Info

API Level:

  • 26

MLSpaceList

typedef struct MLSpaceList MLSpaceList;

A structure containing list of MLSpace. This structure must be initialized by calling MLSpaceListInit before use.

More Info

API Level:

  • 26

MLSpaceQueryFilter

typedef struct MLSpaceQueryFilter MLSpaceQueryFilter;

A collection of filters for Magic Leap Spaces. This structure must be initialized by calling MLSpaceQueryFilterInit before use. There is no support for filters at this time.

More Info

API Level:

  • 26

MLSpaceLocalizationInfo

typedef struct MLSpaceLocalizationInfo MLSpaceLocalizationInfo;

A collection of parameters to be used for localization request. This structure must be initialized by calling MLSpaceLocalizationInfoInit before use.

More Info

API Level:

  • 26

MLSpaceLocalizationResult

typedef struct MLSpaceLocalizationResult MLSpaceLocalizationResult;

A structure containing information about the device's localization state. This structure must be initialized by calling MLSpaceLocalizationResultInit before use.

More Info

API Level:

  • 31

MLSpaceCallbacks

typedef struct MLSpaceCallbacks MLSpaceCallbacks;

A structure containing callbacks for events related to the Space.

This structure must be initialized by calling MLSpaceCallbacksInit before use. Application can unregister (stop receiving callbacks) at any time by setting the corresponding callback to NULL.

More Info

API Level:

  • 26

MLSpaceImportInfo

typedef struct MLSpaceImportInfo MLSpaceImportInfo;

A structure containing information needed to import Magic Leap Space. This structure must be initialized by calling MLSpaceImportInfoInit before use.

More Info

API Level:

  • 26

MLSpaceImportOutData

typedef struct MLSpaceImportOutData MLSpaceImportOutData;

A structure containing information about the imported Space.

More Info

API Level:

  • 26

MLSpaceExportInfo

typedef struct MLSpaceExportInfo MLSpaceExportInfo;

A structure containing information about the Space export settings. This structure must be initialized by calling MLSpaceExportInfoInit before use.

More Info

API Level:

  • 26

MLSpaceExportOutData

typedef struct MLSpaceExportOutData MLSpaceExportOutData;

A structure containing information about the exported Space.

More Info

API Level:

  • 26

Functions Documentation

MLSpaceManagerSettingsInit

static inline void MLSpaceManagerSettingsInit(
MLSpaceManagerSettings * inout_info
)

Initializes default values for MLSpaceManagerSettings.

Parameters

MLSpaceManagerSettings *inout_infoThe object to initialize with default values.

Required Permissions:

  • None

API Level:

  • 26

MLSpaceInit

static inline void MLSpaceInit(
MLSpace * inout_info
)

Initializes default values for MLSpace.

Parameters

MLSpace *inout_infoThe object to initialize with default values.

Required Permissions:

  • None

API Level:

  • 26

MLSpaceListInit

static inline void MLSpaceListInit(
MLSpaceList * inout_info
)

Initializes default values for MLSpaceList.

Parameters

MLSpaceList *inout_infoThe object to initialize with default values.

Required Permissions:

  • None

API Level:

  • 26

MLSpaceQueryFilterInit

static inline void MLSpaceQueryFilterInit(
MLSpaceQueryFilter * inout_query_filter
)

Initializes the default values for a query filter.

Parameters

MLSpaceQueryFilter *inout_query_filterThe filter to initialize.

Required Permissions:

  • None

API Level:

  • 26

MLSpaceLocalizationInfoInit

static inline void MLSpaceLocalizationInfoInit(
MLSpaceLocalizationInfo * inout_info
)

Initializes the default values for localization info.

Parameters

MLSpaceLocalizationInfo *inout_infoThe object to initialize with default values.

Required Permissions:

  • None

API Level:

  • 26

MLSpaceLocalizationResultInit

static inline void MLSpaceLocalizationResultInit(
MLSpaceLocalizationResult * inout_info
)

Initialize default values for MLSpaceLocalizationResult.

Parameters

MLSpaceLocalizationResult *inout_infoThe localization result to initialize.

Required Permissions:

  • None

API Level:

  • 31

MLSpaceCallbacksInit

static inline void MLSpaceCallbacksInit(
MLSpaceCallbacks * inout_callbacks
)

Initialize defaults for MLSpaceCallbacks.

Parameters

MLSpaceCallbacks *inout_callbacksThe callback structure to initialize.

Required Permissions:

  • None

API Level:

  • 26

MLSpaceImportInfoInit

static inline void MLSpaceImportInfoInit(
MLSpaceImportInfo * inout_info
)

Initialize default values for MLSpaceImportInfo.

Parameters

MLSpaceImportInfo *inout_infoThe object to initialize with default values.

Required Permissions:

  • None

API Level:

  • 26

MLSpaceExportInfoInit

static inline void MLSpaceExportInfoInit(
MLSpaceExportInfo * inout_info
)

Initialize default values for MLSpaceExportInfo.

Parameters

MLSpaceExportInfo *inout_infoThe object to initialize with default values.

Required Permissions:

  • None

API Level:

  • 26

MLSpaceGetResultString

const char * MLSpaceGetResultString(
MLResult result
)

Returns an ASCII string for MLSpaceResult and MLResult codes.

Parameters

MLResultresultThe input MLResult enum from MLSpace functions.

Required Permissions:

  • None

Return: ASCII string containing readable version of result code.

API Level:

  • 26

MLSpaceManagerCreate

MLResult MLSpaceManagerCreate(
const MLSpaceManagerSettings * settings,
MLHandle * out_handle
)

Creates a Magic Leap Space manager handle.

Parameters

const MLSpaceManagerSettings *settingsSettings that configures the space manager.
MLHandle *out_handleThe handle to be created.

Returns

MLResultMLResult_ClientLimitExceededFailed due to an existing manager.
MLResultMLResult_InvalidParamOne or more input parameters are not valid.
MLResultMLResult_OkSpace manager handle was successfully created.
MLResultMLResult_PermissionDeniedNecessary permission is missing.
MLResultMLResult_UnspecifiedFailureOperation failed for unknown reason.

Required Permissions:

  • com.magicleap.permission.SPACE_MANAGER (protection level: normal)

Application can create only one Magic Leap Space manager handle. Multiple calls to create a manager handle will result in a failure. The handle is valid for the lifecycle of the application.

API Level:

  • 26

MLSpaceSetCallbacks

MLResult MLSpaceSetCallbacks(
MLHandle handle,
const MLSpaceCallbacks * callbacks,
void * user_data
)

Set the callbacks for events related to the Magic Leap Space.

Parameters

MLHandlehandleSpace manager handle created by MLSpaceManagerCreate.
const MLSpaceCallbacks *callbacksPointer to the MLSpaceCallbacks structure containing the callbacks.
void *user_dataPointer that will be returned in the callback.

Returns

MLResultMLResult_InvalidParamOne or more input parameters are not valid.
MLResultMLResult_OkThe callbacks were registered successfully.
MLResultMLResult_UnspecifiedFailureOperation failed for unknown reason.

API Level:

  • 26

MLSpaceGetSpaceList

MLResult MLSpaceGetSpaceList(
MLHandle handle,
const MLSpaceQueryFilter * query_filter,
MLSpaceList * out_space_list
)

Get the list of available spaces.

Parameters

MLHandlehandleSpace manager handle created by MLSpaceManagerCreate.
const MLSpaceQueryFilter *query_filterThe filter structure for the query.
MLSpaceList *out_space_listList of Spaces currently available to the device.

Returns

MLResultMLResult_InvalidParamOne or more input parameters are not valid.
MLResultMLResult_OkList of spaces retrieved successfully.
MLResultMLResult_UnauthenticatedInvalid authentication credentials for this operation.
MLResultMLResult_UnspecifiedFailureOperation failed for unknown reason.
MLResultMLSpaceResult_ServerErrorOperation failed due to server side error.
MLResultMLSpaceResult_ServiceUnavailableOperation failed because service is not ready.

Required Permissions:

  • None

The list of spaces returned will depend on the current device mapping mode. Only the Spaces associated with the current mapping mode will be returned by this call. Device mapping mode can be changed via the system application(s).

The list memory is owned by the library, call MLSpaceReleaseSpaceList to release the memory. Each get MLSpaceGetSpaceList should have a corresponding MLSpaceReleaseSpaceList.

API Level:

  • 26

MLSpaceReleaseSpaceList

MLResult MLSpaceReleaseSpaceList(
MLHandle handle,
MLSpaceList * space_list
)

Release the list of available spaces.

Parameters

MLHandlehandleSpace manager handle created by MLSpaceManagerCreate.
MLSpaceList *space_listList Magic Leap Spaces that needs to be released.

Returns

MLResultMLResult_InvalidParamOne or more input parameters are not valid.
MLResultMLResult_OkList resources was successfully released.
MLResultMLResult_UnspecifiedFailureOperation failed for unknown reason.

Required Permissions:

  • None

API Level:

  • 26

MLSpaceRequestLocalization

MLResult MLSpaceRequestLocalization(
MLHandle handle,
const MLSpaceLocalizationInfo * localization_info
)

Send a request to localize to a given Magic Leap Space.

Parameters

MLHandlehandleSpace manager handle created by MLSpaceManagerCreate.
const MLSpaceLocalizationInfo *localization_infoMagic Leap Space to localize into.

Returns

MLResultMLResult_InvalidParamOne or more input parameters are not valid.
MLResultMLResult_OkLocalization request was submitted successfully.
MLResultMLResult_UnauthenticatedInvalid authentication credentials for this operation.
MLResultMLResult_UnspecifiedFailureOperation failed for unknown reason.
MLResultMLSpaceResult_UnavailableSpaceOperation failed due an unavailable Space.
MLResultMLSpaceResult_ServerErrorOperation failed due to server side error.
MLResultMLSpaceResult_ServiceUnavailableOperation failed because service is not ready.

Required Permissions:

  • None

This is an asynchronous request. Use MLSpaceGetLocalizationResult to get the results of the localization or use MLSpaceCallbacks to listen to on_localization_changed events.

A new request for localization will override all the past requests for localization that are yet to be completed.

API Level:

  • 26

MLSpaceGetLocalizationResult

MLResult MLSpaceGetLocalizationResult(
MLHandle handle,
MLSpaceLocalizationResult * out_localization_result
)

Get the localization results.

Parameters

MLHandlehandleSpace manager handle created by MLSpaceManagerCreate.
MLSpaceLocalizationResult *out_localization_resultContains the result of the localization request.

Returns

MLResultMLResult_InvalidParamOne or more input parameters are not valid.
MLResultMLResult_OkLocalization result was retrieved successfully.
MLResultMLResult_UnauthenticatedInvalid authentication credentials for this operation.
MLResultMLResult_UnspecifiedFailureOperation failed for unknown reason.

Required Permissions:

  • None

Returns the results of the most recent localization request.

API Level:

  • 26

MLSpaceManagerDestroy

MLResult MLSpaceManagerDestroy(
MLHandle handle
)

Destroys a Space manager handle.

Parameters

MLHandlehandleThe handle to be destroyed.

Returns

MLResultMLResult_InvalidParamOne or more input parameters are not valid.
MLResultMLResult_OkSpace manager handle was successfully destroyed.

Required Permissions:

  • None

API Level:

  • 26

MLSpaceImportSpace

MLResult MLSpaceImportSpace(
const MLSpaceImportInfo * import_info,
MLSpaceImportOutData * out_data
)

Import a Magic Leap Space.

Parameters

const MLSpaceImportInfo *import_infoInformation need to import the space.
MLSpaceImportOutData *out_dataInformation about the imported space.

Returns

MLResultMLResult_InvalidParamOne or more input parameters are not valid.
MLResultMLResult_PermissionDeniedNecessary permission is missing.
MLResultMLResult_UnspecifiedFailureOperation failed for unknown reason.
MLResultMLSpaceResult_IncompatibleSpaceOperation failed due an incompatible Space.
MLResultMLSpaceResult_SpaceAlreadyExistsOperation failed because Space being imported already exists.

Required Permissions:

  • com.magicleap.permission.SPACE_IMPORT_EXPORT (protection level: dangerous)

The MLSpaceImportInfo memory is owned by the app and the app should make sure to release the memory once the API call has returned.

API Level:

  • 26

MLSpaceExportSpace

MLResult MLSpaceExportSpace(
const MLSpaceExportInfo * export_info,
MLSpaceExportOutData * out_data
)

Export an on device Magic Leap Space.

Parameters

const MLSpaceExportInfo *export_infoInformation needed to export the space.
MLSpaceExportOutData *out_dataExported space data.

Returns

MLResultMLResult_InvalidParamOne or more input parameters are not valid.
MLResultMLResult_PermissionDeniedNecessary permission is missing.
MLResultMLResult_UnspecifiedFailureOperation failed for unknown reason.
MLResultMLSpaceResult_UnavailableSpaceOperation failed due an unavailable Space.

Required Permissions:

  • com.magicleap.permission.SPACE_IMPORT_EXPORT (protection level: dangerous)

The MLSpaceExportOutData is owned by the library, call MLSpaceReleaseExportData to release the memory. Each MLSpaceExportSpace call should have a corresponding MLSpaceReleaseExportData.

API Level:

  • 26

MLSpaceReleaseExportData

MLResult MLSpaceReleaseExportData(
MLSpaceExportOutData * space_data
)

Release resources acquired in MLSpaceExportSpace.

Parameters

MLSpaceExportOutData *space_dataMLSpaceExportOutData that needs to be released.

Returns

MLResultMLResult_InvalidParamOne or more input parameters are not valid.
MLResultMLResult_OkList resources was successfully released.
MLResultMLResult_UnspecifiedFailureOperation failed for unknown reason.

Required Permissions:

  • None

API Level:

  • 26

Source code

// %BANNER_BEGIN%
// ---------------------------------------------------------------------
// %COPYRIGHT_BEGIN%
// Copyright (c) 2023 Magic Leap, Inc. All Rights Reserved.
// Use of this file is governed by the Software License Agreement,
// located here: https://www.magicleap.com/software-license-agreement-ml2
// Terms and conditions applicable to third-party materials accompanying
// this distribution may also be found in the top-level NOTICE file
// appearing herein.
// %COPYRIGHT_END%
// ---------------------------------------------------------------------
// %BANNER_END%

#pragma once

#include "ml_api.h"
#include "ml_types.h"

#include <string.h>

ML_EXTERN_C_BEGIN

enum {
MLResultAPIPrefix_Space = MLRESULT_PREFIX(0x10cc),
MLSpace_MaxSpaceNameLength = 64,
};

typedef enum MLSpaceResult {
MLSpaceResult_ServerError = MLResultAPIPrefix_Space,
MLSpaceResult_ServiceUnavailable,
MLSpaceResult_UnavailableSpace,
MLSpaceResult_IncompatibleSpace,
MLSpaceResult_SpaceAlreadyExists,
MLSpaceResult_Ensure32Bits = 0x7FFFFFFF
} MLSpaceResult;

typedef enum MLSpaceType {
MLSpaceType_OnDevice = 0,
MLSpaceType_ARCloud = 1,
MLSpaceType_Ensure32Bits = 0x7FFFFFFF
} MLSpaceType;

typedef enum MLSpaceLocalizationStatus {
MLSpaceLocalizationStatus_NotLocalized = 0,
MLSpaceLocalizationStatus_Localized = 1,
MLSpaceLocalizationStatus_LocalizationPending = 2,
MLSpaceLocalizationStatus_SleepingBeforeRetry = 3,
MLSpaceLocalizationStatus_Ensure32Bits = 0x7FFFFFFF
} MLSpaceLocalizationStatus;

typedef enum MLSpaceLocalizationConfidence {
MLSpaceLocalizationConfidence_Poor = 0,
MLSpaceLocalizationConfidence_Fair = 1,
MLSpaceLocalizationConfidence_Good = 2,
MLSpaceLocalizationConfidence_Excellent = 3,
MLSpaceLocalizationConfidence_Ensure32Bits = 0x7FFFFFFF
} MLSpaceLocalizationConfidence;

typedef enum MLSpaceLocalizationErrorFlag {
MLSpaceLocalizationErrorFlag_None = 0,
MLSpaceLocalizationErrorFlag_Unknown = 1 << 0,
MLSpaceLocalizationErrorFlag_OutOfMappedArea = 1 << 1,
MLSpaceLocalizationErrorFlag_LowFeatureCount = 1 << 2,
MLSpaceLocalizationErrorFlag_ExcessiveMotion = 1 << 3,
MLSpaceLocalizationErrorFlag_LowLight = 1 << 4,
MLSpaceLocalizationErrorFlag_HeadposeFailure = 1 << 5,
MLSpaceLocalizationErrorFlag_AlgorithmFailure = 1 << 6,
MLSpaceLocalizationErrorFlag_Ensure32Bits = 0x7FFFFFFF
} MLSpaceLocalizationErrorFlag;

typedef struct MLSpaceManagerSettings {
uint32_t version;
} MLSpaceManagerSettings;

ML_STATIC_INLINE void MLSpaceManagerSettingsInit(MLSpaceManagerSettings *inout_info) {
if (inout_info) {
memset(inout_info, 0, sizeof(MLSpaceManagerSettings));
inout_info->version = 1u;
}
}

typedef struct MLSpace {
uint32_t version;
char space_name[MLSpace_MaxSpaceNameLength];
MLUUID space_id;
MLSpaceType space_type;
} MLSpace;

ML_STATIC_INLINE void MLSpaceInit(MLSpace *inout_info) {
if (inout_info) {
memset(inout_info, 0, sizeof(MLSpace));
inout_info->version = 1u;
}
}


typedef struct MLSpaceList {
uint32_t version;
uint32_t space_count;
MLSpace *spaces;
} MLSpaceList;

ML_STATIC_INLINE void MLSpaceListInit(MLSpaceList *inout_info) {
if (inout_info) {
memset(inout_info, 0, sizeof(MLSpaceList));
inout_info->version = 1u;
}
}

typedef struct MLSpaceQueryFilter {
uint32_t version;
} MLSpaceQueryFilter;

ML_STATIC_INLINE void MLSpaceQueryFilterInit(MLSpaceQueryFilter *inout_query_filter) {
if (inout_query_filter != NULL) {
memset(inout_query_filter, 0, sizeof(MLSpaceQueryFilter));
inout_query_filter->version = 1;
}
}

typedef struct MLSpaceLocalizationInfo {
uint32_t version;
MLUUID space_id;
} MLSpaceLocalizationInfo ;

ML_STATIC_INLINE void MLSpaceLocalizationInfoInit(MLSpaceLocalizationInfo *inout_info) {
if (inout_info != NULL) {
memset(inout_info, 0, sizeof(MLSpaceLocalizationInfo));
inout_info->version = 1;
}
}

typedef struct MLSpaceLocalizationResult {
uint32_t version;
MLSpaceLocalizationStatus localization_status;
MLSpace space;
MLCoordinateFrameUID target_space_origin;
MLSpaceLocalizationConfidence localization_confidence;
uint32_t error;
} MLSpaceLocalizationResult;

ML_STATIC_INLINE void MLSpaceLocalizationResultInit(MLSpaceLocalizationResult *inout_info) {
if (inout_info != NULL) {
memset(inout_info, 0, sizeof(MLSpaceLocalizationResult));
inout_info->version = 3;
}
}

typedef struct MLSpaceCallbacks {
uint32_t version;
void (*on_localization_changed)(const MLSpaceLocalizationResult *localization_result, void *user_data);
} MLSpaceCallbacks;

ML_STATIC_INLINE void MLSpaceCallbacksInit(MLSpaceCallbacks *inout_callbacks) {
if (inout_callbacks != NULL) {
inout_callbacks->version = 1;
inout_callbacks->on_localization_changed = NULL;
}
}

typedef struct MLSpaceImportInfo {
uint32_t version;
uint64_t size;
const char* data;
} MLSpaceImportInfo;

ML_STATIC_INLINE void MLSpaceImportInfoInit(MLSpaceImportInfo *inout_info) {
if (inout_info != NULL) {
memset(inout_info, 0, sizeof(MLSpaceImportInfo));
inout_info->version = 1;
}
}

typedef struct MLSpaceImportOutData {
MLUUID space_id;
} MLSpaceImportOutData;



typedef struct MLSpaceExportInfo {
uint32_t version;
MLUUID space_id;
} MLSpaceExportInfo;

ML_STATIC_INLINE void MLSpaceExportInfoInit(MLSpaceExportInfo *inout_info) {
if (inout_info != NULL) {
memset(inout_info, 0, sizeof(MLSpaceExportInfo));
inout_info->version = 1;
}
}

typedef struct MLSpaceExportOutData {
uint64_t size;
const char* data;
} MLSpaceExportOutData;


ML_API const char *ML_CALL MLSpaceGetResultString(MLResult result);



ML_API MLResult ML_CALL MLSpaceManagerCreate(const MLSpaceManagerSettings* settings, MLHandle* out_handle);

ML_API MLResult ML_CALL MLSpaceSetCallbacks(MLHandle handle, const MLSpaceCallbacks *callbacks, void* user_data);

ML_API MLResult ML_CALL MLSpaceGetSpaceList(MLHandle handle, const MLSpaceQueryFilter* query_filter, MLSpaceList* out_space_list);

ML_API MLResult ML_CALL MLSpaceReleaseSpaceList(MLHandle handle, MLSpaceList* space_list);

ML_API MLResult ML_CALL MLSpaceRequestLocalization(MLHandle handle, const MLSpaceLocalizationInfo* localization_info);

ML_API MLResult ML_CALL MLSpaceGetLocalizationResult(MLHandle handle, MLSpaceLocalizationResult* out_localization_result);

ML_API MLResult ML_CALL MLSpaceManagerDestroy(MLHandle handle);

ML_API MLResult ML_CALL MLSpaceImportSpace(const MLSpaceImportInfo* import_info, MLSpaceImportOutData* out_data);


ML_API MLResult ML_CALL MLSpaceExportSpace(const MLSpaceExportInfo* export_info, MLSpaceExportOutData* out_data);

ML_API MLResult ML_CALL MLSpaceReleaseExportData(MLSpaceExportOutData* space_data);

ML_EXTERN_C_END