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, MMCamcorderVideoStreamDataType *stream,
+static int __camera_create_media_packet(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,
+static int __camera_create_media_packet_data(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);
-static void __camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
+static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
static gboolean __camera_allocate_preview_buffer(camera_h camera);
static void __camera_release_preview_buffer(camera_h camera);
if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] ||
cb_info->is_evas_render ||
cb_info->bridge) {
- ret = __camera_media_packet_data_create(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
+ ret = __camera_create_media_packet_data(ret_fd, tfd, num_buffer_fd, bo, buffer_bo, data_bo, &mp_data);
if (ret != CAMERA_ERROR_NONE) {
- CAM_LOG_ERROR("__camera_media_packet_data_create failed[0x%x]", ret);
+ CAM_LOG_ERROR("__camera_create_media_packet_data failed[0x%x]", ret);
goto _PREVIEW_CB_HANDLER_DONE;
}
- ret = __camera_media_packet_create(cb_info, stream, mp_data, &pkt);
+ ret = __camera_create_media_packet(cb_info, stream, mp_data, &pkt);
if (ret != CAMERA_ERROR_NONE) {
- CAM_LOG_ERROR("__camera_media_packet_create failed[0x%x]", ret);
- __camera_media_packet_data_release(mp_data, cb_info);
+ CAM_LOG_ERROR("__camera_create_media_packet failed[0x%x]", ret);
+ __camera_release_media_packet_data(mp_data, cb_info);
mp_data = NULL;
goto _PREVIEW_CB_HANDLER_DONE;
}
}
-static int __camera_media_packet_data_create(int ret_fd, int *tfd, int num_buffer_fd, tbm_bo bo,
+static int __camera_create_media_packet_data(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)
{
int i = 0;
return ret;
}
-static void __camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
+static void __camera_release_media_packet_data(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
{
int i = 0;
}
-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_update_media_packet_format(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream)
{
- 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 ret = CAMERA_ERROR_NONE;
int pkt_fmt_width = 0;
int pkt_fmt_height = 0;
+ bool make_pkt_fmt = false;
+ media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
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);
+ if (!cb_info || !stream) {
+ CAM_LOG_ERROR("invalid parameter - %p, %p", cb_info, stream);
return CAMERA_ERROR_INVALID_PARAMETER;
}
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 */
if (cb_info->pkt_fmt) {
media_format_get_video_info(cb_info->pkt_fmt,
ret = media_format_create(&cb_info->pkt_fmt);
if (ret != MEDIA_FORMAT_ERROR_NONE) {
- CAM_LOG_WARNING("media_format_create failed 0x%x", ret);
- goto _PACKET_CREATE_FAILED;
+ CAM_LOG_ERROR("media_format_create failed 0x%x", ret);
+ return CAMERA_ERROR_INVALID_OPERATION;
}
ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
if (ret != MEDIA_FORMAT_ERROR_NONE) {
- CAM_LOG_WARNING("media format set failed 0x%x", ret);
- goto _PACKET_CREATE_FAILED;
+ CAM_LOG_ERROR("media format set failed 0x%x", ret);
+ return CAMERA_ERROR_INVALID_OPERATION;
}
}
+ return CAMERA_ERROR_NONE;
+}
+
+
+static int __camera_create_media_packet(camera_cb_info_s *cb_info, MMCamcorderVideoStreamDataType *stream,
+ camera_media_packet_data *mp_data, media_packet_h *packet)
+{
+ media_packet_h pkt = NULL;
+ tbm_surface_h tsurf = NULL;
+ int ret = 0;
+
+ if (!cb_info || !stream || !mp_data || !packet) {
+ CAM_LOG_ERROR("invalid parameter - %p, %p, %p, %p",
+ cb_info, stream, mp_data, packet);
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = __camera_update_media_packet_format(cb_info, stream);
+ 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;
+ }
+
/* create media packet */
ret = media_packet_new_from_tbm_surface(cb_info->pkt_fmt,
tsurf, (media_packet_dispose_cb)_camera_media_packet_dispose,
pkt, mp_data, tsurf);
g_mutex_lock(&cb_info->mp_data_mutex);
- __camera_media_packet_data_release(mp_data, cb_info);
+ __camera_release_media_packet_data(mp_data, cb_info);
g_mutex_unlock(&cb_info->mp_data_mutex);
if (tsurf)