--- /dev/null
+/*
+* Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_MULTIMEDIA_CAMERA_DEVICE_MANAGER_H__
+#define __TIZEN_MULTIMEDIA_CAMERA_DEVICE_MANAGER_H__
+
+#include <camera_internal.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CAMERA_DEVICE_MAX ((CAMERA_DEVICE_CAMERA9 + 1) * 2)
+
+
+/**
+ * @internal
+ * @brief The structure type of the camera device list.
+ * @since_tizen 6.0
+ */
+typedef struct _camera_device_list_s {
+ unsigned int count;
+ camera_device_s device[CAMERA_DEVICE_MAX];
+} camera_device_list_s;
+
+/**
+ * @internal
+ * @brief The structure type for the camera device manager.
+ * @since_tizen 7.0
+ */
+typedef struct _camera_device_manager {
+ void *dl_handle;
+ int (*initialize)(void);
+ int (*deinitialize)(void);
+ int (*get_device_list)(void *list);
+ int (*add_device_connection_changed_cb)(void *, void *, int *);
+ int (*remove_device_connection_changed_cb)(int);
+} camera_device_manager;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_MULTIMEDIA_CAMERA_DEVICE_MANAGER_H__ */
* @{
*/
-#define CAMERA_DEVICE_MAX ((CAMERA_DEVICE_CAMERA9 + 1) * 2)
-
-/**
- * @internal
- * @brief The structure type of the camera device list.
- * @since_tizen 6.0
- */
-typedef struct _camera_device_list_s {
- unsigned int count;
- camera_device_s device[CAMERA_DEVICE_MAX];
-} camera_device_list_s;
-
/**
* @internal
* @brief The structure type of the meta timestamp.
#define __TIZEN_MULTIMEDIA_CAMERA_PRIVATE_H__
#include <glib.h>
+#include <dlog.h>
#include <camera_internal.h>
#include <media_bridge_internal.h>
#include <muse_core.h>
void *user_data;
} camera_cb_info;
-typedef struct _camera_device_manager {
- void *dl_handle;
- int (*initialize)(void);
- int (*deinitialize)(void);
- int (*get_device_list)(void *list);
- int (*add_device_connection_changed_cb)(void *, void *, int *);
- int (*remove_device_connection_changed_cb)(int);
-} camera_device_manager;
-
int _camera_get_tbm_format(int in_format, uint32_t *out_format);
int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype);
Name: capi-media-camera
Summary: A Camera API
-Version: 0.4.103
+Version: 0.4.104
Release: 0
Group: Multimedia/API
License: Apache-2.0
%files devel
%{_includedir}/media/camera.h
+%{_includedir}/media/camera_device_manager.h
%{_includedir}/media/camera_internal.h
%{_libdir}/pkgconfig/*.pc
%{_libdir}/libcapi-media-camera.so
#include <muse_camera_msg.h>
#include <camera_private.h>
#include <muse_client.h>
-#include <dlog.h>
#include <gio/gio.h>
#include <dlfcn.h>
#endif
#define LOG_TAG "TIZEN_N_CAMERA"
#define MODULE_NAME "camera"
-#define LIB_CAMERA_DEVICE_MANAGER PATH_LIBDIR"/libcamera_device_manager.so"
-#define CAMERA_CHECK_DEVICE_MANAGER \
- do {\
- if (access(LIB_CAMERA_DEVICE_MANAGER, F_OK) != 0) {\
- CAM_LOG_ERROR("no camera device maanger[errno:%d]", errno);\
- return CAMERA_ERROR_NOT_SUPPORTED;\
- }\
- } while (0)
-
-
-/* for camera device manager */
-typedef struct _cdm_symbol_table {
- void **func_ptr;
- const char *func_name;
-} cdm_symbol_table;
+
/* for device changed callback */
static GMutex g_cam_dev_state_changed_cb_lock;
}
-int camera_device_manager_initialize(camera_device_manager_h *manager)
-{
- unsigned int i = 0;
- int ret = CAMERA_ERROR_NONE;
- void *dl_handle = NULL;
- g_autofree camera_device_manager *new_manager = g_new0(camera_device_manager, 1);
- cdm_symbol_table sym_table[] = {
- {(void **)&new_manager->initialize, "cdm_initialize"},
- {(void **)&new_manager->deinitialize, "cdm_deinitialize"},
- {(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"},
- };
-
- CAMERA_CHECK_DEVICE_MANAGER;
-
- if (!manager) {
- CAM_LOG_ERROR("NULL manager");
- ret = CAMERA_ERROR_INVALID_PARAMETER;
- goto _INITIALIZE_FAILED;
- }
-
- dl_handle = dlopen(LIB_CAMERA_DEVICE_MANAGER, RTLD_NOW);
- if (!dl_handle) {
- CAM_LOG_ERROR("dlopen[%s] failed[%s]", LIB_CAMERA_DEVICE_MANAGER, dlerror());
- ret = CAMERA_ERROR_INVALID_OPERATION;
- goto _INITIALIZE_FAILED;
- }
-
- /* get symbols */
- for (i = 0 ; i < G_N_ELEMENTS(sym_table) ; i++) {
- *sym_table[i].func_ptr = dlsym(dl_handle, sym_table[i].func_name);
- if (*sym_table[i].func_ptr == NULL) {
- CAM_LOG_ERROR("symbol failed[%s]", sym_table[i].func_name);
- ret = CAMERA_ERROR_INVALID_OPERATION;
- goto _INITIALIZE_FAILED;
- }
- }
-
- ret = new_manager->initialize();
- if (ret != CAMERA_ERROR_NONE) {
- CAM_LOG_ERROR("failed[0x%x]", ret);
- goto _INITIALIZE_FAILED;
- }
-
- new_manager->dl_handle = dl_handle;
- *manager = (camera_device_manager_h)g_steal_pointer(&new_manager);
-
- CAM_LOG_INFO("camera device manager[%p](dl handle[%p]) initialized",
- *manager, dl_handle);
-
- return CAMERA_ERROR_NONE;
-
-_INITIALIZE_FAILED:
- if (dl_handle)
- dlclose(dl_handle);
-
- return ret;
-}
-
-
-//LCOV_EXCL_START
-int camera_device_manager_deinitialize(camera_device_manager_h manager)
-{
- int ret = CAMERA_ERROR_NONE;
- camera_device_manager *m = (camera_device_manager *)manager;
-
- CAMERA_CHECK_DEVICE_MANAGER;
-
- if (!m) {
- CAM_LOG_ERROR("NULL manager");
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- CAM_LOG_INFO("deinitialize camera device manager[%p]", m);
-
- ret = m->deinitialize();
- if (ret != CAMERA_ERROR_NONE) {
- CAM_LOG_ERROR("failed[0x%x]", ret);
- return ret;
- }
-
- CAM_LOG_INFO("close dl handle[%p]", m->dl_handle);
-
- dlclose(m->dl_handle);
-
- memset(m, 0x0, sizeof(camera_device_manager));
- g_free(m);
-
- return CAMERA_ERROR_NONE;
-}
-
-
-int camera_device_manager_foreach_supported_device(camera_device_manager_h manager, camera_supported_device_cb callback, void *user_data)
-{
- int ret = CAMERA_ERROR_NONE;
- unsigned int i = 0;
- camera_device_list_s device_list;
- camera_device_s *device = NULL;
- camera_device_manager *m = (camera_device_manager *)manager;
-
- CAMERA_CHECK_DEVICE_MANAGER;
-
- if (!m || !callback) {
- CAM_LOG_ERROR("NULL parameter[%p,%p]", m, callback);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- CAM_LOG_INFO("enter");
-
- memset(&device_list, 0x0, sizeof(camera_device_list_s));
-
- ret = m->get_device_list(&device_list);
- if (ret != CAMERA_ERROR_NONE) {
- CAM_LOG_ERROR("failed[0x%x]", ret);
- return ret;
- }
-
- CAM_LOG_INFO("device count[%d]", device_list.count);
-
- for (i = 0 ; i < device_list.count ; i++) {
- device = &device_list.device[i];
-
- CAM_LOG_INFO(" [%d] : type[%d], index[%d], name[%s], id[%s], ex-stream[%d]",
- i, device->type, device->index,
- device->name, device->id, device->extra_stream_num);
-
- if (!callback(device, user_data)) {
- CAM_LOG_WARNING("callback is stopped[called:%u,total:%u]",
- i + 1, device_list.count);
- break;
- }
- }
-
- return CAMERA_ERROR_NONE;
-}
-
-
-int camera_device_manager_add_device_connection_changed_cb(camera_device_manager_h manager,
- camera_device_connection_changed_cb callback, void *user_data, int *cb_id)
-{
- int ret = CAMERA_ERROR_NONE;
- camera_device_manager *m = (camera_device_manager *)manager;
-
- CAMERA_CHECK_DEVICE_MANAGER;
-
- if (!m || !callback || !cb_id) {
- CAM_LOG_ERROR("NULL parameter[%p,%p,%p]", m, callback, cb_id);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- CAM_LOG_INFO("enter");
-
- ret = m->add_device_connection_changed_cb(callback, user_data, cb_id);
- if (ret != CAMERA_ERROR_NONE) {
- CAM_LOG_ERROR("failed[0x%x]", ret);
- return ret;
- }
-
- CAM_LOG_INFO("cb_id[%d] added", *cb_id);
-
- return CAMERA_ERROR_NONE;
-}
-
-
-int camera_device_manager_remove_device_connection_changed_cb(camera_device_manager_h manager, int cb_id)
-{
- int ret = CAMERA_ERROR_NONE;
- camera_device_manager *m = (camera_device_manager *)manager;
-
- CAMERA_CHECK_DEVICE_MANAGER;
-
- if (!m) {
- CAM_LOG_ERROR("NULL manager");
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- CAM_LOG_INFO("enter - cb_id[%d]", cb_id);
-
- ret = m->remove_device_connection_changed_cb(cb_id);
- if (ret != CAMERA_ERROR_NONE) {
- CAM_LOG_ERROR("failed[0x%x]", ret);
- return ret;
- }
-
- CAM_LOG_INFO("cb_id[%d] removed", cb_id);
-
- return CAMERA_ERROR_NONE;
-}
-//LCOV_EXCL_STOP
-
-
int camera_set_extra_preview_cb(camera_h camera, camera_extra_preview_cb callback, void *user_data)
{
int ret = CAMERA_ERROR_NONE;
{
return g_camera_log_level;
}
-
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <string.h>
+#include <unistd.h>
+#include <camera_private.h>
+#include <camera_device_manager.h>
+#include <dlfcn.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_CAMERA"
+
+#define LIB_CAMERA_DEVICE_MANAGER PATH_LIBDIR"/libcamera_device_manager.so"
+#define CAMERA_CHECK_DEVICE_MANAGER \
+ do {\
+ if (access(LIB_CAMERA_DEVICE_MANAGER, F_OK) != 0) {\
+ CAM_LOG_ERROR("no camera device manager[errno:%d]", errno);\
+ return CAMERA_ERROR_NOT_SUPPORTED;\
+ }\
+ } while (0)
+
+
+/* for camera device manager */
+typedef struct _cdm_symbol_table {
+ void **func_ptr;
+ const char *func_name;
+} cdm_symbol_table;
+
+
+int camera_device_manager_initialize(camera_device_manager_h *manager)
+{
+ unsigned int i = 0;
+ int ret = CAMERA_ERROR_NONE;
+ void *dl_handle = NULL;
+ g_autofree camera_device_manager *new_manager = g_new0(camera_device_manager, 1);
+ cdm_symbol_table sym_table[] = {
+ {(void **)&new_manager->initialize, "cdm_initialize"},
+ {(void **)&new_manager->deinitialize, "cdm_deinitialize"},
+ {(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"},
+ };
+
+ CAMERA_CHECK_DEVICE_MANAGER;
+
+ if (!manager) {
+ CAM_LOG_ERROR("NULL manager");
+ ret = CAMERA_ERROR_INVALID_PARAMETER;
+ goto _INITIALIZE_FAILED;
+ }
+
+ dl_handle = dlopen(LIB_CAMERA_DEVICE_MANAGER, RTLD_NOW);
+ if (!dl_handle) {
+ CAM_LOG_ERROR("dlopen[%s] failed[%s]", LIB_CAMERA_DEVICE_MANAGER, dlerror());
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _INITIALIZE_FAILED;
+ }
+
+ /* get symbols */
+ for (i = 0 ; i < G_N_ELEMENTS(sym_table) ; i++) {
+ *sym_table[i].func_ptr = dlsym(dl_handle, sym_table[i].func_name);
+ if (*sym_table[i].func_ptr == NULL) {
+ CAM_LOG_ERROR("symbol failed[%s]", sym_table[i].func_name);
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _INITIALIZE_FAILED;
+ }
+ }
+
+ ret = new_manager->initialize();
+ if (ret != CAMERA_ERROR_NONE) {
+ CAM_LOG_ERROR("failed[0x%x]", ret);
+ goto _INITIALIZE_FAILED;
+ }
+
+ new_manager->dl_handle = dl_handle;
+ *manager = (camera_device_manager_h)g_steal_pointer(&new_manager);
+
+ CAM_LOG_INFO("camera device manager[%p](dl handle[%p]) initialized",
+ *manager, dl_handle);
+
+ return CAMERA_ERROR_NONE;
+
+_INITIALIZE_FAILED:
+ if (dl_handle)
+ dlclose(dl_handle);
+
+ return ret;
+}
+
+
+//LCOV_EXCL_START
+int camera_device_manager_deinitialize(camera_device_manager_h manager)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_device_manager *m = (camera_device_manager *)manager;
+
+ CAMERA_CHECK_DEVICE_MANAGER;
+
+ if (!m) {
+ CAM_LOG_ERROR("NULL manager");
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ CAM_LOG_INFO("deinitialize camera device manager[%p]", m);
+
+ ret = m->deinitialize();
+ if (ret != CAMERA_ERROR_NONE) {
+ CAM_LOG_ERROR("failed[0x%x]", ret);
+ return ret;
+ }
+
+ CAM_LOG_INFO("close dl handle[%p]", m->dl_handle);
+
+ dlclose(m->dl_handle);
+
+ memset(m, 0x0, sizeof(camera_device_manager));
+ g_free(m);
+
+ return CAMERA_ERROR_NONE;
+}
+
+
+int camera_device_manager_foreach_supported_device(camera_device_manager_h manager, camera_supported_device_cb callback, void *user_data)
+{
+ int ret = CAMERA_ERROR_NONE;
+ unsigned int i = 0;
+ camera_device_list_s device_list;
+ camera_device_s *device = NULL;
+ camera_device_manager *m = (camera_device_manager *)manager;
+
+ CAMERA_CHECK_DEVICE_MANAGER;
+
+ if (!m || !callback) {
+ CAM_LOG_ERROR("NULL parameter[%p,%p]", m, callback);
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ CAM_LOG_INFO("enter");
+
+ memset(&device_list, 0x0, sizeof(camera_device_list_s));
+
+ ret = m->get_device_list(&device_list);
+ if (ret != CAMERA_ERROR_NONE) {
+ CAM_LOG_ERROR("failed[0x%x]", ret);
+ return ret;
+ }
+
+ CAM_LOG_INFO("device count[%d]", device_list.count);
+
+ for (i = 0 ; i < device_list.count ; i++) {
+ device = &device_list.device[i];
+
+ CAM_LOG_INFO(" [%d] : type[%d], index[%d], name[%s], id[%s], ex-stream[%d]",
+ i, device->type, device->index,
+ device->name, device->id, device->extra_stream_num);
+
+ if (!callback(device, user_data)) {
+ CAM_LOG_WARNING("callback is stopped[called:%u,total:%u]",
+ i + 1, device_list.count);
+ break;
+ }
+ }
+
+ return CAMERA_ERROR_NONE;
+}
+
+
+int camera_device_manager_add_device_connection_changed_cb(camera_device_manager_h manager,
+ camera_device_connection_changed_cb callback, void *user_data, int *cb_id)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_device_manager *m = (camera_device_manager *)manager;
+
+ CAMERA_CHECK_DEVICE_MANAGER;
+
+ if (!m || !callback || !cb_id) {
+ CAM_LOG_ERROR("NULL parameter[%p,%p,%p]", m, callback, cb_id);
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ CAM_LOG_INFO("enter");
+
+ ret = m->add_device_connection_changed_cb(callback, user_data, cb_id);
+ if (ret != CAMERA_ERROR_NONE) {
+ CAM_LOG_ERROR("failed[0x%x]", ret);
+ return ret;
+ }
+
+ CAM_LOG_INFO("cb_id[%d] added", *cb_id);
+
+ return CAMERA_ERROR_NONE;
+}
+
+
+int camera_device_manager_remove_device_connection_changed_cb(camera_device_manager_h manager, int cb_id)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_device_manager *m = (camera_device_manager *)manager;
+
+ CAMERA_CHECK_DEVICE_MANAGER;
+
+ if (!m) {
+ CAM_LOG_ERROR("NULL manager");
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ CAM_LOG_INFO("enter - cb_id[%d]", cb_id);
+
+ ret = m->remove_device_connection_changed_cb(cb_id);
+ if (ret != CAMERA_ERROR_NONE) {
+ CAM_LOG_ERROR("failed[0x%x]", ret);
+ return ret;
+ }
+
+ CAM_LOG_INFO("cb_id[%d] removed", cb_id);
+
+ return CAMERA_ERROR_NONE;
+}
+//LCOV_EXCL_STOP
#include <mm_types.h>
#include <camera_internal.h>
#include <camera_private.h>
-#include <dlog.h>
#ifdef LOG_TAG
#undef LOG_TAG
/*=======================================================================================
| INCLUDE FILES |
=======================================================================================*/
+#include <stdint.h>
#include "camera_test.h"
/*-----------------------------------------------------------------------