From 5b6fc78f0793dfcb81c24680a29f2cbcb892fa90 Mon Sep 17 00:00:00 2001 From: stan Date: Sun, 19 Oct 2003 13:54:40 +0000 Subject: [PATCH] Changed the streaming headers. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@663 e3e1d417-86f3-4887-817a-d78f3d33393f --- src/zm_event.cpp | 14 +++++++++++--- src/zm_monitor.cpp | 20 ++++++++++++++------ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 093c80409..7cd76297f 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -284,10 +284,18 @@ void Event::StreamEvent( const char *path, int event_id, int rate, int scale, FI setbuf( fd, 0 ); + time_t cache_now = time( 0 ); + char date_string[64]; + strftime( date_string, sizeof(date_string)-1, "%a, %d %b %Y %H:%M:%S GMT", gmtime( &cache_now ) ); + fprintf( fd, "Server: ZoneMinder Stream Server\r\n" ); - fprintf( fd, "Pragma: no-cache\r\n" ); - fprintf( fd, "Cache-Control: no-cache\r\n" ); - fprintf( fd, "Expires: Thu, 01 Dec 1994 16:00:00 GMT\r\n" ); + + fprintf( fd, "Expires: Mon, 26 Jul 1997 05:00:00 GMT\r\n" ); + fprintf( fd, "Last-Modified: %s\r\n", date_string ); + fprintf( fd, "Cache-Control: no-store, no-cache, must-revalidate\r\n" ); + fprintf( fd, "Cache-Control: post-check=0, pre-check=0\r\n" ); + fprintf( fd, "Pragma: no-cache\r\n"); + fprintf( fd, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\r\n\r\n" ); fprintf( fd, "--ZoneMinderFrame\n" ); diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 15fa58dba..7eeb935ee 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -1002,18 +1002,26 @@ void Monitor::StreamImages( unsigned long idle, unsigned long refresh, time_t tt setbuf( fd, 0 ); fprintf( fd, "Server: ZoneMinder Stream Server\r\n" ); - fprintf( fd, "Pragma: no-cache\r\n" ); - fprintf( fd, "Cache-Control: no-cache\r\n" ); - fprintf( fd, "Expires: Thu, 01 Dec 1994 16:00:00 GMT\r\n" ); + + time_t now = time( 0 ); + char date_string[64]; + strftime( date_string, sizeof(date_string)-1, "%a, %d %b %Y %H:%M:%S GMT", gmtime( &now ) ); + + fprintf( fd, "Expires: Mon, 26 Jul 1997 05:00:00 GMT\r\n" ); + fprintf( fd, "Last-Modified: %s\r\n", date_string ); + fprintf( fd, "Cache-Control: no-store, no-cache, must-revalidate\r\n" ); + fprintf( fd, "Cache-Control: post-check=0, pre-check=0\r\n" ); + fprintf( fd, "Pragma: no-cache\r\n"); + fprintf( fd, "Content-Type: multipart/x-mixed-replace;boundary=ZoneMinderFrame\r\n\r\n" ); fprintf( fd, "--ZoneMinderFrame\n" ); + int last_read_index = image_buffer_count; - //JOCTET img_buffer[camera->ImageSize()]; - JOCTET img_buffer[ZM_MAX_IMAGE_SIZE]; + static JOCTET img_buffer[ZM_MAX_IMAGE_SIZE]; int img_buffer_size = 0; int loop_count = (idle/refresh)-1; - time_t start_time, now; + time_t start_time; time( &start_time ); while ( true )