Bug fix - The extra preview callback is not invoked 73/283673/1 accepted/tizen/unified/20221107.173036
authorJeongmo Yang <jm80.yang@samsung.com>
Tue, 1 Nov 2022 08:18:38 +0000 (17:18 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Tue, 1 Nov 2022 08:18:38 +0000 (17:18 +0900)
- The extra preview callback is not invoked
  if it's enabled after start preview.

[Version] 0.10.279
[Issue Type] Bug fix

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

index 793d31d..b70f6ca 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    0.10.278
+Version:    0.10.279
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 5fd7973..3ee6c54 100644 (file)
@@ -703,7 +703,6 @@ typedef struct {
  */
 typedef struct {
        gboolean is_supported;
-       gboolean is_enabled;
        MMCamcorderExtraPreviewMode mode;
        int camera_id[MM_CAMCORDER_EXTRA_PREVIEW_STREAM_NUM];
        _MMCamcorderExtraPreviewFormat format[MM_CAMCORDER_EXTRA_PREVIEW_STREAM_NUM];
index 50c71aa..62bd86f 100644 (file)
@@ -95,6 +95,7 @@ int _mmcamcorder_video_capture_command(MMHandleType handle, int command);
 void _mmcamcorder_destroy_video_capture_pipeline(MMHandleType handle);
 
 int _mmcamcorder_initialize_extra_preview_mode(MMHandleType handle);
+int _mmcamcorder_deinitialize_extra_preview_mode(MMHandleType handle);
 int _mmcamcorder_set_extra_preview_device_type(MMHandleType handle, int stream_id, int device_type);
 int _mmcamcorder_set_extra_preview_stream_format(MMHandleType handle, int stream_id, int pixel_format, int width, int height, int fps);
 int _mmcamcorder_get_extra_preview_stream_format(MMHandleType handle, int stream_id, int *pixel_format, int *width, int *height, int *fps);
index a6e2ef6..2f2cf4d 100644 (file)
@@ -4818,6 +4818,7 @@ bool _mmcamcorder_commit_audio_replay_gain(MMHandleType handle, int attr_idx, co
 
 bool _mmcamcorder_commit_extra_preview(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
 {
+       int ret = MM_ERROR_NONE;
        int current_state = MM_CAMCORDER_STATE_NONE;
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
        _MMCamcorderSubContext *sc = NULL;
@@ -4831,8 +4832,6 @@ bool _mmcamcorder_commit_extra_preview(MMHandleType handle, int attr_idx, const
 
        MMCAM_LOG_INFO("Enable extra preview(%d)", value->value.i_val);
 
-       hcamcorder->extra_preview.is_enabled = (gboolean)value->value.i_val;
-
        current_state = _mmcamcorder_get_state(handle);
        if (current_state < MM_CAMCORDER_STATE_READY) {
                MMCAM_LOG_INFO("will be set when preview is started");
@@ -4842,7 +4841,15 @@ bool _mmcamcorder_commit_extra_preview(MMHandleType handle, int attr_idx, const
        sc = MMF_CAMCORDER_SUBCONTEXT(handle);
        mmf_return_val_if_fail(sc, FALSE);
 
-       MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "extra-preview", value->value.i_val);
+       if (value->value.i_val)
+               ret = _mmcamcorder_initialize_extra_preview_mode(handle);
+       else
+               ret = _mmcamcorder_deinitialize_extra_preview_mode(handle);
+
+       if (ret != MM_ERROR_NONE) {
+               MMCAM_LOG_ERROR("set[%d] failed[0x%x]", value->value.i_val, ret);
+               return FALSE;
+       }
 
        MMCAM_LOG_INFO("done");
 
index 4b434d9..eac943f 100644 (file)
@@ -656,7 +656,6 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", capture_height);
        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-quality", capture_quality);
        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", sc->info_image->hdr_capture_mode);
-       MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "extra-preview", extra_preview_enable);
        MMCAMCORDER_G_OBJECT_GET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "buffer-quark", &hcamcorder->buffer_quark);
 
        /* set camera flip */
@@ -685,6 +684,10 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
 #endif
        }
 
+       /* extra preview */
+       if (extra_preview_enable)
+               _mmcamcorder_initialize_extra_preview_mode(handle);
+
        /* set user buffer fd to videosrc element */
        if (hcamcorder->support_user_buffer) {
                control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
@@ -1771,13 +1774,6 @@ int _mmcamcorder_create_preview_pipeline(MMHandleType handle)
                goto pipeline_creation_error;
        }
 
-       /* extra preview mode */
-       err = _mmcamcorder_initialize_extra_preview_mode(handle);
-       if (err != MM_ERROR_NONE) {
-               MMCAM_LOG_ERROR("initialize extra preview mode[%d] failed", hcamcorder->extra_preview.mode);
-               goto pipeline_creation_error;
-       }
-
        return MM_ERROR_NONE;
 
 pipeline_creation_error:
index 4eb331f..73fafe5 100644 (file)
@@ -69,7 +69,9 @@ static int __mmcamcorder_capture_mode_init_image_pad(MMHandleType handle);
 static int __mmcamcorder_capture_mode_deinit_encodebin(MMHandleType handle);
 
 static int __mmcamcorder_extra_preview_mode_init_camera_control(mmf_camcorder_t *hcamcorder);
+static int __mmcamcorder_extra_preview_mode_deinit_camera_control(mmf_camcorder_t *hcamcorder);
 static int __mmcamcorder_extra_preview_mode_init_pipeline(MMHandleType handle, MMCamcorderExtraPreviewMode mode);
+static int __mmcamcorder_extra_preview_mode_deinit_pipeline(MMHandleType handle, MMCamcorderExtraPreviewMode mode);
 
 static int __mmcamcorder_set_exif_basic_info(MMHandleType handle, int image_width, int image_height);
 static int __mmcamcorder_update_exif_info(MMHandleType handle, void *imagedata, int imgln);
@@ -306,19 +308,14 @@ static int __mmcamcorder_extra_preview_mode_init_camera_control(mmf_camcorder_t
 
        mmf_return_val_if_fail(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
 
-       MMCAM_LOG_INFO("connect extra preview stream signal to _MMCAMCORDER_VIDEOSRC_SRC");
-
-       MMCAMCORDER_SIGNAL_CONNECT(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst,
-               _MMCAMCORDER_HANDLER_EXTRA_PREVIEW, "extra-preview-stream-cb",
-               G_CALLBACK(__mmcamcorder_extra_preview_stream_cb),
-               hcamcorder);
-
        control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
        if (!control) {
                MMCAM_LOG_ERROR("no camera control");
                return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
        }
 
+       MMCAM_LOG_INFO("connect extra preview stream signal and enable extra preview");
+
        for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_NUM ; i++) {
                e_fmt = &hcamcorder->extra_preview.format[i];
 
@@ -347,6 +344,45 @@ static int __mmcamcorder_extra_preview_mode_init_camera_control(mmf_camcorder_t
                }
        }
 
+       MMCAMCORDER_SIGNAL_CONNECT(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst,
+               _MMCAMCORDER_HANDLER_EXTRA_PREVIEW, "extra-preview-stream-cb",
+               G_CALLBACK(__mmcamcorder_extra_preview_stream_cb),
+               hcamcorder);
+
+       MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "extra-preview", TRUE);
+
+       MMCAM_LOG_INFO("done");
+
+       return MM_ERROR_NONE;
+}
+
+
+static int __mmcamcorder_extra_preview_mode_deinit_camera_control(mmf_camcorder_t *hcamcorder)
+{
+       _MMCamcorderSubContext *sc = NULL;
+       GstCameraControl *control = NULL;
+
+       mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+
+       sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
+       mmf_return_val_if_fail(sc && sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+
+       mmf_return_val_if_fail(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+
+       control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+       if (!control) {
+               MMCAM_LOG_ERROR("no camera control");
+               return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
+       }
+
+       MMCAM_LOG_INFO("disable extra preview and disconnect extra preview stream signal");
+
+       MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "extra-preview", FALSE);
+
+       _mmcamcorder_disconnect_signal((MMHandleType)hcamcorder, _MMCAMCORDER_HANDLER_EXTRA_PREVIEW);
+
+       MMCAM_LOG_INFO("done");
+
        return MM_ERROR_NONE;
 }
 
@@ -463,13 +499,19 @@ pipeline_creation_error:
 }
 
 
+static int __mmcamcorder_extra_preview_mode_deinit_pipeline(MMHandleType handle, MMCamcorderExtraPreviewMode mode)
+{
+       /* TODO */
+       return MM_ERROR_NONE;
+}
+
+
 int _mmcamcorder_initialize_extra_preview_mode(MMHandleType handle)
 {
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
 
        mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
-       mmf_return_val_if_fail(hcamcorder->extra_preview.is_supported, MM_ERROR_NONE);
-       mmf_return_val_if_fail(hcamcorder->extra_preview.is_enabled, MM_ERROR_NONE);
+       mmf_return_val_if_fail(hcamcorder->extra_preview.is_supported, MM_ERROR_CAMCORDER_NOT_SUPPORTED);
 
        switch (hcamcorder->extra_preview.mode) {
        case MM_CAMCORDER_EXTRA_PREVIEW_MODE_CAMERA_CONTROL:
@@ -484,6 +526,26 @@ int _mmcamcorder_initialize_extra_preview_mode(MMHandleType handle)
 }
 
 
+int _mmcamcorder_deinitialize_extra_preview_mode(MMHandleType handle)
+{
+       mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+
+       mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+       mmf_return_val_if_fail(hcamcorder->extra_preview.is_supported, MM_ERROR_CAMCORDER_NOT_SUPPORTED);
+
+       switch (hcamcorder->extra_preview.mode) {
+       case MM_CAMCORDER_EXTRA_PREVIEW_MODE_CAMERA_CONTROL:
+               return __mmcamcorder_extra_preview_mode_deinit_camera_control(handle);
+       case MM_CAMCORDER_EXTRA_PREVIEW_MODE_PIPELINE_SRCPAD:
+       case MM_CAMCORDER_EXTRA_PREVIEW_MODE_PIPELINE_ELEMENT:
+               return __mmcamcorder_extra_preview_mode_deinit_pipeline(handle, hcamcorder->extra_preview.mode);
+       default:
+               MMCAM_LOG_ERROR("unknown extra preview mode[%d]", hcamcorder->extra_preview.mode);
+               return MM_ERROR_CAMCORDER_INTERNAL;
+       }
+}
+
+
 static int __mmcamcorder_capture_mode_deinit_encodebin(MMHandleType handle)
 {
        int ret = MM_ERROR_NONE;