Merge branch 'storageareas' of github.com:ConnorTechnology/ZoneMinder into storageareas
This commit is contained in:
commit
e47c8fad88
|
@ -173,7 +173,7 @@ sub Path {
|
||||||
$$event{Path} = join('/',
|
$$event{Path} = join('/',
|
||||||
$Storage->Path(),
|
$Storage->Path(),
|
||||||
$event->{MonitorId},
|
$event->{MonitorId},
|
||||||
strftime( '%y-%m-%d', localtime($event->Time())),
|
strftime( '%Y-%m-%d', localtime($event->Time())),
|
||||||
$event->{Id},
|
$event->{Id},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -102,7 +102,7 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
char id_file[PATH_MAX];
|
char id_file[PATH_MAX];
|
||||||
|
|
||||||
if ( storage->Scheme() == Storage::Schemes::DEEP ) {
|
if ( storage->Scheme() == Storage::DEEP ) {
|
||||||
char *path_ptr = path;
|
char *path_ptr = path;
|
||||||
path_ptr += snprintf( path_ptr, sizeof(path), "%s/%d", storage->Path(), monitor->Id() );
|
path_ptr += snprintf( path_ptr, sizeof(path), "%s/%d", storage->Path(), monitor->Id() );
|
||||||
|
|
||||||
|
@ -136,10 +136,10 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
|
||||||
snprintf( id_file, sizeof(id_file), "%s/.%d", date_path, id );
|
snprintf( id_file, sizeof(id_file), "%s/.%d", date_path, id );
|
||||||
if ( symlink( time_path, id_file ) < 0 )
|
if ( symlink( time_path, id_file ) < 0 )
|
||||||
Error( "Can't symlink %s -> %s: %s", id_file, path, strerror(errno));
|
Error( "Can't symlink %s -> %s: %s", id_file, path, strerror(errno));
|
||||||
} else if ( storage->Scheme() == Storage::Schemes::MEDIUM ) {
|
} else if ( storage->Scheme() == Storage::MEDIUM ) {
|
||||||
char *path_ptr = path;
|
char *path_ptr = path;
|
||||||
path_ptr += snprintf( path_ptr, sizeof(path), "%s/%d/%02d-%02d-%02d",
|
path_ptr += snprintf( path_ptr, sizeof(path), "%s/%d/%04d-%02d-%02d",
|
||||||
storage->Path(), monitor->Id(), stime->tm_year-100, stime->tm_mon+1, stime->tm_mday
|
storage->Path(), monitor->Id(), stime->tm_year+1900, stime->tm_mon+1, stime->tm_mday
|
||||||
);
|
);
|
||||||
if ( mkdir( path, 0755 ) ) {
|
if ( mkdir( path, 0755 ) ) {
|
||||||
// FIXME This should not be fatal. Should probably move to a different storage area.
|
// FIXME This should not be fatal. Should probably move to a different storage area.
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "zm_image.h"
|
#include "zm_image.h"
|
||||||
#include "zm_stream.h"
|
#include "zm_stream.h"
|
||||||
#include "zm_video.h"
|
#include "zm_video.h"
|
||||||
|
#include "zm_storage.h"
|
||||||
|
|
||||||
class Zone;
|
class Zone;
|
||||||
class Monitor;
|
class Monitor;
|
||||||
|
@ -93,6 +94,7 @@ class Event {
|
||||||
int last_db_frame;
|
int last_db_frame;
|
||||||
|
|
||||||
void createNotes( std::string ¬es );
|
void createNotes( std::string ¬es );
|
||||||
|
Storage::Schemes scheme;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static bool OpenFrameSocket( int );
|
static bool OpenFrameSocket( int );
|
||||||
|
|
|
@ -103,7 +103,7 @@ bool EventStream::loadInitialEventData( int init_event_id, unsigned int init_fra
|
||||||
bool EventStream::loadEventData( int event_id ) {
|
bool EventStream::loadEventData( int event_id ) {
|
||||||
static char sql[ZM_SQL_MED_BUFSIZ];
|
static char sql[ZM_SQL_MED_BUFSIZ];
|
||||||
|
|
||||||
snprintf( sql, sizeof(sql), "SELECT MonitorId, StorageId, Frames, unix_timestamp( StartTime ) AS StartTimestamp, (SELECT max(Delta)-min(Delta) FROM Frames WHERE EventId=Events.Id) AS Duration, DefaultVideo FROM Events WHERE Id = %d", event_id );
|
snprintf( sql, sizeof(sql), "SELECT MonitorId, StorageId, Frames, unix_timestamp( StartTime ) AS StartTimestamp, (SELECT max(Delta)-min(Delta) FROM Frames WHERE EventId=Events.Id) AS Duration, DefaultVideo, Scheme FROM Events WHERE Id = %d", event_id );
|
||||||
|
|
||||||
if ( mysql_query( &dbconn, sql ) ) {
|
if ( mysql_query( &dbconn, sql ) ) {
|
||||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||||
|
@ -136,19 +136,36 @@ bool EventStream::loadEventData( int event_id ) {
|
||||||
event_data->frame_count = dbrow[2] == NULL ? 0 : atoi(dbrow[2]);
|
event_data->frame_count = dbrow[2] == NULL ? 0 : atoi(dbrow[2]);
|
||||||
event_data->start_time = atoi(dbrow[3]);
|
event_data->start_time = atoi(dbrow[3]);
|
||||||
event_data->duration = atof(dbrow[4]);
|
event_data->duration = atof(dbrow[4]);
|
||||||
strncpy( event_data->video_file, dbrow[5], sizeof( event_data->video_file )-1 );
|
strncpy( event_data->video_file, dbrow[5], sizeof(event_data->video_file)-1 );
|
||||||
|
std::string scheme_str = std::string(dbrow[6]);
|
||||||
|
if ( scheme_str == "Deep" ) {
|
||||||
|
event_data->scheme = Storage::DEEP;
|
||||||
|
} else if ( scheme_str == "Medium" ) {
|
||||||
|
event_data->scheme = Storage::MEDIUM;
|
||||||
|
} else {
|
||||||
|
event_data->scheme = Storage::SHALLOW;
|
||||||
|
}
|
||||||
mysql_free_result( result );
|
mysql_free_result( result );
|
||||||
|
|
||||||
Storage * storage = new Storage( event_data->storage_id );
|
Storage * storage = new Storage( event_data->storage_id );
|
||||||
const char *storage_path = storage->Path();
|
const char *storage_path = storage->Path();
|
||||||
|
|
||||||
if ( config.use_deep_storage ) {
|
if ( event_data->scheme == Storage::DEEP ) {
|
||||||
struct tm *event_time = localtime( &event_data->start_time );
|
struct tm *event_time = localtime( &event_data->start_time );
|
||||||
|
|
||||||
if ( storage_path[0] == '/' )
|
if ( storage_path[0] == '/' )
|
||||||
snprintf( event_data->path, sizeof(event_data->path), "%s/%ld/%02d/%02d/%02d/%02d/%02d/%02d", storage_path, event_data->monitor_id, event_time->tm_year-100, event_time->tm_mon+1, event_time->tm_mday, event_time->tm_hour, event_time->tm_min, event_time->tm_sec );
|
snprintf( event_data->path, sizeof(event_data->path), "%s/%ld/%02d/%02d/%02d/%02d/%02d/%02d", storage_path, event_data->monitor_id, event_time->tm_year-100, event_time->tm_mon+1, event_time->tm_mday, event_time->tm_hour, event_time->tm_min, event_time->tm_sec );
|
||||||
else
|
else
|
||||||
snprintf( event_data->path, sizeof(event_data->path), "%s/%s/%ld/%02d/%02d/%02d/%02d/%02d/%02d", staticConfig.PATH_WEB.c_str(), storage_path, event_data->monitor_id, event_time->tm_year-100, event_time->tm_mon+1, event_time->tm_mday, event_time->tm_hour, event_time->tm_min, event_time->tm_sec );
|
snprintf( event_data->path, sizeof(event_data->path), "%s/%s/%ld/%02d/%02d/%02d/%02d/%02d/%02d", staticConfig.PATH_WEB.c_str(), storage_path, event_data->monitor_id, event_time->tm_year-100, event_time->tm_mon+1, event_time->tm_mday, event_time->tm_hour, event_time->tm_min, event_time->tm_sec );
|
||||||
|
} else if ( event_data->scheme == Storage::MEDIUM ) {
|
||||||
|
struct tm *event_time = localtime( &event_data->start_time );
|
||||||
|
if ( storage_path[0] == '/' )
|
||||||
|
snprintf( event_data->path, sizeof(event_data->path), "%s/%ld/%04d-%02d-%02d/%ld",
|
||||||
|
storage_path, event_data->monitor_id, event_time->tm_year+1900, event_time->tm_mon+1, event_time->tm_mday, event_data->event_id );
|
||||||
|
else
|
||||||
|
snprintf( event_data->path, sizeof(event_data->path), "%s/%s/%ld/%04d-%02d-%02d/%ld",
|
||||||
|
staticConfig.PATH_WEB.c_str(), storage_path, event_data->monitor_id, event_time->tm_year+1900, event_time->tm_mon+1, event_time->tm_mday,
|
||||||
|
event_data->event_id );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if ( storage_path[0] == '/' )
|
if ( storage_path[0] == '/' )
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "zm_video.h"
|
#include "zm_video.h"
|
||||||
#include "zm_ffmpeg_input.h"
|
#include "zm_ffmpeg_input.h"
|
||||||
#include "zm_monitor.h"
|
#include "zm_monitor.h"
|
||||||
|
#include "zm_storage.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -63,6 +64,7 @@ class EventStream : public StreamBase {
|
||||||
int n_frames;
|
int n_frames;
|
||||||
FrameData *frames;
|
FrameData *frames;
|
||||||
char video_file[PATH_MAX];
|
char video_file[PATH_MAX];
|
||||||
|
Storage::Schemes scheme;
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -36,8 +36,8 @@ Storage::Storage() {
|
||||||
} else {
|
} else {
|
||||||
strncpy(path, staticConfig.DIR_EVENTS.c_str(), sizeof(path)-1 );
|
strncpy(path, staticConfig.DIR_EVENTS.c_str(), sizeof(path)-1 );
|
||||||
}
|
}
|
||||||
scheme = Schemes::SHALLOW;
|
scheme = DEEP;
|
||||||
scheme_str = "Shallow";
|
scheme_str = "Deep";
|
||||||
}
|
}
|
||||||
|
|
||||||
Storage::Storage( MYSQL_ROW &dbrow ) {
|
Storage::Storage( MYSQL_ROW &dbrow ) {
|
||||||
|
@ -48,11 +48,11 @@ Storage::Storage( MYSQL_ROW &dbrow ) {
|
||||||
type_str = std::string(dbrow[index++]);
|
type_str = std::string(dbrow[index++]);
|
||||||
scheme_str = std::string(dbrow[index++]);
|
scheme_str = std::string(dbrow[index++]);
|
||||||
if ( scheme_str == "Deep" ) {
|
if ( scheme_str == "Deep" ) {
|
||||||
scheme = Schemes::DEEP;
|
scheme = DEEP;
|
||||||
} else if ( scheme_str == "Medium" ) {
|
} else if ( scheme_str == "Medium" ) {
|
||||||
scheme = Schemes::MEDIUM;
|
scheme = MEDIUM;
|
||||||
} else {
|
} else {
|
||||||
scheme = Schemes::SHALLOW;
|
scheme = SHALLOW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,11 +75,11 @@ Storage::Storage( unsigned int p_id ) {
|
||||||
type_str = std::string(dbrow[index++]);
|
type_str = std::string(dbrow[index++]);
|
||||||
scheme_str = std::string(dbrow[index++]);
|
scheme_str = std::string(dbrow[index++]);
|
||||||
if ( scheme_str == "Deep" ) {
|
if ( scheme_str == "Deep" ) {
|
||||||
scheme = Schemes::DEEP;
|
scheme = DEEP;
|
||||||
} else if ( scheme_str == "Medium" ) {
|
} else if ( scheme_str == "Medium" ) {
|
||||||
scheme = Schemes::MEDIUM;
|
scheme = MEDIUM;
|
||||||
} else {
|
} else {
|
||||||
scheme = Schemes::SHALLOW;
|
scheme = SHALLOW;
|
||||||
}
|
}
|
||||||
Debug( 1, "Loaded Storage area %d '%s'", id, this->Name() );
|
Debug( 1, "Loaded Storage area %d '%s'", id, this->Name() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ class Event {
|
||||||
if ( $this->{'Scheme'} == 'Deep' ) {
|
if ( $this->{'Scheme'} == 'Deep' ) {
|
||||||
$event_path = $this->{'MonitorId'} .'/'.strftime( '%y/%m/%d/%H/%M/%S', $this->Time()) ;
|
$event_path = $this->{'MonitorId'} .'/'.strftime( '%y/%m/%d/%H/%M/%S', $this->Time()) ;
|
||||||
} else if ( $this->{'Scheme'} == 'Medium' ) {
|
} else if ( $this->{'Scheme'} == 'Medium' ) {
|
||||||
$event_path = $this->{'MonitorId'} .'/'.strftime( '%y-%m-%d', $this->Time() ) . '/'.$this->{'Id'};
|
$event_path = $this->{'MonitorId'} .'/'.strftime( '%Y-%m-%d', $this->Time() ) . '/'.$this->{'Id'};
|
||||||
} else {
|
} else {
|
||||||
$event_path = $this->{'MonitorId'} .'/'.$this->{'Id'};
|
$event_path = $this->{'MonitorId'} .'/'.$this->{'Id'};
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,8 +122,8 @@ function parseRows (rows) {
|
||||||
obrSelect.append('<option value="' + i + '">' + '('.repeat(i) + '</option>');
|
obrSelect.append('<option value="' + i + '">' + '('.repeat(i) + '</option>');
|
||||||
cbrSelect.append('<option value="' + i + '">' + ')'.repeat(i) + '</option>');
|
cbrSelect.append('<option value="' + i + '">' + ')'.repeat(i) + '</option>');
|
||||||
}
|
}
|
||||||
let obrVal = inputTds.eq(1).children().val(); //Save currently selected bracket option
|
let obrVal = inputTds.eq(1).children().val() != undefined ? inputTds.eq(1).children().val() : 0; //Save currently selected bracket option
|
||||||
let cbrVal = inputTds.eq(5).children().val();
|
let cbrVal = inputTds.eq(5).children().val() != undefined ? inputTds.eq(5).children().val() : 0;
|
||||||
inputTds.eq(1).html(obrSelect).children().val(obrVal); //Set bracket contents and assign saved value
|
inputTds.eq(1).html(obrSelect).children().val(obrVal); //Set bracket contents and assign saved value
|
||||||
inputTds.eq(5).html(cbrSelect).children().val(cbrVal);
|
inputTds.eq(5).html(cbrSelect).children().val(cbrVal);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -765,6 +765,27 @@ function initPage() {
|
||||||
//setFit(fitMode); // will redraw
|
//setFit(fitMode); // will redraw
|
||||||
//setLive(liveMode); // will redraw
|
//setLive(liveMode); // will redraw
|
||||||
redrawScreen();
|
redrawScreen();
|
||||||
|
$j('#minTime').datetimepicker({
|
||||||
|
timeFormat: "HH:mm:ss",
|
||||||
|
dateFormat: "yy-mm-dd",
|
||||||
|
maxDate: +0,
|
||||||
|
onClose: function (newDate, oldData) {
|
||||||
|
if (newDate !== oldData.lastVal) {
|
||||||
|
changeDateTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$j('#maxTime').datetimepicker({
|
||||||
|
timeFormat: "HH:mm:ss",
|
||||||
|
dateFormat: "yy-mm-dd",
|
||||||
|
minDate: $j('#minTime').val(),
|
||||||
|
maxDate: +0,
|
||||||
|
onClose: function (newDate, oldData) {
|
||||||
|
if (newDate !== oldData.lastVal) {
|
||||||
|
changeDateTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
window.addEventListener("resize",redrawScreen);
|
window.addEventListener("resize",redrawScreen);
|
||||||
// Kick everything off
|
// Kick everything off
|
||||||
|
|
|
@ -219,8 +219,8 @@ xhtmlHeaders(__FILE__, translate('MontageReview') );
|
||||||
<div id="header">
|
<div id="header">
|
||||||
<?php echo $filter_bar ?>
|
<?php echo $filter_bar ?>
|
||||||
<div id="DateTimeDiv">
|
<div id="DateTimeDiv">
|
||||||
<input type="datetime-local" name="minTime" id="minTime" value="<?php echo preg_replace('/ /', 'T', $minTime ) ?>" onchange="changeDateTime(this);"> to
|
<input type="text" name="minTime" id="minTime" value="<?php echo preg_replace('/T/', ' ', $minTime ) ?>"> to
|
||||||
<input type="datetime-local" name="maxTime" id="maxTime" value="<?php echo preg_replace('/ /', 'T', $maxTime ) ?>" onchange="changeDateTime(this);">
|
<input type="text" name="maxTime" id="maxTime" value="<?php echo preg_replace('/T/', ' ', $maxTime ) ?>">
|
||||||
</div>
|
</div>
|
||||||
<div id="ScaleDiv">
|
<div id="ScaleDiv">
|
||||||
<label for="scaleslider"><?php echo translate('Scale')?></label>
|
<label for="scaleslider"><?php echo translate('Scale')?></label>
|
||||||
|
|
Loading…
Reference in New Issue