Fixed JPEG streaming.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@945 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
84dd33ade1
commit
9ecd8ce9f7
|
@ -331,7 +331,7 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image *
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Info(( "Can't glob '%s': %s", diag_glob, glob_status ));
|
Info(( "Can't glob '%s': %d", diag_glob, glob_status ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -404,6 +404,7 @@ void Event::StreamEvent( int event_id, int rate, int scale )
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( stdout, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\r\n\r\n" );
|
fprintf( stdout, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\r\n\r\n" );
|
||||||
|
fprintf( stdout, "--ZoneMinderFrame\r\n" );
|
||||||
|
|
||||||
//int n_frames = mysql_num_rows( result );
|
//int n_frames = mysql_num_rows( result );
|
||||||
//Info(( "Got %d frames, at rate %d, scale %d", n_frames, rate, scale ));
|
//Info(( "Got %d frames, at rate %d, scale %d", n_frames, rate, scale ));
|
||||||
|
@ -441,6 +442,8 @@ void Event::StreamEvent( int event_id, int rate, int scale )
|
||||||
static char filepath[PATH_MAX];
|
static char filepath[PATH_MAX];
|
||||||
sprintf( filepath, "%s/%03d-capture.jpg", eventpath, atoi(dbrow[0]) );
|
sprintf( filepath, "%s/%03d-capture.jpg", eventpath, atoi(dbrow[0]) );
|
||||||
|
|
||||||
|
fprintf( stdout, "Content-Length: %d\r\n", n_bytes );
|
||||||
|
fprintf( stdout, "Content-Type: image/jpeg\r\n\r\n" );
|
||||||
if ( scale == 100 )
|
if ( scale == 100 )
|
||||||
{
|
{
|
||||||
if ( (fdj = fopen( filepath, "r" )) )
|
if ( (fdj = fopen( filepath, "r" )) )
|
||||||
|
@ -466,9 +469,7 @@ void Event::StreamEvent( int event_id, int rate, int scale )
|
||||||
|
|
||||||
write( fileno(stdout), buffer, n_bytes );
|
write( fileno(stdout), buffer, n_bytes );
|
||||||
}
|
}
|
||||||
fprintf( stdout, "--ZoneMinderFrame\r\n" );
|
fprintf( stdout, "\r\n\r\n--ZoneMinderFrame\r\n" );
|
||||||
fprintf( stdout, "Content-length: %d\r\n", n_bytes );
|
|
||||||
fprintf( stdout, "Content-type: image/jpeg\r\n\r\n" );
|
|
||||||
fflush( stdout );
|
fflush( stdout );
|
||||||
}
|
}
|
||||||
if ( mysql_errno( &dbconn ) )
|
if ( mysql_errno( &dbconn ) )
|
||||||
|
|
|
@ -1078,6 +1078,7 @@ Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose )
|
||||||
void Monitor::StreamImages( unsigned long idle, unsigned long refresh, time_t ttl, int scale )
|
void Monitor::StreamImages( unsigned long idle, unsigned long refresh, time_t ttl, int scale )
|
||||||
{
|
{
|
||||||
fprintf( stdout, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\r\n\r\n" );
|
fprintf( stdout, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\r\n\r\n" );
|
||||||
|
fprintf( stdout, "--ZoneMinderFrame\r\n" );
|
||||||
|
|
||||||
int last_read_index = image_buffer_count;
|
int last_read_index = image_buffer_count;
|
||||||
static JOCTET img_buffer[ZM_MAX_IMAGE_SIZE];
|
static JOCTET img_buffer[ZM_MAX_IMAGE_SIZE];
|
||||||
|
@ -1125,10 +1126,10 @@ void Monitor::StreamImages( unsigned long idle, unsigned long refresh, time_t tt
|
||||||
scaled_image.EncodeJpeg( img_buffer, &img_buffer_size );
|
scaled_image.EncodeJpeg( img_buffer, &img_buffer_size );
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( stdout, "--ZoneMinderFrame\r\n" );
|
fprintf( stdout, "Content-Length: %d\r\n", img_buffer_size );
|
||||||
fprintf( stdout, "Content-length: %d\r\n", img_buffer_size );
|
fprintf( stdout, "Content-Type: image/jpeg\r\n\r\n" );
|
||||||
fprintf( stdout, "Content-type: image/jpeg\r\n\r\n" );
|
|
||||||
fwrite( img_buffer, img_buffer_size, 1, stdout );
|
fwrite( img_buffer, img_buffer_size, 1, stdout );
|
||||||
|
fprintf( stdout, "\r\n\r\n--ZoneMinderFrame\r\n" );
|
||||||
}
|
}
|
||||||
usleep( refresh*1000 );
|
usleep( refresh*1000 );
|
||||||
for ( int i = 0; shared_data->state == IDLE && i < loop_count; i++ )
|
for ( int i = 0; shared_data->state == IDLE && i < loop_count; i++ )
|
||||||
|
|
Loading…
Reference in New Issue