@@ -752,16 +752,15 @@ static void mlp_prepare(ctx_dev *cam)
752752 cam->frame_last_ts .tv_nsec = cam->frame_curr_ts .tv_nsec ;
753753 clock_gettime (CLOCK_MONOTONIC, &cam->frame_curr_ts );
754754
755- if (cam->conf ->pre_capture < 0 ) {
756- cam->conf ->pre_capture = 0 ;
757- }
758-
759755 if (cam->frame_last_ts .tv_sec != cam->frame_curr_ts .tv_sec ) {
760- cam->lastrate = cam->shots + 1 ;
761- cam->shots = -1 ;
756+ cam->lastrate = cam->shots_mt + 1 ;
757+ cam->shots_mt = -1 ;
762758 }
759+ cam->shots_mt ++;
763760
764- cam->shots ++;
761+ if (cam->conf ->pre_capture < 0 ) {
762+ cam->conf ->pre_capture = 0 ;
763+ }
765764
766765 if (cam->startup_frames > 0 ) {
767766 cam->startup_frames --;
@@ -771,7 +770,10 @@ static void mlp_prepare(ctx_dev *cam)
771770/* reset the images */
772771static void mlp_resetimages (ctx_dev *cam)
773772{
773+ int64_t tmpsec;
774+
774775 /* ring_buffer_in is pointing to current pos, update before put in a new image */
776+ tmpsec =cam->current_image ->imgts .tv_sec ;
775777 if (++cam->imgs .ring_in >= cam->imgs .ring_size ) {
776778 cam->imgs .ring_in = 0 ;
777779 }
@@ -793,8 +795,14 @@ static void mlp_resetimages(ctx_dev *cam)
793795 clock_gettime (CLOCK_REALTIME, &cam->current_image ->imgts );
794796 clock_gettime (CLOCK_MONOTONIC, &cam->current_image ->monots );
795797
798+ if (tmpsec != cam->current_image ->imgts .tv_sec ) {
799+ cam->shots_rt = 1 ;
800+ } else {
801+ cam->shots_rt ++;
802+ }
796803 /* Store shot number with pre_captured image */
797- cam->current_image ->shot = cam->shots ;
804+ cam->current_image ->shot = cam->shots_rt ;
805+
798806}
799807
800808/* Try to reconnect to camera */
@@ -804,7 +812,7 @@ static void mlp_retry(ctx_dev *cam)
804812
805813 if ((cam->device_status == STATUS_CLOSED) &&
806814 (cam->frame_curr_ts .tv_sec % 10 == 0 ) &&
807- (cam->shots == 0 )) {
815+ (cam->shots_mt == 0 )) {
808816 MOTPLS_LOG (NTC, TYPE_ALL, NO_ERRNO
809817 ,_ (" Retrying until successful connection with camera" ));
810818
@@ -920,7 +928,7 @@ static void mlp_detection(ctx_dev *cam)
920928/* tune the detection parameters*/
921929static void mlp_tuning (ctx_dev *cam)
922930{
923- if ((cam->conf ->noise_tune && cam->shots == 0 ) &&
931+ if ((cam->conf ->noise_tune && cam->shots_mt == 0 ) &&
924932 (!cam->detecting_motion && (cam->current_image ->diffs <= cam->threshold ))) {
925933 alg_noise_tune (cam);
926934 }
@@ -1233,7 +1241,7 @@ static void mlp_setupmode(ctx_dev *cam)
12331241/* Snapshot interval*/
12341242static void mlp_snapshot (ctx_dev *cam)
12351243{
1236- if ((cam->conf ->snapshot_interval > 0 && cam->shots == 0 &&
1244+ if ((cam->conf ->snapshot_interval > 0 && cam->shots_mt == 0 &&
12371245 cam->frame_curr_ts .tv_sec % cam->conf ->snapshot_interval <=
12381246 cam->frame_last_ts .tv_sec % cam->conf ->snapshot_interval ) ||
12391247 cam->snapshot ) {
@@ -1252,7 +1260,7 @@ static void mlp_timelapse(ctx_dev *cam)
12521260
12531261 if (timestamp_tm.tm_min == 0 &&
12541262 (cam->frame_curr_ts .tv_sec % 60 < cam->frame_last_ts .tv_sec % 60 ) &&
1255- cam->shots == 0 ) {
1263+ cam->shots_mt == 0 ) {
12561264
12571265 if (cam->conf ->timelapse_mode == " daily" ) {
12581266 if (timestamp_tm.tm_hour == 0 ) {
@@ -1275,7 +1283,7 @@ static void mlp_timelapse(ctx_dev *cam)
12751283 }
12761284 }
12771285
1278- if (cam->shots == 0 &&
1286+ if (cam->shots_mt == 0 &&
12791287 cam->frame_curr_ts .tv_sec % cam->conf ->timelapse_interval <=
12801288 cam->frame_last_ts .tv_sec % cam->conf ->timelapse_interval ) {
12811289 event (cam, EVENT_TLAPSE_START);
@@ -1297,7 +1305,7 @@ static void mlp_loopback(ctx_dev *cam)
12971305
12981306 event (cam, EVENT_IMAGE);
12991307
1300- if (!cam->conf ->stream_motion || cam->shots == 0 ) {
1308+ if (!cam->conf ->stream_motion || cam->shots_mt == 0 ) {
13011309 event (cam, EVENT_STREAM);
13021310 }
13031311
@@ -1308,7 +1316,7 @@ static void mlp_loopback(ctx_dev *cam)
13081316static void mlp_parmsupdate (ctx_dev *cam)
13091317{
13101318 /* Check for some config parameter changes but only every second */
1311- if (cam->shots != 0 ) {
1319+ if (cam->shots_mt != 0 ) {
13121320 return ;
13131321 }
13141322
0 commit comments