Fix build warning
[platform/core/multimedia/libmm-camcorder.git] / src / mm_camcorder_attribute.c
index e6c056a..c61cff0 100644 (file)
@@ -29,7 +29,6 @@
 #include <gst/video/colorbalance.h>
 #include <gst/video/cameracontrol.h>
 #include <gst/video/videooverlay.h>
-#include <gst/wayland/wayland.h>
 
 /*-----------------------------------------------------------------------
 |    MACRO DEFINITIONS:                                                        |
@@ -1748,7 +1747,7 @@ _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const cha
        if (attrs) {
                ret = __mmcamcorder_check_valid_pair(handle, err_attr_name, attribute_name, var_args);
        } else {
-               _mmcam_dbg_err("handle 0x%x, attrs is NULL, attr name [%s]", handle, attribute_name);
+               _mmcam_dbg_err("handle %p, attrs is NULL, attr name [%s]", handle, attribute_name);
                ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
        }
 
@@ -2005,6 +2004,7 @@ bool _mmcamcorder_commit_capture_break_cont_shot(MMHandleType handle, int attr_i
        const char *videosrc_name = NULL;
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
        _MMCamcorderSubContext *sc = NULL;
+       _MMCamcorderImageInfo *info = NULL;
        GstCameraControl *control = NULL;
        type_element *VideosrcElement = NULL;
 
@@ -2023,7 +2023,18 @@ bool _mmcamcorder_commit_capture_break_cont_shot(MMHandleType handle, int attr_i
        if (!sc)
                return TRUE;
 
+       info = sc->info_image;
+       if (!info) {
+               _mmcam_dbg_err("info image is NULL");
+               return FALSE;
+       }
+
        if (ivalue && current_state == MM_CAMCORDER_STATE_CAPTURING) {
+               if (info->capture_send_count > 0) {
+                       info->capturing = FALSE;
+                       _mmcam_dbg_warn("capturing -> FALSE and skip capture callback since now");
+               }
+
                if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
                        _mmcam_dbg_warn("Can't cast Video source into camera control.");
                        return TRUE;
@@ -2564,9 +2575,7 @@ bool _mmcamcorder_commit_camera_ptz_type(MMHandleType handle, int attr_idx, cons
                        }
                }
 
-               if (item == NULL) {
-                       _mmcam_dbg_warn("failed to find tilt control channel");
-               }
+               _mmcam_dbg_warn("failed to find tilt control channel");
        }
 
        return FALSE;
@@ -2631,9 +2640,7 @@ bool _mmcamcorder_commit_camera_pan(MMHandleType handle, int attr_idx, const mmf
                        }
                }
 
-               if (item == NULL) {
-                       _mmcam_dbg_warn("failed to find pan control channel");
-               }
+               _mmcam_dbg_warn("failed to find pan control channel");
        }
 
        return FALSE;
@@ -2698,9 +2705,7 @@ bool _mmcamcorder_commit_camera_tilt(MMHandleType handle, int attr_idx, const mm
                        }
                }
 
-               if (item == NULL) {
-                       _mmcam_dbg_warn("failed to find tilt control channel");
-               }
+               _mmcam_dbg_warn("failed to find tilt control channel");
        }
 
        return FALSE;
@@ -3390,16 +3395,11 @@ bool _mmcamcorder_commit_image_encoder_quality(MMHandleType handle, int attr_idx
 
 bool _mmcamcorder_commit_target_filename(MMHandleType handle, int attr_idx, const mmf_value_t *value)
 {
-       _MMCamcorderSubContext *sc = NULL;
-       const char *filename = NULL;
        int size = 0;
+       const char *filename = NULL;
 
        mmf_return_val_if_fail(handle && value, FALSE);
 
-       sc = MMF_CAMCORDER_SUBCONTEXT(handle);
-       if (!sc)
-               return TRUE;
-
        /* get string */
        filename = mmf_value_get_string(value, &size);
        if (filename == NULL) {
@@ -3407,22 +3407,7 @@ bool _mmcamcorder_commit_target_filename(MMHandleType handle, int attr_idx, cons
                return FALSE;
        }
 
-       if (sc->info_video) {
-               SAFE_G_FREE(sc->info_video->filename);
-               sc->info_video->filename = g_strdup(filename);
-               if (sc->info_video->filename == NULL) {
-                       _mmcam_dbg_err("failed to strdup filename [%s]", filename);
-                       return FALSE;
-               }
-       }
-
-       if (sc->encode_element && sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst) {
-               _mmcam_dbg_log("new file location set.[%s] filesink %p", filename, sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst);
-               MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst, "location", filename);
-               _mmcam_dbg_log("new file location set.(%s)", filename);
-       } else {
-               _mmcam_dbg_log("element is not created yet. [%s] will be set later...", filename);
-       }
+       _mmcam_dbg_log("set filename [%s]", filename);
 
        return TRUE;
 }
@@ -3801,11 +3786,11 @@ bool _mmcamcorder_commit_display_mode(MMHandleType handle, int attr_idx, const m
        if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "waylandsink")) {
                _mmcam_dbg_log("Commit : display mode [%d]", value->value.i_val);
                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-mode", value->value.i_val);
-               return TRUE;
        } else {
-               _mmcam_dbg_warn("Commit : This element [%s] does not support display mode", videosink_name);
-               return FALSE;
+               _mmcam_dbg_warn("[%s] does not support display mode, but no error", videosink_name);
        }
+
+       return TRUE;
 }
 
 
@@ -3895,11 +3880,11 @@ bool _mmcamcorder_commit_display_visible(MMHandleType handle, int attr_idx, cons
                !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink")) {
                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "visible", value->value.i_val);
                _mmcam_dbg_log("Set visible [%d] done.", value->value.i_val);
-               return TRUE;
        } else {
-               _mmcam_dbg_warn("videosink[%s] does not support VISIBLE.", videosink_name);
-               return FALSE;
+               _mmcam_dbg_warn("[%s] does not support VISIBLE, but no error", videosink_name);
        }
+
+       return TRUE;
 }
 
 
@@ -3940,11 +3925,11 @@ bool _mmcamcorder_commit_display_geometry_method(MMHandleType handle, int attr_i
            !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink")) {
                method = value->value.i_val;
                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", method);
-               return TRUE;
        } else {
-               _mmcam_dbg_warn("videosink[%s] does not support geometry method.", videosink_name);
-               return FALSE;
+               _mmcam_dbg_warn("[%s] does not support geometry method, but no error", videosink_name);
        }
+
+       return TRUE;
 }
 
 
@@ -4061,12 +4046,11 @@ bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const m
                                        NULL);
                        }
                }
-
-               return TRUE;
        } else {
-               _mmcam_dbg_warn("videosink[%s] does not support display rect.", videosink_name);
-               return FALSE;
+               _mmcam_dbg_warn("[%s] does not support display rect, but no error", videosink_name);
        }
+
+       return TRUE;
 }
 
 
@@ -4540,7 +4524,7 @@ bool _mmcamcorder_commit_pid_for_sound_focus(MMHandleType handle, int attr_idx,
 
        new_pid = value->value.i_val;
 
-       _mmcam_dbg_log("Commit : pid %d, current focus id %d, subscribe id %u",
+       _mmcam_dbg_warn("Commit : pid %d, current focus id %d, subscribe id %u",
                new_pid, hcamcorder->sound_focus_id, hcamcorder->sound_focus_subscribe_id);
 
        /* unregister sound focus and unsubscribe sound signal before set new one */
@@ -4618,13 +4602,6 @@ bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, co
                return FALSE;
        }
 
-       sc = MMF_CAMCORDER_SUBCONTEXT(handle);
-       if (!sc || !sc->encode_element ||
-           !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
-               _mmcam_dbg_log("audiosrc element is not initialized, it will be set later");
-               return TRUE;
-       }
-
        mm_camcorder_get_attributes(handle, NULL,
                MMCAM_SOUND_STREAM_INDEX, &stream_index,
                NULL);
@@ -4633,7 +4610,17 @@ bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, co
                return FALSE;
        }
 
-       _mmcam_dbg_log("Commit : sound stream info - type %s, index %d", stream_type, stream_index);
+       /* unset watch callback if existed */
+       _mmcamcorder_sound_signal_callback(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, 1, (void *)handle);
+
+       sc = MMF_CAMCORDER_SUBCONTEXT(handle);
+       if (!sc || !sc->encode_element ||
+           !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
+               _mmcam_dbg_warn("audiosrc element is not initialized, it will be set later");
+               return TRUE;
+       }
+
+       _mmcam_dbg_warn("Commit : sound stream info - type %s, index %d", stream_type, stream_index);
 
        return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index);
 }
@@ -4701,7 +4688,6 @@ bool _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
                MM_CAM_CAMERA_WDR,
                MM_CAM_FILTER_CONTRAST,
                MM_CAM_FILTER_HUE,
-               MM_CAM_STROBE_MODE,
                MM_CAM_DETECT_MODE
        };
 
@@ -4717,7 +4703,7 @@ bool _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
 
        mmf_return_val_if_fail(hcamcorder, FALSE);
 
-       _mmcam_dbg_log("Set all attribute again.");
+       _mmcam_dbg_log("commit some attributes again");
 
        attr = (mmf_attrs_t *)MMF_CAMCORDER_ATTRS(handle);
        if (attr == NULL) {
@@ -4758,6 +4744,45 @@ bool _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
 }
 
 
+bool _mmcamcorder_set_attribute_to_camsensor2(MMHandleType handle)
+{
+       mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+       mmf_attrs_t *attr = NULL;
+
+       unsigned int i = 0;
+       int ret = TRUE;
+       int attr_idxs[] = {
+               MM_CAM_STROBE_MODE
+       };
+
+       mmf_return_val_if_fail(hcamcorder, FALSE);
+
+       _mmcam_dbg_log("commit some attribute again[2]");
+
+       attr = (mmf_attrs_t *)MMF_CAMCORDER_ATTRS(handle);
+       if (attr == NULL) {
+               _mmcam_dbg_err("Get attribute handle failed.");
+               return FALSE;
+       } else {
+               _mmcam_dbg_log("attribute count(%d)", attr->count);
+
+               for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
+                       if (__mmcamcorder_attrs_is_supported((MMHandleType)attr, attr_idxs[i]))
+                               mmf_attribute_set_modified(&(attr->items[attr_idxs[i]]));
+               }
+
+               if (mmf_attrs_commit((MMHandleType)attr) == -1)
+                       ret = FALSE;
+               else
+                       ret = TRUE;
+       }
+
+       _mmcam_dbg_log("Done.");
+
+       return ret;
+}
+
+
 int _mmcamcorder_lock_readonly_attributes(MMHandleType handle)
 {
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);