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

This commit is contained in:
Isaac Connor 2017-09-25 16:23:33 -04:00
commit 1791d3d5b7
9 changed files with 177 additions and 46 deletions

View File

@ -172,7 +172,7 @@ set(ZM_PATH_ARP "" CACHE PATH
"Full path to compatible arp binary. Leave empty for automatic detection.")
set(ZM_CONFIG_DIR "/${CMAKE_INSTALL_SYSCONFDIR}" CACHE PATH
"Location of ZoneMinder configuration, default system config directory")
set(ZM_CONFIG_SUBDIR "${ZM_CONFIG_DIR}/zm/conf.d" CACHE PATH
set(ZM_CONFIG_SUBDIR "${ZM_CONFIG_DIR}/conf.d" CACHE PATH
"Location of ZoneMinder configuration subfolder, default: ZM_CONFIG_DIR/conf.d")
set(ZM_EXTRA_LIBS "" CACHE STRING
"A list of optional libraries, separated by semicolons, e.g. ssl;theora")

View File

@ -832,38 +832,44 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event
startTime,
this->getMonitor());
} // end if record_audio
strcpy(oldDirectory, event_file);
monitor->SetVideoWriterEventId( last_event_id );
if ( ! videoStore->open() ) {
delete videoStore;
videoStore = NULL;
// Need to write out all the frames from the last keyframe?
// No... need to write out all frames from when the event began. Due to PreEventFrames, this could be more than since the last keyframe.
unsigned int packet_count = 0;
ZMPacket *queued_packet;
} else {
strcpy(oldDirectory, event_file);
monitor->SetVideoWriterEventId( last_event_id );
// Clear all packets that predate the moment when the recording began
packetqueue.clear_unwanted_packets( &recording, mVideoStreamId );
// Need to write out all the frames from the last keyframe?
// No... need to write out all frames from when the event began. Due to PreEventFrames, this could be more than since the last keyframe.
unsigned int packet_count = 0;
ZMPacket *queued_packet;
while ( ( queued_packet = packetqueue.popPacket() ) ) {
AVPacket *avp = queued_packet->av_packet();
// Clear all packets that predate the moment when the recording began
packetqueue.clear_unwanted_packets( &recording, mVideoStreamId );
packet_count += 1;
//Write the packet to our video store
Debug(2, "Writing queued packet stream: %d KEY %d, remaining (%d)", avp->stream_index, avp->flags & AV_PKT_FLAG_KEY, packetqueue.size() );
if ( avp->stream_index == mVideoStreamId ) {
ret = videoStore->writeVideoFramePacket( avp );
have_video_keyframe = true;
} else if ( avp->stream_index == mAudioStreamId ) {
ret = videoStore->writeAudioFramePacket( avp );
} else {
Warning("Unknown stream id in queued packet (%d)", avp->stream_index );
ret = -1;
}
if ( ret < 0 ) {
//Less than zero and we skipped a frame
}
delete queued_packet;
} // end while packets in the packetqueue
Debug(2, "Wrote %d queued packets", packet_count );
while ( ( queued_packet = packetqueue.popPacket() ) ) {
AVPacket *avp = queued_packet->av_packet();
packet_count += 1;
//Write the packet to our video store
Debug(2, "Writing queued packet stream: %d KEY %d, remaining (%d)", avp->stream_index, avp->flags & AV_PKT_FLAG_KEY, packetqueue.size() );
if ( avp->stream_index == mVideoStreamId ) {
ret = videoStore->writeVideoFramePacket( avp );
have_video_keyframe = true;
} else if ( avp->stream_index == mAudioStreamId ) {
ret = videoStore->writeAudioFramePacket( avp );
} else {
Warning("Unknown stream id in queued packet (%d)", avp->stream_index );
ret = -1;
}
if ( ret < 0 ) {
//Less than zero and we skipped a frame
}
delete queued_packet;
} // end while packets in the packetqueue
Debug(2, "Wrote %d queued packets", packet_count );
}
} // end if ! was recording
} else {

View File

@ -112,8 +112,8 @@ Logger::Logger() :
Logger::~Logger() {
terminate();
smCodes.clear();
smSyslogPriorities.clear();
smCodes.clear();
smSyslogPriorities.clear();
#if 0
for ( StringMap::iterator itr = smCodes.begin(); itr != smCodes.end(); itr ++ ) {
smCodes.erase( itr );
@ -193,6 +193,13 @@ void Logger::initialise( const std::string &id, const Options &options ) {
}
}
} // end foreach target
} else {
// if we don't have debug turned on, then the max effective log level is INFO
if ( tempSyslogLevel > INFO ) tempSyslogLevel = INFO;
if ( tempFileLevel > INFO ) tempFileLevel = INFO;
if ( tempTermLevel > INFO ) tempTermLevel = INFO;
if ( tempDatabaseLevel > INFO ) tempDatabaseLevel = INFO;
if ( tempLevel > INFO ) tempLevel = INFO;
} // end if config.log_debug

View File

@ -279,12 +279,25 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in,
}
} // end if audio_in_stream
video_last_pts = 0;
video_last_dts = 0;
audio_last_pts = 0;
audio_last_dts = 0;
video_next_pts = 0;
video_next_dts = 0;
audio_next_pts = 0;
audio_next_dts = 0;
} // VideoStore::VideoStore
bool VideoStore::open() {
/* open the out file, if needed */
if (!(out_format->flags & AVFMT_NOFILE)) {
ret = avio_open2(&oc->pb, filename, AVIO_FLAG_WRITE, NULL, NULL);
if (ret < 0) {
Fatal("Could not open out file '%s': %s\n", filename,
Error("Could not open out file '%s': %s\n", filename,
av_make_error_string(ret).c_str());
return false;
}
}
@ -310,18 +323,11 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in,
if (ret < 0) {
Error("Error occurred when writing out file header to %s: %s\n",
filename, av_make_error_string(ret).c_str());
return false;
}
if (opts) av_dict_free(&opts);
video_last_pts = 0;
video_last_dts = 0;
audio_last_pts = 0;
audio_last_dts = 0;
video_next_pts = 0;
video_next_dts = 0;
audio_next_pts = 0;
audio_next_dts = 0;
} // VideoStore::VideoStore
return true;
}
VideoStore::~VideoStore() {
if (audio_out_codec) {

View File

@ -78,6 +78,7 @@ public:
AVStream *audio_in_stream,
int64_t nStartTime,
Monitor * p_monitor);
bool open();
~VideoStore();
int writeVideoFramePacket( AVPacket *pkt );

88
web/includes/Group.php Normal file
View File

@ -0,0 +1,88 @@
<?php
class Group {
public $defaults = array(
'Id' => null,
'Name' => '',
'MonitorIds' => '',
);
public function __construct( $IdOrRow=NULL ) {
$row = NULL;
if ( $IdOrRow ) {
if ( is_integer( $IdOrRow ) or is_numeric( $IdOrRow ) ) {
$row = dbFetchOne( 'SELECT * FROM Groups WHERE Id=?', NULL, array( $IdOrRow ) );
if ( ! $row ) {
Error('Unable to load Group record for Id=' . $IdOrRow );
}
} elseif ( is_array( $IdOrRow ) ) {
$row = $IdOrRow;
} else {
$backTrace = debug_backtrace();
$file = $backTrace[1]['file'];
$line = $backTrace[1]['line'];
Error("Unknown argument passed to Group Constructor from $file:$line)");
Error("Unknown argument passed to Group Constructor ($IdOrRow)");
return;
}
} # end if isset($IdOrRow)
if ( $row ) {
foreach ($row as $k => $v) {
$this->{$k} = $v;
}
}
} // end function __construct
public function __call( $fn, array $args ) {
if ( count( $args ) ) {
$this->{$fn} = $args[0];
}
if ( array_key_exists( $fn, $this ) ) {
return $this->{$fn};
} else if ( array_key_exists( $fn, $this->defaults ) ) {
$this->{$fn} = $this->defaults{$fn};
return $this->{$fn};
} else {
$backTrace = debug_backtrace();
$file = $backTrace[1]['file'];
$line = $backTrace[1]['line'];
Warning( "Unknown function call Group->$fn from $file:$line" );
}
}
public static function find_all() {
$filters = array();
$result = dbQuery( 'SELECT * FROM Groups ORDER BY Name');
$results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Group' );
foreach ( $results as $row => $obj ) {
$filters[] = $obj;
}
return $filters;
}
public function delete() {
dbQuery( 'DELETE FROM Groups WHERE Id = ?', array($this->{'Id'}) );
} # end function delete()
public function set( $data ) {
foreach ($data as $k => $v) {
if ( is_array( $v ) ) {
$this->{$k} = $v;
} else if ( is_string( $v ) ) {
$this->{$k} = trim( $v );
} else if ( is_integer( $v ) ) {
$this->{$k} = $v;
} else if ( is_bool( $v ) ) {
$this->{$k} = $v;
} else {
Error( "Unknown type $k => $v of var " . gettype( $v ) );
$this->{$k} = $v;
}
}
}
} # end class
?>

View File

@ -213,7 +213,7 @@ function getNavBarHTML() {
<?php if ( ZM_OPT_X10 && canView( 'Devices' ) ) { ?>
<li><a href="?view=devices">Devices</a></li>
<?php } ?>
<li><?php echo makePopupLink( '?view=groups', 'zmGroups', 'groups', sprintf( $CLANG['MonitorCount'], count($displayMonitors), zmVlang( $VLANG['Monitor'], count($displayMonitors) ) ).($group?' ('.$group['Name'].')':''), canView( 'Groups' ) ); ?></li>
<li><?php echo makePopupLink( '?view=groups', 'zmGroups', 'groups', 'Groups', canView( 'Groups' ) ); ?></li>
<li><a href="?view=filter">Filters</a></li>
<?php

View File

@ -156,7 +156,6 @@ function changeSize() {
src = src.replace(/height=[\.\d]+/i,'height='+height );
src = src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) ));
streamImg.src = src;
}
streamImg.style.width = width? width + "px" : null;
streamImg.style.height = height ? height + "px" : null;
@ -210,6 +209,11 @@ function changeScale() {
Cookie.write( 'zmMontageHeight', '', { duration: 10*365 } );
}
function changeGroup() {
var group_id = $('group').get('value');
Cookie.write( 'zmMontageGroup', group_id, { duration: 10*365 } );
window.location = window.location;
}
var monitors = new Array();
function initPage() {

View File

@ -24,10 +24,18 @@ if ( !canView( 'Stream' ) ) {
}
require_once( 'includes/Monitor.php' );
require_once( 'includes/Group.php' );
$groupSql = '';
$group_id = null;
if ( !empty($_REQUEST['group']) ) {
$row = dbFetchOne( 'SELECT * FROM Groups WHERE Id = ?', NULL, array($_REQUEST['group']) );
$group_id = $_REQUEST['group'];
} elseif ( isset( $_COOKIE['zmMontageGroup'] ) ) {
$group_id = $_COOKIE['zmMontageGroup'];
}
if ( $group_id ) {
$row = dbFetchOne( 'SELECT * FROM Groups WHERE Id = ?', NULL, array($group_id) );
$sql = "SELECT * FROM Monitors WHERE Function != 'None' AND find_in_set( Id, '".$row['MonitorIds']."' ) ORDER BY Sequence";
} else {
$sql = "SELECT * FROM Monitors WHERE Function != 'None' ORDER BY Sequence";
@ -140,6 +148,17 @@ if ( $showZones ) {
</div>
<h2><?php echo translate('Montage') ?></h2>
<div id="headerControl">
<span id="groupControl"><label><?php echo translate('Group') ?>:</label>
<?php
$groups = array(0=>'All');
foreach ( Group::find_all() as $Group ) {
$groups[$Group->Id()] = $Group->Name();
}
echo htmlSelect( 'group', $groups, $group_id, 'changeGroup(this);' );
?>
</span>
<span id="widthControl"><label><?php echo translate('Width') ?>:</label><?php echo htmlSelect( 'width', $widths, $options['width'], 'changeSize(this);' ); ?></span>
<span id="heightControl"><label><?php echo translate('Height') ?>:</label><?php echo htmlSelect( 'height', $heights, $options['height'], 'changeSize(this);' ); ?></span>
<span id="scaleControl"><label><?php echo translate('Scale') ?>:</label><?php echo htmlSelect( 'scale', $scales, $scale, 'changeScale(this);' ); ?></span>