Merge pull request #3828 from ovargasp/snapshot_1.37.50

SOAP WSA option for Chinese cameras
This commit is contained in:
Isaac Connor
2024-02-13 10:02:38 -05:00
committed by GitHub
6 changed files with 74 additions and 52 deletions

View File

@@ -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 {

View File

@@ -505,6 +505,7 @@ protected:
double longitude;
bool rtsp_server; // Whether to include this monitor as an rtsp server stream
std::string rtsp_streamname; // path in the rtsp url for this monitor
bool soap_wsa_compl; // Whether the camera supports soap_wsa or not.
std::string onvif_alarm_txt; // def onvif_alarm_txt
int importance; // Importance of this monitor, affects Connection logging errors.
unsigned int zone_count;

View File

@@ -251,6 +251,7 @@ public static function getStatuses() {
'Longitude' => null,
'RTSPServer' => array('type'=>'boolean', 'default'=>0),
'RTSPStreamName' => '',
'SOAP_wsa_compl' => array('type'=>'boolean', 'default'=>0),
'Importance' => 'Normal',
'MQTT_Enabled' => array('type'=>'boolean','default'=>0),
'MQTT_Subscriptions' => '',

View File

@@ -111,7 +111,8 @@ if ($action == 'save') {
'LinkedMonitors' => array(),
'MQTT_Enabled' => 0,
'RTSPServer' => 0,
'SectionLengthWarn' => 0
'SectionLengthWarn' => 0,
'SOAP_wsa_compl' => 0
);
# Checkboxes don't return an element in the POST data, so won't be present in newMonitor.

View File

@@ -954,6 +954,14 @@ None: No frames will be decoded, live view and thumbnails will not be available~
You will get errors in your logs about this. So make sure your keyframe interval is low or you have enough ram.
'
),
// Help for soap_wsa issue with chinesse cameras
'OPTIONS_SOAP_wsa' => array(
'Help' => '
Disable it if you receive an error ~~~ Couldnt do Renew Error 12 ActionNotSupported
<env:Text>The device do NOT support this feature</env:Text> ~~~ when trying to enable/use ONVIF ~~it may
help to get it to work... it is confirmed to work in some chinese cameras that do not implement ONVIF entirely
'
),
// 'LANG_DEFAULT' => array(
// 'Prompt' => "This is a new prompt for this option",

View File

@@ -596,6 +596,10 @@ switch ($name) {
<label><?php echo translate('ONVIF_Alarm_Text') ?></label>
<input type="text" name="newMonitor[ONVIF_Alarm_Text]" value="<?php echo validHtmlStr($monitor->ONVIF_Alarm_Text()) ?>"/>
</li>
<li>
<label><?php echo translate('SOAP WSA COMPLIANCE'); echo makeHelpLink('OPTIONS_SOAP_wsa') ?></label>
<input type="checkbox" name="newMonitor[SOAP_wsa_compl]" value="1"<?php echo $monitor->SOAP_wsa_compl() ? ' checked="checked"' : '' ?>/>
</li>
<li>
<label><?php echo translate('ONVIF_Event_Listener') ?></label>
<?php echo html_radio('newMonitor[ONVIF_Event_Listener]', array('1'=>translate('Enabled'), '0'=>translate('Disabled')), $monitor->ONVIF_Event_Listener()); ?>