Added ttl to streaming.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@401 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
7f3e3e8e38
commit
c722d9046d
13
src/zm.cpp
13
src/zm.cpp
|
@ -2405,8 +2405,10 @@ Monitor *Monitor::Load( int id, bool load_zones )
|
||||||
return( monitor );
|
return( monitor );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Monitor::StreamImages( unsigned long idle, unsigned long refresh, FILE *fd )
|
void Monitor::StreamImages( unsigned long idle, unsigned long refresh, FILE *fd, unsigned int ttl )
|
||||||
{
|
{
|
||||||
|
time_t start_time, now;
|
||||||
|
|
||||||
fprintf( fd, "Server: ZoneMinder Stream Server\r\n" );
|
fprintf( fd, "Server: ZoneMinder Stream Server\r\n" );
|
||||||
fprintf( fd, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\r\n" );
|
fprintf( fd, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\r\n" );
|
||||||
fprintf( fd, "\r\n" );
|
fprintf( fd, "\r\n" );
|
||||||
|
@ -2415,6 +2417,7 @@ void Monitor::StreamImages( unsigned long idle, unsigned long refresh, FILE *fd
|
||||||
JOCTET img_buffer[camera->ImageSize()];
|
JOCTET img_buffer[camera->ImageSize()];
|
||||||
int img_buffer_size = 0;
|
int img_buffer_size = 0;
|
||||||
int loop_count = (idle/refresh)-1;
|
int loop_count = (idle/refresh)-1;
|
||||||
|
time( &start_time );
|
||||||
while ( true )
|
while ( true )
|
||||||
{
|
{
|
||||||
if ( last_read_index != shared_images->last_write_index )
|
if ( last_read_index != shared_images->last_write_index )
|
||||||
|
@ -2437,6 +2440,14 @@ void Monitor::StreamImages( unsigned long idle, unsigned long refresh, FILE *fd
|
||||||
{
|
{
|
||||||
usleep( refresh*1000 );
|
usleep( refresh*1000 );
|
||||||
}
|
}
|
||||||
|
if ( ttl )
|
||||||
|
{
|
||||||
|
time( &now );
|
||||||
|
if ( (now - start_time) > ttl )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
src/zm.h
2
src/zm.h
|
@ -738,5 +738,5 @@ public:
|
||||||
void ReloadZones();
|
void ReloadZones();
|
||||||
static int Load( int device, Monitor **&monitors, bool capture=true );
|
static int Load( int device, Monitor **&monitors, bool capture=true );
|
||||||
static Monitor *Load( int id, bool load_zones=false );
|
static Monitor *Load( int id, bool load_zones=false );
|
||||||
void StreamImages( unsigned long idle=5000, unsigned long refresh=50, FILE *fd=stdout );
|
void StreamImages( unsigned long idle=5000, unsigned long refresh=50, FILE *fd=stdout, unsigned int ttl=0 );
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,6 +26,7 @@ int main( int argc, const char *argv[] )
|
||||||
unsigned long refresh = 50;
|
unsigned long refresh = 50;
|
||||||
int event = 0;
|
int event = 0;
|
||||||
char *path = ".";
|
char *path = ".";
|
||||||
|
unsigned int ttl = 0;
|
||||||
|
|
||||||
const char *query = getenv( "QUERY_STRING" );
|
const char *query = getenv( "QUERY_STRING" );
|
||||||
if ( query )
|
if ( query )
|
||||||
|
@ -55,6 +56,8 @@ int main( int argc, const char *argv[] )
|
||||||
event = atoi( value );
|
event = atoi( value );
|
||||||
else if ( !strcmp( name, "path" ) )
|
else if ( !strcmp( name, "path" ) )
|
||||||
path = value;
|
path = value;
|
||||||
|
else if ( !strcmp( name, "path" ) )
|
||||||
|
ttl = atoi(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +86,9 @@ int main( int argc, const char *argv[] )
|
||||||
Monitor *monitor = Monitor::Load( id );
|
Monitor *monitor = Monitor::Load( id );
|
||||||
|
|
||||||
if ( monitor )
|
if ( monitor )
|
||||||
monitor->StreamImages( idle, refresh, stdout );
|
{
|
||||||
|
monitor->StreamImages( idle, refresh, stdout, ttl );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue