Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ZoneMinder/zoneminder
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac Connor committed Oct 1, 2024
2 parents 34e1512 + 5baf482 commit f030507
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 19 deletions.
7 changes: 5 additions & 2 deletions src/zm_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ class Monitor : public std::enable_shared_from_this<Monitor> {
bool healthy;
std::string last_topic;
std::string last_value;
std::string last_active_topic;
std::string last_active_value;
#ifdef WITH_GSOAP
struct soap *soap = nullptr;
_tev__CreatePullPointSubscription request;
Expand All @@ -339,6 +341,7 @@ class Monitor : public std::enable_shared_from_this<Monitor> {
_wsnt__RenewResponse wsnt__RenewResponse;
PullPointSubscriptionBindingProxy proxyEvent;
void set_credentials(struct soap *soap);
std::unordered_map<std::string, std::string> alarms;
#endif
public:
explicit ONVIF(Monitor *parent_);
Expand All @@ -348,8 +351,8 @@ class Monitor : public std::enable_shared_from_this<Monitor> {
bool isAlarmed() const { return alarmed; };
void setAlarmed(bool p_alarmed) { alarmed = p_alarmed; };
bool isHealthy() const { return healthy; };
const std::string &lastTopic() const { return last_topic; };
const std::string &lastValue() const { return last_value; };
const std::string &lastTopic() const { return last_active_topic; };
const std::string &lastValue() const { return last_active_value; };
};

class AmcrestAPI {
Expand Down
34 changes: 25 additions & 9 deletions src/zm_monitor_onvif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ Monitor::ONVIF::~ONVIF() {
#ifdef WITH_GSOAP
if (soap != nullptr) {
Debug(1, "Tearing Down Onvif");
//We have lost ONVIF clear previous alarm topics
alarms.clear();
//Set alarmed to false so we don't get stuck recording
alarmed = false;
Debug(1, "ONVIF Alarms Cleared: Alarms count is %zu, alarmed is %s", alarms.size(), alarmed ? "true": "false");
_wsnt__Unsubscribe wsnt__Unsubscribe;
_wsnt__UnsubscribeResponse wsnt__UnsubscribeResponse;
const char *RequestMessageID = parent->soap_wsa_compl ? soap_wsa_rand_uuid(soap) : "RequestMessageID";
Expand Down Expand Up @@ -176,27 +181,38 @@ void Monitor::ONVIF::WaitForMessage() {
(msg->Message.__any.elts->next->elts->atts->next != nullptr) &&
(msg->Message.__any.elts->next->elts->atts->next->text != nullptr)
) {
Info("ONVIF Got Motion Alarm! %s %s", msg->Topic->__any.text, msg->Message.__any.elts->next->elts->atts->next->text);
last_topic = msg->Topic->__any.text;
last_value = msg->Message.__any.elts->next->elts->atts->next->text;
Info("ONVIF Got Motion Alarm! %s %s", last_topic.c_str(), last_value.c_str());
// Apparently simple motion events, the value is boolean, but for people detection can be things like isMotion, isPeople
if (strcmp(msg->Message.__any.elts->next->elts->atts->next->text, "false") == 0) {
if (last_value.find("false") == 0) {
Info("Triggered off ONVIF");
alarmed = false;
alarms.erase(last_topic);
if(alarms.empty()) {
Debug(1, "ONVIF Alarms Empty: Alarms count is %zu, alarmed is %s", alarms.size(), alarmed ? "true": "false");
alarmed = false;
}
if (!parent->Event_Poller_Closes_Event) { //If we get a close event, then we know to expect them.
parent->Event_Poller_Closes_Event = true;
Info("Setting ClosesEvent");
}
} else {
// Event Start
Info("Triggered on ONVIF");
if (!alarmed) {
Info("Triggered Event");
alarmed = true;
last_topic = msg->Topic->__any.text;
last_value = msg->Message.__any.elts->next->elts->atts->next->text;
Info("Triggered Start on ONVIF");
if (alarms.count(last_topic) == 0 )
{
alarms[last_topic] = last_value;
last_active_topic = last_topic;
last_active_value = last_value;
if (!alarmed) {
Info("Triggered Start Event on ONVIF");
alarmed = true;
// Why sleep?
std::this_thread::sleep_for(std::chrono::seconds(1)); //thread sleep
}
}
}
Debug(1, "ONVIF Alarms count is %zu, alarmed is %s", alarms.size(), alarmed ? "true": "false");
} else {
Debug(1, "ONVIF Got a message that we couldn't parse");
if ((msg->Topic != nullptr) && (msg->Topic->__any.text != nullptr)) {
Expand Down
19 changes: 12 additions & 7 deletions web/api/app/Controller/HostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ function getLoad() {
}

function login() {
$ver = $this->_getVersion();

$login_array = [];
$login_array['version'] = $ver[0];
$login_array['apiversion'] = $ver[1];

if (!ZM_OPT_USE_AUTH) {
$login_array['_serialize'] = array_keys($login_array);
$this->set($login_array);
return;
}

$username = $this->request->query('user') ? $this->request->query('user') : $this->request->data('user');
if ( !$username )
$username = $this->request->query('username') ? $this->request->query('username') : $this->request->data('username');
Expand All @@ -79,7 +91,6 @@ function login() {
throw new UnauthorizedException(__('No identity provided'));
}

$login_array = [];
$cred = [];

if ( $username && $password ) {
Expand Down Expand Up @@ -109,14 +120,8 @@ function login() {
ZM\Debug('Legacy Auth is disabled, not generating auth= credentials');
}

$ver = $this->_getVersion();
$login_array['version'] = $ver[0];
$login_array['apiversion'] = $ver[1];

$login_array['_serialize'] = array_keys($login_array);

$this->set($login_array);

} // end function login()

// clears out session
Expand Down
5 changes: 4 additions & 1 deletion web/skins/classic/views/js/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,10 @@ function initPage() {

// Event listener for double click
//var elStream = document.querySelectorAll('[id ^= "liveStream"], [id ^= "evtStream"]');
var elStream = document.querySelectorAll("[id = 'wrapperEventVideo'], [id = 'videoobj']");
//// When using video.js, the document will have both #videoobj and #wrapperEventVideo, but we only need #videoobj
//const elStreamVideoJS = document.querySelectorAll("[id = 'videoobj']");
//const elStream = (elStreamVideoJS.length > 0) ? elStreamVideoJS : document.querySelectorAll("[id = 'wrapperEventVideo']");
const elStream = document.querySelectorAll("[id = 'wrapperEventVideo']");
Array.prototype.forEach.call(elStream, (el) => {
el.addEventListener('touchstart', doubleTouch);
el.addEventListener('dblclick', doubleClickOnStream);
Expand Down

0 comments on commit f030507

Please sign in to comment.