fix getVideoStream to getVideoStreamHTML. Change how scaling works

This commit is contained in:
Isaac Connor 2017-11-08 11:17:30 -05:00
parent b6548ba137
commit 625170bffc
1 changed files with 23 additions and 14 deletions

View File

@ -339,11 +339,11 @@ function getVideoStreamHTML( $id, $src, $width, $height, $format, $title='' ) {
} }
function outputImageStream( $id, $src, $width, $height, $title='' ) { function outputImageStream( $id, $src, $width, $height, $title='' ) {
echo getImageStream( $id, $src, $width, $height, $title ); echo getImageStreamHTML( $id, $src, $width, $height, $title );
} }
function getImageStream( $id, $src, $width, $height, $title='' ) { function getImageStreamHTML( $id, $src, $width, $height, $title='' ) {
if ( canStreamIframe() ) { if ( canStreamIframe() ) {
return '<iframe id="'.$id.'" src="'.$src.'" alt="'. validHtmlStr($title) .'" '.($width? ' width="'. validInt($width).'"' : '').($height?' height="'.validInt($height).'"' : '' ).'/>'; return '<iframe id="'.$id.'" src="'.$src.'" alt="'. validHtmlStr($title) .'" '.($width? ' width="'. validInt($width).'"' : '').($height?' height="'.validInt($height).'"' : '' ).'/>';
} else { } else {
@ -1239,12 +1239,18 @@ function parseFilter( &$filter, $saveToSession=false, $querySep='&amp;' ) {
$value = dbEscape($value); $value = dbEscape($value);
break; break;
case 'DateTime': case 'DateTime':
case 'StartDateTime':
case 'EndDateTime':
$value = "'".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."'"; $value = "'".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."'";
break; break;
case 'Date': case 'Date':
case 'StartDate':
case 'EndDate':
$value = "to_days( '".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."' )"; $value = "to_days( '".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."' )";
break; break;
case 'Time': case 'Time':
case 'StartTime':
case 'EndTime':
$value = "extract( hour_second from '".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."' )"; $value = "extract( hour_second from '".strftime( STRF_FMT_DATETIME_DB, strtotime( $value ) )."' )";
break; break;
default : default :
@ -1281,13 +1287,15 @@ function parseFilter( &$filter, $saveToSession=false, $querySep='&amp;' ) {
case 'IS NOT' : case 'IS NOT' :
$filter['sql'] .= " IS NOT $value"; $filter['sql'] .= " IS NOT $value";
break; break;
default:
Warning("Invalid operator in filter: " . $terms[$i]['op'] );
} }
$filter['query'] .= $querySep.urlencode("filter[Query][terms][$i][op]").'='.urlencode($terms[$i]['op']); $filter['query'] .= $querySep.urlencode("filter[Query][terms][$i][op]").'='.urlencode($terms[$i]['op']);
$filter['fields'] .= "<input type=\"hidden\" name=\"filter[Query][terms][$i][op]\" value=\"".htmlspecialchars($terms[$i]['op'])."\"/>\n"; $filter['fields'] .= "<input type=\"hidden\" name=\"filter[Query][terms][$i][op]\" value=\"".htmlspecialchars($terms[$i]['op'])."\"/>\n";
$filter['query'] .= $querySep.urlencode("filter[Query][terms][$i][val]").'='.urlencode($terms[$i]['val']); $filter['query'] .= $querySep.urlencode("filter[Query][terms][$i][val]").'='.urlencode($terms[$i]['val']);
$filter['fields'] .= "<input type=\"hidden\" name=\"filter[Query][terms][$i][val]\" value=\"".htmlspecialchars($terms[$i]['val'])."\"/>\n"; $filter['fields'] .= "<input type=\"hidden\" name=\"filter[Query][terms][$i][val]\" value=\"".htmlspecialchars($terms[$i]['val'])."\"/>\n";
} } // end foreach term
if ( isset($terms[$i]['cbr']) ) { if ( isset($terms[$i]['cbr']) ) {
$filter['query'] .= $querySep.urlencode("filter[Query][terms][$i][cbr]").'='.urlencode($terms[$i]['cbr']); $filter['query'] .= $querySep.urlencode("filter[Query][terms][$i][cbr]").'='.urlencode($terms[$i]['cbr']);
$filter['sql'] .= ' '.str_repeat( ')', $terms[$i]['cbr'] ).' '; $filter['sql'] .= ' '.str_repeat( ')', $terms[$i]['cbr'] ).' ';
@ -1302,13 +1310,14 @@ function parseFilter( &$filter, $saveToSession=false, $querySep='&amp;' ) {
} }
} }
// Please note that the filter is passed in by copy, so you need to use the return value from this function.
//
function addFilterTerm( $filter, $position, $term=false ) { function addFilterTerm( $filter, $position, $term=false ) {
if ( $position < 0 ) if ( $position < 0 )
$position = 0; $position = 0;
if ( ! isset( $filter['Query']['terms'] ) ) if ( ! isset( $filter['Query']['terms'] ) )
$filter['Query']['terms'] = array(); $filter['Query']['terms'] = array();
elseif( $position > count($filter['Query']['terms']) ) elseif( $position > count($filter['Query']['terms']) )
$position = count($filter['Query']['terms']); $position = count($filter['Query']['terms']);
if ( $term && $position == 0 ) if ( $term && $position == 0 )
@ -2141,37 +2150,37 @@ function validHtmlStr( $input ) {
function getStreamHTML( $monitor, $options = array() ) { function getStreamHTML( $monitor, $options = array() ) {
if ( isset($options['scale']) and $options['scale'] and ( $options['scale'] != 100 ) ) { if ( isset($options['scale']) and $options['scale'] and ( $options['scale'] != 100 ) ) {
Warning("Scale to " . $options['scale'] );
$options['width'] = reScale( $monitor->Width(), $options['scale'] ); $options['width'] = reScale( $monitor->Width(), $options['scale'] );
$options['height'] = reScale( $monitor->Height(), $options['scale'] ); $options['height'] = reScale( $monitor->Height(), $options['scale'] );
} else { } else {
if ( ! isset( $options['width'] ) ) { # scale is empty or 100
$options['width'] = NULL; # There may be a fixed width applied though, in which case we need to leave the height empty
} else if ( $options['width'] == 100 ) { if ( ! ( isset($options['width']) and $options['width'] ) ) {
$options['width'] = $monitor->Width(); $options['width'] = $monitor->Width();
} if ( ! ( isset($options['height']) and $options['height'] ) ) {
if ( ! isset( $options['height'] ) ) {
$options['height'] = NULL;
} else if ( $options['height'] == 100 ) {
$options['height'] = $monitor->Height(); $options['height'] = $monitor->Height();
} }
} }
}
if ( ! isset($options['mode'] ) ) { if ( ! isset($options['mode'] ) ) {
$options['mode'] = 'stream'; $options['mode'] = 'stream';
} }
$options['maxfps'] = ZM_WEB_VIDEO_MAXFPS; $options['maxfps'] = ZM_WEB_VIDEO_MAXFPS;
if ( $monitor->StreamReplayBuffer() ) if ( $monitor->StreamReplayBuffer() )
$options['buffer'] = $monitor->StreamReplayBuffer(); $options['buffer'] = $monitor->StreamReplayBuffer();
Warning("width: " . $options['width'] . ' height: ' . $options['height']. ' scale: ' . $options['scale'] );
//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'=>$options['scale'], 'bitrate'=>ZM_WEB_VIDEO_BITRATE, 'maxfps'=>ZM_WEB_VIDEO_MAXFPS, 'format' => ZM_MPEG_LIVE_FORMAT ) ); $streamSrc = $monitor->getStreamSrc( array( 'mode'=>'mpeg', 'scale'=>$options['scale'], 'bitrate'=>ZM_WEB_VIDEO_BITRATE, 'maxfps'=>ZM_WEB_VIDEO_MAXFPS, 'format' => ZM_MPEG_LIVE_FORMAT ) );
return getVideoStream( 'liveStream'.$monitor->Id(), $streamSrc, $options, ZM_MPEG_LIVE_FORMAT, $monitor->Name() ); return getVideoStreamHTML( 'liveStream'.$monitor->Id(), $streamSrc, $options['width'], $options['height'], ZM_MPEG_LIVE_FORMAT, $monitor->Name() );
} else if ( $options['mode'] == 'stream' and canStream() ) { } else if ( $options['mode'] == 'stream' and canStream() ) {
$options['mode'] = 'jpeg'; $options['mode'] = 'jpeg';
$streamSrc = $monitor->getStreamSrc( $options ); $streamSrc = $monitor->getStreamSrc( $options );
if ( canStreamNative() ) if ( canStreamNative() )
return getImageStream( 'liveStream'.$monitor->Id(), $streamSrc, $options['width'], $options['height'], $monitor->Name()); return getImageStreamHTML( 'liveStream'.$monitor->Id(), $streamSrc, $options['width'], $options['height'], $monitor->Name());
elseif ( canStreamApplet() ) elseif ( canStreamApplet() )
// Helper, empty widths and heights really don't work. // Helper, empty widths and heights really don't work.
return getHelperStream( 'liveStream'.$monitor->Id(), $streamSrc, return getHelperStream( 'liveStream'.$monitor->Id(), $streamSrc,