summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeongmo Yang <jm80.yang@samsung.com>2018-08-30 14:14:21 +0900
committerJeongmo Yang <jm80.yang@samsung.com>2018-09-06 10:45:55 +0900
commitfdc9d10411bb4b5abe09b1920cf54a1d1a3a1af5 (patch)
treeab213086cd05d3dee0d97516cbbc9fcac0279cfc
parent57dd37427f0ce7b2fcc62530a8c06e3f9e689cee (diff)
parent036f74d969b35c8e4647d03dd0786497544006a1 (diff)
downloadcamera-fdc9d10411bb4b5abe09b1920cf54a1d1a3a1af5.tar.gz
camera-fdc9d10411bb4b5abe09b1920cf54a1d1a3a1af5.tar.bz2
camera-fdc9d10411bb4b5abe09b1920cf54a1d1a3a1af5.zip
Merge branch 'tizen' into tizen_line_coverage
Change-Id: I31b991e2a89522fb95354e50602117cc06e61666 Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
-rw-r--r--include/camera.h62
-rw-r--r--include/camera_private.h17
-rw-r--r--packaging/capi-media-camera.spec2
-rw-r--r--src/camera.c165
4 files changed, 151 insertions, 95 deletions
diff --git a/include/camera.h b/include/camera.h
index 21e6610..c5223f4 100644
--- a/include/camera.h
+++ b/include/camera.h
@@ -100,6 +100,8 @@ typedef enum {
/**
* @brief Enumeration for the camera pixel format.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks If #CAMERA_PIXEL_FORMAT_INVZ is set, the type of display should be #CAMERA_DISPLAY_TYPE_NONE. \n
+ * Otherwise, camera_start_preview() will return #CAMERA_ERROR_INVALID_OPERATION. (Since 5.0)
*/
typedef enum {
CAMERA_PIXEL_FORMAT_INVALID = -1, /**< Invalid pixel format */
@@ -118,6 +120,7 @@ typedef enum {
CAMERA_PIXEL_FORMAT_ARGB, /**< ARGB pixel format */
CAMERA_PIXEL_FORMAT_JPEG, /**< Encoded pixel format */
CAMERA_PIXEL_FORMAT_H264 = 15, /**< Encoded pixel format : H264 (Since 3.0) */
+ CAMERA_PIXEL_FORMAT_INVZ /**< Depth pixel format : INVZ (Since 5.0) */
} camera_pixel_format_e;
/**
@@ -224,37 +227,42 @@ typedef struct {
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef struct {
- camera_pixel_format_e format; /**< The format of the frame pixel */
- int width; /**< The width of the frame */
- int height; /**< The height of the frame */
- int num_of_planes; /**< The number of planes */
- unsigned int timestamp; /**< The timestamp of the frame */
+ camera_pixel_format_e format; /**< The format of the frame pixel */
+ int width; /**< The width of the frame */
+ int height; /**< The height of the frame */
+ int num_of_planes; /**< The number of planes */
+ unsigned int timestamp; /**< The timestamp of the frame */
union {
struct {
- unsigned char *yuv; /**< The yuv data pointer */
- unsigned int size; /**< The size of data */
- } single_plane; /**< single plane frame data */
+ unsigned char *yuv; /**< The yuv data pointer */
+ unsigned int size; /**< The size of data */
+ } single_plane; /**< Single plane frame data */
struct {
- unsigned char *y; /**< The y data pointer */
- unsigned char *uv; /**< The uv data pointer */
- unsigned int y_size; /**< The size of y data */
- unsigned int uv_size; /**< The size of uv data */
- } double_plane; /**< double plane frame data */
+ unsigned char *y; /**< The y data pointer */
+ unsigned char *uv; /**< The uv data pointer */
+ unsigned int y_size; /**< The size of y data */
+ unsigned int uv_size; /**< The size of uv data */
+ } double_plane; /**< Double plane frame data */
struct {
- unsigned char *y; /**< The y data pointer */
- unsigned char *u; /**< The u data pointer */
- unsigned char *v; /**< The v data pointer */
- unsigned int y_size; /**< The size of y data */
- unsigned int u_size; /**< The size of u data */
- unsigned int v_size; /**< The size of v data */
- } triple_plane; /**< triple plane frame data */
+ unsigned char *y; /**< The y data pointer */
+ unsigned char *u; /**< The u data pointer */
+ unsigned char *v; /**< The v data pointer */
+ unsigned int y_size; /**< The size of y data */
+ unsigned int u_size; /**< The size of u data */
+ unsigned int v_size; /**< The size of v data */
+ } triple_plane; /**< Triple plane frame data */
struct {
- unsigned char *data; /**< The encoded data pointer */
- unsigned int size; /**< The size of encoded data */
- } encoded_plane;
+ unsigned char *data; /**< The encoded data pointer */
+ unsigned int size; /**< The size of encoded data */
+ } encoded_plane; /**< Encoded plane frame data */
+
+ struct {
+ unsigned char *data; /**< The depth data pointer */
+ unsigned int size; /**< The size of depth data */
+ } depth_plane; /**< Depth plane frame data (Since 5.0) */
} data;
} camera_preview_data_s;
@@ -2324,6 +2332,8 @@ int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate);
/**
* @brief Sets the bit rate of encoded preview.
* @since_tizen 3.0
+ * @remarks The recommended range is from 1,000 (1 kbps) to 100,000,000 (100 Mbps). \n
+ * But, due to codec limitations, it may not apply.
* @param[in] camera The handle to the camera
* @param[in] bitrate The bit rate of encoded preview
* @return @c 0 on success, otherwise a negative error value
@@ -2347,13 +2357,15 @@ int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate);
* @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
* @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
- * @see camera_attr_get_encoded_preview_gop_interval()
+ * @see camera_attr_set_encoded_preview_gop_interval()
*/
int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval);
/**
* @brief Sets the GOP(Group Of Pictures) interval of encoded preview.
* @since_tizen 3.0
+ * @remarks The recommended range is from 1,000 (1 second) to 600,000 (10 minutes). \n
+ * But, due to codec limitations, it may not apply.
* @param[in] camera The handle to the camera
* @param[in] interval the GOP interval of encoded preview (millisecond)
* @return @c 0 on success, otherwise a negative error value
@@ -2362,7 +2374,7 @@ int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
* @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CAMERA_ERROR_NOT_SUPPORTED The feature is not supported
* @retval #CAMERA_ERROR_SERVICE_DISCONNECTED The socket to multimedia server is disconnected
- * @see camera_attr_set_encoded_preview_gop_interval()
+ * @see camera_attr_get_encoded_preview_gop_interval()
*/
int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval);
diff --git a/include/camera_private.h b/include/camera_private.h
index e419ec2..27bc050 100644
--- a/include/camera_private.h
+++ b/include/camera_private.h
@@ -80,7 +80,7 @@ typedef struct _camera_stream_data_s {
struct {
unsigned char *data;
unsigned int length_data;
- } encoded;
+ } encoded, depth;
} data; /**< pointer of captured stream */
int data_type; /**< data type */
unsigned int length_total; /**< total length of stream buffer (in byte)*/
@@ -143,17 +143,16 @@ typedef struct _camera_cb_info_s {
/* tbm */
tbm_bufmgr bufmgr;
- /* wayland */
- int parent_id;
-
/* media packet */
media_format_h pkt_fmt;
GMutex mp_data_mutex;
/* preview callback flag */
int preview_cb_flag;
+ camera_pixel_format_e preview_format;
- /* display interface handle */
+ /* display */
+ camera_display_type_e dp_type;
mm_display_interface_h dp_interface;
gboolean run_evas_render;
@@ -179,14 +178,6 @@ typedef struct _camera_idle_event_s {
GMutex event_mutex;
} camera_idle_event_s;
-typedef struct _camera_wl_info_s {
- int parent_id;
- int window_x;
- int window_y;
- int window_width;
- int window_height;
-} camera_wl_info_s;
-
typedef struct _camera_cli_s {
intptr_t remote_handle;
camera_cb_info_s *cb_info;
diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec
index 69ec2c5..4edd005 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.4.9
+Version: 0.4.14
Release: 0
Group: Multimedia/API
License: Apache-2.0
diff --git a/src/camera.c b/src/camera.c
index 1c3ffac..3b20e70 100644
--- a/src/camera.c
+++ b/src/camera.c
@@ -46,6 +46,8 @@ 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 void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
+ int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout);
static 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,
@@ -666,6 +668,65 @@ static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
}
+static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
+ int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
+{
+ int func_ret = CAMERA_ERROR_NONE;
+ int send_ret = 0;
+ char *msg = NULL;
+
+ if (!cb_info || !param0 || !param1) {
+ LOGE("invalid ptr %p %p %p : api %d",
+ cb_info, param0, param1, api);
+ func_ret = CAMERA_ERROR_INVALID_PARAMETER;
+ goto _SEND_PARAM2_INT_DONE;
+ }
+
+ /*LOGD("api %d, param0 [%s:%d], param1 [%s:%d]",
+ api,
+ param0->name, param0->value.value_INT,
+ param1->name, param1->value.value_INT);*/
+
+ msg = muse_core_msg_new(api,
+ param0->type, param0->name, param0->value.value_INT,
+ param1->type, param1->name, param1->value.value_INT,
+ NULL);
+ if (!msg) {
+ LOGE("msg failed: api %d", api);
+ func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
+ goto _SEND_PARAM2_INT_DONE;
+ }
+
+ /*LOGD("send msg [%s]", msg);*/
+
+ if (cb_info->is_server_connected) {
+ __camera_update_api_waiting(cb_info, api, 1);
+
+ g_mutex_lock(&cb_info->fd_lock);
+ send_ret = muse_core_msg_send(cb_info->fd, msg);
+ g_mutex_unlock(&cb_info->fd_lock);
+ }
+
+ if (send_ret < 0) {
+ LOGE("msg send failed");
+
+ func_ret = CAMERA_ERROR_INVALID_OPERATION;
+ } else {
+ func_ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
+ }
+
+ __camera_update_api_waiting(cb_info, api, -1);
+
+ muse_core_msg_free(msg);
+
+_SEND_PARAM2_INT_DONE:
+ if (ret)
+ *ret = func_ret;
+
+ return;
+}
+
+
int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
{
if (in_format <= MM_PIXEL_FORMAT_INVALID ||
@@ -819,6 +880,10 @@ static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_b
frame->data.encoded_plane.data = buf_pos;
frame->data.encoded_plane.size = stream->data.encoded.length_data;
total_size = stream->data.encoded.length_data;
+ } else if (stream->format == MM_PIXEL_FORMAT_INVZ) {
+ frame->data.depth_plane.data = buf_pos;
+ frame->data.depth_plane.size = stream->data.depth.length_data;
+ total_size = stream->data.depth.length_data;
} else {
switch (stream->num_planes) {
case 1:
@@ -1843,7 +1908,7 @@ static void *_camera_msg_recv_func(gpointer data)
recv_msg = cb_info->recv_msg;
while (g_atomic_int_get(&cb_info->msg_recv_running)) {
- recv_length = muse_core_msg_recv(cb_info->fd, recv_msg);
+ recv_length = muse_core_msg_recv(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH);
if (recv_length <= 0) {
cb_info->is_server_connected = FALSE;
LOGE("receive msg failed - server disconnected");
@@ -2296,7 +2361,7 @@ int _camera_independent_request(int api, int device_type, const char *key, int *
goto _REQUEST_EXIT;
}
- ret = muse_core_msg_recv(sock_fd, recv_msg);
+ ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
if (ret <= 0) {
LOGE("recv msg failed %d", errno);
ret = CAMERA_ERROR_INVALID_OPERATION;
@@ -2406,6 +2471,7 @@ int camera_create(camera_device_e device, camera_h *camera)
if (ret == CAMERA_ERROR_NONE) {
intptr_t handle = 0;
+
muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
if (handle == 0) {
LOGE("Receiving Handle Failed!!");
@@ -2423,7 +2489,18 @@ int camera_create(camera_device_e device, camera_h *camera)
}
LOGD("camera create 0x%x", pc->remote_handle);
+
*camera = (camera_h)pc;
+
+ /* get display interface handle */
+ if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
+ LOGW("display interface init failed");
+
+ /* get default preview format */
+ if (camera_get_preview_format(*camera, &pc->cb_info->preview_format) != CAMERA_ERROR_NONE) {
+ LOGW("get default preview format failed");
+ pc->cb_info->preview_format = CAMERA_PIXEL_FORMAT_INVALID;
+ }
} else {
goto ErrorExit;
}
@@ -2540,7 +2617,15 @@ int camera_start_preview(camera_h camera)
return CAMERA_ERROR_INVALID_PARAMETER;
}
- LOGD("Enter");
+ LOGD("Enter : preview format %d, display type %d",
+ pc->cb_info->preview_format, pc->cb_info->dp_type);
+
+ if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
+ pc->cb_info->dp_type != CAMERA_DISPLAY_TYPE_NONE) {
+ LOGE("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
+ pc->cb_info->dp_type);
+ return CAMERA_ERROR_INVALID_OPERATION;
+ }
_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)) {
@@ -2935,13 +3020,13 @@ int camera_cancel_focusing(camera_h camera)
int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
{
int ret = CAMERA_ERROR_NONE;
+ int parent_id = 0;
camera_cli_s *pc = (camera_cli_s *)camera;
camera_cb_info_s *cb_info = NULL;
- muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
camera_state_e current_state = CAMERA_STATE_NONE;
- camera_msg_param param;
- char *msg = NULL;
- int length = 0;
+ camera_msg_param param0;
+ camera_msg_param param1;
+ muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
if (!pc || !pc->cb_info) {
LOGE("NULL handle");
@@ -2971,20 +3056,16 @@ int camera_set_display(camera_h camera, camera_display_type_e type, camera_displ
return CAMERA_ERROR_INVALID_STATE;
}
- LOGD("Enter - display : %p", display);
+ LOGD("Enter - type : %d, display : %p", type, display);
- if (type == CAMERA_DISPLAY_TYPE_NONE) {
- LOGD("display type NONE");
- } else {
- /* display interface handle */
+ if (type != CAMERA_DISPLAY_TYPE_NONE) {
+ /* check display interface handle */
if (!cb_info->dp_interface) {
- if (mm_display_interface_init(&cb_info->dp_interface) != MM_ERROR_NONE) {
- LOGE("display interface init failed");
- return CAMERA_ERROR_NOT_SUPPORTED;
- }
+ LOGE("display interface not supported");
+ return CAMERA_ERROR_NOT_SUPPORTED;
}
- ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &cb_info->parent_id);
+ ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &parent_id);
if (ret != MM_ERROR_NONE) {
LOGE("[INVALID_OPERATION] set display failed[0x%x]", ret);
return CAMERA_ERROR_INVALID_OPERATION;
@@ -3021,50 +3102,19 @@ int camera_set_display(camera_h camera, camera_display_type_e type, camera_displ
}
}
- if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
- int send_ret = 0;
+ CAMERA_MSG_PARAM_SET(param0, INT, type);
+ CAMERA_MSG_PARAM_SET(param1, INT, parent_id);
- length = sizeof(camera_wl_info_s) / sizeof(int) + \
- (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
+ _camera_msg_send_param2_int(api, cb_info, &ret,
+ &param0, &param1, CAMERA_CB_TIMEOUT);
- msg = muse_core_msg_new(api,
- MUSE_TYPE_INT, "type", type,
- MUSE_TYPE_INT, "parent_id", cb_info->parent_id,
- NULL);
- if (!msg) {
- LOGE("msg creation failed: api %d", api);
- return CAMERA_ERROR_OUT_OF_MEMORY;
- }
-
- if (pc->cb_info->is_server_connected) {
- __camera_update_api_waiting(pc->cb_info, api, 1);
-
- g_mutex_lock(&pc->cb_info->fd_lock);
- send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
- g_mutex_unlock(&pc->cb_info->fd_lock);
- }
-
- if (send_ret < 0) {
- LOGE("message send failed");
- ret = CAMERA_ERROR_INVALID_OPERATION;
- } else {
- ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
- }
-
- __camera_update_api_waiting(pc->cb_info, api, -1);
-
- muse_core_msg_free(msg);
- } else {
- CAMERA_MSG_PARAM_SET(param, INT, type);
+ if (ret == CAMERA_ERROR_NONE) {
+ pc->cb_info->dp_type = type;
- _camera_msg_send_param1(api, pc->cb_info, &ret, &param, CAMERA_CB_TIMEOUT);
+ if (type == CAMERA_DISPLAY_TYPE_EVAS)
+ SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
}
- if (ret != CAMERA_ERROR_NONE)
- LOGE("set display error 0x%x", ret);
- else if (type == CAMERA_DISPLAY_TYPE_EVAS)
- SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
-
return ret;
}
@@ -3185,6 +3235,9 @@ int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
_camera_msg_send_param1(api, pc->cb_info, &ret, &param, CAMERA_CB_TIMEOUT);
+ if (ret == CAMERA_ERROR_NONE)
+ pc->cb_info->preview_format = set_format;
+
LOGD("ret : 0x%x", ret);
return ret;