Added patch to allow zms to produce single images.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1013 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
7a60820aa9
commit
d7671a1daf
|
@ -1171,6 +1171,32 @@ void Monitor::StreamImages( int scale, int maxfps, time_t ttl )
|
|||
}
|
||||
}
|
||||
|
||||
void Monitor::SingleImage( int scale)
|
||||
{
|
||||
int last_read_index = shared_data->last_write_index;
|
||||
int img_buffer_size = 0;
|
||||
static JOCTET img_buffer[ZM_MAX_IMAGE_SIZE];
|
||||
Image scaled_image;
|
||||
int index = shared_data->last_write_index%image_buffer_count;
|
||||
Snapshot *snap = &image_buffer[index];
|
||||
Image *snap_image = snap->image;
|
||||
|
||||
if ( scale != 100 )
|
||||
{
|
||||
scaled_image.Assign( *snap_image );
|
||||
scaled_image.Scale( scale );
|
||||
snap_image = &scaled_image;
|
||||
}
|
||||
if ( !timestamp_on_capture )
|
||||
{
|
||||
TimestampImage( snap_image, snap->timestamp->tv_sec );
|
||||
}
|
||||
snap_image->EncodeJpeg( img_buffer, &img_buffer_size );
|
||||
|
||||
fprintf( stdout, "Content-Length: %d\r\n", img_buffer_size );
|
||||
fprintf( stdout, "Content-Type: image/jpeg\r\n\r\n" );
|
||||
fwrite( img_buffer, img_buffer_size, 1, stdout );
|
||||
}
|
||||
|
||||
#if HAVE_LIBAVCODEC
|
||||
|
||||
|
|
|
@ -288,6 +288,7 @@ public:
|
|||
static int Load( const char *host, const char*port, const char*path, Monitor **&monitors, Purpose purpose=QUERY );
|
||||
static Monitor *Load( int id, bool load_zones=false, Purpose purpose=QUERY );
|
||||
void StreamImages( int scale=100, int maxfps=10, time_t ttl=0 );
|
||||
void SingleImage( int scale=100 );
|
||||
#if HAVE_LIBAVCODEC
|
||||
void StreamMpeg( const char *format, int scale=100, int maxfps=10, int bitrate=100000 );
|
||||
#endif // HAVE_LIBAVCODEC
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
int main( int argc, const char *argv[] )
|
||||
{
|
||||
enum { ZMS_JPEG, ZMS_MPEG } mode = ZMS_JPEG;
|
||||
enum { ZMS_JPEG, ZMS_MPEG, ZMS_SINGLE } mode = ZMS_JPEG;
|
||||
char format[32] = "";
|
||||
int id = 1;
|
||||
int event = 0;
|
||||
|
@ -67,7 +67,10 @@ int main( int argc, const char *argv[] )
|
|||
char *name = strtok( parms[p], "=" );
|
||||
char *value = strtok( NULL, "=" );
|
||||
if ( !strcmp( name, "mode" ) )
|
||||
{
|
||||
mode = !strcmp( value, "jpeg" )?ZMS_JPEG:ZMS_MPEG;
|
||||
mode = !strcmp( value, "single" )?ZMS_SINGLE:mode;
|
||||
}
|
||||
else if ( !strcmp( name, "monitor" ) )
|
||||
id = atoi( value );
|
||||
else if ( !strcmp( name, "event" ) )
|
||||
|
@ -121,6 +124,10 @@ int main( int argc, const char *argv[] )
|
|||
{
|
||||
monitor->StreamImages( scale, maxfps, ttl );
|
||||
}
|
||||
else if ( mode == ZMS_SINGLE )
|
||||
{
|
||||
monitor->SingleImage( scale );
|
||||
}
|
||||
else
|
||||
{
|
||||
#if HAVE_LIBAVCODEC
|
||||
|
|
Loading…
Reference in New Issue