diff --git a/src/zm_event.cpp b/src/zm_event.cpp index ef75813c9..2029475a8 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -267,7 +267,7 @@ void Event::AddFrame( struct timeval timestamp, const Image *image, const Image void Event::StreamEvent( const char *path, int event_id, unsigned long refresh, FILE *fd ) { static char sql[256]; - sprintf( sql, "select Id, EventId, ImagePath, Delta*10000 from Frames where EventId = %d order by Id", event_id ); + sprintf( sql, "select Id, EventId, ImagePath, Delta from Frames where EventId = %d order by Id", event_id ); if ( mysql_query( &dbconn, sql ) ) { Error(( "Can't run query: %s", mysql_error( &dbconn ) )); @@ -294,19 +294,16 @@ void Event::StreamEvent( const char *path, int event_id, unsigned long refresh, FILE *fdj = NULL; int n_bytes = 0; static unsigned char buffer[400000]; - int last_delta = 0; + double last_delta = 0; for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ ) { - if ( !refresh ) + if ( refresh < 0 ) { - if ( !i ) + if ( i ) { - last_delta = atoi(dbrow[3]); - } - else - { - usleep( atoi(dbrow[3])-last_delta ); + usleep( (int)((1000000*(atof(dbrow[3])-last_delta))/abs(refresh)) ); } + last_delta = atof(dbrow[3]); } char filepath[PATH_MAX]; sprintf( filepath, "%s/%s", path, dbrow[2] ); diff --git a/src/zm_event.h b/src/zm_event.h index fff41af77..e0f3278a9 100644 --- a/src/zm_event.h +++ b/src/zm_event.h @@ -79,7 +79,7 @@ public: void AddFrames( int n_frames, struct timeval **timestamps, const Image **images ); void AddFrame( struct timeval timestamp, const Image *image, const Image *alarm_frame=NULL, unsigned int score=0 ); - static void StreamEvent( const char *path, int event_id, unsigned long refresh=100, FILE *fd=stdout ); + static void StreamEvent( const char *path, int event_id, unsigned long refresh=-1, FILE *fd=stdout ); }; #endif // ZM_EVENT_H