diff options
author | Jeongmo Yang <jm80.yang@samsung.com> | 2022-06-22 16:32:15 +0900 |
---|---|---|
committer | Jeongmo Yang <jm80.yang@samsung.com> | 2022-06-22 19:05:39 +0900 |
commit | a2cdc6b7acf44a27c3c42f076536270248680d3a (patch) | |
tree | 870f75ef06e3d6691677dbba0204e97e66acdab7 | |
parent | 4f924e50fb4b49aacb61efbd6c8358516e6f586b (diff) | |
download | camera-a2cdc6b7acf44a27c3c42f076536270248680d3a.tar.gz camera-a2cdc6b7acf44a27c3c42f076536270248680d3a.tar.bz2 camera-a2cdc6b7acf44a27c3c42f076536270248680d3a.zip |
Remove duplicated code.(phase#1)
[Version] 0.4.81
[Issue Type] SAM Improvement
Change-Id: I76b561f0bdb09c1db00f05556d79412c4a28f9e6
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
-rw-r--r-- | packaging/capi-media-camera.spec | 2 | ||||
-rw-r--r-- | src/camera.c | 219 |
2 files changed, 31 insertions, 190 deletions
diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec index 90d2614..274affb 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.4.80 +Version: 0.4.81 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/camera.c b/src/camera.c index 73908ee..bc47060 100644 --- a/src/camera.c +++ b/src/camera.c @@ -687,6 +687,27 @@ static void __camera_release_imported_bo(tbm_bo *bo) } +static bool __is_supported_common(camera_h camera, muse_camera_api_e api) +{ + int ret = CAMERA_ERROR_NONE; + camera_cli_s *pc = (camera_cli_s *)camera; + + if (!pc || !pc->cb_info) { + CAM_LOG_ERROR("api[%d] NULL handle[%p]", api, pc); + set_last_result(CAMERA_ERROR_INVALID_PARAMETER); + return false; + } + + CAM_LOG_INFO("Enter - api[%d]", api); + + _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + + CAM_LOG_INFO("Leave - api[%d], ret[%d]", api, ret); + + return (bool)ret; +} + + 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; @@ -2849,27 +2870,7 @@ int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, came bool camera_is_supported_continuous_capture(camera_h camera) { - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; - muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE; - - if (!pc || !pc->cb_info) { - CAM_LOG_ERROR("NULL handle[%p]", pc); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - CAM_LOG_INFO("Enter"); - - _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); - - if (ret < 0) { - CAM_LOG_ERROR("error is occurred 0x%x", ret); - ret = false; - } - - CAM_LOG_INFO("ret : %d", ret); - - return (bool)ret; + return __is_supported_common(camera, MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE); } @@ -2928,105 +2929,25 @@ int camera_stop_continuous_capture(camera_h camera) bool camera_is_supported_face_detection(camera_h camera) { - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; - muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION; - - if (!pc || !pc->cb_info) { - CAM_LOG_ERROR("NULL handle[%p]", pc); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - CAM_LOG_INFO("Enter"); - - _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); - - if (ret < 0) { - CAM_LOG_ERROR("error is occurred 0x%x", ret); - ret = false; - } - - CAM_LOG_INFO("ret : %d", ret); - - return (bool)ret; + return __is_supported_common(camera, MUSE_CAMERA_API_SUPPORT_FACE_DETECTION); } bool camera_is_supported_zero_shutter_lag(camera_h camera) { - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; - muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG; - - if (!pc || !pc->cb_info) { - CAM_LOG_ERROR("NULL handle[%p]", pc); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - CAM_LOG_INFO("Enter"); - - _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); - - if (ret < 0) { - CAM_LOG_ERROR("error is occurred 0x%x", ret); - ret = false; - } - - CAM_LOG_INFO("ret : %d", ret); - - return (bool)ret; + return __is_supported_common(camera, MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG); } bool camera_is_supported_media_packet_preview_cb(camera_h camera) { - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; - muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB; - - if (!pc || !pc->cb_info) { - CAM_LOG_ERROR("NULL handle[%p]", pc); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - CAM_LOG_INFO("Enter"); - - _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); - - if (ret < 0) { - CAM_LOG_ERROR("error is occurred 0x%x", ret); - ret = false; - } - - CAM_LOG_INFO("ret : %d", ret); - - return (bool)ret; + return __is_supported_common(camera, MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB); } bool camera_is_supported_extra_preview(camera_h camera) { - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; - muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_EXTRA_PREVIEW; - - if (!pc || !pc->cb_info) { - CAM_LOG_ERROR("NULL handle[%p]", pc); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - CAM_LOG_INFO("Enter"); - - _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); - - if (ret < 0) { - CAM_LOG_ERROR("error is occurred 0x%x", ret); - ret = false; - } - - CAM_LOG_INFO("ret : %d", ret); - - return (bool)ret; + return __is_supported_common(camera, MUSE_CAMERA_API_SUPPORT_EXTRA_PREVIEW); } @@ -6126,27 +6047,7 @@ int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode) bool camera_attr_is_supported_hdr_capture(camera_h camera) { - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; - muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE; - - if (!pc || !pc->cb_info) { - CAM_LOG_ERROR("NULL handle[%p]", pc); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - CAM_LOG_INFO("Enter"); - - _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); - - if (ret < 0) { - CAM_LOG_ERROR("error is occurred 0x%x", ret); - ret = false; - } - - CAM_LOG_INFO("ret : %d", ret); - - return (bool)ret; + return __is_supported_common(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE); } @@ -6271,27 +6172,7 @@ int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled) bool camera_attr_is_supported_anti_shake(camera_h camera) { - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; - muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE; - - if (!pc || !pc->cb_info) { - CAM_LOG_ERROR("NULL handle[%p]", pc); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - CAM_LOG_INFO("Enter"); - - _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); - - if (ret < 0) { - CAM_LOG_ERROR("error is occurred 0x%x", ret); - ret = false; - } - - CAM_LOG_INFO("ret : %d", ret); - - return (bool)ret; + return __is_supported_common(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE); } @@ -6346,27 +6227,7 @@ int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled) bool camera_attr_is_supported_video_stabilization(camera_h camera) { - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; - muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION; - - if (!pc || !pc->cb_info) { - CAM_LOG_ERROR("NULL handle[%p]", pc); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - CAM_LOG_INFO("Enter"); - - _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); - - if (ret < 0) { - CAM_LOG_ERROR("error is occurred 0x%x", ret); - ret = false; - } - - CAM_LOG_INFO("ret : %d", ret); - - return (bool)ret; + return __is_supported_common(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION); } @@ -6421,27 +6282,7 @@ int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled) bool camera_attr_is_supported_auto_contrast(camera_h camera) { - int ret = CAMERA_ERROR_NONE; - camera_cli_s *pc = (camera_cli_s *)camera; - muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST; - - if (!pc || !pc->cb_info) { - CAM_LOG_ERROR("NULL handle[%p]", pc); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - CAM_LOG_INFO("Enter"); - - _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); - - if (ret < 0) { - CAM_LOG_ERROR("error is occurred 0x%x", ret); - ret = false; - } - - CAM_LOG_INFO("ret : %d", ret); - - return (bool)ret; + return __is_supported_common(camera, MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST); } |