Convert event_id to a 64bit unsigned int
This commit is contained in:
parent
b974b4dcd1
commit
f9f78e9aa3
|
@ -23,35 +23,3 @@ SET @s = (SELECT IF(
|
|||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
|
||||
ALTER TABLE `Frames` MODIFY `Id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT;
|
||||
ALTER TABLE `Events` MODIFY `Id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT;
|
||||
ALTER TABLE `Frames` MODIFY `EventId` BIGINT UNSIGNED NOT NULL;
|
||||
ALTER TABLE `Stats` MODIFY `EventId` BIGINT UNSIGNED NOT NULL;
|
||||
|
||||
ALTER TABLE `Events_Hour` MODIFY `EventId` BIGINT UNSIGNED NOT NULL;
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_TYPE='FOREIGN KEY'
|
||||
AND table_name = 'Events'
|
||||
AND column_name = 'Locked'
|
||||
) > 0,
|
||||
"SELECT 'Column Locked already exists in Events'",
|
||||
"ALTER TABLE `Events` ADD `Locked` BOOLEAN NOT NULL default false AFTER `Scheme`"
|
||||
));
|
||||
ALTER TABLE `Events_Hour` ADD CONSTRAINT Events_Hour_EventId_fk FOREIGN KEY (`EventId`) REFERENCES `Events`(`Id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `Events_Day` MODIFY `EventId` BIGINT UNSIGNED NOT NULL;
|
||||
ALTER TABLE `Events_Day` ADD CONSTRAINT Events_Day_EventId_fk FOREIGN KEY (`EventId`) REFERENCES `Events`(`Id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `Events_Week` MODIFY `EventId` BIGINT UNSIGNED NOT NULL;
|
||||
ALTER TABLE `Events_Week` ADD CONSTRAINT Events_Week_EventId_fk FOREIGN KEY (`EventId`) REFERENCES `Events`(`Id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `Events_Month` MODIFY `EventId` BIGINT UNSIGNED NOT NULL;
|
||||
ALTER TABLE `Events_Month` ADD CONSTRAINT Events_Month_EventId_fk FOREIGN KEY (`EventId`) REFERENCES `Events`(`Id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `Events_Archived` MODIFY `EventId` BIGINT UNSIGNED NOT NULL;
|
||||
ALTER TABLE `Events_Archived` ADD CONSTRAINT Events_Archived_EventId_fk FOREIGN KEY (`EventId`) REFERENCES `Events`(`Id`) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE `Stats` ADD CONSTRAINT Stats_MonitorId_fk FOREIGN KEY (`MonitorId`) REFERENCES `Monitors`(`Id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `Stats` ADD CONSTRAINT Stats_EventId_fk FOREIGN KEY (`EventId`) REFERENCES `Events`(`Id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `Stats` ADD CONSTRAINT Stats_ZoneId_fk FOREIGN KEY (`ZoneId`) REFERENCES `Zones`(`Id`) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE `Frames` ADD CONSTRAINT Frames_EventId_fk FOREIGN KEY (`EventId`) REFERENCES `Events`(`Id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `Frames` DROP INDEX `Type`;
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
ALTER TABLE `Frames` MODIFY `Id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT;
|
||||
ALTER TABLE `Events` MODIFY `Id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT;
|
||||
ALTER TABLE `Frames` MODIFY `EventId` BIGINT UNSIGNED NOT NULL;
|
||||
ALTER TABLE `Stats` MODIFY `EventId` BIGINT UNSIGNED NOT NULL;
|
||||
|
||||
ALTER TABLE `Events_Hour` MODIFY `EventId` BIGINT UNSIGNED NOT NULL;
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_TYPE='FOREIGN KEY'
|
||||
AND table_name = 'Events'
|
||||
AND column_name = 'Locked'
|
||||
) > 0,
|
||||
"SELECT 'Column Locked already exists in Events'",
|
||||
"ALTER TABLE `Events` ADD `Locked` BOOLEAN NOT NULL default false AFTER `Scheme`"
|
||||
));
|
||||
ALTER TABLE `Events_Hour` ADD CONSTRAINT Events_Hour_EventId_fk FOREIGN KEY (`EventId`) REFERENCES `Events`(`Id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `Events_Day` MODIFY `EventId` BIGINT UNSIGNED NOT NULL;
|
||||
ALTER TABLE `Events_Day` ADD CONSTRAINT Events_Day_EventId_fk FOREIGN KEY (`EventId`) REFERENCES `Events`(`Id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `Events_Week` MODIFY `EventId` BIGINT UNSIGNED NOT NULL;
|
||||
ALTER TABLE `Events_Week` ADD CONSTRAINT Events_Week_EventId_fk FOREIGN KEY (`EventId`) REFERENCES `Events`(`Id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `Events_Month` MODIFY `EventId` BIGINT UNSIGNED NOT NULL;
|
||||
ALTER TABLE `Events_Month` ADD CONSTRAINT Events_Month_EventId_fk FOREIGN KEY (`EventId`) REFERENCES `Events`(`Id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `Events_Archived` MODIFY `EventId` BIGINT UNSIGNED NOT NULL;
|
||||
ALTER TABLE `Events_Archived` ADD CONSTRAINT Events_Archived_EventId_fk FOREIGN KEY (`EventId`) REFERENCES `Events`(`Id`) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE `Stats` ADD CONSTRAINT Stats_MonitorId_fk FOREIGN KEY (`MonitorId`) REFERENCES `Monitors`(`Id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `Stats` ADD CONSTRAINT Stats_EventId_fk FOREIGN KEY (`EventId`) REFERENCES `Events`(`Id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `Stats` ADD CONSTRAINT Stats_ZoneId_fk FOREIGN KEY (`ZoneId`) REFERENCES `Zones`(`Id`) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE `Frames` ADD CONSTRAINT Frames_EventId_fk FOREIGN KEY (`EventId`) REFERENCES `Events`(`Id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `Frames` DROP INDEX `Type`;
|
||||
|
|
@ -350,6 +350,10 @@ sub delete {
|
|||
Warning( "Can't Delete event $event->{Id} from Monitor $event->{MonitorId} StartTime:$event->{StartTime} from $caller:$line\n" );
|
||||
return;
|
||||
}
|
||||
if ( ! -e $event->Storage()->Path() ) {
|
||||
Warning("Not deleting event because storage path doesn't exist");
|
||||
return;
|
||||
}
|
||||
Info( "Deleting event $event->{Id} from Monitor $event->{MonitorId} StartTime:$event->{StartTime}\n" );
|
||||
$ZoneMinder::Database::dbh->ping();
|
||||
|
||||
|
|
|
@ -327,6 +327,7 @@ sub checkFilter {
|
|||
Error( "Unable toto delete event $event->{Id} as previous operations failed\n" );
|
||||
}
|
||||
} # end if AutoDelete
|
||||
|
||||
if ( $filter->{AutoMove} ) {
|
||||
my $Event = new ZoneMinder::Event( $$event{Id}, $event );
|
||||
my $NewStorage = new ZoneMinder::Storage( $filter->{AutoMoveTo} );
|
||||
|
|
|
@ -147,7 +147,7 @@ Event::Event(
|
|||
time_path_ptr += snprintf( time_path_ptr, sizeof(time_path)-(time_path_ptr-time_path), "%s%02d", i>3?"/":"", dt_parts[i] );
|
||||
}
|
||||
// Create event id symlink
|
||||
snprintf( id_file, sizeof(id_file), "%s/.%d", date_path, id );
|
||||
snprintf( id_file, sizeof(id_file), "%s/.%llu", date_path, id );
|
||||
if ( symlink( time_path, id_file ) < 0 )
|
||||
Error( "Can't symlink %s -> %s: %s", id_file, path, strerror(errno));
|
||||
} else if ( storage->Scheme() == Storage::MEDIUM ) {
|
||||
|
@ -160,14 +160,14 @@ Event::Event(
|
|||
if ( errno != EEXIST )
|
||||
Error( "Can't mkdir %s: %s", path, strerror(errno));
|
||||
}
|
||||
path_ptr += snprintf( path_ptr, sizeof(path), "/%d", id );
|
||||
path_ptr += snprintf( path_ptr, sizeof(path), "/%llu", id );
|
||||
if ( mkdir( path, 0755 ) ) {
|
||||
// FIXME This should not be fatal. Should probably move to a different storage area.
|
||||
if ( errno != EEXIST )
|
||||
Error( "Can't mkdir %s: %s", path, strerror(errno));
|
||||
}
|
||||
} else {
|
||||
snprintf( path, sizeof(path), "%s/%d/%d", storage->Path(), monitor->Id(), id );
|
||||
snprintf( path, sizeof(path), "%s/%d/%llu", storage->Path(), monitor->Id(), id );
|
||||
if ( mkdir( path, 0755 ) ) {
|
||||
if ( errno != EEXIST ) {
|
||||
Error( "Can't mkdir %s: %s", path, strerror(errno));
|
||||
|
@ -175,7 +175,7 @@ Event::Event(
|
|||
}
|
||||
|
||||
// Create empty id tag file
|
||||
snprintf( id_file, sizeof(id_file), "%s/.%d", path, id );
|
||||
snprintf( id_file, sizeof(id_file), "%s/.%llu", path, id );
|
||||
if ( FILE *id_fp = fopen( id_file, "w" ) )
|
||||
fclose( id_fp );
|
||||
else
|
||||
|
@ -189,7 +189,7 @@ Event::Event(
|
|||
/* Save as video */
|
||||
|
||||
if ( monitor->GetOptVideoWriter() != 0 ) {
|
||||
snprintf( video_name, sizeof(video_name), "%d-%s", id, "video.mp4" );
|
||||
snprintf( video_name, sizeof(video_name), "%llu-%s", id, "video.mp4" );
|
||||
snprintf( video_file, sizeof(video_file), staticConfig.video_file_format, path, video_name );
|
||||
Debug(1,"Writing video file to %s", video_file );
|
||||
|
||||
|
@ -241,7 +241,7 @@ Event::~Event() {
|
|||
if ( frames > last_db_frame ) {
|
||||
Debug(1, "Adding closing frame %d to DB", frames);
|
||||
snprintf(sql, sizeof(sql),
|
||||
"INSERT INTO Frames ( EventId, FrameId, TimeStamp, Delta ) VALUES ( %d, %d, from_unixtime( %ld ), %s%ld.%02ld )",
|
||||
"INSERT INTO Frames ( EventId, FrameId, TimeStamp, Delta ) VALUES ( %llu, %d, from_unixtime( %ld ), %s%ld.%02ld )",
|
||||
id, frames, end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec);
|
||||
db_mutex.lock();
|
||||
if ( mysql_query(&dbconn, sql) ) {
|
||||
|
@ -252,7 +252,9 @@ Event::~Event() {
|
|||
db_mutex.unlock();
|
||||
}
|
||||
|
||||
snprintf(sql, sizeof(sql), "UPDATE Events SET Name='%s%d', EndTime = from_unixtime( %ld ), Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d, DefaultVideo = '%s' where Id = %d", monitor->EventPrefix(), id, end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(alarm_frames?(tot_score/alarm_frames):0), max_score, video_name, id );
|
||||
snprintf(sql, sizeof(sql),
|
||||
"UPDATE Events SET Name='%s %llu', EndTime = from_unixtime( %ld ), Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d, DefaultVideo = '%s' where Id = %llu",
|
||||
monitor->EventPrefix(), id, end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, frames, alarm_frames, tot_score, (int)(alarm_frames?(tot_score/alarm_frames):0), max_score, video_name, id );
|
||||
db_mutex.lock();
|
||||
while ( mysql_query(&dbconn, sql) ) {
|
||||
Error("Can't update event: %s reason: %s", sql, mysql_error(&dbconn));
|
||||
|
@ -421,7 +423,7 @@ void Event::updateNotes( const StringSetMap &newNoteSetMap ) {
|
|||
|
||||
mysql_real_escape_string( &dbconn, escapedNotes, notes.c_str(), notes.length() );
|
||||
|
||||
snprintf( sql, sizeof(sql), "update Events set Notes = '%s' where Id = %d", escapedNotes, id );
|
||||
snprintf( sql, sizeof(sql), "UPDATE Events SET Notes = '%s' WHERE Id = %llu", escapedNotes, id );
|
||||
db_mutex.lock();
|
||||
if ( mysql_query( &dbconn, sql ) ) {
|
||||
Error( "Can't insert event: %s", mysql_error( &dbconn ) );
|
||||
|
@ -479,7 +481,7 @@ void Event::AddFramesInternal( int n_frames, int start_frame, Image **images, st
|
|||
}
|
||||
|
||||
int sql_len = strlen(sql);
|
||||
snprintf( sql+sql_len, sizeof(sql)-sql_len, "( %d, %d, from_unixtime(%ld), %s%ld.%02ld ), ", id, frames, timestamps[i]->tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec );
|
||||
snprintf( sql+sql_len, sizeof(sql)-sql_len, "( %llu, %d, from_unixtime(%ld), %s%ld.%02ld ), ", id, frames, timestamps[i]->tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec );
|
||||
|
||||
frameCount++;
|
||||
}
|
||||
|
@ -540,7 +542,7 @@ Debug(3, "Writing video");
|
|||
|
||||
Debug( 1, "Adding frame %d of type \"%s\" to DB", frames, Event::frame_type_names[frame_type] );
|
||||
static char sql[ZM_SQL_MED_BUFSIZ];
|
||||
snprintf(sql, sizeof(sql), "insert into Frames ( EventId, FrameId, Type, TimeStamp, Delta, Score ) values ( %d, %d, '%s', from_unixtime( %ld ), %s%ld.%02ld, %d )", id, frames, frame_type_names[frame_type], timestamp.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, score);
|
||||
snprintf(sql, sizeof(sql), "INSERT INTO Frames ( EventId, FrameId, Type, TimeStamp, Delta, Score ) values ( %llu, %d, '%s', from_unixtime( %ld ), %s%ld.%02ld, %d )", id, frames, frame_type_names[frame_type], timestamp.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, score);
|
||||
db_mutex.lock();
|
||||
if ( mysql_query(&dbconn, sql) ) {
|
||||
Error("Can't insert frame: %s", mysql_error(&dbconn));
|
||||
|
@ -553,7 +555,8 @@ Debug(3, "Writing video");
|
|||
|
||||
// We are writing a Bulk frame
|
||||
if ( frame_type == BULK ) {
|
||||
snprintf( sql, sizeof(sql), "update Events set Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %d",
|
||||
snprintf( sql, sizeof(sql),
|
||||
"UPDATE Events SET Length = %s%ld.%02ld, Frames = %d, AlarmFrames = %d, TotScore = %d, AvgScore = %d, MaxScore = %d where Id = %llu",
|
||||
( delta_time.positive?"":"-" ),
|
||||
delta_time.sec, delta_time.fsec,
|
||||
frames,
|
||||
|
@ -564,9 +567,11 @@ Debug(3, "Writing video");
|
|||
id
|
||||
);
|
||||
db_mutex.lock();
|
||||
while ( mysql_query( &dbconn, sql ) ) {
|
||||
Error( "Can't update event: %s", mysql_error( &dbconn ) );
|
||||
while ( mysql_query(&dbconn, sql) ) {
|
||||
Error("Can't update event: %s", mysql_error(&dbconn));
|
||||
db_mutex.unlock();
|
||||
sleep(1);
|
||||
db_mutex.lock();
|
||||
}
|
||||
db_mutex.unlock();
|
||||
}
|
||||
|
@ -583,9 +588,9 @@ Debug(3, "Writing video");
|
|||
max_score = score;
|
||||
|
||||
if ( alarm_image ) {
|
||||
snprintf( event_file, sizeof(event_file), staticConfig.analyse_file_format, path, frames );
|
||||
snprintf(event_file, sizeof(event_file), staticConfig.analyse_file_format, path, frames);
|
||||
|
||||
Debug( 1, "Writing analysis frame %d", frames );
|
||||
Debug(1, "Writing analysis frame %d", frames);
|
||||
if ( monitor->GetOptSaveJPEGs() & 2 ) {
|
||||
WriteFrameImage(alarm_image, timestamp, event_file, true);
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ class Event {
|
|||
static int pre_alarm_count;
|
||||
static PreAlarmData pre_alarm_data[MAX_PRE_ALARM_FRAMES];
|
||||
|
||||
unsigned int id;
|
||||
unsigned long long int id;
|
||||
Monitor *monitor;
|
||||
struct timeval start_time;
|
||||
struct timeval end_time;
|
||||
|
@ -103,15 +103,15 @@ class Event {
|
|||
Event( Monitor *p_monitor, struct timeval p_start_time, const std::string &p_cause, const StringSetMap &p_noteSetMap, bool p_videoEvent=false );
|
||||
~Event();
|
||||
|
||||
int Id() const { return( id ); }
|
||||
const std::string &Cause() { return( cause ); }
|
||||
int Frames() const { return( frames ); }
|
||||
int AlarmFrames() const { return( alarm_frames ); }
|
||||
unsigned long long int Id() const { return id; }
|
||||
const std::string &Cause() { return cause; }
|
||||
int Frames() const { return frames; }
|
||||
int AlarmFrames() const { return alarm_frames; }
|
||||
|
||||
const struct timeval &StartTime() const { return( start_time ); }
|
||||
const struct timeval &EndTime() const { return( end_time ); }
|
||||
struct timeval &StartTime() { return( start_time ); }
|
||||
struct timeval &EndTime() { return( end_time ); }
|
||||
const struct timeval &StartTime() const { return start_time; }
|
||||
const struct timeval &EndTime() const { return end_time; }
|
||||
struct timeval &StartTime() { return start_time; }
|
||||
struct timeval &EndTime() { return end_time; }
|
||||
|
||||
bool SendFrameImage( const Image *image, bool alarm_frame=false );
|
||||
bool WriteFrameImage( Image *image, struct timeval timestamp, const char *event_file, bool alarm_frame=false );
|
||||
|
@ -132,7 +132,7 @@ class Event {
|
|||
return( subpath );
|
||||
}
|
||||
static const char *getSubPath( time_t *time ) {
|
||||
return( Event::getSubPath( localtime( time ) ) );
|
||||
return Event::getSubPath( localtime( time ) );
|
||||
}
|
||||
|
||||
char* getEventFile(void) {
|
||||
|
@ -141,7 +141,7 @@ class Event {
|
|||
|
||||
public:
|
||||
static int PreAlarmCount() {
|
||||
return( pre_alarm_count );
|
||||
return pre_alarm_count;
|
||||
}
|
||||
static void EmptyPreAlarmFrames() {
|
||||
if ( pre_alarm_count > 0 ) {
|
||||
|
|
|
@ -62,7 +62,7 @@ bool EventStream::loadInitialEventData( int monitor_id, time_t event_time ) {
|
|||
exit( mysql_errno(&dbconn));
|
||||
}
|
||||
|
||||
int init_event_id = atoi(dbrow[0]);
|
||||
unsigned long long init_event_id = atoll(dbrow[0]);
|
||||
|
||||
mysql_free_result(result);
|
||||
|
||||
|
@ -84,10 +84,10 @@ bool EventStream::loadInitialEventData( int monitor_id, time_t event_time ) {
|
|||
Debug( 3, "Skipping %ld frames", event_data->frame_count );
|
||||
}
|
||||
}
|
||||
return( true );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EventStream::loadInitialEventData( int init_event_id, unsigned int init_frame_id ) {
|
||||
bool EventStream::loadInitialEventData( unsigned long long init_event_id, unsigned int init_frame_id ) {
|
||||
loadEventData(init_event_id);
|
||||
|
||||
if ( init_frame_id ) {
|
||||
|
@ -105,10 +105,10 @@ bool EventStream::loadInitialEventData( int init_event_id, unsigned int init_fra
|
|||
return true;
|
||||
}
|
||||
|
||||
bool EventStream::loadEventData(int event_id) {
|
||||
bool EventStream::loadEventData(unsigned long long event_id) {
|
||||
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, Scheme 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 = %llu", event_id);
|
||||
|
||||
if ( mysql_query(&dbconn, sql) ) {
|
||||
Error("Can't run query: %s", mysql_error(&dbconn));
|
||||
|
@ -159,30 +159,34 @@ bool EventStream::loadEventData(int event_id) {
|
|||
struct tm *event_time = localtime(&event_data->start_time);
|
||||
|
||||
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
|
||||
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",
|
||||
snprintf( event_data->path, sizeof(event_data->path), "%s/%ld/%04d-%02d-%02d/%llu",
|
||||
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",
|
||||
snprintf( event_data->path, sizeof(event_data->path), "%s/%s/%ld/%04d-%02d-%02d/%llu",
|
||||
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 {
|
||||
if ( storage_path[0] == '/' )
|
||||
snprintf( event_data->path, sizeof(event_data->path), "%s/%ld/%ld", storage_path, event_data->monitor_id, event_data->event_id );
|
||||
snprintf( event_data->path, sizeof(event_data->path), "%s/%ld/%llu",
|
||||
storage_path, event_data->monitor_id, event_data->event_id );
|
||||
else
|
||||
snprintf( event_data->path, sizeof(event_data->path), "%s/%s/%ld/%ld", staticConfig.PATH_WEB.c_str(), storage_path, event_data->monitor_id, event_data->event_id );
|
||||
snprintf( event_data->path, sizeof(event_data->path), "%s/%s/%ld/%llu",
|
||||
staticConfig.PATH_WEB.c_str(), storage_path, event_data->monitor_id, event_data->event_id );
|
||||
}
|
||||
delete storage; storage = NULL;
|
||||
|
||||
updateFrameRate( (double)event_data->frame_count/event_data->duration );
|
||||
|
||||
snprintf(sql, sizeof(sql), "select FrameId, unix_timestamp( `TimeStamp` ), Delta from Frames where EventId = %d order by FrameId asc", event_id);
|
||||
snprintf(sql, sizeof(sql), "SELECT FrameId, unix_timestamp( `TimeStamp` ), Delta FROM Frames where EventId = %llu ORDER BY FrameId ASC", event_id);
|
||||
if ( mysql_query(&dbconn, sql) ) {
|
||||
Error("Can't run query: %s", mysql_error(&dbconn));
|
||||
exit(mysql_errno(&dbconn));
|
||||
|
@ -227,7 +231,7 @@ bool EventStream::loadEventData(int event_id) {
|
|||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
mysql_free_result( result );
|
||||
mysql_free_result(result);
|
||||
//for ( int i = 0; i < 250; i++ )
|
||||
//{
|
||||
//Info( "%d -> %d @ %f (%d)", i+1, event_data->frames[i].timestamp, event_data->frames[i].delta, event_data->frames[i].in_db );
|
||||
|
@ -250,7 +254,7 @@ bool EventStream::loadEventData(int event_id) {
|
|||
else
|
||||
curr_stream_time = event_data->frames[event_data->frame_count-1].timestamp;
|
||||
}
|
||||
Debug(2, "Event:%ld, Frames:%ld, Duration: %.2f", event_data->event_id, event_data->frame_count, event_data->duration);
|
||||
Debug(2, "Event:%llu, Frames:%ld, Duration: %.2f", event_data->event_id, event_data->frame_count, event_data->duration);
|
||||
|
||||
return true;
|
||||
} // bool EventStream::loadEventData( int event_id )
|
||||
|
@ -260,7 +264,6 @@ void EventStream::processCommand(const CmdMsg *msg) {
|
|||
// Check for incoming command
|
||||
switch( (MsgCommand)msg->msg_data[0] ) {
|
||||
case CMD_PAUSE :
|
||||
{
|
||||
Debug( 1, "Got PAUSE command" );
|
||||
|
||||
// Set paused flag
|
||||
|
@ -268,12 +271,9 @@ void EventStream::processCommand(const CmdMsg *msg) {
|
|||
replay_rate = ZM_RATE_BASE;
|
||||
last_frame_sent = TV_2_FLOAT( now );
|
||||
break;
|
||||
}
|
||||
case CMD_PLAY :
|
||||
{
|
||||
Debug( 1, "Got PLAY command" );
|
||||
if ( paused ) {
|
||||
// Clear paused flag
|
||||
paused = false;
|
||||
}
|
||||
|
||||
|
@ -287,30 +287,20 @@ void EventStream::processCommand(const CmdMsg *msg) {
|
|||
|
||||
replay_rate = ZM_RATE_BASE;
|
||||
break;
|
||||
}
|
||||
case CMD_VARPLAY :
|
||||
{
|
||||
Debug( 1, "Got VARPLAY command" );
|
||||
if ( paused ) {
|
||||
// Clear paused flag
|
||||
paused = false;
|
||||
}
|
||||
replay_rate = ntohs(((unsigned char)msg->msg_data[2]<<8)|(unsigned char)msg->msg_data[1])-32768;
|
||||
break;
|
||||
}
|
||||
case CMD_STOP :
|
||||
{
|
||||
Debug( 1, "Got STOP command" );
|
||||
|
||||
// Clear paused flag
|
||||
paused = false;
|
||||
break;
|
||||
}
|
||||
case CMD_FASTFWD :
|
||||
{
|
||||
Debug( 1, "Got FAST FWD command" );
|
||||
if ( paused ) {
|
||||
// Clear paused flag
|
||||
paused = false;
|
||||
}
|
||||
// Set play rate
|
||||
|
@ -333,36 +323,21 @@ void EventStream::processCommand(const CmdMsg *msg) {
|
|||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CMD_SLOWFWD :
|
||||
{
|
||||
Debug( 1, "Got SLOW FWD command" );
|
||||
// Set paused flag
|
||||
paused = true;
|
||||
// Set play rate
|
||||
replay_rate = ZM_RATE_BASE;
|
||||
// Set step
|
||||
step = 1;
|
||||
break;
|
||||
}
|
||||
case CMD_SLOWREV :
|
||||
{
|
||||
Debug( 1, "Got SLOW REV command" );
|
||||
// Set paused flag
|
||||
paused = true;
|
||||
// Set play rate
|
||||
replay_rate = ZM_RATE_BASE;
|
||||
// Set step
|
||||
step = -1;
|
||||
break;
|
||||
}
|
||||
case CMD_FASTREV :
|
||||
{
|
||||
Debug( 1, "Got FAST REV command" );
|
||||
if ( paused ) {
|
||||
// Clear paused flag
|
||||
paused = false;
|
||||
}
|
||||
paused = false;
|
||||
// Set play rate
|
||||
switch ( replay_rate ) {
|
||||
case -2 * ZM_RATE_BASE :
|
||||
|
@ -383,9 +358,7 @@ void EventStream::processCommand(const CmdMsg *msg) {
|
|||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CMD_ZOOMIN :
|
||||
{
|
||||
x = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2];
|
||||
y = ((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4];
|
||||
Debug( 1, "Got ZOOM IN command, to %d,%d", x, y );
|
||||
|
@ -409,10 +382,7 @@ void EventStream::processCommand(const CmdMsg *msg) {
|
|||
}
|
||||
send_frame = true;
|
||||
break;
|
||||
|
||||
}
|
||||
case CMD_ZOOMOUT :
|
||||
{
|
||||
Debug( 1, "Got ZOOM OUT command" );
|
||||
switch ( zoom ) {
|
||||
case 500:
|
||||
|
@ -434,22 +404,16 @@ void EventStream::processCommand(const CmdMsg *msg) {
|
|||
}
|
||||
send_frame = true;
|
||||
break;
|
||||
}
|
||||
case CMD_PAN :
|
||||
{
|
||||
x = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2];
|
||||
y = ((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4];
|
||||
Debug( 1, "Got PAN command, to %d,%d", x, y );
|
||||
break;
|
||||
}
|
||||
case CMD_SCALE :
|
||||
{
|
||||
scale = ((unsigned char)msg->msg_data[1]<<8)|(unsigned char)msg->msg_data[2];
|
||||
Debug( 1, "Got SCALE command, to %d", scale );
|
||||
break;
|
||||
}
|
||||
case CMD_PREV :
|
||||
{
|
||||
Debug( 1, "Got PREV command" );
|
||||
if ( replay_rate >= 0 )
|
||||
curr_frame_id = 0;
|
||||
|
@ -458,9 +422,7 @@ void EventStream::processCommand(const CmdMsg *msg) {
|
|||
paused = false;
|
||||
forceEventChange = true;
|
||||
break;
|
||||
}
|
||||
case CMD_NEXT :
|
||||
{
|
||||
Debug( 1, "Got NEXT command" );
|
||||
if ( replay_rate >= 0 )
|
||||
curr_frame_id = event_data->frame_count+1;
|
||||
|
@ -469,7 +431,6 @@ void EventStream::processCommand(const CmdMsg *msg) {
|
|||
paused = false;
|
||||
forceEventChange = true;
|
||||
break;
|
||||
}
|
||||
case CMD_SEEK :
|
||||
{
|
||||
int offset = ((unsigned char)msg->msg_data[1]<<24)|((unsigned char)msg->msg_data[2]<<16)|((unsigned char)msg->msg_data[3]<<8)|(unsigned char)msg->msg_data[4];
|
||||
|
@ -479,35 +440,30 @@ void EventStream::processCommand(const CmdMsg *msg) {
|
|||
break;
|
||||
}
|
||||
case CMD_QUERY :
|
||||
{
|
||||
Debug( 1, "Got QUERY command, sending STATUS" );
|
||||
break;
|
||||
}
|
||||
case CMD_QUIT :
|
||||
{
|
||||
Info ("User initiated exit - CMD_QUIT");
|
||||
Info("User initiated exit - CMD_QUIT");
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
// Do nothing, for now
|
||||
}
|
||||
break;
|
||||
}
|
||||
struct {
|
||||
int event;
|
||||
unsigned long long event_id;
|
||||
int progress;
|
||||
int rate;
|
||||
int zoom;
|
||||
bool paused;
|
||||
} status_data;
|
||||
|
||||
status_data.event = event_data->event_id;
|
||||
status_data.event_id = event_data->event_id;
|
||||
status_data.progress = (int)event_data->frames[curr_frame_id-1].offset;
|
||||
status_data.rate = replay_rate;
|
||||
status_data.zoom = zoom;
|
||||
status_data.paused = paused;
|
||||
Debug( 2, "Event:%d, Paused:%d, progress:%d Rate:%d, Zoom:%d",
|
||||
status_data.event,
|
||||
Debug( 2, "Event:%llu, Paused:%d, progress:%d Rate:%d, Zoom:%d",
|
||||
status_data.event_id,
|
||||
status_data.paused,
|
||||
status_data.progress,
|
||||
status_data.rate,
|
||||
|
@ -516,19 +472,19 @@ void EventStream::processCommand(const CmdMsg *msg) {
|
|||
|
||||
DataMsg status_msg;
|
||||
status_msg.msg_type = MSG_DATA_EVENT;
|
||||
memcpy( &status_msg.msg_data, &status_data, sizeof(status_data) );
|
||||
if ( sendto( sd, &status_msg, sizeof(status_msg), MSG_DONTWAIT, (sockaddr *)&rem_addr, sizeof(rem_addr) ) < 0 ) {
|
||||
memcpy(&status_msg.msg_data, &status_data, sizeof(status_data));
|
||||
if ( sendto(sd, &status_msg, sizeof(status_msg), MSG_DONTWAIT, (sockaddr *)&rem_addr, sizeof(rem_addr)) < 0 ) {
|
||||
//if ( errno != EAGAIN )
|
||||
{
|
||||
Error( "Can't sendto on sd %d: %s", sd, strerror(errno) );
|
||||
exit( -1 );
|
||||
Error("Can't sendto on sd %d: %s", sd, strerror(errno));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
// quit after sending a status, if this was a quit request
|
||||
if ( (MsgCommand)msg->msg_data[0]==CMD_QUIT )
|
||||
exit(0);
|
||||
|
||||
updateFrameRate( (double)event_data->frame_count/event_data->duration );
|
||||
updateFrameRate((double)event_data->frame_count/event_data->duration);
|
||||
}
|
||||
|
||||
void EventStream::checkEventLoaded() {
|
||||
|
@ -536,10 +492,10 @@ void EventStream::checkEventLoaded() {
|
|||
static char sql[ZM_SQL_SML_BUFSIZ];
|
||||
|
||||
if ( curr_frame_id <= 0 ) {
|
||||
snprintf( sql, sizeof(sql), "select Id from Events where MonitorId = %ld and Id < %ld order by Id desc limit 1", event_data->monitor_id, event_data->event_id );
|
||||
snprintf( sql, sizeof(sql), "SELECT Id FROM Events WHERE MonitorId = %ld AND Id < %llu ORDER BY Id DESC LIMIT 1", event_data->monitor_id, event_data->event_id );
|
||||
reload_event = true;
|
||||
} else if ( (unsigned int)curr_frame_id > event_data->frame_count ) {
|
||||
snprintf( sql, sizeof(sql), "select Id from Events where MonitorId = %ld and Id > %ld order by Id asc limit 1", event_data->monitor_id, event_data->event_id );
|
||||
snprintf( sql, sizeof(sql), "SELECT Id FROM Events WHERE MonitorId = %ld AND Id > %llu ORDER BY Id ASC LIMIT 1", event_data->monitor_id, event_data->event_id );
|
||||
reload_event = true;
|
||||
}
|
||||
|
||||
|
@ -564,10 +520,10 @@ void EventStream::checkEventLoaded() {
|
|||
}
|
||||
|
||||
if ( dbrow ) {
|
||||
int event_id = atoi(dbrow[0]);
|
||||
Debug( 1, "Loading new event %d", event_id );
|
||||
unsigned long long event_id = atoll(dbrow[0]);
|
||||
Debug( 1, "Loading new event %llu", event_id );
|
||||
|
||||
loadEventData( event_id );
|
||||
loadEventData(event_id);
|
||||
|
||||
Debug( 2, "Current frame id = %d", curr_frame_id );
|
||||
if ( replay_rate < 0 )
|
||||
|
@ -657,25 +613,25 @@ Debug(2,"Streaming MPEG");
|
|||
send_raw = false;
|
||||
|
||||
if ( send_raw ) {
|
||||
fdj = fopen( filepath, "rb" );
|
||||
fdj = fopen(filepath, "rb");
|
||||
if ( !fdj ) {
|
||||
Error( "Can't open %s: %s", filepath, strerror(errno) );
|
||||
return( false );
|
||||
Error("Can't open %s: %s", filepath, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
#if HAVE_SENDFILE
|
||||
if( fstat(fileno(fdj),&filestat) < 0 ) {
|
||||
Error( "Failed getting information about file %s: %s", filepath, strerror(errno) );
|
||||
return( false );
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
img_buffer_size = fread( img_buffer, 1, sizeof(temp_img_buffer), fdj );
|
||||
img_buffer_size = fread(img_buffer, 1, sizeof(temp_img_buffer), fdj);
|
||||
#endif
|
||||
} else {
|
||||
Image *image = NULL;
|
||||
|
||||
if ( filepath[0] ) {
|
||||
Debug(1, "Loading image");
|
||||
image = new Image( filepath );
|
||||
image = new Image(filepath);
|
||||
} else if ( ffmpeg_input ) {
|
||||
// Get the frame from the mp4 input
|
||||
Debug(1,"Getting frame from ffmpeg");
|
||||
|
@ -722,16 +678,16 @@ Debug(1, "Loading image");
|
|||
|
||||
switch( type ) {
|
||||
case STREAM_JPEG :
|
||||
fprintf( stdout, "Content-Type: image/jpeg\r\n" );
|
||||
fputs( "Content-Type: image/jpeg\r\n", stdout );
|
||||
break;
|
||||
case STREAM_RAW :
|
||||
fprintf( stdout, "Content-Type: image/x-rgb\r\n" );
|
||||
fputs( "Content-Type: image/x-rgb\r\n", stdout );
|
||||
break;
|
||||
case STREAM_ZIP :
|
||||
fprintf( stdout, "Content-Type: image/x-rgbz\r\n" );
|
||||
fputs( "Content-Type: image/x-rgbz\r\n", stdout );
|
||||
break;
|
||||
default :
|
||||
Fatal( "Unexpected frame type %d", type );
|
||||
Fatal("Unexpected frame type %d", type);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -765,11 +721,11 @@ Debug(1, "Loading image");
|
|||
}
|
||||
}
|
||||
|
||||
fprintf( stdout, "\r\n\r\n" );
|
||||
fflush( stdout );
|
||||
fputs("\r\n\r\n", stdout);
|
||||
fflush(stdout);
|
||||
}
|
||||
last_frame_sent = TV_2_FLOAT( now );
|
||||
return( true );
|
||||
last_frame_sent = TV_2_FLOAT(now);
|
||||
return true;
|
||||
}
|
||||
|
||||
void EventStream::runStream() {
|
||||
|
@ -890,7 +846,7 @@ void EventStream::runStream() {
|
|||
|
||||
closeComms();
|
||||
}
|
||||
void EventStream::setStreamStart( int init_event_id, unsigned int init_frame_id=0 ) {
|
||||
void EventStream::setStreamStart( unsigned long long init_event_id, unsigned int init_frame_id=0 ) {
|
||||
loadInitialEventData( init_event_id, init_frame_id );
|
||||
if ( !(monitor = Monitor::Load( event_data->monitor_id, false, Monitor::QUERY )) ) {
|
||||
Fatal( "Unable to load monitor id %d for streaming", event_data->monitor_id );
|
||||
|
@ -898,9 +854,9 @@ void EventStream::setStreamStart( int init_event_id, unsigned int init_frame_id=
|
|||
}
|
||||
}
|
||||
void EventStream::setStreamStart( int monitor_id, time_t event_time ) {
|
||||
loadInitialEventData( monitor_id, event_time );
|
||||
if ( !(monitor = Monitor::Load( event_data->monitor_id, false, Monitor::QUERY )) ) {
|
||||
Fatal( "Unable to load monitor id %d for streaming", monitor_id );
|
||||
loadInitialEventData(monitor_id, event_time);
|
||||
if ( !(monitor = Monitor::Load(event_data->monitor_id, false, Monitor::QUERY)) ) {
|
||||
Fatal("Unable to load monitor id %d for streaming", monitor_id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ class EventStream : public StreamBase {
|
|||
};
|
||||
|
||||
struct EventData {
|
||||
unsigned long event_id;
|
||||
unsigned long long event_id;
|
||||
unsigned long monitor_id;
|
||||
unsigned long storage_id;
|
||||
unsigned long frame_count;
|
||||
|
@ -83,8 +83,8 @@ class EventStream : public StreamBase {
|
|||
FFmpeg_Input *ffmpeg_input;
|
||||
|
||||
protected:
|
||||
bool loadEventData( int event_id );
|
||||
bool loadInitialEventData( int init_event_id, unsigned int init_frame_id );
|
||||
bool loadEventData( unsigned long long event_id );
|
||||
bool loadInitialEventData( unsigned long long init_event_id, unsigned int init_frame_id );
|
||||
bool loadInitialEventData( int monitor_id, time_t event_time );
|
||||
|
||||
void checkEventLoaded();
|
||||
|
@ -110,7 +110,7 @@ class EventStream : public StreamBase {
|
|||
ffmpeg_input = NULL;
|
||||
|
||||
}
|
||||
void setStreamStart( int init_event_id, unsigned int init_frame_id );
|
||||
void setStreamStart( unsigned long long init_event_id, unsigned int init_frame_id );
|
||||
void setStreamStart( int monitor_id, time_t event_time );
|
||||
void setStreamMode( StreamMode p_mode ) {
|
||||
mode = p_mode;
|
||||
|
|
|
@ -261,11 +261,11 @@ bool Monitor::MonitorLink::inAlarm() {
|
|||
|
||||
bool Monitor::MonitorLink::hasAlarmed() {
|
||||
if ( shared_data->state == ALARM ) {
|
||||
return( true );
|
||||
} else if ( shared_data->last_event != (unsigned int)last_event ) {
|
||||
return true;
|
||||
} else if ( shared_data->last_event != last_event ) {
|
||||
last_event = shared_data->last_event;
|
||||
}
|
||||
return( false );
|
||||
return false;
|
||||
}
|
||||
|
||||
Monitor::Monitor(
|
||||
|
@ -634,7 +634,7 @@ Monitor::~Monitor() {
|
|||
}
|
||||
if ( mem_ptr ) {
|
||||
if ( event ) {
|
||||
Info( "%s: image_count:%d - Closing event %d, shutting down", name, image_count, event->Id() );
|
||||
Info( "%s: image_count:%d - Closing event %llu, shutting down", name, image_count, event->Id() );
|
||||
closeEvent();
|
||||
|
||||
// closeEvent may start another thread to close the event, so wait for it to finish
|
||||
|
@ -808,15 +808,15 @@ unsigned int Monitor::GetLastWriteIndex() const {
|
|||
return( shared_data->last_write_index!=(unsigned int)image_buffer_count?shared_data->last_write_index:-1 );
|
||||
}
|
||||
|
||||
uint32_t Monitor::GetLastEventId() const {
|
||||
Debug(2, "mem_ptr(%x), State(%d) last_read_index(%d) last_read_time(%d) last_event(%d)",
|
||||
uint64_t Monitor::GetLastEventId() const {
|
||||
Debug(2, "mem_ptr(%x), State(%d) last_read_index(%d) last_read_time(%d) last_event(%llu)",
|
||||
mem_ptr,
|
||||
shared_data->state,
|
||||
shared_data->last_read_index,
|
||||
shared_data->last_read_time,
|
||||
shared_data->last_event
|
||||
);
|
||||
return( shared_data->last_event );
|
||||
return shared_data->last_event;
|
||||
}
|
||||
|
||||
// This function is crap.
|
||||
|
@ -1090,9 +1090,9 @@ void Monitor::DumpZoneImage( const char *zone_string ) {
|
|||
std::string sql = stringtf("SELECT MAX(Id) FROM Events WHERE MonitorId=%d AND Frames > 0", id);
|
||||
zmDbRow eventid_row;
|
||||
if ( eventid_row.fetch(sql.c_str()) ) {
|
||||
int event_id = atoi(eventid_row[0]);
|
||||
uint64_t event_id = atoll(eventid_row[0]);
|
||||
|
||||
Debug(3, "Got event %d", event_id);
|
||||
Debug(3, "Got event %llu", event_id);
|
||||
EventStream *stream = new EventStream();
|
||||
stream->setStreamStart(event_id, (unsigned int)1);
|
||||
zone_image = stream->getImage();
|
||||
|
@ -1369,7 +1369,7 @@ bool Monitor::Analyse() {
|
|||
}
|
||||
Warning( "%s: %s", SIGNAL_CAUSE, signalText );
|
||||
if ( event && !signal ) {
|
||||
Info( "%s: %03d - Closing event %d, signal loss", name, image_count, event->Id() );
|
||||
Info( "%s: %03d - Closing event %llu, signal loss", name, image_count, event->Id() );
|
||||
closeEvent();
|
||||
last_section_mod = 0;
|
||||
}
|
||||
|
@ -1454,7 +1454,7 @@ bool Monitor::Analyse() {
|
|||
//shared_data->state = state = IDLE;
|
||||
//Info( "%s: %03d - Closing event %d, section end", name, image_count, event->Id() )
|
||||
//} else {
|
||||
Info( "%s: %03d - Closing event %d, section end forced ", name, image_count, event->Id() );
|
||||
Info( "%s: %03d - Closing event %llu, section end forced ", name, image_count, event->Id() );
|
||||
//}
|
||||
closeEvent();
|
||||
last_section_mod = 0;
|
||||
|
@ -1476,7 +1476,7 @@ bool Monitor::Analyse() {
|
|||
snprintf(video_store_data->event_file, sizeof(video_store_data->event_file), "%s", event->getEventFile());
|
||||
video_store_data->recording = event->StartTime();
|
||||
|
||||
Info( "%s: %03d - Opening new event %d, section start", name, image_count, event->Id() );
|
||||
Info( "%s: %03d - Opening new event %llu, section start", name, image_count, event->Id() );
|
||||
|
||||
/* To prevent cancelling out an existing alert\prealarm\alarm state */
|
||||
if ( state == IDLE ) {
|
||||
|
@ -1592,7 +1592,7 @@ bool Monitor::Analyse() {
|
|||
snprintf(video_store_data->event_file, sizeof(video_store_data->event_file), "%s", event->getEventFile());
|
||||
video_store_data->recording = event->StartTime();
|
||||
|
||||
Info( "%s: %03d - Opening new event %d, alarm start", name, image_count, event->Id() );
|
||||
Info( "%s: %03d - Opening new event %llu, alarm start", name, image_count, event->Id() );
|
||||
|
||||
if ( pre_event_images ) {
|
||||
if ( analysis_fps ) {
|
||||
|
@ -1630,11 +1630,11 @@ bool Monitor::Analyse() {
|
|||
shared_data->state = state = ALERT;
|
||||
} else if ( state == ALERT ) {
|
||||
if ( image_count-last_alarm_count > post_event_count ) {
|
||||
Info( "%s: %03d - Left alarm state (%d) - %d(%d) images", name, image_count, event->Id(), event->Frames(), event->AlarmFrames() );
|
||||
Info( "%s: %03d - Left alarm state (%llu) - %d(%d) images", name, image_count, event->Id(), event->Frames(), event->AlarmFrames() );
|
||||
//if ( function != MOCORD || event_close_mode == CLOSE_ALARM || event->Cause() == SIGNAL_CAUSE )
|
||||
if ( function != MOCORD || event_close_mode == CLOSE_ALARM ) {
|
||||
shared_data->state = state = IDLE;
|
||||
Info( "%s: %03d - Closing event %d, alarm end%s", name, image_count, event->Id(), (function==MOCORD)?", section truncated":"" );
|
||||
Info( "%s: %03d - Closing event %llu, alarm end%s", name, image_count, event->Id(), (function==MOCORD)?", section truncated":"" );
|
||||
closeEvent();
|
||||
} else {
|
||||
shared_data->state = state = TAPE;
|
||||
|
@ -1716,7 +1716,7 @@ bool Monitor::Analyse() {
|
|||
}
|
||||
} else {
|
||||
if ( event ) {
|
||||
Info( "%s: %03d - Closing event %d, trigger off", name, image_count, event->Id() );
|
||||
Info( "%s: %03d - Closing event %llu, trigger off", name, image_count, event->Id() );
|
||||
closeEvent();
|
||||
}
|
||||
shared_data->state = state = IDLE;
|
||||
|
@ -1753,7 +1753,7 @@ void Monitor::Reload() {
|
|||
Debug( 1, "Reloading monitor %s", name );
|
||||
|
||||
if ( event ) {
|
||||
Info( "%s: %03d - Closing event %d, reloading", name, image_count, event->Id() );
|
||||
Info( "%s: %03d - Closing event %llu, reloading", name, image_count, event->Id() );
|
||||
closeEvent();
|
||||
}
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ protected:
|
|||
//sizeOf(VideoStoreData) expected to be 4104 bytes on 32bit and 64bit
|
||||
typedef struct {
|
||||
uint32_t size;
|
||||
uint32_t current_event;
|
||||
uint64_t current_event;
|
||||
char event_file[4096];
|
||||
timeval recording; // used as both bool and a pointer to the timestamp when recording should begin
|
||||
//uint32_t frameNumber;
|
||||
|
@ -204,7 +204,7 @@ protected:
|
|||
volatile VideoStoreData *video_store_data;
|
||||
|
||||
int last_state;
|
||||
int last_event;
|
||||
uint64_t last_event;
|
||||
|
||||
|
||||
public:
|
||||
|
@ -212,7 +212,7 @@ protected:
|
|||
~MonitorLink();
|
||||
|
||||
inline int Id() const {
|
||||
return( id );
|
||||
return id;
|
||||
}
|
||||
inline const char *Name() const {
|
||||
return( name );
|
||||
|
@ -401,40 +401,40 @@ public:
|
|||
}
|
||||
|
||||
inline int Id() const {
|
||||
return( id );
|
||||
return id;
|
||||
}
|
||||
inline const char *Name() const {
|
||||
return( name );
|
||||
return name;
|
||||
}
|
||||
inline Storage *getStorage() {
|
||||
if ( ! storage ) {
|
||||
storage = new Storage( storage_id );
|
||||
}
|
||||
return( storage );
|
||||
return storage;
|
||||
}
|
||||
inline Function GetFunction() const {
|
||||
return( function );
|
||||
}
|
||||
inline bool Enabled() {
|
||||
if ( function <= MONITOR )
|
||||
return( false );
|
||||
return( enabled );
|
||||
return false;
|
||||
return enabled;
|
||||
}
|
||||
inline const char *EventPrefix() const {
|
||||
return( event_prefix );
|
||||
return event_prefix;
|
||||
}
|
||||
inline bool Ready() {
|
||||
if ( function <= MONITOR )
|
||||
return( false );
|
||||
return false;
|
||||
return( image_count > ready_count );
|
||||
}
|
||||
inline bool Active() {
|
||||
if ( function <= MONITOR )
|
||||
return( false );
|
||||
return false;
|
||||
return( enabled && shared_data->active );
|
||||
}
|
||||
inline bool Exif() {
|
||||
return( embed_exif );
|
||||
return embed_exif;
|
||||
}
|
||||
Orientation getOrientation() const;
|
||||
|
||||
|
@ -446,8 +446,8 @@ public:
|
|||
int GetOptSaveJPEGs() const { return savejpegs; }
|
||||
VideoWriter GetOptVideoWriter() const { return videowriter; }
|
||||
const std::vector<EncoderParameter_t>* GetOptEncoderParams() const { return &encoderparamsvec; }
|
||||
uint32_t GetVideoWriterEventId() const { return video_store_data->current_event; }
|
||||
void SetVideoWriterEventId( uint32_t p_event_id ) { video_store_data->current_event = p_event_id; }
|
||||
uint64_t GetVideoWriterEventId() const { return video_store_data->current_event; }
|
||||
void SetVideoWriterEventId( uint64_t p_event_id ) { video_store_data->current_event = p_event_id; }
|
||||
|
||||
unsigned int GetPreEventCount() const { return pre_event_count; };
|
||||
State GetState() const;
|
||||
|
@ -461,7 +461,7 @@ public:
|
|||
int GetAlarmCaptureDelay() const { return alarm_capture_delay; }
|
||||
unsigned int GetLastReadIndex() const;
|
||||
unsigned int GetLastWriteIndex() const;
|
||||
uint32_t GetLastEventId() const;
|
||||
uint64_t GetLastEventId() const;
|
||||
double GetFPS() const;
|
||||
void ForceAlarmOn( int force_score, const char *force_case, const char *force_text="" );
|
||||
void ForceAlarmOff();
|
||||
|
|
|
@ -58,7 +58,7 @@ int main( int argc, const char *argv[] ) {
|
|||
char format[32] = "";
|
||||
int monitor_id = 0;
|
||||
time_t event_time = 0;
|
||||
int event_id = 0;
|
||||
unsigned long long event_id = 0;
|
||||
unsigned int frame_id = 1;
|
||||
unsigned int scale = 100;
|
||||
unsigned int rate = 100;
|
||||
|
@ -174,7 +174,7 @@ int main( int argc, const char *argv[] ) {
|
|||
if ( monitor_id ) {
|
||||
snprintf(log_id_string, sizeof(log_id_string), "zms_m%d", monitor_id);
|
||||
} else {
|
||||
snprintf(log_id_string, sizeof(log_id_string), "zms_e%d", event_id);
|
||||
snprintf(log_id_string, sizeof(log_id_string), "zms_e%llu", event_id);
|
||||
}
|
||||
logInit( log_id_string );
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 1351dde6b4c75b215099ae8bcf5a21d6c6e10298
|
||||
Subproject commit c3976f1478c681b0bbc132ec3a3e82c3984eeed5
|
|
@ -176,6 +176,16 @@ xhtmlHeaders( __FILE__, translate('Console') );
|
|||
</div>
|
||||
|
||||
<div class="container-fluid">
|
||||
<?php
|
||||
for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
|
||||
$monitor = $displayMonitors[$monitor_i];
|
||||
$Monitor = new Monitor($monitor);
|
||||
|
||||
if ( $monitor_i % 100 == 0 ) {
|
||||
if ( $monitor_i ) {
|
||||
echo '</table>';
|
||||
}
|
||||
?>
|
||||
<table class="table table-striped table-hover table-condensed" id="consoleTable">
|
||||
<thead class="thead-highlight">
|
||||
<tr>
|
||||
|
@ -203,9 +213,7 @@ xhtmlHeaders( __FILE__, translate('Console') );
|
|||
</thead>
|
||||
<tbody id="consoleTableBody">
|
||||
<?php
|
||||
for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) {
|
||||
$monitor = $displayMonitors[$monitor_i];
|
||||
$Monitor = new Monitor($monitor);
|
||||
} # monitor_i % 100
|
||||
?>
|
||||
<tr id="<?php echo 'monitor_id-'.$monitor['Id'] ?>" title="<?php echo $monitor['Id'] ?>">
|
||||
<?php
|
||||
|
|
Loading…
Reference in New Issue