diff options
author | Jeongmo Yang <jm80.yang@samsung.com> | 2016-08-24 11:08:39 +0900 |
---|---|---|
committer | Jeongmo Yang <jm80.yang@samsung.com> | 2016-08-24 13:52:38 +0900 |
commit | 51649f382ee361004dd4493d0fffb23451b100ef (patch) | |
tree | f77907487c99e4adcd491b3a1c02eaa813798759 | |
parent | 738e879e6aef282f087bc078a7628e5b7172a9f3 (diff) | |
download | camera-51649f382ee361004dd4493d0fffb23451b100ef.tar.gz camera-51649f382ee361004dd4493d0fffb23451b100ef.tar.bz2 camera-51649f382ee361004dd4493d0fffb23451b100ef.zip |
[Release version 0.2.69] Code optimization - so binary size is reduced about 23 KBytesubmit/tizen/20160824.052737accepted/tizen/wearable/20160825.050347accepted/tizen/tv/20160825.050324accepted/tizen/mobile/20160825.050230accepted/tizen/ivi/20160825.050414accepted/tizen/common/20160824.154746
Change-Id: I335d672c963546174498710db6870e7831ed6337
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
-rw-r--r-- | include/camera.h | 26 | ||||
-rw-r--r-- | include/camera_private.h | 22 | ||||
-rw-r--r-- | packaging/capi-media-camera.spec | 2 | ||||
-rw-r--r-- | src/camera.c | 4186 |
4 files changed, 1965 insertions, 2271 deletions
diff --git a/include/camera.h b/include/camera.h index d86074f..713581a 100644 --- a/include/camera.h +++ b/include/camera.h @@ -921,7 +921,7 @@ int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, came * @see camera_stop_continuous_capture() * @see camera_is_supported_zero_shutter_lag() */ -int camera_start_continuous_capture(camera_h camera, int count, int interval, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb , void *user_data); +int camera_start_continuous_capture(camera_h camera, int count, int interval, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data); /** * @brief Aborts continuous capturing. @@ -1316,7 +1316,7 @@ int camera_is_display_visible(camera_h camera, bool *visible); * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported * @see camera_get_display_mode() */ -int camera_set_display_mode(camera_h camera , camera_display_mode_e mode); +int camera_set_display_mode(camera_h camera, camera_display_mode_e mode); /** * @ingroup CAPI_MEDIA_CAMERA_DISPLAY_MODULE @@ -1553,14 +1553,14 @@ int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format); * @brief Gets the facing direction of camera module. * @since_tizen 3.0 * @param[in] camera The handle to the camera - * @param[out] facing_direciton The facing direction of camera module + * @param[out] facing_direction The facing direction of camera module * @return @c 0 on success, otherwise a negative error value * @retval #CAMERA_ERROR_NONE Successful * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported */ -int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direciton); +int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction); /** * @brief Gets the camera's flash state. @@ -2266,7 +2266,7 @@ int camera_attr_get_zoom(camera_h camera, int *zoom); * @see camera_attr_set_zoom() * @see camera_attr_get_zoom() */ -int camera_attr_get_zoom_range(camera_h camera , int *min , int *max); +int camera_attr_get_zoom_range(camera_h camera, int *min, int *max); /** @@ -2729,7 +2729,7 @@ int camera_attr_get_contrast(camera_h camera, int *level); * @see camera_attr_set_contrast() * @see camera_attr_get_contrast() */ -int camera_attr_get_contrast_range(camera_h camera, int *min , int *max); +int camera_attr_get_contrast_range(camera_h camera, int *min, int *max); /** * @brief Sets the white balance mode. @@ -3065,7 +3065,7 @@ int camera_attr_get_tag_software(camera_h camera, char **software); * @see camera_attr_get_geotag() * @see camera_attr_remove_geotag() */ -int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude); +int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude); /** * @brief Gets the geotag(GPS data) in the EXIF(Exchangeable image file format) tag. @@ -3082,7 +3082,7 @@ int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, * @see camera_attr_set_geotag() * @see camera_attr_remove_geotag() */ -int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude); +int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude); /** * @brief Removes the geotag(GPS data) in the EXIF(Exchangeable image file format) tag. @@ -3196,7 +3196,7 @@ int camera_attr_get_lens_orientation(camera_h camera, int *angle); * @pre The camera state must be set to #CAMERA_STATE_CREATED. * @see camera_attr_get_stream_rotation() */ -int camera_attr_set_stream_rotation(camera_h camera , camera_rotation_e rotation); +int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation); /** * @brief Gets the stream rotation. @@ -3211,7 +3211,7 @@ int camera_attr_set_stream_rotation(camera_h camera , camera_rotation_e rotation * @pre The camera state must be set to #CAMERA_STATE_CREATED. * @see camera_attr_set_stream_rotation() */ -int camera_attr_get_stream_rotation(camera_h camera , camera_rotation_e *rotation); +int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation); /** * @} @@ -3262,7 +3262,7 @@ int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_s * @pre The camera state must be set to #CAMERA_STATE_CREATED. * @see camera_attr_set_stream_rotation() */ -int camera_attr_set_stream_flip(camera_h camera , camera_flip_e flip); +int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip); /** * @brief Gets the stream flip. @@ -3277,7 +3277,7 @@ int camera_attr_set_stream_flip(camera_h camera , camera_flip_e flip); * @pre The camera state must be set to #CAMERA_STATE_CREATED. * @see camera_attr_set_stream_rotation() */ -int camera_attr_get_stream_flip(camera_h camera , camera_flip_e *flip); +int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip); /** * @} @@ -3453,7 +3453,7 @@ int camera_attr_enable_anti_shake(camera_h camera, bool enable); * @see camera_attr_enable_anti_shake() * @see camera_attr_is_supported_anti_shake() */ -int camera_attr_is_enabled_anti_shake(camera_h camera , bool *enabled); +int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled); /** * @ingroup CAPI_MEDIA_CAMERA_CAPABILITY_MODULE diff --git a/include/camera_private.h b/include/camera_private.h index 32257f1..fa6667a 100644 --- a/include/camera_private.h +++ b/include/camera_private.h @@ -32,8 +32,16 @@ extern "C" { #undef BUFFER_MAX_PLANE_NUM #endif /* BUFFER_MAX_PLANE_NUM */ -#define BUFFER_MAX_PLANE_NUM 4 +#define BUFFER_MAX_PLANE_NUM 4 #define CAMERA_PARSE_STRING_SIZE 20 +#define CAMERA_CB_TIMEOUT 5 +#define CAMERA_CB_TIMEOUT_LONG 8 + +#define CAMERA_MSG_PARAM_SET(param, msg_type, set_value) { \ + param.type = MUSE_TYPE_##msg_type; \ + param.name = #set_value; \ + param.value.value_##msg_type = set_value; \ +} #define PREVIEW_CB_TYPE_USER 0x0000000F #define PREVIEW_CB_TYPE_EVAS 0x000000F0 @@ -172,6 +180,15 @@ typedef struct _camera_media_packet_data { int ref_cnt; } camera_media_packet_data; +typedef struct _camera_msg_param { + int type; + const char *name; + union { + int value_INT; + const char *value_STRING; + } value; +} camera_msg_param; + int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format); int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype); @@ -179,6 +196,9 @@ int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user int _camera_start_evas_rendering(camera_h camera); int _camera_stop_evas_rendering(camera_h camera, bool keep_screen); +typedef bool (*camera_supported_cb_param1)(int param, void *user_data); +typedef bool (*camera_supported_cb_param2)(int param1, int param2, void *user_data); + #ifdef __cplusplus } #endif diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec index 1939c2e..731092b 100644 --- a/packaging/capi-media-camera.spec +++ b/packaging/capi-media-camera.spec @@ -1,6 +1,6 @@ Name: capi-media-camera Summary: A Camera API -Version: 0.2.68 +Version: 0.2.69 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/camera.c b/src/camera.c index baa060f..22129d0 100644 --- a/src/camera.c +++ b/src/camera.c @@ -105,7 +105,7 @@ static const struct tizen_resource_listener _camera_tz_resource_listener = { __parent_id_getter }; -int _get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info) +int _camera_get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info) { int ret = CAMERA_ERROR_NONE; Ecore_Wl_Window *window = NULL; @@ -226,26 +226,27 @@ _DONE: return ret; } -static int _import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle) + +static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, 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", + if (!bufmgr || !bo || !bo_handle || !tbm_key) { + LOGE("invalid parameter - %p %p %p, key %d", bufmgr, bo, bo_handle, tbm_key); return false; } tmp_bo = tbm_bo_import(bufmgr, tbm_key); if (tmp_bo == NULL) { - LOGE("bo import failed - bufmgr %p, key %d", bufmgr, tbm_key); + LOGE("import failed - key %d", tbm_key); return false; } tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ); if (tmp_bo_handle.ptr == NULL) { - LOGE("bo map failed %p", tmp_bo); + LOGE("map failed %p", tmp_bo); tbm_bo_unref(tmp_bo); tmp_bo = NULL; return false; @@ -260,9 +261,9 @@ static int _import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, return true; } -static void _release_imported_bo(tbm_bo *bo) +static void _camera_release_imported_bo(tbm_bo *bo) { - if (bo == NULL || *bo == NULL) { + if (!bo || !(*bo)) { LOGW("NULL bo"); return; } @@ -273,7 +274,7 @@ static void _release_imported_bo(tbm_bo *bo) return; } -static int _client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out) +static 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; gint64 end_time; @@ -302,16 +303,121 @@ static int _client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *c g_mutex_unlock(&(cb_info->api_mutex[api])); - if (ret == CAMERA_ERROR_SOUND_POLICY) - LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release."); - else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_CALL) - LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release."); - else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_ALARM) - LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release."); + if (ret != CAMERA_ERROR_NONE) { + LOGE("api %d : error 0x%x", api, ret); + + if (ret == CAMERA_ERROR_SOUND_POLICY) + LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release."); + else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_CALL) + LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release."); + else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_ALARM) + LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release."); + } return ret; } + +static void _camera_msg_send(int api, camera_cb_info_s *cb_info, + int *ret, int timeout) +{ + char *msg = NULL; + + if (!cb_info) { + LOGE("NULL info - api %d", api); + + if (ret) + *ret = CAMERA_ERROR_INVALID_PARAMETER; + + return; + } + + msg = muse_core_msg_json_factory_new(api, NULL); + if (!msg) { + LOGE("msg failed: api %d", api); + + if (ret) + *ret = CAMERA_ERROR_OUT_OF_MEMORY; + + return; + } + + /*LOGD("send msg %s", msg);*/ + + if (muse_core_ipc_send_msg(cb_info->fd, msg) < 0) { + LOGE("msg send failed"); + if (ret) + *ret = CAMERA_ERROR_INVALID_OPERATION; + } else { + if (ret) + *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout); + } + + muse_core_msg_json_factory_free(msg); + + return; +} + + +static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info, + int *ret, camera_msg_param *param, int timeout) +{ + char *msg = NULL; + + if (!cb_info || !param) { + LOGE("invalid pointer : api %d - %p %p", api, cb_info, param); + + if (ret) + *ret = CAMERA_ERROR_INVALID_PARAMETER; + + return; + } + + /*LOGD("type %d, name %s", param->type, param->name);*/ + + switch (param->type) { + case MUSE_TYPE_INT: + msg = muse_core_msg_json_factory_new(api, + param->type, param->name, param->value.value_INT, + NULL); + break; + case MUSE_TYPE_STRING: + msg = muse_core_msg_json_factory_new(api, + param->type, param->name, param->value.value_STRING, + NULL); + break; + default: + LOGE("unknown type %d", param->type); + break; + } + + if (!msg) { + LOGE("msg failed: api %d", api); + + if (ret) + *ret = CAMERA_ERROR_OUT_OF_MEMORY; + + return; + } + + /*LOGD("send msg %s", msg);*/ + + if (muse_core_ipc_send_msg(cb_info->fd, msg) < 0) { + LOGE("msg send failed"); + + if (ret) + *ret = CAMERA_ERROR_INVALID_OPERATION; + } else { + if (ret) + *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout); + } + + muse_core_msg_json_factory_free(msg); + + return; +} + + int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format) { if (in_format <= MM_PIXEL_FORMAT_INVALID || @@ -449,8 +555,8 @@ void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_k if (num_buffer_key == 0) { /* non-zero copy */ - if (data_bo_handle == NULL || data_bo_handle->ptr == NULL) { - LOGE("no data pointer"); + if (!data_bo_handle || !data_bo_handle->ptr) { + LOGE("NULL pointer"); return; } @@ -577,15 +683,16 @@ void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera { int i = 0; int tbm_key = 0; + camera_msg_param param; - if (mp_data == NULL || cb_info == NULL) { - LOGE("NULL data %p or cb_info %p", mp_data, cb_info); + if (!mp_data || !cb_info) { + LOGE("NULL pointer %p %p", mp_data, cb_info); return; } if (mp_data->ref_cnt > 1) { mp_data->ref_cnt--; - LOGD("mp_data is still referenced(current %d)", mp_data->ref_cnt); + LOGD("ref count %d", mp_data->ref_cnt); } else { /* release imported bo */ for (i = 0 ; i < mp_data->num_buffer_key ; i++) { @@ -594,13 +701,15 @@ void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera } /* unref tbm bo */ - _release_imported_bo(&mp_data->bo); - _release_imported_bo(&mp_data->data_bo); + _camera_release_imported_bo(&mp_data->bo); + _camera_release_imported_bo(&mp_data->data_bo); /* return buffer */ tbm_key = mp_data->tbm_key; - muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER, - cb_info->fd, cb_info, INT, tbm_key); + + CAMERA_MSG_PARAM_SET(param, INT, tbm_key); + + _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0); g_free(mp_data); mp_data = NULL; @@ -728,8 +837,8 @@ int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s if (pkt_fmt_mimetype != mimetype || pkt_fmt_width != stream->width || pkt_fmt_height != stream->height) { - LOGW("different format. current 0x%x, %dx%d, new 0x%x, %dx%d", - pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height, mimetype, stream->width, stream->height); + LOGW("change fmt: current 0x%x, %dx%d", + pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height); media_format_unref(cb_info->pkt_fmt); cb_info->pkt_fmt = NULL; make_pkt_fmt = true; @@ -740,15 +849,15 @@ int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s /* create packet format */ if (make_pkt_fmt) { - LOGW("make new pkt_fmt - mimetype 0x%x, %dx%d", mimetype, stream->width, stream->height); + LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height); ret = media_format_create(&cb_info->pkt_fmt); if (ret == MEDIA_FORMAT_ERROR_NONE) { ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype); ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width); ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height); - LOGW("media_format_set_video_mime,width,height ret : 0x%x", ret); + LOGW("media_format_set : 0x%x", ret); } else { - LOGW("media_format_create failed"); + LOGW("media_format_create failed 0x%x", ret); } } @@ -757,19 +866,17 @@ int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize, (void *)cb_info, &pkt); if (ret != MEDIA_PACKET_ERROR_NONE) { - LOGE("media_packet_create_from_tbm_surface failed"); - + LOGE("media_packet_create failed 0x%x", ret); tbm_surface_destroy(tsurf); tsurf = NULL; } } else { - LOGE("failed to create tbm surface %dx%d, format %d, num_buffer_key %d, data_bo %p", - stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo); + LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p", + stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo); } if (pkt) { - LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer); - + /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/ /* set media packet data */ ret = media_packet_set_extra(pkt, (void *)mp_data); if (ret != MEDIA_PACKET_ERROR_NONE) { @@ -799,8 +906,8 @@ int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user camera_media_packet_data *mp_data = NULL; tbm_surface_h tsurf = NULL; - if (pkt == NULL || cb_info == NULL) { - LOGE("invalid parameter buffer %p, cb_info %p", pkt, cb_info); + if (!pkt || !cb_info) { + LOGE("NULL pointer %p %p", pkt, cb_info); return MEDIA_PACKET_FINALIZE; } @@ -820,10 +927,8 @@ int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user g_mutex_unlock(&cb_info->mp_data_mutex); ret = media_packet_get_tbm_surface(pkt, &tsurf); - if (ret != MEDIA_PACKET_ERROR_NONE) { - LOGE("media_packet_get_tbm_surface failed 0x%x", ret); - return MEDIA_PACKET_FINALIZE; - } + if (ret != MEDIA_PACKET_ERROR_NONE) + LOGE("get tbm_surface failed 0x%x", ret); if (tsurf) { tbm_surface_destroy(tsurf); @@ -833,15 +938,16 @@ int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user return MEDIA_PACKET_FINALIZE; } -static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event) +static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event) { int param1 = 0; int param2 = 0; int tbm_key = 0; tbm_bo bo = NULL; tbm_bo_handle bo_handle = {NULL, }; + camera_msg_param param; - if (recv_msg == NULL || event >= MUSE_CAMERA_EVENT_TYPE_NUM) { + if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) { LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event); return; } @@ -872,7 +978,7 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus muse_camera_msg_get(by_policy, recv_msg); LOGD("STATE CHANGE - previous %d, current %d, by_policy %d", - previous, current, by_policy); + previous, current, by_policy); ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous, (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]); @@ -896,7 +1002,6 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus case MUSE_CAMERA_EVENT_TYPE_PREVIEW: case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW: { - int e_type = MUSE_CAMERA_EVENT_TYPE_PREVIEW; int i = 0; int ret = 0; int num_buffer_key = 0; @@ -926,22 +1031,22 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus break; } + CAMERA_MSG_PARAM_SET(param, INT, tbm_key); + if (data_key > 0) { /* import tbm data_bo and get virtual address */ - if (!_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) { + if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) { LOGE("failed to import data key %d", data_key); - muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER, - cb_info->fd, cb_info, INT, tbm_key); + _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0); break; } } /* import tbm bo and get virtual address */ - if (!_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) { + if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) { LOGE("failed to import key %d", tbm_key); - _release_imported_bo(&data_bo); - muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER, - cb_info->fd, cb_info, INT, tbm_key); + _camera_release_imported_bo(&data_bo); + _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0); break; } @@ -952,19 +1057,18 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus for (i = 0 ; i < num_buffer_key ; i++) { /* import buffer bo and get virtual address */ - if (!_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) { + if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) { LOGE("failed to import buffer key %d", buffer_key[i]); /* release imported bo */ - _release_imported_bo(&data_bo); - _release_imported_bo(&bo); + _camera_release_imported_bo(&data_bo); + _camera_release_imported_bo(&bo); for (i -= 1 ; i >= 0 ; i--) - _release_imported_bo(&buffer_bo[i]); + _camera_release_imported_bo(&buffer_bo[i]); /* send return buffer */ - muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER, - cb_info->fd, cb_info, INT, tbm_key); + _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0); return; } @@ -974,8 +1078,8 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) { _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame); - e_type = MUSE_CAMERA_EVENT_TYPE_PREVIEW; - ((camera_preview_cb)cb_info->user_cb[e_type])(&frame, cb_info->user_data[e_type]); + ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame, + cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]); } /* call media packet callback */ @@ -985,9 +1089,9 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus if (ret == CAMERA_ERROR_NONE) { ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt); - e_type = MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW; if (ret == CAMERA_ERROR_NONE) { - ((camera_media_packet_preview_cb)cb_info->user_cb[e_type])(pkt, cb_info->user_data[e_type]); + ((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]); } else { _camera_media_packet_data_release(mp_data, cb_info); mp_data = NULL; @@ -1006,9 +1110,9 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus if (ret == CAMERA_ERROR_NONE) { g_mutex_lock(&cb_info->evas_mutex); - if (cb_info->run_evas_render) + if (cb_info->run_evas_render) { mm_evas_renderer_write(pkt, cb_info->evas_info); - else { + } else { LOGW("evas renderer is stopped, skip this buffer..."); media_packet_destroy(pkt); } @@ -1028,20 +1132,19 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus /* send message for preview callback return */ if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) - muse_camera_msg_send_no_return(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info->fd, cb_info); + _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0); if (mp_data == NULL) { /* release imported bo */ for (i = 0 ; i < num_buffer_key ; i++) - _release_imported_bo(&buffer_bo[i]); + _camera_release_imported_bo(&buffer_bo[i]); /* unmap and unref tbm bo */ - _release_imported_bo(&data_bo); - _release_imported_bo(&bo); + _camera_release_imported_bo(&data_bo); + _camera_release_imported_bo(&bo); /* return buffer */ - muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER, - cb_info->fd, cb_info, INT, tbm_key); + _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0); /*LOGD("return buffer Done");*/ } @@ -1068,7 +1171,7 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus muse_camera_msg_get(previous, recv_msg); muse_camera_msg_get(current, recv_msg); - LOGD("INTERRUPTED - policy %d, state previous %d, current %d", + LOGW("INTERRUPTED - policy %d, state previous %d, current %d", policy, previous, current); if (policy == CAMERA_POLICY_SOUND) @@ -1093,7 +1196,7 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus if (count > 0 && tbm_key > 0) { LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key); - if (!_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) + if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) break; /* set face info */ @@ -1113,11 +1216,11 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus #endif /* release bo */ - _release_imported_bo(&bo); + _camera_release_imported_bo(&bo); /* return buffer */ - muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER, - cb_info->fd, cb_info, INT, tbm_key); + CAMERA_MSG_PARAM_SET(param, INT, tbm_key); + _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0); /*LOGD("return buffer done");*/ } else { @@ -1147,192 +1250,56 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus } break; case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION: - muse_camera_msg_get(param1, recv_msg); - muse_camera_msg_get(param2, recv_msg); - - /*LOGD("SUPPORTED_PREVIEW_RESOLUTION - %d x %d", param1, param2);*/ - - if (((camera_supported_preview_resolution_cb)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) { - cb_info->user_cb[event] = NULL; - cb_info->user_data[event] = NULL; - LOGW("stop foreach callback for SUPPORTED_PREVIEW_RESOLUTION"); - } - break; + /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION: muse_camera_msg_get(param1, recv_msg); muse_camera_msg_get(param2, recv_msg); - /*LOGD("SUPPORTED_CAPTURE_RESOLUTION - %d x %d", param1, param2);*/ + /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/ - if (((camera_supported_capture_resolution_cb)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) { + if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) { cb_info->user_cb[event] = NULL; cb_info->user_data[event] = NULL; - LOGW("stop foreach callback for SUPPORTED_CAPTURE_RESOLUTION"); + LOGW("stop foreach callback for event %d", event); } break; case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT: - muse_camera_msg_get(param1, recv_msg); - - /*LOGD("SUPPORTED_CAPTURE_FORMAT - %d ", param1);*/ - - if (((camera_supported_capture_format_cb)cb_info->user_cb[event])((camera_pixel_format_e)param1, cb_info->user_data[event]) == false) { - cb_info->user_cb[event] = NULL; - cb_info->user_data[event] = NULL; - LOGW("stop foreach callback for SUPPORTED_CAPTURE_FORMAT"); - } - break; + /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT: - muse_camera_msg_get(param1, recv_msg); - - /*LOGD("SUPPORTED_PREVIEW_FORMAT - %d ", param1);*/ - - if (((camera_supported_preview_format_cb)cb_info->user_cb[event])((camera_pixel_format_e)param1, cb_info->user_data[event]) == false) { - cb_info->user_cb[event] = NULL; - cb_info->user_data[event] = NULL; - LOGW("stop foreach callback for SUPPORTED_PREVIEW_FORMAT"); - } - break; + /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE: - muse_camera_msg_get(param1, recv_msg); - - /*LOGD("SUPPORTED_AF_MODE - %d ", param1);*/ - - if (((camera_attr_supported_af_mode_cb)cb_info->user_cb[event])((camera_attr_af_mode_e)param1, cb_info->user_data[event]) == false) { - cb_info->user_cb[event] = NULL; - cb_info->user_data[event] = NULL; - LOGW("stop foreach callback for SUPPORTED_AF_MODE"); - } - break; + /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE: - muse_camera_msg_get(param1, recv_msg); - - /*LOGD("SUPPORTED_EXPOSURE_MODE - %d ", param1);*/ - - if (((camera_attr_supported_exposure_mode_cb)cb_info->user_cb[event])((camera_attr_exposure_mode_e)param1, cb_info->user_data[event]) == false) { - cb_info->user_cb[event] = NULL; - cb_info->user_data[event] = NULL; - LOGW("stop foreach callback for SUPPORTED_EXPOSURE_MODE"); - } - break; + /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO: - muse_camera_msg_get(param1, recv_msg); - - /*LOGD("SUPPORTED_ISO - %d ", param1);*/ - - if (((camera_attr_supported_iso_cb)cb_info->user_cb[event])((camera_attr_iso_e)param1, cb_info->user_data[event]) == false) { - cb_info->user_cb[event] = NULL; - cb_info->user_data[event] = NULL; - LOGW("stop foreach callback for SUPPORTED_ISO"); - } - break; + /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE: - muse_camera_msg_get(param1, recv_msg); - - /*LOGD("SUPPORTED_WHITEBALANCE - %d ", param1);*/ - - if (((camera_attr_supported_whitebalance_cb)cb_info->user_cb[event])((camera_attr_whitebalance_e)param1, cb_info->user_data[event]) == false) { - cb_info->user_cb[event] = NULL; - cb_info->user_data[event] = NULL; - LOGW("stop foreach callback for SUPPORTED_WHITEBALANCE"); - } - break; + /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT: - muse_camera_msg_get(param1, recv_msg); - - /*LOGD("SUPPORTED_EFFECT - %d ", param1);*/ - - if (((camera_attr_supported_effect_cb)cb_info->user_cb[event])((camera_attr_effect_mode_e)param1, cb_info->user_data[event]) == false) { - cb_info->user_cb[event] = NULL; - cb_info->user_data[event] = NULL; - LOGW("stop foreach callback for SUPPORTED_EFFECT"); - } - break; + /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE: - muse_camera_msg_get(param1, recv_msg); - - /*LOGD("SUPPORTED_SCENE_MODE - %d ", param1);*/ - - if (((camera_attr_supported_scene_mode_cb)cb_info->user_cb[event])((camera_attr_scene_mode_e)param1, cb_info->user_data[event]) == false) { - cb_info->user_cb[event] = NULL; - cb_info->user_data[event] = NULL; - LOGW("stop foreach callback for SUPPORTED_SCENE_MODE"); - } - break; + /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE: - muse_camera_msg_get(param1, recv_msg); - - /*LOGD("SUPPORTED_FLASH_MODE - %d ", param1);*/ - - if (((camera_attr_supported_flash_mode_cb)cb_info->user_cb[event])((camera_attr_flash_mode_e)param1, cb_info->user_data[event]) == false) { - cb_info->user_cb[event] = NULL; - cb_info->user_data[event] = NULL; - LOGW("stop foreach callback for SUPPORTED_FLASH_MODE"); - } - break; + /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS: - muse_camera_msg_get(param1, recv_msg); - - /*LOGD("SUPPORTED_FPS - %d ", param1);*/ - - if (((camera_attr_supported_fps_cb)cb_info->user_cb[event])((camera_attr_fps_e)param1, cb_info->user_data[event]) == false) { - cb_info->user_cb[event] = NULL; - cb_info->user_data[event] = NULL; - LOGW("stop foreach callback for SUPPORTED_FPS"); - } - break; + /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION: - muse_camera_msg_get(param1, recv_msg); - - /*LOGD("SUPPORTED_FPS_BY_RESOLUTION - %d ", param1);*/ - - if (((camera_attr_supported_fps_cb)cb_info->user_cb[event])((camera_attr_fps_e)param1, cb_info->user_data[event]) == false) { - cb_info->user_cb[event] = NULL; - cb_info->user_data[event] = NULL; - LOGW("stop foreach callback for SUPPORTED_FPS_BY_RESOLUTION"); - } - break; + /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP: - muse_camera_msg_get(param1, recv_msg); - - /*LOGD("SUPPORTED_STREAM_FLIP - %d ", param1);*/ - - if (((camera_attr_supported_stream_flip_cb)cb_info->user_cb[event])((camera_flip_e)param1, cb_info->user_data[event]) == false) { - cb_info->user_cb[event] = NULL; - cb_info->user_data[event] = NULL; - LOGW("stop foreach callback for SUPPORTED_STREAM_FLIP"); - } - break; + /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION: - muse_camera_msg_get(param1, recv_msg); - - /*LOGD("SUPPORTED_STREAM_ROTATION - %d ", param1);*/ - - if (((camera_attr_supported_stream_rotation_cb)cb_info->user_cb[event])((camera_rotation_e)param1, cb_info->user_data[event]) == false) { - cb_info->user_cb[event] = NULL; - cb_info->user_data[event] = NULL; - LOGW("stop foreach callback for SUPPORTED_STREAM_ROTATION"); - } - break; + /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE: - muse_camera_msg_get(param1, recv_msg); - - /*LOGD("SUPPORTED_THEATER_MODE - %d ", param1);*/ - - if (((camera_attr_supported_theater_mode_cb)cb_info->user_cb[event])((camera_attr_theater_mode_e)param1, cb_info->user_data[event]) == false) { - cb_info->user_cb[event] = NULL; - cb_info->user_data[event] = NULL; - LOGW("stop foreach callback for SUPPORTED_THEATER_MODE"); - } - break; + /* fall through */ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE: muse_camera_msg_get(param1, recv_msg); - /*LOGD("SUPPORTED_PTZ_TYPE - %d ", param1);*/ + /*LOGD("event %d SUPPORTED %d ", event, param1);*/ - if (((camera_attr_supported_ptz_type_cb)cb_info->user_cb[event])((camera_attr_ptz_type_e)param1, cb_info->user_data[event]) == false) { + if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) { cb_info->user_cb[event] = NULL; cb_info->user_data[event] = NULL; - LOGW("stop foreach callback for SUPPORTED_PTZ_TYPE"); + LOGW("stop foreach callback for event %d", event); } break; case MUSE_CAMERA_EVENT_TYPE_CAPTURE: @@ -1361,12 +1328,12 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus */ if (tbm_key_main <= 0) { - LOGE("invalid tbm_key_main %d", tbm_key_main); + LOGE("invalid key %d", tbm_key_main); break; } /* import tbm bo and get virtual address */ - if (!_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle)) + if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle)) break; buf_pos = (unsigned char *)bo_main_handle.ptr; @@ -1377,7 +1344,7 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus if (tbm_key_post > 0) { /* import tbm bo and get virtual address */ - if (!_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle)) + if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle)) break; buf_pos = (unsigned char *)bo_post_handle.ptr; @@ -1388,7 +1355,7 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus if (tbm_key_thumb > 0) { /* import tbm bo and get virtual address */ - if (!_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle)) + if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle)) break; buf_pos = (unsigned char *)bo_thumb_handle.ptr; @@ -1401,31 +1368,31 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]); /* unmap and unref tbm bo */ - _release_imported_bo(&bo_main); + _camera_release_imported_bo(&bo_main); /* return buffer */ tbm_key = tbm_key_main; - muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER, - cb_info->fd, cb_info, INT, tbm_key); + + CAMERA_MSG_PARAM_SET(param, INT, tbm_key); + + _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0); if (tbm_key_post > 0) { /* unmap and unref tbm bo */ - _release_imported_bo(&bo_post); + _camera_release_imported_bo(&bo_post); /* return buffer */ - tbm_key = tbm_key_post; - muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER, - cb_info->fd, cb_info, INT, tbm_key); + param.value.value_INT = tbm_key_post; + _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0); } if (tbm_key_thumb > 0) { /* unmap and unref tbm bo */ - _release_imported_bo(&bo_thumb); + _camera_release_imported_bo(&bo_thumb); /* return buffer */ - tbm_key = tbm_key_thumb; - muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER, - cb_info->fd, cb_info, INT, tbm_key); + param.value.value_INT = tbm_key_thumb; + _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0); } LOGD("return buffer done"); @@ -1462,6 +1429,7 @@ static bool _camera_idle_event_callback(void *data) /* 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)cam_idle_event); @@ -1469,7 +1437,7 @@ static bool _camera_idle_event_callback(void *data) g_mutex_unlock(&cb_info->idle_event_mutex); /* user callback */ - _client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event); + _camera_client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event); /* send signal for waiting thread */ g_cond_signal(&cb_info->idle_event_cond); @@ -1550,7 +1518,7 @@ static void *_camera_msg_handler_func(gpointer data) } else if (api == MUSE_CAMERA_CB_EVENT) { switch (cam_msg->event_class) { case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB: - _client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event); + _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event); break; case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN: cam_idle_event = g_new0(camera_idle_event_s, 1); @@ -1624,61 +1592,67 @@ static void _camera_remove_idle_event_all(camera_cb_info_s *cb_info) g_mutex_lock(&cb_info->idle_event_mutex); if (cb_info->idle_event_list == NULL) { - LOGD("No idle event is remained."); - } else { - list = cb_info->idle_event_list; + LOGD("No remained idle event"); + g_mutex_unlock(&cb_info->idle_event_mutex); + return; + } - while (list) { - cam_idle_event = list->data; - list = g_list_next(list); + list = cb_info->idle_event_list; - if (!cam_idle_event) { - LOGW("Fail to remove idle event. The event is NULL"); - } else { - if (g_mutex_trylock(&cam_idle_event->event_mutex)) { - ret = g_idle_remove_by_data(cam_idle_event); + while (list) { + cam_idle_event = list->data; + list = g_list_next(list); - LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret); + if (!cam_idle_event) { + LOGW("Fail to remove idle event. The event is NULL"); + continue; + } - if (ret == FALSE) { - cam_idle_event->cb_info = NULL; - LOGW("idle callback for event %p will be called later", cam_idle_event); - } + if (g_mutex_trylock(&cam_idle_event->event_mutex)) { + ret = g_idle_remove_by_data(cam_idle_event); - cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event); + LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret); - g_mutex_unlock(&cam_idle_event->event_mutex); + if (!ret) { + cam_idle_event->cb_info = NULL; + LOGW("idle event %p will be called later", cam_idle_event); + } - if (ret == TRUE) { - g_mutex_clear(&cam_idle_event->event_mutex); + cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event); - g_free(cam_idle_event); - cam_idle_event = NULL; + g_mutex_unlock(&cam_idle_event->event_mutex); - LOGD("remove idle event done"); - } - } else { - LOGW("event lock failed. it's being called..."); + if (ret) { + g_mutex_clear(&cam_idle_event->event_mutex); - end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100; + g_free(cam_idle_event); + cam_idle_event = NULL; - if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time)) - LOGW("signal received"); - else - LOGW("timeout"); - } + LOGD("remove idle event done"); } + + continue; } - g_list_free(cb_info->idle_event_list); - cb_info->idle_event_list = NULL; + LOGW("event lock failed. it's being called..."); + + end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100; + + if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time)) + LOGW("signal received"); + else + LOGW("timeout"); } + g_list_free(cb_info->idle_event_list); + cb_info->idle_event_list = NULL; + g_mutex_unlock(&cb_info->idle_event_mutex); return; } + static void *_camera_msg_recv_func(gpointer data) { int i = 0; @@ -1694,7 +1668,7 @@ static void *_camera_msg_recv_func(gpointer data) char **parse_str = NULL; camera_cb_info_s *cb_info = (camera_cb_info_s *)data; - if (cb_info == NULL) { + if (!cb_info) { LOGE("cb_info NULL"); return NULL; } @@ -1721,6 +1695,7 @@ static void *_camera_msg_recv_func(gpointer data) ret = muse_core_ipc_recv_msg(cb_info->fd, recv_msg); if (ret <= 0) break; + recv_msg[ret] = '\0'; str_pos = 0; @@ -1733,10 +1708,9 @@ static void *_camera_msg_recv_func(gpointer data) This module supports up to 200 combined msgs. */ for (str_pos = 0; str_pos < ret; str_pos++) { if (recv_msg[str_pos] == '}') { - memset(parse_str[num_token], 0x0, sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH); strncpy(parse_str[num_token], recv_msg + prev_pos, str_pos - prev_pos + 1); /*LOGD("splitted msg : [%s], Index : %d", parse_str[num_token], num_token);*/ - prev_pos = str_pos+1; + prev_pos = str_pos + 1; num_token++; } } @@ -1800,6 +1774,9 @@ static void *_camera_msg_recv_func(gpointer data) g_atomic_int_set(&cb_info->msg_recv_running, 0); LOGD("camera destroy done. close client cb handler"); } + } else if (api == MUSE_CAMERA_API_GET_FLASH_STATE) { + g_atomic_int_set(&cb_info->msg_recv_running, 0); + LOGD("get flash state done. close client cb handler"); } g_cond_signal(&cb_info->api_cond[api]); @@ -1836,7 +1813,7 @@ static void *_camera_msg_recv_func(gpointer data) g_mutex_unlock(&cb_info->msg_handler_info.mutex); } } else { - LOGW("unknown camera api %d and api_class %d", api, api_class); + LOGW("unknown camera api %d, class %d", api, api_class); } } @@ -1913,25 +1890,28 @@ static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info return; } + if (!handler_info->thread) { + LOGW("thread is not created"); + return; + } + type = handler_info->type; LOGD("t:%d thread %p", type, handler_info->thread); - if (handler_info->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_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); - g_thread_unref(handler_info->thread); - handler_info->thread = NULL; + g_thread_join(handler_info->thread); + g_thread_unref(handler_info->thread); + handler_info->thread = NULL; - g_mutex_clear(&handler_info->mutex); - g_cond_clear(&handler_info->cond); - g_queue_free(handler_info->queue); - handler_info->queue = NULL; - } + g_mutex_clear(&handler_info->mutex); + g_cond_clear(&handler_info->cond); + g_queue_free(handler_info->queue); + handler_info->queue = NULL; LOGD("t:%d done", type); @@ -1939,7 +1919,7 @@ static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info } -static camera_cb_info_s *_client_callback_new(gint sockfd) +static camera_cb_info_s *_camera_client_callback_new(gint sockfd, bool need_msg_handler_thread) { camera_cb_info_s *cb_info = NULL; gint i = 0; @@ -1952,6 +1932,11 @@ static camera_cb_info_s *_client_callback_new(gint sockfd) goto ErrorExit; } + 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]); + } + g_mutex_init(&cb_info->idle_event_mutex); g_cond_init(&cb_info->idle_event_cond); g_mutex_init(&cb_info->mp_data_mutex); @@ -1959,30 +1944,27 @@ static camera_cb_info_s *_client_callback_new(gint sockfd) g_mutex_init(&cb_info->evas_mutex); #endif /* TIZEN_FEATURE_EVAS_RENDERER */ - 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]); - } - - /* message handler thread */ - if (!__create_msg_handler_thread(&cb_info->msg_handler_info, - CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) { - LOGE("msg_handler_info failed"); - goto ErrorExit; - } + if (need_msg_handler_thread) { + /* message handler thread */ + if (!__create_msg_handler_thread(&cb_info->msg_handler_info, + CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) { + LOGE("msg_handler_info failed"); + goto ErrorExit; + } - /* message handler thread for preview callback */ - if (!__create_msg_handler_thread(&cb_info->preview_cb_info, - CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) { - LOGE("preview_cb_info failed"); - goto ErrorExit; - } + /* message handler thread for preview callback */ + if (!__create_msg_handler_thread(&cb_info->preview_cb_info, + CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) { + LOGE("preview_cb_info failed"); + goto ErrorExit; + } - /* message handler thread for capture callback */ - if (!__create_msg_handler_thread(&cb_info->capture_cb_info, - CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) { - LOGE("capture_cb_info failed"); - goto ErrorExit; + /* message handler thread for capture callback */ + if (!__create_msg_handler_thread(&cb_info->capture_cb_info, + CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) { + LOGE("capture_cb_info failed"); + goto ErrorExit; + } } cb_info->fd = sockfd; @@ -2008,11 +1990,6 @@ ErrorExit: __destroy_msg_handler_thread(&cb_info->preview_cb_info); __destroy_msg_handler_thread(&cb_info->capture_cb_info); - 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]); - } - g_mutex_clear(&cb_info->idle_event_mutex); g_cond_clear(&cb_info->idle_event_cond); g_mutex_clear(&cb_info->mp_data_mutex); @@ -2020,6 +1997,11 @@ ErrorExit: g_mutex_clear(&cb_info->evas_mutex); #endif /* TIZEN_FEATURE_EVAS_RENDERER */ + 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]); + } + g_free(cb_info); cb_info = NULL; } @@ -2027,30 +2009,25 @@ ErrorExit: return NULL; } -static void _client_callback_destroy(camera_cb_info_s *cb_info) +static void _camera_client_callback_destroy(camera_cb_info_s *cb_info) { - gint i = 0; + int i = 0; g_return_if_fail(cb_info != NULL); - LOGD("MSG receive thread[%p] destroy", cb_info->msg_recv_thread); + LOGD("msg_recv 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 thread removed"); + LOGD("msg_recv thread removed"); /* destroy msg handler threads */ __destroy_msg_handler_thread(&cb_info->msg_handler_info); __destroy_msg_handler_thread(&cb_info->preview_cb_info); __destroy_msg_handler_thread(&cb_info->capture_cb_info); - 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]); - } - g_mutex_clear(&cb_info->idle_event_mutex); g_cond_clear(&cb_info->idle_event_cond); g_mutex_clear(&cb_info->mp_data_mutex); @@ -2058,7 +2035,10 @@ static void _client_callback_destroy(camera_cb_info_s *cb_info) g_mutex_clear(&cb_info->evas_mutex); #endif /* TIZEN_FEATURE_EVAS_RENDERER */ - LOGD("event thread removed"); + 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]); + } if (cb_info->fd > -1) { muse_core_connection_close(cb_info->fd); @@ -2093,13 +2073,8 @@ int _camera_start_evas_rendering(camera_h camera) int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } @@ -2132,13 +2107,8 @@ 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 (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } @@ -2185,17 +2155,11 @@ int camera_create(camera_device_e device, camera_h *camera) muse_core_api_module_e muse_module = MUSE_CAMERA; int device_type = (int)device; - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!camera) { + LOGE("NULL pointer"); return CAMERA_ERROR_INVALID_PARAMETER; } - bufmgr = tbm_bufmgr_init(-1); - if (bufmgr == NULL) { - LOGE("get tbm bufmgr failed"); - return CAMERA_ERROR_INVALID_OPERATION; - } - sock_fd = muse_core_client_new(); if (sock_fd < 0) { LOGE("muse_core_client_new failed - returned fd %d", sock_fd); @@ -2235,7 +2199,14 @@ int camera_create(camera_device_e device, camera_h *camera) goto ErrorExit; } - pc->cb_info = _client_callback_new(sock_fd); + bufmgr = tbm_bufmgr_init(-1); + if (bufmgr == NULL) { + LOGE("get tbm bufmgr failed"); + ret = CAMERA_ERROR_INVALID_OPERATION; + goto ErrorExit; + } + + pc->cb_info = _camera_client_callback_new(sock_fd, true); if (pc->cb_info == NULL) { LOGE("cb_info alloc failed"); ret = CAMERA_ERROR_OUT_OF_MEMORY; @@ -2246,7 +2217,7 @@ int camera_create(camera_device_e device, camera_h *camera) LOGD("cb info : %d", pc->cb_info->fd); - ret = _client_wait_for_cb_return(api, pc->cb_info, CALLBACK_TIME_OUT); + ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { intptr_t handle = 0; muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg); @@ -2274,8 +2245,10 @@ int camera_create(camera_device_e device, camera_h *camera) return ret; ErrorExit: - tbm_bufmgr_deinit(bufmgr); - bufmgr = NULL; + if (bufmgr) { + tbm_bufmgr_deinit(bufmgr); + bufmgr = NULL; + } if (sock_fd > -1) { muse_core_connection_close(sock_fd); @@ -2284,7 +2257,7 @@ ErrorExit: if (pc) { if (pc->cb_info) { - _client_callback_destroy(pc->cb_info); + _camera_client_callback_destroy(pc->cb_info); pc->cb_info = NULL; } g_free(pc); @@ -2302,13 +2275,16 @@ int camera_change_device(camera_h camera, camera_device_e device) int ret = CAMERA_ERROR_NONE; muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE; camera_cli_s *pc = (camera_cli_s *)camera; + camera_msg_param param; - if (camera == NULL || pc->cb_info == NULL) { - LOGE("NULL handle, INVALID_PARAMETER"); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - muse_camera_msg_send1(api, pc->cb_info->fd, pc->cb_info, ret, INT, device); + CAMERA_MSG_PARAM_SET(param, INT, device); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); return ret; } @@ -2316,35 +2292,25 @@ int camera_change_device(camera_h camera, camera_device_e device) int camera_destroy(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; muse_camera_api_e api = MUSE_CAMERA_API_DESTROY; camera_cli_s *pc = (camera_cli_s *)camera; - int sock_fd = 0; - LOGD("ENTER"); - - if (pc->cb_info == NULL) { - LOGE("cb_info NULL, INVALID_PARAMETER"); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + LOGD("Enter"); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { _camera_remove_idle_event_all(pc->cb_info); - _client_callback_destroy(pc->cb_info); + _camera_client_callback_destroy(pc->cb_info); pc->cb_info = NULL; g_free(pc); pc = NULL; - } else { - LOGE("camera destroy error : 0x%x", ret); } return ret; @@ -2355,28 +2321,21 @@ int camera_start_preview(camera_h camera) int ret = CAMERA_ERROR_NONE; muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW; camera_cli_s *pc = (camera_cli_s *)camera; - int sock_fd = 0; - - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - LOGD("start"); - - sock_fd = pc->cb_info->fd; - - muse_camera_msg_send_longtime(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); - if (ret != CAMERA_ERROR_NONE) { - LOGE("start preview failed 0x%x", ret); - } else if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) { + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT_LONG); + if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) { ret = _camera_start_evas_rendering(camera); + if (ret != CAMERA_ERROR_NONE) { + LOGE("stop preview because of error"); + _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0); + } } LOGD("ret : 0x%x", ret); @@ -2384,32 +2343,22 @@ int camera_start_preview(camera_h camera) return ret; } + int camera_stop_preview(camera_h camera) { int ret = CAMERA_ERROR_NONE; - int sock_fd = 0; - camera_cli_s *pc = NULL; + camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW; + camera_state_e current_state = CAMERA_STATE_NONE; - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - pc = (camera_cli_s *)camera; - - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - sock_fd = pc->cb_info->fd; - LOGD("Enter"); if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) { - camera_state_e current_state = CAMERA_STATE_NONE; - ret = camera_get_state(camera, ¤t_state); if (ret != CAMERA_ERROR_NONE) { LOGE("failed to get current state 0x%x", ret); @@ -2424,358 +2373,317 @@ int camera_stop_preview(camera_h camera) } /* send stop preview message */ - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + + if (ret != CAMERA_ERROR_NONE && + current_state == CAMERA_STATE_PREVIEW) { + LOGW("restart evas rendering"); + _camera_start_evas_rendering(camera); + } LOGD("ret : 0x%x", ret); return ret; } + int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE; - int sock_fd; - int is_capturing_cb = 0; - int is_completed_cb = 0; - LOGD("Enter, handle :%x", pc->remote_handle); - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + LOGD("Enter"); - if (capturing_cb != NULL) { - is_capturing_cb = 1; - pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb; - pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data; - } + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb; + pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data; - if (completed_cb != NULL) { - is_completed_cb = 1; - pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb; - pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data; - } + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb; + pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data; + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); - muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, is_capturing_cb, INT, is_completed_cb); - LOGD("is_capturing_cb :%d, is_completed_cb : %d", is_capturing_cb, is_completed_cb); LOGD("ret : 0x%x", ret); + return ret; } + bool camera_is_supported_continuous_capture(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return false; - } - int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); LOGD("ret : 0x%x", ret); + return (bool)ret; } -int camera_start_continuous_capture(camera_h camera, int count, int interval, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb , void *user_data) -{ - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } +int camera_start_continuous_capture(camera_h camera, int count, int interval, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data) +{ int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE; + camera_msg_param param; + int value = 0; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + + LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data; pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb; - muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, count, INT, interval); + value = (count << 16) | interval; + CAMERA_MSG_PARAM_SET(param, INT, value); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); return ret; } + int camera_stop_continuous_capture(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE; - LOGD("Enter, handle :%x", pc->remote_handle); - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } + bool camera_is_supported_face_detection(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return false; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return (bool)ret; } + bool camera_is_supported_zero_shutter_lag(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return false; - } 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; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return (bool)ret; } + bool camera_is_supported_media_packet_preview_cb(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return false; - } - 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; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return (bool)ret; } int camera_get_device_count(camera_h camera, int *device_count) { - if (camera == NULL || device_count == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_device_count = 0; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_device_count; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_device_count, pc->cb_info->recv_msg); *device_count = get_device_count; } + LOGD("ret : 0x%x", ret); + return ret; } int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION; - LOGD("Enter, handle :%x", pc->remote_handle); - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_stop_face_detection(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION; - LOGD("Enter, handle :%x", pc->remote_handle); - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_get_state(camera_h camera, camera_state_e *state) { - if (camera == NULL || state == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_state = CAMERA_STATE_NONE; + + if (!pc || !pc->cb_info || !state) { + LOGE("NULL pointer %p %p", pc, state); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_state; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_state, pc->cb_info->recv_msg); *state = (camera_state_e)get_state; } + LOGD("ret : 0x%x", ret); + return ret; } int camera_start_focusing(camera_h camera, bool continuous) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int is_continuous = (int)continuous; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int is_continuous = (int)continuous; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, is_continuous); + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, is_continuous); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_cancel_focusing(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } @@ -2785,15 +2693,16 @@ int camera_set_display(camera_h camera, camera_display_type_e type, camera_displ void *set_display_handle = NULL; Evas_Object *obj = NULL; const char *object_type = NULL; - camera_wl_info_s *wl_info = NULL; camera_cli_s *pc = (camera_cli_s *)camera; camera_cb_info_s *cb_info = NULL; muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY; camera_state_e current_state = CAMERA_STATE_NONE; - int sock_fd = 0; + camera_msg_param param; + char *msg = NULL; + int length = 0; - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } @@ -2807,13 +2716,7 @@ int camera_set_display(camera_h camera, camera_display_type_e type, camera_displ return CAMERA_ERROR_INVALID_PARAMETER; } - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - cb_info = (camera_cb_info_s *)pc->cb_info; - sock_fd = cb_info->fd; ret = camera_get_state(camera, ¤t_state); if (ret != CAMERA_ERROR_NONE) { @@ -2826,7 +2729,7 @@ int camera_set_display(camera_h camera, camera_display_type_e type, camera_displ return CAMERA_ERROR_INVALID_STATE; } - LOGD("Enter, remote_handle : %x display : 0x%x", pc->remote_handle, display); + LOGD("Enter - display : %p", display); if (type == CAMERA_DISPLAY_TYPE_NONE) { set_display_handle = 0; @@ -2837,7 +2740,7 @@ int camera_set_display(camera_h camera, camera_display_type_e type, camera_displ if (object_type) { if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) { /* get wayland parent id */ - if (_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) { + if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) { LOGE("failed to get wayland info"); return CAMERA_ERROR_INVALID_OPERATION; } @@ -2915,15 +2818,35 @@ int camera_set_display(camera_h camera, camera_display_type_e type, camera_displ pc->display_handle = (intptr_t)set_display_handle; if (type == CAMERA_DISPLAY_TYPE_OVERLAY) { - wl_info = &pc->wl_info; - muse_camera_msg_send_array_and_value(api, sock_fd, cb_info, ret, - wl_info, sizeof(camera_wl_info_s), sizeof(int), INT, type); + length = sizeof(camera_wl_info_s) / sizeof(int) + \ + (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0); + + msg = muse_core_msg_json_factory_new(api, + MUSE_TYPE_INT, "type", type, + MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info, + NULL); + if (!msg) { + LOGE("msg creation failed: api %d", api); + return CAMERA_ERROR_OUT_OF_MEMORY; + } + + if (muse_core_ipc_send_msg(pc->cb_info->fd, msg) < 0) { + LOGE("message send failed"); + ret = CAMERA_ERROR_INVALID_OPERATION; + } else { + ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT); + } + + muse_core_msg_json_factory_free(msg); LOGD("wayland parent id : %d, window %d,%d,%dx%d", - wl_info->parent_id, wl_info->window_x, wl_info->window_y, - wl_info->window_width, wl_info->window_height); - } else - muse_camera_msg_send1(api, sock_fd, cb_info, ret, INT, type); + pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y, + pc->wl_info.window_width, pc->wl_info.window_height); + } else { + CAMERA_MSG_PARAM_SET(param, INT, type); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + } if (ret != CAMERA_ERROR_NONE) LOGE("set display error 0x%x", ret); @@ -2933,127 +2856,125 @@ int camera_set_display(camera_h camera, camera_display_type_e type, camera_displ return ret; } -int camera_set_preview_resolution(camera_h camera, int width, int height) + +int camera_set_preview_resolution(camera_h camera, int width, int height) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int value = 0; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height); + value = (width << 16) | height; + CAMERA_MSG_PARAM_SET(param, INT, value); + + LOGD("%dx%d -> 0x%x", width, height, value); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_set_capture_resolution(camera_h camera, int width, int height) +int camera_set_capture_resolution(camera_h camera, int width, int height) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int value = 0; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height); + LOGD("Enter"); + + value = (width << 16) | height; + CAMERA_MSG_PARAM_SET(param, INT, value); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } + int camera_set_capture_format(camera_h camera, camera_pixel_format_e format) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; int set_format = (int)format; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x, capture_format: %d", pc->remote_handle, set_format); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format); + LOGD("Enter - format %d", set_format); + + CAMERA_MSG_PARAM_SET(param, INT, set_format); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } + int camera_set_preview_format(camera_h camera, camera_pixel_format_e format) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; int set_format = (int)format; - + camera_msg_param param; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x, capture_format: %d", pc->remote_handle, set_format); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format); + LOGD("Enter - capture_format %d", set_format); + + CAMERA_MSG_PARAM_SET(param, INT, set_format); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_get_preview_resolution(camera_h camera, int *width, int *height) -{ - if (camera == NULL || width == NULL || height == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - +int camera_get_preview_resolution(camera_h camera, int *width, int *height) +{ int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_width = 0; + int get_height = 0; + + if (!pc || !pc->cb_info || !width || !height) { + LOGE("NULL pointer %p %p %p", pc, width, height); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_width; - int get_height; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_width, pc->cb_info->recv_msg); @@ -3061,30 +2982,22 @@ int camera_get_preview_resolution(camera_h camera, int *width, int *height) *width = get_width; *height = get_height; } + LOGD("ret : 0x%x", ret); + return ret; } + int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation) { int ret = CAMERA_ERROR_NONE; int set_rotation = (int)rotation; - camera_cli_s *pc = NULL; - - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - if (rotation < CAMERA_ROTATION_NONE || rotation > CAMERA_ROTATION_270) { - LOGE("Invalid rotation %d", rotation); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - pc = (camera_cli_s *)camera; + camera_cli_s *pc = (camera_cli_s *)camera; + camera_msg_param param; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } @@ -3103,32 +3016,26 @@ int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation) } #endif /* TIZEN_FEATURE_EVAS_RENDERER */ - muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, - pc->cb_info->fd, pc->cb_info, ret, INT, set_rotation); + CAMERA_MSG_PARAM_SET(param, INT, set_rotation); + + _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); return ret; } + int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation) { int ret = CAMERA_ERROR_NONE; int get_rotation = CAMERA_ROTATION_NONE; - camera_cli_s *pc = NULL; - - if (camera == NULL || rotation == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - pc = (camera_cli_s *)camera; + camera_cli_s *pc = (camera_cli_s *)camera; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !rotation) { + LOGE("NULL pointer %p %p", pc, rotation); return CAMERA_ERROR_INVALID_PARAMETER; } - muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, - pc->cb_info->fd, pc->cb_info, ret); + _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg); @@ -3138,26 +3045,16 @@ int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation) return ret; } + int camera_set_display_flip(camera_h camera, camera_flip_e flip) { int ret = CAMERA_ERROR_NONE; int set_flip = (int)flip; - camera_cli_s *pc = NULL; - - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - if (flip < CAMERA_FLIP_NONE || flip > CAMERA_FLIP_BOTH) { - LOGE("Invalid flip %d", flip); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - pc = (camera_cli_s *)camera; + camera_cli_s *pc = (camera_cli_s *)camera; + camera_msg_param param; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } @@ -3176,32 +3073,26 @@ int camera_set_display_flip(camera_h camera, camera_flip_e flip) } #endif /* TIZEN_FEATURE_EVAS_RENDERER */ - muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, - pc->cb_info->fd, pc->cb_info, ret, INT, set_flip); + CAMERA_MSG_PARAM_SET(param, INT, set_flip); + + _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); return ret; } + int camera_get_display_flip(camera_h camera, camera_flip_e *flip) { int ret = CAMERA_ERROR_NONE; int get_flip = CAMERA_FLIP_NONE; - camera_cli_s *pc = NULL; - - if (camera == NULL || flip == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - pc = (camera_cli_s *)camera; + camera_cli_s *pc = (camera_cli_s *)camera; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !flip) { + LOGE("NULL pointer %p %p", pc, flip); return CAMERA_ERROR_INVALID_PARAMETER; } - muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, - pc->cb_info->fd, pc->cb_info, ret); + _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_flip, pc->cb_info->recv_msg); @@ -3211,21 +3102,16 @@ int camera_get_display_flip(camera_h camera, camera_flip_e *flip) return ret; } + int camera_set_display_visible(camera_h camera, bool visible) { int ret = CAMERA_ERROR_NONE; int set_visible = (int)visible; - camera_cli_s *pc = NULL; - - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - pc = (camera_cli_s *)camera; + camera_cli_s *pc = (camera_cli_s *)camera; + camera_msg_param param; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } @@ -3244,32 +3130,26 @@ int camera_set_display_visible(camera_h camera, bool visible) } #endif /* TIZEN_FEATURE_EVAS_RENDERER */ - muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, - pc->cb_info->fd, pc->cb_info, ret, INT, set_visible); + CAMERA_MSG_PARAM_SET(param, INT, set_visible); + + _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); return ret; } + int camera_is_display_visible(camera_h camera, bool *visible) { int ret = CAMERA_ERROR_NONE; int get_visible = true; - camera_cli_s *pc = NULL; - - if (camera == NULL || visible == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - pc = (camera_cli_s *)camera; + camera_cli_s *pc = (camera_cli_s *)camera; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !visible) { + LOGE("NULL pointer %p %p", pc, visible); return CAMERA_ERROR_INVALID_PARAMETER; } - muse_camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, - pc->cb_info->fd, pc->cb_info, ret); + _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_visible, pc->cb_info->recv_msg); @@ -3279,26 +3159,16 @@ int camera_is_display_visible(camera_h camera, bool *visible) return ret; } + int camera_set_display_mode(camera_h camera, camera_display_mode_e mode) { int ret = CAMERA_ERROR_NONE; int set_mode = (int)mode; - camera_cli_s *pc = NULL; - - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - if (mode < CAMERA_DISPLAY_MODE_LETTER_BOX || mode > CAMERA_DISPLAY_MODE_CUSTOM_ROI) { - LOGE("Invalid mode %d", mode); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - pc = (camera_cli_s *)camera; + camera_cli_s *pc = (camera_cli_s *)camera; + camera_msg_param param; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } @@ -3317,32 +3187,26 @@ int camera_set_display_mode(camera_h camera, camera_display_mode_e mode) } #endif /* TIZEN_FEATURE_EVAS_RENDERER */ - muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_MODE, - pc->cb_info->fd, pc->cb_info, ret, INT, set_mode); + CAMERA_MSG_PARAM_SET(param, INT, set_mode); + + _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); return ret; } + int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode) { int ret = CAMERA_ERROR_NONE; int get_mode = CAMERA_DISPLAY_MODE_LETTER_BOX; - camera_cli_s *pc = NULL; - - if (camera == NULL || mode == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - pc = (camera_cli_s *)camera; + camera_cli_s *pc = (camera_cli_s *)camera; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !mode) { + LOGE("NULL pointer %p %p", pc, mode); return CAMERA_ERROR_INVALID_PARAMETER; } - muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, - pc->cb_info->fd, pc->cb_info, ret); + _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_mode, pc->cb_info->recv_msg); @@ -3358,21 +3222,18 @@ int camera_set_display_reuse_hint(camera_h camera, bool hint) int ret = CAMERA_ERROR_NONE; int set_hint = (int)hint; camera_cli_s *pc = (camera_cli_s *)camera; + camera_msg_param param; - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } + LOGD("Enter - hint %d", set_hint); - LOGD("set display reuse hint %d", set_hint); + CAMERA_MSG_PARAM_SET(param, INT, set_hint); - muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, - pc->cb_info->fd, pc->cb_info, ret, INT, set_hint); + _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); return ret; } @@ -3385,25 +3246,18 @@ int camera_get_display_reuse_hint(camera_h camera, bool *hint) camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT; - if (camera == NULL || hint == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !hint) { + LOGE("NULL pointer %p %p", pc, hint); return CAMERA_ERROR_INVALID_PARAMETER; } - muse_camera_msg_send(api, pc->cb_info->fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_hint, pc->cb_info->recv_msg); *hint = (bool)get_hint; LOGD("display reuse hint %d", *hint); - } else { - LOGE("failed 0x%x", ret); } return ret; @@ -3412,25 +3266,20 @@ int camera_get_display_reuse_hint(camera_h camera, bool *hint) int camera_get_capture_resolution(camera_h camera, int *width, int *height) { - if (camera == NULL || width == NULL || height == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_width = 0; + int get_height = 0; + + if (!pc || !pc->cb_info || !width || !height) { + LOGE("NULL pointer %p %p %p", pc, width, height); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_width; - int get_height; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_width, pc->cb_info->recv_msg); @@ -3438,162 +3287,154 @@ int camera_get_capture_resolution(camera_h camera, int *width, int *height) *width = get_width; *height = get_height; } + LOGD("ret : 0x%x", ret); + return ret; } + int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format) { - if (camera == NULL || format == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT; - int get_format; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_format = 0; + + if (!pc || !pc->cb_info || !format) { + LOGE("NULL pointer %p %p", pc, format); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_format, pc->cb_info->recv_msg); *format = (camera_pixel_format_e)get_format; } + LOGD("ret : 0x%x", ret); + return ret; } + int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format) { - if (camera == NULL || format == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT; - int get_format; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_format = 0; + + if (!pc || !pc->cb_info || !format) { + LOGE("NULL pointer %p %p", pc, format); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_format, pc->cb_info->recv_msg); *format = (camera_pixel_format_e)get_format; } + LOGD("ret : 0x%x", ret); + return ret; } -int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direciton) -{ - if (camera == NULL || facing_direciton == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } +int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction) +{ int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_facing_direction = 0; + + if (!pc || !pc->cb_info || !facing_direction) { + LOGE("NULL pointer %p %p", pc, facing_direction); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_facing_direction; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_facing_direction, pc->cb_info->recv_msg); - *facing_direciton = (camera_facing_direction_e)get_facing_direction; + *facing_direction = (camera_facing_direction_e)get_facing_direction; } + LOGD("ret : 0x%x", ret); + return ret; } + int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data) { - if (camera == NULL || callback == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; - camera_cb_info_s *cb_info = (camera_cb_info_s *)pc->cb_info; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB; + + if (!pc || !pc->cb_info || !callback) { + LOGE("NULL pointer %p %p", pc, callback); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB; - LOGD("Enter, handle :%x", pc->remote_handle); + LOGD("Enter"); pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data; - SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_USER); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } + int camera_unset_preview_cb(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; - camera_cb_info_s *cb_info = (camera_cb_info_s *)pc->cb_info; muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL; - pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL; - UNSET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_USER); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL; + pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL; + + UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } + int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER); + int ret = CAMERA_ERROR_NONE; + 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) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } @@ -3603,405 +3444,350 @@ int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_prev } if (callback == NULL) { - LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER); + LOGE("NULL callback"); return CAMERA_ERROR_INVALID_PARAMETER; } - int ret = CAMERA_ERROR_NONE; - - camera_cli_s *pc = (camera_cli_s *)camera; - muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB; - - LOGD("Enter, handle :%x", pc->remote_handle); + LOGD("Enter"); - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - sock_fd = pc->cb_info->fd; pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } + int camera_unset_media_packet_preview_cb(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL; - pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL; + pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL; + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } + int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data) { - if (camera == NULL || callback == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !callback) { + LOGE("NULL pointer %p %p", pc, callback); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } + + int camera_unset_state_changed_cb(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL; - pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL; + pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL; + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } + int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data) { - if (camera == NULL || callback == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !callback) { + LOGE("NULL pointer %p %p", pc, callback); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } + int camera_unset_interrupted_cb(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL; - pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL; + pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL; + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } + int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data) { - if (camera == NULL || callback == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !callback) { + LOGE("NULL pointer %p %p", pc, callback); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } + int camera_unset_focus_changed_cb(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL; - pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL; + pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL; + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } + int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data) { - if (camera == NULL || callback == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !callback) { + LOGE("NULL pointer %p %p", pc, callback); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } + int camera_unset_error_cb(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL; - pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL; + pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL; + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb , void *user_data) + +int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data) { - if (camera == NULL || foreach_cb == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !foreach_cb) { + LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb , void *user_data) + +int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data) { - if (camera == NULL || foreach_cb == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !foreach_cb) { + LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb , void *user_data) + +int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data) { - if (camera == NULL || foreach_cb == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !foreach_cb) { + LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb , void *user_data) +int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data) { - if (camera == NULL || foreach_cb == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !foreach_cb) { + LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height) { - if (camera == NULL || width == NULL || height == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_width = 0; + int get_height = 0; + + if (!pc || !pc->cb_info || !width || !height) { + LOGE("NULL pointer %p %p %p", pc, width, height); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_width; - int get_height; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_width, pc->cb_info->recv_msg); @@ -4009,845 +3795,843 @@ int camera_get_recommended_preview_resolution(camera_h camera, int *width, int * *width = get_width; *height = get_height; } + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_get_lens_orientation(camera_h camera, int *angle) { - if (camera == NULL || angle == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_angle = 0; + + if (!pc || !pc->cb_info || !angle) { + LOGE("NULL pointer %p %p", pc, angle); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_angle; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_angle, pc->cb_info->recv_msg); *angle = get_angle; } + LOGD("ret : 0x%x", ret); + return ret; } + int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } 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; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int set_mode = (int)mode; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int set_mode = (int)mode; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode); + + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_mode); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } + int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode) { - if (camera == NULL || mode == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_mode = 0; + + if (!pc || !pc->cb_info || !mode) { + LOGE("NULL pointer %p %p", pc, mode); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_mode; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_mode, pc->cb_info->recv_msg); *mode = (camera_attr_theater_mode_e)get_mode; } + LOGD("ret : 0x%x", ret); + return ret; } + int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data) { - if (camera == NULL || foreach_cb == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !foreach_cb) { + LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("Finish, return :%x", ret); return ret; } -int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps) + +int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int set_fps = (int)fps; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int set_fps = (int)fps; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_fps); + + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_fps); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_set_image_quality(camera_h camera, int quality) +int camera_attr_set_image_quality(camera_h camera, int quality) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, quality); + + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, quality); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps) + +int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps) { - if (camera == NULL || fps == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS; - int get_fps; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_fps = 0; + + if (!pc || !pc->cb_info || !fps) { + LOGE("NULL pointer %p %p", pc, fps); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_fps, pc->cb_info->recv_msg); *fps = (camera_attr_fps_e)get_fps; } + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_get_image_quality(camera_h camera, int *quality) { - if (camera == NULL || quality == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_quality = 0; + + if (!pc || !pc->cb_info || !quality) { + LOGE("NULL pointer %p %p", pc, quality); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_quality; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_quality, pc->cb_info->recv_msg); *quality = get_quality; } + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate) { - if (camera == NULL || bitrate == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_bitrate = 0; + + if (!pc || !pc->cb_info || !bitrate) { + LOGE("NULL pointer %p %p", pc, bitrate); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_bitrate; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_bitrate, pc->cb_info->recv_msg); *bitrate = get_bitrate; } + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int set_bitrate = bitrate; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int set_bitrate = bitrate; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_bitrate); + + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_bitrate); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval) { - if (camera == NULL || interval == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_gop_interval = 0; + + if (!pc || !pc->cb_info || !interval) { + LOGE("NULL pointer %p %p", pc, interval); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_gop_interval; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_gop_interval, pc->cb_info->recv_msg); *interval = get_gop_interval; } + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int set_gop_interval = interval; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int set_gop_interval = interval; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_gop_interval); + + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_set_zoom(camera_h camera, int zoom) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, zoom); + + CAMERA_MSG_PARAM_SET(param, INT, zoom); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode) + +int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } 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; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int set_mode = (int)mode; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int set_mode = (int)mode; + LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode); - LOGD("ret : 0x%x", ret); + + CAMERA_MSG_PARAM_SET(param, INT, set_mode); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + return ret; } + int camera_attr_set_af_area(camera_h camera, int x, int y) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA; - int sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, x, INT, y); + camera_msg_param param; + int value = 0; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + LOGD("Enter - %d,%d", x, y); + + value = (x << 16) | y; + CAMERA_MSG_PARAM_SET(param, INT, value); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_clear_af_area(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode) +int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - if (mode < CAMERA_ATTR_EXPOSURE_MODE_OFF || mode > CAMERA_ATTR_EXPOSURE_MODE_CUSTOM) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - 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; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode); + + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_mode); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_set_exposure(camera_h camera, int value) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, value); + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, value); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int set_iso = (int)iso; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int set_iso = (int)iso; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_iso); + + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_iso); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_set_brightness(camera_h camera, int level) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, level); + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, level); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_set_contrast(camera_h camera, int level) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, level); + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, level); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - if (wb < CAMERA_ATTR_WHITE_BALANCE_NONE || wb > CAMERA_ATTR_WHITE_BALANCE_CUSTOM) { - LOGE("invalid white balance %d", wb); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int set_whitebalance = (int)wb; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int set_whitebalance = (int)wb; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_whitebalance); + + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int set_effect = (int)effect; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int set_effect = (int)effect; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_effect); + + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_effect); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } 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; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int set_mode = (int)mode; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int set_mode = (int)mode; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode); + + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_mode); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_enable_tag(camera_h camera, bool enable) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int set_enable = (int)enable; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int set_enable = (int)enable; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable); + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_enable); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_set_tag_image_description(camera_h camera, const char *description) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - if (description == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + + if (!pc || !pc->cb_info || !description) { + LOGE("NULL pointer %p %p", pc, description); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, description); + + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, STRING, description); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation) +int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int set_orientation = (int)orientation; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int set_orientation = (int)orientation; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_orientation); + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_orientation); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_set_tag_software(camera_h camera, const char *software) +int camera_attr_set_tag_software(camera_h camera, const char *software) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - if (software == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + + if (!pc || !pc->cb_info || !software) { + LOGE("NULL pointer %p %p", pc, software); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, software); + + CAMERA_MSG_PARAM_SET(param, STRING, software); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude) +int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + double set_geotag[3] = {latitude, longitude, altitude}; + char *msg = NULL; + int length = 0; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - double set_geotag[3] = { latitude, longitude, altitude }; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send_array(api, sock_fd, pc->cb_info, ret, - set_geotag, sizeof(set_geotag), sizeof(double)); + LOGD("Enter"); + + length = sizeof(set_geotag) / sizeof(int) + \ + (sizeof(set_geotag) % sizeof(int) ? 1 : 0); + + msg = muse_core_msg_json_factory_new(api, + MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag, + NULL); + if (!msg) { + LOGE("msg creation failed: api %d", api); + return CAMERA_ERROR_OUT_OF_MEMORY; + } + + if (muse_core_ipc_send_msg(pc->cb_info->fd, msg) < 0) { + LOGE("message send failed"); + ret = CAMERA_ERROR_INVALID_OPERATION; + } else { + ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT); + } + + muse_core_msg_json_factory_free(msg); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_remove_geotag(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } 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; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int set_mode = (int)mode; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int set_mode = (int)mode; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode); + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_mode); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_get_zoom(camera_h camera, int *zoom) { - if (camera == NULL || zoom == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM; - int get_zoom; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_zoom = 0; + + if (!pc || !pc->cb_info || !zoom) { + LOGE("NULL pointer %p %p", pc, zoom); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_zoom, pc->cb_info->recv_msg); *zoom = get_zoom; } + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_get_zoom_range(camera_h camera, int *min, int *max) { - if (camera == NULL || min == NULL || max == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE; + int get_min = 0; + int get_max = 0; + + if (!pc || !pc->cb_info || !min || !max) { + LOGE("NULL pointer %p %p %p", pc, min, max); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE; - int get_min; - int get_max; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_min, pc->cb_info->recv_msg); @@ -4855,117 +4639,110 @@ int camera_attr_get_zoom_range(camera_h camera, int *min, int *max) *min = get_min; *max = get_max; } + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode) { - if (camera == NULL || mode == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE; + int get_mode = 0; + + if (!pc || !pc->cb_info || !mode) { + LOGE("NULL pointer %p %p", pc, mode); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE; - int get_mode; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_mode, pc->cb_info->recv_msg); *mode = (camera_attr_af_mode_e)get_mode; } + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode) { - if (camera == NULL || mode == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE; + int get_mode = 0; + + if (!pc || !pc->cb_info || !mode) { + LOGE("NULL pointer %p %p", pc, mode); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE; - int get_mode; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_mode, pc->cb_info->recv_msg); *mode = (camera_attr_exposure_mode_e)get_mode; } + LOGD("ret : 0x%x", ret); + return ret; } + int camera_attr_get_exposure(camera_h camera, int *value) { - if (camera == NULL || value == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE; + int get_value = 0; + + if (!pc || !pc->cb_info || !value) { + LOGE("NULL pointer %p %p", pc, value); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE; - int get_value; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_value, pc->cb_info->recv_msg); *value = get_value; } + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_get_exposure_range(camera_h camera, int *min, int *max) { - if (camera == NULL || min == NULL || max == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE; + int get_min = 0; + int get_max = 0; + + if (!pc || !pc->cb_info || !min || !max) { + LOGE("NULL pointer %p %p %p", pc, min, max); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE; - int get_min; - int get_max; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_min, pc->cb_info->recv_msg); @@ -4973,89 +4750,83 @@ int camera_attr_get_exposure_range(camera_h camera, int *min, int *max) *min = get_min; *max = get_max; } + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso) { - if (camera == NULL || iso == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO; + int get_iso = 0; + + if (!pc || !pc->cb_info || !iso) { + LOGE("NULL pointer %p %p", pc, iso); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO; - int get_iso; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_iso, pc->cb_info->recv_msg); *iso = (camera_attr_iso_e)get_iso; } + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_get_brightness(camera_h camera, int *level) +int camera_attr_get_brightness(camera_h camera, int *level) { - if (camera == NULL || level == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS; + int get_level = 0; + + if (!pc || !pc->cb_info || !level) { + LOGE("NULL pointer %p %p", pc, level); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS; - int get_level; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_level, pc->cb_info->recv_msg); *level = get_level; } + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_get_brightness_range(camera_h camera, int *min, int *max) { - if (camera == NULL || min == NULL || max == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE; + int get_min = 0; + int get_max = 0; + + if (!pc || !pc->cb_info || !min || !max) { + LOGE("NULL pointer %p %p %p", pc, min, max); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE; - int get_min; - int get_max; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_min, pc->cb_info->recv_msg); @@ -5063,60 +4834,56 @@ int camera_attr_get_brightness_range(camera_h camera, int *min, int *max) *min = get_min; *max = get_max; } + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_get_contrast(camera_h camera, int *level) +int camera_attr_get_contrast(camera_h camera, int *level) { - if (camera == NULL || level == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_level = 0; + + if (!pc || !pc->cb_info || !level) { + LOGE("NULL pointer %p %p", pc, level); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_level; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_level, pc->cb_info->recv_msg); *level = get_level; } + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_get_contrast_range(camera_h camera, int *min , int *max) +int camera_attr_get_contrast_range(camera_h camera, int *min, int *max) { - if (camera == NULL || min == NULL || max == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_min = 0; + int get_max = 0; + + if (!pc || !pc->cb_info || !min || !max) { + LOGE("NULL pointer %p %p %p", pc, min, max); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_min; - int get_max; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_min, pc->cb_info->recv_msg); @@ -5124,284 +4891,254 @@ int camera_attr_get_contrast_range(camera_h camera, int *min , int *max) *min = get_min; *max = get_max; } + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb) +int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb) { - if (camera == NULL || wb == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_wb = 0; + + if (!pc || !pc->cb_info || !wb) { + LOGE("NULL pointer %p %p", pc, wb); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_wb; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_wb, pc->cb_info->recv_msg); *wb = (camera_attr_whitebalance_e)get_wb; } + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect) { - if (camera == NULL || effect == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_effect = 0; + + if (!pc || !pc->cb_info || !effect) { + LOGE("NULL pointer %p %p", pc, effect); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_effect; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_effect, pc->cb_info->recv_msg); *effect = (camera_attr_effect_mode_e)get_effect; } + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode) +int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode) { - if (camera == NULL || mode == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_mode = 0; + + if (!pc || !pc->cb_info || !mode) { + LOGE("NULL pointer %p %p", pc, mode); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_mode; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_mode, pc->cb_info->recv_msg); *mode = (camera_attr_scene_mode_e)get_mode; } + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_is_enabled_tag(camera_h camera, bool *enable) +int camera_attr_is_enabled_tag(camera_h camera, bool *enable) { - if (camera == NULL || enable == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_enabled = 0; + + if (!pc || !pc->cb_info || !enable) { + LOGE("NULL pointer %p %p", pc, enable); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_enabled; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg); *enable = (bool)get_enabled; } + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_get_tag_image_description(camera_h camera, char **description) +int camera_attr_get_tag_image_description(camera_h camera, char **description) { - if (camera == NULL || description == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + char get_description[MUSE_CAMERA_MSG_MAX_LENGTH] = {0, }; + + if (!pc || !pc->cb_info || !description) { + LOGE("NULL pointer %p %p", pc, description); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - char get_description[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,}; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get_string(get_description, pc->cb_info->recv_msg); *description = strdup(get_description); } + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation) { - if (camera == NULL || orientation == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_orientation = 0; + + if (!pc || !pc->cb_info || !orientation) { + LOGE("NULL pointer %p %p", pc, orientation); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_orientation; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_orientation, pc->cb_info->recv_msg); *orientation = (camera_attr_tag_orientation_e)get_orientation; - LOGD("success, orientation : %d", *orientation); } + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_get_tag_software(camera_h camera, char **software) { - if (camera == NULL || software == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + char get_software[MUSE_CAMERA_MSG_MAX_LENGTH] = {0, }; + + if (!pc || !pc->cb_info || !software) { + LOGE("NULL pointer %p %p", pc, software); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - char get_software[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,}; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get_string(get_software, pc->cb_info->recv_msg); *software = strdup(get_software); } + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude) +int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude) { - if (camera == NULL || latitude == NULL || longitude == NULL || altitude == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG; - double get_geotag[3] = {0,}; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + double get_geotag[3] = {0.0, }; + + if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) { + LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); + LOGD("Enter"); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get_array(get_geotag, pc->cb_info->recv_msg); *latitude = get_geotag[0]; *longitude = get_geotag[1]; *altitude = get_geotag[2]; - - LOGD("ret : 0x%x", ret); - } else { - LOGE("Returned value is not valid : 0x%x", ret); } + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode) +int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode) { - if (camera == NULL || mode == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_mode = 0; + + if (!pc || !pc->cb_info || !mode) { + LOGE("NULL pointer %p %p", pc, mode); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_mode; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_mode, pc->cb_info->recv_msg); *mode = (camera_attr_flash_mode_e)get_mode; } + LOGD("ret : 0x%x", ret); + return ret; } @@ -5409,8 +5146,9 @@ int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode) int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state) { int sock_fd = -1; - char *sndMsg; + char *msg = NULL; int ret = CAMERA_ERROR_NONE; + int send_ret = 0; camera_cli_s *pc = NULL; int get_flash_state = 0; @@ -5419,547 +5157,525 @@ int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state) muse_core_api_module_e muse_module = MUSE_CAMERA; int device_type = (int)device; - if (state == NULL) { - LOGE("invalid pointer for state"); + if (!state) { + LOGE("NULL pointer"); return CAMERA_ERROR_INVALID_PARAMETER; } sock_fd = muse_core_client_new(); if (sock_fd < 0) { - LOGE("muse_core_client_new failed - returned fd %d", sock_fd); - ret = CAMERA_ERROR_INVALID_OPERATION; - goto Exit; + LOGE("muse_core_client_new failed"); + return CAMERA_ERROR_INVALID_OPERATION; } - sndMsg = muse_core_msg_json_factory_new(api, + msg = muse_core_msg_json_factory_new(api, MUSE_TYPE_INT, "module", muse_module, MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type, 0); + if (!msg) { + LOGE("msg failed"); + ret = CAMERA_ERROR_OUT_OF_MEMORY; + goto Exit; + } + + send_ret = muse_core_ipc_send_msg(sock_fd, msg); - muse_core_ipc_send_msg(sock_fd, sndMsg); - muse_core_msg_json_factory_free(sndMsg); + muse_core_msg_json_factory_free(msg); + msg = NULL; + + if (send_ret < 0) { + LOGE("send msg failed"); + ret = CAMERA_ERROR_INVALID_OPERATION; + goto Exit; + } pc = g_new0(camera_cli_s, 1); - if (pc == NULL) { - LOGE("camera_cli_s alloc failed"); + if (!pc) { + LOGE("handle alloc failed"); ret = CAMERA_ERROR_OUT_OF_MEMORY; goto Exit; } - pc->cb_info = _client_callback_new(sock_fd); - if (pc->cb_info == NULL) { + pc->cb_info = _camera_client_callback_new(sock_fd, false); + if (!pc->cb_info) { LOGE("cb_info alloc failed"); ret = CAMERA_ERROR_OUT_OF_MEMORY; goto Exit; } - ret = _client_wait_for_cb_return(api, pc->cb_info, CALLBACK_TIME_OUT); + sock_fd = -1; + + ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_flash_state, pc->cb_info->recv_msg); *state = (camera_flash_state_e)get_flash_state; } - LOGD("Flash state : %d\n", *state); + LOGD("Flash state : %d", *state); Exit: /* release resources */ if (pc) { - g_atomic_int_set(&pc->cb_info->msg_recv_running, 0); - _client_callback_destroy(pc->cb_info); - pc->cb_info = NULL; + if (pc->cb_info) { + _camera_client_callback_destroy(pc->cb_info); + pc->cb_info = NULL; + } + g_free(pc); pc = NULL; } + if (sock_fd > -1) { + muse_core_connection_close(sock_fd); + sock_fd = -1; + } + return ret; } int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data) { - if (camera == NULL || foreach_cb == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !foreach_cb) { + LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb , void *user_data) +int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data) { - if (camera == NULL || foreach_cb == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !foreach_cb) { + LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data) { - if (camera == NULL || foreach_cb == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !foreach_cb) { + LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb , void *user_data) +int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data) { - if (camera == NULL || foreach_cb == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !foreach_cb) { + LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb , void *user_data) +int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data) { - if (camera == NULL || foreach_cb == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !foreach_cb) { + LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb , void *user_data) +int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data) { - if (camera == NULL || foreach_cb == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !foreach_cb) { + LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb , void *user_data) +int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data) { - if (camera == NULL || foreach_cb == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE; - LOGD("Enter, handle :%x", pc->remote_handle); - - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info || !foreach_cb) { + LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb , void *user_data) +int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data) { - if (camera == NULL || foreach_cb == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + + if (!pc || !pc->cb_info || !foreach_cb) { + LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, handle :%x", pc->remote_handle); + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("Enter, handle :%x", pc->remote_handle); + return ret; } + int camera_attr_foreach_supported_fps_by_resolution(camera_h camera, int width, int height, camera_attr_supported_fps_cb foreach_cb, void *user_data) { - if (camera == NULL || foreach_cb == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int value = 0; + + if (!pc || !pc->cb_info || !foreach_cb) { + LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, handle :%x", pc->remote_handle); + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data; - muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height); + value = (width << 16) | height; + CAMERA_MSG_PARAM_SET(param, INT, value); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } + int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data) { - if (camera == NULL || foreach_cb == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + + if (!pc || !pc->cb_info || !foreach_cb) { + LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, handle :%x", pc->remote_handle); + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data) { - if (camera == NULL || foreach_cb == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + + if (!pc || !pc->cb_info || !foreach_cb) { + LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, handle :%x", pc->remote_handle); + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_set_stream_rotation(camera_h camera , camera_rotation_e rotation) +int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int set_rotation = (int)rotation; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int set_rotation = (int)rotation; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_rotation); + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_rotation); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_get_stream_rotation(camera_h camera , camera_rotation_e *rotation) +int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation) { - if (camera == NULL || rotation == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_rotation = 0; + + if (!pc || !pc->cb_info || !rotation) { + LOGE("NULL pointer %p %p", pc, rotation); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_rotation; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg); *rotation = (camera_rotation_e)get_rotation; } + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_set_stream_flip(camera_h camera , camera_flip_e flip) +int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int set_flip = (int)flip; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int set_flip = (int)flip; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_flip); + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_flip); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_get_stream_flip(camera_h camera , camera_flip_e *flip) +int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip) { - if (camera == NULL || flip == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_flip = 0; + + if (!pc || !pc->cb_info || !flip) { + LOGE("NULL pointer %p %p", pc, flip); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_flip; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_flip, pc->cb_info->recv_msg); *flip = (camera_flip_e)get_flip; } + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - 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; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int set_mode = (int)mode; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int set_mode = (int)mode; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode); + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_mode); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - if (mode == NULL) { - LOGE("INVALID_PARAMETER(0x%08x) - mode", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_mode = 0; + + if (!pc || !pc->cb_info || !mode) { + LOGE("NULL pointer %p %p", pc, mode); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_mode; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_mode, pc->cb_info->recv_msg); *mode = (camera_attr_hdr_mode_e)get_mode; } + LOGD("ret : 0x%x", ret); + return ret; } bool camera_attr_is_supported_hdr_capture(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return false; - } - 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; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return (bool)ret; } @@ -5969,33 +5685,28 @@ int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_pro int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB; - int sock_fd; - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER); + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - sock_fd = pc->cb_info->fd; + LOGD("Enter"); - LOGD("Enter, handle :%x", pc->remote_handle); + if (!camera_attr_is_supported_hdr_capture(camera)) { + LOGE("HDR not supported"); + return CAMERA_ERROR_NOT_SUPPORTED; + } - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + if (!callback) { + LOGE("NULL callback"); + return CAMERA_ERROR_INVALID_PARAMETER; + } - if (ret == CAMERA_ERROR_NONE) { - if (callback == NULL) { - LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback; + pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data; - pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback; - pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data; - } + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); LOGD("ret : 0x%x", ret); @@ -6005,378 +5716,342 @@ int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_pro int camera_attr_unset_hdr_capture_progress_cb(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, handle :%x", pc->remote_handle); - pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL; - pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL; + LOGD("Enter"); + + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL; + pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL; + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_enable_anti_shake(camera_h camera, bool enable) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - 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; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int set_enable = (int)enable; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int set_enable = (int)enable; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable); + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_enable); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } -int camera_attr_is_enabled_anti_shake(camera_h camera , bool *enabled) +int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - if (enabled == NULL) { - LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_enabled = 0; + + if (!pc || !pc->cb_info || !enabled) { + LOGE("NULL pointer %p %p", pc, enabled); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_enabled; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg); *enabled = (bool)get_enabled; } + LOGD("ret : 0x%x", ret); + return ret; } bool camera_attr_is_supported_anti_shake(camera_h camera) { - - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return false; - } - 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; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_enable_video_stabilization(camera_h camera, bool enable) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - 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; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int set_enable = (int)enable; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int set_enable = (int)enable; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable); + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_enable); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - if (enabled == NULL) { - LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_enabled = 0; + + if (!pc || !pc->cb_info || !enabled) { + LOGE("NULL pointer %p %p", pc, enabled); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_enabled; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg); *enabled = (bool)get_enabled; } + LOGD("ret : 0x%x", ret); + return ret; } bool camera_attr_is_supported_video_stabilization(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return false; - } - 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; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_enable_auto_contrast(camera_h camera, bool enable) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - 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; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int set_enable = (int)enable; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int set_enable = (int)enable; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable); + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_enable); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - if (enabled == NULL) { - LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + int get_enabled = 0; + + if (!pc || !pc->cb_info || !enabled) { + LOGE("NULL pointer %p %p", pc, enabled); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int get_enabled; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg); *enabled = (bool)get_enabled; } + LOGD("ret : 0x%x", ret); + return ret; } bool camera_attr_is_supported_auto_contrast(camera_h camera) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return false; - } - 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; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_disable_shutter_sound(camera_h camera, bool disable) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + camera_msg_param param; + int set_disable = (int)disable; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - int set_disable = (int)disable; - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_disable); + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_disable); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - + int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN; + camera_msg_param param; + int set_move_type = (int)move_type; + int value = 0; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - int ret = CAMERA_ERROR_NONE; - int sock_fd = pc->cb_info->fd; - int set_move_type = (int)move_type; - int set_pan_step = pan_step; - muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN; + LOGD("Enter"); + + value = (set_move_type << 16) | pan_step; + CAMERA_MSG_PARAM_SET(param, INT, value); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, set_move_type, INT, set_pan_step); LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_get_pan(camera_h camera, int *pan_step) { - if (camera == NULL || pan_step == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - + int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN; + int get_pan_step = 0; + + if (!pc || !pc->cb_info || !pan_step) { + LOGE("NULL pointer %p %p", pc, pan_step); return CAMERA_ERROR_INVALID_PARAMETER; } - int ret = CAMERA_ERROR_NONE; - int sock_fd = pc->cb_info->fd; - int get_pan_step; - muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN; + LOGD("Enter"); - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_pan_step, pc->cb_info->recv_msg); *pan_step = get_pan_step; } + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_get_pan_range(camera_h camera, int *min, int *max) { - if (camera == NULL || min == NULL || max == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - + int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE; + int get_min = 0; + int get_max = 0; + + if (!pc || !pc->cb_info || !min || !max) { + LOGE("NULL pointer %p %p", pc, min, max); return CAMERA_ERROR_INVALID_PARAMETER; } - int ret = CAMERA_ERROR_NONE; - int sock_fd = pc->cb_info->fd; - int get_min; - int get_max; - muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE; + LOGD("Enter"); - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_min, pc->cb_info->recv_msg); @@ -6384,88 +6059,83 @@ int camera_attr_get_pan_range(camera_h camera, int *min, int *max) *min = get_min; *max = get_max; } + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - + int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT; + camera_msg_param param; + int set_move_type = (int)move_type; + int value = 0; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - int ret = CAMERA_ERROR_NONE; - int sock_fd = pc->cb_info->fd; - int set_move_type = (int)move_type; - int set_tilt_step = tilt_step; - muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT; + LOGD("Enter"); + + value = (set_move_type << 16) | tilt_step; + CAMERA_MSG_PARAM_SET(param, INT, value); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, set_move_type, INT, set_tilt_step); LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_get_tilt(camera_h camera, int *tilt_step) { - if (camera == NULL || tilt_step == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - + int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT; + int get_tilt_step = 0; + + if (!pc || !pc->cb_info || !tilt_step) { + LOGE("NULL pointer %p %p", pc, tilt_step); return CAMERA_ERROR_INVALID_PARAMETER; } - int ret = CAMERA_ERROR_NONE; - int sock_fd = pc->cb_info->fd; - int get_tilt_step; - muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT; + LOGD("Enter"); - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_tilt_step, pc->cb_info->recv_msg); *tilt_step = get_tilt_step; } + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_get_tilt_range(camera_h camera, int *min, int *max) { - if (camera == NULL || min == NULL || max == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - + int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE; + int get_min = 0; + int get_max = 0; + + if (!pc || !pc->cb_info || !min || !max) { + LOGE("NULL pointer %p %p %p", pc, min, max); return CAMERA_ERROR_INVALID_PARAMETER; } - int ret = CAMERA_ERROR_NONE; - int sock_fd = pc->cb_info->fd; - int get_min; - int get_max; - muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE; + LOGD("Enter"); - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get(get_min, pc->cb_info->recv_msg); @@ -6473,81 +6143,77 @@ int camera_attr_get_tilt_range(camera_h camera, int *min, int *max) *min = get_min; *max = get_max; } + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - + int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE; + camera_msg_param param; + int set_ptz_type = (int)ptz_type; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - int ret = CAMERA_ERROR_NONE; - int sock_fd = pc->cb_info->fd; - int set_ptz_type = (int)ptz_type; - muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE; + LOGD("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); - LOGD("Enter, remote_handle : %x", pc->remote_handle); - muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_ptz_type); LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data) { - if (camera == NULL || foreach_cb == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE; - int sock_fd; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + + if (!pc || !pc->cb_info || !foreach_cb) { + LOGE("NULL pointer %p %p", pc, foreach_cb); return CAMERA_ERROR_INVALID_PARAMETER; } - sock_fd = pc->cb_info->fd; - LOGD("Enter, handle :%x", pc->remote_handle); + + LOGD("Enter"); + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb; pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data; - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + LOGD("ret : 0x%x", ret); + return ret; } int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height) { - if (camera == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - + int ret = CAMERA_ERROR_NONE; camera_cli_s *pc = (camera_cli_s *)camera; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA; + int set_display_roi_area[4] = {x, y, width, height}; + char *msg = NULL; + int length = 0; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); return CAMERA_ERROR_INVALID_PARAMETER; } - int ret = CAMERA_ERROR_NONE; - int sock_fd = pc->cb_info->fd; - int set_display_roi_area[4] = {x, y, width, height}; - muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA; - - LOGD("Enter, remote_handle : %x", pc->remote_handle); + LOGD("Enter"); #ifdef TIZEN_FEATURE_EVAS_RENDERER if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) { @@ -6564,8 +6230,25 @@ int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, i } #endif /* TIZEN_FEATURE_EVAS_RENDERER */ - muse_camera_msg_send_array(api, sock_fd, pc->cb_info, ret, - set_display_roi_area, sizeof(set_display_roi_area), sizeof(int)); + length = sizeof(set_display_roi_area) / sizeof(int) + \ + (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0); + + msg = muse_core_msg_json_factory_new(api, + MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area, + NULL); + if (!msg) { + LOGE("msg creation failed: api %d", api); + return CAMERA_ERROR_OUT_OF_MEMORY; + } + + if (muse_core_ipc_send_msg(pc->cb_info->fd, msg) < 0) { + LOGE("message send failed"); + ret = CAMERA_ERROR_INVALID_OPERATION; + } else { + ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT); + } + + muse_core_msg_json_factory_free(msg); LOGD("ret : 0x%x", ret); @@ -6575,38 +6258,29 @@ int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, i int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height) { - if (camera == NULL || x == NULL || y == NULL || width == NULL || height == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - camera_cli_s *pc = (camera_cli_s *)camera; - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - int ret = CAMERA_ERROR_NONE; - int sock_fd = pc->cb_info->fd; int get_display_roi_area[4] = {0,}; muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA; - LOGD("Enter, remote_handle : %x", pc->remote_handle); + if (!pc || !pc->cb_info || !x || !y || !width || !height) { + LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height); + return CAMERA_ERROR_INVALID_PARAMETER; + } - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); if (ret == CAMERA_ERROR_NONE) { muse_camera_msg_get_array(get_display_roi_area, pc->cb_info->recv_msg); - *x = get_display_roi_area[0]; *y = get_display_roi_area[1]; *width = get_display_roi_area[2]; *height = get_display_roi_area[3]; - - LOGD("ret : 0x%x", ret); - } else { - LOGE("Returned value is not valid : 0x%x", ret); } + LOGD("ret : 0x%x", ret); + return ret; } |