From 2a71be3d5bb4650869d5b8cf7eeeec3f4363f12f Mon Sep 17 00:00:00 2001 From: Jeongmo Yang Date: Thu, 16 Mar 2017 08:19:27 +0900 Subject: [PATCH] Add new function to get old state [Version] 0.10.113 [Profile] Common [Issue Type] Update [Dependency module] N/A [Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-3.0-mobile_20170315.2] Change-Id: Ia17ce634baaa31a07a145025b7a06d521f2fd9b8 Signed-off-by: Jeongmo Yang --- packaging/libmm-camcorder.spec | 2 +- src/include/mm_camcorder.h | 1 + src/include/mm_camcorder_internal.h | 29 ++--------------- src/mm_camcorder.c | 14 +++++++-- src/mm_camcorder_audiorec.c | 35 +-------------------- src/mm_camcorder_internal.c | 49 ++++++++++++----------------- 6 files changed, 37 insertions(+), 93 deletions(-) diff --git a/packaging/libmm-camcorder.spec b/packaging/libmm-camcorder.spec index 3ce7edf..5d09ee4 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.10.112 +Version: 0.10.113 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/include/mm_camcorder.h b/src/include/mm_camcorder.h index edc29c2..fe5164d 100644 --- a/src/include/mm_camcorder.h +++ b/src/include/mm_camcorder.h @@ -2999,6 +2999,7 @@ gboolean get_state_of_camcorder() * @endcode */ int mm_camcorder_get_state(MMHandleType camcorder, MMCamcorderStateType *state); +int mm_camcorder_get_state2(MMHandleType camcorder, MMCamcorderStateType *state, MMCamcorderStateType *old_state); /** diff --git a/src/include/mm_camcorder_internal.h b/src/include/mm_camcorder_internal.h index 88c17dc..0e6c7f9 100644 --- a/src/include/mm_camcorder_internal.h +++ b/src/include/mm_camcorder_internal.h @@ -693,9 +693,7 @@ typedef struct mmf_camcorder { int type; /**< mmcamcorder_mode_type */ int device_type; /**< device 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 old_state; /**< old state of camcorder */ /* handles */ MMHandleType attributes; /**< Attribute handle */ @@ -1112,6 +1110,7 @@ int _mmcamcorder_display_init(void); * */ int _mmcamcorder_get_state(MMHandleType handle); +int _mmcamcorder_get_state2(MMHandleType handle, int *state, int *old_state); /** * This function sets new state of camcorder. @@ -1125,18 +1124,6 @@ int _mmcamcorder_get_state(MMHandleType handle); */ void _mmcamcorder_set_state(MMHandleType handle, int state); -/** - * This function gets asynchronous status of MSL Camcroder. - * - * @param[in] handle Handle of camcorder context. - * @param[in] target_state setting target_state value of camcorder. - * @return This function returns asynchrnous state. - * @remarks - * @see _mmcamcorder_set_async_state() - * - */ -int _mmcamcorder_get_async_state(MMHandleType handle); - /** * This function allocates structure of subsidiary attributes. * @@ -1258,18 +1245,6 @@ void _mmcamcorder_destroy_pipeline(MMHandleType handle, int type); */ int _mmcamcorder_gst_set_state(MMHandleType handle, GstElement *pipeline, GstState target_state); -/** - * This function sets gstreamer element status, asynchronously. - * Regardless of processing, it returns immediately. - * - * @param[in] pipeline Pointer of pipeline - * @param[in] target_state newly setting status - * @return This function returns zero on success, or negative value with error code. - * @remarks - * @see - * - */ -int _mmcamcorder_gst_set_state_async(MMHandleType handle, GstElement *pipeline, GstState target_state); /* For xvimagesink */ GstBusSyncReply __mmcamcorder_sync_callback(GstBus *bus, GstMessage *message, gulong data); diff --git a/src/mm_camcorder.c b/src/mm_camcorder.c index 9a77ee3..7dafb33 100644 --- a/src/mm_camcorder.c +++ b/src/mm_camcorder.c @@ -335,7 +335,7 @@ int mm_camcorder_set_video_capture_callback(MMHandleType camcorder, mm_camcorder } -int mm_camcorder_get_state(MMHandleType camcorder, MMCamcorderStateType *status) +int mm_camcorder_get_state(MMHandleType camcorder, MMCamcorderStateType *state) { int ret = MM_ERROR_NONE; @@ -344,10 +344,20 @@ int mm_camcorder_get_state(MMHandleType camcorder, MMCamcorderStateType *status) return MM_ERROR_CAMCORDER_INVALID_ARGUMENT; } - *status = _mmcamcorder_get_state(camcorder); + *state = _mmcamcorder_get_state(camcorder); return ret; +} + + +int mm_camcorder_get_state2(MMHandleType camcorder, MMCamcorderStateType *state, MMCamcorderStateType *old_state) +{ + if (!camcorder) { + _mmcam_dbg_warn("Empty handle."); + return MM_ERROR_CAMCORDER_INVALID_ARGUMENT; + } + return _mmcamcorder_get_state2(camcorder, (int *)state, (int *)old_state); } diff --git a/src/mm_camcorder_audiorec.c b/src/mm_camcorder_audiorec.c index d0e3afe..b87a898 100644 --- a/src/mm_camcorder_audiorec.c +++ b/src/mm_camcorder_audiorec.c @@ -30,8 +30,7 @@ /*--------------------------------------------------------------------------------------- | GLOBAL VARIABLE DEFINITIONS for internal | ---------------------------------------------------------------------------------------*/ -#define MM_CAMCORDER_START_CHANGE_STATE _MMCamcorderStartHelperFunc((void *)hcamcorder) -#define MM_CAMCORDER_STOP_CHANGE_STATE _MMCamcorderStopHelperFunc((void *)hcamcorder) + /*--------------------------------------------------------------------------------------- | LOCAL VARIABLE DEFINITIONS for internal | ---------------------------------------------------------------------------------------*/ @@ -312,38 +311,6 @@ _mmcamcorder_destroy_audio_pipeline(MMHandleType handle) } -/** - * This function operates each command on audio mode. - * - * @param c [in] Handle of camcorder context. - * @param command [in] command type received from Multimedia Framework. - * - * @return This function returns MM_ERROR_NONE on success, or the other values - * on error. - * @remark - * @see _mmcamcorder_set_functions() - * - */ - /* ADDED BY SISO */ - - -void* _MMCamcorderStartHelperFunc(void *handle) -{ - mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); - _mmcamcorder_set_state((MMHandleType)hcamcorder, hcamcorder->target_state); - - return NULL; -} - -void* _MMCamcorderStopHelperFunc(void *handle) -{ - mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); - _mmcamcorder_set_state((MMHandleType)hcamcorder, hcamcorder->target_state); - - return NULL; -} - - int _mmcamcorder_audio_command(MMHandleType handle, int command) { diff --git a/src/mm_camcorder_internal.c b/src/mm_camcorder_internal.c index dd791b2..706d770 100644 --- a/src/mm_camcorder_internal.c +++ b/src/mm_camcorder_internal.c @@ -122,7 +122,7 @@ int _mmcamcorder_create(MMHandleType *handle, MMCamPreset *info) hcamcorder->type = 0; hcamcorder->state = MM_CAMCORDER_STATE_NONE; hcamcorder->sub_context = NULL; - hcamcorder->target_state = MM_CAMCORDER_STATE_NULL; + hcamcorder->old_state = MM_CAMCORDER_STATE_NONE; hcamcorder->capture_in_recording = FALSE; hcamcorder->session_type = MM_SESSION_TYPE_MEDIA; @@ -2513,6 +2513,23 @@ int _mmcamcorder_get_state(MMHandleType handle) } +int _mmcamcorder_get_state2(MMHandleType handle, int *state, int *old_state) +{ + mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); + + mmf_return_val_if_fail(hcamcorder && state && old_state, MM_ERROR_CAMCORDER_INVALID_ARGUMENT); + + _MMCAMCORDER_LOCK_STATE(handle); + + *state = hcamcorder->state; + *old_state = hcamcorder->old_state; + + _MMCAMCORDER_UNLOCK_STATE(handle); + + return MM_ERROR_NONE; +} + + void _mmcamcorder_set_state(MMHandleType handle, int state) { int old_state; @@ -2528,9 +2545,9 @@ void _mmcamcorder_set_state(MMHandleType handle, int state) old_state = hcamcorder->state; if (old_state != state) { hcamcorder->state = state; - hcamcorder->target_state = state; + hcamcorder->old_state = old_state; - _mmcam_dbg_log("set state[%d] and send state-changed message", state); + _mmcam_dbg_log("set state[%d -> %d] and send state-changed message", old_state, state); /* To discern who changes the state */ switch (hcamcorder->state_change_by_system) { @@ -2566,20 +2583,6 @@ void _mmcamcorder_set_state(MMHandleType handle, int state) } -int _mmcamcorder_get_async_state(MMHandleType handle) -{ - int state; - mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); - - _MMCAMCORDER_LOCK_STATE(handle); - state = hcamcorder->target_state; - - _MMCAMCORDER_UNLOCK_STATE(handle); - - return state; -} - - _MMCamcorderSubContext *_mmcamcorder_alloc_subcontext(int type) { int i; @@ -3636,18 +3639,6 @@ void _mmcamcorder_destroy_pipeline(MMHandleType handle, int type) } -int _mmcamcorder_gst_set_state_async(MMHandleType handle, GstElement *pipeline, GstState target_state) -{ - GstStateChangeReturn setChangeReturn = GST_STATE_CHANGE_FAILURE; - - _MMCAMCORDER_LOCK_GST_STATE(handle); - setChangeReturn = gst_element_set_state(pipeline, target_state); - _MMCAMCORDER_UNLOCK_GST_STATE(handle); - - return setChangeReturn; -} - - #ifdef _MMCAMCORDER_USE_SET_ATTR_CB static gboolean __mmcamcorder_set_attr_to_camsensor_cb(gpointer data) { -- 2.34.1