Add code to get replay gain information after audio recording
[platform/core/multimedia/libmm-camcorder.git] / src / include / mm_camcorder_internal.h
index 6e6982b..21bb5a1 100644 (file)
 #include <mm_attrs.h>
 #include <mm_attrs_private.h>
 #include <mm_message.h>
+#include <mm_session.h>
+#include <mm_session_private.h>
 #include <mm_sound_focus.h>
 #include <vconf.h>
 #include <gst/video/video-format.h>
 #include <ttrace.h>
 #include <errno.h>
 #include <restriction.h> /* device policy manager */
+#include <dlog.h>
 
 #include "mm_camcorder.h"
-#include "mm_debug.h"
-#include "mm_camcorder_resource.h"
+
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
+#include <mm_resource_manager.h>
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
 
 /* camcorder sub module */
 #include "mm_camcorder_attribute.h"
 #include "mm_camcorder_configure.h"
 #include "mm_camcorder_sound.h"
 
+#ifdef _MMCAMCORDER_RM_SUPPORT
+/* rm (resource manager)*/
+#include <rm_api.h>
+#endif /* _MMCAMCORDER_RM_SUPPORT */
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "MM_CAMCORDER"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -64,33 +79,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...)  SLOGI(fmt, ##args);
+#define _mmcam_dbg_log(fmt, args...)   SLOGD(fmt, ##args);
+#define _mmcam_dbg_warn(fmt, args...)  SLOGW(fmt, ##args);
+#define _mmcam_dbg_err(fmt, args...)   SLOGE(fmt, ##args);
+#define _mmcam_dbg_crit(fmt, args...)  SLOGF(fmt, ##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
 /**
@@ -101,6 +113,7 @@ extern "C" {
 
 /* gstreamer element creation macro */
 #define _MMCAMCORDER_PIPELINE_MAKE(sub_context, element, eid, name /*char* */, err) \
+do { \
        if (element[eid].gst != NULL) { \
                _mmcam_dbg_err("The element(Pipeline) is existed. element_id=[%d], name=[%s]", eid, name); \
                gst_object_unref(element[eid].gst); \
@@ -113,9 +126,11 @@ extern "C" {
                goto pipeline_creation_error; \
        } else { \
                g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
-       }
+       } \
+} while (0)
 
 #define _MMCAMCORDER_BIN_MAKE(sub_context, element, eid, name /*char* */, err) \
+do { \
        if (element[eid].gst != NULL) { \
                _mmcam_dbg_err("The element(Bin) is existed. element_id=[%d], name=[%s]", eid, name); \
                gst_object_unref(element[eid].gst); \
@@ -128,9 +143,11 @@ extern "C" {
                goto pipeline_creation_error; \
        } else { \
                g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
-       }
+       } \
+} while (0)
 
 #define _MMCAMCORDER_ELEMENT_MAKE(sub_context, element, eid, name /*char* */, nickname /*char* */, elist, err) \
+do { \
        if (element[eid].gst != NULL) { \
                _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
                gst_object_unref(element[eid].gst); \
@@ -148,9 +165,11 @@ extern "C" {
                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]));
+       elist = g_list_append(elist, &(element[eid])); \
+} while (0)
 
 #define _MMCAMCORDER_ELEMENT_MAKE2(sub_context, element, eid, name /*char* */, nickname /*char* */, err) \
+do { \
        if (element[eid].gst != NULL) { \
                _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
                gst_object_unref(element[eid].gst); \
@@ -165,8 +184,10 @@ extern "C" {
                g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
                err = MM_ERROR_NONE; \
        } \
+} while (0)
 
 #define _MMCAMCORDER_ELEMENT_MAKE_IGNORE_ERROR(sub_context, element, eid, name /*char* */, nickname /*char* */, elist) \
+do { \
        if (element[eid].gst != NULL) { \
                _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
                gst_object_unref(element[eid].gst); \
@@ -179,9 +200,31 @@ extern "C" {
                element[eid].id = eid; \
                g_object_weak_ref(G_OBJECT(element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
                elist = g_list_append(elist, &(element[eid])); \
-       }
+       } \
+} while (0)
+
+#define _MMCAMCORDER_ELEMENT_ADD(sub_context, element, eid, gst_element, elist, err) \
+do { \
+       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])); \
+} while (0)
 
 #define _MMCAMCORDER_ENCODEBIN_ELMGET(sub_context, eid, name /*char* */, err) \
+do { \
        if (sub_context->encode_element[eid].gst != NULL) { \
                _mmcam_dbg_err("The element is existed. element_id=[%d], name=[%s]", eid, name); \
                gst_object_unref(sub_context->encode_element[eid].gst); \
@@ -195,7 +238,8 @@ extern "C" {
        } else{ \
                gst_object_unref(sub_context->encode_element[eid].gst); \
                g_object_weak_ref(G_OBJECT(sub_context->encode_element[eid].gst), (GWeakNotify)_mmcamcorder_element_release_noti, sub_context); \
-       }
+       } \
+} while (0)
 
 /* GStreamer element remove macro */
 #define _MMCAMCORDER_ELEMENT_REMOVE(element, eid) \
@@ -209,52 +253,53 @@ 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 = GST_PAD_LINK_OK;\
-       if (srcpad == NULL || sinkpad == NULL) {\
-               if (srcpad == NULL) {\
-                       _mmcam_dbg_err("srcpad is NULL");\
-               } else {\
+#define _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, if_fail_goto) \
+do { \
+       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);\
+                       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;\
+               } \
+               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; \
+} while (0)
 
-#define _MM_GST_PAD_UNLINK_UNREF( srcpad, sinkpad) \
+#define _MM_GST_PAD_UNLINK_UNREF(srcpad, sinkpad) \
+do { \
        if (srcpad && sinkpad) { \
                gst_pad_unlink(srcpad, sinkpad); \
        } else { \
@@ -265,7 +310,8 @@ extern "C" {
        } \
        if (sinkpad) { \
                gst_object_unref(sinkpad); sinkpad = NULL; \
-       }
+       } \
+} while (0)
 
 #define        _MMCAMCORDER_STATE_SET_COUNT            3               /* checking interval */
 #define        _MMCAMCORDER_STATE_CHECK_TOTALTIME      5000000L        /* total wating time for state change */
@@ -291,6 +337,11 @@ extern "C" {
 #define _MMCamcorder_FILENAME_LEN      (512)
 
 /**
+ *     File name for NULL path
+ */
+#define _MMCamcorder_FILENAME_NULL     "/dev/null"
+
+/**
  *     Minimum integer value
  */
 #define _MMCAMCORDER_MIN_INT   (INT_MIN)
@@ -330,15 +381,19 @@ extern "C" {
 
 #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, timeout)    g_cond_wait_until(&_MMCAMCORDER_GET_COND(handle), &_MMCAMCORDER_GET_LOCK(handle), &end_time)
+#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_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)
@@ -384,6 +439,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))
 
+#define _MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle)      (_MMCAMCORDER_CAST_MTSAFE(handle).mstream_cb_lock)
+#define _MMCAMCORDER_LOCK_MSTREAM_CALLBACK(handle)          _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
+#define _MMCAMCORDER_TRYLOCK_MSTREAM_CALLBACK(handle)       _MMCAMCORDER_TRYLOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
+#define _MMCAMCORDER_UNLOCK_MSTREAM_CALLBACK(handle)        _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_MSTREAM_CALLBACK_LOCK(handle))
+
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
+/* for resource conflict */
+#define _MMCAMCORDER_GET_RESOURCE_LOCK(handle)              (_MMCAMCORDER_CAST_MTSAFE(handle).resource_lock)
+#define _MMCAMCORDER_LOCK_RESOURCE(handle)                  _MMCAMCORDER_LOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
+#define _MMCAMCORDER_UNLOCK_RESOURCE(handle)                _MMCAMCORDER_UNLOCK_FUNC(_MMCAMCORDER_GET_RESOURCE_LOCK(handle))
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
+
 /**
  * Caster of main handle (camcorder)
  */
@@ -480,6 +547,7 @@ typedef enum {
 
        /* Pipeline element of Video output */
        _MMCAMCORDER_VIDEOSINK_QUE,
+       _MMCAMCORDER_VIDEOSINK_CLS,
        _MMCAMCORDER_VIDEOSINK_SINK,
 
        _MMCAMCORDER_PIPELINE_ELEMENT_NUM,
@@ -502,6 +570,7 @@ typedef enum {
        _MMCAMCORDER_AUDIOSRC_QUE,
        _MMCAMCORDER_AUDIOSRC_CONV,
        _MMCAMCORDER_AUDIOSRC_VOL,
+       _MMCAMCORDER_AUDIOSRC_RGA,      /* for replay gain analysis element */
 
        /* Pipeline element of Encodebin */
        _MMCAMCORDER_ENCSINK_BIN,
@@ -542,9 +611,10 @@ 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
+       _MMCAMCORDER_STATE_CHANGE_BY_DPM,
+       _MMCAMCORDER_STATE_CHANGE_BY_STORAGE
 } _MMCamcorderStateChange;
 
 
@@ -578,6 +648,7 @@ typedef struct {
        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) */
@@ -586,9 +657,23 @@ typedef struct {
        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) */
+       GMutex mstream_cb_lock;         /**< Mutex (for muxed stream callback) */
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
+       GMutex resource_lock;           /**< Mutex (for resource check) */
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
 } _MMCamcorderMTSafe;
 
 /**
+ * MMCamcorder Replay gain value
+ */
+typedef struct {
+       gdouble track_peak;
+       gdouble track_gain;
+       gdouble album_peak;
+       gdouble album_gain;
+} _MMCamcorderReplayGain;
+
+/**
  * MMCamcorder Sub Context
  */
 typedef struct {
@@ -609,11 +694,15 @@ typedef struct {
        gboolean bencbin_capture;               /**< Use Encodebin for capturing */
        gboolean audio_disable;                 /**< whether audio is disabled or not when record */
        int videosrc_rotate;                    /**< rotate of videosrc */
+       unsigned long long muxed_stream_offset; /**< current offset for muxed stream data */
 
        /* For dropping video frame when start recording */
        int drop_vframe;                        /**< When this value is bigger than zero and pass_first_vframe is zero, MSL will drop video frame though cam_stability count is bigger then zero. */
        int pass_first_vframe;                  /**< When this value is bigger than zero, MSL won't drop video frame though "drop_vframe" is bigger then zero. */
 
+       /* Replay gain */
+       _MMCamcorderReplayGain replay_gain;     /**< Replay gain for audio recording */
+
        /* INI information */
        unsigned int fourcc;                    /**< Get fourcc value of camera INI file */
        _MMCamcorderImageInfo *info_image;      /**< extra information for image capture */
@@ -639,9 +728,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 */
@@ -655,6 +742,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 */
@@ -667,20 +757,23 @@ typedef struct mmf_camcorder {
        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_muxed_stream_callback mstream_cb;          /**< Muxed stream callback */
+       void *mstream_cb_param;                                 /**< Muxed 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 */
        mm_cam_attr_construct_info *cam_attrs_const_info;       /**< attribute info */
-       conf_info_tableconf_main_info_table[CONFIGURE_CATEGORY_MAIN_NUM]; /** configure info table - MAIN category */
-       conf_info_tableconf_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 */
        GMutex restart_preview_lock;                            /**< Capture sound mutex */
        int use_zero_copy_format;                               /**< Whether use 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 */
@@ -694,6 +787,7 @@ typedef struct mmf_camcorder {
        int sound_focus_register;                               /**< Use sound focus internally */
        int sound_focus_id;                                     /**< id for sound focus */
        int sound_focus_watch_id;                               /**< id for sound focus watch */
+       unsigned int sound_focus_subscribe_id;                  /**< subscribe id for sound focus signal */
        int interrupt_code;                                     /**< Interrupt code */
        int acquired_focus;                                     /**< Current acquired focus */
        int session_type;                                       /**< Session type */
@@ -714,8 +808,14 @@ typedef struct mmf_camcorder {
        GCond task_thread_cond;                                 /**< cond for task thread */
        _MMCamcorderTaskThreadState task_thread_state;          /**< state of task thread */
 
+#ifdef _MMCAMCORDER_MM_RM_SUPPORT
        /* resource manager for H/W resources */
-       MMCamcorderResourceManager resource_manager;
+       mm_resource_manager_h resource_manager;
+       mm_resource_manager_res_h camera_resource;
+       mm_resource_manager_res_h video_overlay_resource;
+       mm_resource_manager_res_h video_encoder_resource;
+       gboolean is_release_cb_calling;
+#endif /* _MMCAMCORDER_MM_RM_SUPPORT */
 
        /* gdbus */
        GDBusConnection *gdbus_conn;                            /**< gdbus connection */
@@ -723,10 +823,16 @@ typedef struct mmf_camcorder {
        _MMCamcorderGDbusCbInfo gdbus_info_solo_sound;          /**< Informations for the gbus cb of solo sound play */
 
        /* DPM(device policy manager) */
-       dpm_context_h dpm_context;                              /**< DPM context handle */
-       dpm_restriction_policy_h dpm_policy;                    /**< DPM restriction policy handle */
+       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;
 
@@ -889,7 +995,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
@@ -912,15 +1018,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
@@ -968,6 +1074,20 @@ int _mmcamcorder_set_audio_stream_callback(MMHandleType handle,
                                           void *user_data);
 
 /**
+ *     This function is to set callback for muxed stream.
+ *
+ *     @param[in]      hcamcorder      Specifies the camcorder handle
+ *     @param[in]      callback        Specifies the function pointer of callback function
+ *     @param[in]      user_data       Specifies the user poiner for passing to callback function
+ *
+ *     @return         This function returns zero on success, or negative value with error code.
+ *     @see            mmcamcorder_error_type
+ */
+int _mmcamcorder_set_muxed_stream_callback(MMHandleType handle,
+                                          mm_camcorder_muxed_stream_callback callback,
+                                          void *user_data);
+
+/**
  *     This function is to set callback for video capture.
  *
  *     @param[in]      hcamcorder      Specifies the camcorder  handle
@@ -1028,6 +1148,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.
@@ -1042,18 +1163,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.
  *
  * @param[in]  type            Allocation type of camcorder context.
@@ -1120,21 +1229,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.
@@ -1174,18 +1283,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);
@@ -1199,18 +1296,23 @@ int _mmcamcorder_video_current_framerate(MMHandleType handle);
 int _mmcamcorder_video_average_framerate(MMHandleType handle);
 
 /* sound focus related function */
-void __mmcamcorder_force_stop(mmf_camcorder_t *hcamcorder);
+void __mmcamcorder_force_stop(mmf_camcorder_t *hcamcorder, int state_change_by_system);
 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);
-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);
+       mm_sound_focus_state_e focus_state, const char *reason_for_change,
+       int option, const char *additional_info, void *user_data);
+void _mmcamcorder_sound_focus_watch_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);
+void _mmcamcorder_sound_signal_callback(mm_sound_signal_name_t signal, int value, 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 information to client */
-int _mmcamcorder_get_video_caps(MMHandleType handle, char **caps);
+/* Emit dbus signal */
+void _mmcamcorder_emit_signal(MMHandleType handle, const char *object_name,
+       const char *interface_name, const char *signal_name, int value);
+
+/* external storage state management */
+int _mmcamcorder_manage_external_storage_state(MMHandleType handle, int storage_state);
 
 #ifdef __cplusplus
 }