Merge branch 'storageareas' of github.com:ConnorTechnology/ZoneMinder into storageareas

This commit is contained in:
Isaac Connor 2017-05-05 14:59:46 -04:00
commit 5ca04b00b3
5 changed files with 91 additions and 71 deletions

View File

@ -1491,6 +1491,8 @@ void EventStream::runStream() {
if ( !paused ) { if ( !paused ) {
curr_frame_id += replay_rate>0?1:-1; curr_frame_id += replay_rate>0?1:-1;
if ( (mode == MODE_SINGLE) && ((unsigned int)curr_frame_id == event_data->frame_count) )
curr_frame_id = 1;
if ( send_frame && type != STREAM_MPEG ) { if ( send_frame && type != STREAM_MPEG ) {
Debug( 3, "dUs: %d", delta_us ); Debug( 3, "dUs: %d", delta_us );
usleep( delta_us ); usleep( delta_us );
@ -1498,7 +1500,7 @@ void EventStream::runStream() {
} else { } else {
usleep( (unsigned long)((1000000 * ZM_RATE_BASE)/((base_fps?base_fps:1)*abs(replay_rate*2))) ); usleep( (unsigned long)((1000000 * ZM_RATE_BASE)/((base_fps?base_fps:1)*abs(replay_rate*2))) );
} }
} } // end while ! zm_terminate
#if HAVE_LIBAVCODEC #if HAVE_LIBAVCODEC
if ( type == STREAM_MPEG ) if ( type == STREAM_MPEG )
delete vid_stream; delete vid_stream;

View File

@ -222,9 +222,6 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in,
} }
} }
//av_dict_set(&opts, "movflags", "frag_custom+dash+delay_moov", 0);
//if ((ret = avformat_write_header(ctx, &opts)) < 0) {
//}
//os->ctx_inited = 1; //os->ctx_inited = 1;
//avio_flush(ctx->pb); //avio_flush(ctx->pb);
//av_dict_free(&opts); //av_dict_free(&opts);
@ -232,13 +229,24 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in,
if ( audio_output_stream ) if ( audio_output_stream )
zm_dump_stream_format( oc, 1, 0, 1 ); zm_dump_stream_format( oc, 1, 0, 1 );
AVDictionary * opts = NULL;
//av_dict_set(&opts, "movflags", "frag_custom+dash+delay_moov", 0);
//av_dict_set(&opts, "movflags", "frag_custom+dash+delay_moov", 0);
//av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov+default_base_moof", 0);
if ((ret = avformat_write_header(oc, &opts)) < 0) {
Warning("Unable to set movflags to frag_custom+dash+delay_moov");
/* Write the stream header, if any. */ /* Write the stream header, if any. */
ret = avformat_write_header(oc, NULL); ret = avformat_write_header(oc, NULL);
} else if (av_dict_count(opts) != 0) {
Warning("some options not set\n");
}
if (ret < 0) { if (ret < 0) {
Error("Error occurred when writing output file header to %s: %s\n", Error("Error occurred when writing output file header to %s: %s\n",
filename, filename,
av_make_error_string(ret).c_str()); av_make_error_string(ret).c_str());
} }
if ( opts )
av_dict_free(&opts);
video_last_pts = 0; video_last_pts = 0;
video_last_dts = 0; video_last_dts = 0;

View File

@ -52,3 +52,7 @@ echo 'false';
var focusWindow = <?php echo !empty($focusWindow)?'true':'false' ?>; var focusWindow = <?php echo !empty($focusWindow)?'true':'false' ?>;
var imagePrefix = "<?php echo viewImagePath( "", '&' ) ?>"; var imagePrefix = "<?php echo viewImagePath( "", '&' ) ?>";
<?php if ( ZM_OPT_USE_AUTH && ZM_AUTH_HASH_LOGINS ) { ?>
var auth_hash = '<?php echo $_SESSION['AuthHash']; ?>';
<?php } ?>

View File

@ -18,16 +18,14 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
// //
if ( !canView( 'Events' ) || (!empty($_REQUEST['execute']) && !canEdit('Events')) ) if ( !canView( 'Events' ) || (!empty($_REQUEST['execute']) && !canEdit('Events')) ) {
{ $view = 'error';
$view = "error";
return; return;
} }
require_once( 'includes/Event.php' ); require_once( 'includes/Event.php' );
if ( !empty($_REQUEST['execute']) ) if ( !empty($_REQUEST['execute']) ) {
{
executeFilter( $tempFilterName ); executeFilter( $tempFilterName );
} }
@ -46,8 +44,7 @@ parseSort();
parseFilter( $_REQUEST['filter'] ); parseFilter( $_REQUEST['filter'] );
$filterQuery = $_REQUEST['filter']['query']; $filterQuery = $_REQUEST['filter']['query'];
if ( $_REQUEST['filter']['sql'] ) if ( $_REQUEST['filter']['sql'] ) {
{
$countSql .= $_REQUEST['filter']['sql']; $countSql .= $_REQUEST['filter']['sql'];
$eventsSql .= $_REQUEST['filter']['sql']; $eventsSql .= $_REQUEST['filter']['sql'];
} }
@ -63,25 +60,22 @@ else
$limit = 0; $limit = 0;
$nEvents = dbFetchOne( $countSql, 'EventCount' ); $nEvents = dbFetchOne( $countSql, 'EventCount' );
if ( !empty($limit) && $nEvents > $limit ) if ( !empty($limit) && $nEvents > $limit ) {
{
$nEvents = $limit; $nEvents = $limit;
} }
$pages = (int)ceil($nEvents/ZM_WEB_EVENTS_PER_PAGE); $pages = (int)ceil($nEvents/ZM_WEB_EVENTS_PER_PAGE);
if ( !empty($page) ) { if ( !empty($page) ) {
if ( $page < 0 ) if ( $page < 0 )
$page = 1; $page = 1;
if ( $page > $pages ) else if ( $page > $pages )
$page = $pages; $page = $pages;
} }
if ( !empty($page) ) { if ( !empty($page) ) {
$limitStart = (($page-1)*ZM_WEB_EVENTS_PER_PAGE); $limitStart = (($page-1)*ZM_WEB_EVENTS_PER_PAGE);
if ( empty( $limit ) ) if ( empty( $limit ) ) {
{
$limitAmount = ZM_WEB_EVENTS_PER_PAGE; $limitAmount = ZM_WEB_EVENTS_PER_PAGE;
} } else {
else
{
$limitLeft = $limit - $limitStart; $limitLeft = $limit - $limitStart;
$limitAmount = ($limitLeft>ZM_WEB_EVENTS_PER_PAGE)?ZM_WEB_EVENTS_PER_PAGE:$limitLeft; $limitAmount = ($limitLeft>ZM_WEB_EVENTS_PER_PAGE)?ZM_WEB_EVENTS_PER_PAGE:$limitLeft;
} }
@ -95,8 +89,7 @@ $maxHeight = 0;
$archived = false; $archived = false;
$unarchived = false; $unarchived = false;
$events = array(); $events = array();
foreach ( dbFetchAll( $eventsSql ) as $event_row ) foreach ( dbFetchAll( $eventsSql ) as $event_row ) {
{
$events[] = $event = new Event( $event_row ); $events[] = $event = new Event( $event_row );
# Doesn this code do anything? # Doesn this code do anything?
@ -124,16 +117,12 @@ xhtmlHeaders(__FILE__, translate('Events') );
<div id="header"> <div id="header">
<div id="headerButtons"> <div id="headerButtons">
<?php <?php
if ( $pages > 1 ) if ( $pages > 1 ) {
{ if ( !empty($page) ) {
if ( !empty($page) )
{
?> ?>
<a href="?view=<?php echo $view ?>&amp;page=0<?php echo $filterQuery ?><?php echo $sortQuery ?>&amp;limit=<?php echo $limit ?>"><?php echo translate('ViewAll') ?></a> <a href="?view=<?php echo $view ?>&amp;page=0<?php echo $filterQuery ?><?php echo $sortQuery ?>&amp;limit=<?php echo $limit ?>"><?php echo translate('ViewAll') ?></a>
<?php <?php
} } else {
else
{
?> ?>
<a href="?view=<?php echo $view ?>&amp;page=1<?php echo $filterQuery ?><?php echo $sortQuery ?>&amp;limit=<?php echo $limit ?>"><?php echo translate('ViewPaged') ?></a> <a href="?view=<?php echo $view ?>&amp;page=1<?php echo $filterQuery ?><?php echo $sortQuery ?>&amp;limit=<?php echo $limit ?>"><?php echo translate('ViewPaged') ?></a>
<?php <?php
@ -154,8 +143,7 @@ if ( $pages > 1 )
<input type="hidden" name="sort_asc" value="<?php echo validHtmlStr($_REQUEST['sort_asc']) ?>"/> <input type="hidden" name="sort_asc" value="<?php echo validHtmlStr($_REQUEST['sort_asc']) ?>"/>
<input type="hidden" name="limit" value="<?php echo $limit ?>"/> <input type="hidden" name="limit" value="<?php echo $limit ?>"/>
<?php <?php
if ( $pagination ) if ( $pagination ) {
{
?> ?>
<h3 class="pagination"><?php echo $pagination ?></h3> <h3 class="pagination"><?php echo $pagination ?></h3>
<?php <?php
@ -170,10 +158,8 @@ if ( $pagination )
<tbody> <tbody>
<?php <?php
$count = 0; $count = 0;
foreach ( $events as $event ) foreach ( $events as $event ) {
{ if ( ($count++%ZM_WEB_EVENTS_PER_PAGE) == 0 ) {
if ( ($count++%ZM_WEB_EVENTS_PER_PAGE) == 0 )
{
?> ?>
<tr> <tr>
<th class="colId"><a href="<?php echo sortHeader( 'Id' ) ?>"><?php echo translate('Id') ?><?php echo sortTag( 'Id' ) ?></a></th> <th class="colId"><a href="<?php echo sortHeader( 'Id' ) ?>"><?php echo translate('Id') ?><?php echo sortTag( 'Id' ) ?></a></th>
@ -191,8 +177,7 @@ foreach ( $events as $event )
<th class="colDiskSpace"><a href="<?php echo sortHeader( 'DiskSpace' ) ?>"><?php echo translate('DiskSpace') ?><?php echo sortTag( 'DiskSpace' ) ?></a></th> <th class="colDiskSpace"><a href="<?php echo sortHeader( 'DiskSpace' ) ?>"><?php echo translate('DiskSpace') ?><?php echo sortTag( 'DiskSpace' ) ?></a></th>
<?php <?php
} }
if ( ZM_WEB_LIST_THUMBS ) if ( ZM_WEB_LIST_THUMBS ) {
{
?> ?>
<th class="colThumbnail"><?php echo translate('Thumbnail') ?></th> <th class="colThumbnail"><?php echo translate('Thumbnail') ?></th>
<?php <?php
@ -220,16 +205,26 @@ foreach ( $events as $event )
<td class="colDiskSpace"><?php echo human_filesize( $event->DiskSpace() ) ?></td> <td class="colDiskSpace"><?php echo human_filesize( $event->DiskSpace() ) ?></td>
<?php <?php
} }
if ( ZM_WEB_LIST_THUMBS ) if ( ZM_WEB_LIST_THUMBS ) {
{ if ( $thumbData = $event->createListThumbnail() ) {
if ( $thumbData = $event->createListThumbnail() )
{
?> ?>
<td class="colThumbnail"><?php echo makePopupLink( '?view=frame&amp;eid='.$event->Id().'&amp;fid='.$thumbData['FrameId'], 'zmImage', array( 'image', reScale( $event->Width(), $scale ), reScale( $event->Height(), $scale ) ), '<img src="?view=image&amp;eid='.$event->Id().'&amp;fid='.$thumbData['FrameId'].'&amp;width='.$thumbData['Width'].'&amp;height='.$thumbData['Height'].'" width="'.$thumbData['Width'].'" height="'.$thumbData['Height'].'" alt="'.$thumbData['FrameId'].'/'.$event->MaxScore().'"/>' ) ?></td> <td class="colThumbnail">
<?php <?php
}
else $imgSrc = '?view=image&amp;eid='.$event->Id().'&amp;fid='.$thumbData['FrameId'].'&amp;width='.$thumbData['Width'].'&amp;height='.$thumbData['Height'];
{ $streamSrc = getStreamSrc( array( "source=event", "mode=jpeg", "event=".$event->Id(), "scale=".$scale, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "replay=single") );
$imgHtml = '<img id="thumbnail'.$event->id().'" src="'.$imgSrc.'" alt="'. validHtmlStr('Event '.$event->Id()) .'" style="width:'. validInt($thumbData['Width']) .'px;height:'. validInt( $thumbData['Height'] ).'px;" onmouseover="this.src=\''.$streamSrc.'\';" onmouseout="this.src=\''.$imgSrc.'\';"/>';
echo makePopupLink(
'?view=frame&amp;eid='.$event->Id().'&amp;fid='.$thumbData['FrameId'],
'zmImage',
array( 'image', reScale( $event->Width(), $scale ), reScale( $event->Height(), $scale ) ),
$imgHtml
);
?></td>
<?php
} else {
?> ?>
<td class="colThumbnail">&nbsp;</td> <td class="colThumbnail">&nbsp;</td>
<?php <?php

View File

@ -94,6 +94,9 @@ function setAlarmState( currentAlarmState ) {
} }
var streamCmdParms = "view=request&request=stream&connkey="+connKey; var streamCmdParms = "view=request&request=stream&connkey="+connKey;
if ( auth_hash )
streamCmdParms += '&auth='+auth_hash;
var streamCmdReq = new Request.JSON( { url: monitorUrl+thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getStreamCmdResponse } ); var streamCmdReq = new Request.JSON( { url: monitorUrl+thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getStreamCmdResponse } );
var streamCmdTimer = null; var streamCmdTimer = null;
@ -325,6 +328,8 @@ function streamCmdQuery() {
} }
var statusCmdParms = "view=request&request=status&entity=monitor&id="+monitorId+"&element[]=Status&element[]=FrameRate"; var statusCmdParms = "view=request&request=status&entity=monitor&id="+monitorId+"&element[]=Status&element[]=FrameRate";
if ( auth_hash )
statusCmdParms += '&auth='+auth_hash;
var statusCmdReq = new Request.JSON( { url: monitorUrl+thisUrl, method: 'post', data: statusCmdParms, timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getStatusCmdResponse } ); var statusCmdReq = new Request.JSON( { url: monitorUrl+thisUrl, method: 'post', data: statusCmdParms, timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getStatusCmdResponse } );
var statusCmdTimer = null; var statusCmdTimer = null;
@ -350,6 +355,8 @@ function statusCmdQuery() {
} }
var alarmCmdParms = "view=request&request=alarm&id="+monitorId; var alarmCmdParms = "view=request&request=alarm&id="+monitorId;
if ( auth_hash )
alarmCmdParms += '&auth='+auth_hash;
var alarmCmdReq = new Request.JSON( { url: monitorUrl+thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getAlarmCmdResponse, onTimeout: streamCmdQuery } ); var alarmCmdReq = new Request.JSON( { url: monitorUrl+thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getAlarmCmdResponse, onTimeout: streamCmdQuery } );
var alarmCmdFirst = true; var alarmCmdFirst = true;
@ -390,6 +397,8 @@ function deleteEvent( event, eventId ) {
} }
var eventCmdParms = "view=request&request=status&entity=events&id="+monitorId+"&count="+maxDisplayEvents+"&sort=Id%20desc"; var eventCmdParms = "view=request&request=status&entity=events&id="+monitorId+"&count="+maxDisplayEvents+"&sort=Id%20desc";
if ( auth_hash )
eventCmdParms += '&auth='+auth_hash;
var eventCmdReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, data: eventCmdParms, link: 'cancel', onSuccess: getEventCmdResponse, onTimeout: eventCmdQuery } ); var eventCmdReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, data: eventCmdParms, link: 'cancel', onSuccess: getEventCmdResponse, onTimeout: eventCmdQuery } );
var eventCmdTimer = null; var eventCmdTimer = null;
var eventCmdFirst = true; var eventCmdFirst = true;
@ -496,6 +505,8 @@ function eventCmdQuery() {
} }
var controlParms = "view=request&request=control&id="+monitorId; var controlParms = "view=request&request=control&id="+monitorId;
if ( auth_hash )
controlParms += '&auth='+auth_hash;
var controlReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getControlResponse } ); var controlReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getControlResponse } );
function getControlResponse( respObj, respText ) { function getControlResponse( respObj, respText ) {