Added realtime option to event streaming.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@540 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
384881798f
commit
57158a3eac
|
@ -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] );
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue