diff options
-rw-r--r-- | include/camera_private.h | 1 | ||||
-rw-r--r-- | packaging/capi-media-camera.spec | 8 | ||||
-rw-r--r-- | src/camera.c | 105 | ||||
-rw-r--r-- | test/camera_test.c | 48 |
4 files changed, 107 insertions, 55 deletions
diff --git a/include/camera_private.h b/include/camera_private.h index f1d3cd5..0fa2f77 100644 --- a/include/camera_private.h +++ b/include/camera_private.h @@ -35,6 +35,7 @@ extern "C" { #define BUFFER_MAX_PLANE_NUM 4 #define CAMERA_CB_TIMEOUT 4 +#define CAMERA_CB_NO_TIMEOUT 0 #define CAMERA_MSG_PARAM_SET(param, msg_type, set_value) { \ param.type = MUSE_TYPE_##msg_type; \ diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec index cc04db4..00dc4d9 100644 --- a/packaging/capi-media-camera.spec +++ b/packaging/capi-media-camera.spec @@ -1,7 +1,7 @@ Name: capi-media-camera Summary: A Camera API -Version: 0.2.93 -Release: 0 +Version: 0.2.99 +Release: 1 Group: Multimedia/API License: Apache-2.0 Source0: %{name}-%{version}.tar.gz @@ -71,8 +71,6 @@ make %{?jobs:-j%jobs} %install rm -rf %{buildroot} %make_install -mkdir -p %{buildroot}%{_datadir}/license -cp LICENSE.APLv2 %{buildroot}%{_datadir}/license/%{name} %post -p /sbin/ldconfig @@ -82,8 +80,8 @@ cp LICENSE.APLv2 %{buildroot}%{_datadir}/license/%{name} %files %manifest capi-media-camera.manifest +%license LICENSE.APLv2 %{_libdir}/libcapi-media-camera.so.* -%{_datadir}/license/%{name} %if "%{TIZEN_PRODUCT_TV}" != "1" %{_bindir}/* %endif diff --git a/src/camera.c b/src/camera.c index 77f7912..7d50534 100644 --- a/src/camera.c +++ b/src/camera.c @@ -394,15 +394,22 @@ static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_in 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]; @@ -1090,7 +1097,16 @@ static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_m 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"); + /* return preview callback */ + _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0); + + /* return buffer */ + muse_camera_msg_get(tbm_key, recv_msg); + LOGW("all preview callback from user are NULL - return key %d", tbm_key); + 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); + } return; } } else if (cb_info->user_cb[event] == NULL) { @@ -1168,6 +1184,12 @@ static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_m 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)) { @@ -2552,7 +2574,7 @@ int camera_create(camera_device_e device, camera_h *camera) LOGD("cb info : %d", pc->cb_info->fd); - ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT); + ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_NO_TIMEOUT); pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0; @@ -3783,13 +3805,14 @@ int camera_unset_preview_cb(camera_h camera) LOGD("Enter"); - pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL; - pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL; - - UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER); - _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT); + if (ret == CAMERA_ERROR_NONE) { + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL; + pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL; + UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER); + } + LOGD("ret : 0x%x", ret); return ret; @@ -3845,11 +3868,13 @@ int camera_unset_media_packet_preview_cb(camera_h camera) 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) { + 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; + } + LOGD("ret : 0x%x", ret); return ret; @@ -3895,11 +3920,13 @@ int camera_unset_state_changed_cb(camera_h camera) 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) { + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL; + pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL; + } + LOGD("ret : 0x%x", ret); return ret; @@ -3945,11 +3972,13 @@ int camera_unset_interrupted_cb(camera_h camera) 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) { + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL; + pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL; + } + LOGD("ret : 0x%x", ret); return ret; @@ -3995,11 +4024,13 @@ int camera_unset_focus_changed_cb(camera_h camera) 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) { + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL; + pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL; + } + LOGD("ret : 0x%x", ret); return ret; @@ -4045,11 +4076,13 @@ int camera_unset_error_cb(camera_h camera) 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) { + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL; + pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL; + } + LOGD("ret : 0x%x", ret); return ret; @@ -5937,11 +5970,13 @@ int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_pro 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) { + 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; + } + LOGD("ret : 0x%x", ret); return ret; @@ -5961,11 +5996,13 @@ int camera_attr_unset_hdr_capture_progress_cb(camera_h camera) 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) { + pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL; + pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL; + } + LOGD("ret : 0x%x", ret); return ret; diff --git a/test/camera_test.c b/test/camera_test.c index 8e4616f..022074c 100644 --- a/test/camera_test.c +++ b/test/camera_test.c @@ -786,12 +786,11 @@ static void main_menu(gchar buf) static void setting_menu(gchar buf) { - gboolean bret = FALSE; + int bret = FALSE; int idx = 0; int min = 0; int max = 0; int i = 0; - int value = 0; int err = 0; int x = 0; int y = 0; @@ -1006,9 +1005,12 @@ static void setting_menu(gchar buf) g_print("\n Select Display visible \n"); flush_stdin(); for (i = 0 ; i < 2 ; i++) - g_print("\t %d. %s\n", i+1, visible_mode[i]); - err = scanf("%d", &value); - bret = camera_set_display_visible(hcamcorder->camera, idx-1); + g_print("\t %d. %s\n", i, visible_mode[i]); + err = scanf("%d", &idx); + if (idx == 0 || idx == 1) + bret = camera_set_display_visible(hcamcorder->camera, idx); + else + g_print("invalid input %d", idx); break; case 'o': /* Setting > Display Mode */ g_print("* Display mode!\n"); @@ -1137,9 +1139,12 @@ static void setting_menu(gchar buf) g_print("\nSelect HDR capture mode\n"); flush_stdin(); for (i = 0 ; i < 3 ; i++) - g_print("\t %d. %s\n", i+1, hdr_mode[i]); + g_print("\t %d. %s\n", i, hdr_mode[i]); err = scanf("%d", &idx); - bret = camera_attr_set_hdr_mode(hcamcorder->camera, idx-1); + if (idx >= CAMERA_ATTR_HDR_MODE_DISABLE && idx <= CAMERA_ATTR_HDR_MODE_KEEP_ORIGINAL) + bret = camera_attr_set_hdr_mode(hcamcorder->camera, idx); + else + g_print("invalid input %d\n", idx); break; default: g_print("Wrong input, select again!!\n"); @@ -1168,28 +1173,39 @@ static void setting_menu(gchar buf) g_print("\n Select Anti-handshake mode \n"); flush_stdin(); for (i = 0; i < 2; i++) - g_print("\t %d. %s\n", i+1, ahs_mode[i]); + g_print("\t %d. %s\n", i, ahs_mode[i]); err = scanf("%d", &idx); - bret = camera_attr_enable_anti_shake(hcamcorder->camera, idx-1); + if (idx == 0 || idx == 1) + bret = camera_attr_enable_anti_shake(hcamcorder->camera, idx); + else + g_print("invalid input %d\n", idx); break; case 'K': /* Setting > Video-stabilization */ g_print("*Video-stabilization !\n"); g_print("\n Select Video-stabilization mode \n"); flush_stdin(); for (i = 0 ; i < 2 ; i++) - g_print("\t %d. %s\n", i+1, vs_mode[i]); + g_print("\t %d. %s\n", i, vs_mode[i]); err = scanf("%d", &idx); + + if (idx < 0 || idx > 1) { + g_print("invalid input %d\n", idx); + break; + } + if (idx == 1) { g_print("\n Restart preview with NV12 and 720p resolution\n"); err = camera_stop_preview(hcamcorder->camera); camera_set_preview_resolution(hcamcorder->camera, 1280, 720); camera_set_preview_format(hcamcorder->camera, CAMERA_PIXEL_FORMAT_NV12); - camera_attr_enable_video_stabilization(hcamcorder->camera, idx-1); - if (err == 0) { - err = camera_start_preview(hcamcorder->camera); - if (err != 0) - g_print("\n Restart FAILED! %x\n", err); - } + } + + bret = camera_attr_enable_video_stabilization(hcamcorder->camera, idx); + + if (idx == 1) { + err = camera_start_preview(hcamcorder->camera); + if (err != CAMERA_ERROR_NONE) + g_print("\n Restart FAILED! 0x%x\n", err); } break; case 'u': /* Touch AF area */ |