Files
ANSLIB/ONVIF/include/onvif/onvif_event.h

118 lines
2.9 KiB
C
Raw Normal View History

2026-03-28 11:39:04 +11:00
/***************************************************************************************
*
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
* Copyright (C) 2014-2024, Happytimesoft Corporation, all rights reserved.
*
* Redistribution and use in binary forms, with or without modification, are permitted.
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
****************************************************************************************/
#ifndef ONVIF_EVENT_H
#define ONVIF_EVENT_H
#include "sys_inc.h"
#include "onvif.h"
#include "xml_node.h"
#include "onvif_req.h"
#include "http.h"
typedef struct
{
BOOL used_flag;
ONVIF_DEVICE * p_dev;
} ONVIF_TIMER_DEV;
typedef void (* onvif_event_notify_cb)(Notify_REQ * p_req, void * pdata);
typedef void (* onvif_subscribe_disconnect_cb)(ONVIF_DEVICE * p_dev, void * pdata);
typedef struct
{
onvif_event_notify_cb notify_cb;
void * notify_cb_data;
void * notify_cb_mutex;
onvif_subscribe_disconnect_cb disconnect_cb;
void * disconnect_cb_data;
void * disconnect_cb_mutex;
HTTPSRV http_srv; // http server for receiving event notify
pthread_t event_timer_id;
int event_timer_run;
PPSN_CTX * event_dev_fl;
PPSN_CTX * event_dev_ul;
int event_dev_max;
} ONVIF_EVENT_CLS;
#ifdef __cplusplus
extern "C" {
#endif
/**
* init event handler
*
* init http server for receiving event notify messages
*
* http_srv_addr : http server listen address, NULL means listening on all interfaces
* http_srv_port : http server listen port
* max_clients : max support client numbers
*
*/
HT_API BOOL onvif_event_init(const char * http_srv_addr, uint16 http_srv_port, int max_clients);
/**
* deinit event handler
*/
HT_API void onvif_event_deinit();
/**
* set event notify callback
*
* set cb to NULL, disable callback
*/
HT_API void onvif_set_event_notify_cb(onvif_event_notify_cb cb, void * pdata);
/**
* set event subscribe disconnect callback
*
* set cb to NULL, disable callback
*/
HT_API void onvif_set_subscribe_disconnect_cb(onvif_subscribe_disconnect_cb cb, void * pdata);
/**
* event notify handler, called by http_soap_process
*/
HT_API void onvif_event_notify(HTTPCLN * p_user, HTTPMSG * rx_msg, XMLN * p_xml);
/**
* add p_dev to event timer list, send renew request
*/
HT_API BOOL onvif_event_timer_add(ONVIF_DEVICE * p_dev);
/**
* del p_dev from event timer list
*/
HT_API BOOL onvif_event_timer_del(ONVIF_DEVICE * p_dev);
#ifdef __cplusplus
}
#endif
#endif