get rid of the snapshot setting. If we aren't storing all frames, then we should always store the snapshot.

This commit is contained in:
Isaac Connor
2018-01-13 15:15:14 -05:00
parent 1d6c9d6edd
commit 9284e26512
5 changed files with 56 additions and 36 deletions

View File

@@ -442,7 +442,10 @@ void Event::AddFramesInternal( int n_frames, int start_frame, Image **images, st
static char event_file[PATH_MAX];
snprintf( event_file, sizeof(event_file), staticConfig.capture_file_format, path, frames );
if ( monitor->GetOptSaveJPEGs() & 4 ) {
if ( monitor->GetOptSaveJPEGs() & 1 ) {
Debug( 1, "Writing pre-capture frame %d", frames );
WriteFrameImage( images[i], *(timestamps[i]), event_file );
} else {
//If this is the first frame, we should add a thumbnail to the event directory
// ICON: We are working through the pre-event frames so this snapshot won't
// neccessarily be of the motion. But some events are less than 10 frames,
@@ -453,10 +456,6 @@ void Event::AddFramesInternal( int n_frames, int start_frame, Image **images, st
WriteFrameImage( images[i], *(timestamps[i]), snapshot_file );
}
}
if ( monitor->GetOptSaveJPEGs() & 1 ) {
Debug( 1, "Writing pre-capture frame %d", frames );
WriteFrameImage( images[i], *(timestamps[i]), event_file );
}
if ( videowriter != NULL ) {
WriteFrameVideo( images[i], *(timestamps[i]), videowriter );
}
@@ -494,20 +493,18 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image *
static char event_file[PATH_MAX];
snprintf( event_file, sizeof(event_file), staticConfig.capture_file_format, path, frames );
if ( monitor->GetOptSaveJPEGs() & 4 ) {
// Only snapshots
//If this is the first frame, we should add a thumbnail to the event directory
if ( frames == 10 ) {
char snapshot_file[PATH_MAX];
snprintf( snapshot_file, sizeof(snapshot_file), "%s/snapshot.jpg", path );
WriteFrameImage( image, timestamp, snapshot_file );
}
}
if ( monitor->GetOptSaveJPEGs() & 1 ) {
Debug( 1, "Writing capture frame %d to %s", frames, event_file );
if ( ! WriteFrameImage( image, timestamp, event_file ) ) {
Error("Failed to write frame image");
}
} else {
//If this is the first frame, we should add a thumbnail to the event directory
if ( frames == 1 ) {
char snapshot_file[PATH_MAX];
snprintf( snapshot_file, sizeof(snapshot_file), "%s/snapshot.jpg", path );
WriteFrameImage( image, timestamp, snapshot_file );
}
}
if ( videowriter != NULL ) {
Debug(3, "Writing video");

View File

@@ -23,15 +23,39 @@ class Server {
$this->{'Hostname'} = '';
}
}
public static function find_all() {
$servers = array();
$result = dbQuery( 'SELECT * FROM Servers ORDER BY Name');
$results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Server' );
foreach ( $results as $row => $server_obj ) {
$servers[] = $server_obj;
}
return $servers;
}
public static function find_all( $parameters = null, $options = null ) {
$filters = array();
$sql = 'SELECT * FROM Servers ';
$values = array();
if ( $parameters ) {
$fields = array();
$sql .= 'WHERE ';
foreach ( $parameters as $field => $value ) {
if ( $value == null ) {
$fields[] = $field.' IS NULL';
} else if ( is_array( $value ) ) {
$func = function(){return '?';};
$fields[] = $field.' IN ('.implode(',', array_map( $func, $value ) ). ')';
$values += $value;
} else {
$fields[] = $field.'=?';
$values[] = $value;
}
}
$sql .= implode(' AND ', $fields );
}
if ( $options and isset($options['order']) ) {
$sql .= ' ORDER BY ' . $options['order'];
}
$result = dbQuery($sql, $values);
$results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Server');
foreach ( $results as $row => $obj ) {
$filters[] = $obj;
}
return $filters;
}
public function Url() {
if ( $this->Id() ) {

View File

@@ -18,7 +18,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
$servers = Server::find_all();
$servers = Server::find_all( null, array('order'=>'lower(Name)'));
$ServersById = array();
foreach ( $servers as $S ) {
$ServersById[$S->Id()] = $S;

View File

@@ -463,7 +463,6 @@ $savejpegopts = array(
'Frames only' => 1,
'Analysis images only (if available)' => 2,
'Frames + Analysis images (if available)' => 3,
'Snapshot Only' => 4
);
$videowriteropts = array(

View File

@@ -19,20 +19,20 @@
//
if ( !canEdit( 'System' ) ) {
$view = 'error';
return;
$view = 'error';
return;
}
if ( $_REQUEST['id'] ) {
if ( !($newStorage = dbFetchOne('SELECT * FROM Storage WHERE Id=?', NULL, ARRAY($_REQUEST['id'])) ) ) {
$view = 'error';
return;
if ( !($newStorage = dbFetchOne('SELECT * FROM Storage WHERE Id=?', NULL, ARRAY($_REQUEST['id'])) ) ) {
$view = 'error';
return;
$newStorage['ServerId'] = '';
}
}
} else {
$newStorage = array();
$newStorage['Name'] = translate('NewStorage');
$newStorage['Path'] = '';
$newStorage = array();
$newStorage['Name'] = translate('NewStorage');
$newStorage['Path'] = '';
$newStorage['Type'] = 'local';
$newStorage['Scheme'] = 'Medium';
}
@@ -44,7 +44,7 @@ $scheme_options = array(
'Shallow' => translate('Shallow'),
);
$servers = Server::find_all();
$servers = Server::find_all( null, array('order'=>'lower(Name)') );
$ServersById = array();
foreach ( $servers as $S ) {
$ServersById[$S->Id()] = $S;
@@ -75,7 +75,7 @@ xhtmlHeaders(__FILE__, translate('Storage')." - ".$newStorage['Name'] );
</tr>
<tr>
<th scope="row"><?php echo translate('Server') ?></th>
<td><?php echo htmlSelect( 'newStorage[ServerId]', array('','Remote') + $ServersById, $newStorage['ServerId'] ); ?></td>
<td><?php echo htmlSelect( 'newStorage[ServerId]', array(''=>'Remote / No Specific Server') + $ServersById, $newStorage['ServerId'] ); ?></td>
</tr>
<tr>
<th scope="row"><?php echo translate('Type') ?></th>