From: Jeongmo Yang Date: Wed, 20 Dec 2017 08:26:27 +0000 (+0900) Subject: [ACR-1130] Add new enum and APIs X-Git-Tag: accepted/tizen/unified/20180109.172734~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F71%2F164671%2F2;p=platform%2Fcore%2Fapi%2Fcamera.git [ACR-1130] Add new enum and APIs This commit can support maximum 10 cameras in a target, and new attribute setting(hue level). [Version] 0.4.2 [Profile] Common [Issue Type] Update [Dependency module] N/A Change-Id: I675adab79b60d13a402ccceeea34c5df14b707ee Signed-off-by: Jeongmo Yang --- diff --git a/include/camera.h b/include/camera.h index a221fa1..bb70732 100644 --- a/include/camera.h +++ b/include/camera.h @@ -89,7 +89,15 @@ typedef enum { */ typedef enum { CAMERA_DEVICE_CAMERA0 = 0, /**< Primary camera */ - CAMERA_DEVICE_CAMERA1 /**< Secondary camera */ + CAMERA_DEVICE_CAMERA1, /**< Secondary camera */ + CAMERA_DEVICE_CAMERA2, /**< Third camera (Since 5.0) */ + CAMERA_DEVICE_CAMERA3, /**< 4th camera (Since 5.0) */ + CAMERA_DEVICE_CAMERA4, /**< 5th camera (Since 5.0) */ + CAMERA_DEVICE_CAMERA5, /**< 6th camera (Since 5.0) */ + CAMERA_DEVICE_CAMERA6, /**< 7th camera (Since 5.0) */ + CAMERA_DEVICE_CAMERA7, /**< 8th camera (Since 5.0) */ + CAMERA_DEVICE_CAMERA8, /**< 9th camera (Since 5.0) */ + CAMERA_DEVICE_CAMERA9 /**< 10th camera (Since 5.0) */ } camera_device_e; /** @@ -2891,6 +2899,50 @@ int camera_attr_get_contrast(camera_h camera, int *level); int camera_attr_get_contrast_range(camera_h camera, int *min, int *max); /** + * @brief Sets the hue level. + * @since_tizen 5.0 + * @param[in] camera The handle to the camera + * @param[in] level The hue level + * @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 camera_attr_get_hue() + * @see camera_attr_get_hue_range() + */ +int camera_attr_set_hue(camera_h camera, int level); + +/** + * @brief Gets the hue level. + * @since_tizen 5.0 + * @param[in] camera The handle to the camera + * @param[out] level The hue level + * @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 camera_attr_set_hue() + * @see camera_attr_get_hue_range() + */ +int camera_attr_get_hue(camera_h camera, int *level); + +/** + * @brief Gets the available hue level. + * @since_tizen 5.0 + * @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 hue level + * @param[out] max The maximum hue level + * @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 camera_attr_set_hue() + * @see camera_attr_get_hue() + */ +int camera_attr_get_hue_range(camera_h camera, int *min, int *max); + +/** * @brief Sets the white balance mode. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] camera The handle to the camera diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec index 9666cfb..7cd8b0d 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.1 +Version: 0.4.2 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/camera.c b/src/camera.c index 8e20932..9dbf13f 100644 --- a/src/camera.c +++ b/src/camera.c @@ -4598,6 +4598,30 @@ int camera_attr_set_contrast(camera_h camera, int level) } +int camera_attr_set_hue(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_HUE; + camera_msg_param param; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + 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) { int ret = CAMERA_ERROR_NONE; @@ -5143,6 +5167,57 @@ int camera_attr_get_contrast_range(camera_h camera, int *min, int *max) } +int camera_attr_get_hue(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_HUE; + + if (!pc || !pc->cb_info || !level) { + LOGE("NULL pointer %p %p", pc, level); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + + if (ret == CAMERA_ERROR_NONE) + *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE]; + + LOGD("ret : 0x%x", ret); + + return ret; +} + + +int camera_attr_get_hue_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_HUE_RANGE; + + if (!pc || !pc->cb_info || !min || !max) { + LOGE("NULL pointer %p %p %p", pc, min, max); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + LOGD("Enter"); + + _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + + if (ret == CAMERA_ERROR_NONE) { + *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0]; + *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1]; + LOGD("min %d, max %d", *min, *max); + } + + LOGD("ret : 0x%x", ret); + + return ret; +} + + int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb) { int ret = CAMERA_ERROR_NONE; diff --git a/test/camera_test.c b/test/camera_test.c index 95d5b80..9674880 100644 --- a/test/camera_test.c +++ b/test/camera_test.c @@ -678,11 +678,10 @@ static void print_menu() g_print("\n\t=======================================\n"); g_print("\t CAMERA_TESTSUITE\n"); g_print("\t=======================================\n"); - g_print("\t '1' Video Capture - Front Camera\n"); - g_print("\t '2' Video Capture - Rear Camera\n"); - g_print("\t '3' Add camera device state changed callback\n"); - g_print("\t '4' Remove camera device state changed callback\n"); - g_print("\t '5' Get camera device state\n"); + g_print("\t '1' Video Capture\n"); + g_print("\t '2' Add camera device state changed callback\n"); + g_print("\t '3' Remove camera device state changed callback\n"); + g_print("\t '4' Get camera device state\n"); g_print("\t 'q' Exit\n"); g_print("\t=======================================\n"); @@ -699,7 +698,7 @@ static void print_menu() g_print("\t '1' Stillshot test\n"); g_print("\t '2' Multishot test\n"); g_print("\t '3' Setting\n"); - g_print("\t '4' Change device (Rear <-> Front)\n"); + g_print("\t '4' Change device (CAMERA0 <-> CAMERA1)\n"); g_print("\t '5' Add preview callback\n"); g_print("\t '6' Remove preview callback\n"); g_print("\t 'b' back\n"); @@ -733,6 +732,7 @@ static void print_menu() g_print("\t 'Y' Flip display \n"); g_print("\t 'g' Brightness \n"); g_print("\t 'c' Contrast \n"); + g_print("\t 'h' Hue \n"); g_print("\t 'w' White balance \n"); g_print("\t 't' Color tone \n"); g_print("\t 'd' WDR \n"); @@ -792,7 +792,7 @@ static void main_menu(gchar buf) case '3': /* Setting */ hcamcorder->menu_state = MENU_STATE_SETTING; break; - case '4': /* Change device (Rear <-> Front) */ + case '4': /* Change device (CAMERA0 <-> CAMERA1) */ camera_set_display_reuse_hint(hcamcorder->camera, true); camera_stop_preview(hcamcorder->camera); @@ -1092,7 +1092,7 @@ static void setting_menu(gchar buf) g_print("*Brightness !\n"); camera_attr_get_brightness_range(hcamcorder->camera, &min, &max); flush_stdin(); - g_print("\n Select brightness min (%d) -max(%d)", min, max); + g_print("\n Select brightness min (%d) -max(%d)", min, max); err = scanf("%d", &idx); bret = camera_attr_set_brightness(hcamcorder->camera, idx); break; @@ -1100,10 +1100,22 @@ static void setting_menu(gchar buf) g_print("*Contrast !\n"); camera_attr_get_contrast_range(hcamcorder->camera, &min, &max); flush_stdin(); - g_print("\n Select Contrast min(%d)-max(%d)", min, max); + g_print("\n Select Contrast min(%d)-max(%d)", min, max); err = scanf("%d", &idx); bret = camera_attr_set_contrast(hcamcorder->camera, idx); break; + case 'h': /* Setting > Hue */ + g_print("*Hue !\n"); + camera_attr_get_hue_range(hcamcorder->camera, &min, &max); + if (max >= min) { + flush_stdin(); + g_print("\n Select Hue min(%d)-max(%d)", min, max); + err = scanf("%d", &idx); + bret = camera_attr_set_hue(hcamcorder->camera, idx); + } else { + g_print("\n Hue is not supported (%d,%d)\n", min, max); + } + break; case 'w': /* Setting > White balance */ g_print("*White balance !\n"); flush_stdin(); @@ -1376,22 +1388,37 @@ static gboolean mode_change(gchar buf) { int err = 0; camera_device_state_e device_state = CAMERA_DEVICE_STATE_NULL; + char camera_type = '\0'; char display_type = '\0'; bool check = FALSE; switch (buf) { case '1': - hcamcorder->type = cam_info = CAMERA_DEVICE_CAMERA1; + while (1) { + g_print("\n\tEnter the Camera Type[0 ~ 9]\n"); + + err = scanf("%c", &camera_type); + if (err == EOF) { + g_print("\t!!!read input error!!!\n"); + continue; + } + + if (camera_type < '0' || camera_type > '9') { + g_print("\t Invalid camera type(%c)\n", camera_type); + continue; + } + + hcamcorder->type = cam_info = camera_type - '0'; + + break; + } break; case '2': - hcamcorder->type = cam_info = CAMERA_DEVICE_CAMERA0; - break; - case '3': err = camera_add_device_state_changed_cb(_camera_device_state_changed_cb, NULL, &g_camera_device_changed_cb_id); g_print("add result 0x%x - cb id %d\n", err, g_camera_device_changed_cb_id); return FALSE; - case '4': + case '3': if (g_camera_device_changed_cb_id > 0) { err = camera_remove_device_state_changed_cb(g_camera_device_changed_cb_id); g_camera_device_changed_cb_id = 0; @@ -1400,7 +1427,7 @@ static gboolean mode_change(gchar buf) g_print("invalid callback id %d\n", g_camera_device_changed_cb_id); } return FALSE; - case '5': + case '4': err = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &device_state); g_print("get result 0x%x - state %d\n", err, device_state); return FALSE;