diff --git a/src/zm_event.cpp b/src/zm_event.cpp index ee4416f19..55ff9883d 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -265,7 +265,7 @@ void Event::AddFrame( struct timeval timestamp, const Image *image, const Image } } -void Event::StreamEvent( const char *path, int event_id, long refresh, FILE *fd ) +void Event::StreamEvent( const char *path, int event_id, int rate, FILE *fd ) { static char sql[BUFSIZ]; sprintf( sql, "select Id, EventId, ImagePath, Delta from Frames where EventId = %d order by Id", event_id ); @@ -291,18 +291,23 @@ void Event::StreamEvent( const char *path, int event_id, long refresh, FILE *fd fprintf( fd, "--ZoneMinderFrame\n" ); int n_frames = mysql_num_rows( result ); - Info(( "Got %d frames", n_frames )); + Info(( "Got %d frames, at rate %d", n_frames, rate )); FILE *fdj = NULL; int n_bytes = 0; static unsigned char buffer[400000]; double last_delta = 0; for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ ) { - if ( refresh < 0 ) + if ( rate ) { if ( i ) { - usleep( (int)((1000000*(atof(dbrow[3])-last_delta))/abs(refresh)) ); + int delay = 0; + if ( rate < 0 ) + delay = (int)((1000000*(atof(dbrow[3])-last_delta))*abs(rate)); + else + delay = (int)((1000000*(atof(dbrow[3])-last_delta))/rate); + usleep( delay ); } last_delta = atof(dbrow[3]); } @@ -322,10 +327,6 @@ void Event::StreamEvent( const char *path, int event_id, long refresh, FILE *fd { Error(( "Can't open %s: %s", filepath, strerror(errno) )); } - if ( refresh > 0 ) - { - usleep( refresh*1000 ); - } } if ( mysql_errno( &dbconn ) ) { diff --git a/src/zm_event.h b/src/zm_event.h index 4990dc7b1..c526eef36 100644 --- a/src/zm_event.h +++ b/src/zm_event.h @@ -83,7 +83,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, long refresh=0, FILE *fd=stdout ); + static void StreamEvent( const char *path, int event_id, int rate=1, FILE *fd=stdout ); }; #endif // ZM_EVENT_H diff --git a/src/zms.cpp b/src/zms.cpp index 6a2540dbe..8263da1f2 100644 --- a/src/zms.cpp +++ b/src/zms.cpp @@ -26,6 +26,7 @@ int main( int argc, const char *argv[] ) int id = 1; unsigned long idle = 5000; unsigned long refresh = 50; + unsigned int rate = 1; int event = 0; char *path = "."; unsigned int ttl = 0; @@ -52,7 +53,9 @@ int main( int argc, const char *argv[] ) { char *name = strtok( parms[p], "=" ); char *value = strtok( NULL, "=" ); - if ( !strcmp( name, "refresh" ) ) + if ( !strcmp( name, "rate" ) ) + rate = atoi( value ); + else if ( !strcmp( name, "refresh" ) ) refresh = atol( value ); else if ( !strcmp( name, "idle" ) ) idle = atol( value ); @@ -84,7 +87,7 @@ int main( int argc, const char *argv[] ) } else { - Event::StreamEvent( path, event, refresh, stdout ); + Event::StreamEvent( path, event, rate, stdout ); } return( 0 ); } diff --git a/web/zm_config.php.z b/web/zm_config.php.z index 13f6361a1..cee861bfa 100644 --- a/web/zm_config.php.z +++ b/web/zm_config.php.z @@ -42,6 +42,16 @@ define( "MAX_EVENTS", 10 ); // The maximum number of events to show in th define( "EVENT_HEADER_LINES", 25 ); // How many events are listed in the event window before a new header is inserted define( "LEARN_MODE", false ); // Currently unimplemented, do not change +$rates = array( + "0" => "Max", + "10" => "10x", + "4" => "4x", + "2" => "2x", + "1" => "Real", + "-2" => "1/2x", + "-4" => "1/4x", +); + require_once( 'zm_db.php' ); loadConfig(); diff --git a/web/zm_html_view_event.php b/web/zm_html_view_event.php index 5fdae8385..61a277287 100644 --- a/web/zm_html_view_event.php +++ b/web/zm_html_view_event.php @@ -27,6 +27,8 @@ die( mysql_error() ); $next_event = mysql_fetch_assoc( $result ); + if ( !isset( $rate ) ) + $rate = 1; ?> @@ -76,7 +78,7 @@ function newWindow(Url,Name,Width,Height) disabled> - +
@@ -87,6 +89,15 @@ function newWindow(Url,Name,Width,Height) Learn Pref: 
+ +
+ + + + + +
+ Refresh @@ -113,7 +124,7 @@ Learn Pref: