我要评分
获取效率
正确性
完整性
易理解

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 functional 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.

If sendDataOffset is not 0, when the engine invokes the dataCallback interface, the memory layout of the third parameter (the data pointer) is |SendDataOffset reserved data | valid data with length size|, and the fourth parameter (size) indicates the valid data length. That is, data of SendDataOffset bytes is reserved before the data pointer, followed by valid data with length size.

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));

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.