diff options
author | Jeongmo Yang <jm80.yang@samsung.com> | 2017-11-01 15:11:02 +0900 |
---|---|---|
committer | Jeongmo Yang <jm80.yang@samsung.com> | 2017-11-01 15:13:45 +0900 |
commit | cff3df28eeff869e74de776b96ba39512dab2e7d (patch) | |
tree | 90cddfe86929f30a6413f917388ecbeac7d147cc | |
parent | 00cedaf59f1ffaad57f9a84aee0412e04001d753 (diff) | |
download | camera-cff3df28eeff869e74de776b96ba39512dab2e7d.tar.gz camera-cff3df28eeff869e74de776b96ba39512dab2e7d.tar.bz2 camera-cff3df28eeff869e74de776b96ba39512dab2e7d.zip |
Seperate user callback function for some events which has a large logic
[Version] 0.3.9
[Profile] Common
[Issue Type] Update
[Dependency module] N/A
[Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-unified_20171028.1]
Change-Id: I7b43a71ffbeddfc1192f857306caeecd6f7a819e
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
-rw-r--r-- | packaging/capi-media-camera.spec | 2 | ||||
-rw-r--r-- | src/camera.c | 664 |
2 files changed, 355 insertions, 311 deletions
diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec index ef01eea..6ec1a7f 100644 --- a/packaging/capi-media-camera.spec +++ b/packaging/capi-media-camera.spec @@ -1,6 +1,6 @@ Name: capi-media-camera Summary: A Camera API -Version: 0.3.8 +Version: 0.3.9 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/camera.c b/src/camera.c index 14430e4..f452db8 100644 --- a/src/camera.c +++ b/src/camera.c @@ -50,6 +50,20 @@ 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 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) @@ -333,6 +347,339 @@ _DONE: } +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; @@ -671,7 +1018,7 @@ int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mi 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; @@ -787,7 +1134,7 @@ void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_k 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; @@ -819,7 +1166,7 @@ int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo, 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; @@ -858,7 +1205,7 @@ void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera 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; @@ -1082,10 +1429,6 @@ static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_m { 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); @@ -1145,164 +1488,7 @@ static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_m 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 (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) { - LOGE("invalid num buffer key %d", num_buffer_key); - _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0); - break; - } - - 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: { @@ -1361,40 +1547,7 @@ static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_m } break; case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION: - { - 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 && cb_info->user_cb[event]) { - 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[event])(faces, count, cb_info->user_data[event]); - - /* 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[event]); - } - - /* 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");*/ - } - } + __camera_event_handler_face_detection(cb_info, recv_msg); break; case MUSE_CAMERA_EVENT_TYPE_ERROR: { @@ -1471,116 +1624,7 @@ static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_m } 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; - } - - if (cb_info->user_cb[event] == NULL) { - LOGW("NULL callback"); - goto _EVENT_CAPTURE_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 _EVENT_CAPTURE_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[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]); - - /* unmap and unref tbm bo */ - _camera_release_imported_bo(&bo_main); - -_EVENT_CAPTURE_DONE: - /* 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"); - } + __camera_event_handler_capture(cb_info, recv_msg); break; default: LOGW("unhandled event %d", event); |