Add preview callback information for debug
[platform/core/api/camera.git] / src / camera.c
index 73908ee..a0a07e9 100644 (file)
@@ -43,6 +43,7 @@
                }\
        } while (0)
 
+
 /* for camera device manager */
 typedef struct _cdm_symbol_table {
        void **func_ptr;
@@ -90,10 +91,7 @@ static gboolean __camera_allocate_preview_buffer(camera_h camera)
        camera_cli_s *pc = (camera_cli_s *)camera;
        camera_cb_info_s *cb_info = NULL;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
-               return FALSE;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, FALSE);
 
        cb_info = pc->cb_info;
 
@@ -165,10 +163,7 @@ static void __camera_release_preview_buffer(camera_h camera)
        camera_cli_s *pc = (camera_cli_s *)camera;
        camera_cb_info_s *cb_info = NULL;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
-               return;
-       }
+       CAMERA_CHECK_HANDLE_RETURN(pc);
 
        CAM_LOG_INFO("Enter");
 
@@ -279,6 +274,88 @@ _DONE:
 }
 
 
+static void __camera_preview_cb_monitoring_info_sub_reset(monitoring_info_sub_s *info_sub)
+{
+       if (!info_sub) {
+               CAM_LOG_ERROR("NULL info_sub");
+               return;
+       }
+
+       info_sub->frame_count = 0;
+       info_sub->elapsed_sec_accum = 0.0;
+       info_sub->elapsed_sec_peak = 0.0;
+}
+
+
+static void __camera_preview_cb_monitoring_info_reset(camera_preview_cb_monitoring_info_s *info)
+{
+       if (!info) {
+               CAM_LOG_ERROR("NULL info");
+               return;
+       }
+
+       __camera_preview_cb_monitoring_info_sub_reset(info->total);
+       __camera_preview_cb_monitoring_info_sub_reset(info->interval);
+}
+
+
+static void __camera_preview_cb_monitoring_info_start(camera_preview_cb_monitoring_info_s *info)
+{
+       if (!info) {
+               CAM_LOG_ERROR("NULL info");
+               return;
+       }
+
+       g_timer_start(info->timer_calling);
+
+       if (info->interval->frame_count == 0)
+               g_timer_start(info->timer_interval);
+}
+
+
+static void __camera_preview_cb_monitoring_info_sub_update(monitoring_info_sub_s *info_sub, gdouble elapsed_sec)
+{
+       if (!info_sub) {
+               CAM_LOG_ERROR("NULL info_sub");
+               return;
+       }
+
+       info_sub->frame_count++;
+       info_sub->elapsed_sec_accum += elapsed_sec;
+
+       if (info_sub->elapsed_sec_peak < elapsed_sec)
+               info_sub->elapsed_sec_peak = elapsed_sec;
+}
+
+
+static void __camera_preview_cb_monitoring_info_end(camera_preview_cb_monitoring_info_s *info)
+{
+       gdouble elapsed_sec = 0.0;
+       gdouble elapsed_sec_interval = 0.0;
+
+       if (!info) {
+               CAM_LOG_ERROR("NULL info");
+               return;
+       }
+
+       elapsed_sec = g_timer_elapsed(info->timer_calling, NULL);
+       elapsed_sec_interval = g_timer_elapsed(info->timer_interval, NULL);
+
+       __camera_preview_cb_monitoring_info_sub_update(info->total, elapsed_sec);
+       __camera_preview_cb_monitoring_info_sub_update(info->interval, elapsed_sec);
+
+       if (elapsed_sec_interval >= 1.0) {
+               CAM_LOG_INFO("id[%d], frame count[t:%llu,i:%llu], elapsed - avg[t:%dms,i:%dms], peak[t:%dms,i:%dms]",
+                       info->stream_id, info->total->frame_count, info->interval->frame_count,
+                       (int)((info->total->elapsed_sec_accum / (gdouble)info->total->frame_count) * 1000),
+                       (int)((info->interval->elapsed_sec_accum / (gdouble)info->interval->frame_count) * 1000),
+                       (int)(info->total->elapsed_sec_peak * 1000), (int)(info->interval->elapsed_sec_peak * 1000));
+
+               __camera_preview_cb_monitoring_info_sub_reset(info->interval);
+       }
+}
+
+
 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
 {
        int i = 0;
@@ -300,6 +377,7 @@ static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv
        MMCamcorderVideoStreamDataType *stream = NULL;
        camera_media_packet_data *mp_data = NULL;
        media_packet_h pkt = NULL;
+       camera_preview_cb_monitoring_info_s *monitoring_info = NULL;
 
        /* tfd[0]: MMCamcorderVideoStreamDataType
           tfd[1]: data_bo or zero copy bo[0]
@@ -326,6 +404,11 @@ static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv
        ret_fd = preview_fd;
        CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
 
+       if (cb_info->invoke_preview_cb == FALSE) {
+               CAM_LOG_WARNING("Skip preview callback for fd[%d] due to preview stop.", ret_fd);
+               goto _PREVIEW_CB_HANDLER_DONE;
+       }
+
        if (num_buffer_fd < 0 || num_buffer_fd > BUFFER_MAX_PLANE_NUM) {
                CAM_LOG_ERROR("invalid num buffer fd %d", num_buffer_fd);
                goto _PREVIEW_CB_HANDLER_DONE;
@@ -373,15 +456,23 @@ static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv
                cb_info->stream_data = stream;
 
                if (stream->extra_stream_id < 0) {
+                       monitoring_info = cb_info->monitoring_info_preview;
+                       __camera_preview_cb_monitoring_info_start(monitoring_info);
+
                        if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])
                                ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
                                        cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
                } else {
+                       monitoring_info = cb_info->monitoring_info_preview_ex[stream->extra_stream_id];
+                       __camera_preview_cb_monitoring_info_start(monitoring_info);
+
                        if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])
                                ((camera_extra_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW])(&frame,
                                        stream->extra_stream_id, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_EXTRA_PREVIEW]);
                }
 
+               __camera_preview_cb_monitoring_info_end(monitoring_info);
+
                cb_info->stream_data = NULL;
        }
 
@@ -414,8 +505,14 @@ static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv
        /* 1. media packet preview callback */
        if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
                media_packet_ref(pkt);
+
+               monitoring_info = cb_info->monitoring_info_preview_mp;
+               __camera_preview_cb_monitoring_info_start(monitoring_info);
+
                ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
                        cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
+
+               __camera_preview_cb_monitoring_info_end(monitoring_info);
        }
 
        /* 2. call evas renderer */
@@ -656,16 +753,14 @@ static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo
                return false;
        }
 
-       tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
+       tmp_bo_handle = tbm_bo_get_handle(tmp_bo, TBM_DEVICE_CPU);
        if (tmp_bo_handle.ptr == NULL) {
-               CAM_LOG_ERROR("map failed %p", tmp_bo);
+               CAM_LOG_ERROR("tbm_bo_get_handle() failed %p", tmp_bo);
                tbm_bo_unref(tmp_bo);
                tmp_bo = NULL;
                return false;
        }
 
-       tbm_bo_unmap(tmp_bo);
-
        /* set bo and bo_handle */
        *bo = tmp_bo;
        *bo_handle = tmp_bo_handle;
@@ -687,6 +782,118 @@ static void __camera_release_imported_bo(tbm_bo *bo)
 }
 
 
+static bool __is_supported(camera_h camera, muse_camera_api_e api)
+{
+       int ret = CAMERA_ERROR_NONE;
+       camera_cli_s *pc = (camera_cli_s *)camera;
+
+       if (!pc || !pc->cb_info) {
+               CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
+               set_last_result(CAMERA_ERROR_INVALID_PARAMETER);
+               return false;
+       }
+
+       CAM_LOG_INFO("Enter - api[%d]", api);
+
+       _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+       CAM_LOG_INFO("Leave - api[%d], ret[%d]", api, ret);
+
+       return !!ret;
+}
+
+
+static int __set_mode(camera_h camera, muse_camera_api_e api, int set_mode)
+{
+       int ret = CAMERA_ERROR_NONE;
+       camera_cli_s *pc = (camera_cli_s *)camera;
+       camera_msg_param param;
+
+       if (!pc || !pc->cb_info) {
+               CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
+               return CAMERA_ERROR_INVALID_PARAMETER;
+       }
+
+       CAM_LOG_INFO("Enter - api[%d], mode[%d]", api, set_mode);
+
+       CAMERA_MSG_PARAM_SET(param, INT, set_mode);
+
+       _camera_msg_send_param1(api, pc->cb_info, &ret, &param, CAMERA_CB_TIMEOUT);
+
+       CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
+
+       return ret;
+}
+
+
+static int __set_enable(camera_h camera, muse_camera_api_e api, int set_enable)
+{
+       int ret = CAMERA_ERROR_NONE;
+       camera_cli_s *pc = (camera_cli_s *)camera;
+       camera_msg_param param;
+
+       if (!pc || !pc->cb_info) {
+               CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc);
+               return CAMERA_ERROR_INVALID_PARAMETER;
+       }
+
+       CAM_LOG_INFO("Enter - api[%d], enable[%d]", api, set_enable);
+
+       CAMERA_MSG_PARAM_SET(param, INT, set_enable);
+
+       _camera_msg_send_param1(api, pc->cb_info, &ret, &param, CAMERA_CB_TIMEOUT);
+
+       CAM_LOG_INFO("Leave - api[%d], ret[0x%x]", api, ret);
+
+       return ret;
+}
+
+
+void _camera_send_message_get_return(camera_cb_info_s *cb_info, muse_camera_api_e api, char *msg, int time_out, int *ret)
+{
+       int send_ret = 0;
+
+       if (!msg) {
+               CAM_LOG_ERROR("api[%d] message failed", api);
+               if (ret)
+                       *ret = CAMERA_ERROR_OUT_OF_MEMORY;
+
+               return;
+       }
+
+       if (api != MUSE_CAMERA_API_RETURN_BUFFER && api != MUSE_CAMERA_API_PREVIEW_CB_RETURN)
+               CAM_LOG_INFO("api[%d], message[%s]", api, msg);
+       else
+               CAM_LOG_DEBUG("api[%d], message[%s]", api, msg);
+
+       if (cb_info->is_server_connected) {
+               _camera_update_api_waiting(cb_info, api, 1);
+
+               g_mutex_lock(&cb_info->fd_lock);
+               send_ret = muse_core_msg_send(cb_info->fd, msg);
+               g_mutex_unlock(&cb_info->fd_lock);
+       }
+
+       if (send_ret < 0) {
+               CAM_LOG_ERROR("message send failed");
+               if (ret)
+                       *ret = CAMERA_ERROR_INVALID_OPERATION;
+       } else {
+               if (ret)
+                       *ret = _camera_client_wait_for_cb_return(api, cb_info, time_out);
+       }
+
+       _camera_update_api_waiting(cb_info, api, -1);
+
+       muse_core_msg_free(msg);
+
+       if (api != MUSE_CAMERA_API_RETURN_BUFFER && api != MUSE_CAMERA_API_PREVIEW_CB_RETURN)
+               CAM_LOG_INFO("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
+       else
+               CAM_LOG_DEBUG("api[%d] ret[0x%x]", api, ret ? *ret : 0x0);
+}
+
+
 int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
 {
        int ret = CAMERA_ERROR_NONE;
@@ -738,7 +945,6 @@ _CB_RETURN_END:
 void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
        int *ret, int timeout)
 {
-       int send_ret = 0;
        char *msg = NULL;
 
        if (!cb_info) {
@@ -751,44 +957,14 @@ void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
        }
 
        msg = muse_core_msg_new(api, NULL);
-       if (!msg) {
-               CAM_LOG_ERROR("msg failed: api %d", api);
-
-               if (ret)
-                       *ret = CAMERA_ERROR_OUT_OF_MEMORY;
-
-               return;
-       }
-
-       CAM_LOG_DEBUG("send msg[%s]", msg);
 
-       if (cb_info->is_server_connected) {
-               _camera_update_api_waiting(cb_info, api, 1);
-
-               g_mutex_lock(&cb_info->fd_lock);
-               send_ret = muse_core_msg_send_fd(cb_info->fd, fds, msg);
-               g_mutex_unlock(&cb_info->fd_lock);
-       }
-
-       if (send_ret < 0) {
-               CAM_LOG_ERROR("msg send failed");
-               if (ret)
-                       *ret = CAMERA_ERROR_INVALID_OPERATION;
-       } else {
-               if (ret)
-                       *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
-       }
-
-       _camera_update_api_waiting(cb_info, api, -1);
-
-       muse_core_msg_free(msg);
+       _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
 }
 
 
 void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
        int *ret, camera_msg_param *param, int timeout)
 {
-       int send_ret = 0;
        int array_length;
        char *msg = NULL;
 
@@ -827,53 +1003,23 @@ void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
                break;
        }
 
-       if (!msg) {
-               CAM_LOG_ERROR("msg failed: api %d", api);
-
-               if (ret)
-                       *ret = CAMERA_ERROR_OUT_OF_MEMORY;
-
-               return;
-       }
-
-       CAM_LOG_DEBUG("send msg[%s]", msg);
-
-       if (cb_info->is_server_connected) {
-               _camera_update_api_waiting(cb_info, api, 1);
-
-               g_mutex_lock(&cb_info->fd_lock);
-               send_ret = muse_core_msg_send(cb_info->fd, msg);
-               g_mutex_unlock(&cb_info->fd_lock);
-       }
-
-       if (send_ret < 0) {
-               CAM_LOG_ERROR("msg send failed");
-
-               if (ret)
-                       *ret = CAMERA_ERROR_INVALID_OPERATION;
-       } else {
-               if (ret)
-                       *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
-       }
-
-       _camera_update_api_waiting(cb_info, api, -1);
-
-       muse_core_msg_free(msg);
+       _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
 }
 
 
 void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
        int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
 {
-       int func_ret = CAMERA_ERROR_NONE;
-       int send_ret = 0;
        char *msg = NULL;
 
        if (!cb_info || !param0 || !param1) {
                CAM_LOG_ERROR("invalid ptr %p %p %p : api %d",
                        cb_info, param0, param1, api);
-               func_ret = CAMERA_ERROR_INVALID_PARAMETER;
-               goto _SEND_PARAM2_INT_DONE;
+
+               if (ret)
+                       *ret = CAMERA_ERROR_INVALID_PARAMETER;
+
+               return;
        }
 
        CAM_LOG_DEBUG("api[%d], param0[%s:%d], param1[%s:%d]",
@@ -885,37 +1031,8 @@ void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
                param0->type, param0->name, param0->value.value_INT,
                param1->type, param1->name, param1->value.value_INT,
                NULL);
-       if (!msg) {
-               CAM_LOG_ERROR("msg failed: api %d", api);
-               func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
-               goto _SEND_PARAM2_INT_DONE;
-       }
-
-       CAM_LOG_DEBUG("send msg[%s]", msg);
-
-       if (cb_info->is_server_connected) {
-               _camera_update_api_waiting(cb_info, api, 1);
-
-               g_mutex_lock(&cb_info->fd_lock);
-               send_ret = muse_core_msg_send(cb_info->fd, msg);
-               g_mutex_unlock(&cb_info->fd_lock);
-       }
-
-       if (send_ret < 0) {
-               CAM_LOG_ERROR("msg send failed");
-
-               func_ret = CAMERA_ERROR_INVALID_OPERATION;
-       } else {
-               func_ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
-       }
-
-       _camera_update_api_waiting(cb_info, api, -1);
-
-       muse_core_msg_free(msg);
 
-_SEND_PARAM2_INT_DONE:
-       if (ret)
-               *ret = func_ret;
+       _camera_send_message_get_return(cb_info, api, msg, timeout, ret);
 }
 
 
@@ -1266,7 +1383,7 @@ static int __camera_update_media_packet_format(camera_cb_info_s *cb_info, MMCamc
                media_format_get_video_info(cb_info->pkt_fmt,
                        &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
 
-               CAM_LOG_INFO("pkt_fmt %dx%d - stream %dx%d",
+               CAM_LOG_DEBUG("pkt_fmt %dx%d - stream %dx%d",
                        pkt_fmt_width, pkt_fmt_height, stream->width, stream->height);
 
                if (pkt_fmt_mimetype != mimetype ||
@@ -1329,6 +1446,16 @@ static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVi
                        stream->data.encoded.data, stream->data.encoded.length_data,
                        (media_packet_dispose_cb)_camera_media_packet_dispose, (void *)cb_info,
                        &pkt);
+
+               if (pkt) {
+                       if (!stream->data.encoded.is_delta_frame)
+                               media_packet_set_flags(pkt, MEDIA_PACKET_SYNC_FRAME);
+
+                       if (stream->data.encoded.is_header_included) {
+                               media_packet_set_flags(pkt, MEDIA_PACKET_CODEC_CONFIG);
+                               CAM_LOG_INFO("Codec config in buffer");
+                       }
+               }
        } else {
                tsurf = __camera_get_tbm_surface(stream, mp_data);
                if (!tsurf) {
@@ -1353,8 +1480,7 @@ static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVi
                goto _PACKET_CREATE_FAILED;
        }
 
-       /* set timestamp : msec -> nsec */
-       if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
+       if (media_packet_set_pts(pkt, stream->timestamp_nsec) != MEDIA_PACKET_ERROR_NONE)
                CAM_LOG_WARNING("media_packet_set_pts failed");
 
        if (media_packet_set_rotate_method(pkt, (media_packet_rotate_method_e)stream->rotation) != MEDIA_PACKET_ERROR_NONE)
@@ -1646,6 +1772,7 @@ static gpointer __camera_msg_handler_func(gpointer data)
        camera_idle_event_s *cam_idle_event = NULL;
        camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
        camera_cb_info_s *cb_info = NULL;
+       GThread *thread = NULL;
 
        if (!handler_info || !handler_info->cb_info) {
                CAM_LOG_ERROR("NULL handler %p", handler_info);
@@ -1654,8 +1781,9 @@ static gpointer __camera_msg_handler_func(gpointer data)
 
        cb_info = (camera_cb_info_s *)handler_info->cb_info;
        type = handler_info->type;
+       thread = handler_info->thread;
 
-       CAM_LOG_INFO("t:%d start[thread:%p]", type, handler_info->thread);
+       CAM_LOG_INFO("t:%d start[thread:%p]", type, thread);
 
        g_mutex_lock(&handler_info->mutex);
 
@@ -1767,7 +1895,7 @@ static gpointer __camera_msg_handler_func(gpointer data)
 
        g_mutex_unlock(&handler_info->mutex);
 
-       CAM_LOG_INFO("t:%d return[thread:%p]", type, handler_info->thread);
+       CAM_LOG_INFO("t:%d return[thread:%p]", type, thread);
 
        return NULL;
 }
@@ -2118,6 +2246,8 @@ static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
                return false;
        }
 
+       g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
+
        if (handler_info->thread) {
                CAM_LOG_WARNING("t:%d thread[%p] is already created", type, handler_info->thread);
                return true;
@@ -2132,9 +2262,6 @@ static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
                return false;
        }
 
-       g_mutex_init(&handler_info->mutex);
-       g_cond_init(&handler_info->cond);
-
        handler_info->cb_info = (void *)cb_info;
        g_atomic_int_set(&handler_info->running, 1);
 
@@ -2143,8 +2270,6 @@ static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
        if (handler_info->thread == NULL) {
                CAM_LOG_ERROR("t:%d thread failed", type);
 
-               g_mutex_clear(&handler_info->mutex);
-               g_cond_clear(&handler_info->cond);
                g_queue_free(handler_info->queue);
                handler_info->queue = NULL;
 
@@ -2159,65 +2284,151 @@ static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
 
 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
 {
-       int type = 0;
+       GThread *thread = NULL;
 
        if (!handler_info) {
                CAM_LOG_ERROR("NULL handler");
                return;
        }
 
+       g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&handler_info->mutex);
+
        if (!handler_info->thread) {
-               CAM_LOG_WARNING("thread is not created");
+               CAM_LOG_WARNING("thread[t:%d] is not created", handler_info->type);
                return;
        }
 
-       type = handler_info->type;
+       thread = handler_info->thread;
+       handler_info->thread = NULL;
 
-       CAM_LOG_INFO("t:%d thread[%p]", type, handler_info->thread);
+       CAM_LOG_INFO("t:%d thread[%p]", handler_info->type, thread);
 
-       g_mutex_lock(&handler_info->mutex);
        g_atomic_int_set(&handler_info->running, 0);
        g_cond_signal(&handler_info->cond);
-       g_mutex_unlock(&handler_info->mutex);
 
-       g_thread_join(handler_info->thread);
-       handler_info->thread = NULL;
+       g_clear_pointer(&locker, g_mutex_locker_free);
+
+       g_thread_join(thread);
 
-       g_mutex_clear(&handler_info->mutex);
-       g_cond_clear(&handler_info->cond);
        g_queue_free(handler_info->queue);
        handler_info->queue = NULL;
 
-       CAM_LOG_INFO("t:%d done", type);
+       CAM_LOG_INFO("t:%d done", handler_info->type);
 }
 
 
-static camera_cb_info_s *__camera_client_callback_new(gint sockfd)
+static void __camera_mutex_cond_init(camera_cb_info_s *cb_info)
 {
-       camera_cb_info_s *cb_info = NULL;
-       gint i = 0;
+       int i = 0;
 
-       g_return_val_if_fail(sockfd > 0, NULL);
-
-       cb_info = g_new0(camera_cb_info_s, 1);
-       if (cb_info == NULL) {
-               CAM_LOG_ERROR("cb_info failed");
-               goto ErrorExit;
-       }
-
-       cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
+       if (!cb_info) {
+               CAM_LOG_ERROR("NULL cb_info");
+               return;
+       }
 
        for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
                g_mutex_init(&cb_info->api_mutex[i]);
                g_cond_init(&cb_info->api_cond[i]);
        }
 
+       for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
+               g_mutex_init(&cb_info->user_cb_mutex[i]);
+
        g_mutex_init(&cb_info->fd_lock);
        g_mutex_init(&cb_info->mp_data_mutex);
        g_mutex_init(&cb_info->bridge_lock);
 
+       g_mutex_init(&cb_info->msg_handler_info.mutex);
+       g_mutex_init(&cb_info->preview_cb_info.mutex);
+       g_mutex_init(&cb_info->capture_cb_info.mutex);
+       g_cond_init(&cb_info->msg_handler_info.cond);
+       g_cond_init(&cb_info->preview_cb_info.cond);
+       g_cond_init(&cb_info->capture_cb_info.cond);
+
+       CAM_LOG_INFO("done");
+}
+
+
+static void __camera_mutex_cond_clear(camera_cb_info_s *cb_info)
+{
+       int i = 0;
+
+       if (!cb_info) {
+               CAM_LOG_ERROR("NULL cb_info");
+               return;
+       }
+
+       g_mutex_clear(&cb_info->msg_handler_info.mutex);
+       g_mutex_clear(&cb_info->preview_cb_info.mutex);
+       g_mutex_clear(&cb_info->capture_cb_info.mutex);
+       g_cond_clear(&cb_info->msg_handler_info.cond);
+       g_cond_clear(&cb_info->preview_cb_info.cond);
+       g_cond_clear(&cb_info->capture_cb_info.cond);
+
+       g_mutex_clear(&cb_info->fd_lock);
+       g_mutex_clear(&cb_info->mp_data_mutex);
+       g_mutex_clear(&cb_info->bridge_lock);
+
        for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
-               g_mutex_init(&cb_info->user_cb_mutex[i]);
+               g_mutex_clear(&cb_info->user_cb_mutex[i]);
+
+       for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
+               g_mutex_clear(&cb_info->api_mutex[i]);
+               g_cond_clear(&cb_info->api_cond[i]);
+       }
+
+       CAM_LOG_INFO("done");
+}
+
+
+static camera_preview_cb_monitoring_info_s *__camera_preview_cb_monitoring_info_create(int stream_id)
+{
+       camera_preview_cb_monitoring_info_s *new_info = g_new0(camera_preview_cb_monitoring_info_s, 1);
+
+       new_info->stream_id = stream_id;
+       new_info->total = g_new0(monitoring_info_sub_s, 1);
+       new_info->interval = g_new0(monitoring_info_sub_s, 1);
+       new_info->timer_calling = g_timer_new();
+       new_info->timer_interval = g_timer_new();
+
+       CAM_LOG_INFO("create preview cb monitoring info[%p]", new_info);
+
+       return new_info;
+}
+
+
+static void __camera_preview_cb_monitoring_info_destroy(camera_preview_cb_monitoring_info_s *info)
+{
+       if (!info)
+               return;
+
+       g_timer_destroy(info->timer_calling);
+       g_timer_destroy(info->timer_interval);
+       g_free(info->total);
+       g_free(info->interval);
+
+       CAM_LOG_INFO("destroy preview cb monitoring info[%p]", info);
+
+       g_free(info);
+}
+
+
+static camera_cb_info_s *__camera_client_callback_new(gint sockfd)
+{
+       int i = 0;
+       camera_cb_info_s *cb_info = NULL;
+
+       g_return_val_if_fail(sockfd > 0, NULL);
+
+       cb_info = g_new0(camera_cb_info_s, 1);
+       if (!cb_info) {
+               CAM_LOG_ERROR("cb_info failed");
+               goto ErrorExit;
+       }
+
+       cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
+
+       __camera_mutex_cond_init(cb_info);
 
        /* message handler thread */
        if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
@@ -2250,6 +2461,11 @@ static camera_cb_info_s *__camera_client_callback_new(gint sockfd)
 
        cb_info->is_server_connected = TRUE;
 
+       cb_info->monitoring_info_preview = __camera_preview_cb_monitoring_info_create(CAMERA_MONITORING_INFO_STREAM_ID_PREVIEW);
+       cb_info->monitoring_info_preview_mp = __camera_preview_cb_monitoring_info_create(CAMERA_MONITORING_INFO_STREAM_ID_PREVIEW_MP);
+       for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
+               cb_info->monitoring_info_preview_ex[i] = __camera_preview_cb_monitoring_info_create(i);
+
        return cb_info;
 //LCOV_EXCL_START
 ErrorExit:
@@ -2257,17 +2473,7 @@ ErrorExit:
                __destroy_msg_handler_thread(&cb_info->msg_handler_info);
                __destroy_msg_handler_thread(&cb_info->capture_cb_info);
 
-               for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
-                       g_mutex_clear(&cb_info->user_cb_mutex[i]);
-
-               g_mutex_clear(&cb_info->fd_lock);
-               g_mutex_clear(&cb_info->mp_data_mutex);
-               g_mutex_clear(&cb_info->bridge_lock);
-
-               for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
-                       g_mutex_clear(&cb_info->api_mutex[i]);
-                       g_cond_clear(&cb_info->api_cond[i]);
-               }
+               __camera_mutex_cond_clear(cb_info);
 
                g_free(cb_info);
                cb_info = NULL;
@@ -2277,11 +2483,15 @@ ErrorExit:
 //LCOV_EXCL_STOP
 }
 
+
 static void __camera_client_callback_destroy(camera_cb_info_s *cb_info)
 {
        int i = 0;
 
-       g_return_if_fail(cb_info != NULL);
+       if (!cb_info) {
+               CAM_LOG_ERROR("NULL cb_info");
+               return;
+       }
 
        CAM_LOG_INFO("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
 
@@ -2291,22 +2501,11 @@ static void __camera_client_callback_destroy(camera_cb_info_s *cb_info)
        CAM_LOG_INFO("msg_recv thread removed");
 
        /* destroy msg handler threads */
-       if (cb_info->preview_cb_info.thread)
-               __destroy_msg_handler_thread(&cb_info->preview_cb_info);
+       __destroy_msg_handler_thread(&cb_info->preview_cb_info);
        __destroy_msg_handler_thread(&cb_info->msg_handler_info);
        __destroy_msg_handler_thread(&cb_info->capture_cb_info);
 
-       for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
-               g_mutex_clear(&cb_info->user_cb_mutex[i]);
-
-       g_mutex_clear(&cb_info->fd_lock);
-       g_mutex_clear(&cb_info->mp_data_mutex);
-       g_mutex_clear(&cb_info->bridge_lock);
-
-       for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
-               g_mutex_clear(&cb_info->api_mutex[i]);
-               g_cond_clear(&cb_info->api_cond[i]);
-       }
+       __camera_mutex_cond_clear(cb_info);
 
        if (CAMERA_IS_FD_VALID(cb_info->fd)) {
                muse_client_close(cb_info->fd);
@@ -2327,6 +2526,11 @@ static void __camera_client_callback_destroy(camera_cb_info_s *cb_info)
                cb_info->dp_interface = NULL;
        }
 
+       __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview);
+       __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview_mp);
+       for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
+               __camera_preview_cb_monitoring_info_destroy(cb_info->monitoring_info_preview_ex[i]);
+
        g_free(cb_info);
 }
 
@@ -2335,10 +2539,7 @@ int _camera_start_evas_rendering(camera_h camera)
 {
        camera_cli_s *pc = (camera_cli_s *)camera;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("start");
 
@@ -2359,10 +2560,7 @@ int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
        int ret = CAMERA_ERROR_NONE;
        camera_cli_s *pc = (camera_cli_s *)camera;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("stop - keep screen %d", keep_screen);
 
@@ -2474,11 +2672,6 @@ int _camera_create_private(camera_device_e device, bool is_network, camera_h *ca
        int module_index = -1;
        int device_type = (int)device;
 
-       if (!camera) {
-               CAM_LOG_ERROR("NULL pointer");
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
        CAM_LOG_INFO("device %d, is_network %d", device, is_network);
 
        sock_fd = muse_client_new();
@@ -2574,6 +2767,12 @@ int _camera_create_private(camera_device_e device, bool is_network, camera_h *ca
                CAM_LOG_INFO("default preview format %d, user buffer %d, log level %d",
                        preview_format, user_buffer_supported, g_camera_log_level);
 
+               if (!camera) {
+                       CAM_LOG_ERROR("NULL out handle");
+                       ret= CAMERA_ERROR_INVALID_PARAMETER;
+                       goto ErrorExit;
+               }
+
                *camera = (camera_h)pc;
 
                /* get display interface handle */
@@ -2636,10 +2835,7 @@ int camera_change_device(camera_h camera, camera_device_e device)
        camera_cli_s *pc = (camera_cli_s *)camera;
        camera_msg_param param;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAMERA_MSG_PARAM_SET(param, INT, device);
 
@@ -2663,10 +2859,7 @@ int camera_destroy(camera_h camera)
        muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
        camera_cli_s *pc = (camera_cli_s *)camera;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -2691,16 +2884,14 @@ int camera_destroy(camera_h camera)
 
 int camera_start_preview(camera_h camera)
 {
+       int i = 0;
        int ret = CAMERA_ERROR_NONE;
        int *fds = NULL;
        muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
        camera_cli_s *pc = (camera_cli_s *)camera;
        camera_state_e current_state = CAMERA_STATE_NONE;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter : preview format %d, display type %d",
                pc->cb_info->preview_format, pc->cb_info->dp_info.type);
@@ -2719,6 +2910,11 @@ int camera_start_preview(camera_h camera)
        }
 
        if (current_state == CAMERA_STATE_CREATED) {
+               __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview);
+               __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview_mp);
+               for (i = 0 ; i < MM_CAMCORDER_EXTRA_PREVIEW_STREAM_MAX ; i++)
+                       __camera_preview_cb_monitoring_info_reset(pc->cb_info->monitoring_info_preview_ex[i]);
+
                if (!__create_msg_handler_thread(&pc->cb_info->preview_cb_info,
                                CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "cam:preview_cb", pc->cb_info)) {
                        CAM_LOG_ERROR("preview_cb_info failed");
@@ -2735,11 +2931,13 @@ int camera_start_preview(camera_h camera)
                }
        }
 
+       pc->cb_info->invoke_preview_cb = TRUE;
+
        _camera_msg_send(api, fds, pc->cb_info, &ret,
 #ifdef TIZEN_FEATURE_NO_TIMEOUT_FOR_PREVIEW
                CAMERA_CB_NO_TIMEOUT);
 #else
-               (pc->cb_info->is_network ? CAMERA_CB_NETWORK_PREVIEW_TIMEOUT : CAMERA_CB_TIMEOUT));
+               CAMERA_CB_TIMEOUT_FOR_PREVIEW);
 #endif
        if (ret != CAMERA_ERROR_NONE)
                goto _START_FAILED;
@@ -2778,10 +2976,7 @@ int camera_stop_preview(camera_h camera)
        muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
        camera_state_e current_state = CAMERA_STATE_NONE;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -2800,7 +2995,9 @@ int camera_stop_preview(camera_h camera)
                }
        }
 //LCOV_EXCL_STOP
-       /* send stop preview message */
+
+       pc->cb_info->invoke_preview_cb = FALSE;
+
        _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
 
        if (ret == CAMERA_ERROR_NONE) {
@@ -2826,10 +3023,7 @@ int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, came
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -2849,27 +3043,7 @@ int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, came
 
 bool camera_is_supported_continuous_capture(camera_h camera)
 {
-       int ret = CAMERA_ERROR_NONE;
-       camera_cli_s *pc = (camera_cli_s *)camera;
-       muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
-
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       CAM_LOG_INFO("Enter");
-
-       _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
-
-       if (ret < 0) {
-               CAM_LOG_ERROR("error is occurred 0x%x", ret);
-               ret = false;
-       }
-
-       CAM_LOG_INFO("ret : %d", ret);
-
-       return (bool)ret;
+       return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE);
 }
 
 
@@ -2881,10 +3055,7 @@ int camera_start_continuous_capture(camera_h camera, int count, int interval, ca
        camera_msg_param param;
        int value = 0;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -2911,10 +3082,7 @@ int camera_stop_continuous_capture(camera_h camera)
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -2928,105 +3096,25 @@ int camera_stop_continuous_capture(camera_h camera)
 
 bool camera_is_supported_face_detection(camera_h camera)
 {
-       int ret = CAMERA_ERROR_NONE;
-       camera_cli_s *pc = (camera_cli_s *)camera;
-       muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
-
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       CAM_LOG_INFO("Enter");
-
-       _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
-
-       if (ret < 0) {
-               CAM_LOG_ERROR("error is occurred 0x%x", ret);
-               ret = false;
-       }
-
-       CAM_LOG_INFO("ret : %d", ret);
-
-       return (bool)ret;
+       return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_FACE_DETECTION);
 }
 
 
 bool camera_is_supported_zero_shutter_lag(camera_h camera)
 {
-       int ret = CAMERA_ERROR_NONE;
-       camera_cli_s *pc = (camera_cli_s *)camera;
-       muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
-
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       CAM_LOG_INFO("Enter");
-
-       _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
-
-       if (ret < 0) {
-               CAM_LOG_ERROR("error is occurred 0x%x", ret);
-               ret = false;
-       }
-
-       CAM_LOG_INFO("ret : %d", ret);
-
-       return (bool)ret;
+       return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG);
 }
 
 
 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
 {
-       int ret = CAMERA_ERROR_NONE;
-       camera_cli_s *pc = (camera_cli_s *)camera;
-       muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
-
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       CAM_LOG_INFO("Enter");
-
-       _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
-
-       if (ret < 0) {
-               CAM_LOG_ERROR("error is occurred 0x%x", ret);
-               ret = false;
-       }
-
-       CAM_LOG_INFO("ret : %d", ret);
-
-       return (bool)ret;
+       return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB);
 }
 
 
 bool camera_is_supported_extra_preview(camera_h camera)
 {
-       int ret = CAMERA_ERROR_NONE;
-       camera_cli_s *pc = (camera_cli_s *)camera;
-       muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_EXTRA_PREVIEW;
-
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       CAM_LOG_INFO("Enter");
-
-       _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
-
-       if (ret < 0) {
-               CAM_LOG_ERROR("error is occurred 0x%x", ret);
-               ret = false;
-       }
-
-       CAM_LOG_INFO("ret : %d", ret);
-
-       return (bool)ret;
+       return __is_supported(camera, MUSE_CAMERA_API_SUPPORT_EXTRA_PREVIEW);
 }
 
 
@@ -3036,10 +3124,7 @@ int camera_get_device_count(camera_h camera, int *device_count)
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -3059,10 +3144,7 @@ int camera_start_face_detection(camera_h camera, camera_face_detected_cb callbac
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -3088,10 +3170,7 @@ int camera_stop_face_detection(camera_h camera)
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -3142,10 +3221,7 @@ int camera_start_focusing(camera_h camera, bool continuous)
        camera_msg_param param;
        int is_continuous = (int)continuous;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -3164,10 +3240,7 @@ int camera_cancel_focusing(camera_h camera)
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
 
@@ -3190,10 +3263,7 @@ int _camera_set_display(camera_h camera, mm_display_type_e type, void *display)
        muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
        muse_camera_display_info_s *dp_info = NULL;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        if (type > MM_DISPLAY_TYPE_OVERLAY_EXT) {
                CAM_LOG_ERROR("invalid type %d", type);
@@ -3310,10 +3380,7 @@ int camera_set_preview_resolution(camera_h camera, int width, int height)
        camera_msg_param param;
        int value = 0;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        if (pc->cb_info->is_evas_render) {
                ret = camera_get_state(camera, &current_state);
@@ -3355,10 +3422,7 @@ int camera_set_capture_resolution(camera_h camera, int width, int height)
        camera_msg_param param;
        int value = 0;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -3381,10 +3445,7 @@ int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
        muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
        camera_msg_param param;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter - format %d", set_format);
 
@@ -3406,10 +3467,7 @@ int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter - format %d", set_format);
 
@@ -3459,10 +3517,7 @@ int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
        camera_cli_s *pc = (camera_cli_s *)camera;
        camera_msg_param param;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        if (pc->cb_info->is_evas_render) {
                ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
@@ -3506,10 +3561,7 @@ int camera_set_display_flip(camera_h camera, camera_flip_e flip)
        camera_cli_s *pc = (camera_cli_s *)camera;
        camera_msg_param param;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        if (pc->cb_info->is_evas_render) {
                ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
@@ -3553,10 +3605,7 @@ int camera_set_display_visible(camera_h camera, bool visible)
        camera_cli_s *pc = (camera_cli_s *)camera;
        camera_msg_param param;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        if (pc->cb_info->is_evas_render) {
                ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
@@ -3600,10 +3649,7 @@ int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
        camera_cli_s *pc = (camera_cli_s *)camera;
        camera_msg_param param;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        if (pc->cb_info->is_evas_render) {
                ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
@@ -3647,10 +3693,7 @@ int camera_set_display_reuse_hint(camera_h camera, bool hint)
        camera_cli_s *pc = (camera_cli_s *)camera;
        camera_msg_param param;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter - hint %d", set_hint);
 
@@ -3818,10 +3861,7 @@ int camera_unset_preview_cb(camera_h camera)
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -3848,10 +3888,7 @@ int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_prev
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        if (camera_is_supported_media_packet_preview_cb(camera) == false) {
                CAM_LOG_ERROR("NOT SUPPORTED");
@@ -3888,10 +3925,7 @@ int camera_unset_media_packet_preview_cb(camera_h camera)
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        if (camera_is_supported_media_packet_preview_cb(camera) == false) {
                CAM_LOG_ERROR("NOT SUPPORTED");
@@ -3953,10 +3987,7 @@ int camera_unset_state_changed_cb(camera_h camera)
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -4013,10 +4044,7 @@ int camera_unset_interrupted_cb(camera_h camera)
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -4073,10 +4101,7 @@ int camera_unset_interrupt_started_cb(camera_h camera)
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -4133,10 +4158,7 @@ int camera_unset_focus_changed_cb(camera_h camera)
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -4193,10 +4215,7 @@ int camera_unset_error_cb(camera_h camera)
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -4364,26 +4383,7 @@ int camera_attr_get_lens_orientation(camera_h camera, int *angle)
 
 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
 {
-       int ret = CAMERA_ERROR_NONE;
-       camera_cli_s *pc = (camera_cli_s *)camera;
-       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
-       camera_msg_param param;
-       int set_mode = (int)mode;
-
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       CAM_LOG_INFO("Enter");
-
-       CAMERA_MSG_PARAM_SET(param, INT, set_mode);
-
-       _camera_msg_send_param1(api, pc->cb_info, &ret, &param, CAMERA_CB_TIMEOUT);
-
-       CAM_LOG_INFO("ret : 0x%x", ret);
-
-       return ret;
+       return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_THEATER_MODE, (int)mode);
 }
 
 
@@ -4443,10 +4443,7 @@ int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
        camera_msg_param param;
        int set_fps = (int)fps;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -4467,10 +4464,7 @@ int camera_attr_set_image_quality(camera_h camera, int quality)
        muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
        camera_msg_param param;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -4564,10 +4558,7 @@ int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
        camera_msg_param param;
        int set_bitrate = bitrate;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -4613,10 +4604,7 @@ int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
        camera_msg_param param;
        int set_gop_interval = interval;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -4637,10 +4625,7 @@ int camera_attr_set_zoom(camera_h camera, int zoom)
        muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
        camera_msg_param param;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
 
@@ -4656,24 +4641,7 @@ int camera_attr_set_zoom(camera_h camera, int zoom)
 
 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
 {
-       int ret = CAMERA_ERROR_NONE;
-       camera_cli_s *pc = (camera_cli_s *)camera;
-       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
-       camera_msg_param param;
-       int set_mode = (int)mode;
-
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       CAM_LOG_INFO("Enter, remote_handle : %td", pc->remote_handle);
-
-       CAMERA_MSG_PARAM_SET(param, INT, set_mode);
-
-       _camera_msg_send_param1(api, pc->cb_info, &ret, &param, CAMERA_CB_TIMEOUT);
-
-       return ret;
+       return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_AF_MODE, (int)mode);
 }
 
 
@@ -4685,10 +4653,7 @@ int camera_attr_set_af_area(camera_h camera, int x, int y)
        camera_msg_param param;
        int value = 0;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter - %d,%d", x, y);
 
@@ -4709,10 +4674,7 @@ int camera_attr_clear_af_area(camera_h camera)
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -4726,26 +4688,7 @@ int camera_attr_clear_af_area(camera_h camera)
 
 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
 {
-       int ret = CAMERA_ERROR_NONE;
-       camera_cli_s *pc = (camera_cli_s *)camera;
-       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
-       camera_msg_param param;
-       int set_mode = (int)mode;
-
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       CAM_LOG_INFO("Enter");
-
-       CAMERA_MSG_PARAM_SET(param, INT, set_mode);
-
-       _camera_msg_send_param1(api, pc->cb_info, &ret, &param, CAMERA_CB_TIMEOUT);
-
-       CAM_LOG_INFO("ret : 0x%x", ret);
-
-       return ret;
+       return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE, (int)mode);
 }
 
 
@@ -4756,10 +4699,7 @@ int camera_attr_set_exposure(camera_h camera, int value)
        muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
        camera_msg_param param;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -4781,10 +4721,7 @@ int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
        camera_msg_param param;
        int set_iso = (int)iso;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -4805,10 +4742,7 @@ int camera_attr_set_brightness(camera_h camera, int level)
        muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
        camera_msg_param param;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -4829,10 +4763,7 @@ int camera_attr_set_contrast(camera_h camera, int level)
        muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
        camera_msg_param param;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -4853,10 +4784,7 @@ int camera_attr_set_hue(camera_h camera, int level)
        muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
        camera_msg_param param;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -4878,10 +4806,7 @@ int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
        camera_msg_param param;
        int set_whitebalance = (int)wb;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -4903,10 +4828,7 @@ int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
        camera_msg_param param;
        int set_effect = (int)effect;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -4922,51 +4844,13 @@ int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
 
 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
 {
-       int ret = CAMERA_ERROR_NONE;
-       camera_cli_s *pc = (camera_cli_s *)camera;
-       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
-       camera_msg_param param;
-       int set_mode = (int)mode;
-
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       CAM_LOG_INFO("Enter");
-
-       CAMERA_MSG_PARAM_SET(param, INT, set_mode);
-
-       _camera_msg_send_param1(api, pc->cb_info, &ret, &param, CAMERA_CB_TIMEOUT);
-
-       CAM_LOG_INFO("ret : 0x%x", ret);
-
-       return ret;
+       return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_SCENE_MODE, (int)mode);
 }
 
 
 int camera_attr_enable_tag(camera_h camera, bool enable)
 {
-       int ret = CAMERA_ERROR_NONE;
-       camera_cli_s *pc = (camera_cli_s *)camera;
-       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
-       camera_msg_param param;
-       int set_enable = (int)enable;
-
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       CAM_LOG_INFO("Enter");
-
-       CAMERA_MSG_PARAM_SET(param, INT, set_enable);
-
-       _camera_msg_send_param1(api, pc->cb_info, &ret, &param, CAMERA_CB_TIMEOUT);
-
-       CAM_LOG_INFO("ret : 0x%x", ret);
-
-       return ret;
+       return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_TAG, (int)enable);
 }
 
 
@@ -5002,10 +4886,7 @@ int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation
        camera_msg_param param;
        int set_orientation = (int)orientation;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -5051,12 +4932,8 @@ int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, d
        double set_geotag[3] = {latitude, longitude, altitude};
        char *msg = NULL;
        int length = 0;
-       int send_ret = 0;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -5066,31 +4943,8 @@ int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, d
        msg = muse_core_msg_new(api,
                MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
                NULL);
-       if (!msg) {
-               CAM_LOG_ERROR("msg creation failed: api %d", api);
-               return CAMERA_ERROR_OUT_OF_MEMORY;
-       }
-
-       if (pc->cb_info->is_server_connected) {
-               _camera_update_api_waiting(pc->cb_info, api, 1);
-
-               g_mutex_lock(&pc->cb_info->fd_lock);
-               send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
-               g_mutex_unlock(&pc->cb_info->fd_lock);
-       }
-
-       if (send_ret < 0) {
-               CAM_LOG_ERROR("message send failed");
-               ret = CAMERA_ERROR_INVALID_OPERATION;
-       } else {
-               ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
-       }
-
-       _camera_update_api_waiting(pc->cb_info, api, -1);
 
-       muse_core_msg_free(msg);
-
-       CAM_LOG_INFO("ret : 0x%x", ret);
+       _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
 
        return ret;
 }
@@ -5102,10 +4956,7 @@ int camera_attr_remove_geotag(camera_h camera)
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -5119,26 +4970,7 @@ int camera_attr_remove_geotag(camera_h camera)
 
 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
 {
-       int ret = CAMERA_ERROR_NONE;
-       camera_cli_s *pc = (camera_cli_s *)camera;
-       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
-       camera_msg_param param;
-       int set_mode = (int)mode;
-
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       CAM_LOG_INFO("Enter");
-
-       CAMERA_MSG_PARAM_SET(param, INT, set_mode);
-
-       _camera_msg_send_param1(api, pc->cb_info, &ret, &param, CAMERA_CB_TIMEOUT);
-
-       CAM_LOG_INFO("ret : 0x%x", ret);
-
-       return ret;
+       return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_FLASH_MODE, (int)mode);
 }
 
 
@@ -5986,10 +5818,7 @@ int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
        camera_msg_param param;
        int set_rotation = (int)rotation;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -6035,10 +5864,7 @@ int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
        camera_msg_param param;
        int set_flip = (int)flip;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -6077,26 +5903,7 @@ int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
 
 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
 {
-       int ret = CAMERA_ERROR_NONE;
-       camera_cli_s *pc = (camera_cli_s *)camera;
-       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
-       camera_msg_param param;
-       int set_mode = (int)mode;
-
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       CAM_LOG_INFO("Enter");
-
-       CAMERA_MSG_PARAM_SET(param, INT, set_mode);
-
-       _camera_msg_send_param1(api, pc->cb_info, &ret, &param, CAMERA_CB_TIMEOUT);
-
-       CAM_LOG_INFO("ret : 0x%x", ret);
-
-       return ret;
+       return __set_mode(camera, MUSE_CAMERA_API_ATTR_SET_HDR_MODE, (int)mode);
 }
 
 
@@ -6126,27 +5933,7 @@ int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
 
 bool camera_attr_is_supported_hdr_capture(camera_h camera)
 {
-       int ret = CAMERA_ERROR_NONE;
-       camera_cli_s *pc = (camera_cli_s *)camera;
-       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
-
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       CAM_LOG_INFO("Enter");
-
-       _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
-
-       if (ret < 0) {
-               CAM_LOG_ERROR("error is occurred 0x%x", ret);
-               ret = false;
-       }
-
-       CAM_LOG_INFO("ret : %d", ret);
-
-       return (bool)ret;
+       return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE);
 }
 
 
@@ -6156,10 +5943,7 @@ int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_pro
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -6196,10 +5980,7 @@ int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -6222,26 +6003,7 @@ int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
 
 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
 {
-       int ret = CAMERA_ERROR_NONE;
-       camera_cli_s *pc = (camera_cli_s *)camera;
-       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
-       camera_msg_param param;
-       int set_enable = (int)enable;
-
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       CAM_LOG_INFO("Enter");
-
-       CAMERA_MSG_PARAM_SET(param, INT, set_enable);
-
-       _camera_msg_send_param1(api, pc->cb_info, &ret, &param, CAMERA_CB_TIMEOUT);
-
-       CAM_LOG_INFO("ret : 0x%x", ret);
-
-       return ret;
+       return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE, (int)enable);
 }
 
 
@@ -6271,52 +6033,13 @@ int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
 
 bool camera_attr_is_supported_anti_shake(camera_h camera)
 {
-       int ret = CAMERA_ERROR_NONE;
-       camera_cli_s *pc = (camera_cli_s *)camera;
-       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
-
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       CAM_LOG_INFO("Enter");
-
-       _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
-
-       if (ret < 0) {
-               CAM_LOG_ERROR("error is occurred 0x%x", ret);
-               ret = false;
-       }
-
-       CAM_LOG_INFO("ret : %d", ret);
-
-       return (bool)ret;
+       return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE);
 }
 
 
 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
 {
-       int ret = CAMERA_ERROR_NONE;
-       camera_cli_s *pc = (camera_cli_s *)camera;
-       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
-       camera_msg_param param;
-       int set_enable = (int)enable;
-
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       CAM_LOG_INFO("Enter");
-
-       CAMERA_MSG_PARAM_SET(param, INT, set_enable);
-
-       _camera_msg_send_param1(api, pc->cb_info, &ret, &param, CAMERA_CB_TIMEOUT);
-
-       CAM_LOG_INFO("ret : 0x%x", ret);
-
-       return ret;
+       return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION, (int)enable);
 }
 
 
@@ -6346,52 +6069,13 @@ int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
 
 bool camera_attr_is_supported_video_stabilization(camera_h camera)
 {
-       int ret = CAMERA_ERROR_NONE;
-       camera_cli_s *pc = (camera_cli_s *)camera;
-       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
-
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       CAM_LOG_INFO("Enter");
-
-       _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
-
-       if (ret < 0) {
-               CAM_LOG_ERROR("error is occurred 0x%x", ret);
-               ret = false;
-       }
-
-       CAM_LOG_INFO("ret : %d", ret);
-
-       return (bool)ret;
+       return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION);
 }
 
 
 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
 {
-       int ret = CAMERA_ERROR_NONE;
-       camera_cli_s *pc = (camera_cli_s *)camera;
-       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
-       camera_msg_param param;
-       int set_enable = (int)enable;
-
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       CAM_LOG_INFO("Enter");
-
-       CAMERA_MSG_PARAM_SET(param, INT, set_enable);
-
-       _camera_msg_send_param1(api, pc->cb_info, &ret, &param, CAMERA_CB_TIMEOUT);
-
-       CAM_LOG_INFO("ret : 0x%x", ret);
-
-       return ret;
+       return __set_enable(camera, MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST, (int)enable);
 }
 
 
@@ -6421,27 +6105,7 @@ int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
 
 bool camera_attr_is_supported_auto_contrast(camera_h camera)
 {
-       int ret = CAMERA_ERROR_NONE;
-       camera_cli_s *pc = (camera_cli_s *)camera;
-       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
-
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       CAM_LOG_INFO("Enter");
-
-       _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
-
-       if (ret < 0) {
-               CAM_LOG_ERROR("error is occurred 0x%x", ret);
-               ret = false;
-       }
-
-       CAM_LOG_INFO("ret : %d", ret);
-
-       return (bool)ret;
+       return __is_supported(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST);
 }
 
 
@@ -6453,10 +6117,7 @@ int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
        camera_msg_param param;
        int set_disable = (int)disable;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -6478,10 +6139,7 @@ int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type,
        camera_msg_param param0;
        camera_msg_param param1;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -6555,10 +6213,7 @@ int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type,
        camera_msg_param param0;
        camera_msg_param param1;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -6632,10 +6287,7 @@ int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
        camera_msg_param param;
        int set_ptz_type = (int)ptz_type;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -6681,12 +6333,8 @@ int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, i
        int set_display_roi_area[4] = {x, y, width, height};
        char *msg = NULL;
        int length = 0;
-       int send_ret = 0;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter");
 
@@ -6704,31 +6352,8 @@ int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, i
        msg = muse_core_msg_new(api,
                MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
                NULL);
-       if (!msg) {
-               CAM_LOG_ERROR("msg creation failed: api %d", api);
-               return CAMERA_ERROR_OUT_OF_MEMORY;
-       }
-
-       if (pc->cb_info->is_server_connected) {
-               _camera_update_api_waiting(pc->cb_info, api, 1);
-
-               g_mutex_lock(&pc->cb_info->fd_lock);
-               send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
-               g_mutex_unlock(&pc->cb_info->fd_lock);
-       }
-
-       if (send_ret < 0) {
-               CAM_LOG_ERROR("message send failed");
-               ret = CAMERA_ERROR_INVALID_OPERATION;
-       } else {
-               ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
-       }
 
-       _camera_update_api_waiting(pc->cb_info, api, -1);
-
-       muse_core_msg_free(msg);
-
-       CAM_LOG_INFO("ret : 0x%x", ret);
+       _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
 
        return ret;
 }
@@ -6944,10 +6569,7 @@ int camera_media_bridge_set_bridge(camera_h camera, media_bridge_h bridge)
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_BRIDGE;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        g_mutex_lock(&pc->cb_info->bridge_lock);
 
@@ -6980,10 +6602,7 @@ int camera_media_bridge_unset_bridge(camera_h camera)
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_BRIDGE;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        g_mutex_lock(&pc->cb_info->bridge_lock);
 
@@ -7022,7 +6641,7 @@ int camera_device_manager_initialize(camera_device_manager_h *manager)
        unsigned int i = 0;
        int ret = CAMERA_ERROR_NONE;
        void *dl_handle = NULL;
-       camera_device_manager *new_manager = g_new0(camera_device_manager, 1);
+       g_autofree camera_device_manager *new_manager = g_new0(camera_device_manager, 1);
        cdm_symbol_table sym_table[] = {
                {(void **)&new_manager->initialize, "cdm_initialize"},
                {(void **)&new_manager->deinitialize, "cdm_deinitialize"},
@@ -7063,17 +6682,17 @@ int camera_device_manager_initialize(camera_device_manager_h *manager)
        }
 
        new_manager->dl_handle = dl_handle;
-       *manager = (camera_device_manager_h)new_manager;
+       *manager = (camera_device_manager_h)g_steal_pointer(&new_manager);
 
        CAM_LOG_INFO("camera device manager[%p](dl handle[%p]) initialized",
-               new_manager, dl_handle);
+               *manager, dl_handle);
 
        return CAMERA_ERROR_NONE;
 
 _INITIALIZE_FAILED:
        if (dl_handle)
                dlclose(dl_handle);
-       g_free(new_manager);
+
        return ret;
 }
 
@@ -7144,8 +6763,7 @@ int camera_device_manager_foreach_supported_device(camera_device_manager_h manag
                        i, device->type, device->index,
                        device->name, device->id, device->extra_stream_num);
 
-               if (!callback(device->type, device->index, device->name,
-                               device->id, device->extra_stream_num, user_data)) {
+               if (!callback(device, user_data)) {
                        CAM_LOG_WARNING("callback is stopped[called:%u,total:%u]",
                                i + 1, device_list.count);
                        break;
@@ -7216,8 +6834,15 @@ int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callbac
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_CB;
 
-       if (!pc || !pc->cb_info || !callback) {
-               CAM_LOG_ERROR("NULL pointer %p %p", pc, callback);
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
+
+       if (!camera_is_supported_extra_preview(camera)) {
+               CAM_LOG_ERROR("extra preview is not supported");
+               return CAMERA_ERROR_NOT_SUPPORTED;
+       }
+
+       if (!callback) {
+               CAM_LOG_ERROR("NULL callback");
                return CAMERA_ERROR_INVALID_PARAMETER;
        }
 
@@ -7246,9 +6871,11 @@ int camera_unset_extra_preview_cb(camera_h camera)
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_UNSET_EXTRA_PREVIEW_CB;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
+
+       if (!camera_is_supported_extra_preview(camera)) {
+               CAM_LOG_ERROR("extra preview is not supported");
+               return CAMERA_ERROR_NOT_SUPPORTED;
        }
 
        CAM_LOG_INFO("Enter");
@@ -7273,16 +6900,12 @@ int camera_unset_extra_preview_cb(camera_h camera)
 int camera_set_extra_preview_stream_format(camera_h camera, int stream_id, camera_pixel_format_e pixel_format, int width, int height, int fps)
 {
        int ret = CAMERA_ERROR_NONE;
-       int send_ret = 0;
        int stream_format[4] = {pixel_format, width, height, fps};
        char *msg = NULL;
        camera_cli_s *pc = (camera_cli_s *)camera;
        muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_STREAM_FORMAT;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter - stream[%d],[%d,%dx%d,%d]",
                stream_id, pixel_format, width, height, fps);
@@ -7291,31 +6914,8 @@ int camera_set_extra_preview_stream_format(camera_h camera, int stream_id, camer
                MUSE_TYPE_INT, "stream_id", stream_id,
                MUSE_TYPE_ARRAY, "stream_format", 4, stream_format,
                NULL);
-       if (!msg) {
-               CAM_LOG_ERROR("msg creation failed: api %d", api);
-               return CAMERA_ERROR_OUT_OF_MEMORY;
-       }
-
-       if (pc->cb_info->is_server_connected) {
-               _camera_update_api_waiting(pc->cb_info, api, 1);
-
-               g_mutex_lock(&pc->cb_info->fd_lock);
-               send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
-               g_mutex_unlock(&pc->cb_info->fd_lock);
-       }
 
-       if (send_ret < 0) {
-               CAM_LOG_ERROR("message send failed");
-               ret = CAMERA_ERROR_INVALID_OPERATION;
-       } else {
-               ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
-       }
-
-       _camera_update_api_waiting(pc->cb_info, api, -1);
-
-       muse_core_msg_free(msg);
-
-       CAM_LOG_INFO("ret : 0x%x", ret);
+       _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret);
 
        return ret;
 }
@@ -7360,10 +6960,7 @@ int camera_attr_set_extra_preview_bitrate(camera_h camera, int stream_id, int bi
        camera_msg_param param0;
        camera_msg_param param1;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter - stream[%d], bitrate[%d]", stream_id, bitrate);
 
@@ -7416,10 +7013,7 @@ int camera_attr_set_extra_preview_gop_interval(camera_h camera, int stream_id, i
        camera_msg_param param0;
        camera_msg_param param1;
 
-       if (!pc || !pc->cb_info) {
-               CAM_LOG_ERROR("NULL handle[%p]", pc);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
+       CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER);
 
        CAM_LOG_INFO("Enter - stream[%d], GOP interval[%d]", stream_id, interval);