From 98c865902e4100300608fc7ed24dc72fc530540b Mon Sep 17 00:00:00 2001 From: Jeongmo Yang Date: Thu, 3 Aug 2023 11:35:28 +0900 Subject: [PATCH] Improve continuous capture logic - Previously, in capture mode ENCODEBIN or IMAGE_PAD, 1. The continuous capture is not supported. 2. The capture interval is ignored. - This patch adds the logic for continuous capture and capture interval. [Version] 0.10.295 [Issue Type] Improvement Change-Id: I2dbef7808c53992e05bc77fbcbbc0fb442a1a5fe Signed-off-by: Jeongmo Yang --- packaging/libmm-camcorder.spec | 2 +- src/include/mm_camcorder_stillshot.h | 2 +- src/mm_camcorder_stillshot.c | 14 +++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packaging/libmm-camcorder.spec b/packaging/libmm-camcorder.spec index f0deab5..c2e9124 100755 --- a/packaging/libmm-camcorder.spec +++ b/packaging/libmm-camcorder.spec @@ -1,6 +1,6 @@ Name: libmm-camcorder Summary: Camera and recorder library -Version: 0.10.294 +Version: 0.10.295 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/include/mm_camcorder_stillshot.h b/src/include/mm_camcorder_stillshot.h index 62bd86f..7a1d25d 100644 --- a/src/include/mm_camcorder_stillshot.h +++ b/src/include/mm_camcorder_stillshot.h @@ -61,7 +61,7 @@ typedef struct { int count; /**< Multi-shot capture count */ int capture_cur_count; /**< Multi-shot capture current count */ int capture_send_count; /**< Multi-shot capture send count */ - unsigned long long next_shot_time; /**< next still capture time */ + GstClockTime next_shot_time; /**< next still capture time */ gboolean multi_shot_stop; /**< Multi-shot stop flag */ gboolean capturing; /**< whether MSL is on capturing */ gboolean resolution_change; /**< whether on resolution changing for capturing. After changing to capture resolution, it sets to FALSE again. */ diff --git a/src/mm_camcorder_stillshot.c b/src/mm_camcorder_stillshot.c index 37a3c36..0335310 100644 --- a/src/mm_camcorder_stillshot.c +++ b/src/mm_camcorder_stillshot.c @@ -1998,6 +1998,7 @@ _CAPTURE_CB_EXIF_DONE: /* Set capture count */ count = ++(info->capture_send_count); + info->next_shot_time = GST_BUFFER_PTS(gst_sample_get_buffer(sample1)) + (GST_MSECOND * info->interval); send_captured_message = TRUE; err_release_exif: @@ -2155,18 +2156,29 @@ static gboolean __mmcamcorder_handoff_callback_capture(GstElement *fakesink, Gst { mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(u_data); _MMCamcorderSubContext *sc = NULL; + _MMCamcorderImageInfo *info = NULL; mmf_return_val_if_fail(hcamcorder, FALSE); + mmf_return_val_if_fail(buffer, FALSE); sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder); mmf_return_val_if_fail(sc && sc->element, FALSE); MMCAM_LOG_INFO(""); + info = sc->info_image; + + if (info->capture_send_count > 0 && info->next_shot_time > GST_BUFFER_PTS(buffer)) { + MMCAM_LOG_INFO("next capture time[%"GST_TIME_FORMAT"], but buffer[%"GST_TIME_FORMAT"]", + GST_TIME_ARGS(info->next_shot_time), GST_TIME_ARGS(GST_BUFFER_PTS(buffer))); + return TRUE; + } + /* FIXME. How could you get a thumbnail? */ __mmcamcorder_image_capture_cb(fakesink, gst_sample_new(buffer, gst_pad_get_current_caps(pad), NULL, NULL), NULL, NULL, u_data); - if (sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst) { + if ((info->capture_send_count == info->count || info->capturing == FALSE) && + sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst) { MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst, "signal-handoffs", FALSE); MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "block", TRUE); sc->info_video->push_encoding_buffer = PUSH_ENCODING_BUFFER_STOP; -- 2.7.4