From 43e1ac2ad463f4bbb3c9c91aa101f1897c583f67 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 2 Sep 2020 16:35:27 -0400 Subject: [PATCH] Send Text frame when unable to connect to the monitor. --- src/zm_monitorstream.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/zm_monitorstream.cpp b/src/zm_monitorstream.cpp index 4f7cdb7aa..be2fe99c9 100644 --- a/src/zm_monitorstream.cpp +++ b/src/zm_monitorstream.cpp @@ -388,7 +388,6 @@ bool MonitorStream::sendFrame(Image *image, struct timeval *timestamp) { struct timeval frameStartTime; gettimeofday(&frameStartTime, nullptr); - fputs("--ZoneMinderFrame\r\n", stdout); switch ( type ) { case STREAM_JPEG : send_image->EncodeJpeg(img_buffer, &img_buffer_size); @@ -452,16 +451,21 @@ void MonitorStream::runStream() { openComms(); + if ( type == STREAM_JPEG ) + fputs("Content-Type: multipart/x-mixed-replace; boundary=" BOUNDARY "\r\n\r\n", stdout); + if ( !checkInitialised() ) { Error("Not initialized"); - return; + while ( !(loadMonitor(monitor_id) || zm_terminate) ) { + sendTextFrame("Not connected"); + if ( connkey ) + checkCommandQueue(); + sleep(1); + } } updateFrameRate(monitor->GetFPS()); - if ( type == STREAM_JPEG ) - fputs("Content-Type: multipart/x-mixed-replace; boundary=" BOUNDARY "\r\n\r\n", stdout); - // point to end which is theoretically not a valid value because all indexes are % image_buffer_count unsigned int last_read_index = monitor->image_buffer_count;