Merge branch 'master' into replace_function_concept

This commit is contained in:
Isaac Connor 2022-02-12 22:17:47 -05:00
commit 485cc26065
22 changed files with 254 additions and 138 deletions

View File

@ -5,6 +5,7 @@ web/api/lib
web/includes/csrf/ web/includes/csrf/
web/js/videojs.zoomrotate.js web/js/videojs.zoomrotate.js
web/skins/classic/js/bootstrap-4.5.0.js web/skins/classic/js/bootstrap-4.5.0.js
web/skins/classic/js/bootstrap.bundle.min.js
web/skins/classic/js/chosen web/skins/classic/js/chosen
web/skins/classic/js/dateTimePicker web/skins/classic/js/dateTimePicker
web/skins/classic/js/jquery-*.js web/skins/classic/js/jquery-*.js

View File

@ -42,7 +42,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
,libswscale5|libswscale4 ,libswscale5|libswscale4
,libswresample3|libswresample2 ,libswresample3|libswresample2
,ffmpeg ,ffmpeg
,libcurl4 ,libcurl4, libcurl4-gnutls-dev
,libdatetime-perl, libdate-manip-perl, libmime-lite-perl, libmime-tools-perl ,libdatetime-perl, libdate-manip-perl, libmime-lite-perl, libmime-tools-perl
,libdbd-mysql-perl ,libdbd-mysql-perl
,libphp-serialization-perl ,libphp-serialization-perl

View File

@ -95,6 +95,7 @@ void Image::update_function_pointers() {
delta8_abgr = &std_delta8_abgr; delta8_abgr = &std_delta8_abgr;
delta8_gray8 = &std_delta8_gray8; delta8_gray8 = &std_delta8_gray8;
blend = &std_blend; blend = &std_blend;
Warning("Using slow std functions");
} else { } else {
// Use either sse or neon, or loop unrolled version // Use either sse or neon, or loop unrolled version
delta8_rgb = fptr_delta8_rgb; delta8_rgb = fptr_delta8_rgb;
@ -1737,7 +1738,6 @@ void Image::Overlay( const Image &image, const unsigned int lo_x, const unsigned
} // end void Image::Overlay( const Image &image, unsigned int x, unsigned int y ) } // end void Image::Overlay( const Image &image, unsigned int x, unsigned int y )
void Image::Blend( const Image &image, int transparency ) { void Image::Blend( const Image &image, int transparency ) {
uint8_t* new_buffer;
if ( !( if ( !(
width == image.width && height == image.height width == image.width && height == image.height
@ -1751,7 +1751,7 @@ void Image::Blend( const Image &image, int transparency ) {
if ( transparency <= 0 ) if ( transparency <= 0 )
return; return;
new_buffer = AllocBuffer(size); uint8_t* new_buffer = AllocBuffer(size);
#ifdef ZM_IMAGE_PROFILING #ifdef ZM_IMAGE_PROFILING
TimePoint start = std::chrono::steady_clock::now(); TimePoint start = std::chrono::steady_clock::now();
@ -3397,6 +3397,7 @@ __attribute__((noinline)) void neon64_armv8_fastblend(const uint8_t* col1, const
} }
__attribute__((noinline)) void std_blend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) { __attribute__((noinline)) void std_blend(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count, double blendpercent) {
Warning("Using slow std_blend");
double divide = blendpercent / 100.0; double divide = blendpercent / 100.0;
double opacity = 1.0 - divide; double opacity = 1.0 - divide;
const uint8_t* const max_ptr = result + count; const uint8_t* const max_ptr = result + count;

View File

@ -387,6 +387,7 @@ function getFrameImage() {
$sql = 'SELECT * FROM Frames WHERE EventId = ? AND FrameId = ?'; $sql = 'SELECT * FROM Frames WHERE EventId = ? AND FrameId = ?';
if ( !($frame = dbFetchOne($sql, NULL, array($eventId, $frameId))) ) { if ( !($frame = dbFetchOne($sql, NULL, array($eventId, $frameId))) ) {
ZM\Error("Frame not found for event $eventId frame $frameId");
$frame = array(); $frame = array();
$frame['EventId'] = $eventId; $frame['EventId'] = $eventId;
$frame['FrameId'] = $frameId; $frame['FrameId'] = $frameId;

View File

@ -24,6 +24,8 @@ if ( !canEdit('System') ) {
return; return;
} }
global $error_message;
if ( $action == 'delete' ) { if ( $action == 'delete' ) {
if ( isset($_REQUEST['object']) ) { if ( isset($_REQUEST['object']) ) {
if ( $_REQUEST['object'] == 'server' ) { if ( $_REQUEST['object'] == 'server' ) {
@ -65,10 +67,19 @@ if ( $action == 'delete' ) {
} }
if ( isset($newValue) && ($newValue != $config['Value']) ) { if ( isset($newValue) && ($newValue != $config['Value']) ) {
# Handle special cases first
if ($config['Name'] == 'ZM_LANG_DEFAULT') {
# Verify that the language file exists in the lang directory.
if (!file_exists(ZM_PATH_WEB.'/lang/'.$newValue.'.php')) {
$error_message .= 'Error setting ' . $config['Name'].'. New value ' .$newValue.' not saved because '.ZM_PATH_WEB.'/lang/'.$newValue.'.php doesn\'t exist.<br/>';
ZM\Error($error_message);
continue;
}
}
dbQuery('UPDATE Config SET Value=? WHERE Name=?', array($newValue, $config['Name'])); dbQuery('UPDATE Config SET Value=? WHERE Name=?', array($newValue, $config['Name']));
$changed = true; $changed = true;
} } # end if value changed
} } # end foreach config entry
if ( $changed ) { if ( $changed ) {
switch ( $_REQUEST['tab'] ) { switch ( $_REQUEST['tab'] ) {
case 'system' : case 'system' :

View File

@ -44,12 +44,21 @@ if ($action == 'Save') {
} else { } else {
unset($_REQUEST['newUser']['Password']); unset($_REQUEST['newUser']['Password']);
} }
if (isset($_REQUEST['newUser']['Language']) and $_REQUEST['newUser']['Language']) {
# Verify that the language file exists in the lang directory.
if (!file_exists(ZM_PATH_WEB.'/lang/'.$_REQUEST['newUser']['Language'].'.php')) {
$error_message .= 'Error setting Language. New value ' .$_REQUEST['newUser']['Language'].' not saved because '.ZM_PATH_WEB.'/lang/'.$_REQUEST['newUser']['Language'].'.php doesn\'t exist.<br/>';
ZM\Error($error_message);
unset($_REQUEST['newUser']['Language']);
unset($_REQUEST['redirect']);
}
}
$changes = $dbUser->changes($_REQUEST['newUser']); $changes = $dbUser->changes($_REQUEST['newUser']);
ZM\Debug("Changes: " . print_r($changes, true)); ZM\Debug('Changes: ' . print_r($changes, true));
if (count($changes)) { if (count($changes)) {
if (!$dbUser->save($changes)) { if (!$dbUser->save($changes)) {
$error_message = $dbUser->get_last_error(); $error_message .= $dbUser->get_last_error().'<br/>';
unset($_REQUEST['redirect']); unset($_REQUEST['redirect']);
return; return;
} }
@ -73,6 +82,15 @@ if ($action == 'Save') {
} else { } else {
unset($_REQUEST['newUser']['Password']); unset($_REQUEST['newUser']['Password']);
} }
if (isset($_REQUEST['newUser']['Language']) and $_REQUEST['newUser']['Language']) {
# Verify that the language file exists in the lang directory.
if (!file_exists(ZM_PATH_WEB.'/lang/'.$_REQUEST['newUser']['Language'].'.php')) {
$error_message .= 'Error setting Language. New value ' .$_REQUEST['newUser']['Language'].' not saved because '.ZM_PATH_WEB.'/lang/'.$_REQUEST['newUser']['Language'].'.php doesn\'t exist.<br/>';
ZM\Error($error_message);
unset($_REQUEST['newUser']['Language']);
unset($_REQUEST['redirect']);
}
}
$fields = array('Password'=>'', 'Language'=>'', 'HomeView'=>''); $fields = array('Password'=>'', 'Language'=>'', 'HomeView'=>'');
ZM\Debug("changes: ".print_r(array_intersect_key($_REQUEST['newUser'], $fields),true)); ZM\Debug("changes: ".print_r(array_intersect_key($_REQUEST['newUser'], $fields),true));
$changes = $dbUser->changes(array_intersect_key($_REQUEST['newUser'], $fields)); $changes = $dbUser->changes(array_intersect_key($_REQUEST['newUser'], $fields));
@ -80,7 +98,7 @@ if ($action == 'Save') {
if (count($changes)) { if (count($changes)) {
if (!$dbUser->save($changes)) { if (!$dbUser->save($changes)) {
$error_message = $dbUser->get_last_error(); $error_message .= $dbUser->get_last_error();
unset($_REQUEST['redirect']); unset($_REQUEST['redirect']);
return; return;
} }

View File

@ -34,7 +34,8 @@ function loadLanguage($prefix='') {
$prefix = $prefix.'/'; $prefix = $prefix.'/';
if (isset($user['Language']) and $user['Language']) { if (isset($user['Language']) and $user['Language']) {
$userLangFile = $prefix.'lang/'.$user['Language'].'.php'; # Languages can only have letters, numbers and underscore
$userLangFile = $prefix.'lang/'.preg_replace('/[^[:alnum:]_]+/', '', $user['Language']).'.php';
if (file_exists($userLangFile)) { if (file_exists($userLangFile)) {
return $userLangFile; return $userLangFile;
@ -43,7 +44,7 @@ function loadLanguage($prefix='') {
} }
} }
$systemLangFile = $prefix.'lang/'.ZM_LANG_DEFAULT.'.php'; $systemLangFile = $prefix.'lang/'.preg_replace('/[^[:alnum:]_]+/', '', ZM_LANG_DEFAULT).'.php';
if ( file_exists($systemLangFile) ) { if ( file_exists($systemLangFile) ) {
return $systemLangFile; return $systemLangFile;
} else { } else {

View File

@ -340,6 +340,14 @@ ul.tabList li.active a {
.alarm, .errorText, .error { .alarm, .errorText, .error {
color: #ff3f34; color: #ff3f34;
} }
/* Refers to the error box at the top of the web UI */
#error {
width: 100%;
padding: 5px;
font-weight: bold;
background-color: white;
color: #ff3f34;
}
.timedErrorBox { .timedErrorBox {
color:white; color:white;

View File

@ -36,18 +36,23 @@
#topPanel { #topPanel {
position: relative; position: relative;
height: 220px; min-height: 220px;
margin: 4px auto 6px; margin: 4px auto 6px;
} }
#topPanel:after {
content: ".";
display: block;
height: 0;
font-size: 0;
clear: both;
visibility: hidden;
}
#topPanel #imagePanel #topPanel .imagePanel {
{
width: 50%;
float: left;
text-align: right; text-align: right;
} }
#topPanel #image { #topPanel .image {
margin: 0 auto; margin: 0 auto;
text-align: right; text-align: right;
margin-right: 2px; margin-right: 2px;
@ -57,7 +62,7 @@
width: 100%; width: 100%;
} }
#topPanel #image img { #topPanel .image img {
width: auto; width: auto;
max-width: 100%; max-width: 100%;
height: 100%; height: 100%;
@ -66,6 +71,7 @@
bottom: 0; bottom: 0;
left: 0; left: 0;
right: 0; right: 0;
margin: 0 auto;
} }
#topPanel #dataPanel { #topPanel #dataPanel {
@ -89,6 +95,7 @@
} }
#topPanel #navPanel { #topPanel #navPanel {
float: left;
width: 100%; width: 100%;
height: 70px; height: 70px;
margin: 4px auto; margin: 4px auto;

View File

@ -8,7 +8,9 @@
.chartSize { .chartSize {
height: <?php echo $chart['height'] ?>px; /*
min-height: <?php echo $chart['height'] ?>px;
*/
} }
.graphSize { .graphSize {

View File

@ -169,7 +169,7 @@ function getBodyTopHTML() {
'; ';
global $error_message; global $error_message;
if ( $error_message ) { if ( $error_message ) {
echo '<div class="error">'.$error_message.'</div>'; echo '<div id="error">'.$error_message.'</div>';
} }
} // end function getBodyTopHTML } // end function getBodyTopHTML
@ -203,7 +203,7 @@ function getNormalNavBarHTML($running, $user, $bandwidth_options, $view, $skin)
$status = runtimeStatus($running); $status = runtimeStatus($running);
?> ?>
<div class="fixed-top container-fluid p-0"> <div class="container-fluid p-0">
<nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-center flex-row"> <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-center flex-row">
<div class="navbar-brand justify-content-start align-self-start"> <div class="navbar-brand justify-content-start align-self-start">

View File

@ -1 +1 @@
bootstrap.min.js bootstrap-4.5.0.min.js

View File

@ -193,5 +193,11 @@ xhtmlHeaders(__FILE__, translate('CycleWatch'));
</div> </div>
</div> </div>
<script src="<?php echo cache_bust('js/adapter.min.js') ?>"></script> <script src="<?php echo cache_bust('js/adapter.min.js') ?>"></script>
<?php
if ( $monitor->JanusEnabled() ) {
?>
<script src="/javascript/janus/janus.js"></script> <script src="/javascript/janus/janus.js"></script>
<?php
}
?>
<?php xhtmlFooter() ?> <?php xhtmlFooter() ?>

View File

@ -86,7 +86,7 @@ $limitQuery = '';
if ( $user['MonitorIds'] ) { if ( $user['MonitorIds'] ) {
$user_monitor_ids = ' M.Id in ('.$user['MonitorIds'].')'; $user_monitor_ids = ' M.Id in ('.$user['MonitorIds'].')';
$eventsSql .= $user_monitor_ids; $eventsSql .= $user_monitor_ids;
} else { } else if ( !isset($_REQUEST['filter']) ) {
$eventsSql .= ' 1'; $eventsSql .= ' 1';
} }
@ -98,7 +98,7 @@ if ( isset($_REQUEST['eid']) and $_REQUEST['eid'] ) {
$eventsValues += $_REQUEST['eids']; $eventsValues += $_REQUEST['eids'];
} else if ( isset($_REQUEST['filter']) ) { } else if ( isset($_REQUEST['filter']) ) {
parseSort(); parseSort();
$filter = Filter::parse($_REQUEST['filter']); $filter = ZM\Filter::parse($_REQUEST['filter']);
$filterQuery = $filter->querystring(); $filterQuery = $filter->querystring();
if ( $filter->sql() ) { if ( $filter->sql() ) {

View File

@ -1,4 +1,3 @@
var events = {};
function showEvent(e) { function showEvent(e) {
var eid = e.getAttribute('data-event-id'); var eid = e.getAttribute('data-event-id');
@ -58,35 +57,35 @@ function frameDataResponse( respObj, respText ) {
} }
if (!zm_event['frames']) { if (!zm_event['frames']) {
console.log('No frames data in event response');
console.log(zm_event);
console.log(respObj);
zm_event['frames'] = {}; zm_event['frames'] = {};
} }
zm_event['frames'][frame.FrameId] = frame; zm_event['frames'][frame.FrameId] = frame;
zm_event['frames'][frame.FrameId]['html'] = createEventHtml( zm_event, frame ); zm_event['frames'][frame.FrameId]['html'] = createEventHtml( zm_event, frame );
showEventData(frame.EventId, frame.FrameId); showEventData(zm_event, frame.FrameId);
} }
function showEventData(eventId, frameId) { function showEventData(zm_event, frameId) {
if ( events[eventId] ) { if (zm_event) {
var zm_event = events[eventId];
if (zm_event['frames']) { if (zm_event['frames']) {
if (zm_event['frames'][frameId]) { if (zm_event['frames'][frameId]) {
showEventDetail( zm_event['frames'][frameId]['html'] ); $j('#instruction').hide();
var imagePath = 'index.php?view=image&eid='+eventId+'&fid='+frameId; eventData = $j('#eventData'+zm_event.MonitorId);
loadEventImage(imagePath, eventId, frameId); eventData.html(zm_event['frames'][frameId]['html']);
eventData.show();
var imagePath = 'index.php?view=image&eid='+zm_event.Id+'&fid='+frameId;
loadEventImage(imagePath, zm_event, frameId);
return; return;
} else { } else {
console.log('No frames for ' + frameId); console.log('No frames for ' + frameId);
} }
} else { } else {
console.log('No frames'); console.log('No frames');
requestFrameData(zm_event.Id, frameId);
} }
} else { } else {
console.log('No event for ' + eventId); console.log('No event');
} }
} }
@ -119,31 +118,38 @@ function previewEvent(slot) {
eventId = slot.getAttribute('data-event-id'); eventId = slot.getAttribute('data-event-id');
frameId = slot.getAttribute('data-frame-id'); frameId = slot.getAttribute('data-frame-id');
if (events[eventId] && events[eventId]['frames'] && events[eventId]['frames'][frameId]) { if (events[eventId] && events[eventId]['frames'] && events[eventId]['frames'][frameId]) {
showEventData(eventId, frameId); showEventData(events[eventId], frameId);
} else { } else {
requestFrameData(eventId, frameId); requestFrameData(eventId, frameId);
} }
} }
function loadEventImage( imagePath, eid, fid ) { function loadEventImage(imagePath, zm_event, fid) {
var eventData = $j('#eventData'); if (!zm_event) {
var imageSrc = $j('#imageSrc'); console.log("No event object passed to loadEventImage");
return;
}
const imageSrc = $j('#imageSrc'+zm_event.MonitorId);
imageSrc.show(); imageSrc.show();
imageSrc.attr('src', imagePath); imageSrc.attr('src', imagePath);
imageSrc.attr('data-event-id', eid); imageSrc.attr('data-event-id', zm_event.Id);
imageSrc.attr('data-frame-id', fid); imageSrc.attr('data-frame-id', fid);
imageSrc.off('click'); imageSrc.off('click');
imageSrc.click(function() { imageSrc.on('click', function() {
showEvent(this); showEvent(this);
}); });
eventData.attr('data-event-id', eid); var eventData = $j('#eventData'+zm_event.MonitorId);
eventData.attr('data-frame-id', fid); if ( eventData.length ) {
eventData.off('click'); eventData.off('click');
eventData.click(function() { eventData.on('click', function() {
showEvent(this); showEvent(this);
}); });
} else {
console.log("No eventdata area found for monitor " + zm_event.MonitorId);
}
} }
function tlZoomBounds(event) { function tlZoomBounds(event) {
@ -204,6 +210,11 @@ function initPage() {
window.location.assign('?view=events'+filterQuery); window.location.assign('?view=events'+filterQuery);
}); });
for (const mid in monitors) {
const monitor = monitors[mid];
showEventData(events[monitor.FirstEventId], 1);
}
// Bind the data-on-click attributes associated with a div // Bind the data-on-click attributes associated with a div
divDataOnClick(); divDataOnClick();
} }

View File

@ -6,10 +6,15 @@
global $maxTime; global $maxTime;
global $range; global $range;
global $majXScale; global $majXScale;
global $monEventSlots;
global $monFrameSlots;
?> ?>
var filterQuery = '<?php echo validJsStr($filterQuery) ?>'; var filterQuery = '<?php echo validJsStr($filterQuery) ?>';
var events = {};
<?php <?php
//ZM\Debug(print_r($monEventSlots, true));
//ZM\Debug(print_r($monFrameSlots, true));
$jsMonitors = array(); $jsMonitors = array();
$fields = array('Name', 'LabelFormat', 'SaveJPEGs', 'VideoWriter'); $fields = array('Name', 'LabelFormat', 'SaveJPEGs', 'VideoWriter');
@ -18,6 +23,11 @@ foreach ( $monitors as $monitor ) {
foreach ($fields as $field) { foreach ($fields as $field) {
$jsMonitor[$field] = $monitor->$field(); $jsMonitor[$field] = $monitor->$field();
} }
$firstEvent = reset($monEventSlots[$monitor->Id()])['event'];
$jsMonitor['FirstEventId'] = $firstEvent['Id'];
echo 'events['.$firstEvent['Id'].']='.json_encode($firstEvent).';'.PHP_EOL;
$jsMonitors[$monitor->Id()] = $jsMonitor; $jsMonitors[$monitor->Id()] = $jsMonitor;
} }
?> ?>
@ -30,3 +40,4 @@ var midTime = '<?php echo $midTime?>';
var maxTime = '<?php echo $maxTime?>'; var maxTime = '<?php echo $maxTime?>';
var range = '<?php echo $range?>'; var range = '<?php echo $range?>';
var zoomout_range = '<?php (int)($range*$majXScale['zoomout']) ?>'; var zoomout_range = '<?php (int)($range*$majXScale['zoomout']) ?>';

View File

@ -807,7 +807,15 @@ function initPage() {
if (monitorType == 'Local') getSettingsModal(); if (monitorType == 'Local') getSettingsModal();
} }
// Only enable the settings button for local cameras // Only enable the settings button for local cameras
settingsBtn.prop('disabled', !(canView.Control && (monitorType == 'Local'))); if (!canView.Control) {
settingsBtn.prop('disabled', true);
settingsBtn.prop('title', 'Disbled due to lack of Control View permission.');
} else if (monitorType != 'Local') {
settingsBtn.prop('disabled', true);
settingsBtn.prop('title', 'Settings only available for Local monitors.');
} else {
settingsBtn.prop('disabled', false);
}
if (monitorType != 'WebSite') { if (monitorType != 'WebSite') {
monitorStream = new MonitorStream(monitorData[monIdx]); monitorStream = new MonitorStream(monitorData[monIdx]);

View File

@ -117,6 +117,7 @@ include('_monitor_filters.php');
$filterbar = ob_get_contents(); $filterbar = ob_get_contents();
ob_end_clean(); ob_end_clean();
$need_janus = false;
$monitors = array(); $monitors = array();
foreach ( $displayMonitors as &$row ) { foreach ( $displayMonitors as &$row ) {
if ( $row['Function'] == 'None' ) if ( $row['Function'] == 'None' )
@ -133,7 +134,10 @@ foreach ( $displayMonitors as &$row ) {
if ( ! isset($heights[$row['Height']]) ) { if ( ! isset($heights[$row['Height']]) ) {
$heights[$row['Height']] = $row['Height'].'px'; $heights[$row['Height']] = $row['Height'].'px';
} }
$monitors[] = new ZM\Monitor($row); $monitor = $monitors[] = new ZM\Monitor($row);
if ($monitor->JanusEnabled()) {
$need_janus = true;
}
} # end foreach Monitor } # end foreach Monitor
xhtmlHeaders(__FILE__, translate('Montage')); xhtmlHeaders(__FILE__, translate('Montage'));
@ -319,6 +323,8 @@ foreach (array_reverse($zones) as $zone) {
</div> </div>
</div> </div>
<script src="<?php echo cache_bust('js/adapter.min.js') ?>"></script> <script src="<?php echo cache_bust('js/adapter.min.js') ?>"></script>
<?php if ($need_janus) { ?>
<script src="/javascript/janus/janus.js"></script> <script src="/javascript/janus/janus.js"></script>
<?php } ?>
<script src="<?php echo cache_bust('js/MonitorStream.js') ?>"></script> <script src="<?php echo cache_bust('js/MonitorStream.js') ?>"></script>
<?php xhtmlFooter() ?> <?php xhtmlFooter() ?>

View File

@ -54,9 +54,9 @@ else
$focusWindow = true; $focusWindow = true;
xhtmlHeaders(__FILE__, translate('Options')); xhtmlHeaders(__FILE__, translate('Options'));
getBodyTopHTML();
echo getNavBarHTML();
?> ?>
<body>
<?php echo getNavBarHTML(); ?>
<div class="container-fluid"> <div class="container-fluid">
<div class="row flex-nowrap"> <div class="row flex-nowrap">
<nav id="sidebar"> <nav id="sidebar">

View File

@ -361,7 +361,7 @@ while( $event = $events_result->fetch(PDO::FETCH_ASSOC) ) {
$i = $startIndex; $i = $startIndex;
if ( !isset($currFrameSlots[$i]) ) { if ( !isset($currFrameSlots[$i]) ) {
$currFrameSlots[$i] = array('count'=>1, 'value'=>$event['MaxScore'], 'event'=>$event, 'frame'=>$frame); $currFrameSlots[$i] = array('count'=>1, 'value'=>$event['MaxScore'], 'event'=>$event, 'frame'=>$frame, 'id'=>$frame['FrameId']);
} else { } else {
$currFrameSlots[$i]['count']++; $currFrameSlots[$i]['count']++;
if ( $event['MaxScore'] > $currFrameSlots[$i]['value'] ) { if ( $event['MaxScore'] > $currFrameSlots[$i]['value'] ) {
@ -682,23 +682,32 @@ xhtmlHeaders(__FILE__, translate('Timeline'));
</div> </div>
<div id="content" class="chartSize"> <div id="content" class="chartSize">
<div id="topPanel" class="graphWidth">
<div id="imagePanel">
<div id="image" class="imageHeight">
<img id="imageSrc" class="imageWidth" src="graphics/transparent.png" alt="<?php echo translate('ViewEvent') ?>" title="<?php echo translate('ViewEvent') ?>"/>
</div>
</div>
<div id="dataPanel">
<div id="textPanel">
<div id="instruction"> <div id="instruction">
<p><?php echo translate('TimelineTip1') ?></p> <p><?php echo translate('TimelineTip1') ?></p>
<p><?php echo translate('TimelineTip2') ?></p> <p><?php echo translate('TimelineTip2') ?></p>
<p><?php echo translate('TimelineTip3') ?></p> <p><?php echo translate('TimelineTip3') ?></p>
<p><?php echo translate('TimelineTip4') ?></p> <p><?php echo translate('TimelineTip4') ?></p>
</div> </div>
<div id="eventData"> <div id="topPanel" class="graphWidth">
<?php
foreach ( $monitors as $monitor ) {
?>
<div class="monitorPanel" style="width:<?php echo 100/count($monitors); ?>%; float:left;">
<div class="imagePanel"<?php echo count($monitors)==1?' style="width: 50%; float: left;"' :''?>>
<div class="imageHeight image">
<img id="imageSrc<?php echo $monitor->Id() ?>" class="imageWidth" src="graphics/transparent.png" alt="<?php echo translate('ViewEvent') ?>" title="<?php echo translate('ViewEvent') ?>"/>
</div> </div>
</div> </div>
<div id="dataPanel<?php echo $monitor->Id() ?>" class="dataPanel"<?php echo count($monitors)==1?' style="width: 50%; float: left;"' :''?>>
<div id="textPanel<?php echo $monitor->Id() ?>">
<div id="eventData<?php echo $monitor->Id() ?>">
</div>
</div>
</div>
</div>
<?php
} # end foreach monitor
?>
<div id="navPanel"> <div id="navPanel">
<button type="button" title="<?php echo translate('PanLeft') ?>" data-on-click="tlPanLeft"> <button type="button" title="<?php echo translate('PanLeft') ?>" data-on-click="tlPanLeft">
<i class="material-icons md-18">fast_rewind</i> <i class="material-icons md-18">fast_rewind</i>
@ -711,7 +720,6 @@ xhtmlHeaders(__FILE__, translate('Timeline'));
</button> </button>
</div> </div>
</div> </div>
</div>
<div id="chartPanel"> <div id="chartPanel">
<div id="chart" class="graphSize"> <div id="chart" class="graphSize">
<?php <?php

View File

@ -397,6 +397,12 @@ if ( ZM_WEB_SOUND_ON_ALARM ) {
</div> </div>
</div> </div>
<script src="<?php echo cache_bust('js/adapter.min.js') ?>"></script> <script src="<?php echo cache_bust('js/adapter.min.js') ?>"></script>
<?php
if ( $monitor->JanusEnabled() ) {
?>
<script src="/javascript/janus/janus.js"></script> <script src="/javascript/janus/janus.js"></script>
<?php
}
?>
<script src="<?php echo cache_bust('js/MonitorStream.js') ?>"></script> <script src="<?php echo cache_bust('js/MonitorStream.js') ?>"></script>
<?php xhtmlFooter() ?> <?php xhtmlFooter() ?>

View File

@ -65,7 +65,7 @@ if ( empty($_REQUEST['path']) ) {
if ( empty($_REQUEST['fid']) ) { if ( empty($_REQUEST['fid']) ) {
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
ZM\Fatal('No Frame ID specified'); ZM\Error('No Frame ID specified');
return; return;
} }
@ -73,7 +73,7 @@ if ( empty($_REQUEST['path']) ) {
$Event = ZM\Event::find_one(array('Id'=>$_REQUEST['eid'])); $Event = ZM\Event::find_one(array('Id'=>$_REQUEST['eid']));
if ( !$Event ) { if ( !$Event ) {
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
ZM\Fatal('Event '.$_REQUEST['eid'].' Not found'); ZM\Error('Event '.$_REQUEST['eid'].' Not found');
return; return;
} }
@ -96,7 +96,8 @@ if ( empty($_REQUEST['path']) ) {
} else { } else {
// neither animation nor image found // neither animation nor image found
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
ZM\Fatal("Object detection animation and image not found for this event"); ZM\Error('Object detection animation and image not found for this event');
return;
} }
$Frame = new ZM\Frame(); $Frame = new ZM\Frame();
$Frame->Id('objdetect'); $Frame->Id('objdetect');
@ -104,7 +105,8 @@ if ( empty($_REQUEST['path']) ) {
$path = $Event->Path().'/objdetect.mp4'; $path = $Event->Path().'/objdetect.mp4';
if ( !file_exists($path) ) { if ( !file_exists($path) ) {
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
ZM\Fatal("File $path does not exist. You might not have enabled create_animation in objectconfig.ini. If you have, inspect debug logs for errors during creation"); ZM\Error("File $path does not exist. You might not have enabled create_animation in objectconfig.ini. If you have, inspect debug logs for errors during creation");
return;
} }
$Frame = new ZM\Frame(); $Frame = new ZM\Frame();
$Frame->Id('objdetect'); $Frame->Id('objdetect');
@ -113,7 +115,8 @@ if ( empty($_REQUEST['path']) ) {
$path = $Event->Path().'/objdetect.gif'; $path = $Event->Path().'/objdetect.gif';
if ( !file_exists($path) ) { if ( !file_exists($path) ) {
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
ZM\Fatal("File $path does not exist. You might not have enabled create_animation in objectconfig.ini. If you have, inspect debug logs for errors during creation"); ZM\Error("File $path does not exist. You might not have enabled create_animation in objectconfig.ini. If you have, inspect debug logs for errors during creation");
return;
} }
$Frame = new ZM\Frame(); $Frame = new ZM\Frame();
$Frame->Id('objdetect'); $Frame->Id('objdetect');
@ -122,7 +125,8 @@ if ( empty($_REQUEST['path']) ) {
$path = $Event->Path().'/objdetect.jpg'; $path = $Event->Path().'/objdetect.jpg';
if ( !file_exists($path) ) { if ( !file_exists($path) ) {
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
ZM\Fatal("File $path does not exist. Please make sure store_frame_in_zm is enabled in the object detection config"); ZM\Error("File $path does not exist. Please make sure store_frame_in_zm is enabled in the object detection config");
return;
} }
$Frame = new ZM\Frame(); $Frame = new ZM\Frame();
$Frame->Id('objdetect'); $Frame->Id('objdetect');
@ -149,7 +153,7 @@ if ( empty($_REQUEST['path']) ) {
$path = $Event->Path().'/'.sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d', $Frame->FrameId()).'-'.$show.'.jpg'; $path = $Event->Path().'/'.sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d', $Frame->FrameId()).'-'.$show.'.jpg';
} else { } else {
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
ZM\Fatal('No alarm jpg found for event '.$_REQUEST['eid']); ZM\Error('No alarm jpg found for event '.$_REQUEST['eid']);
return; return;
} }
} else { } else {
@ -189,11 +193,12 @@ if ( empty($_REQUEST['path']) ) {
ZM\Debug("Command: $command, retval: $retval, output: " . implode("\n", $output)); ZM\Debug("Command: $command, retval: $retval, output: " . implode("\n", $output));
if ( ! file_exists($path) ) { if ( ! file_exists($path) ) {
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
ZM\Fatal('Can\'t create frame images from video for this event '.$Event->DefaultVideo().' ZM\Error('Can\'t create frame images from video for this event '.$Event->DefaultVideo().'
Command was: '.$command.' Command was: '.$command.'
Output was: '.implode(PHP_EOL,$output) ); Output was: '.implode(PHP_EOL,$output) );
return;
} }
# Generating an image file will use up more disk space, so update the Event record. # Generating an image file will use up more disk space, so update the Event record.
if ( $Event->EndDateTime() ) { if ( $Event->EndDateTime() ) {
@ -202,7 +207,7 @@ if ( empty($_REQUEST['path']) ) {
} }
} else { } else {
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
ZM\Fatal('No snapshot jpg found for event '.$_REQUEST['eid']); ZM\Error('No snapshot jpg found for event '.$_REQUEST['eid']);
return; return;
} }
} # end if stored jpgs } # end if stored jpgs
@ -231,7 +236,8 @@ if ( empty($_REQUEST['path']) ) {
$Frame->Delta($previousBulkFrame['Delta'] + floor( 100* ( $nextBulkFrame['Delta'] - $previousBulkFrame['Delta'] ) * $percentage )/100); $Frame->Delta($previousBulkFrame['Delta'] + floor( 100* ( $nextBulkFrame['Delta'] - $previousBulkFrame['Delta'] ) * $percentage )/100);
ZM\Debug('Got virtual frame from Bulk Frames previous delta: ' . $previousBulkFrame['Delta'] . ' + nextdelta:' . $nextBulkFrame['Delta'] . ' - ' . $previousBulkFrame['Delta'] . ' * ' . $percentage ); ZM\Debug('Got virtual frame from Bulk Frames previous delta: ' . $previousBulkFrame['Delta'] . ' + nextdelta:' . $nextBulkFrame['Delta'] . ' - ' . $previousBulkFrame['Delta'] . ' * ' . $percentage );
} else { } else {
ZM\Fatal('No Frame found for event('.$_REQUEST['eid'].') and frame id('.$_REQUEST['fid'].')'); ZM\Error('No Frame found for event('.$_REQUEST['eid'].') and frame id('.$_REQUEST['fid'].')');
return;
} }
} # end if !Frame } # end if !Frame
// Frame can be non-existent. We have Bulk frames. So now we should try to load the bulk frame // Frame can be non-existent. We have Bulk frames. So now we should try to load the bulk frame
@ -244,14 +250,14 @@ if ( empty($_REQUEST['path']) ) {
$Frame = ZM\Frame::find_one(array('Id'=>$_REQUEST['fid'])); $Frame = ZM\Frame::find_one(array('Id'=>$_REQUEST['fid']));
if ( !$Frame ) { if ( !$Frame ) {
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
ZM\Fatal('Frame ' . $_REQUEST['fid'] . ' Not Found'); ZM\Error('Frame ' . $_REQUEST['fid'] . ' Not Found');
return; return;
} }
$Event = ZM\Event::find_one(array('Id'=>$Frame->EventId())); $Event = ZM\Event::find_one(array('Id'=>$Frame->EventId()));
if ( !$Event ) { if ( !$Event ) {
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
ZM\Fatal('Event ' . $Frame->EventId() . ' Not Found'); ZM\Error('Event ' . $Frame->EventId() . ' Not Found');
return; return;
} }
$path = $Event->Path().'/'.sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d',$Frame->FrameId()).'-'.$show.'.jpg'; $path = $Event->Path().'/'.sprintf('%0'.ZM_EVENT_IMAGE_DIGITS.'d',$Frame->FrameId()).'-'.$show.'.jpg';
@ -263,7 +269,8 @@ if ( empty($_REQUEST['path']) ) {
if ( ($show == 'capture') and $Event->DefaultVideo() ) { if ( ($show == 'capture') and $Event->DefaultVideo() ) {
if ( !file_exists($Event->Path().'/'.$Event->DefaultVideo()) ) { if ( !file_exists($Event->Path().'/'.$Event->DefaultVideo()) ) {
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
ZM\Fatal("Can't create frame images from video because there is no video file for this event at (".$Event->Path().'/'.$Event->DefaultVideo() ); ZM\Error("Can't create frame images from video because there is no video file for this event at (".$Event->Path().'/'.$Event->DefaultVideo() );
return;
} }
$command = ZM_PATH_FFMPEG.' -ss '. $Frame->Delta() .' -i '.$Event->Path().'/'.$Event->DefaultVideo().' -frames:v 1 '.$path . ' 2>&1'; $command = ZM_PATH_FFMPEG.' -ss '. $Frame->Delta() .' -i '.$Event->Path().'/'.$Event->DefaultVideo().' -frames:v 1 '.$path . ' 2>&1';
#$command ='ffmpeg -ss '. $Frame->Delta() .' -i '.$Event->Path().'/'.$Event->DefaultVideo().' -vf "select=gte(n\\,'.$Frame->FrameId().'),setpts=PTS-STARTPTS" '.$path; #$command ='ffmpeg -ss '. $Frame->Delta() .' -i '.$Event->Path().'/'.$Event->DefaultVideo().' -vf "select=gte(n\\,'.$Frame->FrameId().'),setpts=PTS-STARTPTS" '.$path;
@ -275,11 +282,12 @@ if ( empty($_REQUEST['path']) ) {
ZM\Debug("Command: $command, retval: $retval, output: " . implode("\n", $output)); ZM\Debug("Command: $command, retval: $retval, output: " . implode("\n", $output));
if ( ! file_exists($path) ) { if ( ! file_exists($path) ) {
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
ZM\Fatal('Can\'t create frame images from video for this event '.$Event->DefaultVideo().' ZM\Error('Can\'t create frame images from video for this event '.$Event->DefaultVideo().'
Command was: '.$command.' Command was: '.$command.'
Output was: '.implode(PHP_EOL,$output) ); Output was: '.implode(PHP_EOL,$output) );
return;
} }
# Generating an image file will use up more disk space, so update the Event record. # Generating an image file will use up more disk space, so update the Event record.
if ( $Event->EndDateTime() ) { if ( $Event->EndDateTime() ) {
@ -288,8 +296,9 @@ Output was: '.implode(PHP_EOL,$output) );
} }
} else { } else {
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
ZM\Fatal("Can't create frame $show images from video because there is no video file for this event at ". ZM\Error("Can't create frame $show images from video because there is no video file for this event at ".
$Event->Path().'/'.$Event->DefaultVideo() ); $Event->Path().'/'.$Event->DefaultVideo() );
return;
} }
} # end if ! file_exists($path) } # end if ! file_exists($path)
@ -317,7 +326,8 @@ Output was: '.implode(PHP_EOL,$output) );
} }
if ( !file_exists($path) ) { if ( !file_exists($path) ) {
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
ZM\Fatal("Image not found at $path"); ZM\Error("Image not found at $path");
return;
} }
} }