diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 4d1bd0c29..d528f816d 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -34,7 +34,7 @@ bool Event::initialised = false; bool Event::timestamp_on_capture; -bool Event::bulk_frame_interval; +int Event::bulk_frame_interval; Event::Event( Monitor *p_monitor, struct timeval p_start_time ) : monitor( p_monitor ), start_time( p_start_time ) { @@ -281,7 +281,7 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image * struct DeltaTimeval delta_time; DELTA_TIMEVAL( delta_time, timestamp, start_time, DT_PREC_2 ); - bool db_frame = score>=0 || !((frames-1)%bulk_frame_interval); + bool db_frame = (score>=0) || ((frames%bulk_frame_interval)==0) || !frames; if ( db_frame ) { @@ -289,7 +289,7 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image * Debug( 1, ( "Adding frame %d to DB", frames )); static char sql[BUFSIZ]; - sprintf( sql, "insert into Frames ( EventId, FrameId, AlarmFrame, Delta, Score ) values ( %d, %d, '%s', %s%ld.%02ld, %d )", id, frames, frame_type, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, score ); + sprintf( sql, "insert into Frames ( EventId, FrameId, Type, Delta, Score ) values ( %d, %d, '%s', %s%ld.%02ld, %d )", id, frames, frame_type, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, score ); if ( mysql_query( &dbconn, sql ) ) { Error(( "Can't insert frame: %s", mysql_error( &dbconn ) )); @@ -363,7 +363,7 @@ void Event::StreamEvent( int event_id, int rate, int scale ) static char sql[BUFSIZ]; static char eventpath[PATH_MAX]; - sprintf( sql, "select M.Id, M.Name from Events as E inner join Monitors as M on E.MonitorId = M.Id where E.Id = %d", event_id ); + sprintf( sql, "select M.Id, M.Name, E.Frames from Events as E inner join Monitors as M on E.MonitorId = M.Id where E.Id = %d", event_id ); if ( mysql_query( &dbconn, sql ) ) { Error(( "Can't run query: %s", mysql_error( &dbconn ) )); @@ -385,6 +385,7 @@ void Event::StreamEvent( int event_id, int rate, int scale ) } sprintf( eventpath, "%s/%s/%s/%d", ZM_PATH_WEB, (const char *)config.Item( ZM_DIR_EVENTS ), dbrow[1], event_id ); + int frames = atoi(dbrow[2] ); mysql_free_result( result ); diff --git a/src/zm_event.h b/src/zm_event.h index 2a51e65fa..ce1710f36 100644 --- a/src/zm_event.h +++ b/src/zm_event.h @@ -44,7 +44,7 @@ class Event protected: static bool initialised; static bool timestamp_on_capture; - static bool bulk_frame_interval; + static int bulk_frame_interval; protected: static int sd; diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 2d55a005e..6dff654dd 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -34,7 +34,7 @@ bool Monitor::opt_adaptive_skip; bool Monitor::create_analysis_images; bool Monitor::blend_alarmed_images; bool Monitor::timestamp_on_capture; -bool Monitor::bulk_frame_interval; +int Monitor::bulk_frame_interval; Monitor::Monitor( int p_id, diff --git a/src/zm_monitor.h b/src/zm_monitor.h index 5767c13ce..b38be3f1f 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -70,7 +70,7 @@ protected: static bool create_analysis_images; static bool blend_alarmed_images; static bool timestamp_on_capture; - static bool bulk_frame_interval; + static int bulk_frame_interval; protected: // These are read from the DB and thereafter remain unchanged