From e8125de662296d5f1d892a200eb6deb85ec47394 Mon Sep 17 00:00:00 2001 From: Jeongmo Yang Date: Mon, 19 Sep 2022 19:50:13 +0900 Subject: [PATCH] Add new internal API to set device for extra preview [Version] 0.4.90 [Issue Type] New feature Change-Id: Ie427b44d882062c933f017cfe38414c44cf25666 Signed-off-by: Jeongmo Yang --- include/camera_internal.h | 19 +++++++++++++++++++ include/camera_private.h | 18 ++++++++++++++++++ packaging/capi-media-camera.spec | 2 +- src/camera.c | 29 ++++++++--------------------- src/camera_internal.c | 22 ++++++++++++++++++++++ test/camera_test.c | 9 +++++++++ 6 files changed, 77 insertions(+), 22 deletions(-) diff --git a/include/camera_internal.h b/include/camera_internal.h index 11876ad..672a64b 100644 --- a/include/camera_internal.h +++ b/include/camera_internal.h @@ -218,6 +218,25 @@ int camera_attr_get_focus_level(camera_h camera, int *level); int camera_attr_get_focus_level_range(camera_h camera, int *min, int *max); /** + * @internal + * @brief Sets device for the extra preview stream. + * @since_tizen 7.0 + * @param[in] camera The handle to the camera + * @param[in] stream_id The id of extra preview stream + * @param[in] device The camera type + * @return @c 0 on success, otherwise a negative error value + * @retval #CAMERA_ERROR_NONE Successful + * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported + * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CAMERA_ERROR_INVALID_STATE Invalid state + * @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected + * @pre The camera state must be set to #CAMERA_STATE_CREATED. + * @see camera_set_extra_preview_cb() + * @see camera_unset_extra_preview_cb() + */ +int camera_set_extra_preview_device(camera_h camera, int stream_id, camera_device_e device); + +/** * @} */ #ifdef __cplusplus diff --git a/include/camera_private.h b/include/camera_private.h index 0cece0b..74e11e1 100644 --- a/include/camera_private.h +++ b/include/camera_private.h @@ -87,6 +87,22 @@ extern "C" { LOGD("[V] "format, ##args); \ } while (0) +#define CAMERA_CHECK_HANDLE_RETURN(pc) \ + do {\ + if (!pc || !pc->cb_info) {\ + CAM_LOG_ERROR("NULL handle[%p]", pc);\ + return;\ + }\ + } while (0) + +#define CAMERA_CHECK_HANDLE_RETURN_VAL(pc, val) \ + do {\ + if (!pc || !pc->cb_info) {\ + CAM_LOG_ERROR("NULL handle[%p]", pc);\ + return (val);\ + }\ + } while (0) + enum { CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, @@ -259,6 +275,8 @@ void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info, void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info); int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out); void _camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value); +void _camera_send_message_get_return(camera_cb_info_s *cb_info, muse_camera_api_e api, char *msg, + int time_out, int *ret); int _camera_get_log_level(void); typedef bool (*camera_supported_cb_param1)(int param, void *user_data); diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec index 20221ad..a30a364 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.89 +Version: 0.4.90 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/camera.c b/src/camera.c index 9cbca68..228808f 100644 --- a/src/camera.c +++ b/src/camera.c @@ -42,20 +42,7 @@ return CAMERA_ERROR_NOT_SUPPORTED;\ }\ } while (0) -#define CAMERA_CHECK_HANDLE_RETURN(pc) \ - do {\ - if (!pc || !pc->cb_info) {\ - CAM_LOG_ERROR("NULL handle[%p]", pc);\ - return;\ - }\ - } while (0) -#define CAMERA_CHECK_HANDLE_RETURN_VAL(pc, val) \ - do {\ - if (!pc || !pc->cb_info) {\ - CAM_LOG_ERROR("NULL handle[%p]", pc);\ - return (val);\ - }\ - } while (0) + /* for camera device manager */ typedef struct _cdm_symbol_table { @@ -760,7 +747,7 @@ static int __set_enable(camera_h camera, muse_camera_api_e api, int set_enable) } -static void __send_message_get_return(camera_cb_info_s *cb_info, muse_camera_api_e api, char *msg, int time_out, int *ret) +void _camera_send_message_get_return(camera_cb_info_s *cb_info, muse_camera_api_e api, char *msg, int time_out, int *ret) { int send_ret = 0; @@ -869,7 +856,7 @@ void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info, msg = muse_core_msg_new(api, NULL); - __send_message_get_return(cb_info, api, msg, timeout, ret); + _camera_send_message_get_return(cb_info, api, msg, timeout, ret); } @@ -914,7 +901,7 @@ void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info, break; } - __send_message_get_return(cb_info, api, msg, timeout, ret); + _camera_send_message_get_return(cb_info, api, msg, timeout, ret); } @@ -943,7 +930,7 @@ void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info, param1->type, param1->name, param1->value.value_INT, NULL); - __send_message_get_return(cb_info, api, msg, timeout, ret); + _camera_send_message_get_return(cb_info, api, msg, timeout, ret); } @@ -4792,7 +4779,7 @@ int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, d MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag, NULL); - __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret); + _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret); return ret; } @@ -6201,7 +6188,7 @@ int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, i MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area, NULL); - __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret); + _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret); return ret; } @@ -6763,7 +6750,7 @@ int camera_set_extra_preview_stream_format(camera_h camera, int stream_id, camer MUSE_TYPE_ARRAY, "stream_format", 4, stream_format, NULL); - __send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret); + _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret); return ret; } diff --git a/src/camera_internal.c b/src/camera_internal.c index 59e9c0b..7fc9b72 100644 --- a/src/camera_internal.c +++ b/src/camera_internal.c @@ -335,4 +335,26 @@ int camera_attr_get_focus_level_range(camera_h camera, int *min, int *max) return ret; } + + +int camera_set_extra_preview_device(camera_h camera, int stream_id, camera_device_e device) +{ + int ret = CAMERA_ERROR_NONE; + char *msg = NULL; + camera_cli_s *pc = (camera_cli_s *)camera; + muse_camera_api_e api = MUSE_CAMERA_API_SET_EXTRA_PREVIEW_DEVICE; + + CAMERA_CHECK_HANDLE_RETURN_VAL(pc, CAMERA_ERROR_INVALID_PARAMETER); + + CAM_LOG_INFO("Enter - stream[%d], device[%d]", stream_id, device); + + msg = muse_core_msg_new(api, + MUSE_TYPE_INT, "stream_id", stream_id, + MUSE_TYPE_INT, "device", device, + NULL); + + _camera_send_message_get_return(pc->cb_info, api, msg, CAMERA_CB_TIMEOUT, &ret); + + return ret; +} //LCOV_EXCL_STOP diff --git a/test/camera_test.c b/test/camera_test.c index 8ca3544..4ec9e23 100644 --- a/test/camera_test.c +++ b/test/camera_test.c @@ -1765,6 +1765,7 @@ static void __enable_extra_preview_and_callback(camera_h camera) int height = 0; int fps = 0; int pixel_format = 0; + int camera_device = 0; g_print("\n\t- Format list"); g_print("\n\t0:NV12, 1:NV12T, 2:NV16, 3:NV21, 4:YUYV, 5:UYVY, 6:422P, 7:I420, 8:YV12, 9:RGB565, 10:RGB888"); @@ -1786,6 +1787,14 @@ static void __enable_extra_preview_and_callback(camera_h camera) return; } + g_print("\n\t## for MM_CAMCORDER_EXTRA_PREVIEW_MODE_PIPELINE_ELEMENT ##\n"); + g_print("\n\tSet device for extra preview[0 ~ 9] : "); + err = scanf("%d", (int *)&camera_device); + flush_stdin(); + + err = camera_set_extra_preview_device(hcamcorder->camera, 0, camera_device); + g_print("\n\tcamera_set_extra_preview_device(device:%d) 0x%x\n", camera_device, err); + g_print("\n\tDump extra preview data to file - NO[0], YES[Others] : "); err = scanf("%d", &g_camera_extra_preview_cb_dump); flush_stdin(); -- 2.7.4