From 69905b6ff7e178fedc56718ad1872746293b031b Mon Sep 17 00:00:00 2001 From: "haesu.gwon" Date: Fri, 15 Jan 2016 17:14:27 +0900 Subject: [PATCH] [Release version 0.2.42] Add New APIs 1. camera_attr_get_flash_state 2. camera_attr_get_encoded_preview_bitrate 3. camera_attr_set_encoded_preview_bitrate 4. camera_attr_get_encoded_preview_gop_interval 5. camera_attr_set_encoded_preview_gop_interval Change-Id: Ifc277a63fff0f6956c6a40c9fed8f2a75f81be37 Signed-off-by: haesu.gwon --- include/camera.h | 81 ++++++++++++++++++ packaging/capi-media-camera.spec | 2 +- src/camera.c | 178 ++++++++++++++++++++++++++++++++++++++- test/multimedia_camera_test.c | 10 ++- 4 files changed, 268 insertions(+), 3 deletions(-) diff --git a/include/camera.h b/include/camera.h index 0fe79de..a17cd22 100644 --- a/include/camera.h +++ b/include/camera.h @@ -101,6 +101,7 @@ typedef enum { CAMERA_PIXEL_FORMAT_RGBA, /**< RGBA pixel format */ CAMERA_PIXEL_FORMAT_ARGB, /**< ARGB pixel format */ CAMERA_PIXEL_FORMAT_JPEG, /**< Encoded pixel format */ + CAMERA_PIXEL_FORMAT_H264 = 15, /**< Encoded pixel format : H264 (Since 3.0) */ } camera_pixel_format_e; /** @@ -170,6 +171,15 @@ typedef enum { } camera_facing_direction_e; /** + * @brief Enumeration for the current flash state. + * @since_tizen 3.0 + */ +typedef enum { + CAMERA_FLASH_STATE_NOT_USED = 0, /**< Flash is not used now through camera API */ + CAMERA_FLASH_STATE_USED, /**< Flash is used now through camera API */ +} camera_flash_state_e; + +/** * @brief The structure type of the image data. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ @@ -1472,6 +1482,21 @@ int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format); int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direciton); /** + * @brief Gets the camera's flash state. + * @since_tizen 3.0 + * @param[in] device The hardware camera to access + * @param[out] state The current flash state + * @return @c 0 on success, otherwise a negative error value + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported + * @see camera_attr_set_flash_mode() + * @see camera_attr_get_flash_mode() + */ +int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state); + +/** * @} */ @@ -2045,6 +2070,62 @@ int camera_attr_set_image_quality(camera_h camera, int quality); int camera_attr_get_image_quality(camera_h camera, int *quality); /** + * @brief Gets the bit rate of encoded preview. + * @since_tizen 3.0 + * @param[in] camera The handle to the camera + * @param[out] bitrate The bit rate of encoded preview + * @return @c 0 on success, otherwise a negative error value + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported + * @see camera_attr_set_encoded_preview_bitrate() + */ +int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate); + +/** + * @brief Sets the bit rate of encoded preview. + * @since_tizen 3.0 + * @param[in] camera The handle to the camera + * @param[in] bitrate The bit rate of encoded preview + * @return @c 0 on success, otherwise a negative error value + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported + * @see camera_attr_get_encoded_preview_bitrate() + */ +int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate); + +/** + * @brief Gets the GOP(Group Of Pictures) interval of encoded preview. + * @since_tizen 3.0 + * @param[in] camera The handle to the camera + * @param[out] interval the GOP interval of encoded preview (mili second) + * @return @c 0 on success, otherwise a negative error value + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported + * @see camera_attr_get_encoded_preview_gop_interval() + */ +int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval); + +/** + * @brief Sets the GOP(Group Of Pictures) interval of encoded preview. + * @since_tizen 3.0 + * @param[in] camera The handle to the camera + * @param[in] interval the GOP interval of encoded preview (mili second) + * @return @c 0 on success, otherwise a negative error value + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_INVALID_OPERATION Internal error + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported + * @see camera_attr_set_encoded_preview_gop_interval() + */ +int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval); + +/** * @brief Sets the zoom level. * @details The range for the zoom level is received from camera_attr_get_zoom_range(). If @a zoom is out of range, the #CAMERA_ERROR_INVALID_PARAMETER error occurs. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec index 4bb930e..e649294 100644 --- a/packaging/capi-media-camera.spec +++ b/packaging/capi-media-camera.spec @@ -3,7 +3,7 @@ Name: capi-media-camera Summary: A Camera API -Version: 0.2.41 +Version: 0.2.42 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/camera.c b/src/camera.c index 740df79..dcff6cf 100644 --- a/src/camera.c +++ b/src/camera.c @@ -3659,6 +3659,118 @@ int camera_attr_get_image_quality(camera_h camera, int *quality) } +int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate) +{ + if (camera == NULL || bitrate == NULL) { + LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret = CAMERA_ERROR_NONE; + + camera_cli_s *pc = (camera_cli_s *)camera; + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE; + int sock_fd; + if (pc->cb_info == NULL) { + LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + sock_fd = pc->cb_info->fd; + int get_bitrate; + + LOGD("Enter, remote_handle : %x", pc->remote_handle); + muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + + if (ret == CAMERA_ERROR_NONE) { + muse_camera_msg_get(get_bitrate, pc->cb_info->recv_msg); + *bitrate = get_bitrate; + } + LOGD("ret : 0x%x", ret); + return ret; +} + + +int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate) +{ + if (camera == NULL) { + LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret = CAMERA_ERROR_NONE; + + camera_cli_s *pc = (camera_cli_s *)camera; + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE; + int sock_fd; + if (pc->cb_info == NULL) { + LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + sock_fd = pc->cb_info->fd; + int set_bitrate = bitrate; + LOGD("Enter, remote_handle : %x", pc->remote_handle); + muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_bitrate); + LOGD("ret : 0x%x", ret); + return ret; +} + + +int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval) +{ + if (camera == NULL || interval == NULL) { + LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret = CAMERA_ERROR_NONE; + + camera_cli_s *pc = (camera_cli_s *)camera; + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL; + int sock_fd; + if (pc->cb_info == NULL) { + LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + sock_fd = pc->cb_info->fd; + int get_gop_interval; + + LOGD("Enter, remote_handle : %x", pc->remote_handle); + muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); + + if (ret == CAMERA_ERROR_NONE) { + muse_camera_msg_get(get_gop_interval, pc->cb_info->recv_msg); + *interval = get_gop_interval; + } + LOGD("ret : 0x%x", ret); + return ret; +} + + +int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval) +{ + if (camera == NULL) { + LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + int ret = CAMERA_ERROR_NONE; + + camera_cli_s *pc = (camera_cli_s *)camera; + muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL; + int sock_fd; + if (pc->cb_info == NULL) { + LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } + sock_fd = pc->cb_info->fd; + int set_gop_interval = interval; + LOGD("Enter, remote_handle : %x", pc->remote_handle); + muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_gop_interval); + LOGD("ret : 0x%x", ret); + return ret; +} + + int camera_attr_set_zoom(camera_h camera, int zoom) { if (camera == NULL) { @@ -4118,7 +4230,6 @@ int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode) return ret; } - int camera_attr_get_zoom(camera_h camera, int *zoom) { if (camera == NULL || zoom == NULL) { @@ -4725,6 +4836,71 @@ int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode) return ret; } +int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state) +{ + int sock_fd = -1; + char *sndMsg; + int ret = CAMERA_ERROR_NONE; + int pid = 0; + camera_cli_s *pc = NULL; + int get_flash_state = 0; + + /* create muse connection */ + muse_camera_api_e api = MUSE_CAMERA_API_GET_FLASH_STATE; + muse_core_api_module_e muse_module = MUSE_CAMERA; + int device_type = (int)device; + + sock_fd = muse_core_client_new(); + if (sock_fd < 0) { + LOGE("muse_core_client_new failed - returned fd %d", sock_fd); + ret = CAMERA_ERROR_INVALID_OPERATION; + goto Exit; + } + + sndMsg = muse_core_msg_json_factory_new(api, + MUSE_TYPE_INT, "module", muse_module, + MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type, + 0); + + muse_core_ipc_send_msg(sock_fd, sndMsg); + muse_core_msg_json_factory_free(sndMsg); + + pc = g_new0(camera_cli_s, 1); + if (pc == NULL) { + LOGE("camera_cli_s alloc failed"); + ret = CAMERA_ERROR_OUT_OF_MEMORY; + goto Exit; + } + + pc->cb_info = _client_callback_new(sock_fd); + if (pc->cb_info == NULL) { + LOGE("cb_info alloc failed"); + ret = CAMERA_ERROR_OUT_OF_MEMORY; + goto Exit; + } + + ret = _client_wait_for_cb_return(api, pc->cb_info, CALLBACK_TIME_OUT); + + if (ret == CAMERA_ERROR_NONE) { + muse_camera_msg_get(get_flash_state, pc->cb_info->recv_msg); + *state = (camera_flash_state_e)get_flash_state; + } + + LOGD("Flash state : %d\n", *state); + +Exit: + /* release resources */ + if (pc) { + g_atomic_int_set(&pc->cb_info->msg_recv_running, 0); + g_atomic_int_set(&pc->cb_info->msg_handler_running, 0); + _client_callback_destroy(pc->cb_info); + pc->cb_info = NULL; + g_free(pc); + pc = NULL; + } + + return ret; +} int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data) { diff --git a/test/multimedia_camera_test.c b/test/multimedia_camera_test.c index 0ca7933..b14a1b1 100644 --- a/test/multimedia_camera_test.c +++ b/test/multimedia_camera_test.c @@ -689,6 +689,7 @@ static void print_menu() g_print("\t 'e' EV program mode \n"); g_print("\t >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [etc.]\n"); g_print("\t 'z' Strobe (Flash) \n"); + g_print("\t 'S' Strobe (Flash) state\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"); @@ -956,7 +957,6 @@ static void setting_menu(gchar buf) else g_print("* Error : %d\n", err); break; - /* Display / Filter setting */ case 'v': /* Display visible */ g_print("* Display visible setting !\n"); @@ -1053,6 +1053,14 @@ static void setting_menu(gchar buf) err = scanf("%d", &idx); bret = camera_attr_set_flash_mode(hcamcorder->camera, idx); break; + case 'S' : // Setting > flash state + g_print("*flash state\n"); + err = camera_get_flash_state(cam_info, &idx); + if (CAMERA_ERROR_NONE == err) + g_print("Current flash state = %s\n", idx?"ON":"OFF"); + else + g_print("* Error : %d\n", err); + break; case 'x': /* Setting > Capture mode ,Muitishot? */ g_print("*Select Capture mode!\n"); flush_stdin(); -- 2.7.4