Last Updated on : 2024-06-25 03:46:27download
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.
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.
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.
app_user_event
app_user_onvif
IPC SDK
that supports Real Time Streaming Protocol (RTSP).In the configuration file ability.config
, enable the following functions:
ENV_TUYA_ONVIF_ENABLE=1
ENV_TY_SYS_ONVIF_SERVER_ENABLE=1
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.
This section describes the data structure in app_user_onvif
.
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;
ONVIF_EVENT_TRIGGER_DIGITAL_INPUT_T digital_input;
} 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)
} ONVIF_EVENT_T;
This section describes the server-side APIs in app_user_onvif
.
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);
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);
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);
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)
ability.config
.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.
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.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback