mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2025-12-23 22:37:53 -05:00
Merge branch 'master' of github.com:ZoneMinder/zoneminder
This commit is contained in:
@@ -43,9 +43,9 @@ Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
|
||||
,sudo
|
||||
,javascript-common
|
||||
,libavdevice60|libavdevice59|libavdevice58|libavdevice57
|
||||
,libswscale7|libswscale6|libswscale5|libswscale4
|
||||
,libswresample4|libswresample3|libswresample2
|
||||
,libavdevice61|libavdevice60|libavdevice59|libavdevice58|libavdevice57
|
||||
,libswscale8|libswscale7|libswscale6|libswscale5|libswscale4
|
||||
,libswresample5|libswresample4|libswresample3|libswresample2
|
||||
,ffmpeg
|
||||
,libcurl4, libcurl4-gnutls-dev
|
||||
,libdatetime-perl, libdate-manip-perl, libmime-lite-perl, libmime-tools-perl
|
||||
|
||||
@@ -1174,6 +1174,32 @@ our @options = (
|
||||
format => q( $1 )
|
||||
},
|
||||
category => 'logging',
|
||||
},
|
||||
{
|
||||
name => 'ZM_LOG_LEVEL_TERM',
|
||||
default => '-1',
|
||||
description => 'Save logging output to stdout',
|
||||
help => q`
|
||||
ZoneMinder logging is now more integrated between
|
||||
components and allows you to specify the destination for
|
||||
logging output and the individual levels for each. This option
|
||||
lets you control the level of logging output that goes to the
|
||||
terminal stdout. This really only affects ZoneMinder binaries,
|
||||
not so much the web php scripts. This is generally only useful
|
||||
for debugging purposes.
|
||||
This option controls the maximum level
|
||||
of logging that will be written, so Info includes Warnings and
|
||||
Errors etc. To disable entirely, set this option to None.
|
||||
If you want debug
|
||||
you will also need to set a level and component below
|
||||
`,
|
||||
type => {
|
||||
db_type => 'integer',
|
||||
hint => 'None=-5|Panic=-4|Fatal=-3|Error=-2|Warning=-1|Info=0|Debug=1',
|
||||
pattern => qr|^(\d+)$|,
|
||||
format => q( $1 )
|
||||
},
|
||||
category => 'logging',
|
||||
},
|
||||
{
|
||||
name => 'ZM_LOG_LEVEL_FILE',
|
||||
|
||||
@@ -212,6 +212,7 @@ sub BEGIN {
|
||||
my %dbgConfig = (
|
||||
ZM_LOG_LEVEL_DATABASE => 0,
|
||||
ZM_LOG_LEVEL_FILE => 0,
|
||||
ZM_LOG_LEVEL_TERM => 0,
|
||||
ZM_LOG_LEVEL_SYSLOG => 0,
|
||||
ZM_LOG_DEBUG => 0,
|
||||
ZM_LOG_DEBUG_TARGET => '',
|
||||
@@ -254,7 +255,13 @@ sub initialise( @ ) {
|
||||
my $tempFileLevel = $this->{fileLevel};
|
||||
my $tempSyslogLevel = $this->{syslogLevel};
|
||||
|
||||
$tempTermLevel = $options{termLevel} if defined($options{termLevel});
|
||||
if ( defined($ENV{LOG_PRINT}) ) {
|
||||
$tempTermLevel = $ENV{LOG_PRINT} ? DEBUG : $this->{termLevel};
|
||||
} elsif ( defined($options{termLevel}) ) {
|
||||
$tempFileLevel = $options{termLevel};
|
||||
} else {
|
||||
$tempFileLevel = $ZoneMinder::Config::Config{ZM_LOG_LEVEL_TERM};
|
||||
}
|
||||
if ( defined($options{databaseLevel}) ) {
|
||||
$tempDatabaseLevel = $options{databaseLevel};
|
||||
} else {
|
||||
@@ -271,10 +278,6 @@ sub initialise( @ ) {
|
||||
$tempSyslogLevel = $ZoneMinder::Config::Config{ZM_LOG_LEVEL_SYSLOG};
|
||||
}
|
||||
|
||||
if ( defined($ENV{LOG_PRINT}) ) {
|
||||
$tempTermLevel = $ENV{LOG_PRINT}? DEBUG : NOLOG;
|
||||
}
|
||||
|
||||
my $level;
|
||||
$tempLevel = $level if defined($level = $this->getTargettedEnv('LOG_LEVEL'));
|
||||
$tempTermLevel = $level if defined($level = $this->getTargettedEnv('LOG_LEVEL_TERM'));
|
||||
|
||||
@@ -205,7 +205,7 @@ void zm_dump_codecpar(const AVCodecParameters *par);
|
||||
#ifndef DBG_OFF
|
||||
# define ZM_DUMP_PACKET(pkt, text) \
|
||||
if (pkt) { Debug(2, "%s: pts: %" PRId64 ", dts: %" PRId64 \
|
||||
", size: %d, stream_index: %d, flags: %04x, keyframe(%d) pos: %" PRId64 ", duration: %" AV_PACKET_DURATION_FMT, \
|
||||
", size: %d, stream_index: %d, flags: %04x, keyframe: %d pos: %" PRId64 ", duration: %" AV_PACKET_DURATION_FMT, \
|
||||
text,\
|
||||
pkt->pts,\
|
||||
pkt->dts,\
|
||||
|
||||
@@ -130,6 +130,8 @@ void Logger::initialise(const std::string &id, const Options &options) {
|
||||
|
||||
if ( options.mTerminalLevel != NOOPT )
|
||||
tempTerminalLevel = options.mTerminalLevel;
|
||||
else
|
||||
tempTerminalLevel = config.log_level_term >= DEBUG1 ? DEBUG9 : config.log_level_term;
|
||||
|
||||
// DEBUG1 == 1. So >= DEBUG1, we set to DEBUG9?! Why? icon: because log_level_database only goes up to debug.
|
||||
Level tempDatabaseLevel;
|
||||
@@ -156,7 +158,6 @@ void Logger::initialise(const std::string &id, const Options &options) {
|
||||
|
||||
if ( (envPtr = getTargettedEnv("LOG_LEVEL")) )
|
||||
tempLevel = atoi(envPtr);
|
||||
|
||||
if ( (envPtr = getTargettedEnv("LOG_LEVEL_TERM")) )
|
||||
tempTerminalLevel = atoi(envPtr);
|
||||
if ( (envPtr = getTargettedEnv("LOG_LEVEL_DATABASE")) )
|
||||
|
||||
@@ -580,7 +580,7 @@ void Monitor::Load(MYSQL_ROW dbrow, bool load_zones=true, Purpose p = QUERY) {
|
||||
col++;
|
||||
packetqueue.setPreEventVideoPackets(pre_event_count);
|
||||
packetqueue.setMaxVideoPackets(max_image_buffer_count);
|
||||
packetqueue.setKeepKeyframes(videowriter == PASSTHROUGH || recording != RECORDING_NONE);
|
||||
packetqueue.setKeepKeyframes((videowriter == PASSTHROUGH) && (recording != RECORDING_NONE));
|
||||
post_event_count = atoi(dbrow[col]);
|
||||
col++;
|
||||
stream_replay_buffer = atoi(dbrow[col]);
|
||||
@@ -1964,8 +1964,8 @@ bool Monitor::Analyse() {
|
||||
noteSetMap[MOTION_CAUSE] = noteSet;
|
||||
cause += "ONVIF";
|
||||
// If the camera isn't going to send an event close, we need to close it here, but only after it has actually triggered an alarm.
|
||||
if (!Event_Poller_Closes_Event && state == ALARM)
|
||||
onvif->setAlarmed(false);
|
||||
//if (!Event_Poller_Closes_Event && state == ALARM)
|
||||
//onvif->setAlarmed(false);
|
||||
} // end ONVIF_Trigger
|
||||
} // end if (onvif_event_listener && Event_Poller_Healthy)
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,19 @@
|
||||
#include "zm_monitor.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
|
||||
std::string SOAP_STRINGS[] = {
|
||||
"SOAP_OK", // 0
|
||||
"SOAP_CLI_FAULT", // 1
|
||||
"SOAP_SVR_FAULT",// 2
|
||||
"SOAP_TAG_MISMATCH",// 3
|
||||
"SOAP_TYPE",// 4
|
||||
"SOAP_SYNTAX_ERROR",// 5
|
||||
"SOAP_NO_TAG",// 6
|
||||
"SOAP_IOB",// 7
|
||||
"SOAP_MUSTUNDERSTAND",// 8
|
||||
};
|
||||
|
||||
Monitor::ONVIF::ONVIF(Monitor *parent_) :
|
||||
parent(parent_)
|
||||
@@ -78,13 +91,30 @@ void Monitor::ONVIF::start() {
|
||||
proxyEvent.soap_endpoint = full_url.c_str();
|
||||
set_credentials(soap);
|
||||
const char *RequestMessageID = parent->soap_wsa_compl ? soap_wsa_rand_uuid(soap) : "RequestMessageID";
|
||||
|
||||
if ((!parent->soap_wsa_compl) || (soap_wsa_request(soap, RequestMessageID, proxyEvent.soap_endpoint, "CreatePullPointSubscriptionRequest") == SOAP_OK)) {
|
||||
Debug(1, "ONVIF Endpoint: %s", proxyEvent.soap_endpoint);
|
||||
int rc = proxyEvent.CreatePullPointSubscription(&request, response);
|
||||
#if 0
|
||||
std::stringstream ss;
|
||||
soap->os = &ss; // assign a stringstream to write output to
|
||||
soap_write__tev__CreatePullPointSubscriptionResponse(soap, &response);
|
||||
soap->os = NULL; // no longer writing to the stream
|
||||
Debug(1, "Response was %s", ss.str().c_str());
|
||||
#endif
|
||||
|
||||
if (rc != SOAP_OK) {
|
||||
const char *detail = soap_fault_detail(soap);
|
||||
Error("ONVIF Couldn't create subscription! %d, fault:%s, detail:%s", rc, soap_fault_string(soap), detail ? detail : "null");
|
||||
|
||||
std::stringstream ss;
|
||||
std::ostream *old_stream = soap->os;
|
||||
soap->os = &ss; // assign a stringstream to write output to
|
||||
proxyEvent.CreatePullPointSubscription(&request, response);
|
||||
soap_write__tev__CreatePullPointSubscriptionResponse(soap, &response);
|
||||
soap->os = old_stream; // no longer writing to the stream
|
||||
Debug(1, "Response was %s", ss.str().c_str());
|
||||
|
||||
_wsnt__Unsubscribe wsnt__Unsubscribe;
|
||||
_wsnt__UnsubscribeResponse wsnt__UnsubscribeResponse;
|
||||
proxyEvent.Unsubscribe(response.SubscriptionReference.Address, nullptr, &wsnt__Unsubscribe, wsnt__UnsubscribeResponse);
|
||||
@@ -93,11 +123,19 @@ void Monitor::ONVIF::start() {
|
||||
soap_free(soap);
|
||||
soap = nullptr;
|
||||
} else {
|
||||
#if 0
|
||||
std::stringstream ss;
|
||||
soap->os = &ss; // assign a stringstream to write output to
|
||||
int rc = proxyEvent.CreatePullPointSubscription(&request, response);
|
||||
soap_write__tev__CreatePullPointSubscriptionResponse(soap, &response);
|
||||
soap->os = NULL; // no longer writing to the stream
|
||||
Debug(1, "Response was %s", ss.str().c_str());
|
||||
#endif
|
||||
//Empty the stored messages
|
||||
set_credentials(soap);
|
||||
|
||||
RequestMessageID = parent->soap_wsa_compl ? soap_wsa_rand_uuid(soap):nullptr;
|
||||
if ((!parent->soap_wsa_compl) || (soap_wsa_request(soap, RequestMessageID, response.SubscriptionReference.Address, "PullMessageRequest") == SOAP_OK)) {
|
||||
RequestMessageID = parent->soap_wsa_compl ? soap_wsa_rand_uuid(soap) : nullptr;
|
||||
if ((!parent->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, nullptr, &tev__PullMessages, tev__PullMessagesResponse) != SOAP_OK) &&
|
||||
(soap->error != SOAP_EOF)
|
||||
@@ -162,14 +200,32 @@ void Monitor::ONVIF::WaitForMessage() {
|
||||
int result = proxyEvent.PullMessages(response.SubscriptionReference.Address, nullptr, &tev__PullMessages, tev__PullMessagesResponse);
|
||||
if (result != SOAP_OK) {
|
||||
const char *detail = soap_fault_detail(soap);
|
||||
Debug(1, "Result of getting ONVIF result=%d soap_fault_string=%s detail=%s",
|
||||
Debug(1, "Result of getting ONVIF PullMessageRequest result=%d soap_fault_string=%s detail=%s",
|
||||
result, soap_fault_string(soap), detail ? detail : "null");
|
||||
|
||||
if (result != SOAP_EOF) { //Ignore the timeout error
|
||||
Error("Failed to get ONVIF messages! %d %s", result, soap_fault_string(soap));
|
||||
|
||||
std::ostream *old_stream = soap->os;
|
||||
std::stringstream ss;
|
||||
soap->os = &ss; // assign a stringstream to write output to
|
||||
set_credentials(soap);
|
||||
proxyEvent.PullMessages(response.SubscriptionReference.Address, nullptr, &tev__PullMessages, tev__PullMessagesResponse);
|
||||
soap_write__tev__PullMessagesResponse(soap, &tev__PullMessagesResponse);
|
||||
soap->os = old_stream; // no longer writing to the stream
|
||||
Debug(1, "Response was %s", ss.str().c_str());
|
||||
|
||||
// healthy = false;
|
||||
}
|
||||
} else {
|
||||
Debug(1, "ONVIF polling : Got Good Response! %i", result);
|
||||
if (!tev__PullMessagesResponse.wsnt__NotificationMessage.size()) {
|
||||
if (!parent->Event_Poller_Closes_Event and alarmed) {
|
||||
alarmed = false;
|
||||
alarms.clear();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto msg : tev__PullMessagesResponse.wsnt__NotificationMessage) {
|
||||
if ((msg->Topic != nullptr) &&
|
||||
(msg->Topic->__any.text != nullptr) &&
|
||||
@@ -207,9 +263,9 @@ void Monitor::ONVIF::WaitForMessage() {
|
||||
if (!alarmed) {
|
||||
Info("Triggered Start Event on ONVIF");
|
||||
alarmed = true;
|
||||
// Why sleep?
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1)); //thread sleep
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
Debug(1, "ONVIF Alarms count is %zu, alarmed is %s", alarms.size(), alarmed ? "true": "false");
|
||||
|
||||
@@ -182,14 +182,9 @@ bool PacketQueue::queuePacket(std::shared_ptr<ZMPacket> add_packet) {
|
||||
it = this->deletePacket(it);
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
it ++;
|
||||
//this->deletePacket(it);
|
||||
|
||||
//if (zm_packet->packet->stream_index == video_stream_id)
|
||||
//break;
|
||||
} // end if erasing a whole gop
|
||||
} // end while
|
||||
++it;
|
||||
} // end foreach
|
||||
} else if (warned_count > 0) {
|
||||
warned_count--;
|
||||
} // end if not able catch up
|
||||
@@ -280,7 +275,7 @@ void PacketQueue::clearPackets(const std::shared_ptr<ZMPacket> &add_packet) {
|
||||
if (!lp.trylock()) break;
|
||||
|
||||
if (is_there_an_iterator_pointing_to_packet(zm_packet)) {
|
||||
Warning("Found iterator at beginning of queue. Some thread isn't keeping up");
|
||||
Debug(1, "Found iterator at beginning of queue.");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -734,8 +729,9 @@ void PacketQueue::free_it(packetqueue_iterator *it) {
|
||||
iterators_it != iterators.end();
|
||||
++iterators_it
|
||||
) {
|
||||
if ( *iterators_it == it ) {
|
||||
iterators.erase(iterators_it);
|
||||
if (*iterators_it == it) {
|
||||
delete *iterators_it; // delete the iterator
|
||||
iterators.erase(iterators_it); // this will delete the pointer to it.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,7 +436,9 @@ for ($monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1) {
|
||||
$Server = isset($ServersById[$monitor['ServerId']]) ? $ServersById[$monitor['ServerId']] : new ZM\Server($monitor['ServerId']);
|
||||
echo '<td class="colServer">'.validHtmlStr($Server->Name()).'</td>'.PHP_EOL;
|
||||
}
|
||||
echo '<td class="colSource">'. makeLink( '?view=monitor&mid='.$monitor['Id'], '<span class="'.$source_class.'">'.validHtmlStr($Monitor->Source()).'</span>', $Monitor->canEdit()).'</td>';
|
||||
echo '<td class="colSource">'. makeLink( '?view=monitor&mid='.$monitor['Id'], '<span class="'.$source_class.'">'.validHtmlStr($Monitor->Source()).'</span>', $Monitor->canEdit());
|
||||
echo '<br/>'.$Monitor->Width().'x'.$Monitor->Height();
|
||||
echo '</td>';
|
||||
if ($show_storage_areas) {
|
||||
echo '<td class="colStorage">'.
|
||||
(isset($StorageById[$monitor['StorageId']]) ? validHtmlStr($StorageById[$monitor['StorageId']]->Name()) : ($monitor['StorageId']?'<span class="error">Deleted '.$monitor['StorageId'].'</span>' : '')).'</td>'.PHP_EOL;
|
||||
|
||||
Reference in New Issue
Block a user