X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Finclude%2Fmm_camcorder_internal.h;h=bac3b288669d29f3c8e7285d4bf74c63f5ba7c60;hb=refs%2Ftags%2Faccepted%2Ftizen%2Fivi%2F20160825.050434;hp=a5c32fc4761a899992f7fb887304a3f85dfa5654;hpb=161340ad388471a2b13a49d1f3745cab3d7ad884;p=platform%2Fcore%2Fmultimedia%2Flibmm-camcorder.git diff --git a/src/include/mm_camcorder_internal.h b/src/include/mm_camcorder_internal.h index a5c32fc..bac3b28 100644 --- a/src/include/mm_camcorder_internal.h +++ b/src/include/mm_camcorder_internal.h @@ -28,7 +28,6 @@ #include #include #include -#include #include #include @@ -36,14 +35,18 @@ #include #include #include -#include #include #include #include +#include +#include /* device policy manager */ #include "mm_camcorder.h" #include "mm_debug.h" + +#ifdef _MMCAMCORDER_MURPHY_SUPPORT #include "mm_camcorder_resource.h" +#endif /* _MMCAMCORDER_MURPHY_SUPPORT */ /* camcorder sub module */ #include "mm_camcorder_attribute.h" @@ -57,6 +60,11 @@ #include "mm_camcorder_configure.h" #include "mm_camcorder_sound.h" +#ifdef _MMCAMCORDER_RM_SUPPORT +/* rm (resource manager)*/ +#include +#endif /* _MMCAMCORDER_RM_SUPPORT */ + #ifdef __cplusplus extern "C" { #endif @@ -64,33 +72,30 @@ extern "C" { /*======================================================================================= | MACRO DEFINITIONS | ========================================================================================*/ -#define _mmcam_dbg_verb(fmt, args...) debug_verbose (" "fmt"\n", ##args); -#define _mmcam_dbg_log(fmt, args...) debug_log (" "fmt"\n", ##args); -#define _mmcam_dbg_warn(fmt, args...) debug_warning (" "fmt"\n", ##args); -#define _mmcam_dbg_err(fmt, args...) debug_error (" "fmt"\n", ##args); -#define _mmcam_dbg_crit(fmt, args...) debug_critical (" "fmt"\n", ##args); +#define _mmcam_dbg_verb(fmt, args...) debug_verbose(" "fmt"\n", ##args); +#define _mmcam_dbg_log(fmt, args...) debug_log(" "fmt"\n", ##args); +#define _mmcam_dbg_warn(fmt, args...) debug_warning(" "fmt"\n", ##args); +#define _mmcam_dbg_err(fmt, args...) debug_error(" "fmt"\n", ##args); +#define _mmcam_dbg_crit(fmt, args...) debug_critical(" "fmt"\n", ##args); /** * Macro for checking validity and debugging */ -#define mmf_return_if_fail( expr ) \ - if( expr ){} \ - else \ - { \ - _mmcam_dbg_err( "failed [%s]", #expr); \ - return; \ - }; +#define mmf_return_if_fail(expr) \ + if (!(expr)) { \ + _mmcam_dbg_err("failed [%s]", #expr); \ + return; \ + } /** * Macro for checking validity and debugging */ -#define mmf_return_val_if_fail( expr, val ) \ - if( expr ){} \ - else \ - { \ - _mmcam_dbg_err("failed [%s]", #expr); \ - return( val ); \ - }; +#define mmf_return_val_if_fail(expr, val) \ + if (!(expr)) { \ + _mmcam_dbg_err("failed [%s]", #expr); \ + return (val); \ + } + #ifndef ARRAY_SIZE /** @@ -181,6 +186,24 @@ extern "C" { elist = g_list_append(elist, &(element[eid])); \ } +#define _MMCAMCORDER_ELEMENT_ADD(sub_context, element, eid, gst_element, elist, err) \ + if (element[eid].gst != NULL) { \ + _mmcam_dbg_err("The element is existed. element_id=[%d]", eid); \ + gst_object_unref(element[eid].gst); \ + } \ + element[eid].gst = gst_element; \ + if (element[eid].gst == NULL) { \ + _mmcam_dbg_err("Element is NULL. element_id=[%d]", eid); \ + err = MM_ERROR_CAMCORDER_RESOURCE_CREATION; \ + goto pipeline_creation_error; \ + } else { \ + _mmcam_dbg_log("Adding Element is done. element_id=[%d] %p", eid, gst_element); \ + element[eid].id = eid; \ + g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \ + err = MM_ERROR_NONE; \ + } \ + elist = g_list_append(elist, &(element[eid])); + #define _MMCAMCORDER_ENCODEBIN_ELMGET(sub_context, eid, name /*char* */, err) \ if (sub_context->encode_element[eid].gst != NULL) { \ _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \ @@ -209,35 +232,52 @@ extern "C" { #define _MM_GST_ELEMENT_UNLINK gst_element_unlink #define _MM_GST_PAD_LINK gst_pad_link -#define _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, if_fail_goto)\ -{\ - GstPadLinkReturn ret = _MM_GST_PAD_LINK(srcpad, sinkpad);\ - if (ret != GST_PAD_LINK_OK) {\ - GstObject *src_parent = gst_pad_get_parent(srcpad);\ - GstObject *sink_parent = gst_pad_get_parent(sinkpad);\ - char *src_name = NULL;\ - char *sink_name = NULL;\ - g_object_get((GObject *)src_parent, "name", &src_name, NULL);\ - g_object_get((GObject *)sink_parent, "name", &sink_name, NULL);\ - _mmcam_dbg_err("src[%s] - sink[%s] link failed", src_name, sink_name);\ - gst_object_unref(src_parent); src_parent = NULL;\ - gst_object_unref(sink_parent); sink_parent = NULL;\ - if (src_name) {\ - free(src_name); src_name = NULL;\ - }\ - if (sink_name) {\ - free(sink_name); sink_name = NULL;\ - }\ - gst_object_unref(srcpad); srcpad = NULL;\ - gst_object_unref(sinkpad); sinkpad = NULL;\ - err = MM_ERROR_CAMCORDER_GST_LINK;\ +#define _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, if_fail_goto) \ +{ \ + GstPadLinkReturn ret = GST_PAD_LINK_OK; \ + if (srcpad == NULL || sinkpad == NULL) { \ + if (srcpad == NULL) { \ + _mmcam_dbg_err("srcpad is NULL"); \ + } else { \ + gst_object_unref(srcpad);\ + srcpad = NULL; \ + } \ + if (sinkpad == NULL) { \ + _mmcam_dbg_err("sinkpad is NULL"); \ + } else { \ + gst_object_unref(sinkpad); \ + sinkpad = NULL;\ + } \ + err = MM_ERROR_CAMCORDER_GST_LINK; \ + goto if_fail_goto; \ + } \ + ret = _MM_GST_PAD_LINK(srcpad, sinkpad); \ + if (ret != GST_PAD_LINK_OK) { \ + GstObject *src_parent = gst_pad_get_parent(srcpad); \ + GstObject *sink_parent = gst_pad_get_parent(sinkpad); \ + char *src_name = NULL; \ + char *sink_name = NULL; \ + g_object_get((GObject *)src_parent, "name", &src_name, NULL); \ + g_object_get((GObject *)sink_parent, "name", &sink_name, NULL); \ + _mmcam_dbg_err("src[%s] - sink[%s] link failed", src_name, sink_name); \ + gst_object_unref(src_parent); src_parent = NULL; \ + gst_object_unref(sink_parent); sink_parent = NULL; \ + if (src_name) { \ + free(src_name); src_name = NULL; \ + } \ + if (sink_name) { \ + free(sink_name); sink_name = NULL; \ + } \ + gst_object_unref(srcpad); srcpad = NULL; \ + gst_object_unref(sinkpad); sinkpad = NULL; \ + err = MM_ERROR_CAMCORDER_GST_LINK; \ goto if_fail_goto;\ - }\ - gst_object_unref(srcpad); srcpad = NULL;\ - gst_object_unref(sinkpad); sinkpad = NULL;\ + } \ + gst_object_unref(srcpad); srcpad = NULL; \ + gst_object_unref(sinkpad); sinkpad = NULL; \ } -#define _MM_GST_PAD_UNLINK_UNREF( srcpad, sinkpad) \ +#define _MM_GST_PAD_UNLINK_UNREF(srcpad, sinkpad) \ if (srcpad && sinkpad) { \ gst_pad_unlink(srcpad, sinkpad); \ } else { \ @@ -257,7 +297,7 @@ extern "C" { /** * Default videosink type */ -#define _MMCAMCORDER_DEFAULT_VIDEOSINK_TYPE "VideosinkElementX" +#define _MMCAMCORDER_DEFAULT_VIDEOSINK_TYPE "VideosinkElementOverlay" /** * Default recording motion rate @@ -301,50 +341,54 @@ extern "C" { /** * Functions related with LOCK and WAIT */ -#define _MMCAMCORDER_CAST_MTSAFE(handle) (((mmf_camcorder_t*)handle)->mtsafe) -#define _MMCAMCORDER_LOCK_FUNC(mutex) pthread_mutex_lock(&mutex) -#define _MMCAMCORDER_TRYLOCK_FUNC(mutex) (!pthread_mutex_trylock(&mutex)) -#define _MMCAMCORDER_UNLOCK_FUNC(mutex) pthread_mutex_unlock(&mutex) - -#define _MMCAMCORDER_GET_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).lock) -#define _MMCAMCORDER_LOCK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle)) -#define _MMCAMCORDER_TRYLOCK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle)) -#define _MMCAMCORDER_UNLOCK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle)) - -#define _MMCAMCORDER_GET_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cond) -#define _MMCAMCORDER_WAIT(handle) pthread_cond_wait(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle)) -#define _MMCAMCORDER_TIMED_WAIT(handle, timeout) pthread_cond_timedwait(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle), &timeout) -#define _MMCAMCORDER_SIGNAL(handle) pthread_cond_signal(&_MMCAMCORDER_GET_COND(handle)); -#define _MMCAMCORDER_BROADCAST(handle) pthread_cond_broadcast(&_MMCAMCORDER_GET_COND(handle)); +#define _MMCAMCORDER_CAST_MTSAFE(handle) (((mmf_camcorder_t*)handle)->mtsafe) +#define _MMCAMCORDER_LOCK_FUNC(mutex) g_mutex_lock(&mutex) +#define _MMCAMCORDER_TRYLOCK_FUNC(mutex) g_mutex_trylock(&mutex) +#define _MMCAMCORDER_UNLOCK_FUNC(mutex) g_mutex_unlock(&mutex) + +#define _MMCAMCORDER_GET_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).lock) +#define _MMCAMCORDER_LOCK(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle)) +#define _MMCAMCORDER_TRYLOCK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle)) +#define _MMCAMCORDER_UNLOCK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_LOCK(handle)) + +#define _MMCAMCORDER_GET_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cond) +#define _MMCAMCORDER_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle)) +#define _MMCAMCORDER_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle), end_time) +#define _MMCAMCORDER_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_COND(handle)); +#define _MMCAMCORDER_BROADCAST(handle) g_cond_broadcast(&_MMCAMCORDER_GET_COND(handle)); /* for command */ -#define _MMCAMCORDER_GET_CMD_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_lock) -#define _MMCAMCORDER_LOCK_CMD(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle)) -#define _MMCAMCORDER_TRYLOCK_CMD(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle)) -#define _MMCAMCORDER_UNLOCK_CMD(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle)) +#define _MMCAMCORDER_GET_CMD_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_lock) +#define _MMCAMCORDER_GET_CMD_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).cmd_cond) +#define _MMCAMCORDER_LOCK_CMD(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle)) +#define _MMCAMCORDER_TRYLOCK_CMD(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle)) +#define _MMCAMCORDER_UNLOCK_CMD(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_CMD_LOCK(handle)) +#define _MMCAMCORDER_CMD_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle)) +#define _MMCAMCORDER_CMD_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_CMD_COND(handle), &_MMCAMCORDER_GET_CMD_LOCK(handle), end_time) +#define _MMCAMCORDER_CMD_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_CMD_COND(handle)); /* for ASM */ -#define _MMCAMCORDER_GET_ASM_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).asm_lock) -#define _MMCAMCORDER_LOCK_ASM(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle)) -#define _MMCAMCORDER_TRYLOCK_ASM(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle)) -#define _MMCAMCORDER_UNLOCK_ASM(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle)) +#define _MMCAMCORDER_GET_ASM_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).asm_lock) +#define _MMCAMCORDER_LOCK_ASM(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle)) +#define _MMCAMCORDER_TRYLOCK_ASM(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle)) +#define _MMCAMCORDER_UNLOCK_ASM(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASM_LOCK(handle)) /* for state change */ -#define _MMCAMCORDER_GET_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).state_lock) -#define _MMCAMCORDER_LOCK_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle)) -#define _MMCAMCORDER_TRYLOCK_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle)) -#define _MMCAMCORDER_UNLOCK_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle)) +#define _MMCAMCORDER_GET_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).state_lock) +#define _MMCAMCORDER_LOCK_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle)) +#define _MMCAMCORDER_TRYLOCK_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle)) +#define _MMCAMCORDER_UNLOCK_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_STATE_LOCK(handle)) /* for gstreamer state change */ -#define _MMCAMCORDER_GET_GST_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_state_lock) -#define _MMCAMCORDER_LOCK_GST_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle)) -#define _MMCAMCORDER_TRYLOCK_GST_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle)) -#define _MMCAMCORDER_UNLOCK_GST_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle)) +#define _MMCAMCORDER_GET_GST_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_state_lock) +#define _MMCAMCORDER_LOCK_GST_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle)) +#define _MMCAMCORDER_TRYLOCK_GST_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle)) +#define _MMCAMCORDER_UNLOCK_GST_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_STATE_LOCK(handle)) -#define _MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_encode_state_lock) -#define _MMCAMCORDER_LOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle)) -#define _MMCAMCORDER_TRYLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle)) -#define _MMCAMCORDER_UNLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle)) +#define _MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).gst_encode_state_lock) +#define _MMCAMCORDER_LOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle)) +#define _MMCAMCORDER_TRYLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle)) +#define _MMCAMCORDER_UNLOCK_GST_ENCODE_STATE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_GST_ENCODE_STATE_LOCK(handle)) /* for setting/calling callback */ #define _MMCAMCORDER_GET_MESSAGE_CALLBACK_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).message_cb_lock) @@ -367,6 +411,18 @@ extern "C" { #define _MMCAMCORDER_TRYLOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle)) #define _MMCAMCORDER_UNLOCK_ASTREAM_CALLBACK(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_ASTREAM_CALLBACK_LOCK(handle)) +#ifdef _MMCAMCORDER_MURPHY_SUPPORT +/* for resource conflict */ +#define _MMCAMCORDER_GET_RESOURCE_LOCK(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).resource_lock) +#define _MMCAMCORDER_GET_RESOURCE_COND(handle) (_MMCAMCORDER_CAST_MTSAFE(handle).resource_cond) +#define _MMCAMCORDER_LOCK_RESOURCE(handle) _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle)) +#define _MMCAMCORDER_TRYLOCK_RESOURCE(handle) _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle)) +#define _MMCAMCORDER_UNLOCK_RESOURCE(handle) _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle)) +#define _MMCAMCORDER_RESOURCE_WAIT(handle) g_cond_wait(&_MMCAMCORDER_GET_RESOURCE_COND(handle), &_MMCAMCORDER_GET_RESOURCE_LOCK(handle)) +#define _MMCAMCORDER_RESOURCE_WAIT_UNTIL(handle, end_time) g_cond_wait_until(&_MMCAMCORDER_GET_RESOURCE_COND(handle), &_MMCAMCORDER_GET_RESOURCE_LOCK(handle), end_time) +#define _MMCAMCORDER_RESOURCE_SIGNAL(handle) g_cond_signal(&_MMCAMCORDER_GET_RESOURCE_COND(handle)); +#endif /* _MMCAMCORDER_MURPHY_SUPPORT */ + /** * Caster of main handle (camcorder) */ @@ -463,6 +519,7 @@ typedef enum { /* Pipeline element of Video output */ _MMCAMCORDER_VIDEOSINK_QUE, + _MMCAMCORDER_VIDEOSINK_CLS, _MMCAMCORDER_VIDEOSINK_SINK, _MMCAMCORDER_PIPELINE_ELEMENT_NUM, @@ -525,8 +582,9 @@ typedef enum { */ typedef enum { _MMCAMCORDER_STATE_CHANGE_NORMAL = 0, - _MMCAMCORDER_STATE_CHANGE_BY_ASM, + _MMCAMCORDER_STATE_CHANGE_BY_FOCUS, _MMCAMCORDER_STATE_CHANGE_BY_RM, + _MMCAMCORDER_STATE_CHANGE_BY_DPM } _MMCamcorderStateChange; @@ -557,17 +615,22 @@ typedef struct { * MMCamcorder information for Multi-Thread Safe */ typedef struct { - pthread_mutex_t lock; /**< Mutex (for general use) */ - pthread_cond_t cond; /**< Condition (for general use) */ - pthread_mutex_t cmd_lock; /**< Mutex (for command) */ - pthread_mutex_t asm_lock; /**< Mutex (for ASM) */ - pthread_mutex_t state_lock; /**< Mutex (for state change) */ - pthread_mutex_t gst_state_lock; /**< Mutex (for gst pipeline state change) */ - pthread_mutex_t gst_encode_state_lock; /**< Mutex (for gst encode pipeline state change) */ - pthread_mutex_t message_cb_lock; /**< Mutex (for message callback) */ - pthread_mutex_t vcapture_cb_lock; /**< Mutex (for video capture callback) */ - pthread_mutex_t vstream_cb_lock; /**< Mutex (for video stream callback) */ - pthread_mutex_t astream_cb_lock; /**< Mutex (for audio stream callback) */ + GMutex lock; /**< Mutex (for general use) */ + GCond cond; /**< Condition (for general use) */ + GMutex cmd_lock; /**< Mutex (for command) */ + GCond cmd_cond; /**< Condition (for command) */ + GMutex asm_lock; /**< Mutex (for ASM) */ + GMutex state_lock; /**< Mutex (for state change) */ + GMutex gst_state_lock; /**< Mutex (for gst pipeline state change) */ + GMutex gst_encode_state_lock; /**< Mutex (for gst encode pipeline state change) */ + GMutex message_cb_lock; /**< Mutex (for message callback) */ + GMutex vcapture_cb_lock; /**< Mutex (for video capture callback) */ + GMutex vstream_cb_lock; /**< Mutex (for video stream callback) */ + GMutex astream_cb_lock; /**< Mutex (for audio stream callback) */ +#ifdef _MMCAMCORDER_MURPHY_SUPPORT + GCond resource_cond; /**< Condition (for resource check) */ + GMutex resource_lock; /**< Mutex (for resource check) */ +#endif /* _MMCAMCORDER_MURPHY_SUPPORT */ } _MMCamcorderMTSafe; /** @@ -608,6 +671,7 @@ typedef struct { type_element *VideosinkElement; /**< configure data of videosink element */ type_element *VideoconvertElement; /**< configure data of videoconvert element */ + type_element *VideodecoderElementH264; /**< configure data of video decoder element for H.264 format */ gboolean SensorEncodedCapture; /**< whether camera sensor support encoded image capture */ gboolean internal_encode; /**< whether use internal encoding function */ } _MMCamcorderSubContext; @@ -621,8 +685,8 @@ typedef struct mmf_camcorder { 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. */ + * stands for async state changing. If this value differ from state, + * it means state is changing now asychronously. */ /* handles */ MMHandleType attributes; /**< Attribute handle */ @@ -636,6 +700,9 @@ typedef struct mmf_camcorder { #endif /* _MMCAMCORDER_ENABLE_IDLE_MESSAGE_CALLBACK */ camera_conf *conf_main; /**< Camera configure Main structure */ camera_conf *conf_ctrl; /**< Camera configure Control structure */ +#ifdef _MMCAMCORDER_RM_SUPPORT + int rm_handle; /**< Resource manager handle */ +#endif /* _MMCAMCORDER_RM_SUPPORT */ guint pipeline_cb_event_id; /**< Event source ID of pipeline message callback */ guint encode_pipeline_cb_event_id; /**< Event source ID of encode pipeline message callback */ guint setting_event_id; /**< Event source ID of attributes setting to sensor */ @@ -654,17 +721,16 @@ typedef struct mmf_camcorder { /* etc */ mm_cam_attr_construct_info *cam_attrs_const_info; /**< attribute info */ - conf_info_table* conf_main_info_table[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table - MAIN category */ - conf_info_table* conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table - CONTROL category */ + conf_info_table *conf_main_info_table[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table - MAIN category */ + conf_info_table *conf_ctrl_info_table[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table - CONTROL category */ int conf_main_category_size[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table size - MAIN category */ int conf_ctrl_category_size[CONFIGURE_CATEGORY_CTRL_NUM]; /** configure info table size - CONTROL category */ _MMCamcorderMTSafe mtsafe; /**< Thread safe */ int state_change_by_system; /**< MSL changes its state by itself because of system */ - pthread_mutex_t sound_lock; /**< Capture sound mutex */ - pthread_cond_t sound_cond; /**< Capture sound cond */ - pthread_mutex_t restart_preview_lock; /**< Capture sound mutex */ + GMutex restart_preview_lock; /**< Capture sound mutex */ int use_zero_copy_format; /**< Whether use zero copy format for camera input */ - int support_media_packet_preview_cb; /**< Whether support zero copy format for camera input */ + int use_videoconvert; /**< Whether use videoconvert element for display */ + int support_media_packet_preview_cb; /**< Whether support zero copy format for camera input */ int shutter_sound_policy; /**< shutter sound policy */ int brightness_default; /**< default value of brightness */ int brightness_step_denominator; /**< denominator of brightness bias step */ @@ -681,6 +747,7 @@ typedef struct mmf_camcorder { int acquired_focus; /**< Current acquired focus */ int session_type; /**< Session type */ int session_flags; /**< Session flags */ + int recreate_decoder; /**< Flag of decoder element recreation for encoded preview format */ _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 */ @@ -691,14 +758,32 @@ typedef struct mmf_camcorder { int error_code; /**< error code for internal gstreamer error */ /* task thread */ - pthread_t task_thread; /**< thread for task */ - pthread_mutex_t task_thread_lock; /**< mutex for task thread */ - pthread_cond_t task_thread_cond; /**< cond for task thread */ + GThread *task_thread; /**< thread for task */ + GMutex task_thread_lock; /**< mutex for task thread */ + GCond task_thread_cond; /**< cond for task thread */ _MMCamcorderTaskThreadState task_thread_state; /**< state of task thread */ +#ifdef _MMCAMCORDER_MURPHY_SUPPORT /* resource manager for H/W resources */ MMCamcorderResourceManager resource_manager; +#endif /* _MMCAMCORDER_MURPHY_SUPPORT */ + /* gdbus */ + GDBusConnection *gdbus_conn; /**< gdbus connection */ + _MMCamcorderGDbusCbInfo gdbus_info_sound; /**< Informations for the gbus cb of sound play */ + _MMCamcorderGDbusCbInfo gdbus_info_solo_sound; /**< Informations for the gbus cb of solo sound play */ + + /* DPM(device policy manager) */ + device_policy_manager_h dpm_handle; /**< DPM handle */ + int dpm_camera_cb_id; /**< DPM camera policy changed callback id */ + + /* Storage */ + _MMCamcorderStorageInfo storage_info; /**< Storage information */ + +#ifdef _MMCAMCORDER_RM_SUPPORT + rm_category_request_s request_resources; + rm_device_return_s returned_devices; +#endif /* _MMCAMCORDER_RM_SUPPORT */ int reserved[4]; /**< reserved */ } mmf_camcorder_t; @@ -861,7 +946,7 @@ int _mmcamcorder_commit(MMHandleType hcamcorder); int _mmcamcorder_cancel(MMHandleType hcamcorder); /** - * This function calls after commiting action finished asynchronously. + * This function calls after commiting action finished asynchronously. * In this function, remaining process , such as state change, happens. * * @param[in] hcamcorder Specifies the camcorder handle @@ -884,15 +969,15 @@ int _mmcamcorder_commit_async_end(MMHandleType hcamcorder); * @return This function returns zero on success, or negative value with error code. * @remarks typedef bool (*mm_message_callback) (int msg, mm_messageType *param, void *user_param);@n * @n - * typedef union @n + * typedef union @n * { @n * int code; @n - * struct @n + * struct @n * { @n * int total; @n * int elapsed; @n * } time; @n - * struct @n + * struct @n * { @n * int previous; @n * int current; @n @@ -1092,21 +1177,21 @@ gboolean _mmcamcorder_pipeline_cb_message(GstBus *bus, GstMessage *message, gpoi GstBusSyncReply _mmcamcorder_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data); /** - * This function is callback function of main pipeline. + * This function is callback function of encode pipeline. * Once this function is registered with certain pipeline using gst_bus_set_sync_handler(), * this callback will be called every time when there is upcomming message from pipeline. - * Basically, this function is used as sync error handling function, now. + * Basically, this function is used for EOS and error handling now. * * @param[in] bus pointer of buf that called this function. * @param[in] message callback message from pipeline. * @param[in] data user data. * @return This function returns true on success, or false value with error * @remarks + * @see __mmcamcorder_create_recorder_pipeline() * @see __mmcamcorder_create_audiop_with_encodebin() * */ -GstBusSyncReply _mmcamcorder_audio_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data); - +GstBusSyncReply _mmcamcorder_encode_pipeline_bus_sync_callback(GstBus *bus, GstMessage *message, gpointer data); /** * This function create main pipeline according to type. @@ -1173,12 +1258,15 @@ int _mmcamcorder_video_average_framerate(MMHandleType handle); /* sound focus related function */ void __mmcamcorder_force_stop(mmf_camcorder_t *hcamcorder); void _mmcamcorder_sound_focus_cb(int id, mm_sound_focus_type_e focus_type, - mm_sound_focus_state_e focus_state, const char *reason_for_change, - const char *additional_info, void *user_data); + mm_sound_focus_state_e focus_state, const char *reason_for_change, + const char *additional_info, void *user_data); void _mmcamcorder_sound_focus_watch_cb(mm_sound_focus_type_e focus_type, mm_sound_focus_state_e focus_state, - const char *reason_for_change, const char *additional_info, void *user_data); + const char *reason_for_change, const char *additional_info, void *user_data); + +/* device policy manager */ +void _mmcamcorder_dpm_camera_policy_changed_cb(const char *name, const char *value, void *user_data); -/* For hand over the server's caps informations to client */ +/* For hand over the server's caps information to client */ int _mmcamcorder_get_video_caps(MMHandleType handle, char **caps); #ifdef __cplusplus