#include <camera.h>
#include <muse_camera.h>
#include <muse_camera_msg.h>
-#include <muse_core_ipc.h>
-#include <muse_core_module.h>
#include <camera_private.h>
#include <muse_core.h>
+#include <muse_client.h>
#include <dlog.h>
-#include <Elementary.h>
#include <tbm_surface_internal.h>
-#include <Evas.h>
-#include <Ecore_Wayland.h>
-#include <wayland-client.h>
-#include <tizen-extension-client-protocol.h>
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
-#include <mm_evas_renderer.h>
-#endif /* TIZEN_FEATURE_EVAS_RENDERER */
+#include <gio/gio.h>
#ifdef LOG_TAG
#undef LOG_TAG
#endif
#define LOG_TAG "TIZEN_N_CAMERA"
+#define MODULE_NAME "camera"
+
+/* for device changed callback */
+static GMutex g_cam_dev_state_changed_cb_lock;
+static GList *g_cam_dev_state_changed_cb_list;
+static int g_cam_dev_state_changed_cb_id;
+static GDBusConnection *g_cam_dev_state_changed_cb_conn;
+static guint g_cam_dev_state_changed_cb_subscribe_id;
+static GMutex g_cam_idle_event_lock;
+
+static void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
+ int *ret, int timeout);
+static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
+ int *ret, camera_msg_param *param, int timeout);
+static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
+ int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout);
+static void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info);
+static bool _camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle);
+static void _camera_release_imported_bo(tbm_bo *bo);
+static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_fd,
+ tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame);
+static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
+ camera_media_packet_data *mp_data, media_packet_h *packet);
+static int _camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
+ tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
+static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
+static gboolean _camera_allocate_preview_buffer(camera_h camera);
+static void _camera_release_preview_buffer(camera_h camera);
+
+
+static gboolean _camera_allocate_preview_buffer(camera_h camera)
+{
+ int i = 0;
+ int ret = CAMERA_ERROR_NONE;
+ int format = CAMERA_PIXEL_FORMAT_INVALID;
+ int width = 0;
+ int height = 0;
+ int buffer_size = 0;
+ camera_cli_s *pc = (camera_cli_s *)camera;
+ camera_cb_info_s *cb_info = NULL;
+ if (!pc || !pc->cb_info) {
+ LOGE("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
+ return FALSE;
+ }
-static void __global(void *data, struct wl_registry *registry,
- uint32_t name, const char *interface, uint32_t version)
-{
- struct tizen_surface **tz_surface = NULL;
+ cb_info = pc->cb_info;
- if (!data) {
- LOGE("NULL data");
- return;
+ LOGD("Enter");
+
+ /* get preview info and calculate size */
+ ret = camera_get_preview_format(camera, &format);
+ if (ret != CAMERA_ERROR_NONE) {
+ LOGE("get preview format failed 0x%x", ret);
+ return FALSE;
}
- tz_surface = (struct tizen_surface **)data;
+ ret = camera_get_preview_resolution(camera, &width, &height);
+ if (ret != CAMERA_ERROR_NONE) {
+ LOGE("get preview resolution failed 0x%x", ret);
+ return FALSE;
+ }
- if (!interface) {
- LOGW("NULL interface");
- return;
+ LOGD("preview %dx%d, format %d", width, height, format);
+
+ switch (format) {
+ case CAMERA_PIXEL_FORMAT_INVZ:
+ buffer_size = width * height;
+ break;
+ case CAMERA_PIXEL_FORMAT_NV12:
+ case CAMERA_PIXEL_FORMAT_I420:
+ buffer_size = (width * height * 3) >> 1;
+ break;
+ case CAMERA_PIXEL_FORMAT_YUYV:
+ case CAMERA_PIXEL_FORMAT_UYVY:
+ buffer_size = width * height * 2;
+ break;
+ default:
+ LOGE("unhandled format %d", format);
+ goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
}
- /*LOGI("interface %s", interface);*/
+ LOGD("buffer size %d, num %d", buffer_size, MUSE_NUM_FD);
- if (strcmp(interface, "tizen_surface") == 0) {
- LOGD("binding tizen surface for wayland");
+ for (i = 0 ; i < MUSE_NUM_FD ; i++) {
+ cb_info->bos[i] = tbm_bo_alloc(cb_info->bufmgr, buffer_size, TBM_BO_DEFAULT);
+ if (!cb_info->bos[i]) {
+ LOGE("bo alloc failed [%d,i:%d]", buffer_size, i);
+ goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
+ }
- *tz_surface = wl_registry_bind(registry, name, &tizen_surface_interface, version);
- if (*tz_surface == NULL)
- LOGE("failed to bind");
+ cb_info->fds[i] = tbm_bo_export_fd(cb_info->bos[i]);
+ if (cb_info->fds[i] < 0) {
+ LOGE("export fd failed [%d,i:%d] errno %d", buffer_size, i, errno);
+ goto _ALLOCATE_PREVIEW_BUFFER_FAILED;
+ }
- LOGD("done");
+ LOGD("bo %p, fd %d", cb_info->bos[i], cb_info->fds[i]);
}
- return;
+ LOGD("Done");
+
+ return TRUE;
+
+_ALLOCATE_PREVIEW_BUFFER_FAILED:
+ _camera_release_preview_buffer(camera);
+ return FALSE;
}
-static void __global_remove(void *data, struct wl_registry *wl_registry, uint32_t name)
+
+static void _camera_release_preview_buffer(camera_h camera)
{
- LOGD("enter");
+ int i = 0;
+ camera_cli_s *pc = (camera_cli_s *)camera;
+ camera_cb_info_s *cb_info = NULL;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("invalid pointer %p %p", pc, pc ? pc->cb_info : NULL);
+ return;
+ }
+
+ LOGD("Enter");
+
+ cb_info = pc->cb_info;
+
+ /* close exported fd and bos */
+ for (i = 0 ; i < MUSE_NUM_FD ; i++) {
+ LOGD("unref bo %p, close fd %d", cb_info->bos[i], cb_info->fds[i]);
+
+ if (cb_info->bos[i]) {
+ tbm_bo_unref(cb_info->bos[i]);
+ cb_info->bos[i] = NULL;
+ } else {
+ break;
+ }
+
+ if (cb_info->fds[i] >= 0) {
+ close(cb_info->fds[i]);
+ cb_info->fds[i] = -1;
+ }
+ }
+
+ LOGD("Done");
+
return;
}
-static const struct wl_registry_listener _camera_wl_registry_listener = {
- __global,
- __global_remove
-};
-void __parent_id_getter(void *data, struct tizen_resource *tizen_resource, uint32_t id)
+static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
{
- if (!data) {
- LOGE("NULL data");
+ if (!cb_info ||
+ api < 0 || api >= MUSE_CAMERA_API_MAX) {
+ LOGE("invalid param %p %d", cb_info, api);
return;
}
- *((unsigned int *)data) = id;
+ g_mutex_lock(&(cb_info->api_mutex[api]));
+ cb_info->api_waiting[api] += value;
+ g_mutex_unlock(&(cb_info->api_mutex[api]));
- LOGD("[CLIENT] got parent_id [%u] from server", id);
+ /*LOGD("api %d, value %d, waiting %d",
+ api, value, cb_info->api_waiting[api]);*/
return;
}
-static const struct tizen_resource_listener _camera_tz_resource_listener = {
- __parent_id_getter
-};
-int _get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info)
+static void __camera_device_state_changed_cb(GDBusConnection *connection,
+ const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
+ const gchar *signal_name, GVariant *param, gpointer user_data)
{
- int ret = CAMERA_ERROR_NONE;
- Ecore_Wl_Window *window = NULL;
- struct wl_display *display = NULL;
- struct wl_surface *surface = NULL;
- struct wl_registry *registry = NULL;
- struct tizen_surface *tz_surface = NULL;
- struct tizen_resource *tz_resource = NULL;
+ int value = 0;
+ camera_device_e device = CAMERA_DEVICE_CAMERA0;
+ camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
+ GList *tmp_list = NULL;
+ camera_cb_info *info = NULL;
- if (!obj || !wl_info) {
- LOGE("NULL parameter %p %p", obj, wl_info);
- return CAMERA_ERROR_INVALID_OPERATION;
- }
+ g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
- window = elm_win_wl_window_get(obj);
- if (!window) {
- LOGE("failed to get wayland window");
- ret = CAMERA_ERROR_INVALID_OPERATION;
+ if (!g_cam_dev_state_changed_cb_list || !param) {
+ LOGW("no callback or NULL param %p", param);
goto _DONE;
}
- surface = (struct wl_surface *)ecore_wl_window_surface_get(window);
- if (!surface) {
- LOGE("failed to get wayland surface");
- ret = CAMERA_ERROR_INVALID_OPERATION;
- goto _DONE;
- }
+ /* get device and state */
+ g_variant_get(param, "(i)", &value);
- display = (struct wl_display *)ecore_wl_display_get();
- if (!display) {
- LOGE("failed to get wayland display");
- ret = CAMERA_ERROR_INVALID_OPERATION;
- goto _DONE;
+ device = value >> 16;
+ state = 0x0000ffff & value;
+
+ LOGD("device %d, state %d", device, state);
+
+ tmp_list = g_cam_dev_state_changed_cb_list;
+
+ do {
+ info = (camera_cb_info *)tmp_list->data;
+
+ if (info) {
+ if (info->callback) {
+ LOGD("start id[%d] callback", info->id);
+ ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
+ LOGD("returned id[%d] callback", info->id);
+ } else {
+ LOGW("NULL callback for id %d", info->id);
+ }
+ }
+
+ tmp_list = tmp_list->next;
+ } while (tmp_list);
+
+_DONE:
+ g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
+
+ return;
+}
+
+
+static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
+{
+ int i = 0;
+ int ret = 0;
+ int ret_fd = -1;
+ int preview_fd = -1;
+ int num_buffer_fd = 0;
+ unsigned char *buf_pos = NULL;
+
+ tbm_bo bo = NULL;
+ tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
+ tbm_bo_handle bo_handle = {.ptr = NULL};
+ tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
+ tbm_bo data_bo = NULL;
+ tbm_bo_handle data_bo_handle = {.ptr = NULL};
+
+ camera_msg_param param;
+ camera_preview_data_s frame;
+ camera_stream_data_s *stream = NULL;
+ camera_media_packet_data *mp_data = NULL;
+ media_packet_h pkt = NULL;
+ media_packet_h pkt_evas = NULL;
+
+ /* tfd[0]: MMCamcorderVideoStreamDataType
+ tfd[1]: data_bo or zero copy bo[0]
+ tfd[2]: zero copy bo[1]
+ tfd[3]: zero copy bo[2] */
+
+ if (!cb_info || !recv_msg || !tfd) {
+ LOGE("invalid param %p %p %p", cb_info, recv_msg, tfd);
+ return;
}
- registry = wl_display_get_registry(display);
- if (!registry) {
- LOGE("failed to get wayland registry");
- ret = CAMERA_ERROR_INVALID_OPERATION;
- goto _DONE;
+ muse_camera_msg_get(preview_fd, recv_msg);
+ muse_camera_msg_get(num_buffer_fd, recv_msg);
+
+ /*LOGD("preview_fd %d, num_buffer_fd %d", preview_fd, num_buffer_fd);*/
+
+ memset(&frame, 0x0, sizeof(camera_preview_data_s));
+
+ if (tfd[0] < 0) {
+ LOGE("invalid fd %d", tfd[0]);
+ return;
}
- wl_registry_add_listener(registry, &_camera_wl_registry_listener, &tz_surface);
+ ret_fd = preview_fd;
+ CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
- wl_display_dispatch(display);
- wl_display_roundtrip(display);
+ if (num_buffer_fd < 0 || num_buffer_fd > BUFFER_MAX_PLANE_NUM) {
+ LOGE("invalid num buffer fd %d", num_buffer_fd);
+ goto _PREVIEW_CB_HANDLER_DONE;
+ }
- if (!tz_surface) {
- LOGE("failed to get tizen surface");
- ret = CAMERA_ERROR_INVALID_OPERATION;
- goto _DONE;
+ if (num_buffer_fd == 0 && tfd[1] >= 0) {
+ /* import tbm data_bo and get virtual address */
+ if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[1], &data_bo, &data_bo_handle)) {
+ LOGE("failed to import data fd %d", tfd[1]);
+ goto _PREVIEW_CB_HANDLER_DONE;
+ }
}
- /* Get parent_id which is unique in a entire systemw. */
- tz_resource = tizen_surface_get_tizen_resource(tz_surface, surface);
- if (!tz_resource) {
- LOGE("failed to get tizen resurce");
- ret = CAMERA_ERROR_INVALID_OPERATION;
- goto _DONE;
+ /* import tbm bo and get virtual address */
+ if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
+ LOGE("failed to import fd %d", tfd[0]);
+ goto _PREVIEW_CB_HANDLER_DONE;
}
- wl_info->parent_id = 0;
+ buf_pos = (unsigned char *)bo_handle.ptr;
- tizen_resource_add_listener(tz_resource, &_camera_tz_resource_listener, &wl_info->parent_id);
+ /* get stream info */
+ stream = (camera_stream_data_s *)buf_pos;
- wl_display_roundtrip(display);
+ for (i = 0 ; i < num_buffer_fd ; i++) {
+ /* import buffer bo and get virtual address */
+ if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[i + 1], &buffer_bo[i], &buffer_bo_handle[i])) {
+ LOGE("failed to import buffer fd %d", tfd[i + 1]);
+ goto _PREVIEW_CB_HANDLER_DONE;
+ }
+ }
- if (wl_info->parent_id > 0) {
- int rotation = 0;
- Ecore_Evas *ecore_evas = NULL;
- ret = CAMERA_ERROR_NONE;
+ /* call preview callback */
+ if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
+ _camera_preview_frame_create(stream, num_buffer_fd, buffer_bo_handle, &data_bo_handle, &frame);
+
+ ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
+ cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
+ }
- wl_info->evas_obj = obj;
+ if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
+ ret = _camera_media_packet_data_create(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
- evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
- &wl_info->window_width, &wl_info->window_height);
+ if (ret == CAMERA_ERROR_NONE) {
+ ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
+ if (ret != CAMERA_ERROR_NONE) {
+ LOGE("create pkt for evas failed");
+ _camera_media_packet_data_release(mp_data, cb_info);
+ mp_data = NULL;
+ }
+ }
+ }
- ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
- if (ecore_evas) {
- rotation = ecore_evas_rotation_get(ecore_evas);
- if (rotation == 90 || rotation == 270) {
- int temp = wl_info->window_width;
+ /* call media packet callback */
+ if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
+ ret = _camera_media_packet_data_create(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
- LOGD("swap width and height %d, %d", wl_info->window_width, wl_info->window_height);
+ if (ret == CAMERA_ERROR_NONE) {
+ ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
- wl_info->window_width = wl_info->window_height;
- wl_info->window_height = temp;
+ if (ret == CAMERA_ERROR_NONE) {
+ ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
+ cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
+ } else {
+ _camera_media_packet_data_release(mp_data, cb_info);
+ mp_data = NULL;
}
+ }
+ }
+
+ /* call evas renderer */
+ if (pkt_evas) {
+ if (cb_info->run_evas_render) {
+ mm_display_interface_evas_render(cb_info->dp_interface, pkt_evas);
} else {
- LOGW("failed to get ecore_evas.. skip rotation check");
+ LOGW("evas renderer is stopped, skip this buffer...");
+ media_packet_destroy(pkt_evas);
}
+ pkt_evas = NULL;
+ }
+
+ /* send message for preview callback return */
+ if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
+ _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, NULL, cb_info, NULL, 0);
- LOGD("evas object : %p, rotation : %d, parent id : %u, window : %d,%d,%dx%d",
- wl_info->evas_obj, rotation, wl_info->parent_id,
- wl_info->window_x, wl_info->window_y,
- wl_info->window_width, wl_info->window_height);
+_PREVIEW_CB_HANDLER_DONE:
+ if (mp_data == NULL) {
+ /* release imported bo */
+ for (i = 0 ; i < num_buffer_fd && i < BUFFER_MAX_PLANE_NUM ; i++)
+ _camera_release_imported_bo(&buffer_bo[i]);
+
+ /* unmap and unref tbm bo */
+ _camera_release_imported_bo(&data_bo);
+ _camera_release_imported_bo(&bo);
+
+ /* close imported fd */
+ for (i = 0 ; i < MUSE_NUM_FD ; i++) {
+ if (tfd[i] >= 0) {
+ close(tfd[i]);
+ tfd[i] = -1;
+ } else {
+ break;
+ }
+ }
+
+ /* return buffer */
+ _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
+
+ /*LOGD("return buffer Done");*/
+ }
+
+ return;
+}
+
+
+static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
+{
+ int i = 0;
+ int tfd_index = 0;
+ int capture_fd_main = 0;
+ int capture_fd_post = 0;
+ int capture_fd_thumb = 0;
+ unsigned char *buf_pos = NULL;
+
+ camera_image_data_s *rImage = NULL;
+ camera_image_data_s *rPostview = NULL;
+ camera_image_data_s *rThumbnail = NULL;
+
+ tbm_bo bo_main = NULL;
+ tbm_bo bo_post = NULL;
+ tbm_bo bo_thumb = NULL;
+ tbm_bo_handle bo_main_handle = {.ptr = NULL};
+ tbm_bo_handle bo_post_handle = {.ptr = NULL};
+ tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
+
+ if (!cb_info || !recv_msg || !tfd) {
+ LOGE("invalid param %p %p %p", cb_info, recv_msg, tfd);
+ return;
+ }
+
+ muse_camera_msg_get(capture_fd_main, recv_msg);
+ muse_camera_msg_get(capture_fd_post, recv_msg);
+ muse_camera_msg_get(capture_fd_thumb, recv_msg);
+
+ LOGD("capture fd %d %d %d, received fd %d %d %d",
+ capture_fd_main, capture_fd_post, capture_fd_thumb,
+ tfd[0], tfd[1], tfd[2]);
+
+ if (capture_fd_main < 0 || tfd[tfd_index] < 0) {
+ LOGE("invalid main fd %d %d", capture_fd_main, tfd[tfd_index]);
+ goto _CAPTURE_CB_HANDLER_DONE;
+ }
+
+ if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
+ LOGW("NULL callback");
+ goto _CAPTURE_CB_HANDLER_DONE;
+ }
+
+ /* import tbm bo and get virtual address */
+ if (!_camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_main, &bo_main_handle)) {
+ LOGE("failed to import fd [%d] for main", tfd[tfd_index]);
+ goto _CAPTURE_CB_HANDLER_DONE;
+ }
+
+ buf_pos = (unsigned char *)bo_main_handle.ptr;
+ rImage = (camera_image_data_s *)buf_pos;
+ rImage->data = buf_pos + sizeof(camera_image_data_s);
+ if (rImage->exif && rImage->exif_size > 0) {
+ rImage->exif = rImage->data + rImage->size;
} else {
- ret = CAMERA_ERROR_INVALID_OPERATION;
- LOGE("failed to get parent id");
+ rImage->exif = NULL;
+ rImage->exif_size = 0;
}
-_DONE:
- if (tz_surface) {
- tizen_surface_destroy(tz_surface);
- tz_surface = NULL;
+ LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
+ rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
+
+ if (capture_fd_post >= 0) {
+ /* import tbm bo and get virtual address */
+ tfd_index++;
+ if (_camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_post, &bo_post_handle)) {
+ buf_pos = (unsigned char *)bo_post_handle.ptr;
+ rPostview = (camera_image_data_s *)buf_pos;
+ LOGD("rPostview->size : %d", rPostview->size);
+ rPostview->data = buf_pos + sizeof(camera_image_data_s);
+ } else {
+ LOGE("failed to import fd [i:%d][%d] for postview", tfd_index, tfd[tfd_index]);
+ }
}
- if (tz_resource) {
- tizen_resource_destroy(tz_resource);
- tz_resource = NULL;
+ if (capture_fd_thumb >= 0) {
+ /* import tbm bo and get virtual address */
+ tfd_index++;
+ if (_camera_import_tbm_fd(cb_info->bufmgr, tfd[tfd_index], &bo_thumb, &bo_thumb_handle)) {
+ buf_pos = (unsigned char *)bo_thumb_handle.ptr;
+ rThumbnail = (camera_image_data_s *)buf_pos;
+ LOGD("rThumbnail->size : %d", rThumbnail->size);
+ rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
+ } else {
+ LOGE("failed to import fd [%d] for thumbnail", tfd[tfd_index]);
+ }
}
- if (registry) {
- wl_registry_destroy(registry);
- registry = NULL;
+ ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
+ rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
+
+_CAPTURE_CB_HANDLER_DONE:
+ /* return buffer */
+ if (capture_fd_main >= 0) {
+ _camera_release_imported_bo(&bo_main);
+ _camera_msg_return_buffer(capture_fd_main, cb_info);
}
- return ret;
+ if (capture_fd_post >= 0) {
+ _camera_release_imported_bo(&bo_post);
+ _camera_msg_return_buffer(capture_fd_post, cb_info);
+ }
+
+ if (capture_fd_thumb >= 0) {
+ _camera_release_imported_bo(&bo_thumb);
+ _camera_msg_return_buffer(capture_fd_thumb, cb_info);
+ }
+
+ for (i = 0 ; i < MUSE_NUM_FD ; i++) {
+ if (tfd[i] >= 0) {
+ LOGD("close %d", tfd[i]);
+ close(tfd[i]);
+ tfd[i] = -1;
+ } else {
+ break;
+ }
+ }
+
+ LOGD("return buffer done");
+
+ return;
}
-static int _import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
+
+static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg, int *tfd)
+{
+ int count = 0;
+ int face_fd = -1;
+ camera_detected_face_s *faces = NULL;
+
+ tbm_bo bo = NULL;
+ tbm_bo_handle bo_handle = {.ptr = NULL};
+
+ if (!cb_info || !recv_msg || !tfd) {
+ LOGE("invalid param %p %p %p", cb_info, recv_msg, tfd);
+ return;
+ }
+
+ muse_camera_msg_get(count, recv_msg);
+ muse_camera_msg_get(face_fd, recv_msg);
+
+ if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
+ LOGD("FACE_DETECTION - count %d, fd %d", count, tfd[0]);
+
+ if (tfd[0] >= 0) {
+ if (_camera_import_tbm_fd(cb_info->bufmgr, tfd[0], &bo, &bo_handle)) {
+ /* set face info */
+ faces = bo_handle.ptr;
+ }
+
+ close(tfd[0]);
+ tfd[0] = -1;
+ }
+
+ ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
+ count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
+
+ /* release bo */
+ _camera_release_imported_bo(&bo);
+ } else {
+ LOGW("skip face detection message [count %d, fd %d, cb %p]",
+ count, tfd[0], cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
+ }
+
+ /* return buffer */
+ _camera_msg_return_buffer(face_fd, cb_info);
+
+ return;
+}
+
+
+static bool _camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle)
{
tbm_bo tmp_bo = NULL;
tbm_bo_handle tmp_bo_handle = {NULL, };
- if (bufmgr == NULL || bo == NULL || bo_handle == NULL || tbm_key == 0) {
- LOGE("invalid parameter - bufmgr %p, bo %p, bo_handle %p, key %d",
- bufmgr, bo, bo_handle, tbm_key);
+ if (!bufmgr || !bo || !bo_handle || fd < 0) {
+ LOGE("invalid parameter - %p %p %p, fd %d",
+ bufmgr, bo, bo_handle, fd);
return false;
}
- tmp_bo = tbm_bo_import(bufmgr, tbm_key);
+ tmp_bo = tbm_bo_import_fd(bufmgr, (tbm_fd)fd);
if (tmp_bo == NULL) {
- LOGE("bo import failed - bufmgr %p, key %d", bufmgr, tbm_key);
+ LOGE("import failed - fd %d", fd);
return false;
}
tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
if (tmp_bo_handle.ptr == NULL) {
- LOGE("bo map failed %p", tmp_bo);
+ LOGE("map failed %p", tmp_bo);
tbm_bo_unref(tmp_bo);
tmp_bo = NULL;
return false;
return true;
}
-static void _release_imported_bo(tbm_bo *bo)
+static void _camera_release_imported_bo(tbm_bo *bo)
{
- if (bo == NULL || *bo == NULL) {
- LOGW("NULL bo");
+ if (!bo || !(*bo)) {
+ /*LOGW("NULL bo");*/
return;
}
return;
}
-static int _client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
+static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
{
int ret = CAMERA_ERROR_NONE;
gint64 end_time;
/*LOGD("Enter api : %d", api);*/
+ if (!cb_info->is_server_connected) {
+ LOGE("server is disconnected");
+ return CAMERA_ERROR_SERVICE_DISCONNECTED;
+ }
+
g_mutex_lock(&(cb_info->api_mutex[api]));
if (cb_info->api_activating[api] == 0) {
- end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
- if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
+ if (time_out == CAMERA_CB_NO_TIMEOUT) {
+ LOGW("wait for api %d", api);
+ g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
ret = cb_info->api_ret[api];
cb_info->api_activating[api] = 0;
-
- /*LOGD("return value : 0x%x", ret);*/
+ LOGW("api %d returned 0x%x", api, ret);
} else {
- ret = CAMERA_ERROR_INVALID_OPERATION;
-
- LOGE("api %d was TIMED OUT!", api);
+ end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
+ if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
+ ret = cb_info->api_ret[api];
+ cb_info->api_activating[api] = 0;
+ /*LOGD("return value : 0x%x", ret);*/
+ } else {
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ LOGE("api %d was TIMED OUT!", api);
+ }
}
} else {
ret = cb_info->api_ret[api];
cb_info->api_activating[api] = 0;
- /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
+ /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
+ }
+
+ g_mutex_unlock(&(cb_info->api_mutex[api]));
+
+ if (ret != CAMERA_ERROR_NONE)
+ LOGE("api %d : error 0x%x", api, ret);
+
+ return ret;
+}
+
+
+static void _camera_msg_send(int api, int *fds, camera_cb_info_s *cb_info,
+ int *ret, int timeout)
+{
+ int send_ret = 0;
+ char *msg = NULL;
+
+ if (!cb_info) {
+ LOGE("NULL info - api %d", api);
+
+ if (ret)
+ *ret = CAMERA_ERROR_INVALID_PARAMETER;
+
+ return;
+ }
+
+ msg = muse_core_msg_new(api, NULL);
+ if (!msg) {
+ LOGE("msg failed: api %d", api);
+
+ if (ret)
+ *ret = CAMERA_ERROR_OUT_OF_MEMORY;
+
+ return;
+ }
+
+ /*LOGD("send msg %s", msg);*/
+
+ if (cb_info->is_server_connected) {
+ __camera_update_api_waiting(cb_info, api, 1);
+
+ g_mutex_lock(&cb_info->fd_lock);
+ send_ret = muse_core_msg_send_fd(cb_info->fd, fds, msg);
+ g_mutex_unlock(&cb_info->fd_lock);
+ }
+
+ if (send_ret < 0) {
+ LOGE("msg send failed");
+ if (ret)
+ *ret = CAMERA_ERROR_INVALID_OPERATION;
+ } else {
+ if (ret)
+ *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
+ }
+
+ __camera_update_api_waiting(cb_info, api, -1);
+
+ muse_core_msg_free(msg);
+
+ return;
+}
+
+
+static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
+ int *ret, camera_msg_param *param, int timeout)
+{
+ int send_ret = 0;
+ int array_length;
+ char *msg = NULL;
+
+ if (!cb_info || !param) {
+ LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
+
+ if (ret)
+ *ret = CAMERA_ERROR_INVALID_PARAMETER;
+
+ return;
+ }
+
+ /*LOGD("type %d, name %s", param->type, param->name);*/
+
+ switch (param->type) {
+ case MUSE_TYPE_INT:
+ msg = muse_core_msg_new(api,
+ param->type, param->name, param->value.value_INT,
+ NULL);
+ break;
+ case MUSE_TYPE_STRING:
+ msg = muse_core_msg_new(api,
+ param->type, param->name, param->value.value_STRING,
+ NULL);
+ break;
+ case MUSE_TYPE_ARRAY:
+ array_length = param->value_size / sizeof(int) + \
+ (param->value_size % sizeof(int) ? 1 : 0);
+
+ msg = muse_core_msg_new(api,
+ param->type, param->name, array_length, param->value.value_ARRAY,
+ NULL);
+ break;
+ default:
+ LOGE("unknown type %d", param->type);
+ break;
+ }
+
+ if (!msg) {
+ LOGE("msg failed: api %d", api);
+
+ if (ret)
+ *ret = CAMERA_ERROR_OUT_OF_MEMORY;
+
+ return;
+ }
+
+ /*LOGD("send msg %s", msg);*/
+
+ if (cb_info->is_server_connected) {
+ __camera_update_api_waiting(cb_info, api, 1);
+
+ g_mutex_lock(&cb_info->fd_lock);
+ send_ret = muse_core_msg_send(cb_info->fd, msg);
+ g_mutex_unlock(&cb_info->fd_lock);
+ }
+
+ if (send_ret < 0) {
+ LOGE("msg send failed");
+
+ if (ret)
+ *ret = CAMERA_ERROR_INVALID_OPERATION;
+ } else {
+ if (ret)
+ *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
+ }
+
+ __camera_update_api_waiting(cb_info, api, -1);
+
+ muse_core_msg_free(msg);
+
+ return;
+}
+
+
+static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
+ int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
+{
+ int func_ret = CAMERA_ERROR_NONE;
+ int send_ret = 0;
+ char *msg = NULL;
+
+ if (!cb_info || !param0 || !param1) {
+ LOGE("invalid ptr %p %p %p : api %d",
+ cb_info, param0, param1, api);
+ func_ret = CAMERA_ERROR_INVALID_PARAMETER;
+ goto _SEND_PARAM2_INT_DONE;
+ }
+
+ /*LOGD("api %d, param0 [%s:%d], param1 [%s:%d]",
+ api,
+ param0->name, param0->value.value_INT,
+ param1->name, param1->value.value_INT);*/
+
+ msg = muse_core_msg_new(api,
+ param0->type, param0->name, param0->value.value_INT,
+ param1->type, param1->name, param1->value.value_INT,
+ NULL);
+ if (!msg) {
+ LOGE("msg failed: api %d", api);
+ func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
+ goto _SEND_PARAM2_INT_DONE;
+ }
+
+ /*LOGD("send msg [%s]", msg);*/
+
+ if (cb_info->is_server_connected) {
+ __camera_update_api_waiting(cb_info, api, 1);
+
+ g_mutex_lock(&cb_info->fd_lock);
+ send_ret = muse_core_msg_send(cb_info->fd, msg);
+ g_mutex_unlock(&cb_info->fd_lock);
+ }
+
+ if (send_ret < 0) {
+ LOGE("msg send failed");
+
+ func_ret = CAMERA_ERROR_INVALID_OPERATION;
+ } else {
+ func_ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
+ }
+
+ __camera_update_api_waiting(cb_info, api, -1);
+
+ muse_core_msg_free(msg);
+
+_SEND_PARAM2_INT_DONE:
+ if (ret)
+ *ret = func_ret;
+
+ return;
+}
+
+
+static void _camera_msg_return_buffer(int ret_fd, camera_cb_info_s *cb_info)
+{
+ camera_msg_param param;
+
+ if (ret_fd < 0) {
+ LOGW("invalid fd %d", ret_fd);
+ return;
}
- g_mutex_unlock(&(cb_info->api_mutex[api]));
+ CAMERA_MSG_PARAM_SET(param, INT, ret_fd);
- return ret;
+ _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
+
+ return;
}
+
int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
{
if (in_format <= MM_PIXEL_FORMAT_INVALID ||
case MM_PIXEL_FORMAT_NV12T:
*out_format = TBM_FORMAT_NV12;
break;
+//LCOV_EXCL_START
case MM_PIXEL_FORMAT_NV16:
*out_format = TBM_FORMAT_NV16;
break;
default:
LOGE("invalid in_format %d", in_format);
return CAMERA_ERROR_INVALID_PARAMETER;
+//LCOV_EXCL_STOP
}
return CAMERA_ERROR_NONE;
case MM_PIXEL_FORMAT_NV12T:
*mimetype = MEDIA_FORMAT_NV12;
break;
+//LCOV_EXCL_START
case MM_PIXEL_FORMAT_NV16:
*mimetype = MEDIA_FORMAT_NV16;
break;
default:
LOGE("invalid in_format %d", in_format);
return CAMERA_ERROR_INVALID_PARAMETER;
+//LCOV_EXCL_STOP
}
return CAMERA_ERROR_NONE;
}
-void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
+static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_fd,
tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
{
int total_size = 0;
frame->timestamp = stream->timestamp;
frame->num_of_planes = stream->num_planes;
- if (num_buffer_key == 0) {
+ if (num_buffer_fd == 0) {
+//LCOV_EXCL_START
/* non-zero copy */
- if (data_bo_handle == NULL || data_bo_handle->ptr == NULL) {
- LOGE("no data pointer");
+ if (!data_bo_handle || !data_bo_handle->ptr) {
+ LOGE("NULL pointer");
return;
}
frame->data.encoded_plane.data = buf_pos;
frame->data.encoded_plane.size = stream->data.encoded.length_data;
total_size = stream->data.encoded.length_data;
+ } else if (stream->format == MM_PIXEL_FORMAT_INVZ) {
+ frame->data.depth_plane.data = buf_pos;
+ frame->data.depth_plane.size = stream->data.depth.length_data;
+ total_size = stream->data.depth.length_data;
+ } else if (stream->format == MM_PIXEL_FORMAT_RGBA ||
+ stream->format == MM_PIXEL_FORMAT_ARGB) {
+ frame->data.rgb_plane.data = buf_pos;
+ frame->data.rgb_plane.size = stream->data.rgb.length_data;
+ total_size = stream->data.rgb.length_data;
} else {
switch (stream->num_planes) {
case 1:
break;
}
}
+//LCOV_EXCL_STOP
} else {
/* zero copy */
switch (stream->num_planes) {
+//LCOV_EXCL_START
case 1:
frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
frame->data.single_plane.size = stream->data.yuv420.length_yuv;
total_size = stream->data.yuv420.length_yuv;
break;
+//LCOV_EXCL_STOP
case 2:
frame->data.double_plane.y = buffer_bo_handle[0].ptr;
- if (stream->num_planes == (unsigned int)num_buffer_key)
+ if (stream->num_planes == (unsigned int)num_buffer_fd)
frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
else
frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
stream->data.yuv420sp.length_uv;
break;
case 3:
+//LCOV_EXCL_START
frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
- if (stream->num_planes == (unsigned int)num_buffer_key) {
+ if (stream->num_planes == (unsigned int)num_buffer_fd) {
frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
} else {
stream->data.yuv420p.length_u + \
stream->data.yuv420p.length_v;
break;
+//LCOV_EXCL_STOP
default:
break;
}
return;
}
-int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
+static int _camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
{
int i = 0;
int ret = CAMERA_ERROR_NONE;
camera_media_packet_data *tmp_mp_data = NULL;
+ if (!tfd) {
+ LOGE("NULL tfd");
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
if (*mp_data == NULL) {
tmp_mp_data = g_new0(camera_media_packet_data, 1);
if (tmp_mp_data) {
- tmp_mp_data->tbm_key = tbm_key;
- tmp_mp_data->num_buffer_key = num_buffer_key;
+ tmp_mp_data->ret_fd = ret_fd;
+ tmp_mp_data->fd = tfd[0];
+ tmp_mp_data->num_buffer_fd = num_buffer_fd;
tmp_mp_data->bo = bo;
- tmp_mp_data->data_bo = data_bo;
- tmp_mp_data->ref_cnt++;
- for (i = 0 ; i < num_buffer_key ; i++)
- tmp_mp_data->buffer_bo[i] = buffer_bo[i];
+ if (data_bo) {
+ /* non-zero copy */
+ tmp_mp_data->data_bo = data_bo;
+ tmp_mp_data->data_fd = tfd[1];
+ } else {
+ /* zero copy */
+ for (i = 0 ; i < num_buffer_fd ; i++) {
+ tmp_mp_data->buffer_bo[i] = buffer_bo[i];
+ tmp_mp_data->buffer_fd[i] = (tbm_fd)tfd[i + 1];
+ }
+ }
+
+ tmp_mp_data->ref_cnt++;
*mp_data = tmp_mp_data;
/*LOGD("mp_data %p", tmp_mp_data);*/
return ret;
}
-void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
+static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
{
int i = 0;
- int tbm_key = 0;
- if (mp_data == NULL || cb_info == NULL) {
- LOGE("NULL data %p or cb_info %p", mp_data, cb_info);
+ if (!mp_data || !cb_info) {
+ LOGE("NULL pointer %p %p", mp_data, cb_info);
return;
}
if (mp_data->ref_cnt > 1) {
mp_data->ref_cnt--;
- LOGD("mp_data is still referenced(current %d)", mp_data->ref_cnt);
+ LOGD("ref count %d", mp_data->ref_cnt);
} else {
- /* release imported bo */
- for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
+ /* release imported bo and close imported fd */
+ for (i = 0 ; i < mp_data->num_buffer_fd ; i++) {
tbm_bo_unref(mp_data->buffer_bo[i]);
mp_data->buffer_bo[i] = NULL;
+
+ close(mp_data->buffer_fd[i]);
+ mp_data->buffer_fd[i] = -1;
}
- /* unref tbm bo */
- _release_imported_bo(&mp_data->bo);
- _release_imported_bo(&mp_data->data_bo);
+ /* unref tbm bo and close imported fd */
+ close(mp_data->fd);
+ mp_data->fd = -1;
+ _camera_release_imported_bo(&mp_data->bo);
+
+ if (mp_data->data_bo && mp_data->data_fd >= 0) {
+ close(mp_data->data_fd);
+ mp_data->data_fd = -1;
+ }
+ _camera_release_imported_bo(&mp_data->data_bo);
/* return buffer */
- tbm_key = mp_data->tbm_key;
- muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
- cb_info->fd, cb_info, INT, tbm_key);
+ _camera_msg_return_buffer(mp_data->ret_fd, cb_info);
g_free(mp_data);
mp_data = NULL;
return;
}
-int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
+static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
camera_media_packet_data *mp_data, media_packet_h *packet)
{
media_packet_h pkt = NULL;
uint32_t bo_format = 0;
int ret = 0;
int i = 0;
- int num_buffer_key = 0;
+ int num_buffer_fd = 0;
tbm_bo *buffer_bo = NULL;
if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
buffer_bo = mp_data->buffer_bo;
- num_buffer_key = mp_data->num_buffer_key;
+ num_buffer_fd = mp_data->num_buffer_fd;
/* create tbm surface */
for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
- if (num_buffer_key > 0) {
+ if (num_buffer_fd > 0) {
switch (bo_format) {
case TBM_FORMAT_NV12:
case TBM_FORMAT_NV21:
tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
tsurf_info.planes[0].offset = 0;
- if (num_buffer_key == 1)
+ if (num_buffer_fd == 1)
tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
break;
+//LCOV_EXCL_START
case TBM_FORMAT_YUV420:
case TBM_FORMAT_YVU420:
tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
tsurf_info.planes[0].offset = 0;
- if (num_buffer_key == 1) {
+ if (num_buffer_fd == 1) {
tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
}
break;
default:
break;
+//LCOV_EXCL_STOP
}
- tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
+ tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_fd);
} else if (mp_data->data_bo) {
+//LCOV_EXCL_START
switch (bo_format) {
case TBM_FORMAT_NV12:
case TBM_FORMAT_NV21:
}
tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
+//LCOV_EXCL_STOP
}
/*LOGD("tbm surface %p", tsurf);*/
}
if (pkt_fmt_mimetype != mimetype ||
pkt_fmt_width != stream->width ||
pkt_fmt_height != stream->height) {
- LOGW("different format. current 0x%x, %dx%d, new 0x%x, %dx%d",
- pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height, mimetype, stream->width, stream->height);
+ LOGW("change fmt: current 0x%x, %dx%d",
+ pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
media_format_unref(cb_info->pkt_fmt);
cb_info->pkt_fmt = NULL;
make_pkt_fmt = true;
/* create packet format */
if (make_pkt_fmt) {
- LOGW("make new pkt_fmt - mimetype 0x%x, %dx%d", mimetype, stream->width, stream->height);
+ LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
ret = media_format_create(&cb_info->pkt_fmt);
if (ret == MEDIA_FORMAT_ERROR_NONE) {
ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
- LOGW("media_format_set_video_mime,width,height ret : 0x%x", ret);
+ LOGW("media_format_set : 0x%x", ret);
} else {
- LOGW("media_format_create failed");
+ LOGW("media_format_create failed 0x%x", ret);
}
}
tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
(void *)cb_info, &pkt);
if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGE("media_packet_create_from_tbm_surface failed");
-
+ LOGE("media_packet_create failed 0x%x", ret);
tbm_surface_destroy(tsurf);
tsurf = NULL;
}
} else {
- LOGE("failed to create tbm surface %dx%d, format %d, num_buffer_key %d, data_bo %p",
- stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
+ LOGE("tbm surface failed. %dx%d, format %d, num_buffer_fd %d, data_bo %p",
+ stream->width, stream->height, stream->format, num_buffer_fd, mp_data->data_bo);
}
if (pkt) {
- LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);
-
+ /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
/* set media packet data */
ret = media_packet_set_extra(pkt, (void *)mp_data);
if (ret != MEDIA_PACKET_ERROR_NONE) {
camera_media_packet_data *mp_data = NULL;
tbm_surface_h tsurf = NULL;
- if (pkt == NULL || cb_info == NULL) {
- LOGE("invalid parameter buffer %p, cb_info %p", pkt, cb_info);
+ if (!pkt || !cb_info) {
+ LOGE("NULL pointer %p %p", pkt, cb_info);
return MEDIA_PACKET_FINALIZE;
}
g_mutex_unlock(&cb_info->mp_data_mutex);
ret = media_packet_get_tbm_surface(pkt, &tsurf);
- if (ret != MEDIA_PACKET_ERROR_NONE) {
- LOGE("media_packet_get_tbm_surface failed 0x%x", ret);
- return MEDIA_PACKET_FINALIZE;
- }
+ if (ret != MEDIA_PACKET_ERROR_NONE)
+ LOGE("get tbm_surface failed 0x%x", ret);
if (tsurf) {
tbm_surface_destroy(tsurf);
return MEDIA_PACKET_FINALIZE;
}
-static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
+static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event, int *tfd)
{
int param1 = 0;
int param2 = 0;
- int tbm_key = 0;
- tbm_bo bo = NULL;
- tbm_bo_handle bo_handle = {NULL, };
- if (recv_msg == NULL || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
+ if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
return;
}
/*LOGD("get camera msg %s, event %d", recv_msg, event);*/
- if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
- if (!(CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) &&
- cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] == NULL &&
- cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
- LOGW("all preview callback from user are NULL");
+ g_mutex_lock(&cb_info->user_cb_mutex[event]);
+
+ if (cb_info->user_cb[event] == NULL) {
+ if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
+ event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
+ event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
+ event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
+ g_mutex_unlock(&cb_info->user_cb_mutex[event]);
+ LOGW("NULL callback for event %d, return here", event);
return;
}
- } else if (cb_info->user_cb[event] == NULL) {
- LOGW("user callback for event %d is not set", event);
- return;
+
+ /* return buffer message should be sent for some events.
+ - MUSE_CAMERA_EVENT_TYPE_PREVIEW
+ - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
+ - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
+ - MUSE_CAMERA_EVENT_TYPE_CAPTURE
+ */
}
switch (event) {
muse_camera_msg_get(by_policy, recv_msg);
LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
- previous, current, by_policy);
+ previous, current, by_policy);
((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
(camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
break;
case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
- {
- int e_type = MUSE_CAMERA_EVENT_TYPE_PREVIEW;
- int i = 0;
- int ret = 0;
- int num_buffer_key = 0;
- int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
- int data_key = 0;
- unsigned char *buf_pos = NULL;
-
- tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
- tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
- tbm_bo data_bo = NULL;
- tbm_bo_handle data_bo_handle = {.ptr = NULL};
-
- camera_preview_data_s frame;
- camera_stream_data_s *stream = NULL;
- camera_media_packet_data *mp_data = NULL;
- media_packet_h pkt = NULL;
-
- muse_camera_msg_get(tbm_key, recv_msg);
- muse_camera_msg_get(num_buffer_key, recv_msg);
- muse_camera_msg_get_array(buffer_key, recv_msg);
- muse_camera_msg_get(data_key, recv_msg);
-
- memset(&frame, 0x0, sizeof(camera_preview_data_s));
-
- if (tbm_key <= 0) {
- LOGE("invalid key %d", tbm_key);
- break;
- }
-
- if (data_key > 0) {
- /* import tbm data_bo and get virtual address */
- if (!_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
- LOGE("failed to import data key %d", data_key);
- muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
- cb_info->fd, cb_info, INT, tbm_key);
- break;
- }
- }
-
- /* import tbm bo and get virtual address */
- if (!_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
- LOGE("failed to import key %d", tbm_key);
- _release_imported_bo(&data_bo);
- muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
- cb_info->fd, cb_info, INT, tbm_key);
- break;
- }
-
- buf_pos = (unsigned char *)bo_handle.ptr;
-
- /* get stream info */
- stream = (camera_stream_data_s *)buf_pos;
-
- for (i = 0 ; i < num_buffer_key ; i++) {
- /* import buffer bo and get virtual address */
- if (!_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
- LOGE("failed to import buffer key %d", buffer_key[i]);
-
- /* release imported bo */
- _release_imported_bo(&data_bo);
- _release_imported_bo(&bo);
-
- for (i -= 1 ; i >= 0 ; i--)
- _release_imported_bo(&buffer_bo[i]);
-
- /* send return buffer */
- muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
- cb_info->fd, cb_info, INT, tbm_key);
-
- return;
- }
- }
-
- /* call preview callback */
- if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
- _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
-
- e_type = MUSE_CAMERA_EVENT_TYPE_PREVIEW;
- ((camera_preview_cb)cb_info->user_cb[e_type])(&frame, cb_info->user_data[e_type]);
- }
-
- /* call media packet callback */
- if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
- ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
-
- if (ret == CAMERA_ERROR_NONE) {
- ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
-
- e_type = MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW;
- if (ret == CAMERA_ERROR_NONE) {
- ((camera_media_packet_preview_cb)cb_info->user_cb[e_type])(pkt, cb_info->user_data[e_type]);
- } else {
- _camera_media_packet_data_release(mp_data, cb_info);
- mp_data = NULL;
- }
- }
- }
-
- /* call evas renderer */
- if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
-
- if (ret == CAMERA_ERROR_NONE) {
- ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
-
- if (ret == CAMERA_ERROR_NONE) {
- g_mutex_lock(&cb_info->evas_mutex);
-
- if (cb_info->run_evas_render)
- mm_evas_renderer_write(pkt, cb_info->evas_info);
- else {
- LOGW("evas renderer is stopped, skip this buffer...");
- media_packet_destroy(pkt);
- }
-
- pkt = NULL;
-
- g_mutex_unlock(&cb_info->evas_mutex);
- } else {
- _camera_media_packet_data_release(mp_data, cb_info);
- mp_data = NULL;
- }
- }
-#else /* TIZEN_FEATURE_EVAS_RENDERER */
- LOGW("evas renderer is not supported");
-#endif /* TIZEN_FEATURE_EVAS_RENDERER */
- }
-
- /* send message for preview callback return */
- if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
- muse_camera_msg_send_no_return(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info->fd, cb_info);
-
- if (mp_data == NULL) {
- /* release imported bo */
- for (i = 0 ; i < num_buffer_key ; i++)
- _release_imported_bo(&buffer_bo[i]);
-
- /* unmap and unref tbm bo */
- _release_imported_bo(&data_bo);
- _release_imported_bo(&bo);
-
- /* return buffer */
- muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
- cb_info->fd, cb_info, INT, tbm_key);
-
- /*LOGD("return buffer Done");*/
- }
- }
+ __camera_event_handler_preview(cb_info, recv_msg, tfd);
break;
+//LCOV_EXCL_START
case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
{
int percent = 0;
muse_camera_msg_get(percent, recv_msg);
- LOGD("HDR progress - %d \%", percent);
+ LOGD("HDR progress - %d %%", percent);
((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
}
muse_camera_msg_get(previous, recv_msg);
muse_camera_msg_get(current, recv_msg);
- LOGD("INTERRUPTED - policy %d, state previous %d, current %d",
- policy, previous, current);
+ LOGW("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
(camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
}
break;
- case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
+ case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
{
- int count = 0;
- camera_detected_face_s *faces = NULL;
-
- muse_camera_msg_get(count, recv_msg);
- muse_camera_msg_get(tbm_key, recv_msg);
-
- if (count > 0 && tbm_key > 0) {
- LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
-
- if (!_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle))
- break;
-
- /* set face info */
- faces = bo_handle.ptr;
-
- ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
-
-#if 0
- {
- int i = 0;
-
- for (i = 0 ; i < count ; i++) {
- LOGD("id[%2d] - score %d, position (%d,%d,%dx%d)",
- i, faces[i].score, faces[i].x, faces[i].y, faces[i].width, faces[i].height);
- }
- }
-#endif
+ int policy = 0;
+ int state = 0;
- /* release bo */
- _release_imported_bo(&bo);
+ muse_camera_msg_get(policy, recv_msg);
+ muse_camera_msg_get(state, recv_msg);
- /* return buffer */
- muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
- cb_info->fd, cb_info, INT, tbm_key);
+ LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
- /*LOGD("return buffer done");*/
- } else {
- LOGE("invalid message - count %d, key %d", count, tbm_key);
- }
+ ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
+ (camera_state_e)state, cb_info->user_data[event]);
}
break;
+ case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
+ __camera_event_handler_face_detection(cb_info, recv_msg, tfd);
+ break;
case MUSE_CAMERA_EVENT_TYPE_ERROR:
{
int error = 0;
(camera_state_e)current_state, cb_info->user_data[event]);
}
break;
+//LCOV_EXCL_STOP
case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
- muse_camera_msg_get(param1, recv_msg);
- muse_camera_msg_get(param2, recv_msg);
-
- /*LOGD("SUPPORTED_PREVIEW_RESOLUTION - %d x %d", param1, param2);*/
-
- if (((camera_supported_preview_resolution_cb)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
- cb_info->user_cb[event] = NULL;
- cb_info->user_data[event] = NULL;
- LOGW("stop foreach callback for SUPPORTED_PREVIEW_RESOLUTION");
- }
- break;
+ /* fall through */
case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
muse_camera_msg_get(param1, recv_msg);
muse_camera_msg_get(param2, recv_msg);
- /*LOGD("SUPPORTED_CAPTURE_RESOLUTION - %d x %d", param1, param2);*/
-
- if (((camera_supported_capture_resolution_cb)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
- cb_info->user_cb[event] = NULL;
- cb_info->user_data[event] = NULL;
- LOGW("stop foreach callback for SUPPORTED_CAPTURE_RESOLUTION");
- }
- break;
- case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
- muse_camera_msg_get(param1, recv_msg);
-
- /*LOGD("SUPPORTED_CAPTURE_FORMAT - %d ", param1);*/
-
- if (((camera_supported_capture_format_cb)cb_info->user_cb[event])((camera_pixel_format_e)param1, cb_info->user_data[event]) == false) {
- cb_info->user_cb[event] = NULL;
- cb_info->user_data[event] = NULL;
- LOGW("stop foreach callback for SUPPORTED_CAPTURE_FORMAT");
- }
- break;
- case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
- muse_camera_msg_get(param1, recv_msg);
-
- /*LOGD("SUPPORTED_PREVIEW_FORMAT - %d ", param1);*/
-
- if (((camera_supported_preview_format_cb)cb_info->user_cb[event])((camera_pixel_format_e)param1, cb_info->user_data[event]) == false) {
- cb_info->user_cb[event] = NULL;
- cb_info->user_data[event] = NULL;
- LOGW("stop foreach callback for SUPPORTED_PREVIEW_FORMAT");
- }
- break;
- case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
- muse_camera_msg_get(param1, recv_msg);
-
- /*LOGD("SUPPORTED_AF_MODE - %d ", param1);*/
-
- if (((camera_attr_supported_af_mode_cb)cb_info->user_cb[event])((camera_attr_af_mode_e)param1, cb_info->user_data[event]) == false) {
- cb_info->user_cb[event] = NULL;
- cb_info->user_data[event] = NULL;
- LOGW("stop foreach callback for SUPPORTED_AF_MODE");
- }
- break;
- case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
- muse_camera_msg_get(param1, recv_msg);
-
- /*LOGD("SUPPORTED_EXPOSURE_MODE - %d ", param1);*/
-
- if (((camera_attr_supported_exposure_mode_cb)cb_info->user_cb[event])((camera_attr_exposure_mode_e)param1, cb_info->user_data[event]) == false) {
- cb_info->user_cb[event] = NULL;
- cb_info->user_data[event] = NULL;
- LOGW("stop foreach callback for SUPPORTED_EXPOSURE_MODE");
- }
- break;
- case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
- muse_camera_msg_get(param1, recv_msg);
-
- /*LOGD("SUPPORTED_ISO - %d ", param1);*/
-
- if (((camera_attr_supported_iso_cb)cb_info->user_cb[event])((camera_attr_iso_e)param1, cb_info->user_data[event]) == false) {
- cb_info->user_cb[event] = NULL;
- cb_info->user_data[event] = NULL;
- LOGW("stop foreach callback for SUPPORTED_ISO");
- }
- break;
- case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
- muse_camera_msg_get(param1, recv_msg);
-
- /*LOGD("SUPPORTED_WHITEBALANCE - %d ", param1);*/
-
- if (((camera_attr_supported_whitebalance_cb)cb_info->user_cb[event])((camera_attr_whitebalance_e)param1, cb_info->user_data[event]) == false) {
- cb_info->user_cb[event] = NULL;
- cb_info->user_data[event] = NULL;
- LOGW("stop foreach callback for SUPPORTED_WHITEBALANCE");
- }
- break;
- case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
- muse_camera_msg_get(param1, recv_msg);
-
- /*LOGD("SUPPORTED_EFFECT - %d ", param1);*/
-
- if (((camera_attr_supported_effect_cb)cb_info->user_cb[event])((camera_attr_effect_mode_e)param1, cb_info->user_data[event]) == false) {
- cb_info->user_cb[event] = NULL;
- cb_info->user_data[event] = NULL;
- LOGW("stop foreach callback for SUPPORTED_EFFECT");
- }
- break;
- case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
- muse_camera_msg_get(param1, recv_msg);
-
- /*LOGD("SUPPORTED_SCENE_MODE - %d ", param1);*/
-
- if (((camera_attr_supported_scene_mode_cb)cb_info->user_cb[event])((camera_attr_scene_mode_e)param1, cb_info->user_data[event]) == false) {
- cb_info->user_cb[event] = NULL;
- cb_info->user_data[event] = NULL;
- LOGW("stop foreach callback for SUPPORTED_SCENE_MODE");
- }
- break;
- case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
- muse_camera_msg_get(param1, recv_msg);
-
- /*LOGD("SUPPORTED_FLASH_MODE - %d ", param1);*/
-
- if (((camera_attr_supported_flash_mode_cb)cb_info->user_cb[event])((camera_attr_flash_mode_e)param1, cb_info->user_data[event]) == false) {
- cb_info->user_cb[event] = NULL;
- cb_info->user_data[event] = NULL;
- LOGW("stop foreach callback for SUPPORTED_FLASH_MODE");
- }
- break;
- case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
- muse_camera_msg_get(param1, recv_msg);
-
- /*LOGD("SUPPORTED_FPS - %d ", param1);*/
-
- if (((camera_attr_supported_fps_cb)cb_info->user_cb[event])((camera_attr_fps_e)param1, cb_info->user_data[event]) == false) {
- cb_info->user_cb[event] = NULL;
- cb_info->user_data[event] = NULL;
- LOGW("stop foreach callback for SUPPORTED_FPS");
- }
- break;
- case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
- muse_camera_msg_get(param1, recv_msg);
-
- /*LOGD("SUPPORTED_FPS_BY_RESOLUTION - %d ", param1);*/
-
- if (((camera_attr_supported_fps_cb)cb_info->user_cb[event])((camera_attr_fps_e)param1, cb_info->user_data[event]) == false) {
- cb_info->user_cb[event] = NULL;
- cb_info->user_data[event] = NULL;
- LOGW("stop foreach callback for SUPPORTED_FPS_BY_RESOLUTION");
- }
- break;
- case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
- muse_camera_msg_get(param1, recv_msg);
-
- /*LOGD("SUPPORTED_STREAM_FLIP - %d ", param1);*/
-
- if (((camera_attr_supported_stream_flip_cb)cb_info->user_cb[event])((camera_flip_e)param1, cb_info->user_data[event]) == false) {
- cb_info->user_cb[event] = NULL;
- cb_info->user_data[event] = NULL;
- LOGW("stop foreach callback for SUPPORTED_STREAM_FLIP");
- }
- break;
- case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
- muse_camera_msg_get(param1, recv_msg);
-
- /*LOGD("SUPPORTED_STREAM_ROTATION - %d ", param1);*/
-
- if (((camera_attr_supported_stream_rotation_cb)cb_info->user_cb[event])((camera_rotation_e)param1, cb_info->user_data[event]) == false) {
- cb_info->user_cb[event] = NULL;
- cb_info->user_data[event] = NULL;
- LOGW("stop foreach callback for SUPPORTED_STREAM_ROTATION");
- }
- break;
- case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
- muse_camera_msg_get(param1, recv_msg);
-
- /*LOGD("SUPPORTED_THEATER_MODE - %d ", param1);*/
-
- if (((camera_attr_supported_theater_mode_cb)cb_info->user_cb[event])((camera_attr_theater_mode_e)param1, cb_info->user_data[event]) == false) {
- cb_info->user_cb[event] = NULL;
- cb_info->user_data[event] = NULL;
- LOGW("stop foreach callback for SUPPORTED_THEATER_MODE");
- }
- break;
- case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
- muse_camera_msg_get(param1, recv_msg);
-
- /*LOGD("SUPPORTED_PTZ_TYPE - %d ", param1);*/
+ /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
- if (((camera_attr_supported_ptz_type_cb)cb_info->user_cb[event])((camera_attr_ptz_type_e)param1, cb_info->user_data[event]) == false) {
+ if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
cb_info->user_cb[event] = NULL;
- cb_info->user_data[event] = NULL;
- LOGW("stop foreach callback for SUPPORTED_PTZ_TYPE");
- }
- break;
- case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
- {
- camera_image_data_s *rImage = NULL;
- camera_image_data_s *rPostview = NULL;
- camera_image_data_s *rThumbnail = NULL;
- unsigned char *buf_pos = NULL;
- int tbm_key_main = 0;
- int tbm_key_post = 0;
- int tbm_key_thumb = 0;
- tbm_bo bo_main = NULL;
- tbm_bo bo_post = NULL;
- tbm_bo bo_thumb = NULL;
- tbm_bo_handle bo_main_handle = {NULL, };
- tbm_bo_handle bo_post_handle = {NULL, };
- tbm_bo_handle bo_thumb_handle = {NULL, };
-
- muse_camera_msg_get(tbm_key_main, recv_msg);
- muse_camera_msg_get(tbm_key_post, recv_msg);
- muse_camera_msg_get(tbm_key_thumb, recv_msg);
-
- /*
- LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
- tbm_key_main, tbm_key_post, tbm_key_thumb);
- */
-
- if (tbm_key_main <= 0) {
- LOGE("invalid tbm_key_main %d", tbm_key_main);
- break;
- }
-
- /* import tbm bo and get virtual address */
- if (!_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle))
- break;
-
- buf_pos = (unsigned char *)bo_main_handle.ptr;
- rImage = (camera_image_data_s *)buf_pos;
- rImage->data = buf_pos + sizeof(camera_image_data_s);
-
- LOGD("image info %dx%d, size : %d", rImage->width, rImage->height, rImage->size);
-
- if (tbm_key_post > 0) {
- /* import tbm bo and get virtual address */
- if (!_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle))
- break;
-
- buf_pos = (unsigned char *)bo_post_handle.ptr;
- rPostview = (camera_image_data_s *)buf_pos;
- LOGD("rPostview->size : %d", rPostview->size);
- rPostview->data = buf_pos + sizeof(camera_image_data_s);
- }
-
- if (tbm_key_thumb > 0) {
- /* import tbm bo and get virtual address */
- if (!_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle))
- break;
-
- buf_pos = (unsigned char *)bo_thumb_handle.ptr;
-
- rThumbnail = (camera_image_data_s *)buf_pos;
- LOGD("rThumbnail->size : %d", rThumbnail->size);
- rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
- }
-
- ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
-
- /* unmap and unref tbm bo */
- _release_imported_bo(&bo_main);
-
- /* return buffer */
- tbm_key = tbm_key_main;
- muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
- cb_info->fd, cb_info, INT, tbm_key);
-
- if (tbm_key_post > 0) {
- /* unmap and unref tbm bo */
- _release_imported_bo(&bo_post);
-
- /* return buffer */
- tbm_key = tbm_key_post;
- muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
- cb_info->fd, cb_info, INT, tbm_key);
- }
-
- if (tbm_key_thumb > 0) {
- /* unmap and unref tbm bo */
- _release_imported_bo(&bo_thumb);
+ cb_info->user_data[event] = NULL;
+ LOGW("stop foreach callback for event %d", event);
+ }
+ break;
+ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
+ /* fall through */
+ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
+ /* fall through */
+ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
+ /* fall through */
+ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
+ /* fall through */
+ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
+ /* fall through */
+ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
+ /* fall through */
+ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
+ /* fall through */
+ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
+ /* fall through */
+ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
+ /* fall through */
+ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
+ /* fall through */
+ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
+ /* fall through */
+ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
+ /* fall through */
+ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
+ /* fall through */
+//LCOV_EXCL_START
+ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
+ /* fall through */
+ case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
+ muse_camera_msg_get(param1, recv_msg);
- /* return buffer */
- tbm_key = tbm_key_thumb;
- muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
- cb_info->fd, cb_info, INT, tbm_key);
- }
+ /*LOGD("event %d SUPPORTED %d ", event, param1);*/
- LOGD("return buffer done");
+ if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
+ cb_info->user_cb[event] = NULL;
+ cb_info->user_data[event] = NULL;
+ LOGW("stop foreach callback for event %d", event);
}
break;
- case MUSE_CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR:
+//LCOV_EXCL_STOP
+ case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
+ __camera_event_handler_capture(cb_info, recv_msg, tfd);
break;
default:
- LOGW("Unknown event : %d", event);
+ LOGW("unhandled event %d", event);
break;
}
+ g_mutex_unlock(&cb_info->user_cb_mutex[event]);
+
return;
}
-static bool _camera_idle_event_callback(void *data)
+static gboolean _camera_idle_event_callback(gpointer data)
{
camera_cb_info_s *cb_info = NULL;
camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
if (cam_idle_event == NULL) {
LOGE("cam_idle_event is NULL");
- return false;
+ return FALSE;
}
/* lock event */
- g_mutex_lock(&cam_idle_event->event_mutex);
+ g_mutex_lock(&g_cam_idle_event_lock);
cb_info = cam_idle_event->cb_info;
if (cb_info == NULL) {
- LOGW("camera cb_info is NULL. event %d", cam_idle_event->event);
+ LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
+ g_mutex_unlock(&g_cam_idle_event_lock);
goto IDLE_EVENT_CALLBACK_DONE;
}
/* remove event from list */
- g_mutex_lock(&cb_info->idle_event_mutex);
if (cb_info->idle_event_list)
cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
- /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
- g_mutex_unlock(&cb_info->idle_event_mutex);
+ g_mutex_unlock(&g_cam_idle_event_lock);
/* user callback */
- _client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
-
- /* send signal for waiting thread */
- g_cond_signal(&cb_info->idle_event_cond);
+ _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event, cam_idle_event->tfd);
IDLE_EVENT_CALLBACK_DONE:
- /* unlock and release event */
- g_mutex_unlock(&cam_idle_event->event_mutex);
- g_mutex_clear(&cam_idle_event->event_mutex);
-
+ /* release event */
g_free(cam_idle_event);
cam_idle_event = NULL;
- return false;
+ return FALSE;
}
-static void *_camera_msg_handler_func(gpointer data)
+static gpointer _camera_msg_handler_func(gpointer data)
{
- int ret = 0;
int api = 0;
- int event = 0;
- int event_class = 0;
+ int type = 0;
camera_message_s *cam_msg = NULL;
camera_idle_event_s *cam_idle_event = NULL;
- camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
+ camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
+ camera_cb_info_s *cb_info = NULL;
- if (cb_info == NULL) {
- LOGE("cb_info NULL");
+ if (!handler_info || !handler_info->cb_info) {
+ LOGE("NULL handler %p", handler_info);
return NULL;
}
- LOGD("start");
+ cb_info = (camera_cb_info_s *)handler_info->cb_info;
+ type = handler_info->type;
+
+ LOGD("t:%d start", type);
- g_mutex_lock(&cb_info->msg_handler_mutex);
+ g_mutex_lock(&handler_info->mutex);
- while (g_atomic_int_get(&cb_info->msg_handler_running)) {
- if (g_queue_is_empty(cb_info->msg_queue)) {
- /*LOGD("signal wait...");*/
- g_cond_wait(&cb_info->msg_handler_cond, &cb_info->msg_handler_mutex);
- /*LOGD("signal received");*/
+ while (g_atomic_int_get(&handler_info->running)) {
+ if (g_queue_is_empty(handler_info->queue)) {
+ /*LOGD("t:%d signal wait...", type);*/
+ g_cond_wait(&handler_info->cond, &handler_info->mutex);
+ /*LOGD("t:%d signal received", type);*/
- if (g_atomic_int_get(&cb_info->msg_handler_running) == 0) {
- LOGD("stop event thread");
+ if (g_atomic_int_get(&handler_info->running) == 0) {
+ LOGD("t:%d stop event thread", type);
break;
}
}
- cam_msg = (camera_message_s *)g_queue_pop_head(cb_info->msg_queue);
+ cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
- g_mutex_unlock(&cb_info->msg_handler_mutex);
+ g_mutex_unlock(&handler_info->mutex);
if (cam_msg == NULL) {
- LOGE("NULL message");
- g_mutex_lock(&cb_info->msg_handler_mutex);
+ LOGE("t:%d NULL message", type);
+ g_mutex_lock(&handler_info->mutex);
continue;
}
api = cam_msg->api;
if (api < MUSE_CAMERA_API_MAX) {
+ int ret = 0;
+
g_mutex_lock(&cb_info->api_mutex[api]);
if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
- cb_info->api_ret[api] = ret;
- cb_info->api_activating[api] = 1;
+ if (cb_info->api_waiting[api] > 0) {
+ cb_info->api_ret[api] = ret;
+ cb_info->api_activating[api] = 1;
- /*LOGD("camera api %d - return 0x%x", ret);*/
+ /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
- g_cond_signal(&cb_info->api_cond[api]);
+ g_cond_signal(&cb_info->api_cond[api]);
+ } else {
+ LOGW("no waiting for this api [%d]", api);
+ }
} else {
- LOGE("failed to get camera ret for api %d, msg %s", api, cam_msg->recv_msg);
+ LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
}
g_mutex_unlock(&cb_info->api_mutex[api]);
} else if (api == MUSE_CAMERA_CB_EVENT) {
- event = -1;
- event_class = -1;
-
- if (!muse_camera_msg_get(event, cam_msg->recv_msg) ||
- !muse_camera_msg_get(event_class, cam_msg->recv_msg)) {
- LOGE("failed to get camera event %d, class %d", event, event_class);
-
- g_free(cam_msg);
- cam_msg = NULL;
-
- g_mutex_lock(&cb_info->msg_handler_mutex);
- continue;
- }
-
- switch (event_class) {
+ switch (cam_msg->event_class) {
case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
- _client_user_callback(cb_info, cam_msg->recv_msg, event);
+ _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event, cam_msg->tfd);
break;
case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
cam_idle_event = g_new0(camera_idle_event_s, 1);
if (cam_idle_event == NULL) {
- LOGE("cam_idle_event alloc failed");
+ LOGE("t:%d cam_idle_event alloc failed", type);
break;
}
- cam_idle_event->event = event;
+ cam_idle_event->event = cam_msg->event;
cam_idle_event->cb_info = cb_info;
- g_mutex_init(&cam_idle_event->event_mutex);
- memcpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
- /*LOGD("add camera event[%d, %p] to IDLE", event, cam_idle_event);*/
+ strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
+ memcpy(cam_idle_event->tfd, cam_msg->tfd, sizeof(cam_idle_event->tfd));
+
+ /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
- g_mutex_lock(&cb_info->idle_event_mutex);
+ g_mutex_lock(&g_cam_idle_event_lock);
cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
- g_mutex_unlock(&cb_info->idle_event_mutex);
+ g_mutex_unlock(&g_cam_idle_event_lock);
g_idle_add_full(G_PRIORITY_DEFAULT,
(GSourceFunc)_camera_idle_event_callback,
NULL);
break;
default:
- LOGE("unknown camera event class %d", event_class);
+ LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
break;
}
} else {
- LOGE("unknown camera api[%d] message[%s]", api, cam_msg->recv_msg);
+ LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
}
g_free(cam_msg);
cam_msg = NULL;
- g_mutex_lock(&cb_info->msg_handler_mutex);
+ g_mutex_lock(&handler_info->mutex);
}
/* remove remained event */
- while (!g_queue_is_empty(cb_info->msg_queue)) {
- cam_msg = (camera_message_s *)g_queue_pop_head(cb_info->msg_queue);
+ while (!g_queue_is_empty(handler_info->queue)) {
+ cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
if (cam_msg) {
- LOGD("remove camera message %p", cam_msg);
+ LOGD("t:%d remove camera message %p", type, cam_msg);
free(cam_msg);
cam_msg = NULL;
} else {
- LOGW("NULL camera message");
+ LOGW("t:%d NULL camera message", type);
}
}
- g_mutex_unlock(&cb_info->msg_handler_mutex);
+ g_mutex_unlock(&handler_info->mutex);
- LOGD("return");
+ LOGD("t:%d return", type);
return NULL;
}
-static void _camera_remove_idle_event_all(camera_cb_info_s *cb_info)
+
+static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
{
camera_idle_event_s *cam_idle_event = NULL;
- gboolean ret = TRUE;
GList *list = NULL;
- gint64 end_time = 0;
if (cb_info == NULL) {
LOGE("cb_info is NULL");
return;
}
- g_mutex_lock(&cb_info->idle_event_mutex);
+ g_mutex_lock(&g_cam_idle_event_lock);
if (cb_info->idle_event_list == NULL) {
- LOGD("No idle event is remained.");
+ LOGD("No remained idle event");
+ g_mutex_unlock(&g_cam_idle_event_lock);
+ return;
+ }
+
+ list = cb_info->idle_event_list;
+
+ while (list) {
+ cam_idle_event = list->data;
+ list = g_list_next(list);
+
+ if (!cam_idle_event) {
+ LOGW("Fail to remove idle event. The event is NULL");
+ continue;
+ }
+
+ if (g_idle_remove_by_data(cam_idle_event)) {
+ LOGW("remove idle event %p done", cam_idle_event);
+
+ cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
+
+ g_free(cam_idle_event);
+ cam_idle_event = NULL;
+
+ continue;
+ }
+
+ LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
+ cam_idle_event, cam_idle_event->event);
+
+ cam_idle_event->cb_info = NULL;
+
+ cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
+ }
+
+ g_list_free(cb_info->idle_event_list);
+ cb_info->idle_event_list = NULL;
+
+ g_mutex_unlock(&g_cam_idle_event_lock);
+
+ return;
+}
+
+
+static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg, int *tfd)
+{
+ camera_message_s *cam_msg = NULL;
+
+ if (!cb_info || !msg) {
+ LOGE("NULL pointer %p %p", cb_info, msg);
+ return;
+ }
+
+ cam_msg = g_new0(camera_message_s, 1);
+ if (!cam_msg) {
+ LOGE("failed to alloc cam_msg for [%s]", msg);
+ return;
+ }
+
+ cam_msg->api = api;
+ cam_msg->event = event;
+ cam_msg->event_class = event_class;
+
+ if (tfd && tfd[0] >= 0)
+ memcpy(cam_msg->tfd, tfd, sizeof(cam_msg->tfd));
+
+ strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
+
+ /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
+
+ if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
+ g_mutex_lock(&cb_info->preview_cb_info.mutex);
+ g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
+ g_cond_signal(&cb_info->preview_cb_info.cond);
+ g_mutex_unlock(&cb_info->preview_cb_info.mutex);
+ } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
+ g_mutex_lock(&cb_info->capture_cb_info.mutex);
+ g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
+ g_cond_signal(&cb_info->capture_cb_info.cond);
+ g_mutex_unlock(&cb_info->capture_cb_info.mutex);
} else {
- list = cb_info->idle_event_list;
+ g_mutex_lock(&cb_info->msg_handler_info.mutex);
+ g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
+ g_cond_signal(&cb_info->msg_handler_info.cond);
+ g_mutex_unlock(&cb_info->msg_handler_info.mutex);
+ }
- while (list) {
- cam_idle_event = list->data;
- list = g_list_next(list);
+ cam_msg = NULL;
- if (!cam_idle_event) {
- LOGW("Fail to remove idle event. The event is NULL");
- } else {
- if (g_mutex_trylock(&cam_idle_event->event_mutex)) {
- ret = g_idle_remove_by_data(cam_idle_event);
+ return;
+}
- LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret);
- if (ret == FALSE) {
- cam_idle_event->cb_info = NULL;
- LOGW("idle callback for event %p will be called later", cam_idle_event);
- }
+static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg, int *tfd)
+{
+ int ret = CAMERA_ERROR_NONE;
+ int api = -1;
+ int api_class = -1;
+ int event = -1;
+ int event_class = -1;
+ int get_type = -1;
+ int get_index = -1;
+
+ if (!cb_info || !msg) {
+ LOGE("invalid ptr %p %p", cb_info, msg);
+ return;
+ }
- cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
+ /*LOGD("msg [%s]", msg);*/
- g_mutex_unlock(&cam_idle_event->event_mutex);
+ if (!muse_camera_msg_get(api, msg)) {
+ LOGE("failed to get camera api");
+ return;
+ }
- if (ret == TRUE) {
- g_mutex_clear(&cam_idle_event->event_mutex);
+ if (api == MUSE_CAMERA_CB_EVENT) {
+ if (!muse_camera_msg_get(event, msg) ||
+ !muse_camera_msg_get(event_class, msg)) {
+ LOGE("failed to get camera event or event_class [%s]", msg);
+ return;
+ }
+ } else {
+ if (!muse_camera_msg_get(api_class, msg)) {
+ LOGE("failed to get camera api_class [%s]", msg);
+ return;
+ }
+ }
- g_free(cam_idle_event);
- cam_idle_event = NULL;
+ if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
+ if (api >= MUSE_CAMERA_API_MAX) {
+ LOGE("invalid api %d", api);
+ return;
+ }
- LOGD("remove idle event done");
- }
- } else {
- LOGW("event lock failed. it's being called...");
+ if (!muse_camera_msg_get(ret, msg)) {
+ LOGE("failed to get camera ret");
+ return;
+ }
- end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
+ g_mutex_lock(&cb_info->api_mutex[api]);
- if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
- LOGW("signal received");
- else
- LOGW("timeout");
+ switch (api) {
+ case MUSE_CAMERA_API_CREATE:
+ if (ret != CAMERA_ERROR_NONE) {
+ g_atomic_int_set(&cb_info->msg_recv_running, 0);
+ LOGE("camera create error 0x%x. close client cb handler", ret);
+ }
+ break;
+ case MUSE_CAMERA_API_DESTROY:
+ if (ret == CAMERA_ERROR_NONE) {
+ g_atomic_int_set(&cb_info->msg_recv_running, 0);
+ LOGD("camera destroy done. close client cb handler");
+ }
+ break;
+ default:
+ muse_camera_msg_get(get_type, msg);
+ if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
+ if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
+ muse_camera_msg_get(get_index, msg);
+
+ switch (get_type) {
+ case MUSE_CAMERA_GET_TYPE_INT:
+ muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
+ break;
+ case MUSE_CAMERA_GET_TYPE_INT_PAIR:
+ muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
+ muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
+ break;
+ case MUSE_CAMERA_GET_TYPE_ARRAY:
+ if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
+ muse_core_msg_deserialize("get_value",
+ msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
+ LOGD("get display roi %d,%d,%dx%d",
+ cb_info->get_display_roi_area[0],
+ cb_info->get_display_roi_area[1],
+ cb_info->get_display_roi_area[2],
+ cb_info->get_display_roi_area[3]);
+ } else {
+ muse_core_msg_deserialize("get_value",
+ msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
+ LOGD("get geotag %lf, %lf, %lf",
+ cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
+ }
+ break;
+ case MUSE_CAMERA_GET_TYPE_STRING:
+ muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
+ break;
+ default:
+ LOGW("unknown type %d", get_type);
+ break;
}
}
+ break;
}
- g_list_free(cb_info->idle_event_list);
- cb_info->idle_event_list = NULL;
- }
+ if (cb_info->api_waiting[api] > 0) {
+ cb_info->api_ret[api] = ret;
+ cb_info->api_activating[api] = 1;
+
+ g_cond_signal(&cb_info->api_cond[api]);
+ } else {
+ LOGW("no waiting for this api [%d]", api);
+ }
- g_mutex_unlock(&cb_info->idle_event_mutex);
+ g_mutex_unlock(&cb_info->api_mutex[api]);
+ } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
+ __camera_add_msg_to_queue(cb_info, api, event, event_class, msg, tfd);
+ } else {
+ LOGW("unknown camera api %d, class %d", api, api_class);
+ }
return;
}
-static void *_camera_msg_recv_func(gpointer data)
+
+static gpointer _camera_msg_recv_func(gpointer data)
{
int i = 0;
- int ret = 0;
- int api = 0;
- int api_class = 0;
- int num_token = 0;
- int str_pos = 0;
- int prev_pos = 0;
+ int recv_length = 0;
+ int tfd[MUSE_NUM_FD] = {-1, -1, -1, -1};
char *recv_msg = NULL;
- char **parse_str = NULL;
camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
- if (cb_info == NULL) {
+ if (!cb_info) {
LOGE("cb_info NULL");
return NULL;
}
- LOGD("start");
+ LOGD("start - fd : %d", cb_info->fd);
- parse_str = (char **)malloc(sizeof(char *) * CAMERA_PARSE_STRING_SIZE);
- if (parse_str == NULL) {
- LOGE("parse_str malloc failed");
- return NULL;
- }
+ recv_msg = cb_info->recv_msg;
+
+ while (g_atomic_int_get(&cb_info->msg_recv_running)) {
+ for (i = 0 ; i < MUSE_NUM_FD ; i++)
+ tfd[i] = -1;
- for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) {
- parse_str[i] = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
- if (parse_str[i] == NULL) {
- LOGE("parse_str[%d] malloc failed", i);
- goto CB_HANDLER_EXIT;
+ recv_length = muse_core_msg_recv_fd(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH, tfd);
+ if (recv_length <= 0) {
+ cb_info->is_server_connected = FALSE;
+ LOGE("receive msg failed - server disconnected");
+ break;
}
+
+ /*
+ if (tfd[0] >= 0)
+ LOGD("%d %d %d %d", tfd[0], tfd[1], tfd[2], tfd[3]);
+ */
+
+ recv_msg[recv_length] = '\0';
+
+ /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
+
+ __camera_process_msg(cb_info, recv_msg, tfd);
}
- recv_msg = cb_info->recv_msg;
+ LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
- while (g_atomic_int_get(&cb_info->msg_recv_running)) {
- ret = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
- if (ret <= 0)
- break;
- recv_msg[ret] = '\0';
-
- str_pos = 0;
- prev_pos = 0;
- num_token = 0;
-
- /*LOGD("recvMSg : %s, length : %d", recv_msg, ret);*/
-
- /* Need to split the combined entering msgs.
- This module supports up to 200 combined msgs. */
- for (str_pos = 0; str_pos < ret; str_pos++) {
- if (recv_msg[str_pos] == '}') {
- memset(parse_str[num_token], 0x0, sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
- strncpy(parse_str[num_token], recv_msg + prev_pos, str_pos - prev_pos + 1);
- /*LOGD("splitted msg : [%s], Index : %d", parse_str[num_token], num_token);*/
- prev_pos = str_pos+1;
- num_token++;
- }
+ if (!cb_info->is_server_connected) {
+ char *error_msg = NULL;
+
+ if (cb_info->bufmgr == NULL) {
+ LOGE("No need to send error(handle is not created)");
+ return NULL;
}
- /*LOGD("num_token : %d", num_token);*/
+ if (cb_info->fd < 0) {
+ LOGE("fd is closed in client side");
+ return NULL;
+ }
- /* Re-construct to the useful single msg. */
- for (i = 0; i < num_token; i++) {
- if (i >= CAMERA_PARSE_STRING_SIZE) {
- LOGE("invalid token index %d", i);
- break;
- }
+ /* send error msg for server disconnection */
+ error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
+ MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
+ MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
+ NULL);
- api = -1;
- api_class = -1;
+ if (!error_msg) {
+ LOGE("error_msg failed");
+ return NULL;
+ }
- if (!muse_camera_msg_get(api, parse_str[i])) {
- LOGE("failed to get camera api");
- continue;
- }
+ __camera_add_msg_to_queue(cb_info,
+ MUSE_CAMERA_CB_EVENT,
+ MUSE_CAMERA_EVENT_TYPE_ERROR,
+ MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
+ error_msg,
+ NULL);
- if (api != MUSE_CAMERA_CB_EVENT) {
- if (!muse_camera_msg_get(api_class, parse_str[i])) {
- LOGE("failed to get camera api_class");
- continue;
- }
- }
+ muse_core_msg_free(error_msg);
+ error_msg = NULL;
- if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
- if (api >= MUSE_CAMERA_API_MAX) {
- LOGE("invalid api %d", api);
- continue;
- }
+ LOGE("add error msg for service disconnection done");
+ }
- g_mutex_lock(&cb_info->api_mutex[api]);
+ return NULL;
+}
- if (!muse_camera_msg_get(ret, parse_str[i])) {
- LOGE("failed to get camera ret");
- g_mutex_unlock(&cb_info->api_mutex[api]);
- continue;
- }
- cb_info->api_ret[api] = ret;
- cb_info->api_activating[api] = 1;
+static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
+ int type, const char *thread_name, camera_cb_info_s *cb_info)
+{
+ if (!handler_info || !thread_name || !cb_info) {
+ LOGE("t:%d NULL %p %p %p",
+ type, handler_info, thread_name, cb_info);
+ return false;
+ }
+
+ LOGD("t:%d", type);
- if (api == MUSE_CAMERA_API_CREATE) {
- if (ret != CAMERA_ERROR_NONE) {
- g_atomic_int_set(&cb_info->msg_recv_running, 0);
- LOGE("camera create error 0x%x. close client cb handler", ret);
- }
- } else if (api == MUSE_CAMERA_API_DESTROY) {
- if (ret == CAMERA_ERROR_NONE) {
- g_atomic_int_set(&cb_info->msg_recv_running, 0);
- LOGD("camera destroy done. close client cb handler");
- }
- }
+ handler_info->type = type;
+ handler_info->queue = g_queue_new();
+ if (handler_info->queue == NULL) {
+ LOGE("t:%d queue failed", type);
+ return false;
+ }
- g_cond_signal(&cb_info->api_cond[api]);
- g_mutex_unlock(&cb_info->api_mutex[api]);
- } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
- camera_message_s *cam_msg = g_new0(camera_message_s, 1);
- if (cam_msg == NULL) {
- LOGE("failed to alloc cam_msg");
- continue;
- }
+ g_mutex_init(&handler_info->mutex);
+ g_cond_init(&handler_info->cond);
- cam_msg->api = api;
- memcpy(cam_msg->recv_msg, parse_str[i], sizeof(cam_msg->recv_msg));
+ handler_info->cb_info = (void *)cb_info;
+ g_atomic_int_set(&handler_info->running, 1);
- /*LOGD("add camera message to queue : api %d", api);*/
+ handler_info->thread = g_thread_try_new(thread_name,
+ _camera_msg_handler_func, (gpointer)handler_info, NULL);
+ if (handler_info->thread == NULL) {
+ LOGE("t:%d thread failed", type);
- g_mutex_lock(&cb_info->msg_handler_mutex);
- g_queue_push_tail(cb_info->msg_queue, (gpointer)cam_msg);
- g_cond_signal(&cb_info->msg_handler_cond);
- g_mutex_unlock(&cb_info->msg_handler_mutex);
- } else {
- LOGW("unknown camera api %d and api_class %d", api, api_class);
- }
- }
+ g_mutex_clear(&handler_info->mutex);
+ g_cond_clear(&handler_info->cond);
+ g_queue_free(handler_info->queue);
+ handler_info->queue = NULL;
+ return false;
}
- LOGD("client cb exit");
+ LOGD("t:%d done", type);
-CB_HANDLER_EXIT:
- if (parse_str) {
- for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) {
- if (parse_str[i]) {
- free(parse_str[i]);
- parse_str[i] = NULL;
- }
- }
+ return true;
+}
+
+
+static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
+{
+ int type = 0;
- free(parse_str);
- parse_str = NULL;
+ if (!handler_info) {
+ LOGE("NULL handler");
+ return;
}
- return NULL;
+ if (!handler_info->thread) {
+ LOGW("thread is not created");
+ return;
+ }
+
+ type = handler_info->type;
+
+ LOGD("t:%d thread %p", type, handler_info->thread);
+
+ g_mutex_lock(&handler_info->mutex);
+ g_atomic_int_set(&handler_info->running, 0);
+ g_cond_signal(&handler_info->cond);
+ g_mutex_unlock(&handler_info->mutex);
+
+ g_thread_join(handler_info->thread);
+ handler_info->thread = NULL;
+
+ g_mutex_clear(&handler_info->mutex);
+ g_cond_clear(&handler_info->cond);
+ g_queue_free(handler_info->queue);
+ handler_info->queue = NULL;
+
+ LOGD("t:%d done", type);
+
+ return;
}
-static camera_cb_info_s *_client_callback_new(gint sockfd)
+
+static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
{
camera_cb_info_s *cb_info = NULL;
- gint *tmp_activating = NULL;
- gint *tmp_ret = NULL;
gint i = 0;
g_return_val_if_fail(sockfd > 0, NULL);
goto ErrorExit;
}
- g_mutex_init(&cb_info->msg_handler_mutex);
- g_cond_init(&cb_info->msg_handler_cond);
- g_mutex_init(&cb_info->idle_event_mutex);
- g_cond_init(&cb_info->idle_event_cond);
- g_mutex_init(&cb_info->mp_data_mutex);
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- g_mutex_init(&cb_info->evas_mutex);
-#endif /* TIZEN_FEATURE_EVAS_RENDERER */
+ cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
g_mutex_init(&cb_info->api_mutex[i]);
g_cond_init(&cb_info->api_cond[i]);
}
- tmp_activating = g_new0(gint, MUSE_CAMERA_API_MAX);
- if (tmp_activating == NULL) {
- LOGE("tmp_activating failed");
- goto ErrorExit;
- }
+ g_mutex_init(&cb_info->fd_lock);
+ g_mutex_init(&cb_info->mp_data_mutex);
+
+ for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
+ g_mutex_init(&cb_info->user_cb_mutex[i]);
- tmp_ret = g_new0(gint, MUSE_CAMERA_API_MAX);
- if (tmp_ret == NULL) {
- LOGE("tmp_ret failed");
+ /* message handler thread */
+ if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
+ CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
+ LOGE("msg_handler_info failed");
goto ErrorExit;
}
- cb_info->msg_queue = g_queue_new();
- if (cb_info->msg_queue == NULL) {
- LOGE("msg_queue new failed");
+ /* message handler thread for preview callback */
+ if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
+ CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
+ LOGE("preview_cb_info failed");
goto ErrorExit;
}
- g_atomic_int_set(&cb_info->msg_handler_running, 1);
- cb_info->msg_handler_thread = g_thread_try_new("camera_msg_handler",
- _camera_msg_handler_func, (gpointer)cb_info, NULL);
- if (cb_info->msg_handler_thread == NULL) {
- LOGE("message handler thread creation failed");
+ /* message handler thread for capture callback */
+ if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
+ CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
+ LOGE("capture_cb_info failed");
goto ErrorExit;
}
cb_info->fd = sockfd;
- cb_info->api_activating = tmp_activating;
- cb_info->api_ret = tmp_ret;
cb_info->preview_cb_flag = 0;
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- cb_info->evas_info = NULL;
-#endif /* TIZEN_FEATURE_EVAS_RENDERER */
+ /* message receive thread */
g_atomic_int_set(&cb_info->msg_recv_running, 1);
cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
_camera_msg_recv_func, (gpointer)cb_info, NULL);
goto ErrorExit;
}
- return cb_info;
+ /* initialize fd */
+ for (i = 0 ; i < MUSE_NUM_FD ; i++)
+ cb_info->fds[i] = -1;
+
+ cb_info->is_server_connected = TRUE;
+ return cb_info;
+//LCOV_EXCL_START
ErrorExit:
if (cb_info) {
- if (cb_info->msg_handler_thread) {
- g_mutex_lock(&cb_info->msg_handler_mutex);
- g_atomic_int_set(&cb_info->msg_handler_running, 0);
- g_cond_signal(&cb_info->msg_handler_cond);
- g_mutex_unlock(&cb_info->msg_handler_mutex);
-
- g_thread_join(cb_info->msg_handler_thread);
- g_thread_unref(cb_info->msg_handler_thread);
- cb_info->msg_handler_thread = NULL;
- }
+ __destroy_msg_handler_thread(&cb_info->msg_handler_info);
+ __destroy_msg_handler_thread(&cb_info->preview_cb_info);
+ __destroy_msg_handler_thread(&cb_info->capture_cb_info);
- for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
- g_mutex_clear(&cb_info->api_mutex[i]);
- g_cond_clear(&cb_info->api_cond[i]);
- }
+ for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
+ g_mutex_clear(&cb_info->user_cb_mutex[i]);
- g_mutex_clear(&cb_info->msg_handler_mutex);
- g_cond_clear(&cb_info->msg_handler_cond);
- g_mutex_clear(&cb_info->idle_event_mutex);
- g_cond_clear(&cb_info->idle_event_cond);
+ g_mutex_clear(&cb_info->fd_lock);
g_mutex_clear(&cb_info->mp_data_mutex);
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- g_mutex_clear(&cb_info->evas_mutex);
-#endif /* TIZEN_FEATURE_EVAS_RENDERER */
- if (cb_info->msg_queue) {
- g_queue_free(cb_info->msg_queue);
- cb_info->msg_queue = NULL;
+ for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
+ g_mutex_clear(&cb_info->api_mutex[i]);
+ g_cond_clear(&cb_info->api_cond[i]);
}
g_free(cb_info);
cb_info = NULL;
}
- if (tmp_activating) {
- g_free(tmp_activating);
- tmp_activating = NULL;
- }
- if (tmp_ret) {
- g_free(tmp_ret);
- tmp_ret = NULL;
- }
-
return NULL;
+//LCOV_EXCL_STOP
}
-static void _client_callback_destroy(camera_cb_info_s *cb_info)
+static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
{
- gint i = 0;
+ int i = 0;
g_return_if_fail(cb_info != NULL);
- LOGD("MSG receive thread[%p] destroy", cb_info->msg_recv_thread);
+ LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
g_thread_join(cb_info->msg_recv_thread);
- g_thread_unref(cb_info->msg_recv_thread);
cb_info->msg_recv_thread = NULL;
- LOGD("msg thread removed");
+ LOGD("msg_recv thread removed");
- g_mutex_lock(&cb_info->msg_handler_mutex);
- g_atomic_int_set(&cb_info->msg_handler_running, 0);
- g_cond_signal(&cb_info->msg_handler_cond);
- g_mutex_unlock(&cb_info->msg_handler_mutex);
+ /* destroy msg handler threads */
+ __destroy_msg_handler_thread(&cb_info->msg_handler_info);
+ __destroy_msg_handler_thread(&cb_info->preview_cb_info);
+ __destroy_msg_handler_thread(&cb_info->capture_cb_info);
- g_thread_join(cb_info->msg_handler_thread);
- g_thread_unref(cb_info->msg_handler_thread);
- cb_info->msg_handler_thread = NULL;
+ for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
+ g_mutex_clear(&cb_info->user_cb_mutex[i]);
- g_queue_free(cb_info->msg_queue);
- cb_info->msg_queue = NULL;
+ g_mutex_clear(&cb_info->fd_lock);
+ g_mutex_clear(&cb_info->mp_data_mutex);
for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
g_mutex_clear(&cb_info->api_mutex[i]);
g_cond_clear(&cb_info->api_cond[i]);
}
- g_mutex_clear(&cb_info->msg_handler_mutex);
- g_cond_clear(&cb_info->msg_handler_cond);
- g_mutex_clear(&cb_info->idle_event_mutex);
- g_cond_clear(&cb_info->idle_event_cond);
- g_mutex_clear(&cb_info->mp_data_mutex);
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- g_mutex_clear(&cb_info->evas_mutex);
-#endif /* TIZEN_FEATURE_EVAS_RENDERER */
-
- LOGD("event thread removed");
-
if (cb_info->fd > -1) {
- muse_core_connection_close(cb_info->fd);
+ muse_client_close(cb_info->fd);
cb_info->fd = -1;
}
tbm_bufmgr_deinit(cb_info->bufmgr);
cb_info->bufmgr = NULL;
}
- if (cb_info->api_activating) {
- g_free(cb_info->api_activating);
- cb_info->api_activating = NULL;
- }
- if (cb_info->api_ret) {
- g_free(cb_info->api_ret);
- cb_info->api_ret = NULL;
- }
if (cb_info->pkt_fmt) {
media_format_unref(cb_info->pkt_fmt);
cb_info->pkt_fmt = NULL;
}
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- if (cb_info->evas_info)
- mm_evas_renderer_destroy(&cb_info->evas_info);
-#endif /* TIZEN_FEATURE_EVAS_RENDERER */
+ if (cb_info->dp_interface) {
+ mm_display_interface_deinit(cb_info->dp_interface);
+ cb_info->dp_interface = NULL;
+ }
cb_info->preview_cb_flag = 0;
return;
}
-
+//LCOV_EXCL_START
int _camera_start_evas_rendering(camera_h camera)
{
- int ret = CAMERA_ERROR_NONE;
camera_cli_s *pc = (camera_cli_s *)camera;
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
return CAMERA_ERROR_NONE;
}
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- g_mutex_lock(&pc->cb_info->evas_mutex);
-
/* set evas render flag as RUN */
pc->cb_info->run_evas_render = true;
- ret = CAMERA_ERROR_NONE;
- g_mutex_unlock(&pc->cb_info->evas_mutex);
-#else /* TIZEN_FEATURE_EVAS_RENDERER */
- LOGW("evas renderer is not supported");
- ret = CAMERA_ERROR_NOT_SUPPORTED;
-#endif /* TIZEN_FEATURE_EVAS_RENDERER */
+ return CAMERA_ERROR_NONE;
+}
+
+
+int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_cli_s *pc = (camera_cli_s *)camera;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ LOGD("stop - keep screen %d", keep_screen);
+
+ if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
+ LOGE("EVAS surface is not set");
+ return CAMERA_ERROR_NONE;
+ }
+
+ /* set evas render flag as STOP and release buffers */
+ pc->cb_info->run_evas_render = false;
+
+ ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
+ if (ret == MM_ERROR_NONE) {
+ ret = CAMERA_ERROR_NONE;
+ } else {
+ LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ }
return ret;
}
+//LCOV_EXCL_STOP
-
-int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
+int _camera_independent_request(int api, int device_type, const char *key, int *value)
{
int ret = CAMERA_ERROR_NONE;
- camera_cli_s *pc = (camera_cli_s *)camera;
+ int sock_fd = -1;
+ int module_index = -1;
+ char *msg = NULL;
+ char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ /* create muse connection */
+ if (!key || !value) {
+ LOGE("NULL pointer");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ sock_fd = muse_client_new();
+ if (sock_fd < 0) {
+ LOGE("muse_client_new failed");
+ return CAMERA_ERROR_INVALID_OPERATION;
}
- LOGD("stop - keep screen %d", keep_screen);
+ if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
+ LOGE("muse client get module index failed");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _REQUEST_EXIT;
+ }
- if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
- LOGE("EVAS surface is not set");
- return CAMERA_ERROR_NONE;
+ msg = muse_core_msg_new(api,
+ MUSE_TYPE_INT, "module", module_index,
+ MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
+ 0);
+ if (!msg) {
+ LOGE("msg failed");
+ ret = CAMERA_ERROR_OUT_OF_MEMORY;
+ goto _REQUEST_EXIT;
}
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- g_mutex_lock(&pc->cb_info->evas_mutex);
+ ret = muse_core_msg_send(sock_fd, msg);
- /* set evas render flag as STOP and release buffers */
- pc->cb_info->run_evas_render = false;
+ muse_core_msg_free(msg);
+ msg = NULL;
- ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
- if (ret != MM_ERROR_NONE) {
- LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
+ if (ret < 0) {
+ LOGE("send msg failed");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _REQUEST_EXIT;
+ }
+
+ ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
+ if (ret <= 0) {
+ LOGE("recv msg failed %d", errno);
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _REQUEST_EXIT;
+ }
+
+ if (!muse_camera_msg_get(ret, recv_msg)) {
+ LOGE("failed to get return value from msg [%s]", recv_msg);
ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _REQUEST_EXIT;
}
- g_mutex_unlock(&pc->cb_info->evas_mutex);
-#else /* TIZEN_FEATURE_EVAS_RENDERER */
- LOGW("evas renderer is not supported");
- ret = CAMERA_ERROR_NOT_SUPPORTED;
-#endif /* TIZEN_FEATURE_EVAS_RENDERER */
+ if (ret == CAMERA_ERROR_NONE)
+ muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
+
+ LOGD("api %d - value %d", api, *value);
+
+_REQUEST_EXIT:
+ if (sock_fd > -1) {
+ muse_client_close(sock_fd);
+ sock_fd = -1;
+ }
return ret;
}
int camera_create(camera_device_e device, camera_h *camera)
{
int sock_fd = -1;
- char *sndMsg;
+ char *send_msg = NULL;
+ int send_ret = 0;
int ret = CAMERA_ERROR_NONE;
- int pid = 0;
camera_cli_s *pc = NULL;
tbm_bufmgr bufmgr = NULL;
muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
- muse_core_api_module_e muse_module = MUSE_CAMERA;
+ int module_index = -1;
int device_type = (int)device;
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!camera) {
+ LOGE("NULL pointer");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- bufmgr = tbm_bufmgr_init(-1);
- if (bufmgr == NULL) {
- LOGE("get tbm bufmgr failed");
- return CAMERA_ERROR_INVALID_OPERATION;
- }
-
- sock_fd = muse_core_client_new();
+ sock_fd = muse_client_new();
if (sock_fd < 0) {
- LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
+ LOGE("muse_client_new failed - returned fd %d", sock_fd);
ret = CAMERA_ERROR_INVALID_OPERATION;
goto ErrorExit;
}
- pid = getpid();
+ if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
+ LOGE("muse client get module index failed");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto ErrorExit;
+ }
- sndMsg = muse_core_msg_json_factory_new(api,
- MUSE_TYPE_INT, "module", muse_module,
+ send_msg = muse_core_msg_new(api,
+ MUSE_TYPE_INT, "module", module_index,
MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
- MUSE_TYPE_INT, "pid", pid,
0);
- muse_core_ipc_send_msg(sock_fd, sndMsg);
- muse_core_msg_json_factory_free(sndMsg);
+ if (!send_msg) {
+ LOGE("NULL msg");
+ ret = CAMERA_ERROR_OUT_OF_MEMORY;
+ goto ErrorExit;
+ }
+
+ send_ret = muse_core_msg_send(sock_fd, send_msg);
+
+ muse_core_msg_free(send_msg);
+ send_msg = NULL;
+
+ if (send_ret < 0) {
+ LOGE("send msg failed %d", errno);
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto ErrorExit;
+ }
pc = g_new0(camera_cli_s, 1);
if (pc == NULL) {
goto ErrorExit;
}
- pc->cb_info = _client_callback_new(sock_fd);
+ bufmgr = tbm_bufmgr_init(-1);
+ if (bufmgr == NULL) {
+ LOGE("get tbm bufmgr failed");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto ErrorExit;
+ }
+
+ pc->cb_info = _camera_client_callback_new(sock_fd);
if (pc->cb_info == NULL) {
LOGE("cb_info alloc failed");
ret = CAMERA_ERROR_OUT_OF_MEMORY;
goto ErrorExit;
}
+ sock_fd = -1;
+
LOGD("cb info : %d", pc->cb_info->fd);
- ret = _client_wait_for_cb_return(api, pc->cb_info, CALLBACK_TIME_OUT);
+ ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
+
+ pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
+
if (ret == CAMERA_ERROR_NONE) {
+ int preview_format = CAMERA_PIXEL_FORMAT_INVALID;
+ int user_buffer_supported = 0;
intptr_t handle = 0;
+
muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
if (handle == 0) {
LOGE("Receiving Handle Failed!!");
goto ErrorExit;
}
+ muse_camera_msg_get(preview_format, pc->cb_info->recv_msg);
+ muse_camera_msg_get(user_buffer_supported, pc->cb_info->recv_msg);
+
pc->remote_handle = handle;
pc->cb_info->bufmgr = bufmgr;
+ pc->cb_info->preview_format = preview_format;
+ pc->cb_info->dp_info.type = CAMERA_DISPLAY_TYPE_NONE;
+ pc->cb_info->user_buffer_supported = (gboolean)user_buffer_supported;
- ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
- if (ret != CAMERA_ERROR_NONE) {
- LOGE("init display failed 0x%x", ret);
- goto ErrorExit;
- }
+ LOGD("default preview format %d, user buffer %d",
+ preview_format, user_buffer_supported);
- LOGD("camera create 0x%x", pc->remote_handle);
*camera = (camera_h)pc;
+
+ /* get display interface handle */
+ if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
+ LOGW("display interface init failed");
} else {
goto ErrorExit;
}
return ret;
-
+//LCOV_EXCL_START
ErrorExit:
- tbm_bufmgr_deinit(bufmgr);
- bufmgr = NULL;
+ if (bufmgr) {
+ tbm_bufmgr_deinit(bufmgr);
+ bufmgr = NULL;
+ }
+
+ if (sock_fd > -1) {
+ muse_client_close(sock_fd);
+ sock_fd = -1;
+ }
if (pc) {
- _client_callback_destroy(pc->cb_info);
- pc->cb_info = NULL;
+ if (pc->cb_info) {
+ int temp_fd = pc->cb_info->fd;
+
+ /* pc->cb_info->fd should be closed,
+ because g_thread_join for msg_recv_thread is not returned
+ in _camera_client_callback_destroy. */
+ if (temp_fd > -1) {
+ pc->cb_info->fd = -1;
+ muse_client_close(temp_fd);
+ }
+
+ _camera_client_callback_destroy(pc->cb_info);
+ pc->cb_info = NULL;
+ }
g_free(pc);
pc = NULL;
}
LOGE("camera create error : 0x%x", ret);
return ret;
+//LCOV_EXCL_STOP
}
int camera_change_device(camera_h camera, camera_device_e device)
{
+ int i = 0;
int ret = CAMERA_ERROR_NONE;
muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
camera_cli_s *pc = (camera_cli_s *)camera;
+ camera_msg_param param;
- if (camera == NULL || pc->cb_info == NULL) {
- LOGE("NULL handle, INVALID_PARAMETER");
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- muse_camera_msg_send1(api, pc->cb_info->fd, pc->cb_info, ret, INT, device);
+ CAMERA_MSG_PARAM_SET(param, INT, device);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ /* reset callback and user data */
+ for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
+ pc->cb_info->user_cb[i] = NULL;
+ pc->cb_info->user_data[i] = NULL;
+ }
+ UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
+ }
return ret;
}
int camera_destroy(camera_h camera)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
int ret = CAMERA_ERROR_NONE;
muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
camera_cli_s *pc = (camera_cli_s *)camera;
- int sock_fd = 0;
- LOGD("ENTER");
-
- if (pc->cb_info == NULL) {
- LOGE("cb_info NULL, INVALID_PARAMETER");
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
+ LOGD("Enter");
+
+ if (pc->cb_info->is_server_connected)
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+ else
+ LOGW("server disconnected. release resource without send message.");
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
if (ret == CAMERA_ERROR_NONE) {
- _camera_remove_idle_event_all(pc->cb_info);
- _client_callback_destroy(pc->cb_info);
+ _camera_deactivate_idle_event_all(pc->cb_info);
+ _camera_client_callback_destroy(pc->cb_info);
pc->cb_info = NULL;
g_free(pc);
pc = NULL;
- } else {
- LOGE("camera destroy error : 0x%x", ret);
}
+ LOGD("ret : 0x%x", ret);
+
return ret;
}
int ret = CAMERA_ERROR_NONE;
muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
camera_cli_s *pc = (camera_cli_s *)camera;
- int sock_fd = 0;
+ camera_state_e current_state = CAMERA_STATE_NONE;
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ LOGD("Enter : preview format %d, display type %d",
+ pc->cb_info->preview_format, pc->cb_info->dp_info.type);
+
+ ret = camera_get_state(camera, ¤t_state);
+ if (ret != CAMERA_ERROR_NONE) {
+ LOGE("failed to get current state 0x%x", ret);
+ return ret;
}
- LOGD("start");
+ if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
+ pc->cb_info->dp_info.type != CAMERA_DISPLAY_TYPE_NONE) {
+ LOGE("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
+ pc->cb_info->dp_info.type);
+ return CAMERA_ERROR_INVALID_OPERATION;
+ }
- sock_fd = pc->cb_info->fd;
+ if (current_state == CAMERA_STATE_CREATED && pc->cb_info->user_buffer_supported) {
+ if (!_camera_allocate_preview_buffer(camera))
+ return CAMERA_ERROR_INVALID_OPERATION;
- muse_camera_msg_send_longtime(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, pc->cb_info->fds, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
+ } else {
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
+ }
- if (ret != CAMERA_ERROR_NONE) {
- LOGE("start preview failed 0x%x", ret);
- } else if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
+ if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
ret = _camera_start_evas_rendering(camera);
+ if (ret != CAMERA_ERROR_NONE) {
+ LOGE("stop preview because of error");
+ _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, NULL, pc->cb_info, NULL, 0);
+ }
}
LOGD("ret : 0x%x", ret);
return ret;
}
+
int camera_stop_preview(camera_h camera)
{
int ret = CAMERA_ERROR_NONE;
- int sock_fd = 0;
- camera_cli_s *pc = NULL;
+ camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
+ camera_state_e current_state = CAMERA_STATE_NONE;
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- pc = (camera_cli_s *)camera;
-
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
-
LOGD("Enter");
+//LCOV_EXCL_START
if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
- camera_state_e current_state = CAMERA_STATE_NONE;
-
ret = camera_get_state(camera, ¤t_state);
if (ret != CAMERA_ERROR_NONE) {
LOGE("failed to get current state 0x%x", ret);
return ret;
}
}
-
+//LCOV_EXCL_STOP
/* send stop preview message */
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ if (pc->cb_info->user_buffer_supported)
+ _camera_release_preview_buffer(camera);
+ } else if (current_state == CAMERA_STATE_PREVIEW) {
+ LOGW("restart evas rendering");
+ _camera_start_evas_rendering(camera);
+ }
LOGD("ret : 0x%x", ret);
return ret;
}
+
int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
{
- 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_START_CAPTURE;
- int sock_fd;
- int is_capturing_cb = 0;
- int is_completed_cb = 0;
- LOGD("Enter, handle :%x", pc->remote_handle);
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
+ LOGD("Enter");
- if (capturing_cb != NULL) {
- is_capturing_cb = 1;
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
- }
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
- if (completed_cb != NULL) {
- is_completed_cb = 1;
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
- }
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, is_capturing_cb, INT, is_completed_cb);
- LOGD("is_capturing_cb :%d, is_completed_cb : %d", is_capturing_cb, is_completed_cb);
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
bool camera_is_supported_continuous_capture(camera_h camera)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return false;
- }
-
int ret = CAMERA_ERROR_NONE;
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret < 0) {
+ LOGE("error is occurred 0x%x", ret);
+ ret = false;
+ }
+
+ LOGD("ret : %d", ret);
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
- LOGD("ret : 0x%x", ret);
return (bool)ret;
}
-int camera_start_continuous_capture(camera_h camera, int count, int interval, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb , void *user_data)
-{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+int camera_start_continuous_capture(camera_h camera, int count, int interval, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
+{
int ret = CAMERA_ERROR_NONE;
-
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
+ camera_msg_param param;
+ int value = 0;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
+
+ LOGD("Enter");
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
- muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, count, INT, interval);
+ value = (count << 16) | interval;
+ CAMERA_MSG_PARAM_SET(param, INT, value);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
LOGD("ret : 0x%x", ret);
return ret;
}
+
int camera_stop_continuous_capture(camera_h camera)
{
- 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_STOP_CONTINUOUS_CAPTURE;
- LOGD("Enter, handle :%x", pc->remote_handle);
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
bool camera_is_supported_face_detection(camera_h camera)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return false;
- }
int ret = CAMERA_ERROR_NONE;
-
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
- LOGD("ret : 0x%x", ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret < 0) {
+ LOGE("error is occurred 0x%x", ret);
+ ret = false;
+ }
+
+ LOGD("ret : %d", ret);
+
return (bool)ret;
}
+
bool camera_is_supported_zero_shutter_lag(camera_h camera)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return false;
- }
int ret = CAMERA_ERROR_NONE;
-
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
- LOGD("ret : 0x%x", ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret < 0) {
+ LOGE("error is occurred 0x%x", ret);
+ ret = false;
+ }
+
+ LOGD("ret : %d", ret);
+
return (bool)ret;
}
+
bool camera_is_supported_media_packet_preview_cb(camera_h camera)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return false;
- }
-
int ret = CAMERA_ERROR_NONE;
-
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
- LOGD("ret : 0x%x", ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret < 0) {
+ LOGE("error is occurred 0x%x", ret);
+ ret = false;
+ }
+
+ LOGD("ret : %d", ret);
+
return (bool)ret;
}
int camera_get_device_count(camera_h camera, int *device_count)
{
- if (camera == NULL || device_count == 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_GET_DEVICE_COUNT;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_device_count;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_device_count, pc->cb_info->recv_msg);
- *device_count = get_device_count;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
{
- 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_START_FACE_DETECTION;
- LOGD("Enter, handle :%x", pc->remote_handle);
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
+ }
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_stop_face_detection(camera_h camera)
{
- 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_STOP_FACE_DETECTION;
- LOGD("Enter, handle :%x", pc->remote_handle);
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
+ }
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_get_state(camera_h camera, camera_state_e *state)
{
- if (camera == NULL || state == 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_GET_STATE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !state) {
+ LOGE("NULL pointer %p %p", pc, state);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_state;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_state, pc->cb_info->recv_msg);
- *state = (camera_state_e)get_state;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_start_focusing(camera_h camera, bool continuous)
{
- 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_START_FOCUSING;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int is_continuous = (int)continuous;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int is_continuous = (int)continuous;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, is_continuous);
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_cancel_focusing(camera_h camera)
{
- 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_CANCEL_FOCUSING;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter, remote_handle : %td", pc->remote_handle);
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
{
+ int mm_ret = MM_ERROR_NONE;
int ret = CAMERA_ERROR_NONE;
- void *set_display_handle = NULL;
- Evas_Object *obj = NULL;
- const char *object_type = NULL;
- camera_wl_info_s *wl_info = NULL;
camera_cli_s *pc = (camera_cli_s *)camera;
camera_cb_info_s *cb_info = NULL;
- muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
camera_state_e current_state = CAMERA_STATE_NONE;
- int sock_fd = 0;
+ camera_msg_param param;
+ muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
+ muse_camera_display_info_s *dp_info = NULL;
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
return CAMERA_ERROR_INVALID_PARAMETER;
}
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
cb_info = (camera_cb_info_s *)pc->cb_info;
- sock_fd = cb_info->fd;
+ dp_info = &cb_info->dp_info;
ret = camera_get_state(camera, ¤t_state);
if (ret != CAMERA_ERROR_NONE) {
return CAMERA_ERROR_INVALID_STATE;
}
- LOGD("Enter, remote_handle : %x display : 0x%x", pc->remote_handle, display);
+ LOGD("Enter - type : %d, display : %p", type, display);
- if (type == CAMERA_DISPLAY_TYPE_NONE) {
- set_display_handle = 0;
- LOGD("display type NONE");
- } else {
- obj = (Evas_Object *)display;
- object_type = evas_object_type_get(obj);
- if (object_type) {
- if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
- /* get wayland parent id */
- if (_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
- LOGE("failed to get wayland info");
- return CAMERA_ERROR_INVALID_OPERATION;
- }
-
- set_display_handle = (void *)&pc->wl_info;
- LOGD("display type OVERLAY : handle %p", set_display_handle);
- } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
- /* evas object surface */
- set_display_handle = (void *)display;
- LOGD("display type EVAS : handle %p", set_display_handle);
-
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- g_mutex_lock(&cb_info->evas_mutex);
-
- if (cb_info->evas_info) {
- LOGW("destroy existed evas renderer %p", cb_info->evas_info);
- ret = mm_evas_renderer_destroy(&cb_info->evas_info);
- if (ret != MM_ERROR_NONE) {
- LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
- g_mutex_unlock(&cb_info->evas_mutex);
- return CAMERA_ERROR_INVALID_OPERATION;
- }
- }
-
- /* create evas renderer */
- ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
- if (ret == MM_ERROR_NONE) {
- camera_flip_e flip = CAMERA_FLIP_NONE;
- camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
- camera_rotation_e rotation = CAMERA_ROTATION_NONE;
- bool visible = 0;
- int x = 0;
- int y = 0;
- int width = 0;
- int height = 0;
-
- camera_get_display_flip(camera, &flip);
- camera_get_display_mode(camera, &mode);
- camera_get_display_rotation(camera, &rotation);
- camera_is_display_visible(camera, &visible);
- camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
-
- LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
- flip, mode, rotation, visible, x, y, width, height);
-
- ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
- ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
- ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
- ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
-
- if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
- ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
- }
+ if (type != CAMERA_DISPLAY_TYPE_NONE) {
+ /* check display interface handle */
+ if (!cb_info->dp_interface) {
+ LOGE("display interface not supported");
+ return CAMERA_ERROR_NOT_SUPPORTED;
+ }
- g_mutex_unlock(&cb_info->evas_mutex);
+ mm_ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &dp_info->parent_id);
+ if (mm_ret != MM_ERROR_NONE) {
+ LOGE("[INVALID_OPERATION] set display failed[0x%x]", mm_ret);
+ return CAMERA_ERROR_INVALID_OPERATION;
+ }
- if (ret != MM_ERROR_NONE) {
- LOGE("mm_evas_renderer error 0x%x", ret);
- return CAMERA_ERROR_INVALID_OPERATION;
- }
-#else /* TIZEN_FEATURE_EVAS_RENDERER */
- LOGE("EVAS surface is not supported");
- return CAMERA_ERROR_NOT_SUPPORTED;
-#endif /* TIZEN_FEATURE_EVAS_RENDERER */
- } else {
- LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
- } else {
- LOGE("failed to get evas object type from %p", obj);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
+ mm_ret = mm_display_interface_get_window_rect(cb_info->dp_interface, &dp_info->window_rect);
+
+ LOGD("ret 0x%x, parent_id %d, window rect %d,%d,%dx%d",
+ ret, dp_info->parent_id, dp_info->window_rect.x, dp_info->window_rect.y,
+ dp_info->window_rect.width, dp_info->window_rect.height);
+ } else if (type == CAMERA_DISPLAY_TYPE_EVAS) {
+//LCOV_EXCL_START
+ camera_flip_e flip = CAMERA_FLIP_NONE;
+ camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
+ camera_rotation_e rotation = CAMERA_ROTATION_NONE;
+ bool visible = 0;
+ int x = 0;
+ int y = 0;
+ int width = 0;
+ int height = 0;
+
+ camera_get_display_flip(camera, &flip);
+ camera_get_display_mode(camera, &mode);
+ camera_get_display_rotation(camera, &rotation);
+ camera_is_display_visible(camera, &visible);
+ camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
+
+ LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
+ flip, mode, rotation, visible, x, y, width, height);
+
+ mm_ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
+ mm_ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
+ mm_ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
+ mm_ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
+
+ if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
+ mm_ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
+//LCOV_EXCL_STOP
}
}
- pc->display_handle = (intptr_t)set_display_handle;
+ if (mm_ret != MM_ERROR_NONE) {
+ LOGE("mm_ret 0x%x failed", mm_ret);
+ return CAMERA_ERROR_INVALID_OPERATION;
+ }
+
+ dp_info->type = type;
- if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
- wl_info = &pc->wl_info;
- muse_camera_msg_send_array_and_value(api, sock_fd, cb_info, ret,
- wl_info, sizeof(camera_wl_info_s), sizeof(int), INT, type);
+ CAMERA_MSG_PARAM_SET_ARRAY(param, ARRAY, dp_info, sizeof(muse_camera_display_info_s));
- LOGD("wayland parent id : %d, window %d,%d,%dx%d",
- wl_info->parent_id, wl_info->window_x, wl_info->window_y,
- wl_info->window_width, wl_info->window_height);
- } else
- muse_camera_msg_send1(api, sock_fd, cb_info, ret, INT, type);
+ _camera_msg_send_param1(api, cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- if (ret != CAMERA_ERROR_NONE)
- LOGE("set display error 0x%x", ret);
- else if (type == CAMERA_DISPLAY_TYPE_EVAS)
- SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
+ if (ret == CAMERA_ERROR_NONE) {
+ if (type == CAMERA_DISPLAY_TYPE_EVAS)
+ SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
+ }
return ret;
}
-int camera_set_preview_resolution(camera_h camera, int width, int height)
+
+int camera_set_preview_resolution(camera_h camera, int width, int height)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
int ret = CAMERA_ERROR_NONE;
-
+ camera_state_e current_state = CAMERA_STATE_NONE;
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int value = 0;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
+ if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
+ ret = camera_get_state(camera, ¤t_state);
+ if (ret != CAMERA_ERROR_NONE) {
+ LOGE("failed to get current state 0x%x", ret);
+ return ret;
+ }
+
+ if (current_state == CAMERA_STATE_PREVIEW) {
+ ret = _camera_stop_evas_rendering(camera, true);
+ if (ret != CAMERA_ERROR_NONE)
+ return ret;
+ }
+ }
+
+ value = (width << 16) | height;
+ CAMERA_MSG_PARAM_SET(param, INT, value);
+
+ LOGD("%dx%d -> 0x%x", width, height, value);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
+ if (current_state == CAMERA_STATE_PREVIEW) {
+ LOGW("restart evas rendering");
+ _camera_start_evas_rendering(camera);
+ }
+
return ret;
}
-int camera_set_capture_resolution(camera_h camera, int width, int height)
+int camera_set_capture_resolution(camera_h camera, int width, int height)
{
- 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_SET_CAPTURE_RESOLUTION;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int value = 0;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
+ LOGD("Enter");
+
+ value = (width << 16) | height;
+ CAMERA_MSG_PARAM_SET(param, INT, value);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
int ret = CAMERA_ERROR_NONE;
int set_format = (int)format;
-
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x, capture_format: %d", pc->remote_handle, set_format);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format);
+ LOGD("Enter - format %d", set_format);
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_format);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
int ret = CAMERA_ERROR_NONE;
int set_format = (int)format;
-
+ camera_msg_param param;
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x, capture_format: %d", pc->remote_handle, set_format);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format);
+ LOGD("Enter - format %d", set_format);
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_format);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ pc->cb_info->preview_format = set_format;
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_get_preview_resolution(camera_h camera, int *width, int *height)
-{
- if (camera == NULL || width == NULL || height == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
+int camera_get_preview_resolution(camera_h camera, int *width, int *height)
+{
int ret = CAMERA_ERROR_NONE;
-
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !width || !height) {
+ LOGE("NULL pointer %p %p %p", pc, width, height);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_width;
- int get_height;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
- muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
- *width = get_width;
- *height = get_height;
+ *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
+ *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
}
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
{
int ret = CAMERA_ERROR_NONE;
int set_rotation = (int)rotation;
- camera_cli_s *pc = NULL;
-
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- if (rotation < CAMERA_ROTATION_NONE || rotation > CAMERA_ROTATION_270) {
- LOGE("Invalid rotation %d", rotation);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- pc = (camera_cli_s *)camera;
+ camera_cli_s *pc = (camera_cli_s *)camera;
+ camera_msg_param param;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
- g_mutex_lock(&pc->cb_info->evas_mutex);
-
- ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
-
- g_mutex_unlock(&pc->cb_info->evas_mutex);
-
+ ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
if (ret != MM_ERROR_NONE) {
LOGE("failed to set rotation for evas surface 0x%x", ret);
return CAMERA_ERROR_INVALID_OPERATION;
}
}
-#endif /* TIZEN_FEATURE_EVAS_RENDERER */
- muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION,
- pc->cb_info->fd, pc->cb_info, ret, INT, set_rotation);
+ CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
+
+ _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
return ret;
}
+
int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
{
int ret = CAMERA_ERROR_NONE;
- int get_rotation = CAMERA_ROTATION_NONE;
- camera_cli_s *pc = NULL;
-
- if (camera == NULL || rotation == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- pc = (camera_cli_s *)camera;
+ camera_cli_s *pc = (camera_cli_s *)camera;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !rotation) {
+ LOGE("NULL pointer %p %p", pc, rotation);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION,
- pc->cb_info->fd, pc->cb_info, ret);
+ _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
- *rotation = (camera_rotation_e)get_rotation;
- }
+ if (ret == CAMERA_ERROR_NONE)
+ *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
return ret;
}
+
int camera_set_display_flip(camera_h camera, camera_flip_e flip)
{
int ret = CAMERA_ERROR_NONE;
int set_flip = (int)flip;
- camera_cli_s *pc = NULL;
-
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- if (flip < CAMERA_FLIP_NONE || flip > CAMERA_FLIP_BOTH) {
- LOGE("Invalid flip %d", flip);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- pc = (camera_cli_s *)camera;
+ camera_cli_s *pc = (camera_cli_s *)camera;
+ camera_msg_param param;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
- g_mutex_lock(&pc->cb_info->evas_mutex);
-
- ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
-
- g_mutex_unlock(&pc->cb_info->evas_mutex);
-
+ ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
if (ret != MM_ERROR_NONE) {
LOGE("failed to set flip for evas surface 0x%x", ret);
return CAMERA_ERROR_INVALID_OPERATION;
}
}
-#endif /* TIZEN_FEATURE_EVAS_RENDERER */
- muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_FLIP,
- pc->cb_info->fd, pc->cb_info, ret, INT, set_flip);
+ CAMERA_MSG_PARAM_SET(param, INT, set_flip);
+
+ _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
return ret;
}
+
int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
{
int ret = CAMERA_ERROR_NONE;
- int get_flip = CAMERA_FLIP_NONE;
- camera_cli_s *pc = NULL;
-
- if (camera == NULL || flip == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- pc = (camera_cli_s *)camera;
+ camera_cli_s *pc = (camera_cli_s *)camera;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !flip) {
+ LOGE("NULL pointer %p %p", pc, flip);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP,
- pc->cb_info->fd, pc->cb_info, ret);
+ _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
- *flip = (camera_flip_e)get_flip;
- }
+ if (ret == CAMERA_ERROR_NONE)
+ *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
return ret;
}
+
int camera_set_display_visible(camera_h camera, bool visible)
{
int ret = CAMERA_ERROR_NONE;
int set_visible = (int)visible;
- camera_cli_s *pc = NULL;
-
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- pc = (camera_cli_s *)camera;
+ camera_cli_s *pc = (camera_cli_s *)camera;
+ camera_msg_param param;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
- g_mutex_lock(&pc->cb_info->evas_mutex);
-
- ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
-
- g_mutex_unlock(&pc->cb_info->evas_mutex);
-
+ ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
if (ret != MM_ERROR_NONE) {
LOGE("failed to set visible for evas surface 0x%x", ret);
return CAMERA_ERROR_INVALID_OPERATION;
}
}
-#endif /* TIZEN_FEATURE_EVAS_RENDERER */
- muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE,
- pc->cb_info->fd, pc->cb_info, ret, INT, set_visible);
+ CAMERA_MSG_PARAM_SET(param, INT, set_visible);
+
+ _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
return ret;
}
+
int camera_is_display_visible(camera_h camera, bool *visible)
{
int ret = CAMERA_ERROR_NONE;
- int get_visible = true;
- camera_cli_s *pc = NULL;
-
- if (camera == NULL || visible == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- pc = (camera_cli_s *)camera;
+ camera_cli_s *pc = (camera_cli_s *)camera;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !visible) {
+ LOGE("NULL pointer %p %p", pc, visible);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- muse_camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE,
- pc->cb_info->fd, pc->cb_info, ret);
+ _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_visible, pc->cb_info->recv_msg);
- *visible = (bool)get_visible;
- }
+ if (ret == CAMERA_ERROR_NONE)
+ *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
return ret;
}
+
int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
{
int ret = CAMERA_ERROR_NONE;
int set_mode = (int)mode;
- camera_cli_s *pc = NULL;
-
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- if (mode < CAMERA_DISPLAY_MODE_LETTER_BOX || mode > CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
- LOGE("Invalid mode %d", mode);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- pc = (camera_cli_s *)camera;
+ camera_cli_s *pc = (camera_cli_s *)camera;
+ camera_msg_param param;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
- g_mutex_lock(&pc->cb_info->evas_mutex);
-
- ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
-
- g_mutex_unlock(&pc->cb_info->evas_mutex);
-
+ ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
if (ret != MM_ERROR_NONE) {
LOGE("failed to set geometry for evas surface 0x%x", ret);
return CAMERA_ERROR_INVALID_OPERATION;
}
}
-#endif /* TIZEN_FEATURE_EVAS_RENDERER */
- muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_MODE,
- pc->cb_info->fd, pc->cb_info, ret, INT, set_mode);
+ CAMERA_MSG_PARAM_SET(param, INT, set_mode);
+
+ _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
return ret;
}
+
int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
{
int ret = CAMERA_ERROR_NONE;
- int get_mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
- camera_cli_s *pc = NULL;
-
- if (camera == NULL || mode == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- pc = (camera_cli_s *)camera;
+ camera_cli_s *pc = (camera_cli_s *)camera;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !mode) {
+ LOGE("NULL pointer %p %p", pc, mode);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE,
- pc->cb_info->fd, pc->cb_info, ret);
+ _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
- *mode = (camera_display_mode_e)get_mode;
- }
+ if (ret == CAMERA_ERROR_NONE)
+ *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
return ret;
}
int ret = CAMERA_ERROR_NONE;
int set_hint = (int)hint;
camera_cli_s *pc = (camera_cli_s *)camera;
+ camera_msg_param param;
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ LOGD("Enter - hint %d", set_hint);
- LOGD("set display reuse hint %d", set_hint);
+ CAMERA_MSG_PARAM_SET(param, INT, set_hint);
- muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT,
- pc->cb_info->fd, pc->cb_info, ret, INT, set_hint);
+ _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
return ret;
}
int camera_get_display_reuse_hint(camera_h camera, bool *hint)
{
int ret = CAMERA_ERROR_NONE;
- int get_hint = 0;
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
- if (camera == NULL || hint == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !hint) {
+ LOGE("NULL pointer %p %p", pc, hint);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- muse_camera_msg_send(api, pc->cb_info->fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_hint, pc->cb_info->recv_msg);
- *hint = (bool)get_hint;
-
+ *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
LOGD("display reuse hint %d", *hint);
- } else {
- LOGE("failed 0x%x", ret);
}
return ret;
int camera_get_capture_resolution(camera_h camera, int *width, int *height)
{
- if (camera == NULL || width == NULL || height == 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_GET_CAPTURE_RESOLUTION;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !width || !height) {
+ LOGE("NULL pointer %p %p %p", pc, width, height);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_width;
- int get_height;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
- muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
- *width = get_width;
- *height = get_height;
+ *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
+ *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
}
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
{
- if (camera == NULL || format == 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_GET_CAPTURE_FORMAT;
- int get_format;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !format) {
+ LOGE("NULL pointer %p %p", pc, format);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
- *format = (camera_pixel_format_e)get_format;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
-{
- if (camera == NULL || format == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
+{
int ret = CAMERA_ERROR_NONE;
-
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
- int get_format;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !format) {
+ LOGE("NULL pointer %p %p", pc, format);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
- *format = (camera_pixel_format_e)get_format;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direciton)
-{
- if (camera == NULL || facing_direciton == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
+{
int ret = CAMERA_ERROR_NONE;
-
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !facing_direction) {
+ LOGE("NULL pointer %p %p", pc, facing_direction);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_facing_direction;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_facing_direction, pc->cb_info->recv_msg);
- *facing_direciton = (camera_facing_direction_e)get_facing_direction;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
{
- if (camera == NULL || callback == 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;
- camera_cb_info_s *cb_info = (camera_cb_info_s *)pc->cb_info;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
+
+ if (!pc || !pc->cb_info || !callback) {
+ LOGE("NULL pointer %p %p", pc, callback);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
- LOGD("Enter, handle :%x", pc->remote_handle);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
- SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_USER);
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
+
+ SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
+ }
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
int camera_unset_preview_cb(camera_h camera)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", 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_UNSET_PREVIEW_CB;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret = CAMERA_ERROR_NONE;
+ LOGD("Enter");
- camera_cli_s *pc = (camera_cli_s *)camera;
- camera_cb_info_s *cb_info = (camera_cb_info_s *)pc->cb_info;
- muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- LOGD("Enter, handle :%x", pc->remote_handle);
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
+
+ UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
}
- sock_fd = pc->cb_info->fd;
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
- UNSET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_USER);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x) - handle", 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_SET_MEDIA_PACKET_PREVIEW_CB;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
}
if (callback == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
+ LOGE("NULL callback");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret = CAMERA_ERROR_NONE;
+ LOGD("Enter");
- camera_cli_s *pc = (camera_cli_s *)camera;
- muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- LOGD("Enter, handle :%x", pc->remote_handle);
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
}
- sock_fd = pc->cb_info->fd;
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
int camera_unset_media_packet_preview_cb(camera_h camera)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", 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_UNSET_MEDIA_PACKET_PREVIEW_CB;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret = CAMERA_ERROR_NONE;
+ LOGD("Enter");
- camera_cli_s *pc = (camera_cli_s *)camera;
- muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- LOGD("Enter, handle :%x", pc->remote_handle);
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
}
- sock_fd = pc->cb_info->fd;
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
{
- if (camera == NULL || callback == 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_SET_STATE_CHANGED_CB;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !callback) {
+ LOGE("NULL pointer %p %p", pc, callback);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
+ }
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
+
int camera_unset_state_changed_cb(camera_h camera)
{
- 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_UNSET_STATE_CHANGED_CB;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
+ }
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
{
- if (camera == NULL || callback == 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_SET_INTERRUPTED_CB;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !callback) {
+ LOGE("NULL pointer %p %p", pc, callback);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
+ }
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
int camera_unset_interrupted_cb(camera_h camera)
{
- 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_UNSET_INTERRUPTED_CB;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
+ }
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
+
+int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
{
- if (camera == NULL || callback == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", 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_SET_INTERRUPT_STARTED_CB;
+
+ if (!pc || !pc->cb_info || !callback) {
+ LOGE("NULL pointer %p %p", pc, callback);
return CAMERA_ERROR_INVALID_PARAMETER;
}
+
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
+ }
+
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
+}
+
+
+int camera_unset_interrupt_started_cb(camera_h camera)
+{
int ret = CAMERA_ERROR_NONE;
+ camera_cli_s *pc = (camera_cli_s *)camera;
+ muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
+ }
+
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
+}
+
+int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
+{
+ int ret = CAMERA_ERROR_NONE;
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !callback) {
+ LOGE("NULL pointer %p %p", pc, callback);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
+ }
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
int camera_unset_focus_changed_cb(camera_h camera)
{
- 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_UNSET_FOCUS_CHANGED_CB;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
+ }
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
{
- if (camera == NULL || callback == 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_SET_ERROR_CB;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !callback) {
+ LOGE("NULL pointer %p %p", pc, callback);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
+ }
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
int camera_unset_error_cb(camera_h camera)
{
- 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_UNSET_ERROR_CB;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
+ }
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb , void *user_data)
+
+int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
{
- if (camera == NULL || foreach_cb == 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_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !foreach_cb) {
+ LOGE("NULL pointer %p %p", pc, foreach_cb);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
+
+ LOGD("Enter");
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb , void *user_data)
+
+int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
{
- if (camera == NULL || foreach_cb == 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_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !foreach_cb) {
+ LOGE("NULL pointer %p %p", pc, foreach_cb);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
+
+ LOGD("Enter");
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb , void *user_data)
+
+int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
{
- if (camera == NULL || foreach_cb == 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_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !foreach_cb) {
+ LOGE("NULL pointer %p %p", pc, foreach_cb);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
+
+ LOGD("Enter");
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb , void *user_data)
+int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
{
- if (camera == NULL || foreach_cb == 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_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !foreach_cb) {
+ LOGE("NULL pointer %p %p", pc, foreach_cb);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
+
+ LOGD("Enter");
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
{
- if (camera == NULL || width == NULL || height == 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_GET_RECOMMENDED_PREVIEW_RESOLUTION;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !width || !height) {
+ LOGE("NULL pointer %p %p %p", pc, width, height);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_width;
- int get_height;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
- muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
- *width = get_width;
- *height = get_height;
+ *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
+ *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
}
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_get_lens_orientation(camera_h camera, int *angle)
{
- if (camera == NULL || angle == 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_LENS_ORIENTATION;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !angle) {
+ LOGE("NULL pointer %p %p", pc, angle);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_angle;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_angle, pc->cb_info->recv_msg);
- *angle = get_angle;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
{
- 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_THEATER_MODE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int set_mode = (int)mode;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_mode = (int)mode;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
+
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_mode);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
{
- if (camera == NULL || mode == 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_THEATER_MODE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !mode) {
+ LOGE("NULL pointer %p %p", pc, mode);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_mode;
- 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_mode, pc->cb_info->recv_msg);
- *mode = (camera_attr_theater_mode_e)get_mode;
- }
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
{
- if (camera == NULL || foreach_cb == 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_FOREACH_SUPPORTED_THEATER_MODE;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !foreach_cb) {
+ LOGE("NULL pointer %p %p", pc, foreach_cb);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
+
+ LOGD("Enter");
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
LOGD("Finish, return :%x", ret);
return ret;
}
-int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
+
+int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
{
- 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_PREVIEW_FPS;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int set_fps = (int)fps;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_fps = (int)fps;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_fps);
+
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_fps);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_set_image_quality(camera_h camera, int quality)
+int camera_attr_set_image_quality(camera_h camera, int quality)
{
- 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_IMAGE_QUALITY;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, quality);
+
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, quality);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
+
+int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
{
- if (camera == NULL || fps == 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_PREVIEW_FPS;
- int get_fps;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !fps) {
+ LOGE("NULL pointer %p %p", pc, fps);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_fps, pc->cb_info->recv_msg);
- *fps = (camera_attr_fps_e)get_fps;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_get_image_quality(camera_h camera, int *quality)
{
- if (camera == NULL || quality == 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_IMAGE_QUALITY;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !quality) {
+ LOGE("NULL pointer %p %p", pc, quality);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_quality;
- 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_quality, pc->cb_info->recv_msg);
- *quality = get_quality;
- }
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
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);
+
+ if (!pc || !pc->cb_info || !bitrate) {
+ LOGE("NULL pointer %p %p", pc, bitrate);
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);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
- 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);
+ camera_msg_param param;
+ int set_bitrate = bitrate;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
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("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
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);
+
+ if (!pc || !pc->cb_info || !interval) {
+ LOGE("NULL pointer %p %p", pc, interval);
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);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
- 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);
+ camera_msg_param param;
+ int set_gop_interval = interval;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
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("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_set_zoom(camera_h camera, int zoom)
{
- 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_ZOOM;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, zoom);
+ LOGD("Enter, remote_handle : %td", pc->remote_handle);
+
+ CAMERA_MSG_PARAM_SET(param, INT, zoom);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
+
+int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
{
- 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_AF_MODE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int set_mode = (int)mode;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_mode = (int)mode;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
- LOGD("ret : 0x%x", ret);
+
+ LOGD("Enter, remote_handle : %td", pc->remote_handle);
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_mode);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
return ret;
}
+
int camera_attr_set_af_area(camera_h camera, int x, int y)
{
- 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_AF_AREA;
- int sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, x, INT, y);
+ camera_msg_param param;
+ int value = 0;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ LOGD("Enter - %d,%d", x, y);
+
+ value = (x << 16) | y;
+ CAMERA_MSG_PARAM_SET(param, INT, value);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_clear_af_area(camera_h camera)
{
- 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_CLEAR_AF_AREA;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
+int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
-
- if (mode < CAMERA_ATTR_EXPOSURE_MODE_OFF || mode > CAMERA_ATTR_EXPOSURE_MODE_CUSTOM) {
- 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_EXPOSURE_MODE;
+ camera_msg_param param;
int set_mode = (int)mode;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
+
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_mode);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_set_exposure(camera_h camera, int value)
{
- 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_EXPOSURE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, value);
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, value);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
{
- 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_ISO;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int set_iso = (int)iso;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_iso = (int)iso;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_iso);
+
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_iso);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_set_brightness(camera_h camera, int level)
{
- 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_BRIGHTNESS;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, level);
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, level);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_set_contrast(camera_h camera, int level)
{
- 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_CONTRAST;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, level);
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, level);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
+int camera_attr_set_hue(camera_h camera, int level)
{
- 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_HUE;
+ camera_msg_param param;
- if (wb < CAMERA_ATTR_WHITE_BALANCE_NONE || wb > CAMERA_ATTR_WHITE_BALANCE_CUSTOM) {
- LOGE("invalid white balance %d", wb);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret = CAMERA_ERROR_NONE;
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, level);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
+}
+
+int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
+{
+ int ret = CAMERA_ERROR_NONE;
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int set_whitebalance = (int)wb;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_whitebalance = (int)wb;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_whitebalance);
+
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
{
- 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_EFFECT;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int set_effect = (int)effect;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_effect = (int)effect;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_effect);
+
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_effect);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
{
- 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_SCENE_MODE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int set_mode = (int)mode;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_mode = (int)mode;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
+
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_mode);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_enable_tag(camera_h camera, bool enable)
{
- 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_ENABLE_TAG;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int set_enable = (int)enable;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_enable = (int)enable;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_enable);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_set_tag_image_description(camera_h camera, const char *description)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
- if (description == 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_TAG_IMAGE_DESCRIPTION;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+
+ if (!pc || !pc->cb_info || !description) {
+ LOGE("NULL pointer %p %p", pc, description);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, description);
+
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, STRING, description);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
+int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
{
- 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_TAG_ORIENTATION;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int set_orientation = (int)orientation;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_orientation = (int)orientation;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_orientation);
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_set_tag_software(camera_h camera, const char *software)
+int camera_attr_set_tag_software(camera_h camera, const char *software)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
- if (software == 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_TAG_SOFTWARE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+
+ if (!pc || !pc->cb_info || !software) {
+ LOGE("NULL pointer %p %p", pc, software);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, software);
+
+ LOGD("Enter, remote_handle : %td", pc->remote_handle);
+
+ CAMERA_MSG_PARAM_SET(param, STRING, software);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude)
+int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
{
- 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_GEOTAG;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ double set_geotag[3] = {latitude, longitude, altitude};
+ char *msg = NULL;
+ int length = 0;
+ int send_ret = 0;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- double set_geotag[3] = { latitude, longitude, altitude };
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send_array(api, sock_fd, pc->cb_info, ret,
- set_geotag, sizeof(set_geotag), sizeof(double));
+ LOGD("Enter");
+
+ length = sizeof(set_geotag) / sizeof(int) + \
+ (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
+
+ msg = muse_core_msg_new(api,
+ MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
+ NULL);
+ if (!msg) {
+ LOGE("msg creation failed: api %d", api);
+ return CAMERA_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (pc->cb_info->is_server_connected) {
+ __camera_update_api_waiting(pc->cb_info, api, 1);
+
+ g_mutex_lock(&pc->cb_info->fd_lock);
+ send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
+ g_mutex_unlock(&pc->cb_info->fd_lock);
+ }
+
+ if (send_ret < 0) {
+ LOGE("message send failed");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ } else {
+ ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
+ }
+
+ __camera_update_api_waiting(pc->cb_info, api, -1);
+
+ muse_core_msg_free(msg);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_remove_geotag(camera_h camera)
{
- 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_REMOVE_GEOTAG;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
{
- 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_FLASH_MODE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int set_mode = (int)mode;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_mode = (int)mode;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_mode);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_get_zoom(camera_h camera, int *zoom)
{
- if (camera == NULL || zoom == 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_ZOOM;
- int get_zoom;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !zoom) {
+ LOGE("NULL pointer %p %p", pc, zoom);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_zoom, pc->cb_info->recv_msg);
- *zoom = get_zoom;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
{
- if (camera == NULL || min == NULL || max == 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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
+
+ if (!pc || !pc->cb_info || !min || !max) {
+ LOGE("NULL pointer %p %p %p", pc, min, max);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
- int get_min;
- int get_max;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
- muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
- *min = get_min;
- *max = get_max;
+ *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
+ *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
}
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
{
- if (camera == NULL || mode == 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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
+
+ if (!pc || !pc->cb_info || !mode) {
+ LOGE("NULL pointer %p %p", pc, mode);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
- int get_mode;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
- *mode = (camera_attr_af_mode_e)get_mode;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
{
- if (camera == NULL || mode == 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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
+
+ if (!pc || !pc->cb_info || !mode) {
+ LOGE("NULL pointer %p %p", pc, mode);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
- int get_mode;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
- *mode = (camera_attr_exposure_mode_e)get_mode;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
int camera_attr_get_exposure(camera_h camera, int *value)
{
- if (camera == NULL || value == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", 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_EXPOSURE;
+
+ if (!pc || !pc->cb_info || !value) {
+ LOGE("NULL pointer %p %p", pc, value);
return CAMERA_ERROR_INVALID_PARAMETER;
}
+
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
+
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
+}
+
+
+int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
+{
int ret = CAMERA_ERROR_NONE;
camera_cli_s *pc = (camera_cli_s *)camera;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
+
+ if (!pc || !pc->cb_info || !min || !max) {
+ LOGE("NULL pointer %p %p %p", pc, min, max);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
- int get_value;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_value, pc->cb_info->recv_msg);
- *value = get_value;
+ *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
+ *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
}
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
+int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
{
- if (camera == NULL || min == NULL || max == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", 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_ISO;
+
+ if (!pc || !pc->cb_info || !iso) {
+ LOGE("NULL pointer %p %p", pc, iso);
return CAMERA_ERROR_INVALID_PARAMETER;
}
+
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
+
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
+}
+
+
+int camera_attr_get_brightness(camera_h camera, int *level)
+{
int ret = CAMERA_ERROR_NONE;
camera_cli_s *pc = (camera_cli_s *)camera;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
+
+ if (!pc || !pc->cb_info || !level) {
+ LOGE("NULL pointer %p %p", pc, level);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
- int get_min;
- int get_max;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
- muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
- *min = get_min;
- *max = get_max;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
+int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
{
- if (camera == NULL || iso == 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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
+
+ if (!pc || !pc->cb_info || !min || !max) {
+ LOGE("NULL pointer %p %p %p", pc, min, max);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
- int get_iso;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_iso, pc->cb_info->recv_msg);
- *iso = (camera_attr_iso_e)get_iso;
+ *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
+ *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
}
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_get_brightness(camera_h camera, int *level)
+int camera_attr_get_contrast(camera_h camera, int *level)
{
- if (camera == NULL || level == 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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
+
+ if (!pc || !pc->cb_info || !level) {
+ LOGE("NULL pointer %p %p", pc, level);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
- int get_level;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
- *level = get_level;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
+int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
{
- if (camera == NULL || min == NULL || max == 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;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
+
+ if (!pc || !pc->cb_info || !min || !max) {
+ LOGE("NULL pointer %p %p %p", pc, min, max);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
- int get_min;
- int get_max;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
- muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
- *min = get_min;
- *max = get_max;
+ *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
+ *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
+ LOGD("min %d, max %d", *min, *max);
}
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_get_contrast(camera_h camera, int *level)
+int camera_attr_get_hue(camera_h camera, int *level)
{
- if (camera == NULL || level == 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_CONTRAST;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
+
+ if (!pc || !pc->cb_info || !level) {
+ LOGE("NULL pointer %p %p", pc, level);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_level;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
- *level = get_level;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_get_contrast_range(camera_h camera, int *min , int *max)
+int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
{
- if (camera == NULL || min == NULL || max == 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_CONTRAST_RANGE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
+
+ if (!pc || !pc->cb_info || !min || !max) {
+ LOGE("NULL pointer %p %p %p", pc, min, max);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_min;
- int get_max;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
- muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
- *min = get_min;
- *max = get_max;
+ *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
+ *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
+ LOGD("min %d, max %d", *min, *max);
}
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
+int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
{
- if (camera == NULL || wb == 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_WHITEBALANCE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !wb) {
+ LOGE("NULL pointer %p %p", pc, wb);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_wb;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_wb, pc->cb_info->recv_msg);
- *wb = (camera_attr_whitebalance_e)get_wb;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
{
- if (camera == NULL || effect == 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_EFFECT;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !effect) {
+ LOGE("NULL pointer %p %p", pc, effect);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_effect;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_effect, pc->cb_info->recv_msg);
- *effect = (camera_attr_effect_mode_e)get_effect;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
+int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
{
- if (camera == NULL || mode == 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_SCENE_MODE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !mode) {
+ LOGE("NULL pointer %p %p", pc, mode);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_mode;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
- *mode = (camera_attr_scene_mode_e)get_mode;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
+int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
{
- if (camera == NULL || enable == 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_IS_ENABLED_TAG;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !enable) {
+ LOGE("NULL pointer %p %p", pc, enable);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_enabled;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
- *enable = (bool)get_enabled;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_get_tag_image_description(camera_h camera, char **description)
+int camera_attr_get_tag_image_description(camera_h camera, char **description)
{
- if (camera == NULL || description == 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_TAG_IMAGE_DESCRIPTION;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !description) {
+ LOGE("NULL pointer %p %p", pc, description);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- char get_description[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,};
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get_string(get_description, pc->cb_info->recv_msg);
- *description = strdup(get_description);
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
{
- if (camera == NULL || orientation == 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_TAG_ORIENTATION;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !orientation) {
+ LOGE("NULL pointer %p %p", pc, orientation);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_orientation;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_orientation, pc->cb_info->recv_msg);
- *orientation = (camera_attr_tag_orientation_e)get_orientation;
- LOGD("success, orientation : %d", *orientation);
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_get_tag_software(camera_h camera, char **software)
{
- if (camera == NULL || software == 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_TAG_SOFTWARE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !software) {
+ LOGE("NULL pointer %p %p", pc, software);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- char get_software[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,};
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get_string(get_software, pc->cb_info->recv_msg);
- *software = strdup(get_software);
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude)
+int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
{
- if (camera == NULL || latitude == NULL || longitude == NULL || altitude == 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_GEOTAG;
- double get_geotag[3] = {0,};
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
+ LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
+ LOGD("Enter");
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get_array(get_geotag, pc->cb_info->recv_msg);
- *latitude = get_geotag[0];
- *longitude = get_geotag[1];
- *altitude = get_geotag[2];
-
- LOGD("ret : 0x%x", ret);
- } else {
- LOGE("Returned value is not valid : 0x%x", ret);
+ *latitude = pc->cb_info->get_geotag[0];
+ *longitude = pc->cb_info->get_geotag[1];
+ *altitude = pc->cb_info->get_geotag[2];
}
+ LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
+int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
{
- if (camera == NULL || mode == 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_FLASH_MODE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !mode) {
+ LOGE("NULL pointer %p %p", pc, mode);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_mode;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
- *mode = (camera_attr_flash_mode_e)get_mode;
- }
LOGD("ret : 0x%x", ret);
+
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;
- 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;
-
- if (state == NULL) {
- LOGE("invalid pointer for state");
+ if (!state) {
+ LOGE("NULL pointer");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- 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);
+ ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
+ (int)device, "get_flash_state", &get_flash_state);
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;
+ LOGD("flash state %d", *state);
+ } else {
+ LOGE("failed 0x%x", ret);
}
return ret;
int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
{
- if (camera == NULL || foreach_cb == 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_FOREACH_SUPPORTED_AF_MODE;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !foreach_cb) {
+ LOGE("NULL pointer %p %p", pc, foreach_cb);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
+
+ LOGD("Enter");
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb , void *user_data)
+int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
{
- if (camera == NULL || foreach_cb == 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_FOREACH_SUPPORTED_EXPOSURE_MODE;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !foreach_cb) {
+ LOGE("NULL pointer %p %p", pc, foreach_cb);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
+
+ LOGD("Enter");
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
{
- if (camera == NULL || foreach_cb == 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_FOREACH_SUPPORTED_ISO;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !foreach_cb) {
+ LOGE("NULL pointer %p %p", pc, foreach_cb);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
+
+ LOGD("Enter");
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb , void *user_data)
+int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
{
- if (camera == NULL || foreach_cb == 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_FOREACH_SUPPORTED_WHITEBALANCE;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !foreach_cb) {
+ LOGE("NULL pointer %p %p", pc, foreach_cb);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
+
+ LOGD("Enter");
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb , void *user_data)
+int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
{
- if (camera == NULL || foreach_cb == 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_FOREACH_SUPPORTED_EFFECT;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !foreach_cb) {
+ LOGE("NULL pointer %p %p", pc, foreach_cb);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
+
+ LOGD("Enter");
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb , void *user_data)
+int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
{
- if (camera == NULL || foreach_cb == 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_FOREACH_SUPPORTED_SCENE_MODE;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !foreach_cb) {
+ LOGE("NULL pointer %p %p", pc, foreach_cb);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
+
+ LOGD("Enter");
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb , void *user_data)
+int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
{
- if (camera == NULL || foreach_cb == 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_FOREACH_SUPPORTED_FLASH_MODE;
- LOGD("Enter, handle :%x", pc->remote_handle);
-
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info || !foreach_cb) {
+ LOGE("NULL pointer %p %p", pc, foreach_cb);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
+
+ LOGD("Enter");
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb , void *user_data)
+int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
{
- if (camera == NULL || foreach_cb == 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_FOREACH_SUPPORTED_FPS;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !foreach_cb) {
+ LOGE("NULL pointer %p %p", pc, foreach_cb);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, handle :%x", pc->remote_handle);
+
+ LOGD("Enter");
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
- LOGD("Enter, handle :%x", pc->remote_handle);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ LOGD("Enter, handle :%td", pc->remote_handle);
+
return ret;
}
+
int camera_attr_foreach_supported_fps_by_resolution(camera_h camera, int width, int height, camera_attr_supported_fps_cb foreach_cb, void *user_data)
{
- if (camera == NULL || foreach_cb == 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_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int value = 0;
+
+ if (!pc || !pc->cb_info || !foreach_cb) {
+ LOGE("NULL pointer %p %p", pc, foreach_cb);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, handle :%x", pc->remote_handle);
+
+ LOGD("Enter");
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
- muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
+ value = (width << 16) | height;
+ CAMERA_MSG_PARAM_SET(param, INT, value);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
+
int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
{
- if (camera == NULL || foreach_cb == 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_FOREACH_SUPPORTED_STREAM_FLIP;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !foreach_cb) {
+ LOGE("NULL pointer %p %p", pc, foreach_cb);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, handle :%x", pc->remote_handle);
+
+ LOGD("Enter");
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
{
- if (camera == NULL || foreach_cb == 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_FOREACH_SUPPORTED_STREAM_ROTATION;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !foreach_cb) {
+ LOGE("NULL pointer %p %p", pc, foreach_cb);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, handle :%x", pc->remote_handle);
+
+ LOGD("Enter");
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_set_stream_rotation(camera_h camera , camera_rotation_e rotation)
+int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
{
- 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_STREAM_ROTATION;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int set_rotation = (int)rotation;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_rotation = (int)rotation;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_rotation);
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_get_stream_rotation(camera_h camera , camera_rotation_e *rotation)
+int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
{
- if (camera == NULL || rotation == 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_STREAM_ROTATION;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !rotation) {
+ LOGE("NULL pointer %p %p", pc, rotation);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_rotation;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
- *rotation = (camera_rotation_e)get_rotation;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_set_stream_flip(camera_h camera , camera_flip_e flip)
+int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
{
- 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_STREAM_FLIP;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int set_flip = (int)flip;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_flip = (int)flip;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_flip);
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_flip);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_get_stream_flip(camera_h camera , camera_flip_e *flip)
+int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
{
- if (camera == NULL || flip == 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_STREAM_FLIP;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !flip) {
+ LOGE("NULL pointer %p %p", pc, flip);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_flip;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
- *flip = (camera_flip_e)get_flip;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
{
- 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_HDR_MODE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int set_mode = (int)mode;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_mode = (int)mode;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_mode);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
- if (mode == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x) - mode", 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_HDR_MODE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !mode) {
+ LOGE("NULL pointer %p %p", pc, mode);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_mode;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
- *mode = (camera_attr_hdr_mode_e)get_mode;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
bool camera_attr_is_supported_hdr_capture(camera_h camera)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return false;
- }
-
int ret = CAMERA_ERROR_NONE;
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
- LOGD("ret : 0x%x", ret);
+
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret < 0) {
+ LOGE("error is occurred 0x%x", ret);
+ ret = false;
+ }
+
+ LOGD("ret : %d", ret);
+
return (bool)ret;
}
int ret = CAMERA_ERROR_NONE;
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
- int sock_fd;
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ LOGD("Enter");
- sock_fd = pc->cb_info->fd;
+ if (!camera_attr_is_supported_hdr_capture(camera)) {
+ LOGE("HDR not supported");
+ return CAMERA_ERROR_NOT_SUPPORTED;
+ }
- LOGD("Enter, handle :%x", pc->remote_handle);
+ if (!callback) {
+ LOGE("NULL callback");
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
- if (callback == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
}
LOGD("ret : 0x%x", ret);
int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
{
- 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_UNSET_HDR_CAPTURE_PROGRESS_CB;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, handle :%x", pc->remote_handle);
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
+
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
+
+ g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
+ }
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_enable_anti_shake(camera_h camera, bool enable)
{
- 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_ENABLE_ANTI_SHAKE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int set_enable = (int)enable;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_enable = (int)enable;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_enable);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
-int camera_attr_is_enabled_anti_shake(camera_h camera , bool *enabled)
+int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
- if (enabled == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x) - enabled", 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_IS_ENABLED_ANTI_SHAKE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !enabled) {
+ LOGE("NULL pointer %p %p", pc, enabled);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_enabled;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
- *enabled = (bool)get_enabled;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
bool camera_attr_is_supported_anti_shake(camera_h camera)
{
-
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return false;
- }
-
int ret = CAMERA_ERROR_NONE;
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
- LOGD("ret : 0x%x", ret);
- return ret;
+
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret < 0) {
+ LOGE("error is occurred 0x%x", ret);
+ ret = false;
+ }
+
+ LOGD("ret : %d", ret);
+
+ return (bool)ret;
}
int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
{
- 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_ENABLE_VIDEO_STABILIZATION;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int set_enable = (int)enable;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_enable = (int)enable;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_enable);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
- if (enabled == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x) - enabled", 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_IS_ENABLED_VIDEO_STABILIZATION;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !enabled) {
+ LOGE("NULL pointer %p %p", pc, enabled);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_enabled;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
- *enabled = (bool)get_enabled;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
bool camera_attr_is_supported_video_stabilization(camera_h camera)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return false;
- }
-
int ret = CAMERA_ERROR_NONE;
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
- LOGD("ret : 0x%x", ret);
- return ret;
+
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret < 0) {
+ LOGE("error is occurred 0x%x", ret);
+ ret = false;
+ }
+
+ LOGD("ret : %d", ret);
+
+ return (bool)ret;
}
int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
{
- 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_ENABLE_AUTO_CONTRAST;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int set_enable = (int)enable;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_enable = (int)enable;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_enable);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
- }
- if (enabled == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x) - enabled", 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_IS_ENABLED_AUTO_CONTRAST;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !enabled) {
+ LOGE("NULL pointer %p %p", pc, enabled);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int get_enabled;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
- *enabled = (bool)get_enabled;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
bool camera_attr_is_supported_auto_contrast(camera_h camera)
{
- if (camera == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return false;
- }
-
int ret = CAMERA_ERROR_NONE;
camera_cli_s *pc = (camera_cli_s *)camera;
muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
- LOGD("ret : 0x%x", ret);
- return ret;
+
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret < 0) {
+ LOGE("error is occurred 0x%x", ret);
+ ret = false;
+ }
+
+ LOGD("ret : %d", ret);
+
+ return (bool)ret;
}
int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
{
- 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_DISABLE_SHUTTER_SOUND;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_msg_param param;
+ int set_disable = (int)disable;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- int set_disable = (int)disable;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_disable);
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_disable);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
{
- 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;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
+ camera_msg_param param0;
+ camera_msg_param param1;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret = CAMERA_ERROR_NONE;
- int sock_fd = pc->cb_info->fd;
- int set_move_type = (int)move_type;
- int set_pan_step = pan_step;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param0, INT, move_type);
+ CAMERA_MSG_PARAM_SET(param1, INT, pan_step);
+
+ _camera_msg_send_param2_int(api, pc->cb_info, &ret,
+ ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, set_move_type, INT, set_pan_step);
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_get_pan(camera_h camera, int *pan_step)
{
- if (camera == NULL || pan_step == 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;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
+
+ if (!pc || !pc->cb_info || !pan_step) {
+ LOGE("NULL pointer %p %p", pc, pan_step);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret = CAMERA_ERROR_NONE;
- int sock_fd = pc->cb_info->fd;
- int get_pan_step;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
+ LOGD("Enter");
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_pan_step, pc->cb_info->recv_msg);
- *pan_step = get_pan_step;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
{
- if (camera == NULL || min == NULL || max == 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;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
+
+ if (!pc || !pc->cb_info || !min || !max) {
+ LOGE("NULL pointer %p %p %p", pc, min, max);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret = CAMERA_ERROR_NONE;
- int sock_fd = pc->cb_info->fd;
- int get_min;
- int get_max;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
+ LOGD("Enter");
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
- muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
- *min = get_min;
- *max = get_max;
+ *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
+ *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
}
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
{
- 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;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
+ camera_msg_param param0;
+ camera_msg_param param1;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret = CAMERA_ERROR_NONE;
- int sock_fd = pc->cb_info->fd;
- int set_move_type = (int)move_type;
- int set_tilt_step = tilt_step;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param0, INT, move_type);
+ CAMERA_MSG_PARAM_SET(param1, INT, tilt_step);
+
+ _camera_msg_send_param2_int(api, pc->cb_info, &ret,
+ ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, set_move_type, INT, set_tilt_step);
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_get_tilt(camera_h camera, int *tilt_step)
{
- if (camera == NULL || tilt_step == 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;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
+
+ if (!pc || !pc->cb_info || !tilt_step) {
+ LOGE("NULL pointer %p %p", pc, tilt_step);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret = CAMERA_ERROR_NONE;
- int sock_fd = pc->cb_info->fd;
- int get_tilt_step;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
+ LOGD("Enter");
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE)
+ *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
- if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_tilt_step, pc->cb_info->recv_msg);
- *tilt_step = get_tilt_step;
- }
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
{
- if (camera == NULL || min == NULL || max == 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;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
+
+ if (!pc || !pc->cb_info || !min || !max) {
+ LOGE("NULL pointer %p %p %p", pc, min, max);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret = CAMERA_ERROR_NONE;
- int sock_fd = pc->cb_info->fd;
- int get_min;
- int get_max;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
+ LOGD("Enter");
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
- muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
- *min = get_min;
- *max = get_max;
+ *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
+ *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
}
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
{
- 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;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
+ camera_msg_param param;
+ int set_ptz_type = (int)ptz_type;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret = CAMERA_ERROR_NONE;
- int sock_fd = pc->cb_info->fd;
- int set_ptz_type = (int)ptz_type;
- muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
+ LOGD("Enter");
+
+ CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
+
+ _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
- muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_ptz_type);
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
{
- if (camera == NULL || foreach_cb == 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_FOREACH_SUPPORTED_PTZ_TYPE;
- int sock_fd;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+
+ if (!pc || !pc->cb_info || !foreach_cb) {
+ LOGE("NULL pointer %p %p", pc, foreach_cb);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = pc->cb_info->fd;
- LOGD("Enter, handle :%x", pc->remote_handle);
+
+ LOGD("Enter");
+
pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
LOGD("ret : 0x%x", ret);
+
return ret;
}
int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
{
- 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;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
+ int set_display_roi_area[4] = {x, y, width, height};
+ char *msg = NULL;
+ int length = 0;
+ int send_ret = 0;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
return CAMERA_ERROR_INVALID_PARAMETER;
}
- int ret = CAMERA_ERROR_NONE;
- int sock_fd = pc->cb_info->fd;
- int set_display_roi_area[4] = {x, y, width, height};
- muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
-
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
+ LOGD("Enter");
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
- g_mutex_lock(&pc->cb_info->evas_mutex);
-
- ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
-
- g_mutex_unlock(&pc->cb_info->evas_mutex);
-
+ ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
if (ret != MM_ERROR_NONE) {
LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
return CAMERA_ERROR_INVALID_OPERATION;
}
}
-#endif /* TIZEN_FEATURE_EVAS_RENDERER */
- muse_camera_msg_send_array(api, sock_fd, pc->cb_info, ret,
- set_display_roi_area, sizeof(set_display_roi_area), sizeof(int));
+ length = sizeof(set_display_roi_area) / sizeof(int) + \
+ (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
+
+ msg = muse_core_msg_new(api,
+ MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
+ NULL);
+ if (!msg) {
+ LOGE("msg creation failed: api %d", api);
+ return CAMERA_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (pc->cb_info->is_server_connected) {
+ __camera_update_api_waiting(pc->cb_info, api, 1);
+
+ g_mutex_lock(&pc->cb_info->fd_lock);
+ send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
+ g_mutex_unlock(&pc->cb_info->fd_lock);
+ }
+
+ if (send_ret < 0) {
+ LOGE("message send failed");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ } else {
+ ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
+ }
+
+ __camera_update_api_waiting(pc->cb_info, api, -1);
+
+ muse_core_msg_free(msg);
LOGD("ret : 0x%x", ret);
int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
{
- if (camera == NULL || x == NULL || y == NULL || width == NULL || height == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
+ camera_cli_s *pc = (camera_cli_s *)camera;
+ int ret = CAMERA_ERROR_NONE;
+ muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
+
+ if (!pc || !pc->cb_info || !x || !y || !width || !height) {
+ LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- camera_cli_s *pc = (camera_cli_s *)camera;
- if (pc->cb_info == NULL) {
- LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
- return CAMERA_ERROR_INVALID_PARAMETER;
+ LOGD("Enter");
+
+ _camera_msg_send(api, NULL, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ *x = pc->cb_info->get_display_roi_area[0];
+ *y = pc->cb_info->get_display_roi_area[1];
+ *width = pc->cb_info->get_display_roi_area[2];
+ *height = pc->cb_info->get_display_roi_area[3];
}
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
+}
+
+
+int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
+{
int ret = CAMERA_ERROR_NONE;
- int sock_fd = pc->cb_info->fd;
- int get_display_roi_area[4] = {0,};
- muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
+ int get_device_state = 0;
- LOGD("Enter, remote_handle : %x", pc->remote_handle);
+ if (!state) {
+ LOGE("NULL pointer");
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
- muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
+ ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
+ (int)device, "get_device_state", &get_device_state);
if (ret == CAMERA_ERROR_NONE) {
- muse_camera_msg_get_array(get_display_roi_area, pc->cb_info->recv_msg);
+ *state = (camera_device_state_e)get_device_state;
+ LOGD("device state %d", *state);
+ } else {
+ LOGE("failed 0x%x", ret);
+ }
- *x = get_display_roi_area[0];
- *y = get_display_roi_area[1];
- *width = get_display_roi_area[2];
- *height = get_display_roi_area[3];
+ return ret;
+}
- LOGD("ret : 0x%x", ret);
- } else {
- LOGE("Returned value is not valid : 0x%x", ret);
+
+int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
+ camera_cb_info *info = NULL;
+
+ if (!callback || !cb_id) {
+ LOGE("invalid pointer %p %p", callback, cb_id);
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ /* check camera support */
+ ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
+ if (ret != CAMERA_ERROR_NONE) {
+ LOGE("get device state failed");
+ return ret;
+ }
+
+ g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
+
+ info = g_new0(camera_cb_info, 1);
+ if (!info) {
+ LOGE("info failed");
+ ret = CAMERA_ERROR_OUT_OF_MEMORY;
+ goto _DONE;
+ }
+
+ info->id = ++g_cam_dev_state_changed_cb_id;
+ info->callback = (void *)callback;
+ info->user_data = user_data;
+
+ *cb_id = info->id;
+
+ /* subscribe dbus signal for camera state change */
+ if (!g_cam_dev_state_changed_cb_conn) {
+ g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
+ if (!g_cam_dev_state_changed_cb_conn) {
+ LOGE("failed to get gdbus connection");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _DONE;
+ }
+
+ LOGD("subscribe signal %s - %s - %s",
+ MM_CAMCORDER_DBUS_OBJECT,
+ MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
+ MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
+
+ g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
+ NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
+ if (!g_cam_dev_state_changed_cb_subscribe_id) {
+ LOGE("failed to get gdbus connection");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _DONE;
+ }
+
+ LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
+ }
+
+ g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
+
+ LOGD("callback id %d", info->id);
+
+_DONE:
+ if (ret != CAMERA_ERROR_NONE) {
+ if (info) {
+ g_free(info);
+ info = NULL;
+ }
+
+ if (g_cam_dev_state_changed_cb_conn) {
+ g_object_unref(g_cam_dev_state_changed_cb_conn);
+ g_cam_dev_state_changed_cb_conn = NULL;
+ }
+ }
+
+ g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
+
+ return ret;
+}
+
+
+int camera_remove_device_state_changed_cb(int cb_id)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
+ GList *tmp_list = NULL;
+ camera_cb_info *info = NULL;
+
+ /* check camera support */
+ ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
+ if (ret != CAMERA_ERROR_NONE) {
+ LOGE("get device state failed");
+ return ret;
+ }
+
+ g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
+
+ if (!g_cam_dev_state_changed_cb_list) {
+ LOGE("there is no callback info");
+ ret = CAMERA_ERROR_INVALID_OPERATION;
+ goto _DONE;
}
+ tmp_list = g_cam_dev_state_changed_cb_list;
+
+ do {
+ info = tmp_list->data;
+ tmp_list = tmp_list->next;
+
+ if (!info) {
+ LOGW("NULL info");
+ continue;
+ }
+
+ if (info->id == cb_id) {
+ g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
+
+ g_free(info);
+ info = NULL;
+
+ if (!g_cam_dev_state_changed_cb_list) {
+ /* no remained callback */
+ if (g_cam_dev_state_changed_cb_conn) {
+ /* unsubscribe signal */
+ g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
+ g_cam_dev_state_changed_cb_subscribe_id = 0;
+
+ /* unref connection */
+ g_object_unref(g_cam_dev_state_changed_cb_conn);
+ g_cam_dev_state_changed_cb_conn = NULL;
+ }
+ }
+
+ LOGD("id %d callback removed", cb_id);
+ ret = CAMERA_ERROR_NONE;
+
+ goto _DONE;
+ }
+ } while (tmp_list);
+
+ LOGE("id %d callback not found", cb_id);
+ ret = CAMERA_ERROR_INVALID_PARAMETER;
+
+_DONE:
+ g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
+
return ret;
}