Fix build warnings
[platform/core/api/recorder.git] / src / recorder.c
index 59689e6..e240071 100644 (file)
@@ -17,6 +17,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <inttypes.h>
 #include <camera_internal.h>
 #include <recorder.h>
 #include <sound_manager.h>
 #include <storage-internal.h>
 #include <muse_recorder.h>
 #include <muse_recorder_msg.h>
-#include <muse_core_ipc.h>
-#include <muse_core_module.h>
+#include <muse_core.h>
+#include <muse_client.h>
 #include <recorder_private.h>
-#include <glib.h>
 #include <gio/gio.h>
 #include <dlog.h>
 #include <tzplatform_config.h>
@@ -36,7 +36,8 @@
 #ifdef LOG_TAG
 #undef LOG_TAG
 #endif
-#define LOG_TAG "TIZEN_N_RECORDER"
+#define LOG_TAG         "TIZEN_N_RECORDER"
+#define MODULE_NAME     "recorder"
 
 /* for device changed callback */
 static GMutex g_rec_dev_state_changed_cb_lock;
@@ -44,6 +45,27 @@ static GList *g_rec_dev_state_changed_cb_list;
 static int g_rec_dev_state_changed_cb_id;
 static GDBusConnection *g_rec_dev_state_changed_cb_conn;
 static guint g_rec_dev_state_changed_cb_subscribe_id;
+static GMutex g_rec_idle_event_lock;
+
+
+
+static void __recorder_update_api_waiting(recorder_cb_info_s *cb_info, int api, int value)
+{
+       if (!cb_info ||
+               api < 0 || api >= MUSE_RECORDER_API_MAX) {
+               LOGE("invalid param %p %d", cb_info, api);
+               return;
+       }
+
+       g_mutex_lock(&(cb_info->api_mutex[api]));
+       cb_info->api_waiting[api] += value;
+       g_mutex_unlock(&(cb_info->api_mutex[api]));
+
+       /*LOGD("api %d, value %d, waiting %d",
+               api, value, cb_info->api_waiting[api]);*/
+
+       return;
+}
 
 
 static void __recorder_device_state_changed_cb(GDBusConnection *connection,
@@ -96,20 +118,20 @@ _DONE:
 }
 
 
-static int _recorder_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
+static int _recorder_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle)
 {
        tbm_bo tmp_bo = NULL;
        tbm_bo_handle tmp_bo_handle = {NULL, };
 
-       if (bufmgr == NULL || bo == NULL || bo_handle == NULL || tbm_key == 0) {
-               LOGE("invalid parameter - bufmgr %p, bo %p, bo_handle %p, key %d",
-                    bufmgr, bo, bo_handle, tbm_key);
+       if (bufmgr == NULL || bo == NULL || bo_handle == NULL || fd < 0) {
+               LOGE("invalid parameter - bufmgr %p, bo %p, bo_handle %p, fd %d",
+                    bufmgr, bo, bo_handle, fd);
                return false;
        }
 
-       tmp_bo = tbm_bo_import(bufmgr, tbm_key);
+       tmp_bo = tbm_bo_import_fd(bufmgr, (tbm_fd)fd);
        if (tmp_bo == NULL) {
-               LOGE("bo import failed - bufmgr %p, key %d", bufmgr, tbm_key);
+               LOGE("bo import failed - bufmgr %p, fd %d", bufmgr, fd);
                return false;
        }
 
@@ -142,7 +164,7 @@ static void _recorder_release_imported_bo(tbm_bo *bo)
        return;
 }
 
-static void _recorder_client_user_callback(recorder_cb_info_s *cb_info, char *recv_msg, muse_recorder_event_e event)
+static void _recorder_client_user_callback(recorder_cb_info_s *cb_info, char *recv_msg, muse_recorder_event_e event, int tfd)
 {
        if (recv_msg == NULL || event >= MUSE_RECORDER_EVENT_TYPE_NUM) {
                LOGE("invalid parameter - recorder msg %p, event %d", recv_msg, event);
@@ -151,9 +173,17 @@ static void _recorder_client_user_callback(recorder_cb_info_s *cb_info, char *re
 
        /*LOGD("get recorder msg %s, event %d", recv_msg, event);*/
 
+       g_mutex_lock(&cb_info->user_cb_mutex[event]);
+
        if (cb_info->user_cb[event] == NULL) {
-               LOGW("user callback for event %d is not set", event);
-               return;
+               if (event != MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM &&
+                       event != MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM) {
+                       g_mutex_unlock(&cb_info->user_cb_mutex[event]);
+                       LOGW("NULL callback for event %d, return here", event);
+                       return;
+               } else {
+                       LOGW("NULL callback for event %d, NOT return here", event);
+               }
        }
 
        switch (event) {
@@ -188,8 +218,8 @@ static void _recorder_client_user_callback(recorder_cb_info_s *cb_info, char *re
                        int64_t cb_elapsed_time = 0;
                        int64_t cb_file_size = 0;
 
-                       muse_recorder_msg_get(cb_elapsed_time, recv_msg);
-                       muse_recorder_msg_get(cb_file_size, recv_msg);
+                       muse_recorder_msg_get_int64(cb_elapsed_time, recv_msg);
+                       muse_recorder_msg_get_int64(cb_file_size, recv_msg);
 
                        ((recorder_recording_status_cb)cb_info->user_cb[event])((unsigned long long)cb_elapsed_time,
                                (unsigned long long)cb_file_size,
@@ -206,12 +236,7 @@ static void _recorder_client_user_callback(recorder_cb_info_s *cb_info, char *re
                        muse_recorder_msg_get(previous, recv_msg);
                        muse_recorder_msg_get(current, recv_msg);
 
-                       if (policy == RECORDER_POLICY_SOUND)
-                               LOGW("DEPRECATION WARNING: RECORDER_POLICY_SOUND is deprecated and will be removed from next release.");
-                       else if (policy == RECORDER_POLICY_SOUND_BY_CALL)
-                               LOGW("DEPRECATION WARNING: RECORDER_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
-                       else if (policy == RECORDER_POLICY_SOUND_BY_ALARM)
-                               LOGW("DEPRECATION WARNING: RECORDER_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
+                       LOGW("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
 
                        ((recorder_interrupted_cb)cb_info->user_cb[event])((recorder_policy_e)policy,
                                (recorder_state_e)previous,
@@ -219,9 +244,23 @@ static void _recorder_client_user_callback(recorder_cb_info_s *cb_info, char *re
                                cb_info->user_data[event]);
                        break;
                }
+       case MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED:
+               {
+                       int policy = 0;
+                       int state = 0;
+
+                       muse_recorder_msg_get(policy, recv_msg);
+                       muse_recorder_msg_get(state, recv_msg);
+
+                       LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
+
+                       ((recorder_interrupt_started_cb)cb_info->user_cb[event])((recorder_policy_e)policy,
+                               (recorder_state_e)state, cb_info->user_data[event]);
+               }
+               break;
        case MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM:
                {
-                       int tbm_key = 0;
+                       int audio_fd = -1;
                        int size = 0;
                        int format = 0;
                        int channel = 0;
@@ -230,42 +269,110 @@ static void _recorder_client_user_callback(recorder_cb_info_s *cb_info, char *re
                        tbm_bo_handle bo_handle = {.ptr = NULL};
                        char *send_msg = NULL;
 
-                       muse_recorder_msg_get(tbm_key, recv_msg);
-                       if (tbm_key == 0) {
-                               LOGE("invalid key");
+                       if (tfd < 0) {
+                               LOGE("invalid fd %d", tfd);
                                break;
                        }
 
-                       if (!_recorder_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
-                               LOGE("tbm key %d import failed", tbm_key);
+                       muse_recorder_msg_get(audio_fd, recv_msg);
+
+                       if (cb_info->user_cb[event]) {
+                               if (_recorder_import_tbm_fd(cb_info->bufmgr, tfd, &bo, &bo_handle)) {
+                                       muse_recorder_msg_get(size, recv_msg);
+                                       muse_recorder_msg_get(format, recv_msg);
+                                       muse_recorder_msg_get(channel, recv_msg);
+                                       muse_recorder_msg_get(timestamp, recv_msg);
+
+                                       LOGD("%p, size %d, format %d, channel %d, timestamp %d",
+                                               bo_handle.ptr, size, format, channel, timestamp);
+
+                                       ((recorder_audio_stream_cb)cb_info->user_cb[event])((void *)bo_handle.ptr,
+                                               size, (audio_sample_type_e)format, channel,
+                                               (unsigned int)timestamp, cb_info->user_data[event]);
+
+                                       LOGD("returned");
+
+                                       /* release imported bo */
+                                       _recorder_release_imported_bo(&bo);
+                               } else {
+                                       LOGE("tbm fd %d import failed", tfd);
+                               }
+                       }
+
+                       /* return buffer */
+                       send_msg = muse_core_msg_new(MUSE_RECORDER_API_RETURN_BUFFER,
+                               MUSE_TYPE_INT, "ret_fd", audio_fd, NULL);
+
+                       if (send_msg) {
+                               if (muse_core_msg_send(cb_info->fd, send_msg) <= 0)
+                                       LOGE("sending message failed");
+
+                               muse_core_msg_free(send_msg);
+                               send_msg = NULL;
+                       } else {
+                               LOGE("failed to create send msg for fd %d", audio_fd);
+                       }
+
+                       /* close imported fd */
+                       close(tfd);
+                       tfd = -1;
+                       break;
+               }
+       case MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM:
+               {
+                       int muxed_fd = -1;
+                       int size = 0;
+                       int64_t offset = 0;
+
+                       tbm_bo bo = NULL;
+                       tbm_bo_handle bo_handle = {.ptr = NULL};
+                       char *send_msg = NULL;
+
+                       if (tfd < 0) {
+                               LOGE("invalid fd %d", tfd);
                                break;
                        }
 
-                       muse_recorder_msg_get(size, recv_msg);
-                       muse_recorder_msg_get(format, recv_msg);
-                       muse_recorder_msg_get(channel, recv_msg);
-                       muse_recorder_msg_get(timestamp, recv_msg);
-
-                       ((recorder_audio_stream_cb)cb_info->user_cb[event])((void *)bo_handle.ptr,
-                               size,
-                               (audio_sample_type_e)format,
-                               channel,
-                               (unsigned int)timestamp,
-                               cb_info->user_data[event]);
+                       muse_recorder_msg_get(muxed_fd, recv_msg);
 
-                       /* release imported bo */
-                       _recorder_release_imported_bo(&bo);
+                       if (cb_info->user_cb[event]) {
+                               if (_recorder_import_tbm_fd(cb_info->bufmgr, tfd, &bo, &bo_handle)) {
+                                       muse_recorder_msg_get(size, recv_msg);
+                                       muse_recorder_msg_get_int64(offset, recv_msg);
 
-                       /* return buffer */
-                       send_msg = muse_core_msg_json_factory_new(MUSE_RECORDER_API_RETURN_BUFFER,
-                               MUSE_TYPE_INT, "tbm_key", tbm_key, NULL);
+                                       LOGD("%p, size %d, offset %"PRId64, bo_handle.ptr, size, offset);
 
-                       if (muse_core_ipc_send_msg(cb_info->fd, send_msg) <= 0)
-                               LOGE("sending message failed");
+                                       ((recorder_muxed_stream_cb)cb_info->user_cb[event])((void *)bo_handle.ptr,
+                                               size, (unsigned long long)offset, cb_info->user_data[event]);
 
-                       muse_core_msg_json_factory_free(send_msg);
+                                       LOGD("returned");
+
+                                       /* release imported bo */
+                                       _recorder_release_imported_bo(&bo);
+                               } else {
+                                       LOGE("tbm fd %d import failed", tfd);
+                               }
+                       }
+
+                       /* return buffer */
+                       send_msg = muse_core_msg_new(MUSE_RECORDER_API_RETURN_BUFFER,
+                               MUSE_TYPE_INT, "ret_fd", muxed_fd, NULL);
+                       if (send_msg) {
+                               if (muse_core_msg_send(cb_info->fd, send_msg) <= 0)
+                                       LOGE("sending message failed");
+
+                               muse_core_msg_free(send_msg);
+                               send_msg = NULL;
+                       } else {
+                               LOGE("failed to create send msg for fd %d", tfd);
+                       }
+
+                       /* close imported fd */
+                       close(tfd);
+                       tfd = -1;
                        break;
                }
+//LCOV_EXCL_START
        case MUSE_RECORDER_EVENT_TYPE_ERROR:
                {
                        int error = 0;
@@ -274,18 +381,12 @@ static void _recorder_client_user_callback(recorder_cb_info_s *cb_info, char *re
                        muse_recorder_msg_get(error, recv_msg);
                        muse_recorder_msg_get(current_state, recv_msg);
 
-                       if (error == RECORDER_ERROR_SOUND_POLICY)
-                               LOGW("DEPRECATION WARNING: RECORDER_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
-                       else if (error == RECORDER_ERROR_SOUND_POLICY_BY_CALL)
-                               LOGW("DEPRECATION WARNING: RECORDER_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
-                       else if (error == RECORDER_ERROR_SOUND_POLICY_BY_ALARM)
-                               LOGW("DEPRECATION WARNING: RECORDER_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
-
                        ((recorder_error_cb)cb_info->user_cb[event])((recorder_error_e)error,
                                (recorder_state_e)current_state,
                                cb_info->user_data[event]);
                        break;
                }
+//LCOV_EXCL_STOP
        case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER:
                {
                        int codec = 0;
@@ -325,7 +426,7 @@ static void _recorder_client_user_callback(recorder_cb_info_s *cb_info, char *re
                        }
                        break;
                }
-       case MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION:
+       default: /* MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION */
                {
                        int width = 0;
                        int height = 0;
@@ -340,74 +441,63 @@ static void _recorder_client_user_callback(recorder_cb_info_s *cb_info, char *re
                        }
                        break;
                }
-
-       default:
-                       LOGE("Unknonw recorder event %d", event);
-                       break;
        }
 
+       g_mutex_unlock(&cb_info->user_cb_mutex[event]);
+
        return;
 }
 
 
-static bool _recorder_idle_event_callback(void *data)
+static gboolean _recorder_idle_event_callback(gpointer data)
 {
        recorder_cb_info_s *cb_info = NULL;
        recorder_idle_event_s *rec_idle_event = (recorder_idle_event_s *)data;
 
        if (rec_idle_event == NULL) {
                LOGE("rec_idle_event is NULL");
-               return false;
+               return FALSE;
        }
 
        /* lock event */
-       g_mutex_lock(&rec_idle_event->event_mutex);
+       g_mutex_lock(&g_rec_idle_event_lock);
 
        cb_info = rec_idle_event->cb_info;
        if (cb_info == NULL) {
-               LOGW("recorder cb_info is NULL. event %d", rec_idle_event->event);
+               LOGW("recorder cb_info is NULL. event %p %d", rec_idle_event, rec_idle_event->event);
+               g_mutex_unlock(&g_rec_idle_event_lock);
                goto IDLE_EVENT_CALLBACK_DONE;
        }
 
        /* remove event from list */
-       g_mutex_lock(&cb_info->idle_event_mutex);
        if (cb_info->idle_event_list)
                cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)rec_idle_event);
 
-       /*LOGD("remove recorder idle event %p, %p", rec_idle_event, cb_info->idle_event_list);*/
-       g_mutex_unlock(&cb_info->idle_event_mutex);
+       g_mutex_unlock(&g_rec_idle_event_lock);
 
        /* user callback */
-       _recorder_client_user_callback(rec_idle_event->cb_info, rec_idle_event->recv_msg, rec_idle_event->event);
-
-       /* send signal for waiting thread */
-       g_cond_signal(&cb_info->idle_event_cond);
+       _recorder_client_user_callback(cb_info, rec_idle_event->recv_msg, rec_idle_event->event, -1);
 
 IDLE_EVENT_CALLBACK_DONE:
-       /* unlock and release event */
-       g_mutex_unlock(&rec_idle_event->event_mutex);
-       g_mutex_clear(&rec_idle_event->event_mutex);
-
+       /* release event */
        g_free(rec_idle_event);
        rec_idle_event = NULL;
 
-       return false;
+       return FALSE;
 }
 
 
-static void _recorder_remove_idle_event_all(recorder_cb_info_s *cb_info)
+static void _recorder_deactivate_idle_event_all(recorder_cb_info_s *cb_info)
 {
        recorder_idle_event_s *rec_idle_event = NULL;
-       gboolean ret = true;
        GList *list = NULL;
-       gint64 end_time = 0;
 
        if (cb_info == NULL) {
                LOGE("cb_info is NULL");
                return;
        }
 
-       g_mutex_lock(&cb_info->idle_event_mutex);
+       g_mutex_lock(&g_rec_idle_event_lock);
 
        if (cb_info->idle_event_list == NULL) {
                LOGD("No event");
@@ -423,55 +513,39 @@ static void _recorder_remove_idle_event_all(recorder_cb_info_s *cb_info)
                                continue;
                        }
 
-                       if (!g_mutex_trylock(&rec_idle_event->event_mutex)) {
-                               LOGW("lock failed");
+                       if (g_idle_remove_by_data(rec_idle_event)) {
+                               LOGW("remove idle event %p done", rec_idle_event);
 
-                               end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
+                               cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)rec_idle_event);
 
-                               if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
-                                       LOGW("signal received");
-                               else
-                                       LOGW("timeout");
+                               g_free(rec_idle_event);
+                               rec_idle_event = NULL;
 
                                continue;
                        }
 
-                       ret = g_idle_remove_by_data(rec_idle_event);
-
-                       LOGD("remove event %p, ret %d", rec_idle_event, ret);
+                       LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
+                               rec_idle_event, rec_idle_event->event);
 
-                       if (!ret) {
-                               rec_idle_event->cb_info = NULL;
-                               LOGW("idle cb for event %p will be called later", rec_idle_event);
-                       }
+                       rec_idle_event->cb_info = NULL;
 
                        cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)rec_idle_event);
-
-                       g_mutex_unlock(&rec_idle_event->event_mutex);
-
-                       if (ret) {
-                               g_mutex_clear(&rec_idle_event->event_mutex);
-
-                               g_free(rec_idle_event);
-                               rec_idle_event = NULL;
-
-                               LOGD("remove event done");
-                       }
                }
 
                g_list_free(cb_info->idle_event_list);
                cb_info->idle_event_list = NULL;
        }
 
-       g_mutex_unlock(&cb_info->idle_event_mutex);
+       g_mutex_unlock(&g_rec_idle_event_lock);
 
        return;
 }
 
 
-static void __recorder_add_msg_to_queue(recorder_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
+static void __recorder_add_msg_to_queue(recorder_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int tfd)
 {
        recorder_message_s *rec_msg = NULL;
+       recorder_msg_handler_info_s *msg_handler_info = NULL;
 
        if (!cb_info || !msg) {
                LOGE("NULL pointer %p %p", cb_info, msg);
@@ -487,22 +561,23 @@ static void __recorder_add_msg_to_queue(recorder_cb_info_s *cb_info, int api, in
        rec_msg->api = api;
        rec_msg->event = event;
        rec_msg->event_class = event_class;
+       rec_msg->tfd = tfd;
 
        strncpy(rec_msg->recv_msg, msg, sizeof(rec_msg->recv_msg) - 1);
 
        /*LOGD("add recorder message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
 
-       if (event == MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM) {
-               g_mutex_lock(&cb_info->audio_stream_cb_info.mutex);
-               g_queue_push_tail(cb_info->audio_stream_cb_info.queue, (gpointer)rec_msg);
-               g_cond_signal(&cb_info->audio_stream_cb_info.cond);
-               g_mutex_unlock(&cb_info->audio_stream_cb_info.mutex);
-       } else {
-               g_mutex_lock(&cb_info->msg_handler_info.mutex);
-               g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)rec_msg);
-               g_cond_signal(&cb_info->msg_handler_info.cond);
-               g_mutex_unlock(&cb_info->msg_handler_info.mutex);
-       }
+       if (event == MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM)
+               msg_handler_info = &cb_info->audio_stream_cb_info;
+       else if (event == MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM)
+               msg_handler_info = &cb_info->muxed_stream_cb_info;
+       else
+               msg_handler_info = &cb_info->msg_handler_info;
+
+       g_mutex_lock(&msg_handler_info->mutex);
+       g_queue_push_tail(msg_handler_info->queue, (gpointer)rec_msg);
+       g_cond_signal(&msg_handler_info->cond);
+       g_mutex_unlock(&msg_handler_info->mutex);
 
        rec_msg = NULL;
 
@@ -645,7 +720,7 @@ static void __recorder_get_api_operation(int api, recorder_cb_info_s *cb_info, c
 }
 
 
-static void __recorder_process_msg(recorder_cb_info_s *cb_info, char *msg)
+static void __recorder_process_msg(recorder_cb_info_s *cb_info, char *msg, int tfd)
 {
        int ret = RECORDER_ERROR_NONE;
        int api = -1;
@@ -691,9 +766,6 @@ static void __recorder_process_msg(recorder_cb_info_s *cb_info, char *msg)
 
                g_mutex_lock(&cb_info->api_mutex[api]);
 
-               cb_info->api_ret[api] = ret;
-               cb_info->api_activating[api] = 1;
-
                if (api == MUSE_RECORDER_API_GET_DEVICE_STATE) {
                        g_atomic_int_set(&cb_info->msg_recv_running, 0);
                        LOGD("get device state done. close client cb handler");
@@ -717,10 +789,18 @@ static void __recorder_process_msg(recorder_cb_info_s *cb_info, char *msg)
                        }
                }
 
-               g_cond_signal(&cb_info->api_cond[api]);
+               if (cb_info->api_waiting[api] > 0) {
+                       cb_info->api_ret[api] = ret;
+                       cb_info->api_activating[api] = TRUE;
+
+                       g_cond_signal(&cb_info->api_cond[api]);
+               } else {
+                       LOGE("no waiting for api [%d]", api);
+               }
+
                g_mutex_unlock(&cb_info->api_mutex[api]);
        } else if (api_class == MUSE_RECORDER_API_CLASS_THREAD_SUB || api == MUSE_RECORDER_CB_EVENT) {
-               __recorder_add_msg_to_queue(cb_info, api, event, event_class, msg);
+               __recorder_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
        } else {
                LOGW("unknown recorder api %d and api_class %d", api, api_class);
        }
@@ -778,12 +858,16 @@ static void *_recorder_msg_handler_func(gpointer data)
                        g_mutex_lock(&cb_info->api_mutex[api]);
 
                        if (muse_recorder_msg_get(ret, rec_msg->recv_msg)) {
-                               cb_info->api_ret[api] = ret;
-                               cb_info->api_activating[api] = 1;
+                               if (cb_info->api_waiting[api] > 0) {
+                                       cb_info->api_ret[api] = ret;
+                                       cb_info->api_activating[api] = TRUE;
 
-                               /*LOGD("recorder api %d - return 0x%x", ret);*/
+                                       /*LOGD("recorder api %d - return 0x%x", api, ret);*/
 
-                               g_cond_signal(&cb_info->api_cond[api]);
+                                       g_cond_signal(&cb_info->api_cond[api]);
+                               } else {
+                                       LOGE("no waiting for api [%d]", api);
+                               }
                        } else {
                                LOGE("t:%d failed to get ret for api %d, msg %s", type, api, rec_msg->recv_msg);
                        }
@@ -792,7 +876,7 @@ static void *_recorder_msg_handler_func(gpointer data)
                } else if (api == MUSE_RECORDER_CB_EVENT) {
                        switch (rec_msg->event_class) {
                        case MUSE_RECORDER_EVENT_CLASS_THREAD_SUB:
-                               _recorder_client_user_callback(cb_info, rec_msg->recv_msg, rec_msg->event);
+                               _recorder_client_user_callback(cb_info, rec_msg->recv_msg, rec_msg->event, rec_msg->tfd);
                                break;
                        case MUSE_RECORDER_EVENT_CLASS_THREAD_MAIN:
                                rec_idle_event = g_new0(recorder_idle_event_s, 1);
@@ -803,14 +887,14 @@ static void *_recorder_msg_handler_func(gpointer data)
 
                                rec_idle_event->event = rec_msg->event;
                                rec_idle_event->cb_info = cb_info;
-                               g_mutex_init(&rec_idle_event->event_mutex);
-                               strncpy(rec_idle_event->recv_msg, rec_msg->recv_msg, sizeof(rec_idle_event->recv_msg) - 1);
+
+                               strncpy(rec_idle_event->recv_msg, rec_msg->recv_msg, sizeof(rec_idle_event->recv_msg));
 
                                /*LOGD("add recorder event[%d, %p] to IDLE", rec_msg->event, rec_idle_event);*/
 
-                               g_mutex_lock(&cb_info->idle_event_mutex);
+                               g_mutex_lock(&g_rec_idle_event_lock);
                                cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)rec_idle_event);
-                               g_mutex_unlock(&cb_info->idle_event_mutex);
+                               g_mutex_unlock(&g_rec_idle_event_lock);
 
                                g_idle_add_full(G_PRIORITY_DEFAULT,
                                        (GSourceFunc)_recorder_idle_event_callback,
@@ -854,14 +938,8 @@ static void *_recorder_msg_handler_func(gpointer data)
 static void *_recorder_msg_recv_func(gpointer data)
 {
        int recv_length = 0;
-       int single_length = 0;
-       int remained_length = 0;
+       int tfd[MUSE_NUM_FD] = {-1, -1, -1, -1};
        char *recv_msg = NULL;
-       char *single_msg = NULL;
-       char *remained_msg = NULL;
-       int num_msg = 0;
-       int cur_pos = 0;
-       int prev_pos = 0;
        recorder_cb_info_s *cb_info = (recorder_cb_info_s *)data;
 
        if (cb_info == NULL) {
@@ -871,95 +949,34 @@ static void *_recorder_msg_recv_func(gpointer data)
 
        LOGD("start");
 
-       single_msg = (char *)malloc(sizeof(char) * MUSE_RECORDER_MSG_MAX_LENGTH);
-       if (single_msg == NULL) {
-               LOGE("single_msg malloc failed");
-               goto CB_HANDLER_EXIT;
-       }
-
        recv_msg = cb_info->recv_msg;
 
        while (g_atomic_int_get(&cb_info->msg_recv_running)) {
-               recv_length = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
+               /* tfd[0] is only used. */
+               tfd[0] = -1;
+
+               recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
                if (recv_length <= 0) {
+//LCOV_EXCL_START
                        cb_info->is_server_connected = FALSE;
                        LOGE("receive msg failed - server disconnected");
                        break;
+//LCOV_EXCL_STOP
                }
 
                recv_msg[recv_length] = '\0';
 
-               cur_pos = 0;
-               prev_pos = 0;
-               num_msg = 0;
-
                /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
 
-               /* Need to split the combined entering msgs */
-               for (cur_pos = 0; cur_pos < recv_length; cur_pos++) {
-                       if (recv_msg[cur_pos] == '}') {
-                               single_length = cur_pos - prev_pos + 1;
-
-                               if (single_length < MUSE_RECORDER_MSG_MAX_LENGTH) {
-                                       /* check remained msg */
-                                       if (remained_length > 0) {
-                                               if (remained_msg) {
-                                                       strncpy(single_msg, remained_msg, remained_length);
-                                                       strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
-                                                       single_msg[remained_length + single_length] = '\0';
-
-                                                       free(remained_msg);
-                                                       remained_msg = NULL;
-                                               } else {
-                                                       strncpy(single_msg, recv_msg + prev_pos, single_length);
-                                                       single_msg[single_length] = '\0';
-                                                       LOGE("lost msg [%s], skip...", single_msg);
-                                               }
-
-                                               remained_length = 0;
-                                       } else {
-                                               strncpy(single_msg, recv_msg + prev_pos, single_length);
-                                               single_msg[single_length] = '\0';
-                                       }
-
-                                       if (single_msg[0] == '{') {
-                                               num_msg++;
-                                               /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
-                                               __recorder_process_msg(cb_info, single_msg);
-                                       } else {
-                                               LOGE("invalid msg [%s]", single_msg);
-                                       }
-                               } else {
-                                       LOGE("too long message [len %d] skip...", single_length);
-                               }
-
-                               prev_pos = cur_pos + 1;
-                       }
-               }
-
-               /* check incompleted message */
-               if (recv_msg[recv_length - 1] != '}') {
-                       remained_length = recv_length - prev_pos;
-
-                       LOGW("incompleted message [len %d]", remained_length);
-
-                       remained_msg = (char *)malloc(remained_length + 1);
-                       if (remained_msg) {
-                               strncpy(remained_msg, recv_msg + prev_pos, remained_length);
-                               remained_msg[remained_length] = '\0';
-                       } else {
-                               LOGE("failed to alloc for remained msg");
-                       }
-               } else {
-                       remained_length = 0;
-               }
+               __recorder_process_msg(cb_info, recv_msg, tfd[0]);
        }
 
        LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
 
        if (!cb_info->is_server_connected) {
+//LCOV_EXCL_START
                /* send error msg for server disconnection */
-               char *error_msg = muse_core_msg_json_factory_new(MUSE_RECORDER_CB_EVENT,
+               char *error_msg = muse_core_msg_new(MUSE_RECORDER_CB_EVENT,
                        MUSE_TYPE_INT, "error", RECORDER_ERROR_SERVICE_DISCONNECTED,
                        MUSE_TYPE_INT, "current_state", RECORDER_STATE_NONE,
                        NULL);
@@ -975,25 +992,17 @@ static void *_recorder_msg_recv_func(gpointer data)
                        MUSE_RECORDER_CB_EVENT,
                        MUSE_RECORDER_EVENT_TYPE_ERROR,
                        MUSE_RECORDER_EVENT_CLASS_THREAD_MAIN,
-                       error_msg);
+                       error_msg,
+                       -1);
 
-               muse_core_msg_json_factory_free(error_msg);
+               muse_core_msg_free(error_msg);
                error_msg = NULL;
 
                LOGE("add error msg for service disconnection done");
+//LCOV_EXCL_STOP
        }
 
 CB_HANDLER_EXIT:
-       if (single_msg) {
-               free(single_msg);
-               single_msg = NULL;
-       }
-
-       if (remained_msg) {
-               free(remained_msg);
-               remained_msg = NULL;
-       }
-
        return NULL;
 }
 
@@ -1025,6 +1034,7 @@ static bool __create_msg_handler_thread(recorder_msg_handler_info_s *handler_inf
        handler_info->thread = g_thread_try_new(thread_name,
                _recorder_msg_handler_func, (gpointer)handler_info, NULL);
        if (handler_info->thread == NULL) {
+//LCOV_EXCL_START
                LOGE("t:%d thread failed", type);
 
                g_mutex_clear(&handler_info->mutex);
@@ -1033,6 +1043,7 @@ static bool __create_msg_handler_thread(recorder_msg_handler_info_s *handler_inf
                handler_info->queue = NULL;
 
                return false;
+//LCOV_EXCL_STOP
        }
 
        LOGD("t:%d done", type);
@@ -1065,7 +1076,6 @@ static void __destroy_msg_handler_thread(recorder_msg_handler_info_s *handler_in
        g_mutex_unlock(&handler_info->mutex);
 
        g_thread_join(handler_info->thread);
-       g_thread_unref(handler_info->thread);
        handler_info->thread = NULL;
 
        g_mutex_clear(&handler_info->mutex);
@@ -1092,13 +1102,15 @@ static recorder_cb_info_s *_recorder_client_callback_new(gint sockfd)
                goto ErrorExit;
        }
 
+       cb_info->api_waiting[MUSE_RECORDER_API_CREATE] = 1;
+
        for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
                g_mutex_init(&cb_info->api_mutex[i]);
                g_cond_init(&cb_info->api_cond[i]);
        }
 
-       g_mutex_init(&cb_info->idle_event_mutex);
-       g_cond_init(&cb_info->idle_event_cond);
+       for (i = 0 ; i < MUSE_RECORDER_EVENT_TYPE_NUM ; i++)
+               g_mutex_init(&cb_info->user_cb_mutex[i]);
 
        /* message handler thread */
        if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
@@ -1114,6 +1126,13 @@ static recorder_cb_info_s *_recorder_client_callback_new(gint sockfd)
                goto ErrorExit;
        }
 
+       /* message handler thread for muxed stream callback */
+       if (!__create_msg_handler_thread(&cb_info->muxed_stream_cb_info,
+               _RECORDER_MESSAGE_HANDLER_TYPE_MUXED_STREAM_CB, "recorder_msg_handler:muxed_stream_cb", cb_info)) {
+               LOGE("muxed_stream_cb_info failed");
+               goto ErrorExit;
+       }
+
        cb_info->fd = sockfd;
 
        /* message receive thread */
@@ -1128,14 +1147,15 @@ static recorder_cb_info_s *_recorder_client_callback_new(gint sockfd)
        cb_info->is_server_connected = TRUE;
 
        return cb_info;
-
+//LCOV_EXCL_START
 ErrorExit:
        if (cb_info) {
                __destroy_msg_handler_thread(&cb_info->msg_handler_info);
                __destroy_msg_handler_thread(&cb_info->audio_stream_cb_info);
+               __destroy_msg_handler_thread(&cb_info->muxed_stream_cb_info);
 
-               g_mutex_clear(&cb_info->idle_event_mutex);
-               g_cond_clear(&cb_info->idle_event_cond);
+               for (i = 0 ; i < MUSE_RECORDER_EVENT_TYPE_NUM ; i++)
+                       g_mutex_clear(&cb_info->user_cb_mutex[i]);
 
                for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
                        g_mutex_clear(&cb_info->api_mutex[i]);
@@ -1147,6 +1167,7 @@ ErrorExit:
        }
 
        return NULL;
+//LCOV_EXCL_STOP
 }
 
 static int _recorder_client_wait_for_cb_return(muse_recorder_api_e api, recorder_cb_info_s *cb_info, int time_out)
@@ -1163,43 +1184,38 @@ static int _recorder_client_wait_for_cb_return(muse_recorder_api_e api, recorder
 
        g_mutex_lock(&(cb_info->api_mutex[api]));
 
-       if (cb_info->api_activating[api] == 0) {
-               end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
-               if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
-                       ret = cb_info->api_ret[api];
-                       cb_info->api_activating[api] = 0;
+       LOGD("api [%d], timeout [%d sec]", api, time_out);
 
-                       /*LOGD("return value : 0x%x", ret);*/
-               } else {
-                       ret = RECORDER_ERROR_INVALID_OPERATION;
+       end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
 
+       while (!cb_info->api_activating[api]) {
+               if (time_out == RECORDER_CB_NO_TIMEOUT) {
+                       g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
+                       LOGW("api %d returned 0x%x", api, cb_info->api_ret[api]);
+               } else if (!g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
                        LOGE("api %d was TIMED OUT!", api);
+                       ret = RECORDER_ERROR_INVALID_OPERATION;
+                       goto _CB_RETURN_END;
                }
-       } else {
-               ret = cb_info->api_ret[api];
-               cb_info->api_activating[api] = 0;
 
-               /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
+               if (!cb_info->api_activating[api])
+                       LOGW("invalid signal received, wait again...");
        }
 
-       if (ret != RECORDER_ERROR_NONE) {
-               LOGE("ERROR : api %d - ret 0x%x", api, ret);
-
-               if (ret == RECORDER_ERROR_SOUND_POLICY)
-                       LOGW("DEPRECATION WARNING: RECORDER_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
-               else if (ret == RECORDER_ERROR_SOUND_POLICY_BY_CALL)
-                       LOGW("DEPRECATION WARNING: RECORDER_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
-               else if (ret == RECORDER_ERROR_SOUND_POLICY_BY_ALARM)
-                       LOGW("DEPRECATION WARNING: RECORDER_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
-       }
+       ret = cb_info->api_ret[api];
+       cb_info->api_activating[api] = FALSE;
 
+_CB_RETURN_END:
        g_mutex_unlock(&(cb_info->api_mutex[api]));
 
+       if (ret != RECORDER_ERROR_NONE)
+               LOGE("ERROR : api %d - ret 0x%x", api, ret);
+
        return ret;
 }
 
 
-static int _recorder_msg_send(int api, recorder_cb_info_s *cb_info, int *ret)
+static int _recorder_msg_send(int api, recorder_cb_info_s *cb_info, int *ret, int timeout)
 {
        int send_ret = 0;
        char *msg = NULL;
@@ -1209,7 +1225,7 @@ static int _recorder_msg_send(int api, recorder_cb_info_s *cb_info, int *ret)
                return RECORDER_ERROR_INVALID_PARAMETER;
        }
 
-       msg = muse_core_msg_json_factory_new(api, NULL);
+       msg = muse_core_msg_new(api, NULL);
        if (!msg) {
                LOGE("msg creation failed: api %d", api);
                return RECORDER_ERROR_OUT_OF_MEMORY;
@@ -1217,17 +1233,21 @@ static int _recorder_msg_send(int api, recorder_cb_info_s *cb_info, int *ret)
 
        /*LOGD("send msg %s", msg);*/
 
-       if (cb_info->is_server_connected)
-               send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
+       if (cb_info->is_server_connected) {
+               __recorder_update_api_waiting(cb_info, api, 1);
+               send_ret = muse_core_msg_send(cb_info->fd, msg);
+       }
 
        if (send_ret < 0) {
                LOGE("message send failed");
                *ret = RECORDER_ERROR_INVALID_OPERATION;
        } else {
-               *ret = _recorder_client_wait_for_cb_return(api, cb_info, RECORDER_CB_TIMEOUT);
+               *ret = _recorder_client_wait_for_cb_return(api, cb_info, timeout);
        }
 
-       muse_core_msg_json_factory_free(msg);
+       __recorder_update_api_waiting(cb_info, api, -1);
+
+       muse_core_msg_free(msg);
 
        return RECORDER_ERROR_NONE;
 }
@@ -1247,13 +1267,13 @@ static int _recorder_msg_send_param1(int api, recorder_cb_info_s *cb_info, int *
 
        switch (param->type) {
        case MUSE_TYPE_INT:
-               msg = muse_core_msg_json_factory_new(api, param->type, param->name, param->value.value_INT, NULL);
+               msg = muse_core_msg_new(api, param->type, param->name, param->value.value_INT, NULL);
                break;
        case MUSE_TYPE_DOUBLE:
-               msg = muse_core_msg_json_factory_new(api, param->type, param->name, param->value.value_DOUBLE, NULL);
+               msg = muse_core_msg_new(api, param->type, param->name, param->value.value_DOUBLE, NULL);
                break;
        case MUSE_TYPE_STRING:
-               msg = muse_core_msg_json_factory_new(api, param->type, param->name, param->value.value_STRING, NULL);
+               msg = muse_core_msg_new(api, param->type, param->name, param->value.value_STRING, NULL);
                break;
        default:
                LOGE("unknown type %d", param->type);
@@ -1268,8 +1288,11 @@ static int _recorder_msg_send_param1(int api, recorder_cb_info_s *cb_info, int *
 
        /*LOGD("send msg %s", msg);*/
 
-       if (cb_info->is_server_connected)
-               send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
+       if (cb_info->is_server_connected) {
+               __recorder_update_api_waiting(cb_info, api, 1);
+
+               send_ret = muse_core_msg_send(cb_info->fd, msg);
+       }
 
        if (send_ret < 0) {
                LOGE("message send failed");
@@ -1278,7 +1301,9 @@ static int _recorder_msg_send_param1(int api, recorder_cb_info_s *cb_info, int *
                *ret = _recorder_client_wait_for_cb_return(api, cb_info, RECORDER_CB_TIMEOUT);
        }
 
-       muse_core_msg_json_factory_free(msg);
+       __recorder_update_api_waiting(cb_info, api, -1);
+
+       muse_core_msg_free(msg);
 
        return RECORDER_ERROR_NONE;
 }
@@ -1293,16 +1318,16 @@ static void _recorder_client_callback_destroy(recorder_cb_info_s *cb_info)
        LOGD("MSG receive thread[%p] destroy", cb_info->msg_recv_thread);
 
        g_thread_join(cb_info->msg_recv_thread);
-       g_thread_unref(cb_info->msg_recv_thread);
        cb_info->msg_recv_thread = NULL;
 
        LOGD("msg_recv thread removed");
 
        __destroy_msg_handler_thread(&cb_info->msg_handler_info);
        __destroy_msg_handler_thread(&cb_info->audio_stream_cb_info);
+       __destroy_msg_handler_thread(&cb_info->muxed_stream_cb_info);
 
-       g_mutex_clear(&cb_info->idle_event_mutex);
-       g_cond_clear(&cb_info->idle_event_cond);
+       for (i = 0 ; i < MUSE_RECORDER_EVENT_TYPE_NUM ; i++)
+               g_mutex_clear(&cb_info->user_cb_mutex[i]);
 
        for (i = 0 ; i < MUSE_RECORDER_API_MAX ; i++) {
                g_mutex_clear(&cb_info->api_mutex[i]);
@@ -1310,7 +1335,7 @@ static void _recorder_client_callback_destroy(recorder_cb_info_s *cb_info)
        }
 
        if (cb_info->fd > -1) {
-               muse_core_connection_close(cb_info->fd);
+               muse_client_close(cb_info->fd);
                cb_info->fd = -1;
        }
 
@@ -1330,7 +1355,7 @@ static void _recorder_client_callback_destroy(recorder_cb_info_s *cb_info)
 }
 
 
-static int _recorder_storage_device_supported_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data)
+static bool _recorder_storage_device_supported_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data)
 {
        char **root_directory = (char **)user_data;
 
@@ -1383,6 +1408,7 @@ static int _recorder_create_common(recorder_h *recorder, muse_recorder_type_e ty
        int ret = RECORDER_ERROR_NONE;
        int destroy_ret = RECORDER_ERROR_NONE;
        int sock_fd = -1;
+       int module_index = -1;
        int send_ret = 0;
        char *send_msg = NULL;
        char *root_directory = NULL;
@@ -1416,46 +1442,59 @@ static int _recorder_create_common(recorder_h *recorder, muse_recorder_type_e ty
                goto _ERR_RECORDER_EXIT;
        }
 
-       sock_fd = muse_core_client_new();
+       sock_fd = muse_client_new();
        if (sock_fd < 0) {
-               LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
+//LCOV_EXCL_START
+               LOGE("muse_client_new failed - returned fd %d", sock_fd);
+               ret = RECORDER_ERROR_INVALID_OPERATION;
+               goto _ERR_RECORDER_EXIT;
+//LCOV_EXCL_STOP
+       }
+
+       if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
+               LOGE("muse client get module index failed");
                ret = RECORDER_ERROR_INVALID_OPERATION;
                goto _ERR_RECORDER_EXIT;
        }
 
        if (type == MUSE_RECORDER_TYPE_AUDIO) {
-               send_msg = muse_core_msg_json_factory_new(MUSE_RECORDER_API_CREATE,
-                       MUSE_TYPE_INT, "module", MUSE_RECORDER,
+               send_msg = muse_core_msg_new(MUSE_RECORDER_API_CREATE,
+                       MUSE_TYPE_INT, "module", module_index,
                        MUSE_TYPE_INT, PARAM_RECORDER_TYPE, MUSE_RECORDER_TYPE_AUDIO,
                        MUSE_TYPE_INT, "pid", getpid(),
                        NULL);
        } else {
                pc->camera = camera;
                camera_handle = (intptr_t)((camera_cli_s *)camera)->remote_handle;
-               send_msg = muse_core_msg_json_factory_new(MUSE_RECORDER_API_CREATE,
-                       MUSE_TYPE_INT, "module", MUSE_RECORDER,
+               send_msg = muse_core_msg_new(MUSE_RECORDER_API_CREATE,
+                       MUSE_TYPE_INT, "module", module_index,
                        MUSE_TYPE_INT, PARAM_RECORDER_TYPE, MUSE_RECORDER_TYPE_VIDEO,
+                       MUSE_TYPE_INT, "pid", getpid(),
                        MUSE_TYPE_POINTER, "camera_handle", camera_handle,
                        NULL);
        }
 
        if (!send_msg) {
+//LCOV_EXCL_START
                LOGE("NULL msg");
                ret = RECORDER_ERROR_OUT_OF_MEMORY;
                goto _ERR_RECORDER_EXIT;
+//LCOV_EXCL_STOP
        }
 
        LOGD("sock_fd : %d, msg : %s", sock_fd, send_msg);
 
-       send_ret = muse_core_ipc_send_msg(sock_fd, send_msg);
+       send_ret = muse_core_msg_send(sock_fd, send_msg);
 
-       muse_core_msg_json_factory_free(send_msg);
+       muse_core_msg_free(send_msg);
        send_msg = NULL;
 
        if (send_ret < 0) {
+//LCOV_EXCL_START
                LOGE("send msg failed %d", errno);
                ret = RECORDER_ERROR_INVALID_OPERATION;
                goto _ERR_RECORDER_EXIT;
+//LCOV_EXCL_STOP
        }
 
        pc->cb_info = _recorder_client_callback_new(sock_fd);
@@ -1467,6 +1506,9 @@ static int _recorder_create_common(recorder_h *recorder, muse_recorder_type_e ty
        sock_fd = -1;
 
        ret = _recorder_client_wait_for_cb_return(MUSE_RECORDER_API_CREATE, pc->cb_info, RECORDER_CB_TIMEOUT);
+
+       pc->cb_info->api_waiting[MUSE_RECORDER_API_CREATE] = 0;
+
        if (ret != RECORDER_ERROR_NONE) {
                LOGE("API_CREATE failed 0x%x", ret);
                goto _ERR_RECORDER_EXIT;
@@ -1474,15 +1516,19 @@ static int _recorder_create_common(recorder_h *recorder, muse_recorder_type_e ty
 
        muse_recorder_msg_get_pointer(handle, pc->cb_info->recv_msg);
        if (handle == 0) {
+//LCOV_EXCL_START
                LOGE("Receiving Handle Failed!!");
                ret = RECORDER_ERROR_INVALID_OPERATION;
                goto _ERR_RECORDER_AFTER_CREATE;
+//LCOV_EXCL_STOP
        }
 
        if (!_recorder_client_get_root_directory(&root_directory) || root_directory == NULL) {
+//LCOV_EXCL_START
                LOGE("failed to get root directory of internal storage");
                ret = RECORDER_ERROR_INVALID_OPERATION;
                goto _ERR_RECORDER_AFTER_CREATE;
+//LCOV_EXCL_STOP
        }
 
        LOGD("root directory [%s]", root_directory);
@@ -1503,7 +1549,7 @@ static int _recorder_create_common(recorder_h *recorder, muse_recorder_type_e ty
        pc->remote_handle = handle;
        pc->cb_info->bufmgr = bufmgr;
 
-       LOGD("recorder[type %d] %p create success : remote handle 0x%x",
+       LOGD("recorder[type %d] %p create success : remote handle 0x%td",
                type, pc, pc->remote_handle);
 
        *recorder = (recorder_h)pc;
@@ -1511,9 +1557,9 @@ static int _recorder_create_common(recorder_h *recorder, muse_recorder_type_e ty
        LOGD("done");
 
        return RECORDER_ERROR_NONE;
-
+//LCOV_EXCL_START
 _ERR_RECORDER_AFTER_CREATE:
-       _recorder_msg_send(MUSE_RECORDER_API_DESTROY, pc->cb_info, &destroy_ret);
+       _recorder_msg_send(MUSE_RECORDER_API_DESTROY, pc->cb_info, &destroy_ret, RECORDER_CB_TIMEOUT);
        LOGE("destroy return 0x%x", destroy_ret);
 
 _ERR_RECORDER_EXIT:
@@ -1526,7 +1572,7 @@ _ERR_RECORDER_EXIT:
        }
 
        if (sock_fd > -1) {
-               muse_core_connection_close(sock_fd);
+               muse_client_close(sock_fd);
                sock_fd = -1;
        }
 
@@ -1540,6 +1586,7 @@ _ERR_RECORDER_EXIT:
        }
 
        return ret;
+//LCOV_EXCL_STOP
 }
 
 
@@ -1571,9 +1618,9 @@ int recorder_get_state(recorder_h recorder, recorder_state_e *state)
                return RECORDER_ERROR_INVALID_PARAMETER;
        }
 
-       LOGD("Enter, remote_handle : %x", pc->remote_handle);
+       LOGD("Enter, remote_handle : %td", pc->remote_handle);
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        if (ret == RECORDER_ERROR_NONE)
                *state = (recorder_state_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_STATE];
@@ -1598,12 +1645,12 @@ int recorder_destroy(recorder_h recorder)
        LOGD("ENTER");
 
        if (pc->cb_info->is_server_connected)
-               _recorder_msg_send(api, pc->cb_info, &ret);
+               _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
        else
                LOGW("server disconnected. release resource without send message.");
 
        if (ret == RECORDER_ERROR_NONE) {
-               _recorder_remove_idle_event_all(pc->cb_info);
+               _recorder_deactivate_idle_event_all(pc->cb_info);
                _recorder_client_callback_destroy(pc->cb_info);
                g_free(pc);
                pc = NULL;
@@ -1628,7 +1675,7 @@ int recorder_prepare(recorder_h recorder)
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        LOGD("ret : 0x%x", ret);
 
@@ -1654,6 +1701,7 @@ int recorder_unprepare(recorder_h recorder)
        LOGD("ENTER");
 
        if (pc->camera) {
+//LCOV_EXCL_START
                ret = camera_get_state(pc->camera, &camera_state);
                if (ret != CAMERA_ERROR_NONE) {
                        LOGE("failed to get camera state 0x%x", ret);
@@ -1667,9 +1715,10 @@ int recorder_unprepare(recorder_h recorder)
                                return RECORDER_ERROR_INVALID_OPERATION;
                        }
                }
+//LCOV_EXCL_STOP
        }
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        LOGD("ret : 0x%x", ret);
 
@@ -1692,6 +1741,7 @@ int recorder_start(recorder_h recorder)
        LOGD("ENTER");
 
        if (pc->camera) {
+//LCOV_EXCL_START
                ret = recorder_get_state(recorder, &current_state);
                if (ret != RECORDER_ERROR_NONE) {
                        LOGE("failed to get current state 0x%x", ret);
@@ -1705,9 +1755,10 @@ int recorder_start(recorder_h recorder)
                                return RECORDER_ERROR_INVALID_OPERATION;
                        }
                }
+//LCOV_EXCL_STOP
        }
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_NO_TIMEOUT);
 
        if (pc->camera && current_state == RECORDER_STATE_READY)
                camera_start_evas_rendering(pc->camera);
@@ -1731,7 +1782,7 @@ int recorder_pause(recorder_h recorder)
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        LOGD("ret : 0x%x", ret);
 
@@ -1754,6 +1805,7 @@ int recorder_commit(recorder_h recorder)
        LOGD("ENTER");
 
        if (pc->camera) {
+//LCOV_EXCL_START
                ret = recorder_get_state(recorder, &current_state);
                if (ret != RECORDER_ERROR_NONE) {
                        LOGE("failed to get current state 0x%x", ret);
@@ -1767,9 +1819,10 @@ int recorder_commit(recorder_h recorder)
                                return RECORDER_ERROR_INVALID_OPERATION;
                        }
                }
+//LCOV_EXCL_STOP
        }
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        if (pc->camera && current_state >= RECORDER_STATE_RECORDING)
                camera_start_evas_rendering(pc->camera);
@@ -1810,7 +1863,7 @@ int recorder_cancel(recorder_h recorder)
                }
        }
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        if (pc->camera && current_state >= RECORDER_STATE_RECORDING)
                camera_start_evas_rendering(pc->camera);
@@ -1836,13 +1889,16 @@ int recorder_set_video_resolution(recorder_h recorder, int width, int height)
 
        LOGD("ENTER");
 
-       send_msg = muse_core_msg_json_factory_new(api,
+       send_msg = muse_core_msg_new(api,
                MUSE_TYPE_INT, "width", width,
                MUSE_TYPE_INT, "height", height,
                NULL);
        if (send_msg) {
-               if (pc->cb_info->is_server_connected)
-                       send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, send_msg);
+               if (pc->cb_info->is_server_connected) {
+                       __recorder_update_api_waiting(pc->cb_info, api, 1);
+
+                       send_ret = muse_core_msg_send(pc->cb_info->fd, send_msg);
+               }
 
                if (send_ret < 0) {
                        LOGE("message send failed");
@@ -1851,7 +1907,9 @@ int recorder_set_video_resolution(recorder_h recorder, int width, int height)
                        ret = _recorder_client_wait_for_cb_return(api, pc->cb_info, RECORDER_CB_TIMEOUT);
                }
 
-               muse_core_msg_json_factory_free(send_msg);
+               __recorder_update_api_waiting(pc->cb_info, api, -1);
+
+               muse_core_msg_free(send_msg);
        } else {
                LOGE("failed to create msg");
                ret = RECORDER_ERROR_OUT_OF_MEMORY;
@@ -1881,7 +1939,7 @@ int recorder_get_video_resolution(recorder_h recorder, int *width, int *height)
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        if (ret == RECORDER_ERROR_NONE) {
                *width = pc->cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_RESOLUTION] >> 16;
@@ -1906,12 +1964,12 @@ int recorder_foreach_supported_video_resolution(recorder_h recorder,
                return RECORDER_ERROR_INVALID_PARAMETER;
        }
 
-       LOGD("Enter, handle :%x", pc->remote_handle);
+       LOGD("Enter, handle :%td", pc->remote_handle);
 
        pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION] = foreach_cb;
        pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_RESOLUTION] = user_data;
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        LOGD("ret : 0x%x", ret);
 
@@ -1932,7 +1990,7 @@ int recorder_get_audio_level(recorder_h recorder, double *level)
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        if (ret == RECORDER_ERROR_NONE)
                *level = pc->cb_info->get_double_value[_RECORDER_GET_DOUBLE_AUDIO_LEVEL];
@@ -1943,13 +2001,14 @@ int recorder_get_audio_level(recorder_h recorder, double *level)
 }
 
 
-int recorder_set_filename(recorder_h recorder,  const char *filename)
+int recorder_set_filename(recorder_h recorder, const char *filename)
 {
        int ret = RECORDER_ERROR_NONE;
+       size_t length = 0;
        muse_recorder_api_e api = MUSE_RECORDER_API_SET_FILENAME;
        recorder_cli_s *pc = (recorder_cli_s *)recorder;
        recorder_msg_param param;
-       char set_filename[RECORDER_FILENAME_MAX] = {0, };
+       char set_filename[RECORDER_FILENAME_MAX] = {'\0',};
 
        if (!pc || !pc->cb_info) {
                LOGE("NULL handle");
@@ -1961,14 +2020,23 @@ int recorder_set_filename(recorder_h recorder,  const char *filename)
                return RECORDER_ERROR_INVALID_PARAMETER;
        }
 
-       LOGD("ENTER");
+       LOGD("ENTER [%s]", filename);
+
+       length = strlen(filename);
+
+       if (length >= RECORDER_FILENAME_MAX - 1) {
+               LOGE("too long file name [%zu]", length);
+               return RECORDER_ERROR_INVALID_PARAMETER;
+       }
 
        if (storage_get_origin_internal_path(filename, RECORDER_FILENAME_MAX, set_filename) < 0) {
                /* Cannot convert. Use original path. */
-               strncpy(set_filename, filename, strlen(filename));
+               strncpy(set_filename, filename, length + 1);
+               pc->cb_info->is_filename_converted = FALSE;
        } else {
                /* Converted. Use converted path. */
                LOGD("Converted filename : %s -> %s", filename, set_filename);
+               pc->cb_info->is_filename_converted = TRUE;
        }
 
        RECORDER_MSG_PARAM_SET(param, STRING, set_filename);
@@ -2000,11 +2068,12 @@ int recorder_get_filename(recorder_h recorder,  char **filename)
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        if (ret == RECORDER_ERROR_NONE) {
-               if (storage_get_compat_internal_path(pc->cb_info->get_filename, RECORDER_FILENAME_MAX, compat_filename) < 0) {
-                       /* Cannot convert. Use original path. */
+               if (pc->cb_info->is_filename_converted == FALSE ||
+                       storage_get_compat_internal_path(pc->cb_info->get_filename, RECORDER_FILENAME_MAX, compat_filename) < 0) {
+                       /* Use original path. */
                        *filename = pc->cb_info->get_filename;
                } else {
                        /* Converted. Use converted path. */
@@ -2064,7 +2133,7 @@ int recorder_get_file_format(recorder_h recorder, recorder_file_format_e *format
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        if (ret == RECORDER_ERROR_NONE)
                *format = (recorder_file_format_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_FILE_FORMAT];
@@ -2110,13 +2179,16 @@ int recorder_set_sound_stream_info(recorder_h recorder, sound_stream_info_h stre
        LOGD("sound manager return [0x%x]", ret);
 
        if (ret == SOUND_MANAGER_ERROR_NONE) {
-               send_msg = muse_core_msg_json_factory_new(api,
+               send_msg = muse_core_msg_new(api,
                        MUSE_TYPE_STRING, "stream_type", stream_type,
                        MUSE_TYPE_INT, "stream_index", stream_index,
                        NULL);
                if (send_msg) {
-                       if (pc->cb_info->is_server_connected)
-                               send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, send_msg);
+                       if (pc->cb_info->is_server_connected) {
+                               __recorder_update_api_waiting(pc->cb_info, api, 1);
+
+                               send_ret = muse_core_msg_send(pc->cb_info->fd, send_msg);
+                       }
 
                        if (send_ret < 0) {
                                LOGE("message send failed");
@@ -2125,7 +2197,9 @@ int recorder_set_sound_stream_info(recorder_h recorder, sound_stream_info_h stre
                                ret = _recorder_client_wait_for_cb_return(api, pc->cb_info, RECORDER_CB_TIMEOUT);
                        }
 
-                       muse_core_msg_json_factory_free(send_msg);
+                       __recorder_update_api_waiting(pc->cb_info, api, -1);
+
+                       muse_core_msg_free(send_msg);
                } else {
                        LOGE("failed to create msg");
                        ret = RECORDER_ERROR_OUT_OF_MEMORY;
@@ -2138,7 +2212,7 @@ int recorder_set_sound_stream_info(recorder_h recorder, sound_stream_info_h stre
 }
 
 
-int recorder_set_state_changed_cb(recorder_h recorder, recorder_state_changed_cb callback, voiduser_data)
+int recorder_set_state_changed_cb(recorder_h recorder, recorder_state_changed_cb callback, void *user_data)
 {
        int ret = RECORDER_ERROR_NONE;
        recorder_cli_s *pc = (recorder_cli_s *)recorder;
@@ -2149,12 +2223,18 @@ int recorder_set_state_changed_cb(recorder_h recorder, recorder_state_changed_cb
                return RECORDER_ERROR_INVALID_PARAMETER;
        }
 
-       LOGD("Enter, handle :%x", pc->remote_handle);
+       LOGD("Enter, handle :%td", pc->remote_handle);
+
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+       if (ret == RECORDER_ERROR_NONE) {
+               g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE]);
 
-       pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = callback;
-       pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = user_data;
+               pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = callback;
+               pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = user_data;
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+               g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE]);
+       }
 
        LOGD("ret : 0x%x", ret);
 
@@ -2175,7 +2255,16 @@ int recorder_unset_state_changed_cb(recorder_h recorder)
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+       if (ret == RECORDER_ERROR_NONE) {
+               g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE]);
+
+               pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = NULL;
+               pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE] = NULL;
+
+               g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_STATE_CHANGE]);
+       }
 
        LOGD("ret : 0x%x", ret);
 
@@ -2194,12 +2283,18 @@ int recorder_set_interrupted_cb(recorder_h recorder, recorder_interrupted_cb cal
                return RECORDER_ERROR_INVALID_PARAMETER;
        }
 
-       LOGD("Enter, handle :%x", pc->remote_handle);
+       LOGD("Enter, handle :%td", pc->remote_handle);
 
-       pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = callback;
-       pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = user_data;
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       if (ret == RECORDER_ERROR_NONE) {
+               g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED]);
+
+               pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = callback;
+               pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = user_data;
+
+               g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED]);
+       }
 
        LOGD("ret : 0x%x", ret);
 
@@ -2220,7 +2315,16 @@ int recorder_unset_interrupted_cb(recorder_h recorder)
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+       if (ret == RECORDER_ERROR_NONE) {
+               g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED]);
+
+               pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = NULL;
+               pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED] = NULL;
+
+               g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPTED]);
+       }
 
        LOGD("ret : 0x%x", ret);
 
@@ -2228,7 +2332,67 @@ int recorder_unset_interrupted_cb(recorder_h recorder)
 }
 
 
-int recorder_set_audio_stream_cb(recorder_h recorder, recorder_audio_stream_cb callback, void* user_data)
+int recorder_set_interrupt_started_cb(recorder_h recorder, recorder_interrupt_started_cb callback, void *user_data)
+{
+       int ret = RECORDER_ERROR_NONE;
+       recorder_cli_s *pc = (recorder_cli_s *)recorder;
+       muse_recorder_api_e api = MUSE_RECORDER_API_SET_INTERRUPT_STARTED_CB;
+
+       if (!pc || !pc->cb_info || callback == NULL) {
+               LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
+               return RECORDER_ERROR_INVALID_PARAMETER;
+       }
+
+       LOGD("Enter, handle :%td", pc->remote_handle);
+
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+       if (ret == RECORDER_ERROR_NONE) {
+               g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED]);
+
+               pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = callback;
+               pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
+
+               g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED]);
+       }
+
+       LOGD("ret : 0x%x", ret);
+
+       return ret;
+}
+
+
+int recorder_unset_interrupt_started_cb(recorder_h recorder)
+{
+       int ret = RECORDER_ERROR_NONE;
+       muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_INTERRUPT_STARTED_CB;
+       recorder_cli_s *pc = (recorder_cli_s *)recorder;
+
+       if (!pc || !pc->cb_info) {
+               LOGE("NULL handle");
+               return RECORDER_ERROR_INVALID_PARAMETER;
+       }
+
+       LOGD("ENTER");
+
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+       if (ret == RECORDER_ERROR_NONE) {
+               g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED]);
+
+               pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
+               pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
+
+               g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED]);
+       }
+
+       LOGD("ret : 0x%x", ret);
+
+       return ret;
+}
+
+
+int recorder_set_audio_stream_cb(recorder_h recorder, recorder_audio_stream_cb callback, void *user_data)
 {
        int ret = RECORDER_ERROR_NONE;
        recorder_cli_s *pc = (recorder_cli_s *)recorder;
@@ -2239,12 +2403,18 @@ int recorder_set_audio_stream_cb(recorder_h recorder, recorder_audio_stream_cb c
                return RECORDER_ERROR_INVALID_PARAMETER;
        }
 
-       LOGD("Enter, handle :%x", pc->remote_handle);
+       LOGD("Enter, handle :%td", pc->remote_handle);
 
-       pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = callback;
-       pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = user_data;
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       if (ret == RECORDER_ERROR_NONE) {
+               g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM]);
+
+               pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = callback;
+               pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = user_data;
+
+               g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM]);
+       }
 
        LOGD("ret : 0x%x", ret);
 
@@ -2265,7 +2435,76 @@ int recorder_unset_audio_stream_cb(recorder_h recorder)
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+       if (ret == RECORDER_ERROR_NONE) {
+               g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM]);
+
+               pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = NULL;
+               pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM] = NULL;
+
+               g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM]);
+       }
+
+       LOGD("ret : 0x%x", ret);
+
+       return ret;
+}
+
+
+int recorder_set_muxed_stream_cb(recorder_h recorder, recorder_muxed_stream_cb callback, void *user_data)
+{
+       int ret = RECORDER_ERROR_NONE;
+       recorder_cli_s *pc = (recorder_cli_s *)recorder;
+       muse_recorder_api_e api = MUSE_RECORDER_API_SET_MUXED_STREAM_CB;
+
+       if (!pc || !pc->cb_info || !callback) {
+               LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
+               return RECORDER_ERROR_INVALID_PARAMETER;
+       }
+
+       LOGD("Enter, handle :%td", pc->remote_handle);
+
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+       if (ret == RECORDER_ERROR_NONE) {
+               g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM]);
+
+               pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM] = callback;
+               pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM] = user_data;
+
+               g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM]);
+       }
+
+       LOGD("ret : 0x%x", ret);
+
+       return ret;
+}
+
+
+int recorder_unset_muxed_stream_cb(recorder_h recorder)
+{
+       int ret = RECORDER_ERROR_NONE;
+       muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_MUXED_STREAM_CB;
+       recorder_cli_s *pc = (recorder_cli_s *)recorder;
+
+       if (!pc || !pc->cb_info) {
+               LOGE("NULL handle");
+               return RECORDER_ERROR_INVALID_PARAMETER;
+       }
+
+       LOGD("ENTER");
+
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+       if (ret == RECORDER_ERROR_NONE) {
+               g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM]);
+
+               pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM] = NULL;
+               pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM] = NULL;
+
+               g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_MUXED_STREAM]);
+       }
 
        LOGD("ret : 0x%x", ret);
 
@@ -2284,12 +2523,18 @@ int recorder_set_error_cb(recorder_h recorder, recorder_error_cb callback, void
                return RECORDER_ERROR_INVALID_PARAMETER;
        }
 
-       LOGD("Enter, handle :%x", pc->remote_handle);
+       LOGD("Enter, handle :%td", pc->remote_handle);
+
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
-       pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_ERROR] = callback;
-       pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_ERROR] = user_data;
+       if (ret == RECORDER_ERROR_NONE) {
+               g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_ERROR]);
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+               pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_ERROR] = callback;
+               pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_ERROR] = user_data;
+
+               g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_ERROR]);
+       }
 
        LOGD("ret : 0x%x", ret);
 
@@ -2310,7 +2555,16 @@ int recorder_unset_error_cb(recorder_h recorder)
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+       if (ret == RECORDER_ERROR_NONE) {
+               g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_ERROR]);
+
+               pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_ERROR] = NULL;
+               pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_ERROR] = NULL;
+
+               g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_ERROR]);
+       }
 
        LOGD("ret : 0x%x", ret);
 
@@ -2318,7 +2572,7 @@ int recorder_unset_error_cb(recorder_h recorder)
 }
 
 
-int recorder_set_recording_status_cb(recorder_h recorder, recorder_recording_status_cb callback, voiduser_data)
+int recorder_set_recording_status_cb(recorder_h recorder, recorder_recording_status_cb callback, void *user_data)
 {
        int ret = RECORDER_ERROR_NONE;
        recorder_cli_s *pc = (recorder_cli_s *)recorder;
@@ -2329,12 +2583,18 @@ int recorder_set_recording_status_cb(recorder_h recorder, recorder_recording_sta
                return RECORDER_ERROR_INVALID_PARAMETER;
        }
 
-       LOGD("Enter, handle :%x", pc->remote_handle);
+       LOGD("Enter, handle :%td", pc->remote_handle);
 
-       pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = callback;
-       pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = user_data;
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       if (ret == RECORDER_ERROR_NONE) {
+               g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS]);
+
+               pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = callback;
+               pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = user_data;
+
+               g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS]);
+       }
 
        LOGD("ret : 0x%x", ret);
 
@@ -2355,7 +2615,16 @@ int recorder_unset_recording_status_cb(recorder_h recorder)
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+       if (ret == RECORDER_ERROR_NONE) {
+               g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS]);
+
+               pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = NULL;
+               pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS] = NULL;
+
+               g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_STATUS]);
+       }
 
        LOGD("ret : 0x%x", ret);
 
@@ -2363,7 +2632,7 @@ int recorder_unset_recording_status_cb(recorder_h recorder)
 }
 
 
-int recorder_set_recording_limit_reached_cb(recorder_h recorder, recorder_recording_limit_reached_cb callback, voiduser_data)
+int recorder_set_recording_limit_reached_cb(recorder_h recorder, recorder_recording_limit_reached_cb callback, void *user_data)
 {
        int ret = RECORDER_ERROR_NONE;
        recorder_cli_s *pc = (recorder_cli_s *)recorder;
@@ -2374,10 +2643,16 @@ int recorder_set_recording_limit_reached_cb(recorder_h recorder, recorder_record
                return RECORDER_ERROR_INVALID_PARAMETER;
        }
 
-       pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = callback;
-       pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = user_data;
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       if (ret == RECORDER_ERROR_NONE) {
+               g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED]);
+
+               pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = callback;
+               pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = user_data;
+
+               g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED]);
+       }
 
        LOGD("ret : 0x%x", ret);
 
@@ -2398,7 +2673,16 @@ int recorder_unset_recording_limit_reached_cb(recorder_h recorder)
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
+
+       if (ret == RECORDER_ERROR_NONE) {
+               g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED]);
+
+               pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = NULL;
+               pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED] = NULL;
+
+               g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_RECORDER_EVENT_TYPE_RECORDING_LIMITED]);
+       }
 
        LOGD("ret : 0x%x", ret);
 
@@ -2417,12 +2701,12 @@ int recorder_foreach_supported_file_format(recorder_h recorder, recorder_support
                return RECORDER_ERROR_INVALID_PARAMETER;
        }
 
-       LOGD("Enter, handle :%x", pc->remote_handle);
+       LOGD("Enter, handle :%td", pc->remote_handle);
 
        pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT] = foreach_cb;
        pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_FILE_FORMAT] = user_data;
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        LOGD("ret : 0x%x", ret);
 
@@ -2546,7 +2830,7 @@ int recorder_get_audio_encoder(recorder_h recorder, recorder_audio_codec_e *code
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        if (ret == RECORDER_ERROR_NONE)
                *codec = (recorder_audio_codec_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_ENCODER];
@@ -2600,7 +2884,7 @@ int recorder_get_video_encoder(recorder_h recorder, recorder_video_codec_e *code
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        if (ret == RECORDER_ERROR_NONE)
                *codec = (recorder_video_codec_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_ENCODER];
@@ -2701,7 +2985,7 @@ int recorder_attr_get_size_limit(recorder_h recorder, int *kbyte)
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        if (ret == RECORDER_ERROR_NONE)
                *kbyte = pc->cb_info->get_int_value[_RECORDER_GET_INT_SIZE_LIMIT];
@@ -2730,7 +3014,7 @@ int recorder_attr_get_time_limit(recorder_h recorder, int *second)
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        if (ret == RECORDER_ERROR_NONE)
                *second = pc->cb_info->get_int_value[_RECORDER_GET_INT_TIME_LIMIT];
@@ -2759,7 +3043,7 @@ int recorder_attr_get_audio_device(recorder_h recorder, recorder_audio_device_e
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        if (ret == RECORDER_ERROR_NONE)
                *device = (recorder_audio_device_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_DEVICE];
@@ -2788,7 +3072,7 @@ int recorder_attr_get_audio_samplerate(recorder_h recorder, int *samplerate)
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        if (ret == RECORDER_ERROR_NONE)
                *samplerate = pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_SAMPLERATE];
@@ -2817,7 +3101,7 @@ int recorder_attr_get_audio_encoder_bitrate(recorder_h recorder, int *bitrate)
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        if (ret == RECORDER_ERROR_NONE)
                *bitrate = pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_ENCODER_BITRATE];
@@ -2846,7 +3130,7 @@ int recorder_attr_get_video_encoder_bitrate(recorder_h recorder, int *bitrate)
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        if (ret == RECORDER_ERROR_NONE)
                *bitrate = pc->cb_info->get_int_value[_RECORDER_GET_INT_VIDEO_ENCODER_BITRATE];
@@ -2868,12 +3152,12 @@ int recorder_foreach_supported_audio_encoder(recorder_h recorder, recorder_suppo
                return RECORDER_ERROR_INVALID_PARAMETER;
        }
 
-       LOGD("Enter, handle :%x", pc->remote_handle);
+       LOGD("Enter, handle :%td", pc->remote_handle);
 
        pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER] = foreach_cb;
        pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_AUDIO_ENCODER] = user_data;
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        LOGD("ret : 0x%x", ret);
 
@@ -2892,12 +3176,12 @@ int recorder_foreach_supported_video_encoder(recorder_h recorder, recorder_suppo
                return RECORDER_ERROR_INVALID_PARAMETER;
        }
 
-       LOGD("Enter, handle :%x", pc->remote_handle);
+       LOGD("Enter, handle :%td", pc->remote_handle);
 
        pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER] = foreach_cb;
        pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_FOREACH_SUPPORTED_VIDEO_ENCODER] = user_data;
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        LOGD("ret : 0x%x", ret);
 
@@ -2943,7 +3227,7 @@ bool recorder_attr_is_muted(recorder_h recorder)
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        if (ret == RECORDER_ERROR_SERVICE_DISCONNECTED)
                ret = false;
@@ -2996,7 +3280,7 @@ int recorder_attr_get_recording_motion_rate(recorder_h recorder, double *rate)
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
        if (ret == RECORDER_ERROR_NONE)
                *rate = pc->cb_info->get_double_value[_RECORDER_GET_DOUBLE_RECORDING_MOTION_RATE];
 
@@ -3048,7 +3332,7 @@ int recorder_attr_get_audio_channel(recorder_h recorder, int *channel_count)
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        if (ret == RECORDER_ERROR_NONE)
                *channel_count = pc->cb_info->get_int_value[_RECORDER_GET_INT_AUDIO_CHANNEL];
@@ -3102,7 +3386,7 @@ int  recorder_attr_get_orientation_tag(recorder_h recorder, recorder_rotation_e
 
        LOGD("ENTER");
 
-       _recorder_msg_send(api, pc->cb_info, &ret);
+       _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT);
 
        if (ret == RECORDER_ERROR_NONE)
                *orientation = (recorder_rotation_e)pc->cb_info->get_int_value[_RECORDER_GET_INT_ORIENTATION_TAG];
@@ -3117,6 +3401,7 @@ int recorder_get_device_state(recorder_type_e type, recorder_device_state_e *sta
 {
        int ret = RECORDER_ERROR_NONE;
        int sock_fd = -1;
+       int module_index = -1;
        int get_device_state = 0;
        char *send_msg = NULL;
        char recv_msg[MUSE_RECORDER_MSG_MAX_LENGTH] = {'\0',};
@@ -3128,47 +3413,63 @@ int recorder_get_device_state(recorder_type_e type, recorder_device_state_e *sta
 
        LOGD("Enter - type %d", type);
 
-       sock_fd = muse_core_client_new();
+       sock_fd = muse_client_new();
        if (sock_fd < 0) {
-               LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
+//LCOV_EXCL_START
+               LOGE("muse_client_new failed - returned fd %d", sock_fd);
+               ret = RECORDER_ERROR_INVALID_OPERATION;
+               goto _GET_DEVICE_STATE_EXIT;
+//LCOV_EXCL_STOP
+       }
+
+       if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
+               LOGE("muse client get module index failed");
                ret = RECORDER_ERROR_INVALID_OPERATION;
                goto _GET_DEVICE_STATE_EXIT;
        }
 
-       send_msg = muse_core_msg_json_factory_new(MUSE_RECORDER_API_GET_DEVICE_STATE,
-               MUSE_TYPE_INT, "module", MUSE_RECORDER,
+       send_msg = muse_core_msg_new(MUSE_RECORDER_API_GET_DEVICE_STATE,
+               MUSE_TYPE_INT, "module", module_index,
                MUSE_TYPE_INT, PARAM_RECORDER_TYPE, type,
                NULL);
        if (!send_msg) {
+//LCOV_EXCL_START
                LOGE("NULL msg");
                ret = RECORDER_ERROR_OUT_OF_MEMORY;
                goto _GET_DEVICE_STATE_EXIT;
+//LCOV_EXCL_STOP
        }
 
        LOGD("sock_fd : %d, msg : %s", sock_fd, send_msg);
 
-       ret = muse_core_ipc_send_msg(sock_fd, send_msg);
+       ret = muse_core_msg_send(sock_fd, send_msg);
 
-       muse_core_msg_json_factory_free(send_msg);
+       muse_core_msg_free(send_msg);
        send_msg = NULL;
 
        if (ret < 0) {
+//LCOV_EXCL_START
                LOGE("send msg failed %d", errno);
                ret = RECORDER_ERROR_INVALID_OPERATION;
                goto _GET_DEVICE_STATE_EXIT;
+//LCOV_EXCL_STOP
        }
 
-       ret = muse_core_ipc_recv_msg(sock_fd, recv_msg);
+       ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_RECORDER_MSG_MAX_LENGTH);
        if (ret <= 0) {
+//LCOV_EXCL_START
                LOGE("recv msg failed %d", errno);
                ret = RECORDER_ERROR_INVALID_OPERATION;
                goto _GET_DEVICE_STATE_EXIT;
+//LCOV_EXCL_STOP
        }
 
        if (!muse_recorder_msg_get(ret, recv_msg)) {
+//LCOV_EXCL_START
                LOGE("failed to get return value from msg [%s]", recv_msg);
                ret = RECORDER_ERROR_INVALID_OPERATION;
                goto _GET_DEVICE_STATE_EXIT;
+//LCOV_EXCL_STOP
        }
 
        if (ret == RECORDER_ERROR_NONE) {
@@ -3185,7 +3486,7 @@ int recorder_get_device_state(recorder_type_e type, recorder_device_state_e *sta
 
 _GET_DEVICE_STATE_EXIT:
        if (sock_fd > -1) {
-               muse_core_connection_close(sock_fd);
+               muse_client_close(sock_fd);
                sock_fd = -1;
        }
 
@@ -3259,6 +3560,7 @@ int recorder_add_device_state_changed_cb(recorder_device_state_changed_cb callba
 
 _DONE:
        if (ret != RECORDER_ERROR_NONE) {
+//LCOV_EXCL_START
                if (info) {
                        g_free(info);
                        info = NULL;
@@ -3268,6 +3570,7 @@ _DONE:
                        g_object_unref(g_rec_dev_state_changed_cb_conn);
                        g_rec_dev_state_changed_cb_conn = NULL;
                }
+//LCOV_EXCL_STOP
        }
 
        g_mutex_unlock(&g_rec_dev_state_changed_cb_lock);