diff options
author | Jeongmo Yang <jm80.yang@samsung.com> | 2022-01-18 21:23:42 +0900 |
---|---|---|
committer | Jeongmo Yang <jm80.yang@samsung.com> | 2022-01-26 19:56:24 +0900 |
commit | d0fbc7bc055409094e3ad93dabccb37b9597e916 (patch) | |
tree | c1b6c8db3e0b2ced096c715c40a1f0331f6f93ba | |
parent | a25689453043863db897f98944dce092b7e08acd (diff) | |
download | camera-d0fbc7bc055409094e3ad93dabccb37b9597e916.tar.gz camera-d0fbc7bc055409094e3ad93dabccb37b9597e916.tar.bz2 camera-d0fbc7bc055409094e3ad93dabccb37b9597e916.zip |
Add sub function to create tbm surface
- Minor change
: Remove duplicated structure and definition.
: Add missing dependency in pc file.
[Version] 0.4.72
[Issue Type] Update
Change-Id: I3196a2ae26fa2d874a7604f9ecde0a2f0eb4e840
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | include/camera_internal.h | 52 | ||||
-rw-r--r-- | include/camera_private.h | 2 | ||||
-rw-r--r-- | packaging/capi-media-camera.spec | 5 | ||||
-rw-r--r-- | src/camera.c | 93 | ||||
-rw-r--r-- | src/camera_internal.c | 2 |
6 files changed, 71 insertions, 87 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cb03ea..ca27ab3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,8 +9,8 @@ SET(service "media") SET(submodule "camera") # for package file -SET(dependents "glib-2.0 gio-2.0 libtbm dlog mm-common capi-base-common capi-media-tool mmsvc-camera muse-client mm-display-interface") -SET(pc_dependents "capi-base-common capi-media-tool mm-common") +SET(dependents "glib-2.0 gio-2.0 libtbm dlog mm-common mm-camcorder capi-base-common capi-media-tool mmsvc-camera muse-client mm-display-interface") +SET(pc_dependents "capi-base-common capi-media-tool libtbm mm-common mm-camcorder") SET(fw_name "${project_prefix}-${service}-${submodule}") PROJECT(${fw_name}) diff --git a/include/camera_internal.h b/include/camera_internal.h index 51ae1fe..c0bf836 100644 --- a/include/camera_internal.h +++ b/include/camera_internal.h @@ -19,6 +19,7 @@ #include <camera.h> #include <mm_types.h> +#include <mm_camcorder.h> #include <tbm_surface_internal.h> #ifdef __cplusplus @@ -36,59 +37,10 @@ extern "C" { * @{ */ -#ifdef BUFFER_MAX_PLANE_NUM -#undef BUFFER_MAX_PLANE_NUM -#endif /* BUFFER_MAX_PLANE_NUM */ - -#define BUFFER_MAX_PLANE_NUM 4 #define CAMERA_DEVICE_MAX ((CAMERA_DEVICE_CAMERA9 + 1) * 2) #define DEVICE_NAME_MAX_LENGTH 64 #define DEVICE_ID_MAX_LENGTH 64 -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; - int is_delta_frame; - } encoded, depth, rgb; - } 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 */ - int extra_stream_id; /**< ID of extra preview stream */ - int focus_state; /**< Focus state */ - int facing_direction; /**< Facing direction */ - int flip; /**< Flip */ - int rotation; /**< Rotation */ -} camera_stream_data_s; - typedef enum { CAMERA_DEVICE_TYPE_BUILTIN = 0, /**< Built-in camera */ @@ -201,7 +153,7 @@ int camera_set_ecore_wl_display(camera_h camera, void *ecore_wl_window); * @param[in] data_bo_handle The bo handle of data * @param[out] frame The frame which will be filled */ -void camera_create_preview_frame(camera_stream_data_s *stream, int num_buffer_fd, +void camera_create_preview_frame(MMCamcorderVideoStreamDataType *stream, int num_buffer_fd, tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame); /** diff --git a/include/camera_private.h b/include/camera_private.h index 01fbddf..aa95198 100644 --- a/include/camera_private.h +++ b/include/camera_private.h @@ -177,7 +177,7 @@ typedef struct _camera_cb_info_s { GMutex bridge_lock; /* preview stream */ - camera_stream_data_s *stream_data; + MMCamcorderVideoStreamDataType *stream_data; } camera_cb_info_s; typedef struct _camera_message_s { diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec index d744337..cf5246c 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.4.71 -Release: 1 +Version: 0.4.72 +Release: 0 Group: Multimedia/API License: Apache-2.0 Source0: %{name}-%{version}.tar.gz @@ -11,6 +11,7 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(muse-client) BuildRequires: pkgconfig(mm-common) +BuildRequires: pkgconfig(mm-camcorder) BuildRequires: pkgconfig(mm-display-interface) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(mmsvc-camera) diff --git a/src/camera.c b/src/camera.c index 46679c0..bb180cd 100644 --- a/src/camera.c +++ b/src/camera.c @@ -20,6 +20,7 @@ #include <string.h> #include <mm.h> #include <mm_types.h> +#include <mm_camcorder.h> #include <muse_camera_msg.h> #include <camera_private.h> #include <muse_client.h> @@ -46,7 +47,7 @@ static int g_camera_log_level = CAMERA_LOG_LEVEL_INFO; static bool __camera_import_tbm_fd(tbm_bufmgr bufmgr, int fd, tbm_bo *bo, tbm_bo_handle *bo_handle); static void __camera_release_imported_bo(tbm_bo *bo); -static 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, MMCamcorderVideoStreamDataType *stream, camera_media_packet_data *mp_data, media_packet_h *packet); static int __camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo, tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data); @@ -279,7 +280,7 @@ static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv camera_msg_param param; camera_preview_data_s frame; - camera_stream_data_s *stream = NULL; + MMCamcorderVideoStreamDataType *stream = NULL; camera_media_packet_data *mp_data = NULL; media_packet_h pkt = NULL; @@ -330,7 +331,7 @@ static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv buf_pos = (unsigned char *)bo_handle.ptr; /* get stream info */ - stream = (camera_stream_data_s *)buf_pos; + stream = (MMCamcorderVideoStreamDataType *)buf_pos; for (i = 0 ; i < num_buffer_fd ; i++) { /* import buffer bo and get virtual address */ @@ -1119,43 +1120,32 @@ static void __camera_media_packet_data_release(camera_media_packet_data *mp_data g_free(mp_data); } -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 tbm_surface_h __camera_get_tbm_surface(MMCamcorderVideoStreamDataType *stream, camera_media_packet_data *mp_data) { - media_packet_h pkt = NULL; - bool make_pkt_fmt = false; - tbm_surface_h tsurf = NULL; - tbm_surface_info_s tsurf_info; - media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12; - uint32_t bo_format = 0; - int ret = 0; int i = 0; + int ret = CAMERA_ERROR_NONE; int num_buffer_fd = 0; - int pkt_fmt_width = 0; - int pkt_fmt_height = 0; + uint32_t bo_format = 0; tbm_bo *buffer_bo = NULL; - media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12; + tbm_surface_info_s tsurf_info; - if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) { - CAM_LOG_ERROR("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p", - cb_info, stream, mp_data, packet); - return CAMERA_ERROR_INVALID_PARAMETER; + if (!stream || !mp_data) { + CAM_LOG_ERROR("NULL param [%p,%p]", stream, mp_data); + return NULL; } - memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s)); - buffer_bo = mp_data->buffer_bo; num_buffer_fd = mp_data->num_buffer_fd; - /* create tbm surface */ + memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s)); + for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++) tsurf_info.planes[i].stride = stream->stride[i]; - /* get tbm surface format */ ret = _camera_get_tbm_surface_format(stream->format, &bo_format); - ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype); if (ret != CAMERA_ERROR_NONE) - return ret; + return NULL; tsurf_info.width = stream->width; tsurf_info.height = stream->height; @@ -1198,7 +1188,7 @@ static int __camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream //LCOV_EXCL_STOP } - tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_fd); + return tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_fd); } else if (mp_data->data_bo) { //LCOV_EXCL_START switch (bo_format) { @@ -1230,14 +1220,55 @@ static int __camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream break; } - tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1); + return tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1); //LCOV_EXCL_STOP } - if (!tsurf) { - CAM_LOG_ERROR("tbm surface failed. %dx%d, format %d, num_buffer_fd %d, data_bo %p", - stream->width, stream->height, stream->format, num_buffer_fd, mp_data->data_bo); - return CAMERA_ERROR_INVALID_OPERATION; + CAM_LOG_ERROR("should not be reached here"); + + return NULL; +} + + +static int __camera_media_packet_create(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream, + camera_media_packet_data *mp_data, media_packet_h *packet) +{ + media_packet_h pkt = NULL; + bool make_pkt_fmt = false; + tbm_surface_h tsurf = NULL; + media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12; + int ret = 0; + int pkt_fmt_width = 0; + int pkt_fmt_height = 0; + media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12; + + if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) { + CAM_LOG_ERROR("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p", + cb_info, stream, mp_data, packet); + return CAMERA_ERROR_INVALID_PARAMETER; + } + + ret = _camera_get_media_packet_mimetype(stream->format, &mimetype); + if (ret != CAMERA_ERROR_NONE) + return ret; + + switch (stream->data_type) { + case MM_CAM_STREAM_DATA_ENCODED: + /* TODO */ + break; + case MM_CAM_STREAM_DATA_DEPTH: + /* TODO */ + break; + case MM_CAM_STREAM_DATA_RGB: + break; + default: /* YUV */ + tsurf = __camera_get_tbm_surface(stream, mp_data); + if (!tsurf) { + CAM_LOG_ERROR("tbm surface failed. %dx%d, format %d, num_buffer_fd %d, data_bo %p", + stream->width, stream->height, stream->format, mp_data->num_buffer_fd, mp_data->data_bo); + return CAMERA_ERROR_INVALID_OPERATION; + } + break; } /* check media packet format */ diff --git a/src/camera_internal.c b/src/camera_internal.c index 15e50d6..6618838 100644 --- a/src/camera_internal.c +++ b/src/camera_internal.c @@ -58,7 +58,7 @@ int camera_set_ecore_wl_display(camera_h camera, void *ecore_wl_window) //LCOV_EXCL_STOP -void camera_create_preview_frame(camera_stream_data_s *stream, int num_buffer_fd, +void camera_create_preview_frame(MMCamcorderVideoStreamDataType *stream, int num_buffer_fd, tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame) { int total_size = 0; |