|
|
|
@@ -104,7 +104,7 @@ std::string load_monitor_sql =
|
|
|
|
|
"`MotionFrameSkip`, "
|
|
|
|
|
"`FPSReportInterval`, `RefBlendPerc`, `AlarmRefBlendPerc`, `TrackMotion`, `Exif`, "
|
|
|
|
|
"`Latitude`, `Longitude`, "
|
|
|
|
|
"`RTSPServer`, `RTSPStreamName`, `ONVIF_Alarm_Text`,"
|
|
|
|
|
"`RTSPServer`, `RTSPStreamName`, `SOAP_wsa_compl`, `ONVIF_Alarm_Text`,"
|
|
|
|
|
"`ONVIF_URL`, `ONVIF_Username`, `ONVIF_Password`, `ONVIF_Options`, "
|
|
|
|
|
"`ONVIF_Event_Listener`, `use_Amcrest_API`,"
|
|
|
|
|
"`SignalCheckPoints`, `SignalCheckColour`, `Importance`-1, ZoneCount "
|
|
|
|
@@ -257,6 +257,7 @@ Monitor::Monitor() :
|
|
|
|
|
longitude(0.0),
|
|
|
|
|
rtsp_server(false),
|
|
|
|
|
rtsp_streamname(""),
|
|
|
|
|
soap_wsa_compl(false),
|
|
|
|
|
onvif_alarm_txt(""),
|
|
|
|
|
importance(0),
|
|
|
|
|
zone_count(0),
|
|
|
|
@@ -361,7 +362,7 @@ Monitor::Monitor() :
|
|
|
|
|
"ImageBufferCount, `MaxImageBufferCount`, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, "
|
|
|
|
|
"SectionLength, MinSectionLength, FrameSkip, MotionFrameSkip, "
|
|
|
|
|
"FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif,"
|
|
|
|
|
"`RTSPServer`,`RTSPStreamName`,
|
|
|
|
|
"`RTSPServer`, `RTSPStreamName`, `SOAP_wsa_compl`,"
|
|
|
|
|
"`ONVIF_URL`, `ONVIF_Username`, `ONVIF_Password`, `ONVIF_Options`, `ONVIF_Event_Listener`, `use_Amcrest_API`, "
|
|
|
|
|
"SignalCheckPoints, SignalCheckColour, Importance-1, ZoneCount, `MQTT_Enabled`, `MQTT_Subscriptions` FROM Monitors";
|
|
|
|
|
*/
|
|
|
|
@@ -553,6 +554,8 @@ void Monitor::Load(MYSQL_ROW dbrow, bool load_zones=true, Purpose p = QUERY) {
|
|
|
|
|
/* "`RTSPServer`,`RTSPStreamName`, */
|
|
|
|
|
rtsp_server = (*dbrow[col] != '0'); col++;
|
|
|
|
|
rtsp_streamname = dbrow[col]; col++;
|
|
|
|
|
// get soap_wsa_compliance value
|
|
|
|
|
soap_wsa_compl = (*dbrow[col] != '0'); col++;
|
|
|
|
|
// get alarm text from table.
|
|
|
|
|
onvif_alarm_txt = std::string(dbrow[col] ? dbrow[col] : ""); col++;
|
|
|
|
|
|
|
|
|
@@ -1072,15 +1075,15 @@ bool Monitor::connect() {
|
|
|
|
|
soap->send_timeout = 0;
|
|
|
|
|
//soap->bind_flags |= SO_REUSEADDR;
|
|
|
|
|
soap_register_plugin(soap, soap_wsse);
|
|
|
|
|
soap_register_plugin(soap, soap_wsa);
|
|
|
|
|
if (soap_wsa_compl) {soap_register_plugin(soap, soap_wsa);}
|
|
|
|
|
proxyEvent = PullPointSubscriptionBindingProxy(soap);
|
|
|
|
|
|
|
|
|
|
if (!onvif_url.empty()) {
|
|
|
|
|
std::string full_url = onvif_url + "/Events";
|
|
|
|
|
proxyEvent.soap_endpoint = full_url.c_str();
|
|
|
|
|
set_credentials(soap);
|
|
|
|
|
const char *RequestMessageID = soap_wsa_rand_uuid(soap);
|
|
|
|
|
if (soap_wsa_request(soap, RequestMessageID, proxyEvent.soap_endpoint , "CreatePullPointSubscriptionRequest") == SOAP_OK) {
|
|
|
|
|
const char *RequestMessageID = soap_wsa_compl ? soap_wsa_rand_uuid(soap) : "RequestMessageID";
|
|
|
|
|
if ((!soap_wsa_compl) || (soap_wsa_request(soap, RequestMessageID, proxyEvent.soap_endpoint , "CreatePullPointSubscriptionRequest") == SOAP_OK)) {
|
|
|
|
|
Debug(1, "ONVIF Endpoint: %s", proxyEvent.soap_endpoint);
|
|
|
|
|
if (proxyEvent.CreatePullPointSubscription(&request, response) != SOAP_OK) {
|
|
|
|
|
const char *detail = soap_fault_detail(soap);
|
|
|
|
@@ -1095,8 +1098,8 @@ bool Monitor::connect() {
|
|
|
|
|
} else {
|
|
|
|
|
//Empty the stored messages
|
|
|
|
|
set_credentials(soap);
|
|
|
|
|
RequestMessageID = soap_wsa_rand_uuid(soap);
|
|
|
|
|
if (soap_wsa_request(soap, RequestMessageID, response.SubscriptionReference.Address , "PullMessageRequest") == SOAP_OK) {
|
|
|
|
|
RequestMessageID = soap_wsa_compl ? soap_wsa_rand_uuid(soap):NULL;
|
|
|
|
|
if ((!soap_wsa_compl) || (soap_wsa_request(soap, RequestMessageID, response.SubscriptionReference.Address , "PullMessageRequest") == SOAP_OK)) {
|
|
|
|
|
Debug(1, "ONVIF :soap_wsa_request OK ");
|
|
|
|
|
if ((proxyEvent.PullMessages(response.SubscriptionReference.Address, NULL, &tev__PullMessages, tev__PullMessagesResponse) != SOAP_OK) &&
|
|
|
|
|
(soap->error != SOAP_EOF)
|
|
|
|
@@ -1113,30 +1116,32 @@ bool Monitor::connect() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// we renew the current subscription .........
|
|
|
|
|
set_credentials(soap);
|
|
|
|
|
RequestMessageID = soap_wsa_rand_uuid(soap);
|
|
|
|
|
if (soap_wsa_request(soap, RequestMessageID, response.SubscriptionReference.Address, "RenewRequest") == SOAP_OK) {
|
|
|
|
|
Debug(1, "ONVIF :soap_wsa_request OK");
|
|
|
|
|
if (proxyEvent.Renew(response.SubscriptionReference.Address, NULL, &wsnt__Renew, wsnt__RenewResponse) != SOAP_OK) {
|
|
|
|
|
Error("ONVIF Couldn't do initial Renew ! Error %i %s, %s", soap->error, soap_fault_string(soap), soap_fault_detail(soap));
|
|
|
|
|
if (soap->error==12) {//ActionNotSupported
|
|
|
|
|
Event_Poller_Healthy = true;
|
|
|
|
|
if (soap_wsa_compl){
|
|
|
|
|
set_credentials(soap);
|
|
|
|
|
RequestMessageID = soap_wsa_rand_uuid(soap);
|
|
|
|
|
if (soap_wsa_request(soap, RequestMessageID, response.SubscriptionReference.Address, "RenewRequest") == SOAP_OK) {
|
|
|
|
|
Debug(1, "ONVIF :soap_wsa_request OK");
|
|
|
|
|
if (proxyEvent.Renew(response.SubscriptionReference.Address, NULL, &wsnt__Renew, wsnt__RenewResponse) != SOAP_OK) {
|
|
|
|
|
Error("ONVIF Couldn't do initial Renew ! Error %i %s, %s", soap->error, soap_fault_string(soap), soap_fault_detail(soap));
|
|
|
|
|
if (soap->error==12) {//ActionNotSupported
|
|
|
|
|
Event_Poller_Healthy = true;
|
|
|
|
|
} else {
|
|
|
|
|
Event_Poller_Healthy = false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Event_Poller_Healthy = false;
|
|
|
|
|
Debug(1, "Good Initial ONVIF Renew %i %s, %s", soap->error, soap_fault_string(soap), soap_fault_detail(soap));
|
|
|
|
|
Event_Poller_Healthy = true;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Debug(1, "Good Initial ONVIF Renew %i %s, %s", soap->error, soap_fault_string(soap), soap_fault_detail(soap));
|
|
|
|
|
Event_Poller_Healthy = true;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Error("ONVIF Couldn't set wsa headers RequestMessageID=%s; TO=%s; Request=RenewRequest Error %i %s, %s",
|
|
|
|
|
RequestMessageID,
|
|
|
|
|
response.SubscriptionReference.Address,
|
|
|
|
|
soap->error,
|
|
|
|
|
soap_fault_string(soap),
|
|
|
|
|
soap_fault_detail(soap));
|
|
|
|
|
Event_Poller_Healthy = false;
|
|
|
|
|
}
|
|
|
|
|
Error("ONVIF Couldn't set wsa headers RequestMessageID=%s; TO=%s; Request=RenewRequest Error %i %s, %s",
|
|
|
|
|
RequestMessageID,
|
|
|
|
|
response.SubscriptionReference.Address,
|
|
|
|
|
soap->error,
|
|
|
|
|
soap_fault_string(soap),
|
|
|
|
|
soap_fault_detail(soap));
|
|
|
|
|
Event_Poller_Healthy = false;
|
|
|
|
|
}// end renew
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Error("ONVIF Couldn't set wsa headers RequestMessageID=%s; TO=%s; Request=CreatePullPointSubscriptionRequest Error %i %s, %s",
|
|
|
|
@@ -1844,8 +1849,8 @@ bool Monitor::Poll() {
|
|
|
|
|
} else {
|
|
|
|
|
#ifdef WITH_GSOAP
|
|
|
|
|
set_credentials(soap);
|
|
|
|
|
const char *RequestMessageID = soap_wsa_rand_uuid(soap);
|
|
|
|
|
if (soap_wsa_request(soap, RequestMessageID, response.SubscriptionReference.Address, "PullMessageRequest") == SOAP_OK) {
|
|
|
|
|
const char *RequestMessageID = soap_wsa_compl ? soap_wsa_rand_uuid(soap) : "RequestMessageID";
|
|
|
|
|
if ((!soap_wsa_compl) || (soap_wsa_request(soap, RequestMessageID, response.SubscriptionReference.Address, "PullMessageRequest") == SOAP_OK)) {
|
|
|
|
|
Debug(1, ":soap_wsa_request OK; starting ONVIF PullMessageRequest ...");
|
|
|
|
|
int result = proxyEvent.PullMessages(response.SubscriptionReference.Address, NULL, &tev__PullMessages, tev__PullMessagesResponse);
|
|
|
|
|
if (result != SOAP_OK) {
|
|
|
|
@@ -1892,28 +1897,30 @@ bool Monitor::Poll() {
|
|
|
|
|
} // end foreach msg
|
|
|
|
|
|
|
|
|
|
// we renew the current subscription .........
|
|
|
|
|
set_credentials(soap);
|
|
|
|
|
std::string Termination_time = "PT60S";
|
|
|
|
|
wsnt__Renew.TerminationTime = &Termination_time;
|
|
|
|
|
RequestMessageID = soap_wsa_rand_uuid(soap);
|
|
|
|
|
if (soap_wsa_request(soap, RequestMessageID, response.SubscriptionReference.Address, "RenewRequest") == SOAP_OK) {
|
|
|
|
|
Debug(1, ":soap_wsa_request OK");
|
|
|
|
|
if (proxyEvent.Renew(response.SubscriptionReference.Address, NULL, &wsnt__Renew, wsnt__RenewResponse) != SOAP_OK) {
|
|
|
|
|
Error("Couldn't do Renew! Error %i %s, %s", soap->error, soap_fault_string(soap), soap_fault_detail(soap));
|
|
|
|
|
if (soap->error==12) {//ActionNotSupported
|
|
|
|
|
Event_Poller_Healthy = true;
|
|
|
|
|
if (soap_wsa_compl){
|
|
|
|
|
set_credentials(soap);
|
|
|
|
|
std::string Termination_time = "PT60S";
|
|
|
|
|
wsnt__Renew.TerminationTime = &Termination_time;
|
|
|
|
|
RequestMessageID = soap_wsa_compl ? soap_wsa_rand_uuid(soap) : "RequestMessageID";
|
|
|
|
|
if ((!soap_wsa_compl) || (soap_wsa_request(soap, RequestMessageID, response.SubscriptionReference.Address, "RenewRequest") == SOAP_OK)) {
|
|
|
|
|
Debug(1, ":soap_wsa_request OK");
|
|
|
|
|
if (proxyEvent.Renew(response.SubscriptionReference.Address, NULL, &wsnt__Renew, wsnt__RenewResponse) != SOAP_OK) {
|
|
|
|
|
Error("Couldn't do Renew! Error %i %s, %s", soap->error, soap_fault_string(soap), soap_fault_detail(soap));
|
|
|
|
|
if (soap->error==12) {//ActionNotSupported
|
|
|
|
|
Event_Poller_Healthy = true;
|
|
|
|
|
} else {
|
|
|
|
|
Event_Poller_Healthy = false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Event_Poller_Healthy = false;
|
|
|
|
|
Debug(1, "Good Renew ONVIF Renew %i %s, %s", soap->error, soap_fault_string(soap), soap_fault_detail(soap));
|
|
|
|
|
Event_Poller_Healthy = true;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Debug(1, "Good Renew ONVIF Renew %i %s, %s", soap->error, soap_fault_string(soap), soap_fault_detail(soap));
|
|
|
|
|
Event_Poller_Healthy = true;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Error("Couldn't set wsa headers RequestMessageID=%s; TO=%s; Request= RenewRequest .... ! Error %i %s, %s",
|
|
|
|
|
RequestMessageID, response.SubscriptionReference.Address, soap->error, soap_fault_string(soap), soap_fault_detail(soap));
|
|
|
|
|
Event_Poller_Healthy = false;
|
|
|
|
|
}
|
|
|
|
|
Error("Couldn't set wsa headers RequestMessageID=%s; TO=%s; Request= RenewRequest .... ! Error %i %s, %s",
|
|
|
|
|
RequestMessageID, response.SubscriptionReference.Address, soap->error, soap_fault_string(soap), soap_fault_detail(soap));
|
|
|
|
|
Event_Poller_Healthy = false;
|
|
|
|
|
} // end renew
|
|
|
|
|
}
|
|
|
|
|
} // end if SOAP OK/NOT OK
|
|
|
|
|
} else {
|
|
|
|
|
Error("Couldn't set wsa headers RequestMessageID= %s ; TO= %s ; Request= PullMessageRequest .... ! Error %i %s, %s",
|
|
|
|
@@ -3480,8 +3487,8 @@ int Monitor::Close() {
|
|
|
|
|
Debug(1, "Tearing Down Onvif");
|
|
|
|
|
_wsnt__Unsubscribe wsnt__Unsubscribe;
|
|
|
|
|
_wsnt__UnsubscribeResponse wsnt__UnsubscribeResponse;
|
|
|
|
|
const char *RequestMessageID = soap_wsa_rand_uuid(soap);
|
|
|
|
|
if (soap_wsa_request(soap, RequestMessageID, response.SubscriptionReference.Address, "UnsubscribeRequest") == SOAP_OK)
|
|
|
|
|
const char *RequestMessageID = soap_wsa_compl ? soap_wsa_rand_uuid(soap) : "RequestMessageID";
|
|
|
|
|
if ((!soap_wsa_compl) || (soap_wsa_request(soap, RequestMessageID, response.SubscriptionReference.Address, "UnsubscribeRequest") == SOAP_OK))
|
|
|
|
|
{
|
|
|
|
|
proxyEvent.Unsubscribe(response.SubscriptionReference.Address, NULL, &wsnt__Unsubscribe, wsnt__UnsubscribeResponse);
|
|
|
|
|
} else {
|
|
|
|
|