Edge API - Linux, Android
This page describes the API provided by LG AI Platform SDK.
Introduction
Edge API is an interface supported in the Edge/Device area of LG AI Platform.
Calling Sequence
Linux/Android SDK provides 8 Edge APIs in total. The description and calling sequence of each API are as follows:

API description
API |
Description |
create |
Engine Creation API
Creates an engine and allocates memory.
The create() API cannot be called in duplicate instances. If you call the create() API once, then call it again, an LGAI_INVALID_STATE error is returned. You can call the create() API again only after calling the destroy() API.
|
configure |
Engine Configuration API
Configures the control values and settings of the JSON format for an engine.
You can call the configure() API after calling the create() API and before calling the start() API.
|
setListener |
Engine Listener Registration API
Registers a callback listener to receive a resultant value after processing by the engine.
An engine that does not support callback listener will return an LGAI_NOT_SUPPORTED_API error.
|
start |
Engine Start API
Starts the engine once the engine settings are configured.
In the case of an engine that uses a thread, the start() API creates a thread inside the engine and waits for data to be transferred. The start() API cannot be called in duplicate instances. If you call the start() API once, then call it again, LGAI_INVALID_STATE error is returned. You can call the start() API again only after calling the stop() API.
|
process |
Input/Output Data Transmission API
Transfers the input data to an engine and receives the resultant value after it is processed by the engine.
A resultant value is transferred through a result argument or a callback listener registered in the setListener() API.
|
control |
It is used to change the engine settings or to transmit control commands while the engine is running.
An engine that does not support the control() API will return an LGAI_NOT_SUPPORTED_API error.
|
stop |
Engine Stop API
Stops an engine when it is no longer used. In the case of an engine using a thread, it stops the thread. Data entered after the engine stops is ignored.
Since an engine transfers the resultant value to the result argument or the callback listener, even if the resultant value has been transferred to the application, the engine does not stop unless the application calls the stop() API. If an engine does not stop, memory may be used unnecessarily. Therefore, the stop() API must be called after using the engine. The stop() API cannot be called in duplicate instances. If you call the stop() API once, then call it again, LGAI_INVALID_STATE error is returned. You can call the stop() API again only after calling the start() API.
|
destroy |
Engine Destruction API
Destroys the engine and releases the engine object from memory.
The destroy() API cannot be called in duplicate instances. If you call the destroy() API once, then call it again, LGAI_INVALID_STATE error is returned. You can call the destroy() API again only after calling the create() API.
|
Engine Status
SDK API provides the getState() API so an application can easily check the status of an engine object. An application developer can check the engine status by calling the getState() API while the application is running. The engine statuses change when the API is called, as shown in the following figure.

Engine State
Engine Status |
Description |
NONE |
The initial state of the engine.
|
CREATED |
If the create() API is processed successfully, the state of the engine changes to CREATED.
CREATED status is the state in which an object is created and its settings are initialized. In the CREATED status, you can call the setListener() API and the configure() API. The engine remains in the CREATED status even if the called setListener() API was processed successfully. In addition, you can change the internal settings of the engine dynamically by calling the control() API.
|
READY |
If the configure() API is processed successfully, the state of the engine changes to READY.
READY status is the state in which the engine has been configured completely. In this status, you can call the configure(), setListener() and control() APIs. In the READY status, you can call the configure() API and the setListener() API several times, and the last called value is reflected while the previous values are deleted. Even if the configure(), setListener(), and control() APIs are processed successfully, the engine remains in the READY status. In addition, you can change the internal settings of the engine dynamically by calling the control() API.
|
RUNNING |
If the start() API is processed successfully, the state of the engine changes to RUNNING.
RUNNING status is the state in which the engine operates. In this state, the process() API is called to transfer the data required for engine operation and receive the resultant value. In addition, you can change the internal settings of the engine dynamically by calling the control() API.
|
DESTROYED |
If the destroy() API is processed successfully, the state of the engine changes to DESTROYED.
DESTROYED status is the state in which the engine object has been destroyed.
|