From ef4b87c0b88429e1bf68f847f7e8d25f9b08eedc Mon Sep 17 00:00:00 2001 From: Jeongmo Yang Date: Wed, 3 Feb 2021 14:58:37 +0900 Subject: [PATCH] Add new internal APIs for flash brightness [Version] 0.4.45 [Issue Type] New feature Change-Id: Ib0f5a19dfb8349caab7011c0732cf761ef1a17aa Signed-off-by: Jeongmo Yang --- include/camera_internal.h | 54 +++++++++++++++++++++++++++++ include/camera_private.h | 7 ++++ packaging/capi-media-camera.spec | 2 +- src/camera.c | 15 +++----- src/camera_internal.c | 74 ++++++++++++++++++++++++++++++++++++++++ test/camera_test.c | 9 +++++ 6 files changed, 149 insertions(+), 12 deletions(-) diff --git a/include/camera_internal.h b/include/camera_internal.h index 7049087..46a1aae 100644 --- a/include/camera_internal.h +++ b/include/camera_internal.h @@ -278,6 +278,60 @@ int camera_device_manager_add_device_list_changed_cb(camera_device_manager_h man int camera_device_manager_remove_device_list_changed_cb(camera_device_manager_h manager, int cb_id); /** + * @internal + * @brief Sets the brightness level of flash. + * @since_tizen 6.5 + * @remarks If the min value is greater than the max value from camera_attr_get_flash_brightness_range(), \n + * it means that this feature is not supported. + * @param[in] camera The handle to the camera + * @param[in] level The brightness level of flash + * @return @c 0 on success, otherwise a negative error value + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported + * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected + * @pre The camera state must be set to #CAMERA_STATE_CREATED or #CAMERA_STATE_PREVIEW. + * @see camera_attr_get_flash_brightness() + * @see camera_attr_get_flash_brightness_range() + */ +int camera_attr_set_flash_brightness(camera_h camera, int level); + +/** + * @internal + * @brief Gets the brightness level of flash. + * @since_tizen 6.5 + * @param[in] camera The handle to the camera + * @param[out] level The brightness level of flash + * @return @c 0 on success, otherwise a negative error value + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported + * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected + * @see camera_attr_set_flash_brightness() + * @see camera_attr_get_flash_brightness_range() + */ +int camera_attr_get_flash_brightness(camera_h camera, int *level); + +/** + * @internal + * @brief Gets the available brightness level of flash. + * @since_tizen 6.5 + * @remarks If the min value is greater than the max value, it means that this feature is not supported. + * @param[in] camera The handle to the camera + * @param[out] min The minimum brightness level of flash + * @param[out] max The maximum brightness level of flash + * @return @c 0 on success, otherwise a negative error value + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported + * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected + * @see camera_attr_set_flash_brightness() + * @see camera_attr_get_flash_brightness() + */ +int camera_attr_get_flash_brightness_range(camera_h camera, int *min, int *max); + +/** * @} */ #ifdef __cplusplus diff --git a/include/camera_private.h b/include/camera_private.h index e8da26f..e8a4509 100644 --- a/include/camera_private.h +++ b/include/camera_private.h @@ -242,6 +242,13 @@ int _camera_stop_evas_rendering(camera_h camera, bool keep_screen); int _camera_independent_request(int api, int device_type, const char *key, int *value); int _camera_set_display(camera_h camera, mm_display_type_e type, void *display); int _camera_create_private(camera_device_e device, bool is_network, camera_h *camera); +void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info, + int *ret, int timeout); +void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info, + int *ret, camera_msg_param *param, int timeout); +void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info, + int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout); +void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info); typedef bool (*camera_supported_cb_param1)(int param, void *user_data); typedef bool (*camera_supported_cb_param2)(int param1, int param2, void *user_data); diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec index 9992fff..37cba4c 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.44 +Version: 0.4.45 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/camera.c b/src/camera.c index e260a2b..19cb7a2 100644 --- a/src/camera.c +++ b/src/camera.c @@ -43,13 +43,6 @@ static GMutex g_cam_idle_event_lock; /* log level */ int g_mmcam_log_level = CAMERA_LOG_LEVEL_INFO; -static void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info, - int *ret, int timeout); -static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info, - int *ret, camera_msg_param *param, int timeout); -static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info, - int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout); -static void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info); static bool _camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle); static void _camera_release_imported_bo(tbm_bo *bo); static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream, @@ -674,7 +667,7 @@ _CB_RETURN_END: } -static void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info, +void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info, int *ret, int timeout) { int send_ret = 0; @@ -726,7 +719,7 @@ static void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info, } -static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info, +void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info, int *ret, camera_msg_param *param, int timeout) { int send_ret = 0; @@ -805,7 +798,7 @@ static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info, } -static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info, +void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info, int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout) { int func_ret = CAMERA_ERROR_NONE; @@ -864,7 +857,7 @@ _SEND_PARAM2_INT_DONE: } -static void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info) +void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info) { camera_msg_param param; diff --git a/src/camera_internal.c b/src/camera_internal.c index f909c3e..fed2c67 100644 --- a/src/camera_internal.c +++ b/src/camera_internal.c @@ -362,3 +362,77 @@ int camera_device_manager_remove_device_list_changed_cb(camera_device_manager_h return ret; } + + +int camera_attr_set_flash_brightness(camera_h camera, int level) +{ + int ret = CAMERA_ERROR_NONE; + camera_cli_s *pc = (camera_cli_s *)camera; + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_BRIGHTNESS; + camera_msg_param param; + + if (!pc || !pc->cb_info) { + CAM_LOG_ERROR("NULL handle"); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + CAM_LOG_INFO("Enter"); + + CAMERA_MSG_PARAM_SET(param, INT, level); + + _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT); + + CAM_LOG_INFO("ret : 0x%x", ret); + + return ret; +} + + +int camera_attr_get_flash_brightness(camera_h camera, int *level) +{ + int ret = CAMERA_ERROR_NONE; + camera_cli_s *pc = (camera_cli_s *)camera; + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_BRIGHTNESS; + + if (!pc || !pc->cb_info || !level) { + CAM_LOG_ERROR("NULL pointer %p %p", pc, level); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + CAM_LOG_INFO("Enter"); + + _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + + if (ret == CAMERA_ERROR_NONE) + *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_BRIGHTNESS]; + + CAM_LOG_INFO("ret : 0x%x", ret); + + return ret; +} + + +int camera_attr_get_flash_brightness_range(camera_h camera, int *min, int *max) +{ + int ret = CAMERA_ERROR_NONE; + camera_cli_s *pc = (camera_cli_s *)camera; + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_BRIGHTNESS_RANGE; + + if (!pc || !pc->cb_info || !min || !max) { + CAM_LOG_ERROR("NULL pointer %p %p %p", pc, min, max); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + CAM_LOG_INFO("Enter"); + + _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + + if (ret == CAMERA_ERROR_NONE) { + *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_FLASH_BRIGHTNESS_RANGE][0]; + *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_FLASH_BRIGHTNESS_RANGE][1]; + } + + CAM_LOG_INFO("ret : 0x%x", ret); + + return ret; +} diff --git a/test/camera_test.c b/test/camera_test.c index 3bfe894..9e4152e 100644 --- a/test/camera_test.c +++ b/test/camera_test.c @@ -808,6 +808,7 @@ static void print_menu() g_print("\t >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [etc.]\n"); g_print("\t 'z' Strobe (Flash) \n"); g_print("\t 'S' Strobe (Flash) state\n"); + g_print("\t 'G' Strobe (Flash) brightness\n"); g_print("\t 'x' Capture mode (Still/Multishot/HDR)\n"); g_print("\t 'l' Face detection \n"); g_print("\t 'k' Anti-handshake \n"); @@ -1246,6 +1247,14 @@ static void setting_menu(gchar buf) else g_print("* Error : %d\n", err); break; + case 'G': /* Setting > flash brightness */ + g_print("*Flash brightness !\n"); + camera_attr_get_flash_brightness_range(hcamcorder->camera, &min, &max); + g_print("\n Select flash brightness min(%d) - max(%d) > ", min, max); + err = scanf("%d", &idx); + flush_stdin(); + bret = camera_attr_set_flash_brightness(hcamcorder->camera, idx); + break; case 'x': /* Setting > Capture mode ,Muitishot? */ g_print("*Select Capture mode!\n"); g_print(" \n\t1. Stillshot mode\n\t2. Multishot mode\n\t3. HDR capture\n"); -- 2.7.4