Add new configuration field to skip frame when start preview or capture 84/170084/3 accepted/tizen/unified/20180222.080152 submit/tizen/20180221.065315
authorJeongmo Yang <jm80.yang@samsung.com>
Tue, 13 Feb 2018 08:08:49 +0000 (17:08 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Wed, 21 Feb 2018 06:30:33 +0000 (06:30 +0000)
- In some target, unstable video frame could be captured

[Version] 0.10.152
[Profile] Common
[Issue Type] Update
[Dependency module] N/A

Change-Id: Idafacf13d3396f2af26a1df79613e9a910eb6b86
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/libmm-camcorder.spec
src/include/mm_camcorder_gstcommon.h
src/include/mm_camcorder_internal.h
src/include/mm_camcorder_platform.h
src/mm_camcorder_configure.c
src/mm_camcorder_gstcommon.c
src/mm_camcorder_internal.c
src/mm_camcorder_stillshot.c

index f261a46..5a2ce85 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    0.10.151
+Version:    0.10.152
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 42c46c1..01250aa 100644 (file)
@@ -162,7 +162,7 @@ bool _mmcamcorder_recreate_decoder_for_encoded_preview(MMHandleType handle);
 
 /* etc */
 int _mmcamcorder_videosink_window_set(MMHandleType handle, type_element *VideosinkElement);
-int _mmcamcorder_vframe_stablize(MMHandleType handle);
+int _mmcamcorder_video_frame_stabilize(MMHandleType handle, int cmd);
 gboolean _mmcamcorder_get_device_info(MMHandleType handle);
 int _mmcamcorder_get_eos_message(MMHandleType handle);
 void _mmcamcorder_remove_element_handle(MMHandleType handle, void *element, int first_elem, int last_elem);
index 21bb5a1..9c15b4a 100644 (file)
@@ -681,7 +681,7 @@ typedef struct {
        bool isMaxtimePausing;                  /**< Because of time limit, pipeline is paused. */
        int element_num;                        /**< count of element */
        int encode_element_num;                 /**< count of encode element */
-       int cam_stability_count;                /**< camsensor stability count. the count of frame will drop */
+       int frame_stability_count;              /**< camsensor stability count. the count of frame will drop */
        GstClockTime pipeline_time;             /**< current time of Gstreamer Pipeline */
        GstClockTime pause_time;                /**< amount of time while pipeline is in PAUSE state.*/
        GstClockTime stillshot_time;            /**< pipeline time of capturing moment*/
index f375ca9..f1f2954 100644 (file)
@@ -135,7 +135,6 @@ extern "C" {
 #define MMF_CROP_CIF_BOTTOM                    0
 
 /* Camera etc */
-#define _MMCAMCORDER_CAMSTABLE_COUNT           0               /* stablize count of camsensor */
 #define _MMCAMCORDER_MINIMUM_SPACE             (512*1024)      /* byte */
 #define _MMCAMCORDER_MMS_MARGIN_SPACE          (512)           /* byte */
 
index 1c4ac74..667d3ca 100644 (file)
@@ -776,11 +776,12 @@ int _mmcamcorder_conf_init(MMHandleType handle, int type, camera_conf *configure
                { "FPS9",                 CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
                { "PictureFormat",        CONFIGURE_VALUE_INT_ARRAY,      {NULL} },
                { "Overlay",              CONFIGURE_VALUE_INT_RANGE,      {NULL} },
-               { "RecommendDisplayRotation", CONFIGURE_VALUE_INT,     {.value_int = 3}    },
+               { "RecommendDisplayRotation", CONFIGURE_VALUE_INT,     {.value_int = 3} },
                { "RecommendPreviewFormatCapture", CONFIGURE_VALUE_INT, {.value_int = MM_PIXEL_FORMAT_YUYV} },
                { "RecommendPreviewFormatRecord",  CONFIGURE_VALUE_INT, {.value_int = MM_PIXEL_FORMAT_NV12} },
                { "RecommendPreviewResolution", CONFIGURE_VALUE_INT_PAIR_ARRAY, {NULL} },
                { "FacingDirection",      CONFIGURE_VALUE_INT, {.value_int = MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR} },
+               { "FrameStabilityCount",  CONFIGURE_VALUE_INT,     {.value_int = 0} },
        };
 
        /* [Strobe] matching table */
@@ -838,6 +839,7 @@ int _mmcamcorder_conf_init(MMHandleType handle, int type, camera_conf *configure
                { "SensorEncodedCapture", CONFIGURE_VALUE_INT,       {.value_int = 1} },
                { "SupportHDR",           CONFIGURE_VALUE_INT_ARRAY, {NULL} },
                { "SupportZSL",           CONFIGURE_VALUE_INT,       {.value_int = FALSE} },
+               { "FrameStabilityCount",  CONFIGURE_VALUE_INT,       {.value_int = 0} },
        };
 
        /* [Detect] matching table */
index 58593e9..af976e0 100644 (file)
@@ -1481,21 +1481,35 @@ int _mmcamcorder_videosink_window_set(MMHandleType handle, type_element* Videosi
 }
 
 
-int _mmcamcorder_vframe_stablize(MMHandleType handle)
+int _mmcamcorder_video_frame_stabilize(MMHandleType handle, int cmd)
 {
+       int category = 0;
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
        _MMCamcorderSubContext *sc = NULL;
 
-       _mmcam_dbg_log("%d", _MMCAMCORDER_CAMSTABLE_COUNT);
-
        mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
 
        sc = MMF_CAMCORDER_SUBCONTEXT(handle);
 
        mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
 
-       if (sc->cam_stability_count != _MMCAMCORDER_CAMSTABLE_COUNT)
-               sc->cam_stability_count = _MMCAMCORDER_CAMSTABLE_COUNT;
+       switch (cmd) {
+       case _MMCamcorder_CMD_PREVIEW_START:
+               category = CONFIGURE_CATEGORY_CTRL_CAMERA;
+               break;
+       case _MMCamcorder_CMD_CAPTURE:
+               category = CONFIGURE_CATEGORY_CTRL_CAPTURE;
+               break;
+       default:
+               _mmcam_dbg_warn("unknown command : %d", cmd);
+               return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
+       }
+
+       _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_ctrl,
+               category, "FrameStabilityCount", &sc->frame_stability_count);
+
+       _mmcam_dbg_log("[cmd %d] frame stability count : %d",
+               cmd, sc->frame_stability_count);
 
        return MM_ERROR_NONE;
 }
@@ -1587,9 +1601,9 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_preview(GstPad *pad, GstP
                        _mmcam_dbg_log("Drop video frame by drop_vframe");
                        return GST_PAD_PROBE_DROP;
                }
-       } else if (sc->cam_stability_count > 0) {
-               sc->cam_stability_count--;
-               _mmcam_dbg_log("Drop video frame by cam_stability_count");
+       } else if (sc->frame_stability_count > 0) {
+               sc->frame_stability_count--;
+               _mmcam_dbg_log("Drop video frame by frame_stability_count");
                return GST_PAD_PROBE_DROP;
        }
 
index d5ad355..7a5169d 100644 (file)
@@ -2621,7 +2621,7 @@ _MMCamcorderSubContext *_mmcamcorder_alloc_subcontext(int type)
        }
 
        sc->fourcc = 0x80000000;
-       sc->cam_stability_count = 0;
+       sc->frame_stability_count = 0;
        sc->drop_vframe = 0;
        sc->pass_first_vframe = 0;
        sc->is_modified_rate = FALSE;
index 9214742..4879af4 100644 (file)
@@ -530,6 +530,9 @@ int _mmcamcorder_image_cmd_capture(MMHandleType handle)
 
                        info->resolution_change = TRUE;
 
+                       /* set frame stability count for capture */
+                       _mmcamcorder_video_frame_stabilize(handle, _MMCamcorder_CMD_CAPTURE);
+
                        /* make pipeline state as PLAYING */
                        ret = _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
                        if (ret != MM_ERROR_NONE) {
@@ -652,8 +655,6 @@ int _mmcamcorder_image_cmd_preview_start(MMHandleType handle)
        info->multi_shot_stop = TRUE;
        info->capturing = FALSE;
 
-       _mmcamcorder_vframe_stablize(handle);
-
        current_state = _mmcamcorder_get_state(handle);
        _mmcam_dbg_log("current state [%d]", current_state);
 
@@ -783,6 +784,9 @@ int _mmcamcorder_image_cmd_preview_start(MMHandleType handle)
                                        goto cmd_error;
                                }
 
+                               /* set frame stability count for preview */
+                               _mmcamcorder_video_frame_stabilize(handle, _MMCamcorder_CMD_PREVIEW_START);
+
                                ret = _mmcamcorder_gst_set_state(handle, pipeline, GST_STATE_PLAYING);
                                if (ret != MM_ERROR_NONE)
                                        goto cmd_error;
@@ -801,6 +805,9 @@ int _mmcamcorder_image_cmd_preview_start(MMHandleType handle)
                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
 
+               /* set frame stability count for preview */
+               _mmcamcorder_video_frame_stabilize(handle, _MMCamcorder_CMD_PREVIEW_START);
+
                traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:START:SET_PLAYING_TO_PIPELINE");
 
                ret = _mmcamcorder_gst_set_state(handle, pipeline, GST_STATE_PLAYING);