Merge branch 'master' of github.com:ZoneMinder/zoneminder

add_janus_rtsp_user
Isaac Connor 2022-09-06 11:22:28 -04:00
commit 1f20b18100
11 changed files with 100 additions and 77 deletions

View File

@ -238,8 +238,18 @@ void PacketQueue::clearPackets(const std::shared_ptr<ZMPacket> &add_packet) {
packetqueue_iterator it = pktQueue.end();
--it;
while (*it != add_packet) {
if ((*it)->packet->stream_index == video_stream_id)
if (!(*it)) {
Error("null packet");
break;
}
if (!((*it)->packet)) {
Error("null av packet");
++tail_count;
} else {
if ((*it)->packet->stream_index == video_stream_id)
++tail_count;
}
--it;
}
}
@ -258,10 +268,11 @@ void PacketQueue::clearPackets(const std::shared_ptr<ZMPacket> &add_packet) {
}
pktQueue.pop_front();
packet_counts[zm_packet->packet->stream_index] -= 1;
int stream_index = zm_packet->packet ? zm_packet->packet->stream_index : 0;
packet_counts[stream_index] -= 1;
Debug(1,
"Deleting a packet with stream index:%d image_index:%d with keyframe:%d, video frames in queue:%d max: %d, queuesize:%zu",
zm_packet->packet->stream_index,
stream_index,
zm_packet->image_index,
zm_packet->keyframe,
packet_counts[video_stream_id],

View File

@ -42,7 +42,7 @@ class Filter extends ZM_Object {
protected $_Terms;
public function sql() {
if ( ! isset($this->_sql) ) {
if (!isset($this->_sql)) {
$this->_sql = '';
foreach ( $this->FilterTerms() as $term ) {
#if ( ! ($term->is_pre_sql() or $term->is_post_sql()) ) {
@ -196,12 +196,12 @@ class Filter extends ZM_Object {
// The following three fields are actually stored in the Query
public function sort_field( ) {
if ( func_num_args( ) ) {
if (func_num_args()) {
$Query = $this->Query();
$Query['sort_field'] = func_get_arg(0);
$this->Query($Query);
}
if ( isset( $this->Query()['sort_field'] ) ) {
if (isset($this->Query()['sort_field'])) {
return $this->{'Query'}['sort_field'];
}
return ZM_WEB_EVENT_SORT_FIELD;
@ -674,11 +674,11 @@ class Filter extends ZM_Object {
}
$where = $this->sql() ? ' WHERE ('.$this->sql().')' : '';
$sort = $this->sort_field() ? $this->sort_field() .' '.$this->sort_asc() : '';
$sort = $this->sort_field() ? $this->sort_field() .' '.($this->sort_asc() ? 'ASC' : 'DESC') : '';
$col_str = 'E.*, M.Name AS Monitor';
$sql = 'SELECT ' .$col_str. ' FROM `Events` AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id'.$where.($sort?' ORDER BY '.$sort:'');
if ($filter->limit() and !count($this->pre_sql_conditions()) and !count($this->post_sql_conditions())) {
if ($this->limit() and !count($this->pre_sql_conditions()) and !count($this->post_sql_conditions())) {
$sql .= ' LIMIT '.$this->limit();
}
@ -687,7 +687,7 @@ class Filter extends ZM_Object {
if (!$query) return $events;
while ($row = dbFetchNext($query)) {
$event = new ZM\Event($row);
$event = new Event($row);
$event->remove_from_cache();
if (!$this->test_post_sql_conditions($event)) {
continue;

View File

@ -77,7 +77,7 @@ class FilterTerm {
switch ( $this->attr ) {
case 'AlarmedZoneId':
$value = '(SELECT * FROM Stats WHERE EventId=E.Id AND ZoneId='.$value.' AND Score > 0)';
$value = '(SELECT * FROM Stats WHERE EventId=E.Id AND ZoneId='.$value.' AND Score > 0 LIMIT 1)';
break;
case 'ExistsInFileSystem':
$value = '';

View File

@ -8,6 +8,7 @@ class Group extends ZM_Object {
'Name' => array('type'=>'text','filter_regexp'=>'/[^\w\-\.\(\)\:\/ ]/', 'default'=>'Group'),
'ParentId' => null,
);
protected static $monitor_ids_cache = array();
public static function find( $parameters = array(), $options = array() ) {
return ZM_Object::_find(get_class(), $parameters, $options);
@ -47,7 +48,10 @@ class Group extends ZM_Object {
public function MonitorIds( ) {
if ( ! property_exists($this, 'MonitorIds') ) {
$this->{'MonitorIds'} = dbFetchAll('SELECT `MonitorId` FROM `Groups_Monitors` WHERE `GroupId`=?', 'MonitorId', array($this->{'Id'}));
if (!isset($monitor_ids_cache[$this->{'Id'}])) {
$monitor_ids_cache[$this->{'Id'}] = dbFetchAll('SELECT `MonitorId` FROM `Groups_Monitors` WHERE `GroupId`=?', 'MonitorId', array($this->{'Id'}));
}
$this->{'MonitorIds'} = &$monitor_ids_cache[$this->{'Id'}];
}
return $this->{'MonitorIds'};
}
@ -77,7 +81,7 @@ class Group extends ZM_Object {
public static function get_dropdown_options() {
$Groups = array();
foreach ( Group::find(array(), array('order'=>'lower(Name)')) as $Group ) {
if ($Group->canView()) $Groups[$Group->Id()] = $Group;
if ($Group->canView()) $Groups[$Group->Id()] = $Group;
}
# This array is indexed by parent_id
@ -138,75 +142,80 @@ class Group extends ZM_Object {
} else if ( isset($_COOKIE['zmMonitorId']) ) {
$monitor_id = $_COOKIE['zmMonitorId'];
}
$sql = 'SELECT `Id`,`Name` FROM `Monitors`';
if ( $options ) {
$sql .= ' WHERE '. implode(' AND ', array(
( isset($options['groupSql']) ? $options['groupSql']:'')
) ).' ORDER BY `Sequence` ASC';
}
$monitors_dropdown = array(''=>'All');
$sql = 'SELECT `Id`,`Name` FROM `Monitors`';
if ( $options ) {
$sql .= ' WHERE '. implode(' AND ', array(
( isset($options['groupSql']) ? $options['groupSql']:'')
) ).' ORDER BY `Sequence` ASC';
}
$monitors_dropdown = array(''=>'All');
foreach ( dbFetchAll($sql) as $monitor ) {
if ( !visibleMonitor($monitor['Id']) ) {
continue;
}
$monitors_dropdown[$monitor['Id']] = $monitor['Name'];
}
foreach ( dbFetchAll($sql) as $monitor ) {
if ( !visibleMonitor($monitor['Id']) ) {
continue;
}
$monitors_dropdown[$monitor['Id']] = $monitor['Name'];
}
echo htmlSelect('monitor_id', $monitors_dropdown, $monitor_id, array('data-on-change-this'=>'changeMonitor'));
return $monitor_id;
}
echo htmlSelect('monitor_id', $monitors_dropdown, $monitor_id, array('data-on-change-this'=>'changeMonitor'));
return $monitor_id;
}
public function Parent( ) {
if ( $this->{'ParentId'} ) {
return Group::find_one(array('Id'=>$this->{'ParentId'}));
}
return null;
}
public function Parent( ) {
if ( $this->{'ParentId'} ) {
return Group::find_one(array('Id'=>$this->{'ParentId'}));
}
return null;
}
public function Parents() {
$Parents = array();
$Parent = $this->Parent();
public function Parents() {
$Parents = array();
$Parent = $this->Parent();
$seen_parents = array();
while ($Parent) {
while ($Parent) {
$seen_parents[$Parent->Id()] = $Parent;
array_unshift($Parents, $Parent);
$Parent = $Parent->Parent();
array_unshift($Parents, $Parent);
$Parent = $Parent->Parent();
if ($Parent and isset($seen_parents[$Parent->Id()])) {
Warning("Detected hierarchy loop in group {$Parent->Name()}");
break;
}
}
return $Parents;
}
public function Children() {
if (!property_exists($this, 'Children')) {
$this->{'Children'} = Group::find(array('ParentId'=>$this->Id()));
}
return $this->{'Children'};
}
public function Monitors() {
}
return $Parents;
}
public function Children() {
if (!property_exists($this, 'Children')) {
$this->{'Children'} = Group::find(array('ParentId'=>$this->Id()));
}
return $this->{'Children'};
}
public function Monitors() {
if (!property_exists($this, 'Monitors') ) {
$this->{'Monitors'} = Monitor::find(array('Id'=>$this->MonitorIds()));
}
return $this->{'Monitors'};
}
$monitor_ids = $this->MonitorIds();
if (count($monitor_ids)) {
$this->{'Monitors'} = Monitor::find(array('Id'=>$monitor_ids));
} else {
$this->{'Monitors'} = array();
}
}
return $this->{'Monitors'};
}
public function canView($u=null) {
global $user;
if (!$u) $u = $user;
public function canView($u=null) {
global $user;
if (!$u) $u = $user;
if (!count($this->Monitors()) and !count($this->Children())) {
return true;
}
# Can view if we can view any of the monitors in it.
foreach ($this->Monitors() as $monitor) {
if ($monitor->canView($u)) return true;
}
foreach ($this->Children() as $child) {
if ($child->canView($u)) return true;
}
# Can view if we can view any of the monitors in it.
foreach ($this->Monitors() as $monitor) {
if ($monitor->canView($u)) return true;
}
foreach ($this->Children() as $child) {
if ($child->canView($u)) return true;
}
return false;
}
return false;
}
} # end class Group
?>

View File

@ -59,7 +59,7 @@ class Zone extends ZM_Object {
}
public function svg_polygon() {
return '<polygon points="'.$this->AreaCoords().'" class="'.$this->Type().'" data-mid="'.$this->MonitorId().'" data-zid="'.$this->Id().'"/>';
return '<polygon points="'.$this->AreaCoords().'" class="'.$this->Type().'" data-mid="'.$this->MonitorId().'" data-zid="'.$this->Id().'"><title>'.$this->Name().'</title></polygon>';
}
} # end class Zone
?>

View File

@ -62,6 +62,7 @@ if ($action == 'save') {
}
}
$newMonitor['ManufacturerId'] = $newManufacturer->Id();
unset($newMonitor['Manufacturer']);
}
if (!$newMonitor['ModelId'] and ($newMonitor['Model'] != '')) {
@ -77,6 +78,7 @@ if ($action == 'save') {
}
}
$newMonitor['ModelId'] = $newModel->Id();
unset($newMonitor['Model']);
}
$monitor = new ZM\Monitor($mid);

View File

@ -175,8 +175,8 @@ hr {
height: 1px;
width: 100%;
border: 0;
color: #7f7fb2;
background-color: #7f7fb2;
color: #3498db;
background-color: #3498db;
}
/*

View File

@ -73,8 +73,11 @@ min-width: 500px;
}
#ActionsAndOptions {
padding-top: 5px;
border-top: 1px solid #7f7fb2;
border-bottom: 1px solid #7f7fb2;
border-top: 1px solid #3498db;
border-bottom: 1px solid #3498db;
}
#ActionsAndOptions fieldset {
border: none;
}
#ActionsAndOptions:after {
content: ".";

View File

@ -55,8 +55,6 @@ img.normal {
}
hr {
color: #8f8fc2;
background-color: #8f8fc2;
}
ul.tabList li {
@ -227,4 +225,4 @@ ul.nav.nav-pills.flex-column {
.thead-highlight {
background-color:#485460;
}
}

View File

@ -155,8 +155,8 @@ while ( $event_row = dbFetchNext($results) ) {
<td class="colMonitorName"><?php echo makeLink('?view=monitor&amp;mid='.$event->MonitorId(), $event->MonitorName(), canEdit('Monitors')) ?></td>
<td class="colCause"><?php echo makeLink($event_link, validHtmlStr($event->Cause()), canView('Events'), 'title="' .htmlspecialchars($event->Notes()). '" class="eDetailLink" data-eid="'.$event->Id().'"') ?></td>
<td class="colTime"><?php echo $dateTimeFormatter->format(strtotime($event->StartDateTime())) .
( $event->EndDateTime() ? ' until ' . $dateTimeFormater->format(strtotime($event->EndDateTime())) : '' ) ?></td>
<td class="colDuration"><?php echo gmdate('H:i:s', $event->Length()) ?></td>
( $event->EndDateTime() ? ' until ' . $dateTimeFormatter->format(strtotime($event->EndDateTime())) : '' ) ?></td>
<td class="colDuration"><?php echo gmdate('H:i:s', intval($event->Length())) ?></td>
<td class="colFrames"><?php echo makeLink('?view=frames&amp;eid='.$event->Id(), $event->Frames()) ?></td>
<td class="colAlarmFrames"><?php echo makeLink('?view=frames&amp;eid='.$event->Id(), $event->AlarmFrames()) ?></td>
<td class="colTotScore"><?php echo $event->TotScore() ?></td>

View File

@ -428,7 +428,7 @@ if (canEdit('Monitors')) {
<!-- BEGIN ITEM LIST -->
<div class="d-flex flex-row container-fluid pr-0">
<form name="contentForm" id="contentForm" method="post" action="?view=monitor">
<form name="contentForm" id="contentForm" method="post" action="?view=monitor" autocomplete="off">
<input type="hidden" name="tab" value="<?php echo $tab?>"/>
<input type="hidden" name="mid" value="<?php echo $monitor->Id() ? $monitor->Id() : $mid ?>"/>
<input type="hidden" name="origMethod" value="<?php echo (null !== $monitor->Method())?validHtmlStr($monitor->Method()):'' ?>"/>