update and use Monitor object to generate the stream html. Also introduce a mode parameter to getStreamHTML to specify stills
parent
be1083e007
commit
eb0ddc4e32
|
@ -2141,12 +2141,12 @@ function validHtmlStr( $input ) {
|
||||||
return( htmlspecialchars( $input, ENT_QUOTES ) );
|
return( htmlspecialchars( $input, ENT_QUOTES ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStreamHTML( $monitor, $scale=100 ) {
|
function getStreamHTML( $monitor, $scale=100, $mode="stream" ) {
|
||||||
//FIXME, the width and height of the image need to be scaled.
|
//FIXME, the width and height of the image need to be scaled.
|
||||||
if ( ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT ) {
|
if ( ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT ) {
|
||||||
$streamSrc = $monitor->getStreamSrc( array( "mode=mpeg", "scale=".$scale, "bitrate=".ZM_WEB_VIDEO_BITRATE, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "format=".ZM_MPEG_LIVE_FORMAT ) );
|
$streamSrc = $monitor->getStreamSrc( array( "mode=mpeg", "scale=".$scale, "bitrate=".ZM_WEB_VIDEO_BITRATE, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "format=".ZM_MPEG_LIVE_FORMAT ) );
|
||||||
return getVideoStream( "liveStream".$monitor->Id(), $streamSrc, reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ), ZM_MPEG_LIVE_FORMAT, $monitor->Name() );
|
return getVideoStream( "liveStream".$monitor->Id(), $streamSrc, reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ), ZM_MPEG_LIVE_FORMAT, $monitor->Name() );
|
||||||
} else if ( canStream() ) {
|
} else if ( $mode == "stream" and canStream() ) {
|
||||||
$streamSrc = $monitor->getStreamSrc( array( 'mode=jpeg', 'scale='.$scale, 'maxfps='.ZM_WEB_VIDEO_MAXFPS, 'buffer='.$monitor->StreamReplayBuffer() ) );
|
$streamSrc = $monitor->getStreamSrc( array( 'mode=jpeg', 'scale='.$scale, 'maxfps='.ZM_WEB_VIDEO_MAXFPS, 'buffer='.$monitor->StreamReplayBuffer() ) );
|
||||||
if ( canStreamNative() )
|
if ( canStreamNative() )
|
||||||
return getImageStream( "liveStream".$monitor->Id(), $streamSrc, reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ), $monitor->Name() );
|
return getImageStream( "liveStream".$monitor->Id(), $streamSrc, reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ), $monitor->Name() );
|
||||||
|
@ -2154,7 +2154,9 @@ function getStreamHTML( $monitor, $scale=100 ) {
|
||||||
return getHelperStream( "liveStream".$monitor->Id(), $streamSrc, reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ), $monitor->Name() );
|
return getHelperStream( "liveStream".$monitor->Id(), $streamSrc, reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ), $monitor->Name() );
|
||||||
} else {
|
} else {
|
||||||
$streamSrc = $monitor->getStreamSrc( array( 'mode=single', "scale=".$scale ) );
|
$streamSrc = $monitor->getStreamSrc( array( 'mode=single', "scale=".$scale ) );
|
||||||
Info( "The system has fallen back to single jpeg mode for streaming. Consider enabling Cambozola or upgrading the client browser.");
|
if ( $mode == "stream" ) {
|
||||||
|
Info( "The system has fallen back to single jpeg mode for streaming. Consider enabling Cambozola or upgrading the client browser.");
|
||||||
|
}
|
||||||
return getImageStill( "liveStream".$monitor->Id(), $streamSrc, reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ), $monitor->Name() );
|
return getImageStill( "liveStream".$monitor->Id(), $streamSrc, reScale( $monitor->Width(), $scale ), reScale( $monitor->Height(), $scale ), $monitor->Name() );
|
||||||
}
|
}
|
||||||
} // end function getStreamHTML
|
} // end function getStreamHTML
|
||||||
|
|
|
@ -18,71 +18,49 @@
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
//
|
//
|
||||||
|
|
||||||
if ( !canView( 'Stream' ) )
|
if ( !canView( 'Stream' ) ) {
|
||||||
{
|
$view = "error";
|
||||||
$view = "error";
|
return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( empty($_REQUEST['mode']) )
|
if ( empty($_REQUEST['mode']) ) {
|
||||||
{
|
if ( canStream() )
|
||||||
if ( canStream() )
|
$mode = "stream";
|
||||||
$mode = "stream";
|
else
|
||||||
else
|
$mode = "still";
|
||||||
$mode = "still";
|
} else {
|
||||||
}
|
$mode = validHtmlStr($_REQUEST['mode']);
|
||||||
else
|
|
||||||
{
|
|
||||||
$mode = validHtmlStr($_REQUEST['mode']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$group = '';
|
$group = '';
|
||||||
$groupSql = '';
|
$groupSql = '';
|
||||||
if ( !empty($_REQUEST['group']) )
|
if ( !empty($_REQUEST['group']) ) {
|
||||||
{
|
$group = validInt($_REQUEST['group']);
|
||||||
$group = validInt($_REQUEST['group']);
|
$row = dbFetchOne( 'SELECT * FROM Groups WHERE Id = ?', NULL, array($group) );
|
||||||
$row = dbFetchOne( 'SELECT * FROM Groups WHERE Id = ?', NULL, array($group) );
|
$groupSql = " and find_in_set( Id, '".$row['MonitorIds']."' )";
|
||||||
$groupSql = " and find_in_set( Id, '".$row['MonitorIds']."' )";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT * FROM Monitors WHERE Function != 'None'$groupSql ORDER BY Sequence";
|
$sql = "SELECT * FROM Monitors WHERE Function != 'None'$groupSql ORDER BY Sequence";
|
||||||
$monitors = array();
|
$monitors = array();
|
||||||
$monIdx = 0;
|
$monIdx = 0;
|
||||||
foreach( dbFetchAll( $sql ) as $row )
|
foreach( dbFetchAll( $sql ) as $row ) {
|
||||||
{
|
if ( !visibleMonitor( $row['Id'] ) )
|
||||||
if ( !visibleMonitor( $row['Id'] ) )
|
continue;
|
||||||
continue;
|
if ( isset($_REQUEST['mid']) && $row['Id'] == $_REQUEST['mid'] )
|
||||||
if ( isset($_REQUEST['mid']) && $row['Id'] == $_REQUEST['mid'] )
|
$monIdx = count($monitors);
|
||||||
$monIdx = count($monitors);
|
$row['ScaledWidth'] = reScale( $row['Width'], $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
|
||||||
$row['ScaledWidth'] = reScale( $row['Width'], $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
|
$row['ScaledHeight'] = reScale( $row['Height'], $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
|
||||||
$row['ScaledHeight'] = reScale( $row['Height'], $row['DefaultScale'], ZM_WEB_DEFAULT_SCALE );
|
$monitors[] = new Monitor( $row );
|
||||||
$monitors[] = $row;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$monitor = $monitors[$monIdx];
|
$monitor = $monitors[$monIdx];
|
||||||
$nextMid = $monIdx==(count($monitors)-1)?$monitors[0]['Id']:$monitors[$monIdx+1]['Id'];
|
$nextMid = $monIdx==(count($monitors)-1)?$monitors[0]['Id']:$monitors[$monIdx+1]['Id'];
|
||||||
$montageWidth = $monitor['ScaledWidth'];
|
$montageWidth = $monitor->ScaledWidth();
|
||||||
$montageHeight = $monitor['ScaledHeight'];
|
$montageHeight = $monitor->ScaledHeight();
|
||||||
$widthScale = ($montageWidth*SCALE_BASE)/$monitor['Width'];
|
$widthScale = ($montageWidth*SCALE_BASE)/$monitor->Width();
|
||||||
$heightScale = ($montageHeight*SCALE_BASE)/$monitor['Height'];
|
$heightScale = ($montageHeight*SCALE_BASE)/$monitor->Height();
|
||||||
$scale = (int)(($widthScale<$heightScale)?$widthScale:$heightScale);
|
$scale = (int)(($widthScale<$heightScale)?$widthScale:$heightScale);
|
||||||
|
|
||||||
if ( false && (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 ( $mode == 'stream' && 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 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
noCacheHeaders();
|
noCacheHeaders();
|
||||||
|
|
||||||
$focusWindow = true;
|
$focusWindow = true;
|
||||||
|
@ -94,33 +72,17 @@ xhtmlHeaders(__FILE__, translate('CycleWatch') );
|
||||||
<div id="header">
|
<div id="header">
|
||||||
<div id="headerButtons">
|
<div id="headerButtons">
|
||||||
<?php if ( $mode == "stream" ) { ?>
|
<?php if ( $mode == "stream" ) { ?>
|
||||||
<a href="?view=<?php echo $view ?>&mode=still&group=<?php echo $group ?>&mid=<?php echo $monitor['Id'] ?>"><?php echo translate('Stills') ?></a>
|
<a href="?view=<?php echo $view ?>&mode=still&group=<?php echo $group ?>&mid=<?php echo $monitor->Id() ?>"><?php echo translate('Stills') ?></a>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<a href="?view=<?php echo $view ?>&mode=stream&group=<?php echo $group ?>&mid=<?php echo $monitor['Id'] ?>"><?php echo translate('Stream') ?></a>
|
<a href="?view=<?php echo $view ?>&mode=stream&group=<?php echo $group ?>&mid=<?php echo $monitor->Id() ?>"><?php echo translate('Stream') ?></a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<a href="#" onclick="closeWindow(); return( false );"><?php echo translate('Close') ?></a>
|
<a href="#" onclick="closeWindow(); return( false );"><?php echo translate('Close') ?></a>
|
||||||
</div>
|
</div>
|
||||||
<h2><?php echo translate('Cycle') ?> - <?php echo validHtmlStr($monitor['Name']) ?></h2>
|
<h2><?php echo translate('Cycle') ?> - <?php echo validHtmlStr($monitor->Name()) ?></h2>
|
||||||
</div>
|
</div>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<div id="imageFeed">
|
<div id="imageFeed">
|
||||||
<?php
|
<?php echo getStreamHTML( $monitor, $scale, $mode ); ?>
|
||||||
if ( $streamMode == "mpeg" )
|
|
||||||
{
|
|
||||||
outputVideoStream( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), ZM_MPEG_LIVE_FORMAT, validHtmlStr($monitor['Name']) );
|
|
||||||
}
|
|
||||||
elseif ( $streamMode == "jpeg" )
|
|
||||||
{
|
|
||||||
if ( canStreamNative() )
|
|
||||||
outputImageStream( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), validHtmlStr($monitor['Name']) );
|
|
||||||
elseif ( canStreamApplet() )
|
|
||||||
outputHelperStream( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), validHtmlStr($monitor['Name']) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
outputImageStill( "liveStream", $streamSrc, reScale( $monitor['Width'], $scale ), reScale( $monitor['Height'], $scale ), validHtmlStr($monitor['Name']) );
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue