InitVmiEngine
Function Usage
Initializes the cloud phone server.
Restrictions
- This API cannot be called repeatedly. That is, it cannot be called after the initialization is complete.
- The data output callback cannot be blocked for a long time. It is recommended that the callback be returned within 1 ms.
Prototype
VmiErrCode InitVmiEngine(VmiConfigEngine *config);
Parameter Description
Field Name |
Input/Output |
Field Type |
Description |
|---|---|---|---|
config |
Input |
VmiConfigEngine |
This structure consists of the DataCallback and DataTypeConfig arrays. |
The VmiConfigEngine structure is required for starting the engine. It includes the DataCallback and the list of modules to be started.
1 2 3 4 | struct VmiConfigEngine { DataCallback dataCallback = nullptr; // Callback for sending server data. DataTypeConfig dataTypeConfig[DATA_TYPE_MAX]; } __attribute__((packed)); |
No function interface is provided for data output. Instead, the DataCallback is used. DataCallback definition:
1 | using DataCallback = int(*)(VmiDataType module, VmiCmd cmd, uint8_t *data, uint32_t size); |
The DataTypeConfig array specifies whether each module needs to be initialized and the size of the memory space that needs to be reserved before the data packet header during initialization so that developers can fill in required data.
1 2 3 4 | struct DataTypeConfig { bool shouldInit = false; uint32_t sendDataOffset = 0; // Space (in bytes) reserved before the data packet header when the callback is used to send data. The value range is 0 to 1024. } __attribute__((packed)); |
If sendDataOffset is not 0, the memory layout of the data pointer (the third parameter) of the dataCallback API is as follows: N bytes of reserved data (specified by sendDataOffset) + N bytes of valid data (specified by the fourth parameter size).
Return Value Description
Data type: enum VmiErrCode: int32_t
The value can be any of the following:
- OK (0): The initialization is successful.
- Other values: The initialization fails, and an error code is returned.