Add new internal APIs for flash brightness 19/252919/2 accepted/tizen/unified/20210208.061727 submit/tizen/20210204.050939
authorJeongmo Yang <jm80.yang@samsung.com>
Wed, 3 Feb 2021 05:58:37 +0000 (14:58 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Wed, 3 Feb 2021 09:27:51 +0000 (18:27 +0900)
[Version] 0.4.45
[Issue Type] New feature

Change-Id: Ib0f5a19dfb8349caab7011c0732cf761ef1a17aa
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
include/camera_internal.h
include/camera_private.h
packaging/capi-media-camera.spec
src/camera.c
src/camera_internal.c
test/camera_test.c

index 7049087..46a1aae 100644 (file)
@@ -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
index e8da26f..e8a4509 100644 (file)
@@ -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);
index 9992fff..37cba4c 100644 (file)
@@ -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
index e260a2b..19cb7a2 100644 (file)
@@ -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;
 
index f909c3e..fed2c67 100644 (file)
@@ -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, &param, 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;
+}
index 3bfe894..9e4152e 100644 (file)
@@ -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");