Added rate control to event replay.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@649 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
e498c91185
commit
3fe296d406
|
@ -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];
|
static char sql[BUFSIZ];
|
||||||
sprintf( sql, "select Id, EventId, ImagePath, Delta 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 );
|
||||||
|
@ -291,18 +291,23 @@ void Event::StreamEvent( const char *path, int event_id, long refresh, FILE *fd
|
||||||
fprintf( fd, "--ZoneMinderFrame\n" );
|
fprintf( fd, "--ZoneMinderFrame\n" );
|
||||||
|
|
||||||
int n_frames = mysql_num_rows( result );
|
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;
|
FILE *fdj = NULL;
|
||||||
int n_bytes = 0;
|
int n_bytes = 0;
|
||||||
static unsigned char buffer[400000];
|
static unsigned char buffer[400000];
|
||||||
double last_delta = 0;
|
double last_delta = 0;
|
||||||
for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ )
|
for( int i = 0; MYSQL_ROW dbrow = mysql_fetch_row( result ); i++ )
|
||||||
{
|
{
|
||||||
if ( refresh < 0 )
|
if ( rate )
|
||||||
{
|
{
|
||||||
if ( i )
|
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]);
|
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) ));
|
Error(( "Can't open %s: %s", filepath, strerror(errno) ));
|
||||||
}
|
}
|
||||||
if ( refresh > 0 )
|
|
||||||
{
|
|
||||||
usleep( refresh*1000 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ( mysql_errno( &dbconn ) )
|
if ( mysql_errno( &dbconn ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -83,7 +83,7 @@ public:
|
||||||
void AddFrames( int n_frames, struct timeval **timestamps, const Image **images );
|
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 );
|
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
|
#endif // ZM_EVENT_H
|
||||||
|
|
|
@ -26,6 +26,7 @@ int main( int argc, const char *argv[] )
|
||||||
int id = 1;
|
int id = 1;
|
||||||
unsigned long idle = 5000;
|
unsigned long idle = 5000;
|
||||||
unsigned long refresh = 50;
|
unsigned long refresh = 50;
|
||||||
|
unsigned int rate = 1;
|
||||||
int event = 0;
|
int event = 0;
|
||||||
char *path = ".";
|
char *path = ".";
|
||||||
unsigned int ttl = 0;
|
unsigned int ttl = 0;
|
||||||
|
@ -52,7 +53,9 @@ int main( int argc, const char *argv[] )
|
||||||
{
|
{
|
||||||
char *name = strtok( parms[p], "=" );
|
char *name = strtok( parms[p], "=" );
|
||||||
char *value = strtok( NULL, "=" );
|
char *value = strtok( NULL, "=" );
|
||||||
if ( !strcmp( name, "refresh" ) )
|
if ( !strcmp( name, "rate" ) )
|
||||||
|
rate = atoi( value );
|
||||||
|
else if ( !strcmp( name, "refresh" ) )
|
||||||
refresh = atol( value );
|
refresh = atol( value );
|
||||||
else if ( !strcmp( name, "idle" ) )
|
else if ( !strcmp( name, "idle" ) )
|
||||||
idle = atol( value );
|
idle = atol( value );
|
||||||
|
@ -84,7 +87,7 @@ int main( int argc, const char *argv[] )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Event::StreamEvent( path, event, refresh, stdout );
|
Event::StreamEvent( path, event, rate, stdout );
|
||||||
}
|
}
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -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( "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
|
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' );
|
require_once( 'zm_db.php' );
|
||||||
loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
die( mysql_error() );
|
die( mysql_error() );
|
||||||
$next_event = mysql_fetch_assoc( $result );
|
$next_event = mysql_fetch_assoc( $result );
|
||||||
|
|
||||||
|
if ( !isset( $rate ) )
|
||||||
|
$rate = 1;
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
@ -76,7 +78,7 @@ function newWindow(Url,Name,Width,Height)
|
||||||
<input type="hidden" name="eid" value="<?= $eid ?>">
|
<input type="hidden" name="eid" value="<?= $eid ?>">
|
||||||
<input type="text" size="16" name="event_name" value="<?= $event[Name] ?>" class="form">
|
<input type="text" size="16" name="event_name" value="<?= $event[Name] ?>" class="form">
|
||||||
<input type="submit" value="Rename" class="form"<?php if ( !canEdit( 'Events' ) ) { ?> disabled<?php } ?>></form></td>
|
<input type="submit" value="Rename" class="form"<?php if ( !canEdit( 'Events' ) ) { ?> disabled<?php } ?>></form></td>
|
||||||
<td colspan="3" align="right" class="text">
|
<td colspan="2" align="right" class="text">
|
||||||
<form name="learn_form" method="get" action="<?= $PHP_SELF ?>">
|
<form name="learn_form" method="get" action="<?= $PHP_SELF ?>">
|
||||||
<input type="hidden" name="view" value="<?= $view ?>">
|
<input type="hidden" name="view" value="<?= $view ?>">
|
||||||
<input type="hidden" name="action" value="learn">
|
<input type="hidden" name="action" value="learn">
|
||||||
|
@ -87,6 +89,15 @@ function newWindow(Url,Name,Width,Height)
|
||||||
Learn Pref: <select name="learn_state" class="form" onChange="learn_form.submit();"><option value=""<?php if ( !$event[LearnState] ) echo " selected" ?>>Ignore</option><option value="-"<?php if ( $event[LearnState]=='-' ) echo " selected" ?>>Exclude</option><option value="+"<?php if ( $event[LearnState]=='+' ) echo " selected" ?>>Include</option></select>
|
Learn Pref: <select name="learn_state" class="form" onChange="learn_form.submit();"><option value=""<?php if ( !$event[LearnState] ) echo " selected" ?>>Ignore</option><option value="-"<?php if ( $event[LearnState]=='-' ) echo " selected" ?>>Exclude</option><option value="+"<?php if ( $event[LearnState]=='+' ) echo " selected" ?>>Include</option></select>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</form></td>
|
</form></td>
|
||||||
|
<td colspan="1" align="right" class="text">
|
||||||
|
<form name="rate_form" method="get" action="<?= $PHP_SELF ?>">
|
||||||
|
<input type="hidden" name="view" value="<?= $view ?>">
|
||||||
|
<input type="hidden" name="action" value="rename">
|
||||||
|
<input type="hidden" name="mid" value="<?= $mid ?>">
|
||||||
|
<input type="hidden" name="eid" value="<?= $eid ?>">
|
||||||
|
<?php buildSelect( "rate", $rates, "document.rate_form.submit();" ); ?>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" class="text"><a href="javascript: refreshWindow();">Refresh</a></td>
|
<td align="center" class="text"><a href="javascript: refreshWindow();">Refresh</a></td>
|
||||||
|
@ -113,7 +124,7 @@ Learn Pref: <select name="learn_state" class="form" onChange="learn_form.su
|
||||||
<?php
|
<?php
|
||||||
if ( $mode == "stream" )
|
if ( $mode == "stream" )
|
||||||
{
|
{
|
||||||
$stream_src = ZM_PATH_ZMS."?path=".ZM_PATH_WEB."&event=$eid&refresh=".STREAM_EVENT_DELAY;
|
$stream_src = ZM_PATH_ZMS."?path=".ZM_PATH_WEB."&event=$eid&rate=$rate";
|
||||||
if ( isNetscape() )
|
if ( isNetscape() )
|
||||||
{
|
{
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue