#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>
static GDBusConnection *g_cam_dev_state_changed_cb_conn;
static guint g_cam_dev_state_changed_cb_subscribe_id;
+static void _camera_msg_send(int api, 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 int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, 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_key,
+ 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 tbm_key, int num_buffer_key, 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 void __global(void *data, struct wl_registry *registry,
uint32_t name, const char *interface, uint32_t version)
{
goto _DONE;
}
+ ecore_wl_window_video_has(window, EINA_TRUE);
+
surface = (struct wl_surface *)ecore_wl_window_surface_get(window);
if (!surface) {
LOGE("failed to get wayland surface");
Ecore_Evas *ecore_evas = NULL;
ret = CAMERA_ERROR_NONE;
- wl_info->evas_obj = obj;
-
evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
&wl_info->window_width, &wl_info->window_height);
}
LOGD("evas object : %p, rotation : %d, parent id : %u, window : %d,%d,%dx%d",
- wl_info->evas_obj, rotation, wl_info->parent_id,
+ obj, rotation, wl_info->parent_id,
wl_info->window_x, wl_info->window_y,
wl_info->window_width, wl_info->window_height);
} else {
}
+static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
+{
+ if (!cb_info ||
+ api < 0 || api >= MUSE_CAMERA_API_MAX) {
+ LOGE("invalid param %p %d", cb_info, api);
+ return;
+ }
+
+ g_mutex_lock(&(cb_info->api_mutex[api]));
+ cb_info->api_waiting[api] += value;
+ g_mutex_unlock(&(cb_info->api_mutex[api]));
+
+ /*LOGD("api %d, value %d, waiting %d",
+ api, value, cb_info->api_waiting[api]);*/
+
+ return;
+}
+
+
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)
}
+static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg)
+{
+ int i = 0;
+ int ret = 0;
+ int num_buffer_key = 0;
+ int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
+ int tbm_key = 0;
+ int data_key = 0;
+ unsigned char *buf_pos = NULL;
+ camera_msg_param param;
+
+ 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_preview_data_s frame;
+ camera_stream_data_s *stream = NULL;
+ camera_media_packet_data *mp_data = NULL;
+ media_packet_h pkt = NULL;
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+ media_packet_h pkt_evas = NULL;
+#endif /* TIZEN_FEATURE_EVAS_RENDERER */
+
+ if (!cb_info || !recv_msg) {
+ LOGE("invalid param %p %p", cb_info, recv_msg);
+ return;
+ }
+
+ 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);
+ return;
+ }
+
+ CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
+
+ if (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) {
+ LOGE("invalid num buffer key %d", num_buffer_key);
+ goto _PREVIEW_CB_HANDLER_DONE;
+ }
+
+ if (data_key > 0) {
+ /* import tbm data_bo and get virtual address */
+ if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
+ LOGE("failed to import data key %d", data_key);
+ goto _PREVIEW_CB_HANDLER_DONE;
+ }
+ }
+
+ /* import tbm bo and get virtual address */
+ if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
+ LOGE("failed to import key %d", tbm_key);
+ goto _PREVIEW_CB_HANDLER_DONE;
+ }
+
+ 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 (!_camera_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]);
+ goto _PREVIEW_CB_HANDLER_DONE;
+ }
+ }
+
+ /* 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);
+
+ ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
+ cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
+ }
+
+ 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_evas);
+ if (ret != CAMERA_ERROR_NONE) {
+ LOGE("create pkt for evas failed");
+ _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 */
+ }
+
+ /* 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);
+
+ 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;
+ }
+ }
+ }
+
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+ /* call evas renderer */
+ if (pkt_evas) {
+ g_mutex_lock(&cb_info->evas_mutex);
+ if (cb_info->run_evas_render) {
+ mm_evas_renderer_write(pkt_evas, cb_info->evas_info);
+ } else {
+ LOGW("evas renderer is stopped, skip this buffer...");
+ media_packet_destroy(pkt_evas);
+ }
+ pkt_evas = NULL;
+ g_mutex_unlock(&cb_info->evas_mutex);
+ }
+#endif /* TIZEN_FEATURE_EVAS_RENDERER */
+
+ /* 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, cb_info, NULL, 0);
+
+_PREVIEW_CB_HANDLER_DONE:
+ if (mp_data == NULL) {
+ /* release imported bo */
+ for (i = 0 ; i < num_buffer_key ; i++)
+ _camera_release_imported_bo(&buffer_bo[i]);
+
+ /* unmap and unref tbm bo */
+ _camera_release_imported_bo(&data_bo);
+ _camera_release_imported_bo(&bo);
+
+ /* 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 tbm_key = 0;
+ int tbm_key_main = 0;
+ int tbm_key_post = 0;
+ int tbm_key_thumb = 0;
+ unsigned char *buf_pos = NULL;
+
+ camera_msg_param param;
+ 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) {
+ LOGE("invalid param %p %p", cb_info, recv_msg);
+ return;
+ }
+
+ 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 key %d", tbm_key_main);
+ 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_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle)) {
+ LOGE("failed to import key [%d] for main", tbm_key_main);
+ 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 {
+ rImage->exif = NULL;
+ rImage->exif_size = 0;
+ }
+
+ LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
+ rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
+
+ if (tbm_key_post > 0) {
+ /* import tbm bo and get virtual address */
+ if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &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 key [%d] for postview", tbm_key_post);
+ }
+ }
+
+ if (tbm_key_thumb > 0) {
+ /* import tbm bo and get virtual address */
+ if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &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 key [%d] for thumbnail", tbm_key_thumb);
+ }
+ }
+
+ ((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 (tbm_key_main > 0) {
+ _camera_release_imported_bo(&bo_main);
+
+ tbm_key = tbm_key_main;
+ CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
+
+ _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
+ }
+
+ if (tbm_key_post > 0) {
+ _camera_release_imported_bo(&bo_post);
+
+ tbm_key = tbm_key_post;
+ CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
+
+ _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
+ }
+
+ if (tbm_key_thumb > 0) {
+ _camera_release_imported_bo(&bo_thumb);
+
+ tbm_key = tbm_key_thumb;
+ CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
+
+ _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
+ }
+
+ LOGD("return buffer done");
+
+ return;
+}
+
+
+static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg)
+{
+ int count = 0;
+ int tbm_key = 0;
+ camera_detected_face_s *faces = NULL;
+ camera_msg_param param;
+
+ tbm_bo bo = NULL;
+ tbm_bo_handle bo_handle = {.ptr = NULL};
+
+ if (!cb_info || !recv_msg) {
+ LOGE("invalid param %p %p", cb_info, recv_msg);
+ return;
+ }
+
+ muse_camera_msg_get(count, recv_msg);
+ muse_camera_msg_get(tbm_key, recv_msg);
+
+ if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
+ LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
+
+ if (tbm_key > 0) {
+
+ if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
+ /* set face info */
+ faces = bo_handle.ptr;
+ }
+ }
+
+ ((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, key %d, cb %p",
+ count, tbm_key, cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
+ }
+
+ /* return buffer */
+ if (tbm_key > 0) {
+ CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
+ _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
+ /*LOGD("return buffer done");*/
+ }
+
+ return;
+}
+
+
static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
{
tbm_bo tmp_bo = NULL;
static void _camera_release_imported_bo(tbm_bo *bo)
{
if (!bo || !(*bo)) {
- LOGW("NULL bo");
+ /*LOGW("NULL bo");*/
return;
}
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];
return;
}
- msg = muse_core_msg_json_factory_new(api, NULL);
+ msg = muse_core_msg_new(api, NULL);
if (!msg) {
LOGE("msg failed: api %d", api);
/*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_ipc_send_msg(cb_info->fd, msg);
+ send_ret = muse_core_msg_send(cb_info->fd, msg);
g_mutex_unlock(&cb_info->fd_lock);
}
*ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
}
- muse_core_msg_json_factory_free(msg);
+ __camera_update_api_waiting(cb_info, api, -1);
+
+ muse_core_msg_free(msg);
return;
}
switch (param->type) {
case MUSE_TYPE_INT:
- msg = muse_core_msg_json_factory_new(api,
+ msg = muse_core_msg_new(api,
param->type, param->name, param->value.value_INT,
NULL);
break;
case MUSE_TYPE_STRING:
- msg = muse_core_msg_json_factory_new(api,
+ msg = muse_core_msg_new(api,
param->type, param->name, param->value.value_STRING,
NULL);
break;
/*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_ipc_send_msg(cb_info->fd, msg);
+ send_ret = muse_core_msg_send(cb_info->fd, msg);
g_mutex_unlock(&cb_info->fd_lock);
}
*ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
}
- muse_core_msg_json_factory_free(msg);
+ __camera_update_api_waiting(cb_info, api, -1);
+
+ muse_core_msg_free(msg);
return;
}
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_key,
tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
{
int total_size = 0;
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 tbm_key, int num_buffer_key, tbm_bo bo,
tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
{
int i = 0;
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;
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;
{
int param1 = 0;
int param2 = 0;
- int tbm_key = 0;
- tbm_bo bo = NULL;
- tbm_bo_handle bo_handle = {NULL, };
- camera_msg_param param;
if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
/*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) {
break;
case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_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;
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- media_packet_h pkt_evas = NULL;
-#endif /* TIZEN_FEATURE_EVAS_RENDERER */
-
- 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;
- }
-
- CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
-
- if (data_key > 0) {
- /* import tbm data_bo and get virtual address */
- if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
- LOGE("failed to import data key %d", data_key);
- _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
- break;
- }
- }
-
- /* import tbm bo and get virtual address */
- if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
- LOGE("failed to import key %d", tbm_key);
- _camera_release_imported_bo(&data_bo);
- _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
- 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 (!_camera_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 */
- _camera_release_imported_bo(&data_bo);
- _camera_release_imported_bo(&bo);
-
- for (i -= 1 ; i >= 0 ; i--)
- _camera_release_imported_bo(&buffer_bo[i]);
-
- /* send return buffer */
- _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
-
- 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);
-
- ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
- cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
- }
-
- 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_evas);
- if (ret != CAMERA_ERROR_NONE) {
- LOGE("create pkt for evas failed");
- _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 */
- }
-
- /* 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);
-
- 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;
- }
- }
- }
-
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
- /* call evas renderer */
- if (pkt_evas) {
- g_mutex_lock(&cb_info->evas_mutex);
- if (cb_info->run_evas_render) {
- mm_evas_renderer_write(pkt_evas, cb_info->evas_info);
- } else {
- LOGW("evas renderer is stopped, skip this buffer...");
- media_packet_destroy(pkt_evas);
- }
- pkt_evas = NULL;
- g_mutex_unlock(&cb_info->evas_mutex);
- }
-#endif /* TIZEN_FEATURE_EVAS_RENDERER */
-
- /* 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, cb_info, NULL, 0);
-
- if (mp_data == NULL) {
- /* release imported bo */
- for (i = 0 ; i < num_buffer_key ; i++)
- _camera_release_imported_bo(&buffer_bo[i]);
-
- /* unmap and unref tbm bo */
- _camera_release_imported_bo(&data_bo);
- _camera_release_imported_bo(&bo);
-
- /* return buffer */
- _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
-
- /*LOGD("return buffer Done");*/
- }
- }
+ __camera_event_handler_preview(cb_info, recv_msg);
break;
case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
{
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]);
}
(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 (!_camera_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;
+ int policy = 0;
+ int state = 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
+ muse_camera_msg_get(policy, recv_msg);
+ muse_camera_msg_get(state, recv_msg);
- /* release bo */
- _camera_release_imported_bo(&bo);
+ LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
- /* return buffer */
- CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
- _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
+ if (policy == CAMERA_POLICY_SOUND)
+ LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
+ else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
+ LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
+ else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
+ LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
- /*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);
+ break;
case MUSE_CAMERA_EVENT_TYPE_ERROR:
{
int error = 0;
}
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 key %d", tbm_key_main);
- break;
- }
-
- /* import tbm bo and get virtual address */
- if (!_camera_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);
- if (rImage->exif && rImage->exif_size > 0) {
- rImage->exif = rImage->data + rImage->size;
- } else {
- rImage->exif = NULL;
- rImage->exif_size = 0;
- }
-
- LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
- rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
-
- if (tbm_key_post > 0) {
- /* import tbm bo and get virtual address */
- if (!_camera_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 (!_camera_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 */
- _camera_release_imported_bo(&bo_main);
-
- /* return buffer */
- tbm_key = tbm_key_main;
-
- CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
-
- _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
-
- if (tbm_key_post > 0) {
- /* unmap and unref tbm bo */
- _camera_release_imported_bo(&bo_post);
-
- /* return buffer */
- param.value.value_INT = tbm_key_post;
- _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
- }
-
- if (tbm_key_thumb > 0) {
- /* unmap and unref tbm bo */
- _camera_release_imported_bo(&bo_thumb);
-
- /* return buffer */
- param.value.value_INT = tbm_key_thumb;
- _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
- }
-
- LOGD("return buffer done");
- }
- break;
- case MUSE_CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR:
+ __camera_event_handler_capture(cb_info, recv_msg);
break;
default:
- LOGW("Unknown event : %d", event);
+ LOGW("unhandled event %d", event);
break;
}
+ g_mutex_unlock(&cb_info->user_cb_mutex[event]);
+
return;
}
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);
goto IDLE_EVENT_CALLBACK_DONE;
}
g_mutex_unlock(&cb_info->idle_event_mutex);
/* user callback */
- _camera_client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
+ _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
/* send signal for waiting thread */
g_cond_signal(&cb_info->idle_event_cond);
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("t:%d camera api %d - return 0x%x", type, 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("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
}
}
-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;
continue;
}
- if (g_mutex_trylock(&cam_idle_event->event_mutex)) {
- ret = g_idle_remove_by_data(cam_idle_event);
-
- LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret);
-
- if (!ret) {
- cam_idle_event->cb_info = NULL;
- LOGW("idle event %p will be called later", cam_idle_event);
- }
-
- cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
-
- g_mutex_unlock(&cam_idle_event->event_mutex);
-
- if (ret) {
- g_mutex_clear(&cam_idle_event->event_mutex);
+ if (!g_mutex_trylock(&cam_idle_event->event_mutex)) {
+ LOGW("lock failed, %p event is calling now", cam_idle_event);
- g_free(cam_idle_event);
- cam_idle_event = NULL;
+ end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
- LOGD("remove idle event done");
- }
+ if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
+ LOGW("signal received");
+ else
+ LOGW("timeout");
continue;
}
- LOGW("event lock failed. it's being called...");
+ 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;
- end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
+ cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
- if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
- LOGW("signal received");
- else
- LOGW("timeout");
+ g_mutex_unlock(&cam_idle_event->event_mutex);
}
g_list_free(cb_info->idle_event_list);
g_mutex_lock(&cb_info->api_mutex[api]);
- cb_info->api_ret[api] = ret;
- cb_info->api_activating[api] = 1;
-
switch (api) {
case MUSE_CAMERA_API_CREATE:
if (ret != CAMERA_ERROR_NONE) {
switch (get_type) {
case MUSE_CAMERA_GET_TYPE_INT:
- muse_core_msg_json_deserialize("get_value", msg, NULL, &cb_info->get_int[get_index], NULL, MUSE_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_json_deserialize("get_value0", msg, NULL, &cb_info->get_int_pair[get_index][0], NULL, MUSE_TYPE_INT);
- muse_core_msg_json_deserialize("get_value1", msg, NULL, &cb_info->get_int_pair[get_index][1], NULL, MUSE_TYPE_INT);
+ 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_json_deserialize("get_value",
- msg, NULL, cb_info->get_display_roi_area, NULL, MUSE_TYPE_ARRAY);
+ 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_json_deserialize("get_value",
- msg, NULL, cb_info->get_geotag, NULL, MUSE_TYPE_ARRAY);
+ 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_json_deserialize("get_value", msg, NULL, cb_info->get_string[get_index], NULL, MUSE_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;
}
- g_cond_signal(&cb_info->api_cond[api]);
+ 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->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);
recv_msg = cb_info->recv_msg;
while (g_atomic_int_get(&cb_info->msg_recv_running)) {
- recv_length = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
+ recv_length = muse_core_msg_recv(cb_info->fd, recv_msg);
if (recv_length <= 0) {
cb_info->is_server_connected = FALSE;
LOGE("receive msg failed - server disconnected");
LOGW("incompleted message [len %d]", remained_length);
+ if (remained_msg) {
+ free(remained_msg);
+ remained_msg = NULL;
+ }
+
remained_msg = (char *)malloc(remained_length + 1);
if (remained_msg) {
strncpy(remained_msg, recv_msg + prev_pos, remained_length);
if (!cb_info->is_server_connected) {
/* send error msg for server disconnection */
- char *error_msg = muse_core_msg_json_factory_new(MUSE_CAMERA_CB_EVENT,
+ char *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);
MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
error_msg);
- muse_core_msg_json_factory_free(error_msg);
+ muse_core_msg_free(error_msg);
error_msg = NULL;
LOGE("add error msg for service disconnection done");
g_mutex_unlock(&handler_info->mutex);
g_thread_join(handler_info->thread);
- g_thread_unref(handler_info->thread);
handler_info->thread = NULL;
g_mutex_clear(&handler_info->mutex);
goto ErrorExit;
}
+ 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]);
g_mutex_init(&cb_info->evas_mutex);
#endif /* TIZEN_FEATURE_EVAS_RENDERER */
+ for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
+ g_mutex_init(&cb_info->user_cb_mutex[i]);
+
/* message handler thread */
if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_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_EVENT_TYPE_NUM ; i++)
+ g_mutex_clear(&cb_info->user_cb_mutex[i]);
+
g_mutex_clear(&cb_info->fd_lock);
g_mutex_clear(&cb_info->idle_event_mutex);
g_cond_clear(&cb_info->idle_event_cond);
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_recv thread removed");
__destroy_msg_handler_thread(&cb_info->preview_cb_info);
__destroy_msg_handler_thread(&cb_info->capture_cb_info);
+ for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
+ g_mutex_clear(&cb_info->user_cb_mutex[i]);
+
g_mutex_clear(&cb_info->fd_lock);
g_mutex_clear(&cb_info->idle_event_mutex);
g_cond_clear(&cb_info->idle_event_cond);
}
if (cb_info->fd > -1) {
- muse_core_connection_close(cb_info->fd);
+ muse_client_close(cb_info->fd);
cb_info->fd = -1;
}
return CAMERA_ERROR_INVALID_PARAMETER;
}
- sock_fd = muse_core_client_new();
+ sock_fd = muse_client_new();
if (sock_fd < 0) {
- LOGE("muse_core_client_new failed");
+ LOGE("muse_client_new failed");
return CAMERA_ERROR_INVALID_OPERATION;
}
- msg = muse_core_msg_json_factory_new(api,
+ msg = muse_core_msg_new(api,
MUSE_TYPE_INT, "module", MUSE_CAMERA,
MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
0);
goto _REQUEST_EXIT;
}
- ret = muse_core_ipc_send_msg(sock_fd, msg);
+ ret = muse_core_msg_send(sock_fd, msg);
- muse_core_msg_json_factory_free(msg);
+ muse_core_msg_free(msg);
msg = NULL;
if (ret < 0) {
goto _REQUEST_EXIT;
}
- ret = muse_core_ipc_recv_msg(sock_fd, recv_msg);
+ ret = muse_core_msg_recv(sock_fd, recv_msg);
if (ret <= 0) {
LOGE("recv msg failed %d", errno);
ret = CAMERA_ERROR_INVALID_OPERATION;
}
if (ret == CAMERA_ERROR_NONE)
- muse_core_msg_json_deserialize(key, recv_msg, NULL, value, NULL, MUSE_TYPE_ANY);
+ 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_core_connection_close(sock_fd);
+ muse_client_close(sock_fd);
sock_fd = -1;
}
return CAMERA_ERROR_INVALID_PARAMETER;
}
- 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();
- send_msg = muse_core_msg_json_factory_new(api,
+ send_msg = muse_core_msg_new(api,
MUSE_TYPE_INT, "module", muse_module,
MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
MUSE_TYPE_INT, "pid", pid,
goto ErrorExit;
}
- send_ret = muse_core_ipc_send_msg(sock_fd, send_msg);
+ send_ret = muse_core_msg_send(sock_fd, send_msg);
- muse_core_msg_json_factory_free(send_msg);
+ muse_core_msg_free(send_msg);
send_msg = NULL;
if (send_ret < 0) {
LOGD("cb info : %d", pc->cb_info->fd);
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) {
intptr_t handle = 0;
muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
}
if (sock_fd > -1) {
- muse_core_connection_close(sock_fd);
+ muse_client_close(sock_fd);
sock_fd = -1;
}
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_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;
}
LOGW("server disconnected. release resource without send message.");
if (ret == CAMERA_ERROR_NONE) {
- _camera_remove_idle_event_all(pc->cb_info);
+ _camera_deactivate_idle_event_all(pc->cb_info);
_camera_client_callback_destroy(pc->cb_info);
pc->cb_info = NULL;
LOGD("Enter");
- _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT_LONG);
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
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) {
LOGD("Enter");
- 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;
-
_camera_msg_send(api, 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;
_camera_msg_send(api, 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;
length = sizeof(camera_wl_info_s) / sizeof(int) + \
(sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
- msg = muse_core_msg_json_factory_new(api,
+ msg = muse_core_msg_new(api,
MUSE_TYPE_INT, "type", type,
MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
NULL);
}
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_ipc_send_msg(pc->cb_info->fd, msg);
+ send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
g_mutex_unlock(&pc->cb_info->fd_lock);
}
ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
}
- muse_core_msg_json_factory_free(msg);
+ __camera_update_api_waiting(pc->cb_info, api, -1);
+
+ muse_core_msg_free(msg);
LOGD("wayland parent id : %d, window %d,%d,%dx%d",
pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
_camera_msg_send(api, 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;
+
+ 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);
}
LOGD("Enter");
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
- UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
+ if (ret == CAMERA_ERROR_NONE) {
+ g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
- _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+ 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);
+ }
LOGD("ret : 0x%x", ret);
_camera_msg_send(api, 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_MEDIA_PACKET_PREVIEW]);
+
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]);
}
LOGD("ret : 0x%x", ret);
LOGD("Enter");
- 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;
-
_camera_msg_send(api, 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_MEDIA_PACKET_PREVIEW]);
+
+ 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]);
+ }
+
LOGD("ret : 0x%x", ret);
return ret;
_camera_msg_send(api, 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);
LOGD("Enter");
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
-
_camera_msg_send(api, 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;
_camera_msg_send(api, 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);
LOGD("Enter");
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
+ _camera_msg_send(api, 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_interrupt_started_cb(camera_h camera, camera_interrupt_started_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_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, 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, 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;
_camera_msg_send(api, 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);
LOGD("Enter");
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
-
_camera_msg_send(api, 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;
_camera_msg_send(api, 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);
LOGD("Enter");
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
-
_camera_msg_send(api, 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;
length = sizeof(set_geotag) / sizeof(int) + \
(sizeof(set_geotag) % sizeof(int) ? 1 : 0);
- msg = muse_core_msg_json_factory_new(api,
+ msg = muse_core_msg_new(api,
MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
NULL);
if (!msg) {
}
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_ipc_send_msg(pc->cb_info->fd, msg);
+ send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
g_mutex_unlock(&pc->cb_info->fd_lock);
}
ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
}
- muse_core_msg_json_factory_free(msg);
+ __camera_update_api_waiting(pc->cb_info, api, -1);
+
+ muse_core_msg_free(msg);
LOGD("ret : 0x%x", ret);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- 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;
-
_camera_msg_send(api, 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] = 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);
return ret;
LOGD("Enter");
- pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
- pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
-
_camera_msg_send(api, 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]);
+ }
+
LOGD("ret : 0x%x", ret);
return ret;
muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
if (!pc || !pc->cb_info || !min || !max) {
- LOGE("NULL pointer %p %p", pc, min, max);
+ LOGE("NULL pointer %p %p %p", pc, min, max);
return CAMERA_ERROR_INVALID_PARAMETER;
}
length = sizeof(set_display_roi_area) / sizeof(int) + \
(sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
- msg = muse_core_msg_json_factory_new(api,
+ msg = muse_core_msg_new(api,
MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
NULL);
if (!msg) {
}
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_ipc_send_msg(pc->cb_info->fd, msg);
+ send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
g_mutex_unlock(&pc->cb_info->fd_lock);
}
ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
}
- muse_core_msg_json_factory_free(msg);
+ __camera_update_api_waiting(pc->cb_info, api, -1);
+
+ muse_core_msg_free(msg);
LOGD("ret : 0x%x", ret);