diff options
author | Jeongmo Yang <jm80.yang@samsung.com> | 2012-08-27 16:52:06 +0900 |
---|---|---|
committer | Jeongmo Yang <jm80.yang@samsung.com> | 2012-08-27 16:52:06 +0900 |
commit | ca403a464a8bf19b4053e954e6d8e946dba93cf3 (patch) | |
tree | 4ef3662a4e8f0f2d7998b6137c4b02ae33bbbe48 | |
parent | a5eb0f73f5ce3a86b2d6365e7d21ca539fe43b78 (diff) | |
download | libmm-camcorder-ca403a464a8bf19b4053e954e6d8e946dba93cf3.tar.gz libmm-camcorder-ca403a464a8bf19b4053e954e6d8e946dba93cf3.tar.bz2 libmm-camcorder-ca403a464a8bf19b4053e954e6d8e946dba93cf3.zip |
1. Add new attribute for EXIF raw data - MMCAM_CAPTURED_EXIF_RAW_DATA
2. Support "evaspixmapsink" for display plugin
3. SEL Verification - Fix P120817-4807 Shutter sound works on silent mode
-rw-r--r-- | packaging/libmm-camcorder.spec | 3 | ||||
-rw-r--r-- | src/include/mm_camcorder.h | 23 | ||||
-rw-r--r-- | src/include/mm_camcorder_attribute.h | 5 | ||||
-rw-r--r-- | src/include/mm_camcorder_internal.h | 78 | ||||
-rw-r--r-- | src/include/mm_camcorder_stillshot.h | 6 | ||||
-rw-r--r-- | src/mm_camcorder_attribute.c | 745 | ||||
-rw-r--r-- | src/mm_camcorder_exifinfo.c | 132 | ||||
-rw-r--r-- | src/mm_camcorder_gstcommon.c | 25 | ||||
-rw-r--r-- | src/mm_camcorder_internal.c | 33 | ||||
-rw-r--r-- | src/mm_camcorder_sound.c | 237 | ||||
-rw-r--r-- | src/mm_camcorder_stillshot.c | 257 | ||||
-rw-r--r-- | src/mm_camcorder_videorec.c | 107 | ||||
-rw-r--r-- | test/mm_camcorder_testsuite.c | 135 |
13 files changed, 999 insertions, 787 deletions
diff --git a/packaging/libmm-camcorder.spec b/packaging/libmm-camcorder.spec index 798dc14..98a4995 100644 --- a/packaging/libmm-camcorder.spec +++ b/packaging/libmm-camcorder.spec @@ -1,6 +1,6 @@ Name: libmm-camcorder Summary: Camera and recorder library -Version: 0.6.8 +Version: 0.6.11 Release: 0 Group: libs License: Apache-2.0 @@ -58,6 +58,7 @@ rm -rf %{buildroot} /sbin/ldconfig vconftool set -t int memory/camera/state 0 -i -u 5000 +vconftool set -t int file/camera/shutter_sound_policy 0 -u 5000 %postun -p /sbin/ldconfig diff --git a/src/include/mm_camcorder.h b/src/include/mm_camcorder.h index 2b3de94..e3a7729 100644 --- a/src/include/mm_camcorder.h +++ b/src/include/mm_camcorder.h @@ -934,6 +934,18 @@ extern "C" { #define MMCAM_CAPTURE_BREAK_CONTINUOUS_SHOT "capture-break-cont-shot" /** + * Raw data of captured image which resolution is same as preview. + * This is READ-ONLY attribute and only available in capture callback. + * This should be used after casted as MMCamcorderCaptureDataType. + */ +#define MMCAM_CAPTURED_SCREENNAIL "captured-screennail" + +/** + * Raw data of EXIF. This is READ-ONLY attribute and only available in capture callback. + */ +#define MMCAM_CAPTURED_EXIF_RAW_DATA "captured-exif-raw-data" + +/** * Pointer of display buffer or ID of xwindow. */ #define MMCAM_DISPLAY_HANDLE "display-handle" @@ -1028,6 +1040,17 @@ extern "C" { #define MMCAM_DISPLAY_GEOMETRY_METHOD "display-geometry-method" /** + * A videosink name of evas surface. + * This is READ-ONLY attribute. + */ +#define MMCAM_DISPLAY_EVAS_SURFACE_SINK "display-evas-surface-sink" + +/** + * This attribute is only available if value of MMCAM_DISPLAY_EVAS_SURFACE_SINK "evaspixmapsink" + */ +#define MMCAM_DISPLAY_EVAS_DO_SCALING "display-evas-do-scaling" + +/** * Target filename. Only used in Audio/Video recording. This is not used for capturing. */ #define MMCAM_TARGET_FILENAME "target-filename" diff --git a/src/include/mm_camcorder_attribute.h b/src/include/mm_camcorder_attribute.h index bcb5b67..be1845c 100644 --- a/src/include/mm_camcorder_attribute.h +++ b/src/include/mm_camcorder_attribute.h @@ -165,6 +165,9 @@ typedef enum MM_CAM_AUDIO_DISABLE, MM_CAM_RECOMMEND_CAMERA_WIDTH, /* 110 */ MM_CAM_RECOMMEND_CAMERA_HEIGHT, + MM_CAM_CAPTURED_EXIF_RAW_DATA, + MM_CAM_DISPLAY_EVAS_SURFACE_SINK, + MM_CAM_DISPLAY_EVAS_DO_SCALING, MM_CAM_NUM }MMCamcorderAttrsID; @@ -310,6 +313,7 @@ bool _mmcamcorder_commit_capture_width(MMHandleType handle, int attr_idx, const bool _mmcamcorder_commit_capture_height(MMHandleType handle, int attr_idx, const mmf_value_t *value); bool _mmcamcorder_commit_capture_break_cont_shot(MMHandleType handle, int attr_idx, const mmf_value_t *value); bool _mmcamcorder_commit_capture_count(MMHandleType handle, int attr_idx, const mmf_value_t *value); +bool _mmcamcorder_commit_capture_sound_enable(MMHandleType handle, int attr_idx, const mmf_value_t *value); bool _mmcamcorder_commit_audio_volume(MMHandleType handle, int attr_idx, const mmf_value_t *value); bool _mmcamcorder_commit_audio_input_route(MMHandleType handle, int attr_idx, const mmf_value_t *value); bool _mmcamcorder_commit_audio_disable(MMHandleType handle, int attr_idx, const mmf_value_t *value); @@ -339,6 +343,7 @@ bool _mmcamcorder_commit_display_visible(MMHandleType handle, int attr_idx, cons bool _mmcamcorder_commit_display_geometry_method(MMHandleType handle, int attr_idx, const mmf_value_t *value); bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const mmf_value_t *value); bool _mmcamcorder_commit_display_scale(MMHandleType handle, int attr_idx, const mmf_value_t *value); +bool _mmcamcorder_commit_display_evas_do_scaling(MMHandleType handle, int attr_idx, const mmf_value_t *value); bool _mmcamcorder_commit_strobe(MMHandleType handle, int attr_idx, const mmf_value_t *value); bool _mmcamcorder_commit_detect(MMHandleType handle, int attr_idx, const mmf_value_t *value); bool _mmcamcorder_commit_camera_flip_horizontal(MMHandleType handle, int attr_idx, const mmf_value_t *value); diff --git a/src/include/mm_camcorder_internal.h b/src/include/mm_camcorder_internal.h index c008e14..b5719eb 100644 --- a/src/include/mm_camcorder_internal.h +++ b/src/include/mm_camcorder_internal.h @@ -38,6 +38,7 @@ #include <mm_message.h> #include <mm_ta.h> #include <sndfile.h> +#include <vconf.h> #include "mm_camcorder.h" #include "mm_debug.h" @@ -562,52 +563,53 @@ typedef struct { */ typedef struct mmf_camcorder { /* information */ - int type; /**< mmcamcorder_mode_type */ - int state; /**< state of camcorder */ - int target_state; /**< Target state that want to set. This is a flag that - * stands for async state changing. If this value differ from state, - * it means state is changing now asychronously. */ + int type; /**< mmcamcorder_mode_type */ + int state; /**< state of camcorder */ + int target_state; /**< Target state that want to set. This is a flag that + * stands for async state changing. If this value differ from state, + * it means state is changing now asychronously. */ /* handles */ - MMHandleType attributes; /**< Attribute handle */ + MMHandleType attributes; /**< Attribute handle */ _MMCamcorderSubContext *sub_context; /**< sub context */ - mm_exif_info_t *exif_info; /**< EXIF */ - GList *buffer_probes; /**< a list of buffer probe handle */ - GList *event_probes; /**< a list of event probe handle */ - GList *data_probes; /**< a list of data probe handle */ - GList *signals; /**< a list of signal handle */ - GList *msg_data; /**< a list of msg data */ - camera_conf *conf_main; /**< Camera configure Main structure */ - camera_conf *conf_ctrl; /**< Camera configure Control structure */ - int asm_handle; /**< Audio session manager handle */ - guint pipeline_cb_event_id; /**< Event source ID of pipeline message callback */ - guint setting_event_id; /**< Event source ID of attributes setting to sensor */ - SOUND_INFO snd_info; /**< Sound handle for multishot capture */ + mm_exif_info_t *exif_info; /**< EXIF */ + GList *buffer_probes; /**< a list of buffer probe handle */ + GList *event_probes; /**< a list of event probe handle */ + GList *data_probes; /**< a list of data probe handle */ + GList *signals; /**< a list of signal handle */ + GList *msg_data; /**< a list of msg data */ + camera_conf *conf_main; /**< Camera configure Main structure */ + camera_conf *conf_ctrl; /**< Camera configure Control structure */ + int asm_handle; /**< Audio session manager handle */ + guint pipeline_cb_event_id; /**< Event source ID of pipeline message callback */ + guint setting_event_id; /**< Event source ID of attributes setting to sensor */ + SOUND_INFO snd_info; /**< Sound handle for multishot capture */ /* callback handlers */ - MMMessageCallback msg_cb; /**< message callback */ - void *msg_cb_param; /**< message callback parameter */ - mm_camcorder_video_stream_callback vstream_cb; /**< Video stream callback */ - void *vstream_cb_param; /**< Video stream callback parameter */ - mm_camcorder_audio_stream_callback astream_cb; /**< Audio stream callback */ - void *astream_cb_param; /**< Audio stream callback parameter */ - mm_camcorder_video_capture_callback vcapture_cb; /**< Video capture callback */ - void *vcapture_cb_param; /**< Video capture callback parameter */ - int (*command)(MMHandleType, int); /**< camcorder's command */ + MMMessageCallback msg_cb; /**< message callback */ + void *msg_cb_param; /**< message callback parameter */ + mm_camcorder_video_stream_callback vstream_cb; /**< Video stream callback */ + void *vstream_cb_param; /**< Video stream callback parameter */ + mm_camcorder_audio_stream_callback astream_cb; /**< Audio stream callback */ + void *astream_cb_param; /**< Audio stream callback parameter */ + mm_camcorder_video_capture_callback vcapture_cb; /**< Video capture callback */ + void *vcapture_cb_param; /**< Video capture callback parameter */ + int (*command)(MMHandleType, int); /**< camcorder's command */ /* etc */ - _MMCamcorderMTSafe mtsafe; /**< Thread safe */ - _MMCamcorderCommand cmd; /**< information for command loop */ - int sync_state_change; /**< Change framework state synchronously */ + _MMCamcorderMTSafe mtsafe; /**< Thread safe */ + _MMCamcorderCommand cmd; /**< information for command loop */ + int sync_state_change; /**< Change framework state synchronously */ int quick_device_close; - int state_change_by_system; /**< MSL changes its state by itself because of system(ASM,MDM..) **/ - int asm_event_code; /**< event code of audio session manager */ - pthread_mutex_t sound_lock; /**< Capture sound mutex */ - pthread_cond_t sound_cond; /**< Capture sound cond */ - int use_zero_copy_format; /**< Whether use zero copy format for camera input */ - - _MMCamcorderInfoConverting caminfo_convert[CAMINFO_CONVERT_NUM]; /**< converting structure of camera info */ - _MMCamcorderEnumConvert enum_conv[ENUM_CONVERT_NUM]; /**< enum converting list that is modified by ini info */ + int state_change_by_system; /**< MSL changes its state by itself because of system(ASM,MDM..) **/ + int asm_event_code; /**< event code of audio session manager */ + pthread_mutex_t sound_lock; /**< Capture sound mutex */ + pthread_cond_t sound_cond; /**< Capture sound cond */ + int use_zero_copy_format; /**< Whether use zero copy format for camera input */ + int shutter_sound_policy; /**< shutter sound policy */ + + _MMCamcorderInfoConverting caminfo_convert[CAMINFO_CONVERT_NUM]; /**< converting structure of camera info */ + _MMCamcorderEnumConvert enum_conv[ENUM_CONVERT_NUM]; /**< enum converting list that is modified by ini info */ int reserved[4]; /**< reserved */ } mmf_camcorder_t; diff --git a/src/include/mm_camcorder_stillshot.h b/src/include/mm_camcorder_stillshot.h index 2e4ab6e..601a25b 100644 --- a/src/include/mm_camcorder_stillshot.h +++ b/src/include/mm_camcorder_stillshot.h @@ -122,12 +122,12 @@ int _mmcamcorder_image_command(MMHandleType handle, int command); int _mmcamcorder_set_resize_property(MMHandleType handle, int capture_width, int capture_height); /* Function for capture */ -int __mmcamcorder_set_exif_basic_info(MMHandleType handle, MMCamcorderCaptureDataType *capture_data); +int __mmcamcorder_set_exif_basic_info(MMHandleType handle, int image_width, int image_height); void __mmcamcorder_init_stillshot_info(MMHandleType handle); void __mmcamcorder_get_capture_data_from_buffer(MMCamcorderCaptureDataType *capture_data, int pixtype, GstBuffer *buffer); void __mmcamcorder_release_jpeg_data(MMHandleType handle, MMCamcorderCaptureDataType *dest); -gboolean __mmcamcorder_capture_save_exifinfo(MMHandleType handle, MMCamcorderCaptureDataType *original, MMCamcorderCaptureDataType *thumbnail); -gboolean __mmcamcorder_set_jpeg_data(MMHandleType handle, MMCamcorderCaptureDataType *dest, MMCamcorderCaptureDataType *thumbnail); +int __mmcamcorder_capture_save_exifinfo(MMHandleType handle, MMCamcorderCaptureDataType *original, MMCamcorderCaptureDataType *thumbnail); +int __mmcamcorder_set_jpeg_data(MMHandleType handle, MMCamcorderCaptureDataType *dest, MMCamcorderCaptureDataType *thumbnail); #ifdef __cplusplus } diff --git a/src/mm_camcorder_attribute.c b/src/mm_camcorder_attribute.c index 7725e55..e31f451 100644 --- a/src/mm_camcorder_attribute.c +++ b/src/mm_camcorder_attribute.c @@ -1225,7 +1225,7 @@ mm_cam_attr_construct_info cam_attrs_const_info[] ={ MM_CAM_CAPTURED_SCREENNAIL, "captured-screennail", MMF_VALUE_TYPE_DATA, - MM_ATTRS_FLAG_RW, + MM_ATTRS_FLAG_READABLE, {(void*)NULL}, MM_ATTRS_VALID_TYPE_NONE, 0, @@ -1242,7 +1242,7 @@ mm_cam_attr_construct_info cam_attrs_const_info[] ={ MM_ATTRS_VALID_TYPE_INT_RANGE, 0, 1, - NULL, + _mmcamcorder_commit_capture_sound_enable, }, //99 { @@ -1388,6 +1388,42 @@ mm_cam_attr_construct_info cam_attrs_const_info[] ={ 0, NULL, }, + //112 + { + MM_CAM_CAPTURED_EXIF_RAW_DATA, + "captured-exif-raw-data", + MMF_VALUE_TYPE_DATA, + MM_ATTRS_FLAG_READABLE, + {(void*)NULL}, + MM_ATTRS_VALID_TYPE_NONE, + 0, + 0, + NULL, + }, + //113 + { + MM_CAM_DISPLAY_EVAS_SURFACE_SINK, + "display-evas-surface-sink", + MMF_VALUE_TYPE_STRING, + MM_ATTRS_FLAG_READABLE, + {(void*)NULL}, + MM_ATTRS_VALID_TYPE_NONE, + 0, + 0, + NULL, + }, + //114 + { + MM_CAM_DISPLAY_EVAS_DO_SCALING, + "display-evas-do-scaling", + MMF_VALUE_TYPE_INT, + MM_ATTRS_FLAG_RW, + {(void*)TRUE}, + MM_ATTRS_VALID_TYPE_INT_RANGE, + FALSE, + TRUE, + _mmcamcorder_commit_display_evas_do_scaling, + } }; @@ -1564,7 +1600,7 @@ _mmcamcorder_get_attributes(MMHandleType handle, char **err_attr_name, const ch attrs = MMF_CAMCORDER_ATTRS(handle); mmf_return_val_if_fail( attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED ); - ret = mm_attrs_get_valist (attrs, err_attr_name, attribute_name, var_args); + ret = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, var_args); return ret; } @@ -1588,7 +1624,7 @@ _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const cha if( ret == MM_ERROR_NONE ) { - ret = mm_attrs_set_valist (attrs, err_attr_name, attribute_name, var_args); + ret = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, var_args); } return ret; @@ -1883,7 +1919,7 @@ bool _mmcamcorder_commit_capture_break_cont_shot (MMHandleType handle, int attr_ } -bool _mmcamcorder_commit_capture_count (MMHandleType handle, int attr_idx, const mmf_value_t *value) +bool _mmcamcorder_commit_capture_count(MMHandleType handle, int attr_idx, const mmf_value_t *value) { int ret = FALSE; int cap_count = 0; @@ -1896,7 +1932,7 @@ bool _mmcamcorder_commit_capture_count (MMHandleType handle, int attr_idx, const cap_count = value->value.i_val; mm_camcorder_get_attributes(handle, NULL, MMCAM_MODE, &mode, NULL); - if (mode == MM_CAMCORDER_MODE_IMAGE) { + if (mode != MM_CAMCORDER_MODE_AUDIO) { if (cap_count > 1) { __ta__("_mmcamcorder_sound_init", #ifdef _MMCAMCORDER_UPLOAD_SAMPLE @@ -1911,11 +1947,36 @@ bool _mmcamcorder_commit_capture_count (MMHandleType handle, int attr_idx, const ); _mmcam_dbg_log("sound finalize [%d]", ret); } + + _mmcam_dbg_log("Capture Count %d, ret %d", cap_count, ret); + } else { + _mmcam_dbg_err("Current mode is AUDIO recording"); + ret = FALSE; } - _mmcam_dbg_log("Capture Count(%d)", cap_count); + return ret; +} + - return TRUE; +bool _mmcamcorder_commit_capture_sound_enable(MMHandleType handle, int attr_idx, const mmf_value_t *value) +{ + int shutter_sound_policy = FALSE; + + mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); + + mmf_return_val_if_fail(hcamcorder, FALSE); + + _mmcam_dbg_log("shutter sound policy: %d", hcamcorder->shutter_sound_policy); + + /* return error when disable shutter sound if policy is TRUE */ + if (!value->value.i_val && + hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) { + _mmcam_dbg_err("not permitted DISABLE SHUTTER SOUND"); + return FALSE; + } else { + _mmcam_dbg_log("set value [%d] success", value->value.i_val); + return TRUE; + } } @@ -2515,7 +2576,7 @@ bool _mmcamcorder_commit_camera_capture_mode (MMHandleType handle, int attr_idx, if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) { if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) { _mmcam_dbg_log("Can't cast Video source into camera control."); - return TRUE; + return TRUE; } control = GST_CAMERA_CONTROL (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst); @@ -2525,15 +2586,14 @@ bool _mmcamcorder_commit_camera_capture_mode (MMHandleType handle, int attr_idx, __ta__(" gst_camera_control_set_exposure", ret = gst_camera_control_set_exposure(control, exposure_type, newVal1, newVal2); ); - if (ret) { - //_mmcam_dbg_log( "Succeed in setting exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2 ); + _mmcam_dbg_log("Succeed in setting exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2 ); return TRUE; } else { - _mmcam_dbg_warn( "Failed to set exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2 ); + _mmcam_dbg_warn("Failed to set exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2 ); } } else { - //_mmcam_dbg_log( "No need to set exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2 ); + _mmcam_dbg_log("No need to set exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2); return TRUE; } } else { @@ -2644,7 +2704,7 @@ bool _mmcamcorder_commit_camera_hold_af_after_capturing (MMHandleType handle, in if (!sc) return TRUE; - current_state = _mmcamcorder_get_state( handle); + current_state = _mmcamcorder_get_state(handle); if( current_state < MM_CAMCORDER_STATE_READY ) { @@ -2670,7 +2730,7 @@ bool _mmcamcorder_commit_camera_rotate (MMHandleType handle, int attr_idx, const _mmcam_dbg_log("rotate(%d)", value->value.i_val); - current_state = _mmcamcorder_get_state( handle); + current_state = _mmcamcorder_get_state(handle); if (current_state > MM_CAMCORDER_STATE_READY) { _mmcam_dbg_err("camera rotation setting failed.(state=%d, is_state_changing(%d))", current_state); @@ -2681,10 +2741,39 @@ bool _mmcamcorder_commit_camera_rotate (MMHandleType handle, int attr_idx, const } -bool _mmcamcorder_commit_image_encoder_quality (MMHandleType handle, int attr_idx, const mmf_value_t *value) +bool _mmcamcorder_commit_image_encoder_quality(MMHandleType handle, int attr_idx, const mmf_value_t *value) { + int current_state = MM_CAMCORDER_STATE_NONE; + + mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); + _MMCamcorderSubContext *sc = NULL; + + mmf_return_val_if_fail(handle, FALSE); + + /* check type */ + if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) { + _mmcam_dbg_err("invalid mode %d", hcamcorder->type); + return FALSE; + } + + /* check current state */ + current_state = _mmcamcorder_get_state(handle); + if (current_state < MM_CAMCORDER_STATE_READY) { + _mmcam_dbg_log("NOT initialized. this will be applied later"); + return TRUE; + } + + sc = MMF_CAMCORDER_SUBCONTEXT(handle); + _mmcam_dbg_log("Image encoder quality(%d)", value->value.i_val); - return TRUE; + + if (current_state == MM_CAMCORDER_STATE_PREPARE) { + MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", value->value.i_val); + return TRUE; + } else { + _mmcam_dbg_err("invalid state %d", current_state); + return FALSE; + } } @@ -3114,34 +3203,50 @@ bool _mmcamcorder_commit_audio_disable(MMHandleType handle, int attr_idx, const bool _mmcamcorder_commit_display_handle(MMHandleType handle, int attr_idx, const mmf_value_t *value) { - _MMCamcorderSubContext *sc = NULL; + int current_state = MM_CAMCORDER_STATE_NONE; char *videosink_name = NULL; + void *p_handle = NULL; - mmf_return_val_if_fail(handle, TRUE); + mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); + _MMCamcorderSubContext *sc = NULL; - sc = MMF_CAMCORDER_SUBCONTEXT(handle); - mmf_return_val_if_fail(sc, TRUE); + mmf_return_val_if_fail(handle, FALSE); - _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name); + /* check type */ + if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) { + _mmcam_dbg_err("invalid mode %d", hcamcorder->type); + return FALSE; + } - _mmcam_dbg_log("Commit : videosinkname[%s]", videosink_name); + /* check current state */ + current_state = _mmcamcorder_get_state(handle); + if (current_state < MM_CAMCORDER_STATE_READY) { + _mmcam_dbg_log("NOT initialized. this will be applied later"); + return TRUE; + } - if (sc->element && sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst) { - void *p_handle = value->value.p_val; + sc = MMF_CAMCORDER_SUBCONTEXT(handle); - if (p_handle) { - if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) { - _mmcam_dbg_log("Commit : Set XID[%x]", *(int*)(p_handle)); - gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), *(int*)(p_handle)); - } else if (!strcmp(videosink_name, "evasimagesink")) { - _mmcam_dbg_log("Commit : Set evas object [%p]", p_handle); - MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "evas-object", p_handle); - } else { - _mmcam_dbg_log("Commit : Nothing to commit with this element[%s]", videosink_name); - } + p_handle = value->value.p_val; + if (p_handle) { + /* get videosink name */ + _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name); + _mmcam_dbg_log("Commit : videosinkname[%s]", videosink_name); + + if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) { + _mmcam_dbg_log("Commit : Set XID[%x]", *(int*)(p_handle)); + gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), *(int*)(p_handle)); + } else if (!strcmp(videosink_name, "evasimagesink") || + !strcmp(videosink_name, "evaspixmapsink")) { + _mmcam_dbg_log("Commit : Set evas object [%p]", p_handle); + MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "evas-object", p_handle); } else { - _mmcam_dbg_warn("Display handle is NULL. Nothing to do."); + _mmcam_dbg_warn("Commit : Nothing to commit with this element[%s]", videosink_name); + return FALSE; } + } else { + _mmcam_dbg_warn("Display handle is NULL"); + return FALSE; } return TRUE; @@ -3150,395 +3255,347 @@ bool _mmcamcorder_commit_display_handle(MMHandleType handle, int attr_idx, const bool _mmcamcorder_commit_display_mode(MMHandleType handle, int attr_idx, const mmf_value_t *value) { - _MMCamcorderSubContext *sc = NULL; + int current_state = MM_CAMCORDER_STATE_NONE; char *videosink_name = NULL; - mmf_return_val_if_fail(handle, TRUE); + mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); + _MMCamcorderSubContext *sc = NULL; + + mmf_return_val_if_fail(handle, FALSE); + + /* check type */ + if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) { + _mmcam_dbg_err("invalid mode %d", hcamcorder->type); + return FALSE; + } + + /* check current state */ + current_state = _mmcamcorder_get_state(handle); + if (current_state < MM_CAMCORDER_STATE_READY) { + _mmcam_dbg_log("NOT initialized. this will be applied later"); + return TRUE; + } sc = MMF_CAMCORDER_SUBCONTEXT(handle); - mmf_return_val_if_fail(sc, TRUE); _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name); - _mmcam_dbg_log("Commit : videosinkname[%s]", videosink_name); - if (sc->element && sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst) { - if (!strcmp(videosink_name, "xvimagesink")) { - _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); - } else { - _mmcam_dbg_log("Commit : This element [%s] does not support display mode", videosink_name); - } + if (!strcmp(videosink_name, "xvimagesink")) { + _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; } - - return TRUE; } -bool _mmcamcorder_commit_display_rotation (MMHandleType handle, int attr_idx, const mmf_value_t *value) +bool _mmcamcorder_commit_display_rotation(MMHandleType handle, int attr_idx, const mmf_value_t *value) { - mmf_camcorder_t *hcamcorder = NULL; - _MMCamcorderSubContext *sc = NULL; int current_state = MM_CAMCORDER_STATE_NONE; - hcamcorder = MMF_CAMCORDER(handle); - if(!hcamcorder) - return TRUE; - sc = MMF_CAMCORDER_SUBCONTEXT(handle); - if (!sc) - return TRUE; + mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); - current_state = _mmcamcorder_get_state( handle); + mmf_return_val_if_fail(handle, FALSE); - if( current_state > MM_CAMCORDER_STATE_NULL ) { - if( hcamcorder->type != MM_CAMCORDER_MODE_AUDIO ) { - return _mmcamcorder_set_display_rotation( handle, value->value.i_val ); - } else { - _mmcam_dbg_warn( "Current Mode is AUDIO only mode." ); - return FALSE; - } - } else { - _mmcam_dbg_err("display rotation change failed.(state=%d)", current_state); + /* check type */ + if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) { + _mmcam_dbg_err("invalid mode %d", hcamcorder->type); return FALSE; } + + /* check current state */ + current_state = _mmcamcorder_get_state(handle); + if (current_state < MM_CAMCORDER_STATE_READY) { + _mmcam_dbg_log("NOT initialized. this will be applied later"); + return TRUE; + } + + return _mmcamcorder_set_display_rotation(handle, value->value.i_val); } bool _mmcamcorder_commit_display_visible (MMHandleType handle, int attr_idx, const mmf_value_t *value) { - mmf_camcorder_t *hcamcorder= MMF_CAMCORDER( handle); - _MMCamcorderSubContext *sc = NULL; - - int is_visible = 0; int current_state = MM_CAMCORDER_STATE_NONE; - int bret = 0; - char *videosink_name = NULL; - - sc = MMF_CAMCORDER_SUBCONTEXT(handle); - if (!sc) - return TRUE; - current_state = _mmcamcorder_get_state( handle); - if( current_state > MM_CAMCORDER_STATE_NULL ) - { - if( hcamcorder->type != MM_CAMCORDER_MODE_AUDIO ) - { - if( sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst ) - { - // Get videosink name - _mmcamcorder_conf_get_value_element_name( sc->VideosinkElement, &videosink_name ); + mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); + _MMCamcorderSubContext *sc = NULL; - is_visible = value->value.i_val; + mmf_return_val_if_fail(handle, FALSE); - if( !strcmp( videosink_name, "xvimagesink" ) - || !strcmp( videosink_name, "avsysvideosink" ) ) - { - MMCAMCORDER_G_OBJECT_SET( sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, - "visible", is_visible); + /* check type */ + if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) { + _mmcam_dbg_err("invalid mode %d", hcamcorder->type); + return FALSE; + } - _mmcam_dbg_log( "Set visible [%d] done.", is_visible ); - bret = TRUE; - } - else - { - _mmcam_dbg_warn( "videosink[%s] does not support VISIBLE.", videosink_name ); - bret = FALSE; - } - } - else - { - _mmcam_dbg_warn( "Videosink element is null, but current state is [%d]", current_state ); - bret = FALSE; - } - } - else - { - _mmcam_dbg_warn( "Current Mode is AUDIO only mode." ); - bret = FALSE; - } + /* check current state */ + current_state = _mmcamcorder_get_state(handle); + if (current_state < MM_CAMCORDER_STATE_READY) { + _mmcam_dbg_log("NOT initialized. this will be applied later"); + return TRUE; } - else - { - _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state); - bret = TRUE; + + sc = MMF_CAMCORDER_SUBCONTEXT(handle); + + /* Get videosink name */ + _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name); + if (!strcmp(videosink_name, "xvimagesink") || + !strcmp(videosink_name, "evaspixmapsink")) { + 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; } - return bret; } bool _mmcamcorder_commit_display_geometry_method (MMHandleType handle, int attr_idx, const mmf_value_t *value) { - mmf_camcorder_t *hcamcorder= MMF_CAMCORDER( handle); - _MMCamcorderSubContext *sc = NULL; - - int newattrs = 0; + int method = 0; int current_state = MM_CAMCORDER_STATE_NONE; - int bret = 0; - char *videosink_name = NULL; - - sc = MMF_CAMCORDER_SUBCONTEXT(handle); - if (!sc) - return TRUE; - current_state = _mmcamcorder_get_state( handle); - if (current_state > MM_CAMCORDER_STATE_NULL) - { - if (sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst) - { - // Get videosink name - _mmcamcorder_conf_get_value_element_name( sc->VideosinkElement, &videosink_name ); + mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); + _MMCamcorderSubContext *sc = NULL; - if(strcmp(videosink_name, "xvimagesink") == 0) //only for xvimagesink - { - if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) - { - newattrs = value->value.i_val; - MMCAMCORDER_G_OBJECT_SET( sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", newattrs); - } - } - bret = TRUE; - } - else - { - _mmcam_dbg_log("Videosink element is null"); - bret = FALSE; - } + mmf_return_val_if_fail(handle, FALSE); + + /* check type */ + if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) { + _mmcam_dbg_err("invalid mode %d", hcamcorder->type); + return FALSE; } - else - { - _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state); - bret = TRUE; + + /* check current state */ + current_state = _mmcamcorder_get_state(handle); + if (current_state < MM_CAMCORDER_STATE_READY) { + _mmcam_dbg_log("NOT initialized. this will be applied later"); + return TRUE; + } + + sc = MMF_CAMCORDER_SUBCONTEXT(handle); + + /* Get videosink name */ + _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name); + if (!strcmp(videosink_name, "xvimagesink") || + !strcmp(videosink_name, "evaspixmapsink")) { + 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; } - - return bret; } -bool _mmcamcorder_commit_display_rect (MMHandleType handle, int attr_idx, const mmf_value_t *value) +bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const mmf_value_t *value) { - mmf_camcorder_t *hcamcorder= MMF_CAMCORDER( handle); - _MMCamcorderSubContext *sc = NULL; - int current_state = MM_CAMCORDER_STATE_NONE; - int bret = 0; - + int method = 0; char *videosink_name = NULL; - - sc = MMF_CAMCORDER_SUBCONTEXT(handle); - if (!sc) + + mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); + _MMCamcorderSubContext *sc = NULL; + + mmf_return_val_if_fail(handle, FALSE); + + /* check type */ + if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) { + _mmcam_dbg_err("invalid mode %d", hcamcorder->type); + return FALSE; + } + + /* check current state */ + current_state = _mmcamcorder_get_state(handle); + if (current_state < MM_CAMCORDER_STATE_READY) { + _mmcam_dbg_log("NOT initialized. this will be applied later"); return TRUE; - current_state = _mmcamcorder_get_state( handle); + } - if (current_state > MM_CAMCORDER_STATE_NULL) - { - if (sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst) - { - // Get videosink name - _mmcamcorder_conf_get_value_element_name( sc->VideosinkElement, &videosink_name ); - - if(strcmp(videosink_name, "xvimagesink") == 0) //only for xvimagesink - { - if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) - { - int err = 0; - int rectx, recty, rectw, recth; - int display_geometry_method = 0; - - err = mm_camcorder_get_attributes(handle, NULL, - MMCAM_DISPLAY_RECT_X, &rectx, - MMCAM_DISPLAY_RECT_Y, &recty, - MMCAM_DISPLAY_RECT_WIDTH, &rectw, - MMCAM_DISPLAY_RECT_HEIGHT, &recth, - MMCAM_DISPLAY_GEOMETRY_METHOD, &display_geometry_method, - NULL); - if (err < 0) - { - _mmcam_dbg_warn("Get display-geometry-method attrs fail. (%x)", err); - return FALSE; - } + sc = MMF_CAMCORDER_SUBCONTEXT(handle); - if (display_geometry_method == MM_DISPLAY_METHOD_CUSTOM_ROI) - { - int flags = MM_ATTRS_FLAG_NONE; - MMCamAttrsInfo info; - _mmcam_dbg_log("FRECT(x,y,w,h) = (%d,%d,%d,%d)", rectx, recty, rectw, recth); - switch(attr_idx) - { - case MM_CAM_DISPLAY_RECT_X: - mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_Y, &info); - flags |= info.flag; - memset(&info, 0x00, sizeof(info)); - mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info); - flags |= info.flag; - memset(&info, 0x00, sizeof(info)); - mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info); - flags |= info.flag; - - rectx = value->value.i_val; - break; - case MM_CAM_DISPLAY_RECT_Y: - mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info); - flags |= info.flag; - memset(&info, 0x00, sizeof(info)); - mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info); - flags |= info.flag; - - recty = value->value.i_val; - break; - case MM_CAM_DISPLAY_RECT_WIDTH: - mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info); - flags |= info.flag; + /* check current method */ + mm_camcorder_get_attributes(handle, NULL, + MMCAM_DISPLAY_GEOMETRY_METHOD, &method, + NULL); + if (method != MM_DISPLAY_METHOD_CUSTOM_ROI) { + _mmcam_dbg_log("current method[%d] is not supported rect", method); + return FALSE; + } - rectw = value->value.i_val; - break; - case MM_CAM_DISPLAY_RECT_HEIGHT: - recth = value->value.i_val; - break; - default: - _mmcam_dbg_err("Wrong attr_idx!"); - return FALSE; - } + /* Get videosink name */ + _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name); + if (!strcmp(videosink_name, "xvimagesink") || + !strcmp(videosink_name, "evaspixmapsink")) { + int rect_x = 0; + int rect_y = 0; + int rect_width = 0; + int rect_height = 0; + int flags = MM_ATTRS_FLAG_NONE; + MMCamAttrsInfo info; - if (!(flags & MM_ATTRS_FLAG_MODIFIED)) - { - _mmcam_dbg_log("RECT(x,y,w,h) = (%d,%d,%d,%d)", rectx, recty, rectw, recth); - - //Do we need to check all? - if(g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst)), "dst-roi-x")) - { - g_object_set (sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, - "dst-roi-x", rectx, - "dst-roi-y", recty, - "dst-roi-w", rectw, - "dst-roi-h", recth, - NULL); - } - } - } - } - } - bret = TRUE; + mm_camcorder_get_attributes(handle, NULL, + MMCAM_DISPLAY_RECT_X, &rect_x, + MMCAM_DISPLAY_RECT_Y, &rect_y, + MMCAM_DISPLAY_RECT_WIDTH, &rect_width, + MMCAM_DISPLAY_RECT_HEIGHT, &rect_height, + NULL); + switch (attr_idx) { + case MM_CAM_DISPLAY_RECT_X: + mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_Y, &info); + flags |= info.flag; + memset(&info, 0x00, sizeof(info)); + mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info); + flags |= info.flag; + memset(&info, 0x00, sizeof(info)); + mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info); + flags |= info.flag; + + rect_x = value->value.i_val; + break; + case MM_CAM_DISPLAY_RECT_Y: + mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info); + flags |= info.flag; + memset(&info, 0x00, sizeof(info)); + mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info); + flags |= info.flag; + + rect_y = value->value.i_val; + break; + case MM_CAM_DISPLAY_RECT_WIDTH: + mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info); + flags |= info.flag; + + rect_width = value->value.i_val; + break; + case MM_CAM_DISPLAY_RECT_HEIGHT: + rect_height = value->value.i_val; + break; + default: + _mmcam_dbg_err("Wrong attr_idx!"); + return FALSE; } - else - { - _mmcam_dbg_log("Videosink element is null"); - bret = FALSE; + + if (!(flags & MM_ATTRS_FLAG_MODIFIED)) { + _mmcam_dbg_log("RECT(x,y,w,h) = (%d,%d,%d,%d)", + rect_x, rect_y, rect_width, rect_height); + g_object_set(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, + "dst-roi-x", rect_x, + "dst-roi-y", rect_y, + "dst-roi-w", rect_width, + "dst-roi-h", rect_height, + NULL); } + + return TRUE; + } else { + _mmcam_dbg_warn("videosink[%s] does not support display rect.", videosink_name); + return FALSE; } - else - { - _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state); - bret = TRUE; - } - - return bret; } -bool _mmcamcorder_commit_display_scale (MMHandleType handle, int attr_idx, const mmf_value_t *value) +bool _mmcamcorder_commit_display_scale(MMHandleType handle, int attr_idx, const mmf_value_t *value) { - mmf_camcorder_t *hcamcorder= MMF_CAMCORDER( handle); - _MMCamcorderSubContext *sc = NULL; - int zoom = 0; int current_state = MM_CAMCORDER_STATE_NONE; - int bret = 0; - char *videosink_name = NULL; + GstElement *vs_element = NULL; + + mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); + _MMCamcorderSubContext *sc = NULL; + + mmf_return_val_if_fail(handle, FALSE); + + /* check type */ + if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) { + _mmcam_dbg_err("invalid mode %d", hcamcorder->type); + return FALSE; + } + + /* check current state */ + current_state = _mmcamcorder_get_state(handle); + if (current_state < MM_CAMCORDER_STATE_READY) { + _mmcam_dbg_log("NOT initialized. this will be applied later"); + return TRUE; + } sc = MMF_CAMCORDER_SUBCONTEXT(handle); - if (!sc) + + /* Get videosink name */ + _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name); + zoom = value->value.i_val; + if (!strcmp(videosink_name, "xvimagesink")) { + vs_element = sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst; + + MMCAMCORDER_G_OBJECT_SET(vs_element, "zoom", zoom + 1); + _mmcam_dbg_log("Set display zoom to %d", zoom + 1); + return TRUE; - current_state = _mmcamcorder_get_state( handle); + } else { + _mmcam_dbg_warn("videosink[%s] does not support scale", videosink_name); + return FALSE; + } +} - if( current_state > MM_CAMCORDER_STATE_NULL ) - { - if( hcamcorder->type != MM_CAMCORDER_MODE_AUDIO ) - { - if( sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst ) - { - // Get videosink name - _mmcamcorder_conf_get_value_element_name( sc->VideosinkElement, &videosink_name ); - - zoom = value->value.i_val; - if( !strcmp( videosink_name, "xvimagesink" )) - { - //xvimagesink - switch (zoom) - { - case MM_DISPLAY_SCALE_DEFAULT: - { - MMCAMCORDER_G_OBJECT_SET( sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "zoom", 1); +bool _mmcamcorder_commit_display_evas_do_scaling(MMHandleType handle, int attr_idx, const mmf_value_t *value) +{ + int current_state = MM_CAMCORDER_STATE_NONE; + int do_scaling = 0; + char *videosink_name = NULL; - _mmcam_dbg_log( "Set display zoom to default."); - break; - } - case MM_DISPLAY_SCALE_DOUBLE_LENGTH: - { - MMCAMCORDER_G_OBJECT_SET( sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "zoom", 2); + mmf_camcorder_t *hcamcorder= MMF_CAMCORDER( handle); + _MMCamcorderSubContext *sc = NULL; - _mmcam_dbg_log( "Set display zoom to double."); - break; - } - case MM_DISPLAY_SCALE_TRIPLE_LENGTH: - { - MMCAMCORDER_G_OBJECT_SET( sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "zoom", 3); + mmf_return_val_if_fail(handle, FALSE); - _mmcam_dbg_log( "Set display zoom to triple."); - break; - } - default: - { - _mmcam_dbg_warn( "Unsupported value."); - } - } - - bret = TRUE; - } - else if (!strcmp( videosink_name, "avsysvideosink" ) ) - { - //avsysvideosink - bret = TRUE; - } - else - { - _mmcam_dbg_warn( "videosink[%s] does not support 'zoom'.", videosink_name ); - bret = FALSE; - } - } - else - { - _mmcam_dbg_warn( "Videosink element is null, but current state is [%d]", current_state ); - bret = FALSE; - } - } - else - { - _mmcam_dbg_warn( "Current Mode is AUDIO only mode." ); - bret = FALSE; - } + /* check type */ + if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) { + _mmcam_dbg_err("invalid mode %d", hcamcorder->type); + return FALSE; } - else - { - _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state); - bret = TRUE; + + /* check current state */ + current_state = _mmcamcorder_get_state(handle); + if (current_state < MM_CAMCORDER_STATE_READY) { + _mmcam_dbg_log("NOT initialized. this will be applied later"); + return TRUE; } - return bret; + sc = MMF_CAMCORDER_SUBCONTEXT(handle); + + do_scaling = value->value.i_val; + + /* Get videosink name */ + _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name); + if (!strcmp(videosink_name, "evaspixmapsink")) { + MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "origin-size", !do_scaling); + _mmcam_dbg_log("Set origin-size to %d", !(value->value.i_val)); + return TRUE; + } else { + _mmcam_dbg_warn("videosink[%s] does not support scale", videosink_name); + return FALSE; + } } bool _mmcamcorder_commit_strobe (MMHandleType handle, int attr_idx, const mmf_value_t *value) { - bool bret = FALSE; - _MMCamcorderSubContext* sc = NULL; - int strobe_type, mslVal, newVal, cur_value; - int current_state = MM_CAMCORDER_STATE_NONE; + bool bret = FALSE; + _MMCamcorderSubContext *sc = NULL; + int strobe_type, mslVal, newVal, cur_value; + int current_state = MM_CAMCORDER_STATE_NONE; - sc = MMF_CAMCORDER_SUBCONTEXT( handle ); + sc = MMF_CAMCORDER_SUBCONTEXT(handle); if (!sc) return TRUE; diff --git a/src/mm_camcorder_exifinfo.c b/src/mm_camcorder_exifinfo.c index f3e01fc..615fe66 100644 --- a/src/mm_camcorder_exifinfo.c +++ b/src/mm_camcorder_exifinfo.c @@ -215,45 +215,48 @@ mm_exif_set_exif_to_info (mm_exif_info_t *info, ExifData *exif) int mm_exif_set_add_entry (ExifData *exif, ExifIfd ifd, ExifTag tag,ExifFormat format,unsigned long components,unsigned char* data) { -// mmf_debug (MMF_DEBUG_LOG, "%s()\n", __func__); - ExifData *ed = (ExifData *)exif; - ExifEntry *e = NULL; + /*mmf_debug (MMF_DEBUG_LOG, "%s()\n", __func__);*/ + ExifData *ed = (ExifData *)exif; + ExifEntry *e = NULL; - if(exif==NULL || format<=0 || components<=0 || data==NULL) - { - mmf_debug (MMF_DEBUG_ERROR,"[%05d][%s] invalid argument exif=%p format=%d, components=%lu data=%p!\n", __LINE__, __func__,exif,format,components,data); + if (exif == NULL || format <= 0 || components <= 0 || data == NULL) { + mmf_debug(MMF_DEBUG_ERROR,"[%05d][%s] invalid argument exif=%p format=%d, components=%lu data=%p!\n", + __LINE__, __func__,exif,format,components,data); return MM_ERROR_CAMCORDER_INVALID_ARGUMENT; } + /*remove same tag in EXIF*/ - exif_content_remove_entry (ed->ifd[ifd], exif_content_get_entry(ed->ifd[ifd], tag)); + exif_content_remove_entry(ed->ifd[ifd], exif_content_get_entry(ed->ifd[ifd], tag)); + /*create new tag*/ - e = exif_entry_new (); - if(e==NULL) - { - mmf_debug (MMF_DEBUG_ERROR,"[%05d][%s] entry create error!\n", __LINE__, __func__); + e = exif_entry_new(); + if (e == NULL) { + mmf_debug(MMF_DEBUG_ERROR,"[%05d][%s] entry create error!\n", __LINE__, __func__); return MM_ERROR_CAMCORDER_LOW_MEMORY; } - exif_entry_initialize (e, tag); - e->tag = tag; - e->format = format; - e->components = components; + exif_entry_initialize(e, tag); - if(e->size==0) - { - e->data=NULL; - e->data=malloc(exif_format_get_size(format)*e->components); - if(!e->data) - { + e->tag = tag; + e->format = format; + e->components = components; + + if (e->size == 0) { + e->data = NULL; + e->data = malloc(exif_format_get_size(format) * e->components); + if (!e->data) { exif_entry_unref(e); return MM_ERROR_CAMCORDER_LOW_MEMORY; } - if(format==EXIF_FORMAT_ASCII) - memset (e->data, '\0', exif_format_get_size(format)*e->components); + + if (format == EXIF_FORMAT_ASCII) { + memset(e->data, '\0', exif_format_get_size(format) * e->components); + } } - e->size = exif_format_get_size(format)*e->components; + + e->size = exif_format_get_size(format) * e->components; memcpy(e->data,data,e->size); - exif_content_add_entry (ed->ifd[ifd], e); + exif_content_add_entry(ed->ifd[ifd], e); exif_entry_unref(e); return MM_ERROR_NONE; @@ -270,64 +273,63 @@ mm_exif_set_add_entry (ExifData *exif, ExifIfd ifd, ExifTag tag,ExifFormat forma int mm_exif_create_exif_info (mm_exif_info_t **info) { - mm_exif_info_t *x = NULL; + mm_exif_info_t *x = NULL; #if (MM_EXIFINFO_USE_BINARY_EXIFDATA == 0) - ExifData *ed = NULL; - unsigned char *eb = NULL; - unsigned int ebs; + ExifData *ed = NULL; + unsigned char *eb = NULL; + unsigned int ebs; #endif - mmf_debug (MMF_DEBUG_LOG,"[%05d][%s]\n", __LINE__, __func__); - x = malloc (sizeof (mm_exif_info_t)); - if(!x) - { - mmf_debug (MMF_DEBUG_ERROR,"[%05d][%s]malloc error\n", __LINE__, __func__); + if (!info) { + mmf_debug(MMF_DEBUG_ERROR,"[%05d][%s] NULL pointer\n", __LINE__, __func__); + return MM_ERROR_CAMCORDER_INVALID_ARGUMENT; + } + + x = malloc(sizeof(mm_exif_info_t)); + if (!x) { + mmf_debug(MMF_DEBUG_ERROR,"[%05d][%s]malloc error\n", __LINE__, __func__); return MM_ERROR_CAMCORDER_LOW_MEMORY; - } + } #if MM_EXIFINFO_USE_BINARY_EXIFDATA - x->data=NULL; - x->data = malloc (_EXIF_BIN_SIZE_); - if(!x->data) - { - mmf_debug (MMF_DEBUG_ERROR,"[%05d][%s]malloc error\n", __LINE__, __func__); + x->data = NULL; + x->data = malloc(_EXIF_BIN_SIZE_); + if (!x->data) { + mmf_debug(MMF_DEBUG_ERROR,"[%05d][%s]malloc error\n", __LINE__, __func__); free(x); return MM_ERROR_CAMCORDER_LOW_MEMORY; - } - memcpy (x->data, g_exif_bin, _EXIF_BIN_SIZE_); + } + memcpy(x->data, g_exif_bin, _EXIF_BIN_SIZE_); x->size = _EXIF_BIN_SIZE_; #else - ed = exif_data_new (); - if(!ed ) - { - mmf_debug (MMF_DEBUG_ERROR,"[%05d][%s]exif data new error\n", __LINE__, __func__); + ed = exif_data_new(); + if (!ed) { + mmf_debug(MMF_DEBUG_ERROR,"[%05d][%s]exif data new error\n", __LINE__, __func__); return MM_ERROR_CAMCORDER_LOW_MEMORY; - } - - exif_data_set_byte_order (ed, EXIF_BYTE_ORDER_INTEL); - exif_data_set_data_type (ed, EXIF_DATA_TYPE_COMPRESSED); - exif_data_set_option (ed, EXIF_DATA_OPTION_FOLLOW_SPECIFICATION); - - exif_data_fix (ed); - - exif_data_save_data (ed, &eb, &ebs); - if(eb==NULL) - { - mmf_debug (MMF_DEBUG_ERROR,"[%05d][%s]exif_data_save_data error\n", __LINE__, __func__); + } + + exif_data_set_byte_order(ed, EXIF_BYTE_ORDER_INTEL); + exif_data_set_data_type(ed, EXIF_DATA_TYPE_COMPRESSED); + exif_data_set_option(ed, EXIF_DATA_OPTION_FOLLOW_SPECIFICATION); + + exif_data_fix(ed); + + exif_data_save_data(ed, &eb, &ebs); + if (eb == NULL) { + mmf_debug(MMF_DEBUG_ERROR,"[%05d][%s]exif_data_save_data error\n", __LINE__, __func__); free(x->data); free(x); - exif_data_unref (ed); + exif_data_unref(ed); return MM_ERROR_CAMCORDER_INTERNAL; - } - exif_data_unref (ed); + } + exif_data_unref(ed); x->data = eb; x->size = ebs; #endif - *info = x; - //mmf_debug (MMF_DEBUG_LOG, "%s() Data:%p Size:%d\n", __func__, x->data, x->size); + mmf_debug(MMF_DEBUG_LOG, "%s() Data:%p Size:%d\n", __func__, x->data, x->size); return MM_ERROR_NONE; } @@ -373,7 +375,7 @@ mm_exif_add_thumbnail_info (mm_exif_info_t *info, void *thumbnail, int width, in /* get ExifData from info*/ ed = mm_exif_get_exif_from_info(info); - ed->data=thumbnail; + ed->data = thumbnail; ed->size = len; /* set thumbnail data */ @@ -405,7 +407,7 @@ mm_exif_add_thumbnail_info (mm_exif_info_t *info, void *thumbnail, int width, in if (ret != MM_ERROR_NONE) { goto exit; } - + ed->data = NULL; ed->size = 0; exif_data_unref (ed); diff --git a/src/mm_camcorder_gstcommon.c b/src/mm_camcorder_gstcommon.c index 178f60d..a067767 100644 --- a/src/mm_camcorder_gstcommon.c +++ b/src/mm_camcorder_gstcommon.c @@ -164,6 +164,7 @@ int _mmcamcorder_create_videosrc_bin(MMHandleType handle) int codectype = 0; int capture_width = 0; int capture_height = 0; + int capture_jpg_quality = 100; int anti_shake = 0; char *videosrc_name = NULL; char *err_name = NULL; @@ -214,6 +215,7 @@ int _mmcamcorder_create_videosrc_bin(MMHandleType handle) MMCAM_CAPTURE_WIDTH, &capture_width, MMCAM_CAPTURE_HEIGHT, &capture_height, MMCAM_IMAGE_ENCODER, &codectype, + MMCAM_IMAGE_ENCODER_QUALITY, &capture_jpg_quality, "camera-hold-af-after-capturing", &hold_af, NULL); if (err != MM_ERROR_NONE) { @@ -248,9 +250,10 @@ int _mmcamcorder_create_videosrc_bin(MMHandleType handle) /* init high-speed-fps */ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "high-speed-fps", 0); - /* set capture size and flip setting which were set before mm_camcorder_realize */ + /* set capture size, quality and flip setting which were set before mm_camcorder_realize */ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", capture_width); 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-jpg-quality", capture_jpg_quality); _mmcamcorder_set_videosrc_hflip(handle, hflip); _mmcamcorder_set_videosrc_vflip(handle, vflip); @@ -1498,6 +1501,7 @@ int _mmcamcorder_videosink_window_set(MMHandleType handle, type_element* Videosi int origin_size = 0; int zoom_attr = 0; int zoom_level = 0; + int do_scaling = FALSE; int *overlay = NULL; gulong xid; char *err_name = NULL; @@ -1532,20 +1536,17 @@ int _mmcamcorder_videosink_window_set(MMHandleType handle, type_element* Videosi MMCAM_DISPLAY_MODE, &display_mode, MMCAM_DISPLAY_GEOMETRY_METHOD, &display_geometry_method, MMCAM_DISPLAY_SCALE, &zoom_attr, + MMCAM_DISPLAY_EVAS_DO_SCALING, &do_scaling, NULL); ); - if (err != MM_ERROR_NONE) { - _mmcam_dbg_warn("Get display attrs fail. (%s:%x)", err_name, err); - SAFE_FREE(err_name); - return err; - } _mmcam_dbg_log("(overlay=%p, size=%d)", overlay, size); _mmcamcorder_conf_get_value_element_name(VideosinkElement, &videosink_name); - /* Set xid */ - if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) { + /* Set display handle */ + if (!strcmp(videosink_name, "xvimagesink") || + !strcmp(videosink_name, "ximagesink")) { if (overlay) { xid = *overlay; _mmcam_dbg_log("xid = %lu )", xid); @@ -1557,12 +1558,14 @@ int _mmcamcorder_videosink_window_set(MMHandleType handle, type_element* Videosi _mmcam_dbg_log("%s set: display_geometry_method[%d],origin-size[%d],visible[%d],rotate[enum:%d]", videosink_name, display_geometry_method, origin_size, visible, rotation); - } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) { + } else if (!strcmp(videosink_name, "evasimagesink") || + !strcmp(videosink_name, "evaspixmapsink")) { _mmcam_dbg_log("videosink : %s, handle : %p", videosink_name, overlay); if (overlay) { - MMCAMCORDER_G_OBJECT_SET( vsink, "evas-object", overlay ); + MMCAMCORDER_G_OBJECT_SET(vsink, "evas-object", overlay); + MMCAMCORDER_G_OBJECT_SET(vsink, "origin-size", !do_scaling); } else { - _mmcam_dbg_err("Evas Object pointer is NULL"); + _mmcam_dbg_err("display handle(eavs object) is NULL"); return MM_ERROR_CAMCORDER_INVALID_ARGUMENT; } } else { diff --git a/src/mm_camcorder_internal.c b/src/mm_camcorder_internal.c index 70e3298..5667971 100644 --- a/src/mm_camcorder_internal.c +++ b/src/mm_camcorder_internal.c @@ -39,7 +39,6 @@ #include <mm_session.h> #include <mm_session_private.h> #include <audio-session-manager.h> -#include <vconf.h> /*--------------------------------------------------------------------------------------- | GLOBAL VARIABLE DEFINITIONS for internal | @@ -97,6 +96,7 @@ int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info) char *ConfCtrlFile = NULL; mmf_camcorder_t *hcamcorder = NULL; ASM_resource_t mm_resource = ASM_RESOURCE_NONE; + type_element *EvasSurfaceElement = NULL; _mmcam_dbg_log("Entered"); @@ -183,8 +183,8 @@ int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info) goto _ERR_AUDIO_BLOCKED; } - __ta__(" _mmcamcorder_alloc_attribute", - hcamcorder->attributes= _mmcamcorder_alloc_attribute((MMHandleType)hcamcorder, info); + __ta__(" _mmcamcorder_alloc_attribute", + hcamcorder->attributes = _mmcamcorder_alloc_attribute((MMHandleType)hcamcorder, info); ); if (!(hcamcorder->attributes)) { _mmcam_dbg_err("_mmcamcorder_create::alloc attribute error."); @@ -332,6 +332,30 @@ int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info) _mmcamcorder_create_command_loop((MMHandleType)hcamcorder); } + /* Get videosink name for evas surface */ + _mmcamcorder_conf_get_element(hcamcorder->conf_main, + CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT, + "VideosinkElementEvas", + &EvasSurfaceElement); + if (EvasSurfaceElement) { + int attr_index = 0; + char *evassink_name = NULL; + mmf_attribute_t *item_evassink_name = NULL; + mmf_attrs_t *attrs = MMF_CAMCORDER_ATTRS(hcamcorder); + + _mmcamcorder_conf_get_value_element_name(EvasSurfaceElement, &evassink_name); + mm_attrs_get_index((MMHandleType)attrs, MMCAM_DISPLAY_EVAS_SURFACE_SINK, &attr_index); + item_evassink_name = &attrs->items[attr_index]; + mmf_attribute_set_string(item_evassink_name, evassink_name, strlen(evassink_name)); + mmf_attribute_commit(item_evassink_name); + + _mmcam_dbg_log("Evassink name : %d", evassink_name); + } + + /* get shutter sound policy */ + vconf_get_int(VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY, &hcamcorder->shutter_sound_policy); + _mmcam_dbg_log("current shutter sound policy : %d", hcamcorder->shutter_sound_policy); + /* Set initial state */ _mmcamcorder_set_state((MMHandleType)hcamcorder, MM_CAMCORDER_STATE_NULL); _mmcam_dbg_log("_mmcamcorder_set_state"); @@ -674,8 +698,7 @@ int _mmcamcorder_realize(MMHandleType handle) _mmcamcorder_conf_get_element(hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT, videosink_element_type, - &hcamcorder->sub_context->VideosinkElement ); - + &hcamcorder->sub_context->VideosinkElement); free(videosink_element_type); videosink_element_type = NULL; } else { diff --git a/src/mm_camcorder_sound.c b/src/mm_camcorder_sound.c index 3780c35..05d1572 100644 --- a/src/mm_camcorder_sound.c +++ b/src/mm_camcorder_sound.c @@ -36,9 +36,17 @@ | LOCAL VARIABLE DEFINITIONS for internal | ---------------------------------------------------------------------------------------*/ #define SAMPLE_SOUND_NAME "camera-shutter" -#define SAMPLE_SOUND_VOLUME 65535 +#define SAMPLE_SOUND_VOLUME_MAX 65535 #define SAMPLE_SOUND_RATE 44100 #define DEFAULT_ACTIVE_DEVICE -1 +#define VOLUME_LEVEL_MIN 0 +#define VOLUME_LEVEL_MAX 15 + +enum { + SOUND_DEVICE_TYPE_SPEAKER, + SOUND_DEVICE_TYPE_HEADSET, + SOUND_DEVICE_TYPE_NUM +}; /*--------------------------------------------------------------------------------------- | LOCAL FUNCTION PROTOTYPES: | @@ -160,13 +168,9 @@ gboolean _mmcamcorder_sound_init(MMHandleType handle) ret = mm_camcorder_get_attributes((MMHandleType)hcamcorder, NULL, "capture-sound-enable", &sound_enable, NULL); - if (ret == MM_ERROR_NONE) { - _mmcam_dbg_log("Capture sound enable %d", sound_enable); - if (sound_enable == FALSE) { - return TRUE; - } - } else { - _mmcam_dbg_warn("capture-sound-enable get FAILED.[%x]", ret); + _mmcam_dbg_log("Capture sound enable %d", sound_enable); + if (!sound_enable) { + return TRUE; } info = &(hcamcorder->snd_info); @@ -176,7 +180,7 @@ gboolean _mmcamcorder_sound_init(MMHandleType handle) if (info->state > _MMCAMCORDER_SOUND_STATE_NONE) { _mmcam_dbg_warn("already initialized [%d]", info->state); pthread_mutex_unlock(&(info->open_mutex)); - return FALSE; + return TRUE; } #ifdef _MMCAMCORDER_UPLOAD_SAMPLE @@ -203,33 +207,24 @@ gboolean _mmcamcorder_sound_init(MMHandleType handle) _mmcam_dbg_err("Failed to open sound file"); goto SOUND_INIT_ERROR; } - - /* open PCM handle and set session */ - __ta__(" mm_sound_pcm_play_open", - ret = mm_sound_pcm_play_open_ex(&(info->handle), info->sfinfo.samplerate, - (info->sfinfo.channels == 1) ? MMSOUND_PCM_MONO : MMSOUND_PCM_STEREO, - MMSOUND_PCM_S16_LE, VOLUME_TYPE_FIXED, ASM_EVENT_EXCLUSIVE_MMSOUND); - ); - if (ret < 0) { - /* error */ - _mmcam_dbg_err("mm_sound_pcm_play_open failed [%x]", ret); - goto SOUND_INIT_ERROR; - } -#else /* _MMCAMCORDER_UPLOAD_SAMPLE */ - /* open PCM handle and set session */ - __ta__(" mm_sound_pcm_play_open", - ret = mm_sound_pcm_play_open_ex(&(info->handle), SAMPLE_SOUND_RATE, - MMSOUND_PCM_STEREO, MMSOUND_PCM_S16_LE, - VOLUME_TYPE_FIXED, ASM_EVENT_EXCLUSIVE_MMSOUND); - ); - if (ret < 0) { - /* error */ - _mmcam_dbg_err("mm_sound_pcm_play_open failed [%x]", ret); - goto SOUND_INIT_ERROR; - } #endif /* _MMCAMCORDER_UPLOAD_SAMPLE */ - _mmcam_dbg_log("mm_sound_pcm_play_open done"); + if (hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) { + /* open PCM handle and set session */ + __ta__(" mm_sound_pcm_play_open", + ret = mm_sound_pcm_play_open_ex(&(info->handle), SAMPLE_SOUND_RATE, + MMSOUND_PCM_STEREO, MMSOUND_PCM_S16_LE, + VOLUME_TYPE_FIXED, ASM_EVENT_EXCLUSIVE_MMSOUND); + ); + if (ret < 0) { + _mmcam_dbg_err("mm_sound_pcm_play_open failed [%x]", ret); + goto SOUND_INIT_ERROR; + } + + _mmcam_dbg_log("mm_sound_pcm_play_open and session PLAYING done."); + } else { + _mmcam_dbg_log("do not register session to pause another playing session"); + } /** * Init Pulseaudio thread @@ -309,26 +304,34 @@ gboolean _mmcamcorder_sound_init(MMHandleType handle) pa_threaded_mainloop_wait(info->pulse_mainloop); pa_threaded_mainloop_unlock (info->pulse_mainloop); -#endif /* _MMCAMCORDER_UPLOAD_SAMPLE */ - /* backup current route */ - info->active_out_backup = DEFAULT_ACTIVE_DEVICE; - - ret = mm_sound_get_active_device(&device_in, &device_out); - if (ret != MM_ERROR_NONE) { - _mmcam_dbg_err("mm_sound_get_active_device failed [%x]. skip sound play.", ret); - goto SOUND_INIT_ERROR; - } + /* close sndfile */ + sf_close(info->infile); + info->infile = NULL; +#endif /* _MMCAMCORDER_UPLOAD_SAMPLE */ - _mmcam_dbg_log("current out [%x]", device_out); + if (hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) { + /* backup current route */ + info->active_out_backup = DEFAULT_ACTIVE_DEVICE; - if (device_out != MM_SOUND_DEVICE_OUT_SPEAKER) { - ret = mm_sound_set_active_route (MM_SOUND_ROUTE_OUT_SPEAKER); + __ta__(" mm_sound_get_active_device", + ret = mm_sound_get_active_device(&device_in, &device_out); + ); if (ret != MM_ERROR_NONE) { - _mmcam_dbg_err("mm_sound_set_active_route failed [%x]. skip sound play.", ret); + _mmcam_dbg_err("mm_sound_get_active_device failed [%x]. skip sound play.", ret); goto SOUND_INIT_ERROR; } - info->active_out_backup = device_out; + + _mmcam_dbg_log("current out [%x]", device_out); + + if (device_out != MM_SOUND_DEVICE_OUT_SPEAKER) { + ret = mm_sound_set_active_route (MM_SOUND_ROUTE_OUT_SPEAKER); + if (ret != MM_ERROR_NONE) { + _mmcam_dbg_err("mm_sound_set_active_route failed [%x]. skip sound play.", ret); + goto SOUND_INIT_ERROR; + } + info->active_out_backup = device_out; + } } info->state = _MMCAMCORDER_SOUND_STATE_INIT; @@ -395,6 +398,11 @@ gboolean _mmcamcorder_sound_play(MMHandleType handle) { int ret = 0; int sound_enable = TRUE; + int set_volume = SAMPLE_SOUND_VOLUME_MAX; + int volume_table[SOUND_DEVICE_TYPE_NUM][VOLUME_LEVEL_MAX+1] = { + {0, 19000, 22323, 25647, 28971, 32295, 35619, 38943, 42267, 45591, 48915, 52239, 55563, 58887, 62211, 65535}, /* SPEAKER */ + {0, 20480, 23698, 26916, 30135, 33353, 36571, 39789, 43008, 46226, 49444, 52662, 55880, 59099, 62317, 65535} /* HEADSET */ + }; mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); SOUND_INFO *info = NULL; @@ -406,13 +414,9 @@ gboolean _mmcamcorder_sound_play(MMHandleType handle) ret = mm_camcorder_get_attributes((MMHandleType)hcamcorder, NULL, "capture-sound-enable", &sound_enable, NULL); - if (ret == MM_ERROR_NONE) { - _mmcam_dbg_log("Capture sound enable %d", sound_enable); - if (sound_enable == FALSE) { - return TRUE; - } - } else { - _mmcam_dbg_warn("capture-sound-enable get FAILED.[%x]", ret); + _mmcam_dbg_log("Capture sound enable %d", sound_enable); + if (!sound_enable) { + return TRUE; } info = &(hcamcorder->snd_info); @@ -425,13 +429,55 @@ gboolean _mmcamcorder_sound_play(MMHandleType handle) return FALSE; } + /* get volume level and set volume */ + if (hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_OFF) { + unsigned int volume_level = 0; + gboolean sound_status = FALSE; + mm_sound_device_in device_in; + mm_sound_device_out device_out; + int device_type = SOUND_DEVICE_TYPE_SPEAKER; + + /* get sound status */ + __ta__(" GET:VCONFKEY_SETAPPL_SOUND_STATUS_BOOL", + vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_status); + ); + /* get sound path */ + __ta__(" mm_sound_get_active_device", + mm_sound_get_active_device(&device_in, &device_out); + ); + + _mmcam_dbg_log("sound status %d, device out %x", sound_status, device_out); + + if (device_out != MM_SOUND_DEVICE_OUT_SPEAKER) { + device_type = SOUND_DEVICE_TYPE_HEADSET; + } + + if (sound_status || device_out != MM_SOUND_DEVICE_OUT_SPEAKER) { + mm_sound_volume_get_value(VOLUME_TYPE_MEDIA, &volume_level); + _mmcam_dbg_log("current volume level %d", volume_level); + } else { + volume_level = 0; + _mmcam_dbg_log("current state is SILENT mode and SPEAKER output"); + } + + if (volume_level > VOLUME_LEVEL_MAX) { + _mmcam_dbg_warn("invalid volume level. set max"); + set_volume = volume_table[device_type][VOLUME_LEVEL_MAX]; + } else { + set_volume = volume_table[device_type][volume_level]; + } + } + + _mmcam_dbg_log("shutter sound policy %d, volume %d", + hcamcorder->shutter_sound_policy, set_volume); + _mmcam_dbg_log("Play start"); __ta__(" pa_context_play_sample", pulse_op = pa_context_play_sample(info->pulse_context, SAMPLE_SOUND_NAME, NULL, - SAMPLE_SOUND_VOLUME, + set_volume, NULL, NULL); ); @@ -470,22 +516,24 @@ gboolean _mmcamcorder_sound_finalize(MMHandleType handle) return TRUE; } - /** - * Restore route - */ - _mmcam_dbg_log("restore route"); - if (info->active_out_backup != DEFAULT_ACTIVE_DEVICE) { - ret = mm_sound_get_active_device(&device_in, &device_out); - if (ret != MM_ERROR_NONE) { - _mmcam_dbg_err("mm_sound_get_active_device failed [%x]. skip sound play.", ret); - } + if (hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) { + /** + * Restore route + */ + _mmcam_dbg_log("restore route"); + if (info->active_out_backup != DEFAULT_ACTIVE_DEVICE) { + ret = mm_sound_get_active_device(&device_in, &device_out); + if (ret != MM_ERROR_NONE) { + _mmcam_dbg_err("mm_sound_get_active_device failed [%x]. skip sound play.", ret); + } - _mmcam_dbg_log("current out [%x]", device_out); + _mmcam_dbg_log("current out [%x]", device_out); - if (device_out != info->active_out_backup) { - ret = mm_sound_set_active_route (info->active_out_backup); - if (ret != MM_ERROR_NONE) { - _mmcam_dbg_err("mm_sound_set_active_route failed [%x]. skip sound play.", ret); + if (device_out != info->active_out_backup) { + ret = mm_sound_set_active_route (info->active_out_backup); + if (ret != MM_ERROR_NONE) { + _mmcam_dbg_err("mm_sound_set_active_route failed [%x]. skip sound play.", ret); + } } } } @@ -543,9 +591,11 @@ gboolean _mmcamcorder_sound_finalize(MMHandleType handle) pthread_mutex_destroy(&(info->play_mutex)); pthread_cond_destroy(&(info->play_cond)); - /* close PCM */ - mm_sound_pcm_play_close(info->handle); - info->handle = 0; + if (hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) { + /* close PCM */ + mm_sound_pcm_play_close(info->handle); + info->handle = 0; + } pthread_mutex_unlock(&(info->open_mutex)); @@ -574,23 +624,19 @@ void _mmcamcorder_sound_solo_play(MMHandleType handle, const char* filepath, gbo mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); int sound_handle = 0; - int ret = 0; + int ret = MM_ERROR_NONE; int sound_enable = TRUE; mmf_return_if_fail(filepath && hcamcorder); - _mmcam_dbg_log( "START" ); + _mmcam_dbg_log("START"); ret = mm_camcorder_get_attributes((MMHandleType)hcamcorder, NULL, "capture-sound-enable", &sound_enable, NULL); - if (ret == MM_ERROR_NONE) { - _mmcam_dbg_log("Capture sound enable %d", sound_enable); - if (sound_enable == FALSE) { - return; - } - } else { - _mmcam_dbg_warn("capture-sound-enable get FAILED.[%x]", ret); + _mmcam_dbg_log("Capture sound enable %d", sound_enable); + if (!sound_enable) { + return; } ret = pthread_mutex_trylock(&(hcamcorder->sound_lock)); @@ -599,10 +645,29 @@ void _mmcamcorder_sound_solo_play(MMHandleType handle, const char* filepath, gbo return; } - __ta__("CAPTURE SOUND:mm_sound_play_loud_solo_sound", - ret = mm_sound_play_loud_solo_sound(filepath, VOLUME_TYPE_FIXED, __solo_sound_callback, - (void*)hcamcorder, &sound_handle); - ); + if (hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) { + __ta__("CAPTURE SOUND:mm_sound_play_loud_solo_sound", + ret = mm_sound_play_loud_solo_sound(filepath, VOLUME_TYPE_FIXED, __solo_sound_callback, + (void*)hcamcorder, &sound_handle); + ); + } else { + gboolean sound_status = FALSE; + mm_sound_device_in device_in; + mm_sound_device_out device_out; + + /* get sound status */ + vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_status); + /* get sound path */ + mm_sound_get_active_device(&device_in, &device_out); + + _mmcam_dbg_log("sound status %d, device out %x", sound_status, device_out); + + if (sound_status || device_out != MM_SOUND_DEVICE_OUT_SPEAKER) { + __ta__("CAPTURE SOUND:mm_sound_play_sound", + ret = mm_sound_play_sound(filepath, VOLUME_TYPE_MEDIA, __solo_sound_callback, (void*)hcamcorder, &sound_handle); + ); + } + } if (ret != MM_ERROR_NONE) { _mmcam_dbg_err( "Capture sound play FAILED.[%x]", ret ); } else { diff --git a/src/mm_camcorder_stillshot.c b/src/mm_camcorder_stillshot.c index e75a400..1069918 100644 --- a/src/mm_camcorder_stillshot.c +++ b/src/mm_camcorder_stillshot.c @@ -264,7 +264,6 @@ int _mmcamcorder_image_cmd_capture(MMHandleType handle) int height = 0; int fps = 0; int cap_format = MM_PIXEL_FORMAT_NV12; - int cap_jpeg_quality = 0; int image_encoder = MM_IMAGE_CODEC_JPEG; int strobe_mode = MM_CAMCORDER_STROBE_MODE_OFF; unsigned int cap_fourcc = 0; @@ -315,7 +314,6 @@ int _mmcamcorder_image_cmd_capture(MMHandleType handle) info->capturing = TRUE; mm_camcorder_get_attributes(handle, &err_name, - MMCAM_IMAGE_ENCODER_QUALITY, &cap_jpeg_quality, MMCAM_IMAGE_ENCODER, &image_encoder, MMCAM_CAMERA_WIDTH, &width, MMCAM_CAMERA_HEIGHT, &height, @@ -391,13 +389,12 @@ int _mmcamcorder_image_cmd_capture(MMHandleType handle) } } - _mmcam_dbg_log("capture format (%d), jpeg quality (%d)", cap_format, cap_jpeg_quality); + _mmcam_dbg_log("capture format (%d)", cap_format); /* Note: width/height of capture is set in commit function of attribute or in create function of pipeline */ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-fourcc", cap_fourcc); MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-interval", info->interval); MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-count", info->count); - MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", cap_jpeg_quality); MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", info->hdr_capture_mode); if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) { @@ -801,7 +798,6 @@ int _mmcamcorder_image_cmd_capture_with_encbin(MMHandleType handle) info->capturing = TRUE; ret = mm_camcorder_get_attributes(handle, &err_name, - MMCAM_IMAGE_ENCODER_QUALITY, &cap_jpeg_quality, MMCAM_IMAGE_ENCODER, &image_encoder, MMCAM_CAMERA_WIDTH, &width, MMCAM_CAMERA_HEIGHT, &height, @@ -837,14 +833,11 @@ int _mmcamcorder_image_cmd_capture_with_encbin(MMHandleType handle) if (!strcmp(videosrc_name, "avsysvideosrc") || !strcmp(videosrc_name, "camerasrc")) { cap_fourcc = _mmcamcorder_get_fourcc(cap_format, image_encoder, hcamcorder->use_zero_copy_format); - _mmcam_dbg_log("capture format (%d), jpeg quality (%d)", cap_format, cap_jpeg_quality); + _mmcam_dbg_log("capture format (%d)", cap_format); MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-fourcc", cap_fourcc); MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-interval", info->interval); - MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", info->width); - MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", info->height); MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-count", info->count); - MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", cap_jpeg_quality); if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) { _mmcam_dbg_err("Can't cast Video source into camera control."); @@ -858,6 +851,10 @@ int _mmcamcorder_image_cmd_capture_with_encbin(MMHandleType handle) int set_width = 0; int set_height = 0; + mm_camcorder_get_attributes(handle, &err_name, + MMCAM_IMAGE_ENCODER_QUALITY, &cap_jpeg_quality, + NULL); + if (UseCaptureMode) { if (width != MMFCAMCORDER_HIGHQUALITY_WIDTH || height != MMFCAMCORDER_HIGHQUALITY_HEIGHT) { need_change = 1; @@ -1249,7 +1246,7 @@ void __mmcamcorder_init_stillshot_info (MMHandleType handle) } -gboolean __mmcamcorder_capture_save_exifinfo(MMHandleType handle, MMCamcorderCaptureDataType *original, MMCamcorderCaptureDataType *thumbnail) +int __mmcamcorder_capture_save_exifinfo(MMHandleType handle, MMCamcorderCaptureDataType *original, MMCamcorderCaptureDataType *thumbnail) { int ret = MM_ERROR_NONE; unsigned char *data = NULL; @@ -1263,99 +1260,45 @@ gboolean __mmcamcorder_capture_save_exifinfo(MMHandleType handle, MMCamcorderCap if (!original || original->data == NULL || original->length == 0) { _mmcam_dbg_err("original=%p, data=%p, length=%d", original, original->data, original->length); - return FALSE; + return MM_ERROR_CAMCORDER_INVALID_ARGUMENT; } else { /* original is input/output param. save original values to local var. */ data = original->data; datalen = original->length; } - /* exif 090227 */ - __ta__(" mm_exif_create_exif_info", - ret = mm_exif_create_exif_info(&(hcamcorder->exif_info)); - ); - if (hcamcorder->exif_info == NULL || ret != MM_ERROR_NONE) { - _MMCamcorderMsgItem msg; - - msg.id = MM_MESSAGE_CAMCORDER_ERROR; - msg.param.code = ret; - _mmcamcroder_send_message(handle, &msg); - - _mmcam_dbg_err("Failed to create exif_info [%x]", ret); - return FALSE; - } - - /* add basic exif info */ - _mmcam_dbg_log("add basic exif info"); - __ta__(" __mmcamcorder_set_exif_basic_info", - ret = __mmcamcorder_set_exif_basic_info(handle, original); - ); - if (ret != MM_ERROR_NONE) { - _MMCamcorderMsgItem msg; - - msg.id = MM_MESSAGE_CAMCORDER_ERROR; - msg.param.code = ret; - _mmcamcroder_send_message(handle, &msg); - - _mmcam_dbg_err("Failed to set_exif_basic_info [%x]", ret); - } - - if (thumbnail != NULL) { - int bthumbnail = TRUE; - - /* check whether thumbnail should be included */ - mm_camcorder_get_attributes(handle, NULL, "capture-thumbnail", &bthumbnail, NULL); - - if (thumbnail->data && thumbnail->length >0 && bthumbnail) { + if (thumbnail) { + if (thumbnail->data && thumbnail->length > 0) { _mmcam_dbg_log("thumbnail is added!thumbnail->data=%p thumbnail->width=%d ,thumbnail->height=%d", thumbnail->data, thumbnail->width, thumbnail->height); /* add thumbnail exif info */ __ta__(" mm_exif_add_thumbnail_info", - ret = mm_exif_add_thumbnail_info(hcamcorder->exif_info, thumbnail->data,thumbnail->width, thumbnail->height, thumbnail->length); + ret = mm_exif_add_thumbnail_info(hcamcorder->exif_info, + thumbnail->data, + thumbnail->width, + thumbnail->height, + thumbnail->length); ); - if (ret != MM_ERROR_NONE) { - _MMCamcorderMsgItem msg; - - msg.id = MM_MESSAGE_CAMCORDER_ERROR; - msg.param.code = ret; - _mmcamcroder_send_message(handle, &msg); - - _mmcam_dbg_err("Failed to set_exif_thumbnail [%x]",ret); - } } else { - _mmcam_dbg_err("Skip adding thumbnail (data=%p, length=%d, capture-thumbnail=%d)", - thumbnail->data, thumbnail->length , bthumbnail); + _mmcam_dbg_err("Skip adding thumbnail (data=%p, length=%d)", + thumbnail->data, thumbnail->length); } } - /* write jpeg with exif */ - __ta__(" mm_exif_write_exif_jpeg_to_memory", - ret = mm_exif_write_exif_jpeg_to_memory(&original->data, &original->length ,hcamcorder->exif_info, data, datalen); - ); - if (ret != MM_ERROR_NONE) { - _MMCamcorderMsgItem msg; - - msg.id = MM_MESSAGE_CAMCORDER_ERROR; - msg.param.code = ret; - _mmcamcroder_send_message(handle, &msg); - - _mmcam_dbg_err("mm_exif_write_exif_jpeg_to_memory error! [%x]",ret); + if (ret == MM_ERROR_NONE) { + /* write jpeg with exif */ + __ta__(" mm_exif_write_exif_jpeg_to_memory", + ret = mm_exif_write_exif_jpeg_to_memory(&original->data, &original->length ,hcamcorder->exif_info, data, datalen); + ); + if (ret != MM_ERROR_NONE) { + _mmcam_dbg_err("mm_exif_write_exif_jpeg_to_memory error! [0x%x]",ret); + } } - /* destroy exif info */ - __ta__(" mm_exif_destory_exif_info", - mm_exif_destory_exif_info(hcamcorder->exif_info); - ); - hcamcorder->exif_info = NULL; - - _mmcam_dbg_log("END"); + _mmcam_dbg_log("END ret 0x%x", ret); - if (ret != MM_ERROR_NONE) { - return FALSE; - } else { - return TRUE; - } + return ret; } @@ -1401,42 +1344,25 @@ GET_FAILED: } -gboolean __mmcamcorder_set_jpeg_data(MMHandleType handle, MMCamcorderCaptureDataType *dest, MMCamcorderCaptureDataType *thumbnail) +int __mmcamcorder_set_jpeg_data(MMHandleType handle, MMCamcorderCaptureDataType *dest, MMCamcorderCaptureDataType *thumbnail) { - int tag_enable = 0; - int provide_exif = FALSE; - mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); _MMCamcorderSubContext *sc = NULL; - mmf_return_val_if_fail(hcamcorder, FALSE); - mmf_return_val_if_fail(dest, FALSE); + mmf_return_val_if_fail(hcamcorder && dest, MM_ERROR_CAMCORDER_INVALID_ARGUMENT); sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder); - mmf_return_val_if_fail(sc, FALSE); + mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED); _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 enable[%d], provide exif[%d]", tag_enable, provide_exif); - /* if tag enable and doesn't provide exif, we make it */ - if (tag_enable && !provide_exif) { - _mmcam_dbg_log("Add exif information if existed(thumbnail[%p])", thumbnail); - if (thumbnail && thumbnail->data) { - if (!__mmcamcorder_capture_save_exifinfo(handle, dest, thumbnail)) { - return FALSE; - } - } else { - if (!__mmcamcorder_capture_save_exifinfo(handle, dest, NULL)) { - return FALSE; - } - } + _mmcam_dbg_log("Add exif information if existed(thumbnail[%p])", thumbnail); + if (thumbnail && thumbnail->data) { + return __mmcamcorder_capture_save_exifinfo(handle, dest, thumbnail); + } else { + return __mmcamcorder_capture_save_exifinfo(handle, dest, NULL); } - - return TRUE; } @@ -1456,10 +1382,8 @@ void __mmcamcorder_release_jpeg_data(MMHandleType handle, MMCamcorderCaptureData _mmcam_dbg_log(""); - __ta__( " GetAttr:MMCAM_TAG_ENABLE", + __ta__( " Get:MMCAM_TAG_ENABLE and \"provide-exif\"", mm_camcorder_get_attributes(handle, NULL, MMCAM_TAG_ENABLE, &tag_enable, NULL); - ); - __ta__( " GetProp:\"provide-exif\"", MMCAMCORDER_G_OBJECT_GET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "provide-exif", &provide_exif); ); @@ -1490,6 +1414,9 @@ static void __mmcamcorder_image_capture_cb(GstElement *element, GstBuffer *buffe int attr_index = 0; int count = 0; int stop_cont_shot = 0; + int tag_enable = FALSE; + int provide_exif = FALSE; + unsigned char *exif_raw_data = NULL; mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(u_data); _MMCamcorderImageInfo *info = NULL; @@ -1499,7 +1426,8 @@ static void __mmcamcorder_image_capture_cb(GstElement *element, GstBuffer *buffe MMCamcorderCaptureDataType scrnail = {0,}; mmf_attrs_t *attrs = NULL; - mmf_attribute_t *item = NULL; + mmf_attribute_t *item_screennail = NULL; + mmf_attribute_t *item_exif_raw_data = NULL; void *encoded_data = NULL; @@ -1585,9 +1513,7 @@ static void __mmcamcorder_image_capture_cb(GstElement *element, GstBuffer *buffe __mmcamcorder_get_capture_data_from_buffer(&dest, pixtype, buffer1); } else { _mmcam_dbg_err("buffer1 has wrong pointer. (buffer1=%p)",buffer1); - MMCAM_SEND_MESSAGE(hcamcorder, MM_MESSAGE_CAMCORDER_ERROR, MM_ERROR_CAMCORDER_INTERNAL); - goto error; } @@ -1627,8 +1553,8 @@ static void __mmcamcorder_image_capture_cb(GstElement *element, GstBuffer *buffe /* Screennail image buffer */ attrs = (mmf_attrs_t*)MMF_CAMCORDER_ATTRS(hcamcorder); - mm_attrs_get_index((MMHandleType)attrs, "captured-screennail", &attr_index); - item = &attrs->items[attr_index]; + mm_attrs_get_index((MMHandleType)attrs, MMCAM_CAPTURED_SCREENNAIL, &attr_index); + item_screennail = &attrs->items[attr_index]; if (buffer3 && GST_BUFFER_DATA(buffer3) && GST_BUFFER_SIZE(buffer3) != 0) { _mmcam_dbg_log("Screennail (buffer3=%p,size=%d)", buffer3, GST_BUFFER_SIZE(buffer3)); @@ -1637,18 +1563,63 @@ static void __mmcamcorder_image_capture_cb(GstElement *element, GstBuffer *buffe __mmcamcorder_get_capture_data_from_buffer(&scrnail, pixtype_sub, buffer3); /* Set screennail attribute for application */ - mmf_attribute_set_data(item, &scrnail, sizeof(scrnail)); + ret = mmf_attribute_set_data(item_screennail, &scrnail, sizeof(scrnail)); + _mmcam_dbg_log("Screennail set attribute data %p, size %d, ret %x", &scrnail, sizeof(scrnail), ret); } else { - mmf_attribute_set_data(item, NULL, 0); - _mmcam_dbg_log("buffer3 has wrong pointer. Not Error. (buffer3=%p)",buffer3); + mmf_attribute_set_data(item_screennail, NULL, 0); } /* commit screennail data */ - mmf_attrs_commit_err((MMHandleType)attrs, NULL); + mmf_attribute_commit(item_screennail); - /* Set extra data for jpeg */ - if (dest.format == MM_PIXEL_FORMAT_ENCODED) { + /* create EXIF info */ + __ta__(" mm_exif_create_exif_info", + ret = mm_exif_create_exif_info(&(hcamcorder->exif_info)); + ); + if (ret != MM_ERROR_NONE) { + _mmcam_dbg_err("Failed to create exif_info [%x], but keep going...", ret); + } else { + /* add basic exif info */ + _mmcam_dbg_log("add basic exif info"); + __ta__(" __mmcamcorder_set_exif_basic_info", + ret = __mmcamcorder_set_exif_basic_info((MMHandleType)hcamcorder, dest.width, dest.height); + ); + if (ret != MM_ERROR_NONE) { + _mmcam_dbg_warn("Failed set_exif_basic_info [%x], but keep going...", ret); + ret = MM_ERROR_NONE; + } + } + + /* get attribute item for EXIF data */ + mm_attrs_get_index((MMHandleType)attrs, MMCAM_CAPTURED_EXIF_RAW_DATA, &attr_index); + item_exif_raw_data = &attrs->items[attr_index]; + + /* set EXIF data to attribute */ + if (hcamcorder->exif_info && hcamcorder->exif_info->data) { + exif_raw_data = (unsigned char *)malloc(hcamcorder->exif_info->size); + if (exif_raw_data) { + memcpy(exif_raw_data, hcamcorder->exif_info->data, hcamcorder->exif_info->size); + mmf_attribute_set_data(item_exif_raw_data, exif_raw_data, hcamcorder->exif_info->size); + _mmcam_dbg_log("set EXIF raw data %p, size %d", exif_raw_data, hcamcorder->exif_info->size); + } else { + _mmcam_dbg_warn("failed to alloc for EXIF, size %d", hcamcorder->exif_info->size); + } + } else { + _mmcam_dbg_warn("failed to create EXIF. set EXIF as NULL"); + mmf_attribute_set_data(item_exif_raw_data, NULL, 0); + } + + /* commit EXIF data */ + mmf_attribute_commit(item_exif_raw_data); + + /* get tag-enable and provide-exif */ + mm_camcorder_get_attributes((MMHandleType)hcamcorder, NULL, MMCAM_TAG_ENABLE, &tag_enable, NULL); + MMCAMCORDER_G_OBJECT_GET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "provide-exif", &provide_exif); + + /* Set extra data for JPEG if tag enabled and doesn't provide EXIF */ + if (dest.format == MM_PIXEL_FORMAT_ENCODED && + tag_enable && !provide_exif) { mm_camcorder_get_attributes((MMHandleType)hcamcorder, NULL, MMCAM_IMAGE_ENCODER, &codectype, NULL); @@ -1661,11 +1632,9 @@ static void __mmcamcorder_image_capture_cb(GstElement *element, GstBuffer *buffe __ta__( " __mmcamcorder_set_jpeg_data", ret = __mmcamcorder_set_jpeg_data((MMHandleType)hcamcorder, &dest, &thumb); ); - if (!ret) { + if (ret != MM_ERROR_NONE) { _mmcam_dbg_err("Error on setting extra data to jpeg"); - - MMCAM_SEND_MESSAGE(hcamcorder, MM_MESSAGE_CAMCORDER_ERROR, MM_ERROR_CAMCORDER_INTERNAL); - + MMCAM_SEND_MESSAGE(hcamcorder, MM_MESSAGE_CAMCORDER_ERROR, ret); goto error; } break; @@ -1705,11 +1674,9 @@ static void __mmcamcorder_image_capture_cb(GstElement *element, GstBuffer *buffe /* Send CAPTURED message and count - capture success */ if (info->hdr_capture_mode != MM_CAMCORDER_HDR_ON_AND_ORIGINAL) { MMTA_ACUM_ITEM_BEGIN(" CAPTURED MESSAGE DELAY", FALSE); - MMCAM_SEND_MESSAGE(hcamcorder, MM_MESSAGE_CAMCORDER_CAPTURED, count); } else if (info->hdr_capture_mode == MM_CAMCORDER_HDR_ON_AND_ORIGINAL && count == 2) { MMTA_ACUM_ITEM_BEGIN(" CAPTURED MESSAGE DELAY", FALSE); - /* send captured message only once in HDR and Original Capture mode */ MMCAM_SEND_MESSAGE(hcamcorder, MM_MESSAGE_CAMCORDER_CAPTURED, 1); } @@ -1717,9 +1684,22 @@ static void __mmcamcorder_image_capture_cb(GstElement *element, GstBuffer *buffe err_release_exif: _MMCAMCORDER_UNLOCK_VCAPTURE_CALLBACK(hcamcorder); + /* init screennail and EXIF raw data */ + __ta__(" init attributes:scrnl and EXIF", + mmf_attribute_set_data(item_screennail, NULL, 0); + mmf_attribute_commit(item_screennail); + if (exif_raw_data) { + free(exif_raw_data); + exif_raw_data = NULL; + + mmf_attribute_set_data(item_exif_raw_data, NULL, 0); + mmf_attribute_commit(item_exif_raw_data); + } + ); + /* Release jpeg data */ if (pixtype == MM_PIXEL_FORMAT_ENCODED) { - __ta__( " __mmcamcorder_release_jpeg_data", + __ta__(" __mmcamcorder_release_jpeg_data", __mmcamcorder_release_jpeg_data((MMHandleType)hcamcorder, &dest); ); } @@ -1752,6 +1732,12 @@ error: gst_buffer_unref(buffer3); } + /* destroy exif info */ + __ta__(" mm_exif_destory_exif_info", + mm_exif_destory_exif_info(hcamcorder->exif_info); + ); + hcamcorder->exif_info = NULL; + MMTA_ACUM_ITEM_END( " MSL capture callback", FALSE ); _mmcam_dbg_err("END"); @@ -1809,7 +1795,7 @@ int _mmcamcorder_set_resize_property(MMHandleType handle, int capture_width, int } -int __mmcamcorder_set_exif_basic_info(MMHandleType handle, MMCamcorderCaptureDataType *capture_data) +int __mmcamcorder_set_exif_basic_info(MMHandleType handle, int image_width, int image_height) { int ret = MM_ERROR_NONE; int value; @@ -1858,7 +1844,9 @@ int __mmcamcorder_set_exif_basic_info(MMHandleType handle, MMCamcorderCaptureDat } /* get ExifData from exif info */ + __ta__(" mm_exif_get_exif_from_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)); return MM_ERROR_INVALID_HANDLE; @@ -1877,7 +1865,7 @@ int __mmcamcorder_set_exif_basic_info(MMHandleType handle, MMCamcorderCaptureDat } /*1. EXIF_TAG_IMAGE_WIDTH */ /*EXIF_TAG_PIXEL_X_DIMENSION*/ - value = capture_data->width; + value = image_width; exif_set_long((unsigned char *)&elong[cntl], exif_data_get_byte_order(ed), value); ret = mm_exif_set_add_entry(ed, EXIF_IFD_0, EXIF_TAG_IMAGE_WIDTH, @@ -1894,7 +1882,7 @@ int __mmcamcorder_set_exif_basic_info(MMHandleType handle, MMCamcorderCaptureDat _mmcam_dbg_log("width[%d]", value); /*2. EXIF_TAG_IMAGE_LENGTH*/ /*EXIF_TAG_PIXEL_Y_DIMENSION*/ - value = capture_data->height; + value = image_height; exif_set_long((unsigned char *)&elong[cntl], exif_data_get_byte_order (ed), value); ret = mm_exif_set_add_entry(ed, EXIF_IFD_0, EXIF_TAG_IMAGE_LENGTH, @@ -1963,6 +1951,7 @@ int __mmcamcorder_set_exif_basic_info(MMHandleType handle, MMCamcorderCaptureDat free(b); } + #ifdef WRITE_EXIF_MAKER_INFO /* FIXME */ /*5. EXIF_TAG_MAKE */ maker = strdup(MM_MAKER_NAME); @@ -2030,7 +2019,7 @@ int __mmcamcorder_set_exif_basic_info(MMHandleType handle, MMCamcorderCaptureDat } */ - /*8. EXIF_TAG_ORIENTATION */ + /*8. EXIF_TAG_ORIENTATION */ mm_camcorder_get_attributes(handle, NULL, MMCAM_TAG_ORIENTATION, &value, NULL); _mmcam_dbg_log("orientation [%d]",value); diff --git a/src/mm_camcorder_videorec.c b/src/mm_camcorder_videorec.c index f0897a4..4a4762b 100644 --- a/src/mm_camcorder_videorec.c +++ b/src/mm_camcorder_videorec.c @@ -834,17 +834,10 @@ int _mmcamcorder_video_command(MMHandleType handle, int command) break; case _MMCamcorder_CMD_CAPTURE: { - int cap_jpeg_quality = 0; - GstCameraControl *control = NULL; - ret = mm_camcorder_get_attributes(handle, &err_name, - MMCAM_IMAGE_ENCODER_QUALITY, &cap_jpeg_quality, - NULL); - MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-fourcc", GST_MAKE_FOURCC('J','P','E','G')); MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-count", 1); - MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", cap_jpeg_quality); control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst); gst_camera_control_set_capture_command(control, GST_CAMERA_CONTROL_CAPTURE_COMMAND_START); @@ -1010,6 +1003,9 @@ void _mmcamcorder_video_snapshot_capture_cb(GstElement *element, GstBuffer *buff int pixtype = MM_PIXEL_FORMAT_INVALID; int pixtype_sub = MM_PIXEL_FORMAT_INVALID; int attr_index = 0; + int tag_enable = FALSE; + int provide_exif = FALSE; + unsigned char *exif_raw_data = NULL; mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(u_data); _MMCamcorderVideoInfo *info = NULL; @@ -1020,9 +1016,8 @@ void _mmcamcorder_video_snapshot_capture_cb(GstElement *element, GstBuffer *buff MMCamcorderCaptureDataType scrnail = {0,}; mmf_attrs_t *attrs = NULL; - mmf_attribute_t *item = NULL; - - char *err_attr_name = NULL; + mmf_attribute_t *item_screennail = NULL; + mmf_attribute_t *item_exif_raw_data = NULL; mmf_return_if_fail(hcamcorder); @@ -1067,7 +1062,7 @@ void _mmcamcorder_video_snapshot_capture_cb(GstElement *element, GstBuffer *buff /* Screennail image buffer */ attrs = (mmf_attrs_t*)MMF_CAMCORDER_ATTRS(hcamcorder); mm_attrs_get_index((MMHandleType)attrs, "captured-screennail", &attr_index); - item = &attrs->items[attr_index]; + item_screennail = &attrs->items[attr_index]; if (buffer3 && GST_BUFFER_DATA(buffer3) && GST_BUFFER_SIZE(buffer3) != 0) { _mmcam_dbg_log("Screennail (buffer3=%p,size=%d)", buffer3, GST_BUFFER_SIZE(buffer3)); @@ -1076,24 +1071,69 @@ void _mmcamcorder_video_snapshot_capture_cb(GstElement *element, GstBuffer *buff __mmcamcorder_get_capture_data_from_buffer(&scrnail, pixtype_sub, buffer3); /* Set screennail attribute for application */ - mmf_attribute_set_data(item, &scrnail, sizeof(scrnail)); + mmf_attribute_set_data(item_screennail, &scrnail, sizeof(scrnail)); } else { - mmf_attribute_set_data(item, NULL, 0); - + mmf_attribute_set_data(item_screennail, NULL, 0); _mmcam_dbg_log("buffer3 has wrong pointer. Not Error. (buffer3=%p)",buffer3); } - mmf_attrs_commit_err((MMHandleType)attrs, &err_attr_name); + /* commit attribute */ + mmf_attribute_commit(item_screennail); + + /* create EXIF info */ + __ta__(" mm_exif_create_exif_info", + ret = mm_exif_create_exif_info(&(hcamcorder->exif_info)); + ); + if (ret != MM_ERROR_NONE) { + _mmcam_dbg_err("Failed to create exif_info [%x], but keep going...", ret); + } else { + /* add basic exif info */ + _mmcam_dbg_log("add basic exif info"); + __ta__(" __mmcamcorder_set_exif_basic_info", + ret = __mmcamcorder_set_exif_basic_info((MMHandleType)hcamcorder, dest.width, dest.height); + ); + if (ret != MM_ERROR_NONE) { + _mmcam_dbg_warn("Failed set_exif_basic_info [%x], but keep going...", ret); + ret = MM_ERROR_NONE; + } + } + + /* get attribute item for EXIF data */ + mm_attrs_get_index((MMHandleType)attrs, MMCAM_CAPTURED_EXIF_RAW_DATA, &attr_index); + item_exif_raw_data = &attrs->items[attr_index]; + + /* set EXIF data to attribute */ + if (hcamcorder->exif_info && hcamcorder->exif_info->data) { + exif_raw_data = (unsigned char *)malloc(hcamcorder->exif_info->size); + if (exif_raw_data) { + memcpy(exif_raw_data, hcamcorder->exif_info->data, hcamcorder->exif_info->size); + mmf_attribute_set_data(item_exif_raw_data, exif_raw_data, hcamcorder->exif_info->size); + _mmcam_dbg_log("set EXIF raw data %p, size %d", exif_raw_data, hcamcorder->exif_info->size); + } else { + _mmcam_dbg_warn("failed to alloc for EXIF, size %d", hcamcorder->exif_info->size); + } + } else { + _mmcam_dbg_warn("failed to create EXIF. set EXIF as NULL"); + mmf_attribute_set_data(item_exif_raw_data, NULL, 0); + } + + /* commit EXIF data */ + mmf_attribute_commit(item_exif_raw_data); + + /* get tag-enable and provide-exif */ + mm_camcorder_get_attributes((MMHandleType)hcamcorder, NULL, MMCAM_TAG_ENABLE, &tag_enable, NULL); + MMCAMCORDER_G_OBJECT_GET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "provide-exif", &provide_exif); /* Set extra data for jpeg */ - if (dest.format == MM_PIXEL_FORMAT_ENCODED) { + if (dest.format == MM_PIXEL_FORMAT_ENCODED && + tag_enable && !provide_exif) { __ta__( " VideoSnapshot:__mmcamcorder_set_jpeg_data", ret = __mmcamcorder_set_jpeg_data((MMHandleType)hcamcorder, &dest, &thumb); ); - if (!ret) { + if (ret != MM_ERROR_NONE) { _mmcam_dbg_err("Error on setting extra data to jpeg"); msg.id = MM_MESSAGE_CAMCORDER_ERROR; - msg.param.code = MM_ERROR_CAMCORDER_INTERNAL; + msg.param.code = ret; goto error; } } @@ -1125,6 +1165,19 @@ void _mmcamcorder_video_snapshot_capture_cb(GstElement *element, GstBuffer *buff err_release_exif: _MMCAMCORDER_UNLOCK_VCAPTURE_CALLBACK(hcamcorder); + /* init screennail and EXIF raw data */ + __ta__(" init attributes:scrnl and EXIF", + mmf_attribute_set_data(item_screennail, NULL, 0); + mmf_attribute_commit(item_screennail); + if (exif_raw_data) { + free(exif_raw_data); + exif_raw_data = NULL; + + mmf_attribute_set_data(item_exif_raw_data, NULL, 0); + mmf_attribute_commit(item_exif_raw_data); + } + ); + /* Release jpeg data */ if (pixtype == MM_PIXEL_FORMAT_ENCODED) { __ta__( " VideoSnapshot:__mmcamcorder_release_jpeg_data", @@ -1148,6 +1201,12 @@ error: gst_buffer_unref(buffer3); } + /* destroy exif info */ + __ta__(" mm_exif_destory_exif_info", + mm_exif_destory_exif_info(hcamcorder->exif_info); + ); + hcamcorder->exif_info = NULL; + MMTA_ACUM_ITEM_END(" VideoSnapshot:MSL capture callback", FALSE); _mmcam_dbg_err("END"); @@ -1341,6 +1400,8 @@ static gboolean __mmcamcorder_video_dataprobe_record(GstPad *pad, GstBuffer *buf info->filesize += (guint64)buffer_size; + _mmcam_dbg_log("filesize %u, ", info->filesize); + return TRUE; } @@ -1349,7 +1410,6 @@ static gboolean __mmcamcorder_video_dataprobe_audio_disable(GstPad *pad, GstBuff { guint64 trailer_size = 0; guint64 rec_pipe_time = 0; - static guint count = 0; unsigned int remained_time = 0; GstClockTime b_time; @@ -1411,6 +1471,9 @@ static gboolean __mmcamcorder_video_dataprobe_audio_disable(GstPad *pad, GstBuff msg.param.recording_status.remained_time = remained_time; _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg); + _mmcam_dbg_log("time [%" GST_TIME_FORMAT "], size [%d]", + GST_TIME_ARGS(rec_pipe_time), msg.param.recording_status.filesize); + if (info->record_timestamp_ratio != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE) { GST_BUFFER_TIMESTAMP(buffer) = b_time * (info->record_timestamp_ratio); } @@ -1480,15 +1543,15 @@ static gboolean __mmcamcorder_audioque_dataprobe(GstPad *pad, GstBuffer *buffer, return FALSE; } - /*_mmcam_dbg_log("_mmcamcorder_audioque_dataprobe :: time [%" GST_TIME_FORMAT "], size [%d]", - GST_TIME_ARGS(rec_pipe_time), (info->filesize + trailer_size) >> 10);*/ - msg.id = MM_MESSAGE_CAMCORDER_RECORDING_STATUS; msg.param.recording_status.elapsed = (unsigned int)rec_pipe_time; msg.param.recording_status.filesize = (unsigned int)((info->filesize + trailer_size) >> 10); msg.param.recording_status.remained_time = remained_time; _mmcamcroder_send_message((MMHandleType)hcamcorder, &msg); + _mmcam_dbg_log("_mmcamcorder_audioque_dataprobe :: time [%" GST_TIME_FORMAT "], size [%d]", + GST_TIME_ARGS(rec_pipe_time), msg.param.recording_status.filesize); + return TRUE; } diff --git a/test/mm_camcorder_testsuite.c b/test/mm_camcorder_testsuite.c index f1362ee..d052a37 100644 --- a/test/mm_camcorder_testsuite.c +++ b/test/mm_camcorder_testsuite.c @@ -150,8 +150,11 @@ static GTimer *timer = NULL; #define EXT_AMR "amr" #define EXT_MKV "mkv" -#define STILL_CAPTURE_FILE_PATH_NAME "/root/StillshotCapture" -#define MULTI_CAPTURE_FILE_PATH_NAME "/root/MultishotCapture" +#define STILL_CAPTURE_FILE_PATH_NAME "/opt/media/StillshotCapture" +#define MULTI_CAPTURE_FILE_PATH_NAME "/opt/media/MultishotCapture" +#define IMAGE_CAPTURE_THUMBNAIL_PATH "/opt/media/thumbnail.jpg" +#define IMAGE_CAPTURE_SCREENNAIL_PATH "/opt/media/screennail.yuv" +#define IMAGE_CAPTURE_EXIF_PATH "/opt/media/exif.raw" #define TARGET_FILENAME_PATH "/opt/media/" #define TARGET_FILENAME_VIDEO "/opt/media/test_rec_video.3gp" #define TARGET_FILENAME_AUDIO "/opt/media/test_rec_audio.amr" @@ -538,14 +541,42 @@ static int camcordertest_video_stream_cb(MMCamcorderVideoStreamDataType *stream, return TRUE; } +static void _file_write(char *path, void *data, int size) +{ + FILE *fp = NULL; + + if (!path || !data || size <= 0) { + printf("ERROR %p %p %d\n", path, data, size); + return; + } + + fp = fopen(path, "w"); + if (fp == NULL) { + printf("open error! [%s], errno %d\n", path, errno); + return; + } else { + printf("open success [%s]\n", path); + if (fwrite(data, size, 1, fp) != 1) { + printf("write error! errno %d\n", errno); + } else { + printf("write success [%s]\n", path); + } + + fclose(fp); + fp = NULL; + } +} + + static int camcordertest_video_capture_cb(MMCamcorderCaptureDataType *main, MMCamcorderCaptureDataType *thumb, void *data) { int nret = 0; int scrnl_size = 0; + int exif_size = 0; char m_filename[CAPTURE_FILENAME_LEN]; - FILE *fp = NULL; MMCamcorderCaptureDataType *scrnl = NULL; + unsigned char *exif_data = NULL; if (main == NULL) { warn_msg_t("Capture callback : Main image buffer is NULL!!!"); @@ -553,9 +584,9 @@ camcordertest_video_capture_cb(MMCamcorderCaptureDataType *main, MMCamcorderCapt } if (hcamcorder->isMultishot) { - snprintf(m_filename, CAPTURE_FILENAME_LEN, "%s%03d.jpg", hcamcorder->multishot_filename,hcamcorder->multishot_count++); + snprintf(m_filename, CAPTURE_FILENAME_LEN, "%s%03d.jpg", hcamcorder->multishot_filename, hcamcorder->multishot_count++); } else { - snprintf(m_filename, CAPTURE_FILENAME_LEN, "%s%03d.jpg", hcamcorder->stillshot_filename,hcamcorder->stillshot_count++); + snprintf(m_filename, CAPTURE_FILENAME_LEN, "%s%03d.jpg", hcamcorder->stillshot_filename, hcamcorder->stillshot_count++); } debug_msg_t("hcamcorder->isMultishot=%d =>1: MULTI, 0: STILL, filename : %s", @@ -568,23 +599,7 @@ camcordertest_video_capture_cb(MMCamcorderCaptureDataType *main, MMCamcorderCapt nret = _mmcamcorder_encode_jpeg(main->data, main->width, main->height, main->format, main->length, 90, &dst, &dst_size); if (nret) { - fp = fopen(m_filename, "w+"); - if (fp == NULL) { - printf("FileOPEN error!!\n"); - warn_msg_t("FileOPEN error!!"); - return FALSE; - } else { - printf("open success\n"); - if (fwrite(dst, dst_size, 1, fp) != 1) { - printf("File write error!!\n"); - warn_msg_t("File write error!!"); - fclose(fp); - return FALSE; - } - printf("write success\n"); - } - fclose(fp); - fp = NULL; + _file_write(m_filename, dst, dst_size); } else { printf("Failed to encode YUV(%d) -> JPEG. \n", main->format); } @@ -597,43 +612,11 @@ camcordertest_video_capture_cb(MMCamcorderCaptureDataType *main, MMCamcorderCapt main->data, main->length, main->width, main->height); /* main image */ - fp = fopen(m_filename, "w+"); - if (fp == NULL) { - printf("FileOPEN error!!\n"); - warn_msg_t("FileOPEN error!!"); - return FALSE; - } else { - printf("open success\n"); - if (fwrite(main->data, main->length, 1, fp) != 1) { - printf("File write error!!\n"); - warn_msg_t("File write error!!"); - fclose(fp); - return FALSE; - } - printf("write success\n"); - } - fclose(fp); - fp = NULL; + _file_write(m_filename, main->data, main->length); /* thumbnail */ if (thumb != NULL) { - fp = fopen("./thumbnail.jpg", "w+"); - if (fp == NULL) { - printf("FileOPEN error!!\n"); - warn_msg_t("FileOPEN error!!"); - return FALSE; - } else { - printf("open success\n"); - if (fwrite(thumb->data, thumb->length, 1, fp) != 1) { - printf("File write error!!\n"); - warn_msg_t("File write error!!"); - fclose(fp); - return FALSE; - } - printf("write success\n"); - } - fclose(fp); - fp = NULL; + _file_write(IMAGE_CAPTURE_THUMBNAIL_PATH, thumb->data, thumb->length); } /* screennail */ @@ -641,30 +624,18 @@ camcordertest_video_capture_cb(MMCamcorderCaptureDataType *main, MMCamcorderCapt "captured-screennail", &scrnl, &scrnl_size, NULL); if (scrnl != NULL) { - fp = fopen("./screennail.yuv", "w+"); - if (fp == NULL) { - printf("FileOPEN error!!\n"); - warn_msg_t("FileOPEN error!!"); - return FALSE; - } else { - printf("open success\n"); - - if (fwrite(scrnl->data, scrnl->length, 1, fp) != 1) { - printf("File write error!!\n"); - warn_msg_t("File write error!!"); - fclose(fp); - fp = NULL; - return FALSE; - } - - fclose(fp); - fp = NULL; - - printf("write success\n"); - } + _file_write(IMAGE_CAPTURE_SCREENNAIL_PATH, scrnl->data, scrnl->length); } else { printf( "Screennail buffer is NULL.\n" ); } + + /* EXIF data */ + mm_camcorder_get_attributes(hcamcorder->camcorder, NULL, + "captured-exif-raw-data", &exif_data, &exif_size, + NULL); + if (exif_data) { + _file_write(IMAGE_CAPTURE_EXIF_PATH, exif_data, exif_size); + } } return TRUE; @@ -2986,8 +2957,10 @@ static gboolean init_handle() static gboolean mode_change() { int err = MM_ERROR_NONE; - int state; + int state = MM_CAMCORDER_STATE_NONE; + int name_size = 0; char media_type = '\0'; + char *evassink_name = NULL; bool check= FALSE; debug_msg_t("MMCamcorder State : %d", mmcamcorder_state); @@ -3114,6 +3087,12 @@ static gboolean mode_change() mmcamcorder_state = MM_CAMCORDER_STATE_NULL; } + /* get evassink name */ + mm_camcorder_get_attributes(hcamcorder->camcorder, NULL, + MMCAM_DISPLAY_EVAS_SURFACE_SINK, &evassink_name, &name_size, + NULL); + debug_msg_t("evassink name [%s]", evassink_name); + mm_camcorder_set_message_callback(hcamcorder->camcorder, (MMMessageCallback)msg_callback, hcamcorder); if (!init(hcamcorder->mode)) { |