1. Home
  2. Docs
  3. HTTP API of NDI
  4. Status and switching of encoding and decoding modes

Status and switching of encoding and decoding modes

Module name: mode

Basic URL: /api/v1/mode/

Some NDI devices have the capabilities of both Encoder and Decoder (such as Connect Spark IO), you can switch between the two. But Connect Spark Plus / TCMI4KUHD only has the capability of Encoder, in this case, mode switching will not work.

Get the current encoding/decoding working mode


API URL

/api/v1/mode/get

Request

​ Method: GET/POST

​ Parameters: NONE

Response

Example:

{
    "result": "ok",
    "data": {
        "mode": "encoder" /*Or "decoder"*/
    }
}

Data field description:

Field Value Description
mode [STRING] "encoder" or "decoder"
"encoder" identifies the device is working on Encoder mode, and "decoder" identifies the device is working on Decoder mode.

Switch the encoding/decoding working mode


API URL

/api/v1/mode/switch

Request

​ Method: GET/POST

Parameter Value Description
mode [STRING] , Required "encoder" or "decoder"
Specify to switch to encoder or decoder mode.

Response

Example:

{
    "result": "ok"
}

If the handover fails, see the description of the error message in 1.3.

Note: If some device models do not support encoder / decoder mode switching, this operation will not work and return the corresponding error message.

Switching the Encoder / Decoder mode takes a long time, so if you need to handle the timeout of HTTP requests / responses in particular, please note that the execution time of the request may take up to 5 seconds. Therefore, you need to set the request timeout of the API in order to avoid unexpected failure of the API request due to too short timeout.

If you need to specifically confirm whether the Encoder / Decoder mode is working properly, even after calling this API to switch back you need to further try to call /api/v1/mode/status to confirm the working status of the NDI Device. The reason why it looks so strange here is that the Encoder / Decoder mode switching requires a quick Reboot action inside the device.

Check if the encoding/decoding mode is ready


After you perform the switch operation of Encoder / Decoder mode, due to a quick Reboot action performed inside the device, if you need to confirm whether the switched mode enters the working state normally, you may need to continue to call this API periodically until it returns The result tells you that it has entered the working mode. Usually, it may take 10~15 seconds from switching to working state.

Don’t worry, your current Session ID and Authorization Token are still valid after switching the encoding / decoding mode and performing fast Reboot inside the device.

API URL

/api/v1/mode/status

Request

​ Method: GET/POST

​ Parameters: NONE

Response

If the encoding / decoding mode is ready, it will return:

{
    "result": "ok",
    "data": {
        "mode": "encoder", /*Or "decoder"*/
        "status": "ready"
    }
}

If the mode is not yet ready, an error will be returned:

{
    "result": "error",
    "reason": "not-ready",
    "msg": "...error message..."
}

Please note: "reason": "not-ready" may not exist at any time. Put it simple, if the device is performing an internal Reboot process and the program is temporarily inaccessible, the "reason" field will not exist. However, even during the Reboot process, your HTTP request can still be responded to by the device.

How can we help?