From 5c19f800ad42f91a7c180522b9f8bd7bf0a5971b Mon Sep 17 00:00:00 2001 From: Jeongmo Yang Date: Fri, 14 Apr 2023 20:28:00 +0900 Subject: [PATCH] [ACR-1764] Add new APIs for device manager - int camera_device_manager_get_product_id(camera_device_manager_h manager, camera_device_e device, unsigned short *product_id); - int camera_device_manager_get_vendor_id(camera_device_manager_h manager, camera_device_e device, unsigned short *vendor_id); [Version] 0.4.109 [Issue Type] New feature Change-Id: Ifb08bd81d5838317ae1409f32f57cf104ae4564f Signed-off-by: Jeongmo Yang --- include/camera.h | 34 +++++++++++++++++++++ include/camera_device_manager.h | 13 +++++++- packaging/capi-media-camera.spec | 2 +- src/camera_device_manager.c | 64 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 2 deletions(-) diff --git a/include/camera.h b/include/camera.h index 2a8baf5..6fb15c3 100644 --- a/include/camera.h +++ b/include/camera.h @@ -1034,6 +1034,40 @@ int camera_device_manager_add_device_connection_changed_cb(camera_device_manager int camera_device_manager_remove_device_connection_changed_cb(camera_device_manager_h manager, int cb_id); /** + * @brief Gets the product id of the camera device. + * @since_tizen 8.0 + * @param[in] manager The handle to the camera device manager + * @param[in] device The index of camera device + * @param[out] product_id The product id of camera device + * @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_OPERATION Invalid operation + * @see camera_device_manager_initialize() + * @see camera_device_manager_deinitialize() + * @see camera_supported_device_cb() + */ +int camera_device_manager_get_product_id(camera_device_manager_h manager, camera_device_e device, unsigned short *product_id); + +/** + * @brief Gets the vendor id of the camera device. + * @since_tizen 8.0 + * @param[in] manager The handle to the camera device manager + * @param[in] device The index of camera device + * @param[out] vendor_id The vendor id of camera device + * @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_OPERATION Invalid operation + * @see camera_device_manager_initialize() + * @see camera_device_manager_deinitialize() + * @see camera_supported_device_cb() + */ +int camera_device_manager_get_vendor_id(camera_device_manager_h manager, camera_device_e device, unsigned short *vendor_id); + +/** * @brief Starts capturing and drawing preview frames on the screen. * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif diff --git a/include/camera_device_manager.h b/include/camera_device_manager.h index 6beeec5..e8e3aec 100644 --- a/include/camera_device_manager.h +++ b/include/camera_device_manager.h @@ -38,6 +38,16 @@ typedef struct _camera_device_list_s { /** * @internal + * @brief Enumeration for camera device manager property type. + * @since_tizen 8.0 + */ +typedef enum { + CAMERA_DEVICE_MANAGER_PROPERTY_TYPE_PRODUCT_ID = 0, + CAMERA_DEVICE_MANAGER_PROPERTY_TYPE_VENDOR_ID +} camera_device_manager_property_type_e; + +/** + * @internal * @brief The structure type for the camera device manager. * @since_tizen 7.0 */ @@ -45,9 +55,10 @@ typedef struct _camera_device_manager { void *dl_handle; int (*initialize)(void); int (*deinitialize)(void); - int (*get_device_list)(void *list); + int (*get_device_list)(void *); int (*add_device_connection_changed_cb)(void *, void *, int *); int (*remove_device_connection_changed_cb)(int); + int (*get_device_property)(int, int, void *); } camera_device_manager; #ifdef __cplusplus diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec index 0fe0787..f0b554b 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.108 +Version: 0.4.109 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/camera_device_manager.c b/src/camera_device_manager.c index 3cabc7c..e112d30 100644 --- a/src/camera_device_manager.c +++ b/src/camera_device_manager.c @@ -20,6 +20,7 @@ #include #include #include +#include #ifdef LOG_TAG #undef LOG_TAG @@ -55,6 +56,7 @@ int camera_device_manager_initialize(camera_device_manager_h *manager) {(void **)&new_manager->get_device_list, "cdm_get_device_list"}, {(void **)&new_manager->add_device_connection_changed_cb, "cdm_add_device_connection_changed_cb"}, {(void **)&new_manager->remove_device_connection_changed_cb, "cdm_remove_device_connection_changed_cb"}, + {(void **)&new_manager->get_device_property, "cdm_get_device_property"} }; CAMERA_CHECK_DEVICE_MANAGER; @@ -232,4 +234,66 @@ int camera_device_manager_remove_device_connection_changed_cb(camera_device_mana return CAMERA_ERROR_NONE; } + + +int camera_device_manager_get_product_id(camera_device_manager_h manager, camera_device_e device, unsigned short *product_id) +{ + int ret = CAMERA_ERROR_NONE; + camera_device_manager *m = (camera_device_manager *)manager; + GValue value = G_VALUE_INIT; + + CAMERA_CHECK_DEVICE_MANAGER; + + if (!m || !product_id) { + CAM_LOG_ERROR("NULL param[%p,%p]", m, product_id); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + g_value_init(&value, G_TYPE_UINT); + + ret = m->get_device_property(device, CAMERA_DEVICE_MANAGER_PROPERTY_TYPE_PRODUCT_ID, &value); + if (ret != CAMERA_ERROR_NONE) { + CAM_LOG_ERROR("failed[0x%x]", ret); + return ret; + } + + *product_id = (unsigned short)g_value_get_uint(&value); + + g_value_unset(&value); + + CAM_LOG_INFO("device[%d] - product_id[0x%x], ret[0x%x]", device, *product_id, ret); + + return ret; +} + + +int camera_device_manager_get_vendor_id(camera_device_manager_h manager, camera_device_e device, unsigned short *vendor_id) +{ + int ret = CAMERA_ERROR_NONE; + camera_device_manager *m = (camera_device_manager *)manager; + GValue value = G_VALUE_INIT; + + CAMERA_CHECK_DEVICE_MANAGER; + + if (!m || !vendor_id) { + CAM_LOG_ERROR("NULL param[%p,%p]", m, vendor_id); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + g_value_init(&value, G_TYPE_UINT); + + ret = m->get_device_property(device, CAMERA_DEVICE_MANAGER_PROPERTY_TYPE_VENDOR_ID, &value); + if (ret != CAMERA_ERROR_NONE) { + CAM_LOG_ERROR("failed[0x%x]", ret); + return ret; + } + + *vendor_id = (unsigned short)g_value_get_uint(&value); + + g_value_unset(&value); + + CAM_LOG_INFO("device[%d] - vendor_id[0x%x], ret[0x%x]", device, *vendor_id, ret); + + return CAMERA_ERROR_NONE; +} //LCOV_EXCL_STOP -- 2.7.4