Add new APIs for flash brightness 14/252914/1 accepted/tizen/unified/20210208.061718 submit/tizen/20210204.050939
authorJeongmo Yang <jm80.yang@samsung.com>
Wed, 3 Feb 2021 05:57:06 +0000 (14:57 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Wed, 3 Feb 2021 05:57:35 +0000 (14:57 +0900)
[Version] 0.3.39
[Issue Type] New feature

Change-Id: Ibe4342b440d0bdb6cfcc779699f8f60262e79ad4
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
legacy/include/legacy_camera.h
legacy/src/legacy_camera.c
muse/include/muse_camera.h
muse/src/muse_camera_dispatcher.c
packaging/mmsvc-camera.spec

index c0ac011..00499e3 100644 (file)
@@ -2646,6 +2646,50 @@ int legacy_camera_attr_get_brightness(camera_h camera, int *level);
 int legacy_camera_attr_get_brightness_range(camera_h camera, int *min, int *max);
 
 /**
+ * @brief Sets the brightness level of flash.
+ * @since_tizen 6.5
+ * @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_NOT_SUPPORTED The feature is not supported
+ * @see legacy_camera_attr_get_flash_brightness()
+ * @see legacy_camera_attr_get_flash_brightness_range()
+ */
+int legacy_camera_attr_set_flash_brightness(camera_h camera, int level);
+
+/**
+ * @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
+ * @see legacy_camera_attr_set_flash_brightness()
+ * @see legacy_camera_attr_get_flash_brightness_range()
+ */
+int legacy_camera_attr_get_flash_brightness(camera_h camera, int *level);
+
+/**
+ * @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
+ * @see legacy_camera_attr_set_flash_brightness()
+ * @see legacy_camera_attr_get_flash_brightness()
+ */
+int legacy_camera_attr_get_flash_brightness_range(camera_h camera, int *min, int *max);
+
+/**
  * @brief Sets the contrast level.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  * @param[in] camera The handle to the camera
index 0fd7e80..2a34a60 100644 (file)
@@ -4176,3 +4176,51 @@ int legacy_camera_get_platform_privilege(camera_h camera, const char **platform_
 
        return __convert_camera_error_code(__func__, ret);
 }
+
+
+int legacy_camera_attr_set_flash_brightness(camera_h camera, int level)
+{
+       int ret = MM_ERROR_NONE;
+       camera_s *handle = (camera_s *)camera;
+
+       camera_return_val_if_fail(handle, CAMERA_ERROR_INVALID_PARAMETER);
+
+       ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
+               MMCAM_STROBE_BRIGHTNESS, level,
+               NULL);
+
+       return __convert_camera_error_code(__func__, ret);
+}
+
+
+int legacy_camera_attr_get_flash_brightness(camera_h camera, int *level)
+{
+       int ret = MM_ERROR_NONE;
+       camera_s *handle = (camera_s *)camera;
+
+       camera_return_val_if_fail(handle && level, CAMERA_ERROR_INVALID_PARAMETER);
+
+       ret = mm_camcorder_get_attributes(handle->mm_handle, NULL,
+               MMCAM_STROBE_BRIGHTNESS, level,
+               NULL);
+
+       return __convert_camera_error_code(__func__, ret);
+}
+
+
+int legacy_camera_attr_get_flash_brightness_range(camera_h camera, int *min, int *max)
+{
+       int ret = MM_ERROR_NONE;
+       camera_s *handle = (camera_s *)camera;
+       MMCamAttrsInfo ainfo;
+
+       camera_return_val_if_fail(handle && min && max, CAMERA_ERROR_INVALID_PARAMETER);
+
+       ret = mm_camcorder_get_attribute_info(handle->mm_handle, MMCAM_STROBE_BRIGHTNESS, &ainfo);
+       if (ret == MM_ERROR_NONE) {
+               *min = ainfo.int_range.min;
+               *max = ainfo.int_range.max;
+       }
+
+       return __convert_camera_error_code(__func__, ret);
+}
index a50c299..18c3ff8 100644 (file)
@@ -190,7 +190,9 @@ typedef enum {
        MUSE_CAMERA_API_ATTR_SET_HUE,
        MUSE_CAMERA_API_ATTR_GET_HUE,
        MUSE_CAMERA_API_ATTR_GET_HUE_RANGE,
-
+       MUSE_CAMERA_API_ATTR_SET_FLASH_BRIGHTNESS,
+       MUSE_CAMERA_API_ATTR_GET_FLASH_BRIGHTNESS,
+       MUSE_CAMERA_API_ATTR_GET_FLASH_BRIGHTNESS_RANGE,
        MUSE_CAMERA_API_MAX
 } muse_camera_api_e;
 
@@ -306,6 +308,7 @@ typedef enum {
        MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE,
        MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL,
        MUSE_CAMERA_GET_INT_HUE,
+       MUSE_CAMERA_GET_INT_FLASH_BRIGHTNESS,
        MUSE_CAMERA_GET_INT_NUM
 } muse_camera_get_int_e;
 
@@ -320,6 +323,7 @@ typedef enum {
        MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE,
        MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE,
        MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE,
+       MUSE_CAMERA_GET_INT_PAIR_FLASH_BRIGHTNESS_RANGE,
        MUSE_CAMERA_GET_INT_PAIR_NUM
 } muse_camera_get_int_pair_e;
 
index 7aea81c..0a09d76 100644 (file)
@@ -5091,6 +5091,77 @@ int camera_dispatcher_get_device_state(muse_module_h module)
        return MUSE_CAMERA_ERROR_NONE;
 }
 
+int camera_dispatcher_attr_set_flash_brightness(muse_module_h module)
+{
+       int ret = CAMERA_ERROR_NONE;
+       muse_camera_handle_s *muse_camera = NULL;
+       int level;
+       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_BRIGHTNESS;
+       muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
+
+       muse_camera = (muse_camera_handle_s *)muse_server_ipc_get_handle(module);
+
+       muse_camera_msg_get(level, muse_server_module_get_msg(module));
+
+       CAM_LOG_INFO("handle[%p], level[%d]", muse_camera, level);
+
+       ret = legacy_camera_attr_set_flash_brightness(muse_camera->camera_handle, level);
+
+       CAM_LOG_INFO("ret[0x%x]", ret);
+
+       muse_camera_msg_return(api, class, ret, module);
+
+       return MUSE_CAMERA_ERROR_NONE;
+}
+
+int camera_dispatcher_attr_get_flash_brightness(muse_module_h module)
+{
+       int ret = CAMERA_ERROR_NONE;
+       muse_camera_handle_s *muse_camera = NULL;
+       int get_value = 0;
+       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_BRIGHTNESS;
+       muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
+
+       muse_camera = (muse_camera_handle_s *)muse_server_ipc_get_handle(module);
+
+       CAM_LOG_INFO("handle[%p]", muse_camera);
+
+       ret = legacy_camera_attr_get_flash_brightness(muse_camera->camera_handle, &get_value);
+       if (ret == CAMERA_ERROR_NONE) {
+               muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
+                       MUSE_CAMERA_GET_INT_FLASH_BRIGHTNESS, "get_value", get_value, NULL);
+       } else {
+               muse_camera_msg_return(api, class, ret, module);
+       }
+
+       return MUSE_CAMERA_ERROR_NONE;
+}
+
+
+int camera_dispatcher_attr_get_flash_brightness_range(muse_module_h module)
+{
+       int ret = CAMERA_ERROR_NONE;
+       muse_camera_handle_s *muse_camera = NULL;
+       int get_value0 = 0;
+       int get_value1 = 0;
+       muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_BRIGHTNESS_RANGE;
+       muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
+       muse_camera_get_type_e get_type = MUSE_CAMERA_GET_TYPE_INT_PAIR;
+       muse_camera_get_int_pair_e index = MUSE_CAMERA_GET_INT_PAIR_FLASH_BRIGHTNESS_RANGE;
+
+       muse_camera = (muse_camera_handle_s *)muse_server_ipc_get_handle(module);
+
+       CAM_LOG_INFO("handle[%p]", muse_camera);
+
+       ret = legacy_camera_attr_get_flash_brightness_range(muse_camera->camera_handle, &get_value0, &get_value1);
+       if (ret == CAMERA_ERROR_NONE)
+               muse_camera_msg_return2(api, class, ret, module, get_type, index, get_value0, get_value1);
+       else
+               muse_camera_msg_return(api, class, ret, module);
+
+       return MUSE_CAMERA_ERROR_NONE;
+}
+
 
 static tbm_bo __camera_normal_buffer_bo_new(MMCamcorderVideoStreamDataType *stream, tbm_bufmgr bufmgr)
 {
@@ -5427,11 +5498,14 @@ int (*dispatcher[MUSE_CAMERA_API_MAX]) (muse_module_h module) = {
        camera_dispatcher_get_display_reuse_hint, /* MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT */
        camera_dispatcher_change_device, /* MUSE_CAMERA_API_CHANGE_DEVICE */
        camera_dispatcher_get_device_state, /* MUSE_CAMERA_API_GET_DEVICE_STATE */
-       camera_dispatcher_set_interrupt_started_cb, /* MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB, */
-       camera_dispatcher_unset_interrupt_started_cb, /* MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB, */
-       camera_dispatcher_attr_set_hue, /* MUSE_CAMERA_API_ATTR_SET_HUE, */
-       camera_dispatcher_attr_get_hue, /* MUSE_CAMERA_API_ATTR_GET_HUE, */
-       camera_dispatcher_attr_get_hue_range /* MUSE_CAMERA_API_ATTR_GET_HUE_RANGE, */
+       camera_dispatcher_set_interrupt_started_cb, /* MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB */
+       camera_dispatcher_unset_interrupt_started_cb, /* MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB */
+       camera_dispatcher_attr_set_hue, /* MUSE_CAMERA_API_ATTR_SET_HUE */
+       camera_dispatcher_attr_get_hue, /* MUSE_CAMERA_API_ATTR_GET_HUE */
+       camera_dispatcher_attr_get_hue_range, /* MUSE_CAMERA_API_ATTR_GET_HUE_RANGE */
+       camera_dispatcher_attr_set_flash_brightness, /* MUSE_CAMERA_API_ATTR_SET_FLASH_BRIGHTNESS */
+       camera_dispatcher_attr_get_flash_brightness, /* MUSE_CAMERA_API_ATTR_GET_FLASH_BRIGHTNESS */
+       camera_dispatcher_attr_get_flash_brightness_range /* MUSE_CAMERA_API_ATTR_GET_FLASH_BRIGHTNESS_RANGE */
 };
 
 
index 3d2937e..a658581 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mmsvc-camera
 Summary:    A Camera module for muse server
-Version:    0.3.38
+Version:    0.3.39
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0