[Release version 0.10.27] Remove unused code and dependency
[platform/core/multimedia/libmm-camcorder.git] / src / mm_camcorder_stillshot.c
index 129d90b..da9edc3 100644 (file)
@@ -223,12 +223,20 @@ void _mmcamcorder_destroy_video_capture_pipeline(MMHandleType handle)
                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
 
+               traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:UNREALIZE:SET_NULL_TO_PIPELINE");
+
                _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_NULL);
 
+               traceEnd(TTRACE_TAG_CAMERA);
+
                _mmcamcorder_remove_all_handlers(handle, _MMCAMCORDER_HANDLER_CATEGORY_ALL);
 
+               traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:UNREALIZE:UNREF_PIPELINE");
+
                gst_object_unref(sc->element[_MMCAMCORDER_MAIN_PIPE].gst);
 
+               traceEnd(TTRACE_TAG_CAMERA);
+
                /* NULL initialization will be done in _mmcamcorder_element_release_noti */
        }
 
@@ -327,11 +335,7 @@ int _mmcamcorder_image_cmd_capture(MMHandleType handle)
                info->multi_shot_stop = FALSE;
 
                /* sound init to pause other session */
-#ifdef _MMCAMCORDER_UPLOAD_SAMPLE
-               _mmcamcorder_sound_init(handle, _MMCAMCORDER_FILEPATH_CAPTURE2_SND);
-#else /* _MMCAMCORDER_UPLOAD_SAMPLE */
                _mmcamcorder_sound_init(handle);
-#endif /* _MMCAMCORDER_UPLOAD_SAMPLE */
        }
 
        _mmcam_dbg_log("preview(%dx%d,fmt:%d), capture(%dx%d,fmt:%d), count(%d), hdr mode(%d), interval (%d)",
@@ -742,8 +746,12 @@ 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);
 
+               traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:START:SET_PLAYING_TO_PIPELINE");
+
                ret = _mmcamcorder_gst_set_state(handle, pipeline, GST_STATE_PLAYING);
 
+               traceEnd(TTRACE_TAG_CAMERA);
+
                if (ret != MM_ERROR_NONE) {
                        goto cmd_error;
                }
@@ -823,8 +831,12 @@ int _mmcamcorder_image_cmd_preview_stop(MMHandleType handle)
        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
 
+       traceBegin(TTRACE_TAG_CAMERA, "MMCAMCORDER:STOP:SET_READY_TO_PIPELINE");
+
        ret = _mmcamcorder_gst_set_state(handle, pipeline, GST_STATE_READY);
 
+       traceEnd(TTRACE_TAG_CAMERA);
+
        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
        MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
 
@@ -836,7 +848,6 @@ int _mmcamcorder_image_cmd_preview_stop(MMHandleType handle)
                _mmcam_dbg_log("deregister sound status callback");
 
                vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, __sound_status_changed_cb);
-               mm_sound_volume_remove_callback(VOLUME_TYPE_SYSTEM);
 
                sc->info_image->sound_status = _SOUND_STATUS_INIT;
        }
@@ -917,12 +928,11 @@ void __mmcamcorder_init_stillshot_info (MMHandleType handle)
 }
 
 
-int __mmcamcorder_capture_save_exifinfo(MMHandleType handle, MMCamcorderCaptureDataType *original, MMCamcorderCaptureDataType *thumbnail)
+int __mmcamcorder_capture_save_exifinfo(MMHandleType handle, MMCamcorderCaptureDataType *original, MMCamcorderCaptureDataType *thumbnail, int provide_exif)
 {
        int ret = MM_ERROR_NONE;
        unsigned char *data = NULL;
        unsigned int datalen = 0;
-       int provide_exif = FALSE;
        _MMCamcorderSubContext *sc = NULL;
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
 
@@ -944,8 +954,8 @@ int __mmcamcorder_capture_save_exifinfo(MMHandleType handle, MMCamcorderCaptureD
                data = original->data;
                datalen = original->length;
        }
-       MMCAMCORDER_G_OBJECT_GET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "provide-exif", &provide_exif);
-       if(provide_exif == 0){
+
+       if (provide_exif == FALSE) {
                if (thumbnail) {
                        if (thumbnail->data && thumbnail->length > 0) {
                                _mmcam_dbg_log("thumbnail is added!thumbnail->data=%p thumbnail->width=%d ,thumbnail->height=%d",
@@ -1024,7 +1034,7 @@ GET_FAILED:
 }
 
 
-int __mmcamcorder_set_jpeg_data(MMHandleType handle, MMCamcorderCaptureDataType *dest, MMCamcorderCaptureDataType *thumbnail)
+int __mmcamcorder_set_jpeg_data(MMHandleType handle, MMCamcorderCaptureDataType *dest, MMCamcorderCaptureDataType *thumbnail, int provide_exif)
 {
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
        _MMCamcorderSubContext *sc = NULL;
@@ -1039,18 +1049,15 @@ int __mmcamcorder_set_jpeg_data(MMHandleType handle, MMCamcorderCaptureDataType
        /* if tag enable and doesn't provide exif, we make it */
        _mmcam_dbg_log("Add exif information if existed(thumbnail[%p])", thumbnail);
        if (thumbnail && thumbnail->data) {
-               return __mmcamcorder_capture_save_exifinfo(handle, dest, thumbnail);
+               return __mmcamcorder_capture_save_exifinfo(handle, dest, thumbnail, provide_exif);
        } else {
-               return __mmcamcorder_capture_save_exifinfo(handle, dest, NULL);
+               return __mmcamcorder_capture_save_exifinfo(handle, dest, NULL, provide_exif);
        }
 }
 
 
-void __mmcamcorder_release_jpeg_data(MMHandleType handle, MMCamcorderCaptureDataType *dest)
+void __mmcamcorder_release_jpeg_data(MMHandleType handle, MMCamcorderCaptureDataType *dest, int tag_enable, int provide_exif)
 {
-       int tag_enable = 0;
-       int provide_exif = FALSE;
-
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
        _MMCamcorderSubContext *sc = NULL;
 
@@ -1060,10 +1067,7 @@ void __mmcamcorder_release_jpeg_data(MMHandleType handle, MMCamcorderCaptureData
        sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
        mmf_return_if_fail(sc);
 
-       _mmcam_dbg_log("");
-
-       mm_camcorder_get_attributes(handle, NULL, MMCAM_TAG_ENABLE, &tag_enable, NULL);
-       MMCAMCORDER_G_OBJECT_GET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "provide-exif", &provide_exif);
+       _mmcam_dbg_log("tag : %d, provide exif : %d", tag_enable, provide_exif);
 
        /* if dest->data is allocated in MSL, release it */
        if (tag_enable && !provide_exif) {
@@ -1517,7 +1521,7 @@ static void __mmcamcorder_image_capture_cb(GstElement *element, GstSample *sampl
                        case MM_IMAGE_CODEC_JPEG:
                        case MM_IMAGE_CODEC_SRW:
                        case MM_IMAGE_CODEC_JPEG_SRW:
-                               ret = __mmcamcorder_set_jpeg_data((MMHandleType)hcamcorder, &dest, &thumb);
+                               ret = __mmcamcorder_set_jpeg_data((MMHandleType)hcamcorder, &dest, &thumb, provide_exif);
                                if (ret != MM_ERROR_NONE) {
                                        _mmcam_dbg_err("Error on setting extra data to jpeg");
                                        MMCAM_SEND_MESSAGE(hcamcorder, MM_MESSAGE_CAMCORDER_ERROR, ret);
@@ -1571,7 +1575,7 @@ err_release_exif:
 
        /* Release jpeg data */
        if (pixtype_main == MM_PIXEL_FORMAT_ENCODED) {
-               __mmcamcorder_release_jpeg_data((MMHandleType)hcamcorder, &dest);
+               __mmcamcorder_release_jpeg_data((MMHandleType)hcamcorder, &dest, tag_enable, provide_exif);
        }
 
 error:
@@ -2095,8 +2099,8 @@ int __mmcamcorder_set_exif_basic_info(MMHandleType handle, int image_width, int
 
        /* get ExifData from exif info */
        ed = mm_exif_get_exif_from_info(hcamcorder->exif_info);
-       if (ed == NULL || ed->ifd == NULL) {
-               _mmcam_dbg_err("get exif data error!!(%p, %p)", ed, (ed ? ed->ifd : NULL));
+       if (ed == NULL) {
+               _mmcam_dbg_err("get exif data error!!");
                return MM_ERROR_INVALID_HANDLE;
        }
 
@@ -2211,16 +2215,22 @@ int __mmcamcorder_set_exif_basic_info(MMHandleType handle, int image_width, int
 #endif
        /*6. EXIF_TAG_IMAGE_DESCRIPTION */
        mm_camcorder_get_attributes(handle, NULL, MMCAM_TAG_IMAGE_DESCRIPTION, &str_value, &str_val_len, NULL);
-       _mmcam_dbg_log("desctiption [%s]", str_value);
        if (str_value && str_val_len > 0) {
                char *description = strdup(str_value);
-               ret = mm_exif_set_add_entry(ed, EXIF_IFD_0, EXIF_TAG_IMAGE_DESCRIPTION,
-                                           EXIF_FORMAT_ASCII, strlen(description), (const char *)description);
-               free(description);
-               str_value = NULL;
-               str_val_len = 0;
-               if (ret != MM_ERROR_NONE) {
-                       EXIF_SET_ERR(ret, EXIF_TAG_IMAGE_DESCRIPTION);
+
+               _mmcam_dbg_log("desctiption [%s]", str_value);
+
+               if (description) {
+                       ret = mm_exif_set_add_entry(ed, EXIF_IFD_0, EXIF_TAG_IMAGE_DESCRIPTION,
+                                                   EXIF_FORMAT_ASCII, strlen(description), (const char *)description);
+                       free(description);
+                       str_value = NULL;
+                       str_val_len = 0;
+                       if (ret != MM_ERROR_NONE) {
+                               EXIF_SET_ERR(ret, EXIF_TAG_IMAGE_DESCRIPTION);
+                       }
+               } else {
+                       _mmcam_dbg_err("strdup failed for [%s]", str_value);
                }
        } else {
                _mmcam_dbg_warn("failed to get description");