summaryrefslogtreecommitdiff
path: root/src/camera.c
diff options
context:
space:
mode:
authorJeongmo Yang <jm80.yang@samsung.com>2022-01-18 21:23:42 +0900
committerJeongmo Yang <jm80.yang@samsung.com>2022-01-26 19:56:24 +0900
commitd0fbc7bc055409094e3ad93dabccb37b9597e916 (patch)
treec1b6c8db3e0b2ced096c715c40a1f0331f6f93ba /src/camera.c
parenta25689453043863db897f98944dce092b7e08acd (diff)
downloadcamera-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>
Diffstat (limited to 'src/camera.c')
-rw-r--r--src/camera.c93
1 files changed, 62 insertions, 31 deletions
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 */