2008-07-14 21:54:50 +08:00
|
|
|
<?php
|
|
|
|
//
|
|
|
|
// ZoneMinder web watch view file, $Date$, $Revision$
|
2008-07-25 17:48:16 +08:00
|
|
|
// Copyright (C) 2001-2008 Philip Coombes
|
2008-07-14 21:54:50 +08:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 2
|
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
//
|
|
|
|
|
|
|
|
if ( !canView( 'Stream' ) )
|
|
|
|
{
|
|
|
|
$_REQUEST['view'] = "error";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-04-30 22:01:10 +08:00
|
|
|
$sql = 'select C.*, M.* from Monitors as M left join Controls as C on (M.ControlId = C.Id ) where M.Id = ?';
|
|
|
|
$monitor = dbFetchOne( $sql, NULL, array($_REQUEST['mid']) );
|
2009-09-28 21:34:10 +08:00
|
|
|
|
|
|
|
$showPtzControls = ( ZM_OPT_CONTROL && $monitor['Controllable'] && canView( 'Control' ) );
|
2008-07-14 21:54:50 +08:00
|
|
|
|
|
|
|
$zmuCommand = getZmuCommand( " -m ".$_REQUEST['mid']." -s -f" );
|
|
|
|
$zmuOutput = exec( escapeshellcmd( $zmuCommand ) );
|
2010-02-23 17:10:36 +08:00
|
|
|
list( $status, $fps ) = explode( ' ', $zmuOutput );
|
2008-07-14 21:54:50 +08:00
|
|
|
$statusString = $SLANG['Unknown'];
|
|
|
|
$fpsString = "--.--";
|
|
|
|
$class = "infoText";
|
|
|
|
if ( $status <= STATE_PREALARM )
|
|
|
|
{
|
|
|
|
$statusString = $SLANG['Idle'];
|
|
|
|
}
|
|
|
|
elseif ( $status == STATE_ALARM )
|
|
|
|
{
|
|
|
|
$statusString = $SLANG['Alarm'];
|
|
|
|
$class = "errorText";
|
|
|
|
}
|
|
|
|
elseif ( $status == STATE_ALERT )
|
|
|
|
{
|
|
|
|
$statusString = $SLANG['Alert'];
|
|
|
|
$class = "warnText";
|
|
|
|
}
|
|
|
|
elseif ( $status == STATE_TAPE )
|
|
|
|
{
|
|
|
|
$statusString = $SLANG['Record'];
|
|
|
|
}
|
|
|
|
$fpsString = sprintf( "%.2f", $fps );
|
|
|
|
|
|
|
|
$sql = "select * from Monitors where Function != 'None' order by Sequence";
|
|
|
|
$monitors = array();
|
|
|
|
$monIdx = 0;
|
|
|
|
$maxWidth = 0;
|
|
|
|
$maxHeight = 0;
|
|
|
|
foreach( dbFetchAll( $sql ) as $row )
|
|
|
|
{
|
|
|
|
if ( !visibleMonitor( $row['Id'] ) )
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ( isset($monitor['Id']) && $row['Id'] == $monitor['Id'] )
|
|
|
|
$monIdx = count($monitors);
|
|
|
|
if ( $maxWidth < $row['Width'] ) $maxWidth = $row['Width'];
|
|
|
|
if ( $maxHeight < $row['Height'] ) $maxHeight = $row['Height'];
|
|
|
|
$monitors[] = $row;
|
|
|
|
}
|
|
|
|
|
|
|
|
//$monitor = $monitors[$monIdx];
|
|
|
|
$nextMid = $monIdx==(count($monitors)-1)?$monitors[0]['Id']:$monitors[$monIdx+1]['Id'];
|
|
|
|
$prevMid = $monIdx==0?$monitors[(count($monitors)-1)]['Id']:$monitors[$monIdx-1]['Id'];
|
|
|
|
|
2010-11-04 00:42:10 +08:00
|
|
|
if ( isset( $_REQUEST['scale'] ) )
|
|
|
|
$scale = validInt($_REQUEST['scale']);
|
|
|
|
else
|
|
|
|
$scale = getDeviceScale( $monitor['Width'], $monitor['Height'] );
|
2008-07-14 21:54:50 +08:00
|
|
|
$imageSrc = getStreamSrc( array( "mode=single", "monitor=".$monitor['Id'], "scale=".$scale ), '&' );
|
|
|
|
|
2010-11-04 00:42:10 +08:00
|
|
|
if ( ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT )
|
|
|
|
{
|
|
|
|
$streamMode = "mpeg";
|
|
|
|
$streamSrc = getStreamSrc( array( "mode=".$streamMode, "monitor=".$monitor['Id'], "scale=".$scale, "bitrate=".ZM_WEB_VIDEO_BITRATE, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "format=".ZM_MPEG_LIVE_FORMAT ) );
|
|
|
|
}
|
|
|
|
elseif ( canStream() )
|
|
|
|
{
|
|
|
|
$streamMode = "jpeg";
|
|
|
|
$streamSrc = getStreamSrc( array( "mode=".$streamMode, "monitor=".$monitor['Id'], "scale=".$scale, "maxfps=".ZM_WEB_VIDEO_MAXFPS ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$streamMode = "single";
|
|
|
|
$streamSrc = getStreamSrc( array( "mode=".$streamMode, "monitor=".$monitor['Id'], "scale=".$scale ) );
|
|
|
|
}
|
|
|
|
|
2008-07-14 21:54:50 +08:00
|
|
|
xhtmlHeaders( __FILE__, $monitor['Name'].' - '.$SLANG['Watch'] );
|
|
|
|
?>
|
|
|
|
<body>
|
|
|
|
<div id="page">
|
|
|
|
<div id="content">
|
|
|
|
<p class="<?= $class ?>"><?= makeLink( "?view=events&page=1&view=events&page=1&filter%5Bterms%5D%5B0%5D%5Battr%5D%3DMonitorId&filter%5Bterms%5D%5B0%5D%5Bop%5D%3D%3D&filter%5Bterms%5D%5B0%5D%5Bval%5D%3D".$monitor['Id']."&sort_field=Id&sort_desc=1", $monitor['Name'], canView( 'Events' ) ) ?>: <?= $statusString ?> - <?= $fpsString ?> fps</p>
|
2010-11-04 00:42:10 +08:00
|
|
|
<p>
|
|
|
|
<?php
|
|
|
|
if ( $streamMode == "mpeg" )
|
|
|
|
{
|
|
|
|
outputVideoStream( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), ZM_MPEG_LIVE_FORMAT, $monitor['Name'] );
|
|
|
|
}
|
|
|
|
elseif ( $streamMode == "jpeg" )
|
|
|
|
{
|
|
|
|
if ( canStreamNative() )
|
|
|
|
outputImageStream( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), $monitor['Name'] );
|
|
|
|
elseif ( canStreamApplet() )
|
|
|
|
outputHelperStream( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), $monitor['Name'] );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
?>
|
|
|
|
<a href="?view=<?= $_REQUEST['view'] ?>&mid=<?= $monitor['Id'] ?>"><?= outputImageStill( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), $monitor['Name'] ); ?></a>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</p>
|
2008-07-14 21:54:50 +08:00
|
|
|
<?php
|
2009-09-28 21:34:10 +08:00
|
|
|
if ( $showPtzControls )
|
|
|
|
{
|
|
|
|
foreach ( getSkinIncludes( 'includes/control_functions.php' ) as $includeFile )
|
|
|
|
require_once $includeFile;
|
|
|
|
?>
|
|
|
|
<div id="ptzControls">
|
|
|
|
<?= ptzControls( $monitor ) ?>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
if ( $nextMid != $monitor['Id'] || $prevMid != $monitor['Id'] )
|
|
|
|
{
|
|
|
|
?>
|
|
|
|
<div id="contentButtons">
|
|
|
|
<a href="?view=<?= $_REQUEST['view'] ?>&mid=<?= $prevMid ?>"><?= $SLANG['Prev'] ?></a>
|
|
|
|
<a href="?view=console"><?= $SLANG['Console'] ?></a>
|
|
|
|
<a href="?view=<?= $_REQUEST['view'] ?>&mid=<?= $nextMid ?>"><?= $SLANG['Next'] ?></a>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|