Merge ../ZoneMinder.connortechnology into storageareas

This commit is contained in:
Isaac Connor 2016-10-12 15:40:50 -04:00
commit 0c39ec1492
22 changed files with 390 additions and 351 deletions

View File

@ -205,6 +205,7 @@ CREATE TABLE `Events` (
`Messaged` tinyint(3) unsigned NOT NULL default '0',
`Executed` tinyint(3) unsigned NOT NULL default '0',
`Notes` text,
`Orientation` enum('0','90','180','270','hori','vert') NOT NULL default '0',
PRIMARY KEY (`Id`,`MonitorId`),
KEY `MonitorId` (`MonitorId`),
KEY `StartTime` (`StartTime`),
@ -396,6 +397,7 @@ CREATE TABLE `Monitors` (
`WebColour` varchar(32) NOT NULL default 'red',
`Exif` tinyint(1) unsigned NOT NULL default '0',
`Sequence` smallint(5) unsigned default NULL,
`Orientation` enum('0','90','180','270','hori','vert') NOT NULL default '0',
PRIMARY KEY (`Id`)
) ENGINE=@ZM_MYSQL_ENGINE@;

17
db/zm_update-1.30.8.sql Normal file
View File

@ -0,0 +1,17 @@
--
-- This updates a 1.30.7 database to 1.30.8
--
SET @s = (SELECT IF(
(SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'Events'
AND table_schema = DATABASE()
AND column_name = 'Orientation'
) > 0,
"SELECT 'Column Orientation exists in Events'",
"ALTER TABLE `Events` ADD `Orientation` enum('0','90','180','270','hori','vert') NOT NULL default '0' AFTER Notes",
));
PREPARE stmt FROM @s;
EXECUTE stmt;

View File

@ -84,7 +84,7 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
static char sql[ZM_SQL_MED_BUFSIZ];
struct tm *stime = localtime( &start_time.tv_sec );
snprintf( sql, sizeof(sql), "insert into Events ( MonitorId, StorageId, Name, StartTime, Width, Height, Cause, Notes, Videoed ) values ( %d, %d, 'New Event', from_unixtime( %ld ), %d, %d, '%s', '%s', %d )", monitor->Id(), storage->Id(), start_time.tv_sec, monitor->Width(), monitor->Height(), cause.c_str(), notes.c_str(), videoEvent );
snprintf( sql, sizeof(sql), "insert into Events ( MonitorId, StorageId, Name, StartTime, Width, Height, Cause, Notes, Orientation, Videoed ) values ( %d, %d, 'New Event', from_unixtime( %ld ), %d, %d, '%s', '%s', %d, %d )", monitor->Id(), storage->Id(), start_time.tv_sec, monitor->Width(), monitor->Height(), cause.c_str(), notes.c_str(), monitor->getOrientation(), videoEvent );
if ( mysql_query( &dbconn, sql ) ) {
Error( "Can't insert event: %s. sql was (%s)", mysql_error( &dbconn ), sql );
exit( mysql_errno( &dbconn ) );
@ -1243,7 +1243,14 @@ bool EventStream::sendFrame( int delta_us ) {
static struct stat filestat;
FILE *fdj = NULL;
if ( monitor->GetOptSaveJPEGs() & 1) {
snprintf( filepath, sizeof(filepath), Event::capture_file_format, event_data->path, curr_frame_id );
} else if ( monitor->GetOptSaveJPEGs() & 2 ) {
snprintf( filepath, sizeof(filepath), Event::analyse_file_format, event_data->path, curr_frame_id );
} else {
Fatal("JPEGS not saved.zms is not capable of streaming jpegs from mp4 yet");
return false;
}
#if HAVE_LIBAVCODEC
if ( type == STREAM_MPEG ) {

View File

@ -4178,4 +4178,4 @@ int Monitor::PreCapture() {
int Monitor::PostCapture() {
return( camera->PostCapture() );
}
Monitor::Orientation Monitor::getOrientation()const { return orientation; }
Monitor::Orientation Monitor::getOrientation() const { return orientation; }

View File

@ -76,7 +76,6 @@ Storage::Storage( unsigned int p_id ) {
Debug(1,"No id passed to Storage constructor. Using default path %s instead", path );
strcpy(name, "Default");
}
}
Storage::~Storage() {

View File

@ -1 +1 @@
1.30.7
1.30.8

View File

@ -6,7 +6,7 @@ if ( empty($_REQUEST['id']) && empty($_REQUEST['eids']) ) {
if ( canView( 'Events' ) ) {
switch ( $_REQUEST['action'] ) {
case "video" : {
case 'video' : {
if ( empty($_REQUEST['videoFormat']) ) {
ajaxError( "Video Generation Failure, no format given" );
} elseif ( empty($_REQUEST['rate']) ) {
@ -77,11 +77,9 @@ if ( canView( 'Events' ) ) {
}
}
if ( canEdit( 'Events' ) )
{
switch ( $_REQUEST['action'] )
{
case "rename" :
if ( canEdit( 'Events' ) ) {
switch ( $_REQUEST['action'] ) {
case 'rename' :
{
if ( !empty($_REQUEST['eventName']) )
dbQuery( 'UPDATE Events SET Name = ? WHERE Id = ?', array( $_REQUEST['eventName'], $_REQUEST['id'] ) );
@ -90,24 +88,29 @@ if ( canEdit( 'Events' ) )
ajaxResponse( array( 'refreshEvent'=>true, 'refreshParent'=>true ) );
break;
}
case "eventdetail" :
case 'eventdetail' :
{
dbQuery( 'UPDATE Events SET Cause = ?, Notes = ? WHERE Id = ?', array( $_REQUEST['newEvent']['Cause'], $_REQUEST['newEvent']['Notes'], $_REQUEST['id'] ) );
ajaxResponse( array( 'refreshEvent'=>true, 'refreshParent'=>true ) );
break;
}
case "archive" :
case "unarchive" :
case 'archive' :
case 'unarchive' :
{
$archiveVal = ($_REQUEST['action'] == "archive")?1:0;
dbQuery( 'UPDATE Events SET Archived = ? WHERE Id = ?', array( $archiveVal, $_REQUEST['id']) );
ajaxResponse( array( 'refreshEvent'=>true, 'refreshParent'=>false ) );
break;
}
case "delete" :
case 'delete' :
{
deleteEvent( $_REQUEST['id'] );
ajaxResponse( array( 'refreshEvent'=>false, 'refreshParent'=>true ) );
$Event = new Event( $_REQUEST['id'] );
if ( ! $Event->Id() ) {
ajaxResponse( array( 'refreshEvent'=>false, 'refreshParent'=>true, 'message'=> 'Event not found.' ) );
} else {
$Event->delete();
ajaxResponse( array( 'refreshEvent'=>false, 'refreshParent'=>true ) );
}
break;
}
}

View File

@ -14,6 +14,10 @@ class Event {
} elseif ( is_array( $IdOrRow ) ) {
$row = $IdOrRow;
} else {
$backTrace = debug_backtrace();
$file = $backTrace[1]['file'];
$line = $backTrace[1]['line'];
Error("Unknown argument passed to Event Constructor from $file:$line)");
Error("Unknown argument passed to Event Constructor ($IdOrRow)");
return;
}
@ -30,6 +34,9 @@ class Event {
public function Storage() {
return new Storage( isset($this->{'StorageId'}) ? $this->{'StorageId'} : NULL );
}
public function Monitor() {
return new Monitor( isset($this->{'MonitorId'}) ? $this->{'MonitorId'} : NULL );
}
public function __call( $fn, array $args){
if ( array_key_exists( $fn, $this ) ) {
return $this->{$fn};

View File

@ -289,14 +289,15 @@ if ( !empty($action) ) {
if ( !empty($_REQUEST['mid']) && canEdit( 'Monitors', $_REQUEST['mid'] ) ) {
$mid = validInt($_REQUEST['mid']);
if ( $action == 'function' ) {
$monitor = dbFetchOne( "SELECT * FROM Monitors WHERE Id=?", NULL, array($mid) );
$monitor = dbFetchOne( 'SELECT * FROM Monitors WHERE Id=?', NULL, array($mid) );
$newFunction = validStr($_REQUEST['newFunction']);
$newEnabled = isset( $_REQUEST['newEnabled'] ) and $_REQUEST['newEnabled'] != '1' ? '0' : '1';
# Because we use a checkbox, it won't get passed in the request. So not being in _REQUEST means 0
$newEnabled = ( !isset( $_REQUEST['newEnabled'] ) or $_REQUEST['newEnabled'] != '1' ) ? '0' : '1';
$oldFunction = $monitor['Function'];
$oldEnabled = $monitor['Enabled'];
if ( $newFunction != $oldFunction || $newEnabled != $oldEnabled ) {
dbQuery( "update Monitors set Function=?, Enabled=? where Id=?", array( $newFunction, $newEnabled, $mid ) );
dbQuery( 'UPDATE Monitors SET Function=?, Enabled=? WHERE Id=?', array( $newFunction, $newEnabled, $mid ) );
$monitor['Function'] = $newFunction;
$monitor['Enabled'] = $newEnabled;

View File

@ -468,10 +468,11 @@ function getEventDefaultVideoPath( $event ) {
}
function deletePath( $path ) {
Error("deletePath $path");
if ( is_dir( $path ) ) {
Debug("deletePath rm -rf $path");
system( escapeshellcmd( "rm -rf ".$path ) );
} else {
Debug("deletePath unlink $path");
unlink( $path );
}
}
@ -486,6 +487,8 @@ function deleteEvent( $event ) {
if ( gettype($event) != 'array' ) {
# $event could be an eid, so turn it into an event hash
$event = new Event( $event );
} else {
Debug("Event type: " . gettype($event));
}
global $user;

View File

@ -42,4 +42,8 @@
#monitors .monitorState {
margin: 2px auto;
text-align: center;
border: 0;
}
#monitors .alert .monitorState {
border: 0;
}

View File

@ -42,4 +42,9 @@
#monitors .monitorState {
margin: 2px auto;
text-align: center;
border: 0;
}
#monitors .alert .monitorState {
border: 0;
}

View File

@ -48,4 +48,8 @@
#monitors .monitorState {
margin: 2px auto;
text-align: center;
border: 0;
}
#monitors .alert .monitorState {
border: 0;
}

View File

@ -220,6 +220,7 @@ function getNavBarHTML() {
?>
<li><?php echo makePopupLink( '?view=cycle&amp;group='.$cycleGroup, 'zmCycle'.$cycleGroup, array( 'cycle', $cycleWidth, $cycleHeight ), translate('Cycle'), $running ) ?></li>
<li><?php echo makePopupLink( '?view=montage&amp;group='.$cycleGroup, 'zmMontage'.$cycleGroup, 'montage', translate('Montage'), $running ) ?></li>
<li><?php echo makePopupLink( '?view=montagereview&amp;group='.$cycleGroup, 'zmMontageReview'.$cycleGroup, 'montagereview', translate('MontageReview'), $running ) ?></li>
<?php } ?>
</ul>

View File

@ -102,7 +102,12 @@ function getPopupSize( tag, width, height )
function zmWindow()
{
var zmWin = window.open( 'http://www.zoneminder.com', 'ZoneMinder' );
zmWin.focus();
if ( ! zmWin ) {
// if popup blocking is enabled, the popup won't be defined.
console.log("Please disable popup blocking.");
} else {
zmWin.focus();
}
}
function createPopup( url, name, tag, width, height )
@ -114,7 +119,12 @@ function createPopup( url, name, tag, width, height )
if ( popupSize.height > 0 )
popupDimensions += ",height="+popupSize.height;
var popup = window.open( url, name, popupOptions+popupDimensions );
popup.focus();
if ( ! popup ) {
// if popup blocking is enabled, the popup won't be defined.
console.log("Please disable popup blocking.");
} else {
popup.focus();
}
}
function createEventPopup( eventId, eventFilter, width, height )
@ -125,7 +135,12 @@ function createEventPopup( eventId, eventFilter, width, height )
var name = 'zmEvent';
var popupSize = getPopupSize( 'event', width, height );
var popup = window.open( url, name, popupOptions+",width="+popupSize.width+",height="+popupSize.height );
popup.focus();
if ( ! popup ) {
// if popup blocking is enabled, the popup won't be defined.
console.log("Please disable popup blocking.");
} else {
popup.focus();
}
}
function createFramesPopup( eventId, width, height )
@ -134,7 +149,12 @@ function createFramesPopup( eventId, width, height )
var name = 'zmFrames';
var popupSize = getPopupSize( 'frames', width, height );
var popup = window.open( url, name, popupOptions+",width="+popupSize.width+",height="+popupSize.height );
popup.focus();
if ( ! popup ) {
// if popup blocking is enabled, the popup won't be defined.
console.log("Please disable popup blocking.");
} else {
popup.focus();
}
}
function createFramePopup( eventId, frameId, width, height )
@ -143,7 +163,12 @@ function createFramePopup( eventId, frameId, width, height )
var name = 'zmFrame';
var popupSize = getPopupSize( 'frame', width, height );
var popup = window.open( url, name, popupOptions+",width="+popupSize.width+",height="+popupSize.height );
popup.focus();
if ( ! popup ) {
// if popup blocking is enabled, the popup won't be defined.
console.log("Please disable popup blocking.");
} else {
popup.focus();
}
}
function windowToFront()

View File

@ -18,36 +18,35 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
if ( !canView( 'Events' ) )
{
$view = "error";
if ( !canView( 'Events' ) ) {
$view = 'error';
return;
}
$eid = validInt( $_REQUEST['eid'] );
$fid = !empty($_REQUEST['fid'])?validInt($_REQUEST['fid']):1;
$sql = 'SELECT E.*,M.Name AS MonitorName,E.Width,E.Height,M.DefaultRate,M.DefaultScale,M.VideoWriter,M.SaveJPEGs,M.Orientation,M.LabelFormat FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id WHERE E.Id = ?';
$sql_values = array( $eid );
$Event = new Event( $eid );
$Monitor = $Event->Monitor();
if ( $user['MonitorIds'] ) {
$monitor_ids = explode( ',', $user['MonitorIds'] );
$sql .= ' AND MonitorId IN (' .implode( ',', array_fill(0,count($monitor_ids),'?') ) . ')';
$sql_values = array_merge( $sql_values, $monitor_ids );
$monitor_ids = explode( ',', $user['MonitorIds'] );
if ( count($monitor_ids) and ! in_array( $Event->MonitorId(), $monitors_ids ) ) {
$view = 'error';
return;
}
}
$event = dbFetchOne( $sql, NULL, $sql_values );
if ( isset( $_REQUEST['rate'] ) )
$rate = validInt($_REQUEST['rate']);
else
$rate = reScale( RATE_BASE, $event['DefaultRate'], ZM_WEB_DEFAULT_RATE );
$rate = reScale( RATE_BASE, $Monitor->DefaultRate(), ZM_WEB_DEFAULT_RATE );
if ( isset( $_REQUEST['scale'] ) ) {
$scale = validInt($_REQUEST['scale']);
} else if ( isset( $_COOKIE['zmWatchScale'.$event['MonitorId']] ) ) {
$scale = $_COOKIE['zmEventScale'.$event['MonitorId']];
} else if ( isset( $_COOKIE['zmWatchScale'.$Event->MonitorId()] ) ) {
$scale = $_COOKIE['zmEventScale'.$Event->MonitorId()];
} else {
$scale = reScale( SCALE_BASE, $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
$scale = reScale( SCALE_BASE, $Monitor->DefaultScale(), ZM_WEB_DEFAULT_SCALE );
}
$replayModes = array(
@ -73,11 +72,11 @@ else {
// videojs zoomrotate only when direct recording
$Zoom = 1;
$Rotation = 0;
if ( $event['VideoWriter'] == "2" ) {
if ( $Monitor->VideoWriter() == '2' ) {
# Passthrough
$Rotation = $event['Orientation'];
if ( in_array($event['Orientation'],array('90','270')) )
$Zoom = $event['Height']/$event['Width'];
$Rotation = $Event->Orientation();
if ( in_array($Event->Orientation(),array('90','270')) )
$Zoom = $Event->Height()/$Event->Width();
}
parseSort();
@ -85,7 +84,7 @@ parseFilter( $_REQUEST['filter'] );
$filterQuery = $_REQUEST['filter']['query'];
$panelSections = 40;
$panelSectionWidth = (int)ceil(reScale($event['Width'],$scale)/$panelSections);
$panelSectionWidth = (int)ceil(reScale($Event->Width(),$scale)/$panelSections);
$panelWidth = ($panelSections*$panelSectionWidth-1);
$connkey = generateConnKey();
@ -97,110 +96,102 @@ xhtmlHeaders(__FILE__, translate('Event') );
<body>
<div id="page">
<div id="content">
<?php
if ( ! $Event->Id() ) {
echo 'Event was not found.';
} else {
?>
<div id="dataBar">
<table id="dataTable" class="major" cellspacing="0">
<tr>
<td><span id="dataId" title="<?php echo translate('Id') ?>"><?php echo $event['Id'] ?></span></td>
<td><span id="dataCause" title="<?php echo $event['Notes']?validHtmlStr($event['Notes']):translate('AttrCause') ?>"><?php echo validHtmlStr($event['Cause']) ?></span></td>
<td><span id="dataTime" title="<?php echo translate('Time') ?>"><?php echo strftime( STRF_FMT_DATETIME_SHORT, strtotime($event['StartTime'] ) ) ?></span></td>
<td><span id="dataDuration" title="<?php echo translate('Duration') ?>"><?php echo $event['Length'] ?></span>s</td>
<td><span id="dataFrames" title="<?php echo translate('AttrFrames')."/".translate('AttrAlarmFrames') ?>"><?php echo $event['Frames'] ?>/<?php echo $event['AlarmFrames'] ?></span></td>
<td><span id="dataScore" title="<?php echo translate('AttrTotalScore')."/".translate('AttrAvgScore')."/".translate('AttrMaxScore') ?>"><?php echo $event['TotScore'] ?>/<?php echo $event['AvgScore'] ?>/<?php echo $event['MaxScore'] ?></span></td>
<td><span id="dataId" title="<?php echo translate('Id') ?>"><?php echo $Event->Id() ?></span></td>
<td><span id="dataCause" title="<?php echo $Event->Notes()?validHtmlStr($Event->Notes()):translate('AttrCause') ?>"><?php echo validHtmlStr($Event->Cause()) ?></span></td>
<td><span id="dataTime" title="<?php echo translate('Time') ?>"><?php echo strftime( STRF_FMT_DATETIME_SHORT, strtotime($Event->StartTime() ) ) ?></span></td>
<td><span id="dataDuration" title="<?php echo translate('Duration') ?>"><?php echo $Event->Length() ?></span>s</td>
<td><span id="dataFrames" title="<?php echo translate('AttrFrames')."/".translate('AttrAlarmFrames') ?>"><?php echo $Event->Frames() ?>/<?php echo $Event->AlarmFrames() ?></span></td>
<td><span id="dataScore" title="<?php echo translate('AttrTotalScore')."/".translate('AttrAvgScore')."/".translate('AttrMaxScore') ?>"><?php echo $Event->TotScore() ?>/<?php echo $Event->AvgScore() ?>/<?php echo $Event->MaxScore() ?></span></td>
</tr>
</table>
</div>
<div id="menuBar1">
<div id="scaleControl"><label for="scale"><?php echo translate('Scale') ?></label><?php echo buildSelect( "scale", $scales, "changeScale();" ); ?></div>
<div id="replayControl"><label for="replayMode"><?php echo translate('Replay') ?></label><?php echo buildSelect( "replayMode", $replayModes, "changeReplayMode();" ); ?></div>
<div id="nameControl"><input type="text" id="eventName" name="eventName" value="<?php echo validHtmlStr($event['Name']) ?>" size="16"/><input type="button" value="<?php echo translate('Rename') ?>" onclick="renameEvent()"<?php if ( !canEdit( 'Events' ) ) { ?> disabled="disabled"<?php } ?>/></div>
<div id="nameControl"><input type="text" id="eventName" name="eventName" value="<?php echo validHtmlStr($Event->Name()) ?>" size="16"/><input type="button" value="<?php echo translate('Rename') ?>" onclick="renameEvent()"<?php if ( !canEdit( 'Events' ) ) { ?> disabled="disabled"<?php } ?>/></div>
</div>
<div id="menuBar2">
<div id="closeWindow"><a href="#" onclick="closeWindow();"><?php echo translate('Close') ?></a></div>
<?php
if ( canEdit( 'Events' ) )
{
if ( canEdit( 'Events' ) ) {
?>
<div id="deleteEvent"><a href="#" onclick="deleteEvent()"><?php echo translate('Delete') ?></a></div>
<div id="editEvent"><a href="#" onclick="editEvent()"><?php echo translate('Edit') ?></a></div>
<div id="archiveEvent" class="hidden"><a href="#" onclick="archiveEvent()"><?php echo translate('Archive') ?></a></div>
<div id="unarchiveEvent" class="hidden"><a href="#" onclick="unarchiveEvent()"><?php echo translate('Unarchive') ?></a></div>
<?php
}
if ( canView( 'Events' ) )
{
} // end if can edit Events
if ( canView( 'Events' ) ) {
?>
<div id="framesEvent"><a href="#" onclick="showEventFrames()"><?php echo translate('Frames') ?></a></div>
<?php
if ( $event['SaveJPEGs'] & 3 )
{
if ( $Event->SaveJPEGs() & 3 ) { // Analysis or Jpegs
?>
<div id="stillsEvent"<?php if ( $streamMode == 'still' ) { ?> class="hidden"<?php } ?>><a href="#" onclick="showStills()"><?php echo translate('Stills') ?></a></div>
<?php
}
} // has frames or analysis
?>
<div id="videoEvent"<?php if ( $streamMode == 'video' ) { ?> class="hidden"<?php } ?>><a href="#" onclick="showVideo()"><?php echo translate('Video') ?></a></div>
<div id="exportEvent"><a href="#" onclick="exportEvent()"><?php echo translate('Export') ?></a></div>
</div>
<div id="eventVideo" class="">
<?php
if ( $event['DefaultVideo'] )
{
if ( $Event->DefaultVideo() ) {
?>
<div id="videoFeed">
<video id="videoobj" class="video-js vjs-default-skin" width="<?php echo reScale( $event['Width'], $scale ) ?>" height="<?php echo reScale( $event['Height'], $scale ) ?>" data-setup='{ "controls": true, "playbackRates": [0.5, 1, 1.5, 2, 4, 8, 16, 32, 64, 128, 256], "autoplay": true, "preload": "auto", "plugins": { "zoomrotate": { "rotate": "<?php echo $Rotation ?>", "zoom": "<?php echo $Zoom ?>"}}}'>
<source src="<?php echo getEventDefaultVideoPath($event) ?>" type="video/mp4">
<video id="videoobj" class="video-js vjs-default-skin" width="<?php echo reScale( $Event->Width(), $scale ) ?>" height="<?php echo reScale( $Event->Height(), $scale ) ?>" data-setup='{ "controls": true, "playbackRates": [0.5, 1, 1.5, 2, 4, 8, 16, 32, 64, 128, 256], "autoplay": true, "preload": "auto", "plugins": { "zoomrotate": { "rotate": "<?php echo $Rotation ?>", "zoom": "<?php echo $Zoom ?>"}}}'>
<source src="<?php echo $Event->getStreamSrc( array( "mode=mpeg&format=h264" ) ); ?>" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
<!--script>includeVideoJs();</script-->
<link href="//vjs.zencdn.net/4.11/video-js.css" rel="stylesheet">
<script src="//vjs.zencdn.net/4.11/video.js"></script>
<script src="./js/videojs.zoomrotate.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>
<script>
var LabelFormat = "<?php echo validJsStr($event['LabelFormat'])?>";
var monitorName = "<?php echo validJsStr($event['MonitorName'])?>";
var duration = <?php echo $event['Length'] ?>, startTime = '<?php echo $event['StartTime'] ?>';
addVideoTimingTrack(document.getElementById('videoobj'), LabelFormat, monitorName, duration, startTime);
</script>
<!--script>includeVideoJs();</script-->
<link href="//vjs.zencdn.net/4.11/video-js.css" rel="stylesheet">
<script src="//vjs.zencdn.net/4.11/video.js"></script>
<script src="./js/videojs.zoomrotate.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>
<script>
var LabelFormat = "<?php echo validJsStr($Monitor->LabelFormat())?>";
var monitorName = "<?php echo validJsStr($Monitor->Name())?>";
var duration = <?php echo $Event->Length() ?>, startTime = '<?php echo $Event->StartTime() ?>';
addVideoTimingTrack(document.getElementById('videoobj'), LabelFormat, monitorName, duration, startTime);
</script>
<?php
}
else
{
} // end if DefaultVideo
?>
<div id="imageFeed">
<div id="imageFeed" <?php if ( $Event->DefaultVideo() ) { ?>class="hidden"<?php } ?> >
<?php
if ( ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT )
{
if ( ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT ) {
$streamSrc = getStreamSrc( array( "source=event", "mode=mpeg", "event=".$eid, "frame=".$fid, "scale=".$scale, "rate=".$rate, "bitrate=".ZM_WEB_VIDEO_BITRATE, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "format=".ZM_MPEG_REPLAY_FORMAT, "replay=".$replayMode ) );
outputVideoStream( "evtStream", $streamSrc, reScale( $event['Width'], $scale ), reScale( $event['Height'], $scale ), ZM_MPEG_LIVE_FORMAT );
}
else
{
outputVideoStream( "evtStream", $streamSrc, reScale( $Event->Width(), $scale ), reScale( $Event->Height(), $scale ), ZM_MPEG_LIVE_FORMAT );
} else {
$streamSrc = getStreamSrc( array( "source=event", "mode=jpeg", "event=".$eid, "frame=".$fid, "scale=".$scale, "rate=".$rate, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "replay=".$replayMode) );
if ( canStreamNative() )
{
outputImageStream( "evtStream", $streamSrc, reScale( $event['Width'], $scale ), reScale( $event['Height'], $scale ), validHtmlStr($event['Name']) );
if ( canStreamNative() ) {
outputImageStream( "evtStream", $streamSrc, reScale( $Event->Width(), $scale ), reScale( $Event->Height(), $scale ), validHtmlStr($Event->Name()) );
} else {
outputHelperStream( "evtStream", $streamSrc, reScale( $Event->Width(), $scale ), reScale( $Event->Height(), $scale ) );
}
else
{
outputHelperStream( "evtStream", $streamSrc, reScale( $event['Width'], $scale ), reScale( $event['Height'], $scale ) );
}
}
} // end if stream method
?>
</div>
<p id="dvrControls">
<input type="button" value="&lt;+" id="prevBtn" title="<?php echo translate('Prev') ?>" class="inactive" onclick="streamPrev( true )"/>
<input type="button" value="&lt;&lt;" id="fastRevBtn" title="<?php echo translate('Rewind') ?>" class="inactive" disabled="disabled" onclick="streamFastRev( true )"/>
<input type="button" value="&lt;" id="slowRevBtn" title="<?php echo translate('StepBack') ?>" class="unavail" disabled="disabled" onclick="streamSlowRev( true )"/>
<input type="button" value="||" id="pauseBtn" title="<?php echo translate('Pause') ?>" class="inactive" onclick="streamPause( true )"/>
<input type="button" value="|>" id="playBtn" title="<?php echo translate('Play') ?>" class="active" disabled="disabled" onclick="streamPlay( true )"/>
<input type="button" value="&gt;" id="slowFwdBtn" title="<?php echo translate('StepForward') ?>" class="unavail" disabled="disabled" onclick="streamSlowFwd( true )"/>
<input type="button" value="&gt;&gt;" id="fastFwdBtn" title="<?php echo translate('FastForward') ?>" class="inactive" disabled="disabled" onclick="streamFastFwd( true )"/>
<input type="button" value="&ndash;" id="zoomOutBtn" title="<?php echo translate('ZoomOut') ?>" class="avail" onclick="streamZoomOut()"/>
<input type="button" value="+&gt;" id="nextBtn" title="<?php echo translate('Next') ?>" class="inactive" onclick="streamNext( true )"/>
<input type="button" value="&lt;+" id="prevBtn" title="<?php echo translate('Prev') ?>" class="inactive" onclick="streamPrev( true );"/>
<input type="button" value="&lt;&lt;" id="fastRevBtn" title="<?php echo translate('Rewind') ?>" class="inactive" disabled="disabled" onclick="streamFastRev( true );"/>
<input type="button" value="&lt;" id="slowRevBtn" title="<?php echo translate('StepBack') ?>" class="unavail" disabled="disabled" onclick="streamSlowRev( true );"/>
<input type="button" value="||" id="pauseBtn" title="<?php echo translate('Pause') ?>" class="inactive" onclick="streamPause( true );"/>
<input type="button" value="|>" id="playBtn" title="<?php echo translate('Play') ?>" class="active" disabled="disabled" onclick="streamPlay( true );"/>
<input type="button" value="&gt;" id="slowFwdBtn" title="<?php echo translate('StepForward') ?>" class="unavail" disabled="disabled" onclick="streamSlowFwd( true );"/>
<input type="button" value="&gt;&gt;" id="fastFwdBtn" title="<?php echo translate('FastForward') ?>" class="inactive" disabled="disabled" onclick="streamFastFwd( true );"/>
<input type="button" value="&ndash;" id="zoomOutBtn" title="<?php echo translate('ZoomOut') ?>" class="avail" onclick="streamZoomOut();"/>
<input type="button" value="+&gt;" id="nextBtn" title="<?php echo translate('Next') ?>" class="inactive" onclick="streamNext( true );"/>
</p>
<div id="replayStatus">
<span id="mode"><?php echo translate('Mode') ?>: <span id="modeValue">&nbsp;</span></span>
@ -209,23 +200,14 @@ else
<span id="zoom"><?php echo translate('Zoom') ?>: <span id="zoomValue"></span>x</span>
</div>
<div id="progressBar" class="invisible">
<?php
for ( $i = 0; $i < $panelSections; $i++ )
{
?>
<?php for ( $i = 0; $i < $panelSections; $i++ ) { ?>
<div class="progressBox" id="progressBox<?php echo $i ?>" title=""></div>
<?php
}
?>
<?php } ?>
</div>
<?php
}
?>
</div>
</div>
<?php
if ($event['SaveJPEGs'] & 3)
{
<?php
if ($Event->SaveJPEGs() & 3) { // frames or analysis
?>
<div id="eventStills" class="hidden">
<div id="eventThumbsPanel">
@ -262,9 +244,10 @@ if ($event['SaveJPEGs'] & 3)
</div>
</div>
<?php
}
}
} // end if SaveJPEGs() & 3 Analysis or Jpegs
} // end if canView
} // end if Event exists
?>
</div>
</div><!--page-->
</body>
</html>

View File

@ -18,9 +18,8 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
if ( !canView( 'Events' ) )
{
$view = "error";
if ( !canView( 'Events' ) ) {
$view = 'error';
return;
}
@ -56,7 +55,13 @@ if ( isset( $_REQUEST['scale'] ) )
else
$scale = max( reScale( SCALE_BASE, $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE ), SCALE_BASE );
$imageData = getImageSrc( $event, $frame, $scale, (isset($_REQUEST['show']) && $_REQUEST['show']=="capt") );
$show = 'capt';
if ( isset($_REQUEST['show']) ) {
$show = $_REQUEST['show'];
#} else if ( $imageData['hasAnalImage'] ) {
#$show = 'anal';
}
$imageData = getImageSrc( $event, $frame, $scale, ($show=="capt") );
$imagePath = $imageData['thumbPath'];
$eventPath = $imageData['eventPath'];
@ -79,23 +84,16 @@ xhtmlHeaders(__FILE__, translate('Frame')." - ".$event['Id']." - ".$Frame->Frame
</div>
<div id="content">
<p id="image">
<?php if ( in_array($event['VideoWriter'],array("1","2")) ) { ?>
<img src="?view=image&eid=<?php echo $event['Id'] ?>&fid=<?php echo $Frame->FrameId() ?>&scale=<?php echo $event['DefaultScale'] ?>&amp;show=<?php echo $imageData['isAnalImage']?"capt":"anal" ?>" class="<?php echo $imageData['imageClass'] ?>" width="<?php echo reScale( $event['Width'], $event['DefaultScale'], $scale ) ?>" height="<?php echo reScale( $event['Height'], $event['DefaultScale'], $scale ) ?>" alt="<?php echo $Frame->EventId()."-".$Frame->FrameId() ?>">
<?php } else {
if ( $imageData['hasAnalImage'] ) { ?>
<a href="?view=frame&amp;eid=<?php echo $event['Id'] ?>&amp;fid=<?php echo $Frame->FrameId() ?>&amp;scale=<?php echo $scale ?>&amp;show=<?php echo $imageData['isAnalImage']?'capt':'anal' ?>">
<?php } ?>
<img src="<?php echo $Frame->getImageSrc($imageData['isAnalImage']?'analyse':'capture') ?>" width="<?php echo reScale( $event['Width'], $event['DefaultScale'], $scale ) ?>" height="<?php echo reScale( $event['Height'], $event['DefaultScale'], $scale ) ?>" alt="<?php echo $Frame->EventId()."-".$Frame->FrameId() ?>" class="<?php echo $imageData['imageClass'] ?>"/>
<?php if ( $imageData['hasAnalImage'] ) { ?></a><?php } ?>
<?php } ?>
</p>
<a href="?view=frame&amp;eid=<?php echo $event['Id'] ?>&amp;fid=<?php echo $Frame->FrameId() ?>&amp;scale=<?php echo $scale ?>&amp;show=<?php echo $show == 'anal' ? 'capt':'anal' ?>">
<img src="<?php echo $Frame->getImageSrc($imageData['isAnalImage']?'analyse':'capture') ?>" width="<?php echo reScale( $event['Width'], $event['DefaultScale'], $scale ) ?>" height="<?php echo reScale( $event['Height'], $event['DefaultScale'], $scale ) ?>" alt="<?php echo $Frame->EventId()."-".$Frame->FrameId() ?>" class="<?php echo $imageData['imageClass'] ?>"/>
</p>
<p id="controls">
<?php if ( $Frame->FrameId() > 1 ) { ?>
<a id="firstLink" href="?view=frame&amp;eid=<?php echo $event['Id'] ?>&amp;fid=<?php echo $firstFid ?>&amp;scale=<?php echo $scale ?>"><?php echo translate('First') ?></a>
<a id="prevLink" href="?view=frame&amp;eid=<?php echo $event['Id'] ?>&amp;fid=<?php echo $prevFid ?>&amp;scale=<?php echo $scale ?>"><?php echo translate('Prev') ?></a>
<a id="firstLink" href="?view=frame&amp;eid=<?php echo $event['Id'] ?>&amp;fid=<?php echo $firstFid ?>&amp;scale=<?php echo $scale ?>&amp;show=<?php echo $show ?>"><?php echo translate('First') ?></a>
<a id="prevLink" href="?view=frame&amp;eid=<?php echo $event['Id'] ?>&amp;fid=<?php echo $prevFid ?>&amp;scale=<?php echo $scale ?>&amp;show=<?php echo $show ?>"><?php echo translate('Prev') ?></a>
<?php } if ( $Frame->FrameId() < $maxFid ) { ?>
<a id="nextLink" href="?view=frame&amp;eid=<?php echo $event['Id'] ?>&amp;fid=<?php echo $nextFid ?>&amp;scale=<?php echo $scale ?>"><?php echo translate('Next') ?></a>
<a id="lastLink" href="?view=frame&amp;eid=<?php echo $event['Id'] ?>&amp;fid=<?php echo $lastFid ?>&amp;scale=<?php echo $scale ?>"><?php echo translate('Last') ?></a>
<a id="nextLink" href="?view=frame&amp;eid=<?php echo $event['Id'] ?>&amp;fid=<?php echo $nextFid ?>&amp;scale=<?php echo $scale ?>&amp;show=<?php echo $show ?>"><?php echo translate('Next') ?></a>
<a id="lastLink" href="?view=frame&amp;eid=<?php echo $event['Id'] ?>&amp;fid=<?php echo $lastFid ?>&amp;scale=<?php echo $scale ?>&amp;show=<?php echo $show ?>"><?php echo translate('Last') ?></a>
<?php } ?>
</p>
<?php if (file_exists ($dImagePath)) { ?>

View File

@ -18,9 +18,8 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
if ( !canEdit( 'Monitors' ) )
{
$view = "error";
if ( !canEdit( 'Monitors' ) ) {
$view = 'error';
return;
}
@ -43,8 +42,7 @@ xhtmlHeaders(__FILE__, translate('Function')." - ".validHtmlStr($monitor['Name']
<p>
<select name="newFunction">
<?php
foreach ( getEnumValues( 'Monitors', 'Function' ) as $optFunction )
{
foreach ( getEnumValues( 'Monitors', 'Function' ) as $optFunction ) {
?>
<option value="<?php echo $optFunction ?>"<?php if ( $optFunction == $monitor['Function'] ) { ?> selected="selected"<?php } ?>><?php echo translate('Fn'.$optFunction) ?></option>
<?php

View File

@ -1,7 +1,9 @@
function setButtonState( element, butClass )
{
if ( element ) {
element.className = butClass;
element.disabled = (butClass != 'inactive');
}
}
function changeScale() {
@ -87,7 +89,7 @@ function getCmdResponse( respObj, respText )
streamCmdTimer = streamQuery.delay( streamTimeout );
}
var streamReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'chain', onSuccess: getCmdResponse } );
var streamReq = new Request.JSON( { url: thisUrl, method: 'get', timeout: AJAX_TIMEOUT, link: 'chain', onSuccess: getCmdResponse } );
function streamPause( action )
{
@ -251,7 +253,7 @@ function getEventResponse( respObj, respText )
nearEventsQuery( eventData.Id );
}
var eventReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getEventResponse } );
var eventReq = new Request.JSON( { url: thisUrl, method: 'get', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getEventResponse } );
function eventQuery( eventId )
{
@ -277,7 +279,7 @@ function getNearEventsResponse( respObj, respText )
$('nextEventBtn').disabled = !nextEventId;
}
var nearEventsReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getNearEventsResponse } );
var nearEventsReq = new Request.JSON( { url: thisUrl, method: 'get', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getNearEventsResponse } );
function nearEventsQuery( eventId )
{
@ -386,8 +388,12 @@ function hideEventImageComplete()
{
var eventImg = $('eventImage');
var thumbImg = $('eventThumb'+$('eventImage').getProperty( 'alt' ));
if ( thumbImg ) {
thumbImg.removeClass('selected');
thumbImg.setOpacity( 1.0 );
} else {
console.log("Unable to find eventThumb at " + 'eventThumb'+$('eventImage').getProperty( 'alt' ) );
}
$('prevImageBtn').disabled = true;
$('nextImageBtn').disabled = true;
$('eventImagePanel').setStyle( 'display', 'none' );
@ -447,7 +453,7 @@ function getFrameResponse( respObj, respText )
loadEventThumb( eventData, frame, respObj.loopback=="true" );
}
var frameReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'chain', onSuccess: getFrameResponse } );
var frameReq = new Request.JSON( { url: thisUrl, method: 'get', timeout: AJAX_TIMEOUT, link: 'chain', onSuccess: getFrameResponse } );
function frameQuery( eventId, frameId, loadImage )
{
@ -589,7 +595,7 @@ function getActResponse( respObj, respText )
eventQuery( eventData.Id );
}
var actReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getActResponse } );
var actReq = new Request.JSON( { url: thisUrl, method: 'get', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getActResponse } );
function actQuery( action, parms )
{
@ -639,6 +645,7 @@ function showEventFrames()
function showVideo()
{
$('eventStills').addClass( 'hidden' );
$('imageFeed').addClass('hidden');
$('eventVideo').removeClass( 'hidden' );
$('stillsEvent').removeClass( 'hidden' );
@ -651,7 +658,17 @@ function showVideo()
function showStills()
{
$('eventStills').removeClass( 'hidden' );
$('imageFeed').removeClass('hidden');
$('eventVideo').addClass( 'hidden' );
if (vid && ( vid.paused != true ) ) {
// Pause the video
vid.pause();
// Update the button text to 'Play'
//if ( playButton )
//playButton.innerHTML = "Play";
}
$('stillsEvent').addClass( 'hidden' );
$('videoEvent').removeClass( 'hidden' );
@ -659,8 +676,7 @@ function showStills()
streamMode = 'stills';
streamPause( true );
if ( !scroll )
{
if ( !scroll ) {
scroll = new Fx.Scroll( 'eventThumbs', {
wait: false,
duration: 500,
@ -745,6 +761,7 @@ function handleClick( event )
}
function setupListener()
{
// I think this stuff was to use our existing buttons instead of the videojs controls.
// Buttons
var playButton = document.getElementById("play-pause");
@ -840,42 +857,38 @@ function setupListener()
});
}
function initPage()
{
//FIXME prevent blocking...not sure what is happening or best way to unblock
vid=$('videoobj');
if (vid)
{
/*setupListener();
vid.removeAttribute("controls");
/* window.videoobj.oncanplay=null;
window.videoobj.currentTime=window.videoobj.currentTime-1;
window.videoobj.currentTime=window.videoobj.currentTime+1;//may not be symetrical of course
vid.onstalled=function(){window.vid.currentTime=window.vid.currentTime-1;window.vid.currentTime=window.vid.currentTime+1;}
vid.onwaiting=function(){window.vid.currentTime=window.vid.currentTime-1;window.vid.currentTime=window.vid.currentTime+1;}
vid.onloadstart=function(){window.vid.currentTime=window.vid.currentTime-1;window.vid.currentTime=window.vid.currentTime+1;}
vid.onplay=function(){window.vid.currentTime=window.vid.currentTime-1;window.vid.currentTime=window.vid.currentTime+1;}
vid.onplaying=function(){window.vid.currentTime=window.vid.currentTime-1;window.vid.currentTime=window.vid.currentTime+1;}
//window.vid.hide();//does not help
var sources = window.videoobj.getElementsByTagName('source');
sources[0].src=null;
window.videoobj.load();
streamPlay(); */
}
else
{
streamCmdTimer = streamQuery.delay( 250 );
eventQuery.pass( eventData.Id ).delay( 500 );
function initPage() {
//FIXME prevent blocking...not sure what is happening or best way to unblock
vid = videojs("videoobj");
if ( vid ) {
/*
setupListener();
vid.removeAttribute("controls");
/* window.videoobj.oncanplay=null;
window.videoobj.currentTime=window.videoobj.currentTime-1;
window.videoobj.currentTime=window.videoobj.currentTime+1;//may not be symetrical of course
if ( canStreamNative )
{
var streamImg = $('imageFeed').getElement('img');
if ( !streamImg )
streamImg = $('imageFeed').getElement('object');
$(streamImg).addEvent( 'click', function( event ) { handleClick( event ); } );
}
vid.onstalled=function(){window.vid.currentTime=window.vid.currentTime-1;window.vid.currentTime=window.vid.currentTime+1;}
vid.onwaiting=function(){window.vid.currentTime=window.vid.currentTime-1;window.vid.currentTime=window.vid.currentTime+1;}
vid.onloadstart=function(){window.vid.currentTime=window.vid.currentTime-1;window.vid.currentTime=window.vid.currentTime+1;}
vid.onplay=function(){window.vid.currentTime=window.vid.currentTime-1;window.vid.currentTime=window.vid.currentTime+1;}
vid.onplaying=function(){window.vid.currentTime=window.vid.currentTime-1;window.vid.currentTime=window.vid.currentTime+1;}
//window.vid.hide();//does not help
var sources = window.videoobj.getElementsByTagName('source');
sources[0].src=null;
window.videoobj.load();
streamPlay(); */
} else {
streamCmdTimer = streamQuery.delay( 250 );
eventQuery.pass( eventData.Id ).delay( 500 );
if ( canStreamNative ) {
var streamImg = $('imageFeed').getElement('img');
if ( !streamImg )
streamImg = $('imageFeed').getElement('object');
$(streamImg).addEvent( 'click', function( event ) { handleClick( event ); } );
}
}
}
// Kick everything off

View File

@ -26,11 +26,11 @@ var SCALE_BASE = <?php echo SCALE_BASE ?>;
var connKey = '<?php echo $connkey ?>';
var eventData = {
Id: '<?php echo $event['Id'] ?>',
MonitorId: '<?php echo $event['MonitorId'] ?>',
Width: '<?php echo $event['Width'] ?>',
Height: '<?php echo $event['Height'] ?>',
Length: '<?php echo $event['Length'] ?>'
Id: '<?php echo $Event->Id() ?>',
MonitorId: '<?php echo $Event->MonitorId() ?>',
Width: '<?php echo $Event->Width() ?>',
Height: '<?php echo $Event->Height() ?>',
Length: '<?php echo $Event->Length() ?>'
};
var filterQuery = '<?php echo isset($filterQuery)?validJsStr($filterQuery):'' ?>';

View File

@ -151,7 +151,7 @@ if ( !empty($user['MonitorIds']) )
$eventsSql .= $monFilterSql;
$monitorsSQL .= $monFilterSql;
$frameSql .= $monFilterSql;
$frameSql .= ' AND e.MonitorId IN ('.$user['MonitorIds'].')';
}
// Parse input parameters -- note for future, validate/clean up better in case we don't get called from self.
@ -224,12 +224,12 @@ if( isset($minTime) && isset($maxTime) )
$eventsSql .= "having CalcEndTimeSecs > '" . $minTimeSecs . "' and StartTimeSecs < '" . $maxTimeSecs . "'";
$frameSql .= "and TimeStamp > '" . $minTime . "' and TimeStamp < '" . $maxTime . "'";
}
$frameSql .= "group by E.Id, E.MonitorId, F.TimeStamp order by E.MonitorId, F.TimeStamp asc";
$frameSql .= "group by E.Id, E.MonitorId, F.TimeStamp, F.Delta order by E.MonitorId, F.TimeStamp asc";
// This loads all monitors the user can see - even if we don't have data for one we still show all for switch to live.
$monitors = array();
$monitorsSql .= " order by Sequence asc ";
$monitorsSql .= ' ORDER BY Sequence ASC ';
$index=0;
foreach( dbFetchAll( $monitorsSql ) as $row )
{
@ -256,42 +256,39 @@ input[type=range]::-ms-tooltip {
</div>
<h2><?php echo translate('MontageReview') ?></h2>
</div>
<div id='ScaleDiv' style='display: inline-flex; border: 1px solid black;'>
<label style='margin:5px;' for=scaleslider><?php echo translate('Scale')?></label>
<div id="ScaleDiv" style="display: inline-flex; border: 1px solid black;">
<label style="margin:5px;" for="scaleslider"><?php echo translate('Scale')?></label>
<input id=scaleslider type=range min=0.1 max=1.0 value=<?php echo $defaultScale ?> step=0.10 width=20% onchange='setScale(this.value)' oninput='showScale(this.value)'/>
<span style='margin:5px;' id=scaleslideroutput><?php echo number_format((float)$defaultScale,2,'.','')?> x</span>
</div>
<div id='SpeedDiv' style='display: inline-flex; border: 1px solid black;'>
<div id="SpeedDiv" style='display: inline-flex; border: 1px solid black;'>
<label style='margin:5px;' for=speedslider><?php echo translate('Speed') ?></label>
<input id=speedslider type=range min=0 max=<?php echo count($speeds)-1?> value=<?php echo $speedIndex ?> step=1 wdth=20% onchange='setSpeed(this.value)' oninput='showSpeed(this.value)'/>
<span style='margin:5px;' id=speedslideroutput><?php echo $speeds[$speedIndex] ?> fps</span>
</div>
<div style='display: inline-flex; border: 1px solid black; flex-flow: row wrap;'>
<button type='button' id=panleft onclick='panleft() '>&lt; <?php echo translate('Pan') ?></button>
<button type='button' id=zoomin onclick='zoomin() '><?php echo translate('In +') ?></button>
<button type='button' id=zoomout onclick='zoomout() '><?php echo translate('Out -') ?></button>
<button type='button' id=lasteight onclick='lastEight() '><?php echo translate('8 Hour') ?></button>
<button type='button' id=lasthour onclick='lastHour() '><?php echo translate('1 Hour') ?></button>
<button type='button' id=allof onclick='allof() '><?php echo translate('All Events') ?></button>
<button type='button' id=live onclick='setLive(1-liveMode)'><?php echo translate('Live') ?></button>
<button type='button' id=fit onclick='setFit(1-fitMode) '><?php echo translate('Fit') ?></button>
<button type='button' id=panright onclick='panright() '><?php echo translate('Pan') ?> &gt;</button>
<button type="button" id=panleft onclick='panleft() '>&lt; <?php echo translate('Pan') ?></button>
<button type="button" id=zoomin onclick='zoomin() '><?php echo translate('In +') ?></button>
<button type="button" id=zoomout onclick='zoomout() '><?php echo translate('Out -') ?></button>
<button type="button" id=lasteight onclick='lastEight() '><?php echo translate('8 Hour') ?></button>
<button type="button" id=lasthour onclick='lastHour() '><?php echo translate('1 Hour') ?></button>
<button type="button" id=allof onclick='allof() '><?php echo translate('All Events') ?></button>
<button type="button" id=live onclick='setLive(1-liveMode)'><?php echo translate('Live') ?></button>
<button type="button" id=fit onclick='setFit(1-fitMode) '><?php echo translate('Fit') ?></button>
<button type="button" id=panright onclick='panright() '><?php echo translate('Pan') ?> &gt;</button>
</div>
<div id=timelinediv style='position:relative; width:93%;'>
<canvas id=timeline style='border:1px solid;' onmousemove='mmove(event)' ontouchmove='tmove(event)' onmousedown='mdown(event)' onmouseup='mup(event)' onmouseout='mout(event)' ></canvas>
<span id=scrubleft ></span>
<span id=scrubright ></span>
<span id=scruboutput ></span>
<div id="timelinediv" style="position:relative; width:93%;">
<canvas id="timeline" style="border:1px solid;" onmousemove="mmove(event);" ontouchmove="tmove(event);" onmousedown="mdown(event);" onmouseup="mup(event);" onmouseout="mout(event);"></canvas>
<span id="scrubleft"></span>
<span id="scrubright"></span>
<span id="scruboutput"></span>
</div>
<?php
// Monitor images - these had to be loaded after the monitors used were determined (after loading events)
echo "<div id='monitors' style='position:relative; background-color:black;' width='100%' height='100%'>\n";
foreach ($monitors as $m)
{
{
echo "<canvas width='" . $m['Width'] * $defaultScale . "px' height='" . $m['Height'] * $defaultScale . "px' id='Monitor" . $m['Id'] . "' style='border:3px solid " . $m['WebColour'] . "' onclick='clickMonitor(event," . $m['Id'] . ")'>No Canvas Support!!</canvas>\n";
}
foreach ($monitors as $m) {
echo "<canvas width='" . $m['Width'] * $defaultScale . "px' height='" . $m['Height'] * $defaultScale . "px' id='Monitor" . $m['Id'] . "' style='border:3px solid " . $m['WebColour'] . "' onclick='clickMonitor(event," . $m['Id'] . ")'>No Canvas Support!!</canvas>\n";
}
echo "</div>\n";
echo "<p id='fps'>evaluating fps</p>\n";
@ -331,8 +328,7 @@ $maxTimeSecs = strtotime("1950-01-01 01:01:01");
$index=0;
$anyAlarms=false;
foreach( dbFetchAll( $eventsSql ) as $event )
{
foreach( dbFetchAll( $eventsSql ) as $event ) {
if( $minTimeSecs > $event['StartTimeSecs']) $minTimeSecs=$event['StartTimeSecs'];
if( $maxTimeSecs < $event['CalcEndTimeSecs']) $maxTimeSecs=$event['CalcEndTimeSecs'];
echo "eMonId[$index]=" . $event['MonitorId'] . "; eId[$index]=" . $event['Id'] . "; ";
@ -349,30 +345,25 @@ foreach( dbFetchAll( $eventsSql ) as $event )
echo "\n";
}
if($index == 0) // if there is no data set the min/max to the passed in values
{
if(isset($minTime) && isset($maxTime))
{
$minTimeSecs = strtotime($minTime);
$maxTimeSecs = strtotime($maxTime);
}
else // this is the case of no passed in times AND no data -- just set something arbitrary
{
$minTimeSecs=strtotime('1950-06-01 01:01:01'); // random time so there's something to display
$maxTimeSecs=strtotime('2020-06-02 02:02:02');
}
// if there is no data set the min/max to the passed in values
if($index == 0) {
if(isset($minTime) && isset($maxTime)) {
$minTimeSecs = strtotime($minTime);
$maxTimeSecs = strtotime($maxTime);
} else {
// this is the case of no passed in times AND no data -- just set something arbitrary
$minTimeSecs=strtotime('1950-06-01 01:01:01'); // random time so there's something to display
$maxTimeSecs=strtotime('2020-06-02 02:02:02');
}
}
// We only reset the calling time if there was no calling time
if(!isset($minTime) || !isset($maxTime))
{
$maxTime = strftime($maxTimeSecs);
$minTime = strftime($minTimeSecs);
}
else
{
$minTimeSecs = strtotime($minTime);
$maxTimeSecs = strtotime($maxTime);
if(!isset($minTime) || !isset($maxTime)) {
$maxTime = strftime($maxTimeSecs);
$minTime = strftime($minTimeSecs);
} else {
$minTimeSecs = strtotime($minTime);
$maxTimeSecs = strtotime($maxTime);
}
// If we had any alarms in those events, this builds the list of all alarm frames, but consolidated down to (nearly) contiguous segments
@ -389,41 +380,37 @@ $fromSecs=-1;
$toSecs=-1;
$maxScore=-1;
if($anyAlarms)
foreach( dbFetchAll ($frameSql) as $frame )
{
if($mId<0)
{
$mId=$frame['MonitorId'];
$fromSecs=$frame['TimeStampSecs'];
$toSecs=$frame['TimeStampSecs'];
$maxScore=$frame['Score'];
}
else if ($mId != $frame['MonitorId'] || $frame['TimeStampSecs'] - $toSecs > 10) // dump this one start a new
{
$index++;
echo " fMonId[$index]=" . $mId . ";";
echo " fTimeFromSecs[$index]=" . $fromSecs . ";";
echo " fTimeToSecs[$index]=" . $toSecs . ";";
echo " fScore[$index]=" . $maxScore . ";\n";
$mId=$frame['MonitorId'];
$fromSecs=$frame['TimeStampSecs'];
$toSecs=$frame['TimeStampSecs'];
$maxScore=$frame['Score'];
}
else // just add this one on
{
$toSecs=$frame['TimeStampSecs'];
if($maxScore < $frame['Score']) $maxScore=$frame['Score'];
}
}
if($mId>0)
{
echo " fMonId[$index]=" . $mId . ";";
echo " fTimeFromSecs[$index]=" . $fromSecs . ";";
echo " fTimeToSecs[$index]=" . $toSecs . ";";
echo " fScore[$index]=" . $maxScore . ";\n";
if($anyAlarms) {
foreach( dbFetchAll ($frameSql) as $frame ) {
if($mId<0) {
$mId=$frame['MonitorId'];
$fromSecs=$frame['TimeStampSecs'];
$toSecs=$frame['TimeStampSecs'];
$maxScore=$frame['Score'];
} else if ($mId != $frame['MonitorId'] || $frame['TimeStampSecs'] - $toSecs > 10) {
// dump this one start a new
$index++;
echo " fMonId[$index]=" . $mId . ";";
echo " fTimeFromSecs[$index]=" . $fromSecs . ";";
echo " fTimeToSecs[$index]=" . $toSecs . ";";
echo " fScore[$index]=" . $maxScore . ";\n";
$mId=$frame['MonitorId'];
$fromSecs=$frame['TimeStampSecs'];
$toSecs=$frame['TimeStampSecs'];
$maxScore=$frame['Score'];
} else {
// just add this one on
$toSecs=$frame['TimeStampSecs'];
if($maxScore < $frame['Score']) $maxScore=$frame['Score'];
}
}
}
if($mId>0) {
echo " fMonId[$index]=" . $mId . ";";
echo " fTimeFromSecs[$index]=" . $fromSecs . ";";
echo " fTimeToSecs[$index]=" . $toSecs . ";";
echo " fScore[$index]=" . $maxScore . ";\n";
}
echo "var maxScore=$maxScore;\n"; // used to skip frame load if we find no alarms.
echo "var monitorName = [];\n";
@ -446,17 +433,15 @@ echo "var monitorPtr = []; // monitorName[monitorPtr[0]] is first monitor\n";
$numMonitors=0; // this array is indexed by the monitor ID for faster access later, so it may be sparse
$avgArea=floatval(0); // Calculations the normalizing scale
foreach ($monitors as $m)
{
$avgArea = $avgArea + floatval($m['Width'] * $m['Height']);
$numMonitors++;
foreach ($monitors as $m) {
$avgArea = $avgArea + floatval($m['Width'] * $m['Height']);
$numMonitors++;
}
if($numMonitors>0) $avgArea= $avgArea / $numMonitors;
$numMonitors=0;
foreach ($monitors as $m)
{
foreach ($monitors as $m) {
echo " monitorLoading[" . $m['Id'] . "]=false; ";
echo " monitorImageObject[" . $m['Id'] . "]=null; ";
echo " monitorLoadingStageURL[" . $m['Id'] . "] = ''; ";
@ -543,34 +528,28 @@ function evaluateLoadTimes()
$('fps').innerHTML="Display refresh rate is " + (1000 / currentDisplayInterval).toFixed(1) + " per second, avgFrac=" + avgFrac.toFixed(3) + ".";
}
function SetImageSource(monId,val)
{
if(liveMode==1)
{ // This uses the standard php routine to set up the url and authentication, but because it is called repeatedly the built in random number is not usable, so one is appended below for two total (yuck)
var effectiveScale = (100.0 * monitorCanvasObj[monId].width) / monitorWidth[monId];
var $x = "<?php echo getStreamSrc( array("mode=single"),"&" )?>" + "&monitor=" + monId.toString() + "&scale=" + effectiveScale + Math.random().toString() ;
return $x;
}
else
{
var zeropad = <?php echo sprintf("\"%0" . ZM_EVENT_IMAGE_DIGITS . "d\"",0); ?>;
for(var i=0, var eIdlength = eId.length; i<eIdlength; i++) // Search for a match
{
if(eMonId[i]==monId && val >= eStartSecs[i] && val <= eEndSecs[i])
{
var frame=parseInt((val - eStartSecs[i])/(eEndSecs[i]-eStartSecs[i])*eventFrames[i])+1;
img = "index.php?view=image&eid=" + eId[i] + '&fid='+frame + "&width=" + monitorCanvasObj[monId].width + "&height=" + monitorCanvasObj[monId].height;
return img;
}
}
return "no data";
}
function SetImageSource(monId,val) {
if(liveMode==1) {
// This uses the standard php routine to set up the url and authentication, but because it is called repeatedly the built in random number is not usable, so one is appended below for two total (yuck)
var effectiveScale = (100.0 * monitorCanvasObj[monId].width) / monitorWidth[monId];
var $x = "<?php echo getStreamSrc( array("mode=single"),"&" )?>" + "&monitor=" + monId.toString() + "&scale=" + effectiveScale + Math.random().toString() ;
return $x;
} else {
var zeropad = <?php echo sprintf("\"%0" . ZM_EVENT_IMAGE_DIGITS . "d\"",0); ?>;
for(var i=0, eIdlength = eId.length; i<eIdlength; i++) {
// Search for a match
if(eMonId[i]==monId && val >= eStartSecs[i] && val <= eEndSecs[i]) {
var frame=parseInt((val - eStartSecs[i])/(eEndSecs[i]-eStartSecs[i])*eventFrames[i])+1;
img = "index.php?view=image&eid=" + eId[i] + '&fid='+frame + "&width=" + monitorCanvasObj[monId].width + "&height=" + monitorCanvasObj[monId].height;
return img;
}
} // end for
return "no data";
}
}
function imagedone(obj, monId, success)
{
if(success)
{
function imagedone(obj, monId, success) {
if(success) {
monitorCanvasCtx[monId].drawImage( monitorImageObject[monId], 0, 0, monitorCanvasObj[monId].width, monitorCanvasObj[monId].height);
var iconSize=(Math.max(monitorCanvasObj[monId].width,monitorCanvasObj[monId].height) * 0.10);
monitorCanvasCtx[monId].font = "600 " + iconSize.toString() + "px Arial";
@ -583,10 +562,10 @@ function imagedone(obj, monId, success)
evaluateLoadTimes();
}
monitorLoading[monId]=false;
if(!success) // if we had a failrue queue up the no-data image
if(!success) {
// if we had a failrue queue up the no-data image
loadImage2Monitor(monId,"no data"); // leave the staged URL if there is one, just ignore it here.
else
{
} else {
if(monitorLoadingStageURL[monId]=="") return;
loadImage2Monitor(monId,monitorLoadingStageURL[monId]);
monitorLoadingStageURL[monId]="";
@ -594,24 +573,19 @@ function imagedone(obj, monId, success)
return;
}
function loadImage2Monitor(monId,url)
{
if(monitorLoading[monId] && monitorImageObject[monId].src != url ) // never queue the same image twice (if it's loading it has to be defined, right?
{
monitorLoadingStageURL[monId]=url; // we don't care if we are overriting, it means it didn't change fast enough
}
else
{
function loadImage2Monitor(monId,url) {
if(monitorLoading[monId] && monitorImageObject[monId].src != url ) {
// never queue the same image twice (if it's loading it has to be defined, right?
monitorLoadingStageURL[monId]=url; // we don't care if we are overriting, it means it didn't change fast enough
} else {
var skipthis=0;
if( typeof monitorImageObject[monId] !== "undefined" && monitorImageObject[monId] != null && monitorImageObject[monId].src == url ) return; // do nothing if it's the same
if( monitorImageObject[monId] == null )
{
if( monitorImageObject[monId] == null ) {
monitorImageObject[monId]=new Image();
monitorImageObject[monId].onload = function() {imagedone(this, monId,true )};
monitorImageObject[monId].onerror = function() {imagedone(this, monId,false)};
}
if(url=='no data')
{
if(url=='no data') {
monitorCanvasCtx[monId].fillStyle="white";
monitorCanvasCtx[monId].fillRect(0,0,monitorCanvasObj[monId].width,monitorCanvasObj[monId].height);
var textSize=monitorCanvasObj[monId].width * 0.15;
@ -620,43 +594,38 @@ function loadImage2Monitor(monId,url)
monitorCanvasCtx[monId].fillStyle="black";
var textWidth = monitorCanvasCtx[monId].measureText(text).width;
monitorCanvasCtx[monId].fillText(text,monitorCanvasObj[monId].width/2 - textWidth/2,monitorCanvasObj[monId].height/2);
}
else
{
} else {
monitorLoading[monId]=true;
monitorLoadStartTimems[monId]=new Date().getTime();
monitorImageObject[monId].src=url; // starts a load but doesn't refresh yet, wait until ready
}
}
}
function timerFire()
{
// See if we need to reschedule
if(currentDisplayInterval != timerInterval || currentSpeed == 0) // zero just turn off interrupts
{
clearInterval(timerObj);
timerInterval=currentDisplayInterval;
if(currentSpeed>0 || liveMode!=0) timerObj=setInterval(timerFire,timerInterval); // don't fire out of live mode if speed is zero
}
function timerFire() {
// See if we need to reschedule
if(currentDisplayInterval != timerInterval || currentSpeed == 0) {
// zero just turn off interrupts
clearInterval(timerObj);
timerInterval=currentDisplayInterval;
if(currentSpeed>0 || liveMode!=0) timerObj=setInterval(timerFire,timerInterval); // don't fire out of live mode if speed is zero
}
if (liveMode) outputUpdate(currentTimeSecs); // In live mode we basically do nothing but redisplay
else if (currentTimeSecs + playSecsperInterval >= maxTimeSecs) // beyond the end just stop
{
setSpeed(0);
outputUpdate(currentTimeSecs);
}
else outputUpdate(currentTimeSecs + playSecsperInterval);
return;
if (liveMode) outputUpdate(currentTimeSecs); // In live mode we basically do nothing but redisplay
else if (currentTimeSecs + playSecsperInterval >= maxTimeSecs) // beyond the end just stop
{
setSpeed(0);
outputUpdate(currentTimeSecs);
}
else outputUpdate(currentTimeSecs + playSecsperInterval);
return;
}
function drawSliderOnGraph(val)
{
function drawSliderOnGraph(val) {
var sliderWidth=10;
var sliderLineWidth=1;
var sliderHeight=cHeight;
if(liveMode==1)
{
if(liveMode==1) {
val=Math.floor( Date.now() / 1000);
}
// Set some sizes
@ -665,8 +634,8 @@ function drawSliderOnGraph(val)
var labbottom=parseInt(cHeight * 0.2 / (numMonitors+1)).toString() + "px"; // This is positioning same as row labels below, but from bottom so 1-position
var labfont=labelpx + "px Georgia"; // set this like below row labels
if(numMonitors>0) // if we have no data to display don't do the slider itself
{
if(numMonitors>0) {
// if we have no data to display don't do the slider itself
var sliderX=parseInt( (val - minTimeSecs) / rangeTimeSecs * cWidth - sliderWidth/2); // position left side of slider
if(sliderX < 0) sliderX=0;
if(sliderX+sliderWidth > cWidth) sliderX=cWidth-sliderWidth-1;
@ -896,18 +865,17 @@ HTMLCanvasElement.prototype.relMouseCoords = relMouseCoords;
// These are the functions for mouse movement in the timeline. Note that touch is treated as a mouse move with mouse down
var mouseisdown=false;
function mdown(event) {mouseisdown=true; mmove(event)}
function mdown(event) {mouseisdown=true; mmove(event);}
function mup(event) {mouseisdown=false;}
function mout(event) {mouseisdown=false;} // if we go outside treat it as release
function tmove(event) {mouseisdown=true; mmove(event);}
function mmove(event)
{
if(mouseisdown) // only do anything if the mouse is depressed while on the sheet
{
var sec = minTimeSecs + rangeTimeSecs / event.target.width * event.target.relMouseCoords(event).x;
outputUpdate(sec);
}
function mmove(event) {
if(mouseisdown) {
// only do anything if the mouse is depressed while on the sheet
var sec = minTimeSecs + rangeTimeSecs / event.target.width * event.target.relMouseCoords(event).x;
outputUpdate(sec);
}
}
function secs2dbstr (s)

View File

@ -74,8 +74,9 @@ if ( empty($_REQUEST['path']) ) {
}
if ( ! file_exists( $path ) ) {
Debug( "$path does not exist");
# Generate the frame JPG
if ( $Event->DefaultVideo() ) {
if ( $show == 'capt' and $Event->DefaultVideo() ) {
$command ='ffmpeg -i '.$Event->Path().'/'.$Event->DefaultVideo().' -vf "select=gte(n\\,'.$Frame->FrameId().'),setpts=PTS-STARTPTS" '.$path;
#$command ='ffmpeg -v 0 -i '.$Storage->Path().'/'.$Event->Path().'/'.$Event->DefaultVideo().' -vf "select=gte(n\\,'.$Frame->FrameId().'),setpts=PTS-STARTPTS" '.$path;
Debug( "Running $command" );