Last Updated on : 2023-08-09 09:25:02

The Open Network Video Interface Forum (ONVIF) is an open industry forum that provides and promotes standardized interfaces for the effective interoperability of IP-based physical security products. ONVIF profiles enable ONVIF-compliant devices and clients to be compatible with one another. This topic uses Profile S to describe how an ONVIF device and an ONVIF client communicate with each other.

Feature description

ONVIF follows a client-server model, where the IPC serves as the server and the network video recorder (NVR) acts as the client on the same LAN.

  • As a server, the IPC receives requests from the client.

    ONVIF-compliant IPCs can be added to NVRs through the ONVIF protocol to implement video preview.

  • The client such as NVRs can initiate connection and control requests.

    ONVIF-compliant NVRs can add ONVIF IPCs to stream videos from the IPCs.


Server features

This section describes the features the ONVIF server supports.

  • Start ONVIF server

    • After the ONVIF server is started, an ONVIF client can discover it and request streaming and events after connection.

    • Given the resource constraints of embedded devices, the ONVIF server supports the following functions.

      Device management Media PTZ control
      GetCapabilities GetProfile GetConfiguration
      GetDeviceInformation GetProfiles GetConfigurations
      GetServices GetAudioSources GetNode
      GetServiceCapabilities GetAudioSourceConfiguration GetNodes
      - GetAudioSourceConfigurations ContinuousMove
      - GetAudioEncoderConfiguration Stop
      - GetAudioEncoderConfigurations GetStatus
      - GetVideoSources AbsoluteMove
      - GetVideoSourceConfiguration RelativeMove
      - GetVideoSourceConfigurations GetPresets
      - GetVideoEncoderConfiguration SetPreset
      - GetVideoEncoderConfigurations RemovePreset
      - GetVideoEncoderConfigurationOptions GotoPreset
      - SetVideoEncoderConfiguration -
      - GetStreamUri -

      For more information, see the ONVIF official documentation.

  • Close ONVIF server

    Close the connection between the ONVIF server and ONVIF client. All server-side features will be disabled, and the server cannot be discovered.

Development guide


  • app_user_event
  • app_user_onvif
  • The IPC SDK that supports Real Time Streaming Protocol (RTSP).

How to

In the configuration file ability.config, enable the following functions:


ENV_FIRMNAME=\"xxxxx\" # The name of the camera displayed when it is discovered.

You can modify the configuration items using a graphical user interface later.

Data structure

This section describes the data structure in app_user_onvif.

Type definition

typedef enum {
    ONVIF_EVENT_TYPE_CELL_MOTION_DETECTION = 1,   // Motion detection
    ONVIF_EVENT_TYPE_TRIGGER_DIGITAL_INPUT,       // Not in use, reserved for extension.
    ONVIF_EVENT_TYPE_TRIGGER_RELAY,               // Not in use, reserved for extension.
    ONVIF_EVENT_TYPE_VIDEO_SIGNAL_LOSS,           // Not in use, reserved for extension.
    ONVIF_EVENT_TYPE_DETECTED_SOUND,              // Not in use, reserved for extension.
    ONVIF_EVENT_TYPE_PTZPRESETS_INVOKED,          // Not in use, reserved for extension.
    ONVIF_EVENT_TYPE_PTZPRESETS_REACHED,          // Not in use, reserved for extension.
    ONVIF_EVENT_TYPE_PTZPRESETS_ABORTED,          // Not in use, reserved for extension.
    ONVIF_EVENT_TYPE_PTZPRESETS_LEFT,             // Not in use, reserved for extension.
} ONVIF_EVENT_TYPE_T;     // Event type

typedef struct {
    int channel;                        // The channel of the event
    int state;                          // The event state
} ONVIF_EVENT_CELL_MOTION_DETECTION_T; // Information about motion detection

typedef struct {
    int input_channel;
    int logical_state;
} ONVIF_EVENT_TRIGGER_DIGITAL_INPUT_T; // Not in use, reserved for extension.

typedef struct
    ONVIF_EVENT_TYPE_T event_type;          // Event type
    union {
        ONVIF_EVENT_CELL_MOTION_DETECTION_T cell_motion_detection;
    } event;                                // Event details
    uint64_t event_timestamp_ms;            // Event timestamp
    char* snapshot_buf;                     // The buffer for event image capture (not supported currently)
    unsigned int snapshot_size;             // The size of the event image capture  (not supported currently)

API description

This section describes the server-side APIs in app_user_onvif.

Start and initialize ONVIF server

When this API is invoked, the IPC can be discovered by clients on the same LAN, such as NVR. This API responds immediately. Responses to ONVIF services are executed asynchronously.

* @ start ONVIF Server
* @return int 0: Success. Other values: Failure.
* @warning:
int ty_user_onvif_server_start(void);

Stop ONVIF server

This API returns the result after stopping the ONVIF server.

* @ stop ONVIF Server
* @return int 0: Success. Other values: Failure.
* @warning:
int ty_user_onvif_server_stop(void);

Start receiving internal messages

This API responds to the ONVIF commands received from the mobile app.

This API responds immediately. Responses are executed asynchronously.

* @ start receiving internal messages
* @return int 0: Success. Other values: Failure.
* @warning:
int ty_user_onvif_msg_start(void);

Report events

This API responds immediately. Responses are executed asynchronously.

* @ Reporting an Event
* @param[in] ONVIF_EVENT_T: event info
* @return int 0: Success. Other values: Failure.
* @warning:
int ty_user_onvif_server_event_handling(ONVIF_EVENT_T *event)

Things to note

  • Enable the ONVIF functions in ability.config.
  • Be sure to use the IPC SDK that supports RTSP. Otherwise, the client cannot receive video streams through the ONVIF protocol.
  • Event-triggered capture is not supported currently.
  • For security purposes, the ONVIF server only uses the HTTP digest authentication method. This might lead to compatibility issues with the ONVIF client from other manufacturers, resulting in connection and streaming failures.


Why can’t the NVR receive streams even when ONVIF is enabled on the mobile app?

  • Check if the username and password are correct.
  • Check the authentication method the NVR uses. If it does not use the HTTP digest method, there may be a compatibility issue.

Why does the camera respond slowly to PTZ control after the ONVIF client receives streams and IPC events?

Check the authentication method the NVR uses. If an HTTP digest method is not used, it can result in continuous authentication, which will consume CPU resources and bandwidth that can ultimately slow down other functions.

Why can’t clients pull a stream from the IPC after the video has been streamed to several clients?

The maximum number of connections for ONVIF and RTSP might be reached. You can submit a service ticket to request a change to the upper limit.