static bool __mmcamcorder_find_max_resolution(MMHandleType handle, gint *max_width, gint *max_height);
#endif /* _MMCAMCORDER_PRODUCT_TV */
-static gboolean __mmcamcorder_set_stream_data(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMemory *memory);
+static gboolean __mmcamcorder_set_stream_data(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMapInfo *map_info);
static gboolean __mmcamcorder_set_stream_data_zero_copy(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMemory *memory);
/*=======================================================================================
| FUNCTION DEFINITIONS |
=======================================================================================*/
-static gboolean __mmcamcorder_set_stream_data(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMemory *memory)
+static gboolean __mmcamcorder_set_stream_data(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMapInfo *map_info)
{
gboolean ret = TRUE;
- GstMapInfo map_info;
mmf_return_val_if_fail(buffer, FALSE);
mmf_return_val_if_fail(stream, FALSE);
+ mmf_return_val_if_fail(map_info, FALSE);
- memset(&map_info, 0x0, sizeof(GstMapInfo));
-
- if (!gst_memory_map(memory, &map_info, GST_MAP_READWRITE)) {
- MMCAM_LOG_ERROR("map failed for memory[%p]", memory);
- return FALSE;
- }
-
- stream->length_total = gst_memory_get_sizes(memory, NULL, NULL);
+ stream->length_total = map_info->size;
switch (stream->format) {
case MM_PIXEL_FORMAT_NV12: /* fall through */
case MM_PIXEL_FORMAT_NV21:
stream->data_type = MM_CAM_STREAM_DATA_YUV420SP;
- stream->data.yuv420sp.y = map_info.data;
+ stream->data.yuv420sp.y = map_info->data;
stream->data.yuv420sp.length_y = stream->width * stream->height;
stream->data.yuv420sp.uv = stream->data.yuv420sp.y + stream->data.yuv420sp.length_y;
stream->data.yuv420sp.length_uv = stream->data.yuv420sp.length_y >> 1;
case MM_PIXEL_FORMAT_I420:
stream->data_type = MM_CAM_STREAM_DATA_YUV420P;
- stream->data.yuv420p.y = map_info.data;
+ stream->data.yuv420p.y = map_info->data;
stream->data.yuv420p.length_y = stream->width * stream->height;
stream->data.yuv420p.u = stream->data.yuv420p.y + stream->data.yuv420p.length_y;
stream->data.yuv420p.length_u = stream->data.yuv420p.length_y >> 2;
case MM_PIXEL_FORMAT_422P:
stream->data_type = MM_CAM_STREAM_DATA_YUV422P;
- stream->data.yuv422p.y = map_info.data;
+ stream->data.yuv422p.y = map_info->data;
stream->data.yuv422p.length_y = stream->width * stream->height;
stream->data.yuv422p.u = stream->data.yuv422p.y + stream->data.yuv422p.length_y;
stream->data.yuv422p.length_u = stream->data.yuv422p.length_y >> 1;
case MM_PIXEL_FORMAT_UYVY: /* fall through */
case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
stream->data_type = MM_CAM_STREAM_DATA_YUV422;
- stream->data.yuv422.yuv = map_info.data;
+ stream->data.yuv422.yuv = map_info->data;
stream->data.yuv422.length_yuv = stream->length_total;
stream->stride[0] = stream->width << 1;
stream->elevation[0] = stream->height;
case MM_PIXEL_FORMAT_ENCODED_VP8: /* fall through */
case MM_PIXEL_FORMAT_ENCODED_VP9: /* fall through */
stream->data_type = MM_CAM_STREAM_DATA_ENCODED;
- stream->data.encoded.data = map_info.data;
+ stream->data.encoded.data = map_info->data;
stream->data.encoded.length_data = stream->length_total;
stream->data.encoded.is_delta_frame = GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT);
stream->num_planes = 1;
case MM_PIXEL_FORMAT_INVZ:
stream->data_type = MM_CAM_STREAM_DATA_DEPTH;
- stream->data.depth.data = map_info.data;
+ stream->data.depth.data = map_info->data;
stream->data.depth.length_data = stream->length_total;
stream->stride[0] = stream->width << 1;
stream->elevation[0] = stream->height;
case MM_PIXEL_FORMAT_RGBA: /* fall through */
case MM_PIXEL_FORMAT_ARGB:
stream->data_type = MM_CAM_STREAM_DATA_RGB;
- stream->data.rgb.data = map_info.data;
+ stream->data.rgb.data = map_info->data;
stream->data.rgb.length_data = stream->length_total;
stream->stride[0] = stream->width << 2;
stream->elevation[0] = stream->height;
break;
}
- gst_memory_unmap(memory, &map_info);
-
return ret;
}
GstBuffer *buffer = NULL;
GstMemory *memory = NULL;
+ GstMapInfo map_info;
GstCaps *caps = NULL;
GstStructure *structure = NULL;
if (!__mmcamcorder_set_stream_data_zero_copy(&stream, buffer, memory))
goto _INVOKE_VIDEO_STREAM_CB_DONE;
} else {
- if (!__mmcamcorder_set_stream_data(&stream, buffer, memory))
+ memset(&map_info, 0x0, sizeof(GstMapInfo));
+
+ if (!gst_memory_map(memory, &map_info, GST_MAP_READWRITE)) {
+ MMCAM_LOG_ERROR("map failed for memory[%p]", memory);
+ return FALSE;
+ }
+
+ if (!__mmcamcorder_set_stream_data(&stream, buffer, &map_info))
goto _INVOKE_VIDEO_STREAM_CB_DONE;
}
}
_INVOKE_VIDEO_STREAM_CB_DONE:
+ if (!gst_is_tizen_memory(memory))
+ gst_memory_unmap(memory, &map_info);
+
for (i = 0 ; i < TBM_SURF_PLANE_MAX && stream.bo[i] ; i++) {
tbm_bo_map(stream.bo[i], TBM_DEVICE_CPU, TBM_OPTION_READ|TBM_OPTION_WRITE);
tbm_bo_unmap(stream.bo[i]);