2008-07-14 21:54:50 +08:00
|
|
|
<?php
|
|
|
|
//
|
|
|
|
// ZoneMinder web cycle 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' ) )
|
|
|
|
{
|
2008-09-26 17:47:20 +08:00
|
|
|
$view = "error";
|
2008-07-14 21:54:50 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( empty($_REQUEST['mode']) )
|
|
|
|
{
|
|
|
|
if ( ZM_WEB_USE_STREAMS && canStream() )
|
2008-09-26 17:47:20 +08:00
|
|
|
$mode = "stream";
|
2008-07-14 21:54:50 +08:00
|
|
|
else
|
2008-09-26 17:47:20 +08:00
|
|
|
$mode = "still";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$mode = validHtmlStr($_REQUEST['mode']);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( !empty($_REQUEST['group']) )
|
|
|
|
{
|
2008-09-26 17:47:20 +08:00
|
|
|
$group = validInt($_REQUEST['group']);
|
|
|
|
$sql = "select * from Groups where Id = '".dbEscape($group)."'";
|
2008-07-14 21:54:50 +08:00
|
|
|
$row = dbFetchOne( $sql );
|
|
|
|
$groupSql = " and find_in_set( Id, '".$row['MonitorIds']."' )";
|
|
|
|
}
|
2008-09-26 17:47:20 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$group = '';
|
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
|
|
|
|
$sql = "select * from Monitors where Function != 'None'$groupSql order by Sequence";
|
|
|
|
$monitors = array();
|
|
|
|
$monIdx = 0;
|
|
|
|
foreach( dbFetchAll( $sql ) as $row )
|
|
|
|
{
|
|
|
|
if ( !visibleMonitor( $row['Id'] ) )
|
|
|
|
continue;
|
|
|
|
if ( isset($_REQUEST['mid']) && $row['Id'] == $_REQUEST['mid'] )
|
|
|
|
$monIdx = count($monitors);
|
|
|
|
$row['ScaledWidth'] = reScale( $row['Width'], $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
|
|
|
|
$row['ScaledHeight'] = reScale( $row['Height'], $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
|
|
|
|
$monitors[] = $row;
|
|
|
|
}
|
|
|
|
|
|
|
|
$monitor = $monitors[$monIdx];
|
|
|
|
$nextMid = $monIdx==(count($monitors)-1)?$monitors[0]['Id']:$monitors[$monIdx+1]['Id'];
|
2008-07-15 17:04:09 +08:00
|
|
|
$montageWidth = $monitor['ScaledWidth'];
|
|
|
|
$montageHeight = $monitor['ScaledHeight'];
|
2008-07-14 21:54:50 +08:00
|
|
|
$widthScale = ($montageWidth*SCALE_BASE)/$monitor['Width'];
|
|
|
|
$heightScale = ($montageHeight*SCALE_BASE)/$monitor['Height'];
|
|
|
|
$scale = (int)(($widthScale<$heightScale)?$widthScale:$heightScale);
|
|
|
|
|
|
|
|
if ( false && (ZM_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 ) );
|
|
|
|
}
|
2008-09-26 17:47:20 +08:00
|
|
|
elseif ( $mode == 'stream' && canStream() )
|
2008-07-14 21:54:50 +08:00
|
|
|
{
|
|
|
|
$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 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
noCacheHeaders();
|
|
|
|
|
|
|
|
$focusWindow = true;
|
|
|
|
|
|
|
|
xhtmlHeaders(__FILE__, $SLANG['CycleWatch'] );
|
|
|
|
?>
|
|
|
|
<body>
|
|
|
|
<div id="page">
|
|
|
|
<div id="header">
|
|
|
|
<div id="headerButtons">
|
2008-09-26 17:47:20 +08:00
|
|
|
<?php if ( $mode == "stream" ) { ?>
|
|
|
|
<a href="?view=<?= $view ?>&mode=still&group=<?= $group ?>&mid=<?= $monitor['Id'] ?>"><?= $SLANG['Stills'] ?></a>
|
2008-07-14 21:54:50 +08:00
|
|
|
<?php } else { ?>
|
2008-09-26 17:47:20 +08:00
|
|
|
<a href="?view=<?= $view ?>&mode=stream&group=<?= $group ?>&mid=<?= $monitor['Id'] ?>"><?= $SLANG['Stream'] ?></a>
|
2008-07-14 21:54:50 +08:00
|
|
|
<?php } ?>
|
|
|
|
<a href="#" onclick="closeWindow(); return( false );"><?= $SLANG['Close'] ?></a>
|
|
|
|
</div>
|
2008-09-26 17:47:20 +08:00
|
|
|
<h2><?= $SLANG['Cycle'] ?> - <?= validHtmlStr($monitor['Name']) ?></h2>
|
2008-07-14 21:54:50 +08:00
|
|
|
</div>
|
|
|
|
<div id="content">
|
|
|
|
<div id="imageFeed">
|
|
|
|
<?php
|
|
|
|
if ( $streamMode === "mpeg" )
|
|
|
|
{
|
2008-09-26 17:47:20 +08:00
|
|
|
outputVideoStream( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), ZM_MPEG_LIVE_FORMAT, validHtmlStr($monitor['Name']) );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
elseif ( $streamMode == "jpeg" )
|
|
|
|
{
|
|
|
|
if ( canStreamNative() )
|
2008-09-26 17:47:20 +08:00
|
|
|
outputImageStream( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), validHtmlStr($monitor['Name']) );
|
2008-07-17 00:47:56 +08:00
|
|
|
elseif ( canStreamApplet() )
|
2008-09-26 17:47:20 +08:00
|
|
|
outputHelperStream( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), validHtmlStr($monitor['Name']) );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-09-26 17:47:20 +08:00
|
|
|
outputImageStill( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), validHtmlStr($monitor['Name']) );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|