From e7ca892efd502d2433049b3488838f94bc305972 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 19 May 2017 15:07:41 -0400 Subject: [PATCH] merge more differences from SA --- src/zm_event.cpp | 17 +++++++++++++++-- src/zm_monitor.cpp | 13 ++++++++----- src/zm_monitor.h | 1 + 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index c5fe3963c..10779b9ad 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -1094,7 +1094,20 @@ bool EventStream::sendFrame( int delta_us ) { static struct stat filestat; FILE *fdj = NULL; - snprintf( filepath, sizeof(filepath), Event::capture_file_format, event_data->path, curr_frame_id ); + // This needs to be abstracted. If we are saving jpgs, then load the capture file. If we are only saving analysis frames, then send that. + if ( monitor->GetOptSaveJPEGs() & 1 ) { + snprintf( filepath, sizeof(filepath), Event::capture_file_format, event_data->path, curr_frame_id ); + } else if ( monitor->GetOptSaveJPEGs() & 2 ) { + snprintf( filepath, sizeof(filepath), Event::analyse_file_format, event_data->path, curr_frame_id ); + if ( stat( filepath, &filestat ) < 0 ) { + Debug(1, "%s not found, dalling back to capture"); + snprintf( filepath, sizeof(filepath), Event::capture_file_format, event_data->path, curr_frame_id ); + } + + } else { + Fatal("JPEGS not saved.zms is not capable of streaming jpegs from mp4 yet"); + return false; + } #if HAVE_LIBAVCODEC if ( type == STREAM_MPEG ) { @@ -1321,7 +1334,7 @@ void EventStream::runStream() { } else { usleep( (unsigned long)((1000000 * ZM_RATE_BASE)/((base_fps?base_fps:1)*abs(replay_rate*2))) ); } - } + } // end while ! zm_terminate #if HAVE_LIBAVCODEC if ( type == STREAM_MPEG ) delete vid_stream; diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 5d6798e9f..7bccd021e 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -444,6 +444,9 @@ Monitor::Monitor( Debug( 1, "Monitor %s LBF = '%s', LBX = %d, LBY = %d, LBS = %d", name, label_format, label_coord.X(), label_coord.Y(), label_size ); Debug( 1, "Monitor %s IBC = %d, WUC = %d, pEC = %d, PEC = %d, EAF = %d, FRI = %d, RBP = %d, ARBP = %d, FM = %d", name, image_buffer_count, warmup_count, pre_event_count, post_event_count, alarm_frame_count, fps_report_interval, ref_blend_perc, alarm_ref_blend_perc, track_motion ); + //Set video recording flag for event start constructor and easy reference in code + videoRecording = ((GetOptVideoWriter() == H264PASSTHROUGH) && camera->SupportsNativeVideo()); + if ( purpose == ANALYSIS ) { static char path[PATH_MAX]; @@ -1235,9 +1238,6 @@ bool Monitor::Analyse() { if ( Enabled() ) { bool signal = shared_data->signal; bool signal_change = (signal != last_signal); - //Set video recording flag for event start constructor and easy reference in code - // TODO: Use enum instead of the # 2. Makes for easier reading - bool videoRecording = ((GetOptVideoWriter() == 2) && camera->SupportsNativeVideo()); if ( trigger_data->trigger_state != TRIGGER_OFF ) { unsigned int score = 0; @@ -1592,7 +1592,8 @@ bool Monitor::Analyse() { } shared_data->state = state = IDLE; last_section_mod = 0; - } + } // end if ( trigger_data->trigger_state != TRIGGER_OFF ) + if ( (!signal_change && signal) && (function == MODECT || function == MOCORD) ) { if ( state == ALARM ) { ref_image.Blend( *snap_image, alarm_ref_blend_perc ); @@ -2792,7 +2793,9 @@ int Monitor::Capture() { //Check if FFMPEG camera if ( ( videowriter == H264PASSTHROUGH ) && camera->SupportsNativeVideo() ) { - captureResult = camera->CaptureAndRecord(*(next_buffer.image), video_store_data->recording, video_store_data->event_file); + captureResult = camera->CaptureAndRecord(*(next_buffer.image), + video_store_data->recording, + video_store_data->event_file ); } else { captureResult = camera->Capture(*(next_buffer.image)); } diff --git a/src/zm_monitor.h b/src/zm_monitor.h index bb58ae374..6a1bded9e 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -227,6 +227,7 @@ protected: unsigned int v4l_captures_per_frame; Orientation orientation; // Whether the image has to be rotated at all unsigned int deinterlacing; + bool videoRecording; int savejpegspref; VideoWriter videowriter;