camera_device_s device[CAMERA_DEVICE_MAX];
} camera_device_list_s;
+typedef struct camera_device_manager *camera_device_manager_h;
+
+/**
+ * @internal
+ * @brief Called when the camera device list is changed.
+ * @since_tizen 6.0
+ * @param[in] list The device list of the camera
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see camera_device_manager_add_device_list_changed_cb()
+ */
+typedef void (*camera_device_list_changed_cb)(camera_device_list_s *list, void *user_data);
+
/**
+ * @internal
* @brief Start the evas rendering.
- *
* @since_tizen 3.0
* @param[in] camera The handle to the camera
* @return @c 0 on success, otherwise a negative error value
int camera_start_evas_rendering(camera_h camera);
/**
+ * @internal
* @brief Stop the evas rendering.
- *
* @since_tizen 3.0
* @param[in] camera The handle to the camera
* @param[in] keep_screen If @c true keep last frame on display, otherwise @c false
int camera_stop_evas_rendering(camera_h camera, bool keep_screen);
/**
+ * @internal
* @brief Sets the ecore wayland video display.
* @since_tizen 6.0
* @remarks This function must be called in main thread of the application.
int camera_set_ecore_wl_display(camera_h camera, void *ecore_wl_window);
/**
+ * @internal
* @brief Creates preview frame from stream data.
* @since_tizen 6.0
* @param[in] stream The stream from internal pipeline
tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame);
/**
+ * @internal
* @brief Creates a new camera handle for controlling a network camera.
* @since_tizen 6.0
* @remarks A @a camera must be released using camera_destroy().
int camera_create_network(camera_device_e device, camera_h *camera);
/**
+ * @internal
+ * @brief Initialize a camera device manager.
+ * @since_tizen 6.0
+ * @param[out] manager A newly returned handle to the camera device manager
+ * @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_OUT_OF_MEMORY Out of memory
+ * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
+ * @see camera_device_manager_deinitialize()
+ */
+int camera_device_manager_initialize(camera_device_manager_h *manager);
+
+/**
+ * @internal
+ * @brief Deinitialize the camera device manager handle.
+ * @since_tizen 6.0
+ * @param[in] manager The handle to the camera device manager
+ * @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_INVALID_OPERATION Invalid operation
+ * @see camera_device_manager_initialize()
+ */
+int camera_device_manager_deinitialize(camera_device_manager_h manager);
+
+/**
+ * @internal
* @brief Gets a list of available camera devices.
* @since_tizen 6.0
- * @param[out] list A list of available camera devices
+ * @param[in] manager The handle to the camera device manager
+ * @param[out] list A list of available camera devices
* @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_INVALID_OPERATION Invalid operation
* @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
*/
-int camera_get_device_list(camera_device_list_s *list);
+int camera_device_manager_get_device_list(camera_device_manager_h manager, camera_device_list_s *list);
+
+/**
+ * @internal
+ * @brief Registers a callback function to be called when the camera device list changes.
+ * @since_tizen 6.0
+ * @param[in] manager The handle to the camera device manager
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ * @param[out] cb_id The id of registered callback
+ * @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_INVALID_OPERATION Invalid operation
+ * @retval #CAMERA_ERROR_OUT_OF_MEMORY Out of memory
+ * @post This function will invoke camera_device_list_changed_cb() when the camera device list changes.
+ * @see camera_device_manager_remove_device_list_changed_cb()
+ * @see camera_device_list_changed_cb()
+ */
+int camera_device_manager_add_device_list_changed_cb(camera_device_manager_h manager, camera_device_list_changed_cb callback, void *user_data, int *cb_id);
+
+/**
+ * @internal
+ * @brief Unregisters the callback function.
+ * @since_tizen 6.0
+ * @param[in] manager The handle to the camera device manager
+ * @param[in] cb_id The id of registered callback
+ * @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_INVALID_OPERATION Invalid operation
+ * @see camera_device_manager_add_device_list_changed_cb()
+ */
+int camera_device_manager_remove_device_list_changed_cb(camera_device_manager_h manager, int cb_id);
/**
* @}
#define LIB_CAMERA_DEVICE_MANAGER PATH_LIBDIR"/libcamera_device_manager.so"
+typedef struct _cdm_symbol_table {
+ void **func_ptr;
+ const char *func_name;
+} cdm_symbol_table;
+
+
/* log level */
extern int g_mmcam_log_level;
}
-int camera_get_device_list(camera_device_list_s *list)
+int camera_device_manager_initialize(camera_device_manager_h *manager)
{
unsigned int i = 0;
int ret = CAMERA_ERROR_NONE;
- int (*get_device_list)(camera_device_list_s *list);
void *dl_handle = NULL;
+ 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_list_changed_cb, "cdm_add_device_list_changed_cb"},
+ {(void **)&new_manager->remove_device_list_changed_cb, "cdm_remove_device_list_changed_cb"},
+ };
- CAM_LOG_INFO("enter");
-
- if (!list) {
- CAM_LOG_ERROR("NULL parameter");
- return CAMERA_ERROR_INVALID_PARAMETER;
+ 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());
- return CAMERA_ERROR_NOT_SUPPORTED;
+ ret = CAMERA_ERROR_NOT_SUPPORTED;
+ goto _INITIALIZE_FAILED;
}
- get_device_list = dlsym(dl_handle, "get_device_list");
- if (!get_device_list) {
+ /* 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)new_manager;
+
+ CAM_LOG_INFO("camera device manager[%p]", new_manager);
+
+ return CAMERA_ERROR_NONE;
+
+_INITIALIZE_FAILED:
+ if (dl_handle)
dlclose(dl_handle);
- CAM_LOG_ERROR("failed to get symbol to get device list");
- return CAMERA_ERROR_NOT_SUPPORTED;
+ g_free(new_manager);
+ return ret;
+}
+
+
+int camera_device_manager_deinitialize(camera_device_manager_h manager)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_device_manager *m = (camera_device_manager *)manager;
+
+ if (!m) {
+ CAM_LOG_ERROR("NULL manager");
+ return CAMERA_ERROR_INVALID_PARAMETER;
}
- ret = get_device_list(list);
+ ret = m->deinitialize();
+ if (ret != CAMERA_ERROR_NONE) {
+ CAM_LOG_ERROR("failed[0x%x]", ret);
+ return ret;
+ }
- if (ret == CAMERA_ERROR_NONE) {
- CAM_LOG_INFO("device count[%d]", list->count);
- for (i = 0 ; i < list->count ; i++)
- CAM_LOG_INFO(" [%d] : type[%d], device index[%d], name[%s]",
- i, list->device[i].type, list->device[i].index, list->device[i].name);
- } else {
+ dlclose(m->dl_handle);
+ memset(m, 0x0, sizeof(camera_device_manager));
+ g_free(m);
+
+ CAM_LOG_INFO("finalized");
+
+ return ret;
+}
+
+
+int camera_device_manager_get_device_list(camera_device_manager_h manager, camera_device_list_s *list)
+{
+ int ret = CAMERA_ERROR_NONE;
+ unsigned int i = 0;
+ camera_device_manager *m = (camera_device_manager *)manager;
+
+ if (!m || !list) {
+ CAM_LOG_ERROR("NULL parameter[%p,%p]", m, list);
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ CAM_LOG_INFO("enter");
+
+ ret = m->get_device_list(list);
+ if (ret != CAMERA_ERROR_NONE) {
+ CAM_LOG_ERROR("failed[0x%x]", ret);
+ return ret;
+ }
+
+ CAM_LOG_INFO("device count[%d]", list->count);
+
+ for (i = 0 ; i < list->count ; i++) {
+ CAM_LOG_INFO(" [%d] : type[%d], device index[%d], name[%s]",
+ i, list->device[i].type, list->device[i].index, list->device[i].name);
+ }
+
+ return ret;
+}
+
+
+int camera_device_manager_add_device_list_changed_cb(camera_device_manager_h manager,
+ camera_device_list_changed_cb callback, void *user_data, int *cb_id)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_device_manager *m = (camera_device_manager *)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_list_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 ret;
+}
+
+
+int camera_device_manager_remove_device_list_changed_cb(camera_device_manager_h manager, int cb_id)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_device_manager *m = (camera_device_manager *)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_list_changed_cb(cb_id);
+ if (ret != CAMERA_ERROR_NONE) {
CAM_LOG_ERROR("failed[0x%x]", ret);
+ return ret;
}
- dlclose(dl_handle);
+ CAM_LOG_INFO("cb_id[%d] removed", cb_id);
return ret;
}