Revamped the streaming line endings slightly.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@446 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
6265c24162
commit
64907c388c
|
@ -127,9 +127,10 @@ void Event::StreamEvent( const char *path, int event_id, unsigned long refresh,
|
|||
exit( mysql_errno( &dbconn ) );
|
||||
}
|
||||
|
||||
fprintf( fd, "Server: ZoneMinder Stream Server\n" );
|
||||
fprintf( fd, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\n\n" );
|
||||
fprintf( fd, "--ZoneMinderFrame\n" );
|
||||
setbuf( fd, 0 );
|
||||
fprintf( fd, "Server: ZoneMinder Stream Server\r\n" );
|
||||
fprintf( fd, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\r\n\r\n" );
|
||||
fprintf( fd, "--ZoneMinderFrame\r\n" );
|
||||
|
||||
int n_frames = mysql_num_rows( result );
|
||||
Info(( "Got %d frames\n", n_frames ));
|
||||
|
@ -142,13 +143,12 @@ void Event::StreamEvent( const char *path, int event_id, unsigned long refresh,
|
|||
sprintf( filepath, "%s/%s", path, dbrow[2] );
|
||||
if ( fdj = fopen( filepath, "r" ) )
|
||||
{
|
||||
fprintf( fd, "Content-type: image/jpg\n\n" );
|
||||
fprintf( fd, "Content-type: image/jpg\r\n\r\n" );
|
||||
while ( n_bytes = fread( buffer, 1, sizeof(buffer), fdj ) )
|
||||
{
|
||||
fwrite( buffer, 1, n_bytes, fd );
|
||||
}
|
||||
fprintf( fd, "\n--ZoneMinderFrame\n" );
|
||||
fflush( fd );
|
||||
fprintf( fd, "\r\n--ZoneMinderFrame\r\n" );
|
||||
fclose( fdj );
|
||||
}
|
||||
else
|
||||
|
|
|
@ -669,9 +669,10 @@ void Monitor::StreamImages( unsigned long idle, unsigned long refresh, FILE *fd,
|
|||
{
|
||||
time_t start_time, now;
|
||||
|
||||
fprintf( fd, "Server: ZoneMinder Stream Server\n" );
|
||||
fprintf( fd, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\n\n" );
|
||||
fprintf( fd, "--ZoneMinderFrame\n" );
|
||||
setbuf( fd, 0 );
|
||||
fprintf( fd, "Server: ZoneMinder Stream Server\r\n" );
|
||||
fprintf( fd, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\r\n\r\n" );
|
||||
fprintf( fd, "--ZoneMinderFrame\r\n" );
|
||||
int last_read_index = image_buffer_count;
|
||||
JOCTET img_buffer[camera->ImageSize()];
|
||||
int img_buffer_size = 0;
|
||||
|
@ -679,6 +680,10 @@ void Monitor::StreamImages( unsigned long idle, unsigned long refresh, FILE *fd,
|
|||
time( &start_time );
|
||||
while ( true )
|
||||
{
|
||||
if ( feof( fd ) || ferror( fd ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
if ( last_read_index != shared_images->last_write_index )
|
||||
{
|
||||
// Send the next frame
|
||||
|
@ -689,10 +694,9 @@ void Monitor::StreamImages( unsigned long idle, unsigned long refresh, FILE *fd,
|
|||
Image *image = snap->image;
|
||||
image->EncodeJpeg( img_buffer, &img_buffer_size );
|
||||
|
||||
fprintf( fd, "Content-type: image/jpg\n\n" );
|
||||
fprintf( fd, "Content-type: image/jpg\r\n\r\n" );
|
||||
fwrite( img_buffer, 1, img_buffer_size, fd );
|
||||
fprintf( fd, "\n--ZoneMinderFrame\n" );
|
||||
fflush( fd );
|
||||
fprintf( fd, "\r\n--ZoneMinderFrame\r\n" );
|
||||
}
|
||||
usleep( refresh*1000 );
|
||||
for ( int i = 0; shared_images->state == IDLE && i < loop_count; i++ )
|
||||
|
|
Loading…
Reference in New Issue