From 14593d913db82a9063076488f3c2486e375e8b17 Mon Sep 17 00:00:00 2001 From: Jeongmo Yang Date: Mon, 1 Feb 2016 18:38:28 +0900 Subject: [PATCH] [Release version 0.2.44] Remove client pipeline code and unnecessary dependency - libmm-camcorder, GStreamer Change-Id: Ifd97d2c508db7b703a26501dfc0f471b8978a05d Signed-off-by: Jeongmo Yang --- CMakeLists.txt | 2 +- include/camera_private.h | 64 ++++- packaging/capi-media-camera.spec | 4 +- src/camera.c | 519 ++++++++------------------------------- test/CMakeLists.txt | 2 +- test/camera_test.c | 11 +- 6 files changed, 158 insertions(+), 444 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f461ad..719d1ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ SET(service "media") SET(submodule "camera") # for package file -SET(dependents "libtbm dlog mm-common capi-base-common capi-media-tool mm-camcorder ecore elementary mmsvc-camera gstreamer-1.0 tizen-extension-client") +SET(dependents "libtbm dlog mm-common capi-base-common capi-media-tool ecore elementary mmsvc-camera tizen-extension-client") SET(pc_dependents "capi-base-common capi-media-tool libtbm evas ecore elementary") SET(fw_name "${project_prefix}-${service}-${submodule}") diff --git a/include/camera_private.h b/include/camera_private.h index a463e15..8cf6554 100644 --- a/include/camera_private.h +++ b/include/camera_private.h @@ -23,15 +23,59 @@ #include #include #include -#include #ifdef __cplusplus extern "C" { #endif +#ifdef BUFFER_MAX_PLANE_NUM +#undef BUFFER_MAX_PLANE_NUM +#endif /* BUFFER_MAX_PLANE_NUM */ + +#define BUFFER_MAX_PLANE_NUM 4 #define CAMERA_PARSE_STRING_SIZE 20 + +typedef struct _camera_stream_data_s { + union { + struct { + unsigned char *yuv; + unsigned int length_yuv; + } yuv420, yuv422; + struct { + unsigned char *y; + unsigned int length_y; + unsigned char *uv; + unsigned int length_uv; + } yuv420sp; + struct { + unsigned char *y; + unsigned int length_y; + unsigned char *u; + unsigned int length_u; + unsigned char *v; + unsigned int length_v; + } yuv420p, yuv422p; + struct { + unsigned char *data; + unsigned int length_data; + } encoded; + } data; /**< pointer of captured stream */ + int data_type; /**< data type */ + unsigned int length_total; /**< total length of stream buffer (in byte)*/ + unsigned int num_planes; /**< number of planes */ + MMPixelFormatType format; /**< image format */ + int width; /**< width of video buffer */ + int height; /**< height of video buffer */ + unsigned int timestamp; /**< timestamp of stream buffer (msec)*/ + void *bo[BUFFER_MAX_PLANE_NUM]; /**< TBM buffer object */ + void *internal_buffer; /**< Internal buffer pointer */ + int stride[BUFFER_MAX_PLANE_NUM]; /**< Stride of each plane */ + int elevation[BUFFER_MAX_PLANE_NUM]; /**< Elevation of each plane */ +} camera_stream_data_s; + + typedef struct _camera_cb_info_s { gint fd; GThread *msg_recv_thread; @@ -52,8 +96,6 @@ typedef struct _camera_cb_info_s { gint *api_activating; gint *api_ret; tbm_bufmgr bufmgr; - gint prev_state; - gchar *caps; media_format_h pkt_fmt; } camera_cb_info_s; @@ -69,14 +111,23 @@ typedef struct _camera_idle_event_s { GMutex event_mutex; } camera_idle_event_s; +#ifdef HAVE_WAYLAND +typedef struct _camera_wl_info_s { + int parent_id; + int window_x; + int window_y; + int window_width; + int window_height; + void *evas_obj; +} camera_wl_info_s; +#endif /* HAVE_WAYLAND */ + typedef struct _camera_cli_s { intptr_t remote_handle; - MMHandleType client_handle; - int display_type; intptr_t display_handle; camera_cb_info_s *cb_info; #ifdef HAVE_WAYLAND - MMCamWaylandInfo wl_info; + camera_wl_info_s wl_info; #endif /* HAVE_WAYLAND */ } camera_cli_s; @@ -91,7 +142,6 @@ typedef struct _camera_media_packet_data { int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format); int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype); int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data); -int __convert_camera_error_code(const char *func, int code); #ifdef __cplusplus } diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec index 1dc80ac..2b4a184 100644 --- a/packaging/capi-media-camera.spec +++ b/packaging/capi-media-camera.spec @@ -3,7 +3,7 @@ Name: capi-media-camera Summary: A Camera API -Version: 0.2.43 +Version: 0.2.44 Release: 0 Group: Multimedia/API License: Apache-2.0 @@ -20,8 +20,6 @@ BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(ecore) BuildRequires: pkgconfig(evas) BuildRequires: pkgconfig(capi-media-tool) -BuildRequires: pkgconfig(mm-camcorder) -BuildRequires: pkgconfig(gstreamer-1.0) %if %{with wayland} BuildRequires: pkgconfig(ecore-wayland) %endif diff --git a/src/camera.c b/src/camera.c index 6d1c606..99c7f39 100644 --- a/src/camera.c +++ b/src/camera.c @@ -30,9 +30,6 @@ #include #include #include -#include -#include -#include #include #ifdef HAVE_WAYLAND #include @@ -48,114 +45,6 @@ #define LOG_TAG "TIZEN_N_CAMERA" -int __convert_camera_error_code(const char *func, int code) -{ - int ret = CAMERA_ERROR_NONE; - const char *errorstr = NULL; - - switch (code) { - case MM_ERROR_NONE: - ret = CAMERA_ERROR_NONE; - errorstr = "ERROR_NONE"; - break; - case MM_ERROR_CAMCORDER_INVALID_ARGUMENT: - case MM_ERROR_COMMON_INVALID_ATTRTYPE: - ret = CAMERA_ERROR_INVALID_PARAMETER; - errorstr = "INVALID_PARAMETER"; - break; - case MM_ERROR_CAMCORDER_NOT_INITIALIZED: - case MM_ERROR_CAMCORDER_INVALID_STATE: - ret = CAMERA_ERROR_INVALID_STATE; - errorstr = "INVALID_STATE"; - break; - case MM_ERROR_CAMCORDER_DEVICE_NOT_FOUND: - ret = CAMERA_ERROR_DEVICE_NOT_FOUND; - errorstr = "DEVICE_NOT_FOUND"; - break; - case MM_ERROR_CAMCORDER_DEVICE_BUSY: - case MM_ERROR_CAMCORDER_DEVICE_OPEN: - case MM_ERROR_CAMCORDER_CMD_IS_RUNNING: - ret = CAMERA_ERROR_DEVICE_BUSY; - errorstr = "DEVICE_BUSY"; - break; - case MM_ERROR_CAMCORDER_DEVICE: - case MM_ERROR_CAMCORDER_DEVICE_IO: - case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT: - case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG: - case MM_ERROR_CAMCORDER_DEVICE_LACK_BUFFER: - ret = CAMERA_ERROR_DEVICE; - errorstr = "ERROR_DEVICE"; - break; - case MM_ERROR_CAMCORDER_GST_CORE: - case MM_ERROR_CAMCORDER_GST_LIBRARY: - case MM_ERROR_CAMCORDER_GST_RESOURCE: - case MM_ERROR_CAMCORDER_GST_STREAM: - case MM_ERROR_CAMCORDER_GST_STATECHANGE: - case MM_ERROR_CAMCORDER_GST_NEGOTIATION: - case MM_ERROR_CAMCORDER_GST_LINK: - case MM_ERROR_CAMCORDER_GST_FLOW_ERROR: - case MM_ERROR_CAMCORDER_ENCODER: - case MM_ERROR_CAMCORDER_ENCODER_BUFFER: - case MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE: - case MM_ERROR_CAMCORDER_ENCODER_WORKING: - case MM_ERROR_CAMCORDER_INTERNAL: - case MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT: - case MM_ERROR_CAMCORDER_DSP_FAIL: - case MM_ERROR_CAMCORDER_AUDIO_EMPTY: - case MM_ERROR_CAMCORDER_CREATE_CONFIGURE: - case MM_ERROR_CAMCORDER_FILE_SIZE_OVER: - case MM_ERROR_CAMCORDER_DISPLAY_DEVICE_OFF: - case MM_ERROR_CAMCORDER_INVALID_CONDITION: - ret = CAMERA_ERROR_INVALID_OPERATION; - errorstr = "INVALID_OPERATION"; - break; - case MM_ERROR_CAMCORDER_RESOURCE_CREATION: - case MM_ERROR_COMMON_OUT_OF_MEMORY: - ret = CAMERA_ERROR_OUT_OF_MEMORY; - errorstr = "OUT_OF_MEMORY"; - break; - case MM_ERROR_POLICY_BLOCKED: - ret = CAMERA_ERROR_SOUND_POLICY; - errorstr = "ERROR_SOUND_POLICY"; - break; - case MM_ERROR_POLICY_BLOCKED_BY_CALL: - ret = CAMERA_ERROR_SOUND_POLICY_BY_CALL; - errorstr = "ERROR_SOUND_POLICY_BY_CALL"; - break; - case MM_ERROR_POLICY_BLOCKED_BY_ALARM: - ret = CAMERA_ERROR_SOUND_POLICY_BY_ALARM; - errorstr = "ERROR_SOUND_POLICY_BY_ALARM"; - break; - case MM_ERROR_POLICY_RESTRICTED: - ret = CAMERA_ERROR_SECURITY_RESTRICTED; - errorstr = "ERROR_RESTRICTED"; - break; - case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE: - ret = CAMERA_ERROR_ESD; - errorstr = "ERROR_ESD"; - break; - case MM_ERROR_COMMON_INVALID_PERMISSION: - ret = CAMERA_ERROR_PERMISSION_DENIED; - errorstr = "ERROR_PERMISSION_DENIED"; - break; - case MM_ERROR_COMMON_OUT_OF_ARRAY: - case MM_ERROR_COMMON_OUT_OF_RANGE: - case MM_ERROR_COMMON_ATTR_NOT_EXIST: - case MM_ERROR_CAMCORDER_NOT_SUPPORTED: - ret = CAMERA_ERROR_NOT_SUPPORTED; - errorstr = "ERROR_NOT_SUPPORTED"; - break; - default: - ret = CAMERA_ERROR_INVALID_OPERATION; - errorstr = "INVALID_OPERATION"; - } - - if (code != MM_ERROR_NONE) - LOGE("[%s] %s(0x%08x) : core frameworks error code(0x%08x)", func ? func : "NULL_FUNC", errorstr, ret, code); - - return ret; -} - #ifdef HAVE_WAYLAND static void __global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) @@ -221,7 +110,7 @@ static const struct tizen_resource_listener _camera_tz_resource_listener = __parent_id_getter }; -int _get_wl_info(Evas_Object *obj, MMCamWaylandInfo *wl_info) +int _get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info) { int ret = CAMERA_ERROR_NONE; Ecore_Wl_Window *window = NULL; @@ -636,7 +525,7 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus { camera_preview_data_s frame; unsigned char *buf_pos = NULL; - MMCamcorderVideoStreamDataType *stream = NULL; + camera_stream_data_s *stream = NULL; int i = 0; int total_size = 0; int num_buffer_key = 0; @@ -668,7 +557,7 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus buf_pos = (unsigned char *)bo_handle.ptr; /* get stream info */ - stream = (MMCamcorderVideoStreamDataType *)buf_pos; + stream = (camera_stream_data_s *)buf_pos; for (i = 0 ; i < num_buffer_key ; i++) { /* import buffer bo and get virtual address */ @@ -701,7 +590,7 @@ static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, mus if (num_buffer_key == 0) { /* non-zero copy */ - buf_pos += sizeof(MMCamcorderVideoStreamDataType); + buf_pos += sizeof(camera_stream_data_s); if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) { frame.data.encoded_plane.data = buf_pos; @@ -1646,31 +1535,6 @@ static void *_camera_msg_recv_func(gpointer data) g_atomic_int_set(&cb_info->msg_recv_running, 0); LOGD("camera destroy done. close client cb handler"); } - } else if (api == MUSE_CAMERA_API_START_PREVIEW) { - int prev_state = CAMERA_STATE_NONE; - gchar caps[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',}; - - muse_camera_msg_get(prev_state, parse_str[i]); - - cb_info->prev_state = prev_state; - if (prev_state == CAMERA_STATE_CREATED) { - if (cb_info->caps) { - g_free(cb_info->caps); - cb_info->caps = NULL; - } - - muse_camera_msg_get(caps, parse_str[i]); - if (strlen(caps) > 0) { - cb_info->caps = g_strdup(caps); - if (cb_info->caps) { - LOGD("caps from server [%s]", cb_info->caps); - } else { - LOGE("failed to copy caps string"); - } - } else { - LOGE("no string for caps"); - } - } } g_cond_signal(&cb_info->api_cond[api]); @@ -1884,10 +1748,6 @@ static void _client_callback_destroy(camera_cb_info_s *cb_info) media_format_unref(cb_info->pkt_fmt); cb_info->pkt_fmt = NULL; } - if (cb_info->caps) { - g_free(cb_info->caps); - cb_info->caps = NULL; - } g_free(cb_info); cb_info = NULL; @@ -1944,13 +1804,6 @@ int camera_create(camera_device_e device, camera_h *camera) goto ErrorExit; } - ret = mm_camcorder_client_create(&pc->client_handle); - if (ret != MM_ERROR_NONE) { - LOGE("camera client create Failed 0x%x", ret); - ret = __convert_camera_error_code(__func__, ret); - goto ErrorExit; - } - pc->cb_info = _client_callback_new(sock_fd); if (pc->cb_info == NULL) { LOGE("cb_info alloc failed"); @@ -1973,8 +1826,14 @@ int camera_create(camera_device_e device, camera_h *camera) pc->remote_handle = handle; pc->cb_info->bufmgr = bufmgr; + 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("camera create 0x%x", pc->remote_handle); - *camera = (camera_h) pc; + *camera = (camera_h)pc; } else { goto ErrorExit; } @@ -1986,10 +1845,6 @@ ErrorExit: bufmgr = NULL; if (pc) { - if (pc->client_handle) { - mm_camcorder_client_destroy(pc->client_handle); - pc->client_handle = NULL; - } _client_callback_destroy(pc->cb_info); pc->cb_info = NULL; g_free(pc); @@ -2024,10 +1879,6 @@ int camera_destroy(camera_h camera) muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); if (ret == CAMERA_ERROR_NONE) { - if (pc->client_handle) { - mm_camcorder_client_destroy(pc->client_handle); - pc->client_handle = NULL; - } _camera_remove_idle_event_all(pc->cb_info); _client_callback_destroy(pc->cb_info); pc->cb_info = NULL; @@ -2062,15 +1913,6 @@ int camera_start_preview(camera_h camera) sock_fd = pc->cb_info->fd; - if (pc->client_handle == NULL) { - LOGW("set display is not called by application. set NONE type internally"); - ret = camera_set_display(camera, CAMERA_DISPLAY_TYPE_NONE, NULL); - if (ret != CAMERA_ERROR_NONE) { - LOGE("Internal camera_set_display failed 0x%x", ret); - return ret; - } - } - muse_camera_msg_send_longtime(api, sock_fd, pc->cb_info, ret); if (ret != CAMERA_ERROR_NONE) { @@ -2078,35 +1920,14 @@ int camera_start_preview(camera_h camera) return ret; } - if (pc->cb_info->prev_state == CAMERA_STATE_CREATED) { - if (pc->display_type != CAMERA_DISPLAY_TYPE_OVERLAY) { - if (pc->cb_info->caps == NULL) { - LOGE("caps string is NULL"); - goto _START_PREVIEW_ERROR; - } - - ret = mm_camcorder_client_realize(pc->client_handle, pc->cb_info->caps); - if (ret != MM_ERROR_NONE) { - LOGE("client realize failed 0x%x", ret); - goto _START_PREVIEW_ERROR; - } - } - } - LOGD("ret : 0x%x", ret); return CAMERA_ERROR_NONE; - -_START_PREVIEW_ERROR: - muse_camera_msg_send_longtime(MUSE_CAMERA_API_STOP_PREVIEW, sock_fd, pc->cb_info, ret); - - return CAMERA_ERROR_INVALID_OPERATION; } int camera_stop_preview(camera_h camera) { int ret = CAMERA_ERROR_NONE; - int client_ret = MM_ERROR_NONE; int sock_fd = 0; camera_cli_s *pc = NULL; muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW; @@ -2127,28 +1948,9 @@ int camera_stop_preview(camera_h camera) LOGD("Enter"); - /* destroy client pipeline first */ - if (pc->display_type != CAMERA_DISPLAY_TYPE_OVERLAY) { - if (pc->client_handle != NULL) { - client_ret = mm_camcorder_client_unrealize(pc->client_handle); - } else { - LOGW("client handle is NULL"); - } - } - /* send stop preview message */ muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); - if (ret == MM_ERROR_NONE && client_ret != MM_ERROR_NONE) { - LOGE("client unrealize failed, restart preview"); - muse_camera_msg_send_longtime(MUSE_CAMERA_API_START_PREVIEW, sock_fd, pc->cb_info, ret); - ret = CAMERA_ERROR_INVALID_OPERATION; - } else if (ret != MM_ERROR_NONE && client_ret == MM_ERROR_NONE) { - LOGE("stop preview failed, realize client again"); - mm_camcorder_client_realize(pc->client_handle, pc->cb_info->caps); - ret = CAMERA_ERROR_INVALID_OPERATION; - } - LOGD("ret : 0x%x", ret); return ret; @@ -2506,12 +2308,10 @@ int camera_set_display(camera_h camera, camera_display_type_e type, camera_displ { int ret = CAMERA_ERROR_NONE; void *set_display_handle = NULL; - int set_surface = MM_DISPLAY_SURFACE_OVERLAY; Evas_Object *obj = NULL; const char *object_type = NULL; - char socket_path[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,}; #ifdef HAVE_WAYLAND - MMCamWaylandInfo *wl_info = NULL; + camera_wl_info_s *wl_info = NULL; #endif /* HAVE_WAYLAND */ if (camera == NULL) { @@ -2519,6 +2319,11 @@ int camera_set_display(camera_h camera, camera_display_type_e type, camera_displ return CAMERA_ERROR_INVALID_PARAMETER; } + if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) { + LOGE("invalid type %d", type); + return CAMERA_ERROR_INVALID_PARAMETER; + } + if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) { LOGE("display type[%d] is not NONE, but display handle is NULL", type); return CAMERA_ERROR_INVALID_PARAMETER; @@ -2537,7 +2342,6 @@ int camera_set_display(camera_h camera, camera_display_type_e type, camera_displ if (type == CAMERA_DISPLAY_TYPE_NONE) { set_display_handle = 0; - set_surface = MM_DISPLAY_SURFACE_NULL; LOGD("display type NONE"); } else { obj = (Evas_Object *)display; @@ -2556,12 +2360,10 @@ int camera_set_display(camera_h camera, camera_display_type_e type, camera_displ /* x window overlay surface */ set_display_handle = (void *)elm_win_xwindow_get(obj); #endif /* HAVE_WAYLAND */ - set_surface = MM_DISPLAY_SURFACE_OVERLAY; 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; - set_surface = MM_DISPLAY_SURFACE_EVAS; LOGD("display type EVAS : handle %p", set_display_handle); } else { LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type); @@ -2573,57 +2375,29 @@ int camera_set_display(camera_h camera, camera_display_type_e type, camera_displ } } - pc->display_type = type; pc->display_handle = (intptr_t)set_display_handle; -#ifdef HAVE_WAYLAND if (type == CAMERA_DISPLAY_TYPE_OVERLAY) { +#ifdef HAVE_WAYLAND wl_info = &pc->wl_info; muse_camera_msg_send_array_and_value(api, sock_fd, pc->cb_info, ret, wl_info, 5, sizeof(int), INT, type); - return __convert_camera_error_code(__func__, ret); - } else -#endif /* HAVE_WAYLAND */ - muse_camera_msg_send(api, sock_fd, pc->cb_info, ret); - - if (ret == CAMERA_ERROR_NONE) { - if (muse_camera_msg_get_string(socket_path, pc->cb_info->recv_msg) == FALSE) { - LOGE("failed to get socket path"); - return CAMERA_ERROR_INVALID_OPERATION; - } - - LOGD("socket path : %s", socket_path); - - ret = mm_camcorder_client_set_socket_path(pc->client_handle, socket_path); - if (ret != MM_ERROR_NONE) { - LOGE("failed to set socket path 0x%x", ret); - return __convert_camera_error_code(__func__, ret); - } + 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 /* HAVE_WAYLAND */ + muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, type, INT, set_display_handle); - ret = mm_camcorder_set_attributes(pc->client_handle, NULL, - MMCAM_DISPLAY_SURFACE, set_surface, - NULL); - if (ret != MM_ERROR_NONE) { - LOGE("set display surface failed 0x%x", ret); - return __convert_camera_error_code(__func__, ret); - } + LOGD("x id : %d", (int)set_display_handle); +#endif /* HAVE_WAYLAND */ + } else + muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, type); - if (type != CAMERA_DISPLAY_TYPE_NONE) { - ret = mm_camcorder_set_attributes(pc->client_handle, NULL, - MMCAM_DISPLAY_HANDLE, set_display_handle, sizeof(void *), - NULL); - if (ret != MM_ERROR_NONE) { - LOGE("set display handle failed 0x%x", ret); - return __convert_camera_error_code(__func__, ret); - } - } + if (ret != CAMERA_ERROR_NONE) + LOGE("set display error 0x%x", ret); - return CAMERA_ERROR_NONE;; - } else { - LOGE("set display error - 0x%x"); - return ret; - } + return ret; } int camera_set_preview_resolution(camera_h camera, int width, int height) @@ -2770,33 +2544,21 @@ int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation) } if (rotation < CAMERA_ROTATION_NONE || rotation > CAMERA_ROTATION_270) { + LOGE("Invalid rotation %d", rotation); return CAMERA_ERROR_INVALID_PARAMETER; } pc = (camera_cli_s *)camera; - if (pc->display_type == CAMERA_DISPLAY_TYPE_OVERLAY) { - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, - pc->cb_info->fd, pc->cb_info, ret, INT, set_rotation); - - return ret; - } - - if (pc->client_handle == NULL) { - LOGE("client handle is NULL"); - return CAMERA_ERROR_INVALID_OPERATION; + if (pc->cb_info == NULL) { + LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; } - ret = mm_camcorder_set_attributes(pc->client_handle, NULL, - MMCAM_DISPLAY_ROTATION, rotation, - NULL); + muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, + pc->cb_info->fd, pc->cb_info, ret, INT, set_rotation); - return __convert_camera_error_code(__func__, ret); + return ret; } int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation) @@ -2812,33 +2574,20 @@ int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation) pc = (camera_cli_s *)camera; - if (pc->display_type == CAMERA_DISPLAY_TYPE_OVERLAY) { - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, - pc->cb_info->fd, pc->cb_info, ret); - - if (ret == CAMERA_ERROR_NONE) { - muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg); - *rotation = (camera_rotation_e)get_rotation; - } - - return ret; + if (pc->cb_info == NULL) { + LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; } - if (pc->client_handle == NULL) { - LOGE("client handle is NULL"); - return CAMERA_ERROR_INVALID_OPERATION; - } + muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, + pc->cb_info->fd, pc->cb_info, ret); - ret = mm_camcorder_get_attributes(pc->client_handle, NULL, - MMCAM_DISPLAY_ROTATION, rotation, - NULL); + if (ret == CAMERA_ERROR_NONE) { + muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg); + *rotation = (camera_rotation_e)get_rotation; + } - return __convert_camera_error_code(__func__, ret); + return ret; } int camera_set_display_flip(camera_h camera, camera_flip_e flip) @@ -2853,32 +2602,21 @@ int camera_set_display_flip(camera_h camera, camera_flip_e flip) } if (flip < CAMERA_FLIP_NONE || flip > CAMERA_FLIP_BOTH) { + LOGE("Invalid flip %d", flip); return CAMERA_ERROR_INVALID_PARAMETER; } pc = (camera_cli_s *)camera; - if (pc->display_type == CAMERA_DISPLAY_TYPE_OVERLAY) { - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, - pc->cb_info->fd, pc->cb_info, ret, INT, set_flip); - - return ret; - } - if (pc->client_handle == NULL) { - LOGE("client handle is NULL"); - return CAMERA_ERROR_INVALID_OPERATION; + if (pc->cb_info == NULL) { + LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; } - ret = mm_camcorder_set_attributes(pc->client_handle, NULL, - MMCAM_DISPLAY_FLIP, flip, - NULL); + muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, + pc->cb_info->fd, pc->cb_info, ret, INT, set_flip); - return __convert_camera_error_code(__func__, ret); + return ret; } int camera_get_display_flip(camera_h camera, camera_flip_e *flip) @@ -2894,32 +2632,20 @@ int camera_get_display_flip(camera_h camera, camera_flip_e *flip) pc = (camera_cli_s *)camera; - if (pc->display_type == CAMERA_DISPLAY_TYPE_OVERLAY) { - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, - pc->cb_info->fd, pc->cb_info, ret); + if (pc->cb_info == NULL) { + LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } - if (ret == CAMERA_ERROR_NONE) { - muse_camera_msg_get(get_flip, pc->cb_info->recv_msg); - *flip = (camera_flip_e)get_flip; - } + muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, + pc->cb_info->fd, pc->cb_info, ret); - return ret; - } - if (pc->client_handle == NULL) { - LOGE("client handle is NULL"); - return CAMERA_ERROR_INVALID_OPERATION; + if (ret == CAMERA_ERROR_NONE) { + muse_camera_msg_get(get_flip, pc->cb_info->recv_msg); + *flip = (camera_flip_e)get_flip; } - ret = mm_camcorder_get_attributes(pc->client_handle, NULL, - MMCAM_DISPLAY_FLIP, flip, - NULL); - - return __convert_camera_error_code(__func__, ret); + return ret; } int camera_set_display_visible(camera_h camera, bool visible) @@ -2935,28 +2661,15 @@ int camera_set_display_visible(camera_h camera, bool visible) pc = (camera_cli_s *)camera; - if (pc->display_type == CAMERA_DISPLAY_TYPE_OVERLAY) { - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, - pc->cb_info->fd, pc->cb_info, ret, INT, set_visible); - - return ret; - } - - if (pc->client_handle == NULL) { - LOGE("client handle is NULL"); - return CAMERA_ERROR_INVALID_OPERATION; + if (pc->cb_info == NULL) { + LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; } - ret = mm_camcorder_set_attributes(pc->client_handle, NULL, - MMCAM_DISPLAY_VISIBLE, visible, - NULL); + muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, + pc->cb_info->fd, pc->cb_info, ret, INT, set_visible); - return __convert_camera_error_code(__func__, ret); + return ret; } int camera_is_display_visible(camera_h camera, bool *visible) @@ -2972,33 +2685,20 @@ int camera_is_display_visible(camera_h camera, bool *visible) pc = (camera_cli_s *)camera; - if (pc->display_type == CAMERA_DISPLAY_TYPE_OVERLAY) { - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - muse_camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, - pc->cb_info->fd, pc->cb_info, ret); - - if (ret == CAMERA_ERROR_NONE) { - muse_camera_msg_get(get_visible, pc->cb_info->recv_msg); - *visible = (bool)get_visible; - } - - return ret; + if (pc->cb_info == NULL) { + LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; } - if (pc->client_handle == NULL) { - LOGE("client handle is NULL"); - return CAMERA_ERROR_INVALID_OPERATION; - } + muse_camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, + pc->cb_info->fd, pc->cb_info, ret); - ret = mm_camcorder_get_attributes(pc->client_handle, NULL, - MMCAM_DISPLAY_VISIBLE, visible, - NULL); + if (ret == CAMERA_ERROR_NONE) { + muse_camera_msg_get(get_visible, pc->cb_info->recv_msg); + *visible = (bool)get_visible; + } - return __convert_camera_error_code(__func__, ret); + return ret; } int camera_set_display_mode(camera_h camera, camera_display_mode_e mode) @@ -3013,33 +2713,21 @@ int camera_set_display_mode(camera_h camera, camera_display_mode_e mode) } if (mode < CAMERA_DISPLAY_MODE_LETTER_BOX || mode > CAMERA_DISPLAY_MODE_CROPPED_FULL) { + LOGE("Invalid mode %d", mode); return CAMERA_ERROR_INVALID_PARAMETER; } pc = (camera_cli_s *)camera; - if (pc->display_type == CAMERA_DISPLAY_TYPE_OVERLAY) { - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_MODE, - pc->cb_info->fd, pc->cb_info, ret, INT, set_mode); - - return ret; - } - - if (pc->client_handle == NULL) { - LOGE("client handle is NULL"); - return CAMERA_ERROR_INVALID_OPERATION; + if (pc->cb_info == NULL) { + LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; } - ret = mm_camcorder_set_attributes(pc->client_handle, NULL, - MMCAM_DISPLAY_GEOMETRY_METHOD, mode, - NULL); + muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_MODE, + pc->cb_info->fd, pc->cb_info, ret, INT, set_mode); - return __convert_camera_error_code(__func__, ret); + return ret; } int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode) @@ -3055,32 +2743,20 @@ int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode) pc = (camera_cli_s *)camera; - if (pc->display_type == CAMERA_DISPLAY_TYPE_OVERLAY) { - if (pc->cb_info == NULL) { - LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); - return CAMERA_ERROR_INVALID_PARAMETER; - } - - muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, - pc->cb_info->fd, pc->cb_info, ret); + if (pc->cb_info == NULL) { + LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER); + return CAMERA_ERROR_INVALID_PARAMETER; + } - if (ret == CAMERA_ERROR_NONE) { - muse_camera_msg_get(get_mode, pc->cb_info->recv_msg); - *mode = (camera_display_mode_e)get_mode; - } + muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, + pc->cb_info->fd, pc->cb_info, ret); - return ret; - } - if (pc->client_handle == NULL) { - LOGE("client handle is NULL"); - return CAMERA_ERROR_INVALID_OPERATION; + if (ret == CAMERA_ERROR_NONE) { + muse_camera_msg_get(get_mode, pc->cb_info->recv_msg); + *mode = (camera_display_mode_e)get_mode; } - ret = mm_camcorder_get_attributes(pc->client_handle, NULL, - MMCAM_DISPLAY_GEOMETRY_METHOD, mode, - NULL); - - return __convert_camera_error_code(__func__, ret); + return ret; } int camera_get_capture_resolution(camera_h camera, int *width, int *height) @@ -5078,7 +4754,6 @@ 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; - int pid = 0; camera_cli_s *pc = NULL; int get_flash_state = 0; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index dacac39..6f469b2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -5,7 +5,7 @@ SET(fw_test "${fw_name}-test") #link_directories(${CMAKE_SOURCE_DIR}/../) INCLUDE(FindPkgConfig) -pkg_check_modules(${fw_test} REQUIRED mm-camcorder elementary evas ecore) +pkg_check_modules(${fw_test} REQUIRED elementary evas ecore) FOREACH(flag ${${fw_test}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") MESSAGE(${flag}) diff --git a/test/camera_test.c b/test/camera_test.c index e04d1ee..6ec0003 100644 --- a/test/camera_test.c +++ b/test/camera_test.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -44,7 +43,6 @@ Evas_Object *rect; GMainLoop *g_loop; GIOChannel *stdin_channel; camera_device_e cam_info; -GstCaps *filtercaps; int resolution_set; int g_current_state; int src_w, src_h; @@ -108,9 +106,6 @@ GTimeVal res; #define CAPTURE_FILENAME_LEN 256 #define MAX_STILLSHOT_CAPTURE_RESOLUTION_SUPPORTED 2 -#define DEFAULT_CAM_DEVICE MM_VIDEO_DEVICE_CAMERA1 - - #define CHECK_MM_ERROR(expr) \ do {\ int ret = 0; \ @@ -1054,7 +1049,7 @@ static void setting_menu(gchar buf) break; case 'S' : // Setting > flash state g_print("*flash state\n"); - err = camera_get_flash_state(cam_info, &idx); + err = camera_get_flash_state(cam_info, (camera_flash_state_e *)&idx); if (CAMERA_ERROR_NONE == err) g_print("Current flash state = %s\n", idx?"ON":"OFF"); else @@ -1412,10 +1407,6 @@ int main(int argc, char **argv) timer = g_timer_new(); - gst_init(&argc, &argv); - - LOGD("gst_init() : %12.6lfs", g_timer_elapsed(timer, NULL)); - hcamcorder = (cam_handle_t *) g_malloc0(sizeof(cam_handle_t)); camera_state = CAMERA_STATE_NONE; -- 2.7.4