*/
/*=======================================================================================
-| INCLUDE FILES |
+| INCLUDE FILES |
=======================================================================================*/
#include <gst/allocators/gsttizenmemory.h>
#include <gst/audio/audio-format.h>
#include "mm_camcorder_gstcommon.h"
/*-----------------------------------------------------------------------
-| GLOBAL VARIABLE DEFINITIONS for internal |
+| GLOBAL VARIABLE DEFINITIONS for internal |
-----------------------------------------------------------------------*/
/* Table for compatibility between audio codec and file format */
gboolean audiocodec_fileformat_compatibility_table[MM_AUDIO_CODEC_NUM][MM_FILE_FORMAT_NUM] = {
/*-----------------------------------------------------------------------
-| LOCAL VARIABLE DEFINITIONS for internal |
+| LOCAL VARIABLE DEFINITIONS for internal |
-----------------------------------------------------------------------*/
#define USE_AUDIO_CLOCK_TUNE
#define _MMCAMCORDER_WAIT_EOS_TIME 60.0 /* sec */
/*-----------------------------------------------------------------------
-| LOCAL FUNCTION PROTOTYPES: |
+| LOCAL FUNCTION PROTOTYPES: |
-----------------------------------------------------------------------*/
/* STATIC INTERNAL FUNCTION */
/**
static bool __mmcamcorder_find_max_resolution(MMHandleType handle, gint *max_width, gint *max_height);
#endif /* _MMCAMCORDER_PRODUCT_TV */
+static gboolean __mmcamcorder_set_stream_data_tbm(MMCamcorderVideoStreamDataType *stream, tbm_surface_info_s *ts_info);
+static gboolean __mmcamcorder_set_stream_data_normal(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMapInfo *map_info);
+
/*=======================================================================================
-| FUNCTION DEFINITIONS |
+| FUNCTION DEFINITIONS |
=======================================================================================*/
-/*-----------------------------------------------------------------------
-| GLOBAL FUNCTION DEFINITIONS: |
------------------------------------------------------------------------*/
+static gboolean __mmcamcorder_set_stream_data_normal(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMapInfo *map_info)
+{
+ mmf_return_val_if_fail(buffer, FALSE);
+ mmf_return_val_if_fail(map_info, FALSE);
+ mmf_return_val_if_fail(stream, FALSE);
+
+ switch (stream->format) {
+ case MM_PIXEL_FORMAT_NV12: /* fall through */
+ case MM_PIXEL_FORMAT_NV21:
+ 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;
+ stream->stride[0] = stream->width;
+ stream->elevation[0] = stream->height;
+ stream->stride[1] = stream->width;
+ stream->elevation[1] = stream->height >> 1;
+ stream->num_planes = 2;
+ break;
+
+ case MM_PIXEL_FORMAT_I420:
+ 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;
+ stream->data.yuv420p.v = stream->data.yuv420p.u + stream->data.yuv420p.length_u;
+ stream->data.yuv420p.length_v = stream->data.yuv420p.length_u;
+ stream->stride[0] = stream->width;
+ stream->elevation[0] = stream->height;
+ stream->stride[1] = stream->stride[2] = stream->width >> 1;
+ stream->elevation[1] = stream->elevation[2] = stream->height >> 1;
+ stream->num_planes = 3;
+ break;
+
+ case MM_PIXEL_FORMAT_YUYV: /* fall through */
+ case MM_PIXEL_FORMAT_UYVY: /* fall through */
+ case MM_PIXEL_FORMAT_422P: /* 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.length_yuv = stream->length_total;
+ stream->stride[0] = stream->width << 1;
+ stream->elevation[0] = stream->height;
+ stream->num_planes = 1;
+ break;
+
+ case MM_PIXEL_FORMAT_ENCODED_H264: /* fall through */
+ case MM_PIXEL_FORMAT_ENCODED_MJPEG:
+ stream->data_type = MM_CAM_STREAM_DATA_ENCODED;
+ 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;
+ break;
+
+ case MM_PIXEL_FORMAT_INVZ:
+ stream->data_type = MM_CAM_STREAM_DATA_DEPTH;
+ 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;
+ stream->num_planes = 1;
+ break;
+
+ 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.length_data = stream->length_total;
+ stream->stride[0] = stream->width << 2;
+ stream->elevation[0] = stream->height;
+ stream->num_planes = 1;
+ break;
+
+ default:
+ _mmcam_dbg_err("unsupported format[%d]", stream->format);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+static gboolean __mmcamcorder_set_stream_data_tbm(MMCamcorderVideoStreamDataType *stream, tbm_surface_info_s *ts_info)
+{
+ mmf_return_val_if_fail(ts_info, FALSE);
+ mmf_return_val_if_fail(stream, FALSE);
+
+ switch (stream->format) {
+ case MM_PIXEL_FORMAT_NV12: /* fall through */
+ case MM_PIXEL_FORMAT_NV21:
+ stream->data_type = MM_CAM_STREAM_DATA_YUV420SP;
+ stream->num_planes = 2;
+ stream->data.yuv420sp.y = ts_info->planes[0].ptr;
+ stream->data.yuv420sp.length_y = ts_info->planes[0].size;
+ stream->data.yuv420sp.uv = ts_info->planes[1].ptr;
+ stream->data.yuv420sp.length_uv = ts_info->planes[1].size;
+ break;
+
+ case MM_PIXEL_FORMAT_I420:
+ stream->data_type = MM_CAM_STREAM_DATA_YUV420P;
+ stream->num_planes = 3;
+ stream->data.yuv420p.y = ts_info->planes[0].ptr;
+ stream->data.yuv420p.length_y = ts_info->planes[0].size;
+ stream->data.yuv420p.u = ts_info->planes[1].ptr;
+ stream->data.yuv420p.length_u = ts_info->planes[1].size;
+ stream->data.yuv420p.v = ts_info->planes[2].ptr;
+ stream->data.yuv420p.length_v = ts_info->planes[2].size;
+ break;
+
+ default:
+ _mmcam_dbg_err("unsupported format[%d]", stream->format);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+gboolean _mmcamcorder_invoke_video_stream_cb(MMHandleType handle, GstBuffer *buffer, gboolean is_preview)
+{
+ int i = 0;
+ int num_bos = 0;
+ gboolean ret_cb = TRUE;
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+ _MMCamcorderSubContext *sc = NULL;
+ MMCamcorderVideoStreamDataType stream;
+
+ tbm_surface_h t_surface = NULL;
+ tbm_surface_info_s ts_info;
+
+ GstMemory *memory = NULL;
+ GstMapInfo map_info;
+
+ mmf_return_val_if_fail(hcamcorder, FALSE);
+ mmf_return_val_if_fail(buffer, FALSE);
+ mmf_return_val_if_fail(gst_buffer_n_memory(buffer), FALSE);
+
+ sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
+ mmf_return_val_if_fail(sc, FALSE);
+
+ /* clear data structure */
+ memset(&map_info, 0x0, sizeof(GstMapInfo));
+ memset(&stream, 0x0, sizeof(MMCamcorderVideoStreamDataType));
+
+ stream.format = sc->info_image->preview_format;
+ if (is_preview) {
+ /* preview buffer */
+ stream.width = sc->info_video->preview_width;
+ stream.height = sc->info_video->preview_height;
+ } else {
+ /* video recording buffer */
+ stream.width = sc->info_video->video_width;
+ stream.height = sc->info_video->video_height;
+ }
+
+ /*
+ _mmcam_dbg_log("VideoStreamData : resolution[%dx%d], format[%d]",
+ stream.width, stream.height, stream.format);
+ */
+
+ /* set size and timestamp */
+ if (_mmcamcorder_is_encoded_preview_pixel_format(stream.format))
+ memory = gst_buffer_get_all_memory(buffer);
+ else
+ memory = gst_buffer_peek_memory(buffer, 0);
+ if (!memory) {
+ _mmcam_dbg_err("GstMemory get failed from buffer %p", buffer);
+ return FALSE;
+ }
+
+ /* set zero-copy related information */
+ if (hcamcorder->use_zero_copy_format) {
+ t_surface = (tbm_surface_h)gst_tizen_memory_get_surface(memory);
+
+ if (tbm_surface_get_info(t_surface, &ts_info) != TBM_SURFACE_ERROR_NONE) {
+ _mmcam_dbg_err("failed to get tbm surface[%p] info", t_surface);
+ goto _INVOKE_VIDEO_STREAM_CB_DONE;
+ }
+
+ /* set bo, stride and elevation */
+ num_bos = gst_tizen_memory_get_num_bos(memory);
+ for (i = 0 ; i < num_bos ; i++)
+ stream.bo[i] = gst_tizen_memory_get_bos(memory, i);
+
+ for (i = 0 ; i < ts_info.num_planes ; i++) {
+ stream.stride[i] = ts_info.planes[i].stride;
+ stream.elevation[i] = ts_info.planes[i].size / ts_info.planes[i].stride;
+ /*_mmcam_dbg_log("[%d] %dx%d", i, stream.stride[i], stream.elevation[i]);*/
+ }
+
+ stream.length_total = ts_info.size;
+ stream.internal_buffer = buffer;
+
+ if (!__mmcamcorder_set_stream_data_tbm(&stream, &ts_info))
+ goto _INVOKE_VIDEO_STREAM_CB_DONE;
+ } else {
+ stream.length_total = gst_memory_get_sizes(memory, NULL, NULL);
+
+ if (!gst_memory_map(memory, &map_info, GST_MAP_READWRITE) ||
+ !__mmcamcorder_set_stream_data_normal(&stream, buffer, &map_info))
+ goto _INVOKE_VIDEO_STREAM_CB_DONE;
+ }
+
+ stream.timestamp = (unsigned int)(GST_BUFFER_PTS(buffer) / 1000000); /* nano sec -> milli sec */
+
+ /* invoke application callback */
+ if (is_preview) {
+ _MMCAMCORDER_LOCK_VSTREAM_CALLBACK(hcamcorder);
+ if (hcamcorder->vstream_cb)
+ hcamcorder->vstream_cb(&stream, hcamcorder->vstream_cb_param);
+ _MMCAMCORDER_UNLOCK_VSTREAM_CALLBACK(hcamcorder);
+ } else {
+ _MMCAMCORDER_LOCK_VEDECISION_CALLBACK(hcamcorder);
+ if (hcamcorder->vedecision_cb)
+ ret_cb = hcamcorder->vedecision_cb(&stream, hcamcorder->vedecision_cb_param);
+ _MMCAMCORDER_UNLOCK_VEDECISION_CALLBACK(hcamcorder);
+ }
+
+_INVOKE_VIDEO_STREAM_CB_DONE:
+ 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]);
+ }
+
+ if (map_info.data)
+ gst_memory_unmap(memory, &map_info);
+
+ if (_mmcamcorder_is_encoded_preview_pixel_format(stream.format))
+ gst_memory_unref(memory);
+
+ return ret_cb;
+}
+
+
int _mmcamcorder_create_preview_elements(MMHandleType handle)
{
int err = MM_ERROR_NONE;
static GstPadProbeReturn __mmcamcorder_video_dataprobe_preview(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
{
- int current_state = MM_CAMCORDER_STATE_NONE;
- int i = 0;
-
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(u_data);
_MMCamcorderSubContext *sc = NULL;
_MMCamcorderKPIMeasure *kpi = NULL;
sc = MMF_CAMCORDER_SUBCONTEXT(u_data);
mmf_return_val_if_fail(sc, GST_PAD_PROBE_DROP);
- current_state = hcamcorder->state;
-
if (sc->drop_vframe > 0) {
if (sc->pass_first_vframe > 0) {
sc->pass_first_vframe--;
return GST_PAD_PROBE_DROP;
}
- if (current_state >= MM_CAMCORDER_STATE_PREPARE) {
+ if (hcamcorder->state >= MM_CAMCORDER_STATE_PREPARE) {
int diff_sec;
int frame_count = 0;
struct timeval current_video_time;
}
}
- /* video stream callback */
- if (hcamcorder->vstream_cb && buffer) {
- int state = MM_CAMCORDER_STATE_NULL;
- int num_bos = 0;
- unsigned int fourcc = 0;
- const gchar *string_format = NULL;
-
- MMCamcorderVideoStreamDataType stream;
- tbm_surface_h t_surface = NULL;
- tbm_surface_info_s t_info;
-
- GstCaps *caps = NULL;
- GstStructure *structure = NULL;
- GstMemory *memory = NULL;
- GstMapInfo mapinfo;
-
- if (!_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format)) {
- state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
- if (state < MM_CAMCORDER_STATE_PREPARE) {
- _mmcam_dbg_warn("Not ready for stream callback");
- return GST_PAD_PROBE_OK;
- }
- }
-
- caps = gst_pad_get_current_caps(pad);
- if (caps == NULL) {
- _mmcam_dbg_warn("Caps is NULL.");
- return GST_PAD_PROBE_OK;
- }
-
- /* clear data structure */
- memset(&mapinfo, 0x0, sizeof(GstMapInfo));
- memset(&stream, 0x0, sizeof(MMCamcorderVideoStreamDataType));
-
- structure = gst_caps_get_structure(caps, 0);
- gst_structure_get_int(structure, "width", &(stream.width));
- gst_structure_get_int(structure, "height", &(stream.height));
-
- if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
- stream.format = MM_PIXEL_FORMAT_ENCODED_H264;
- } else if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_MJPEG) {
- stream.format = MM_PIXEL_FORMAT_ENCODED_MJPEG;
- } else {
- string_format = gst_structure_get_string(structure, "format");
- if (string_format == NULL) {
- gst_caps_unref(caps);
- caps = NULL;
- _mmcam_dbg_warn("get string error!!");
- return GST_PAD_PROBE_OK;
- }
-
- fourcc = _mmcamcorder_convert_fourcc_string_to_value(string_format);
- stream.format = _mmcamcorder_get_pixtype(fourcc);
- }
-
- gst_caps_unref(caps);
- caps = NULL;
-
- /*
- _mmcam_dbg_log("Call video steramCb, data[%p], Width[%d],Height[%d], Format[%d]",
- GST_BUFFER_DATA(buffer), stream.width, stream.height, stream.format);
- */
-
- if (stream.width == 0 || stream.height == 0) {
- _mmcam_dbg_warn("Wrong condition!!");
- return GST_PAD_PROBE_OK;
- }
-
- /* set size and timestamp */
- if (_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format))
- memory = gst_buffer_get_all_memory(buffer);
- else
- memory = gst_buffer_peek_memory(buffer, 0);
- if (!memory) {
- _mmcam_dbg_err("GstMemory get failed from buffer %p", buffer);
- return GST_PAD_PROBE_OK;
- }
-
- if (hcamcorder->use_zero_copy_format) {
- t_surface = (tbm_surface_h)gst_tizen_memory_get_surface(memory);
-
- if (tbm_surface_get_info(t_surface, &t_info) != TBM_SURFACE_ERROR_NONE) {
- _mmcam_dbg_err("failed to get tbm surface[%p] info", t_surface);
- return GST_PAD_PROBE_OK;
- }
-
- stream.length_total = t_info.size;
-
- /* set bo, stride and elevation */
- num_bos = gst_tizen_memory_get_num_bos(memory);
- for (i = 0 ; i < num_bos ; i++)
- stream.bo[i] = gst_tizen_memory_get_bos(memory, i);
-
- for (i = 0 ; i < t_info.num_planes ; i++) {
- stream.stride[i] = t_info.planes[i].stride;
- stream.elevation[i] = t_info.planes[i].size / t_info.planes[i].stride;
- /*_mmcam_dbg_log("[%d] %dx%d", i, stream.stride[i], stream.elevation[i]);*/
- }
-
- /* set gst buffer */
- stream.internal_buffer = buffer;
- } else {
- stream.length_total = gst_memory_get_sizes(memory, NULL, NULL);
- }
-
- stream.timestamp = (unsigned int)(GST_BUFFER_PTS(buffer)/1000000); /* nano sec -> mili sec */
-
- /* set data pointers */
- if (stream.format == MM_PIXEL_FORMAT_NV12 ||
- stream.format == MM_PIXEL_FORMAT_NV21 ||
- stream.format == MM_PIXEL_FORMAT_I420) {
- if (hcamcorder->use_zero_copy_format) {
- if (stream.format == MM_PIXEL_FORMAT_NV12 ||
- stream.format == MM_PIXEL_FORMAT_NV21) {
- stream.data_type = MM_CAM_STREAM_DATA_YUV420SP;
- stream.num_planes = 2;
- stream.data.yuv420sp.y = t_info.planes[0].ptr;
- stream.data.yuv420sp.length_y = t_info.planes[0].size;
- stream.data.yuv420sp.uv = t_info.planes[1].ptr;
- stream.data.yuv420sp.length_uv = t_info.planes[1].size;
- /*
- _mmcam_dbg_log("format[%d][num_planes:%d] [Y]p:%p,size:%d [UV]p:%p,size:%d",
- stream.format, stream.num_planes,
- stream.data.yuv420sp.y, stream.data.yuv420sp.length_y,
- stream.data.yuv420sp.uv, stream.data.yuv420sp.length_uv);
- */
- } else {
- stream.data_type = MM_CAM_STREAM_DATA_YUV420P;
- stream.num_planes = 3;
- stream.data.yuv420p.y = t_info.planes[0].ptr;
- stream.data.yuv420p.length_y = t_info.planes[0].size;
- stream.data.yuv420p.u = t_info.planes[1].ptr;
- stream.data.yuv420p.length_u = t_info.planes[1].size;
- stream.data.yuv420p.v = t_info.planes[2].ptr;
- stream.data.yuv420p.length_v = t_info.planes[2].size;
- /*
- _mmcam_dbg_log("S420[num_planes:%d] [Y]p:%p,size:%d [U]p:%p,size:%d [V]p:%p,size:%d",
- stream.num_planes,
- stream.data.yuv420p.y, stream.data.yuv420p.length_y,
- stream.data.yuv420p.u, stream.data.yuv420p.length_u,
- stream.data.yuv420p.v, stream.data.yuv420p.length_v);
- */
- }
- } else {
- gst_memory_map(memory, &mapinfo, GST_MAP_READWRITE);
- if (stream.format == MM_PIXEL_FORMAT_NV12 ||
- stream.format == MM_PIXEL_FORMAT_NV21) {
- stream.data_type = MM_CAM_STREAM_DATA_YUV420SP;
- stream.num_planes = 2;
- stream.data.yuv420sp.y = mapinfo.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;
- stream.stride[0] = stream.width;
- stream.elevation[0] = stream.height;
- stream.stride[1] = stream.width;
- stream.elevation[1] = stream.height >> 1;
- /*
- _mmcam_dbg_log("format[%d][num_planes:%d] [Y]p:%p,size:%d [UV]p:%p,size:%d",
- stream.format, stream.num_planes,
- stream.data.yuv420sp.y, stream.data.yuv420sp.length_y,
- stream.data.yuv420sp.uv, stream.data.yuv420sp.length_uv);
- */
- } else {
- stream.data_type = MM_CAM_STREAM_DATA_YUV420P;
- stream.num_planes = 3;
- stream.data.yuv420p.y = mapinfo.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;
- stream.data.yuv420p.v = stream.data.yuv420p.u + stream.data.yuv420p.length_u;
- stream.data.yuv420p.length_v = stream.data.yuv420p.length_u;
- stream.stride[0] = stream.width;
- stream.elevation[0] = stream.height;
- stream.stride[1] = stream.width >> 1;
- stream.elevation[1] = stream.height >> 1;
- stream.stride[2] = stream.width >> 1;
- stream.elevation[2] = stream.height >> 1;
- /*
- _mmcam_dbg_log("I420[num_planes:%d] [Y]p:%p,size:%d [U]p:%p,size:%d [V]p:%p,size:%d",
- stream.num_planes,
- stream.data.yuv420p.y, stream.data.yuv420p.length_y,
- stream.data.yuv420p.u, stream.data.yuv420p.length_u,
- stream.data.yuv420p.v, stream.data.yuv420p.length_v);
- */
- }
- }
- } else {
- gst_memory_map(memory, &mapinfo, GST_MAP_READWRITE);
-
- switch (stream.format) {
- case MM_PIXEL_FORMAT_YUYV:
- case MM_PIXEL_FORMAT_UYVY:
- case MM_PIXEL_FORMAT_422P:
- case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
- stream.data_type = MM_CAM_STREAM_DATA_YUV422;
- stream.data.yuv422.yuv = mapinfo.data;
- stream.data.yuv422.length_yuv = stream.length_total;
- stream.stride[0] = stream.width << 1;
- stream.elevation[0] = stream.height;
- break;
- case MM_PIXEL_FORMAT_ENCODED_H264:
- stream.data_type = MM_CAM_STREAM_DATA_ENCODED;
- stream.data.encoded.data = mapinfo.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);
- /*
- _mmcam_dbg_log("H264[num_planes:%d] [0]p:%p,size:%d,is_delta:%d",
- stream.num_planes,
- stream.data.encoded.data,
- stream.data.encoded.length_data,
- stream.data.encoded.is_delta_frame);
-
- */
- break;
- case MM_PIXEL_FORMAT_ENCODED_MJPEG:
- stream.data_type = MM_CAM_STREAM_DATA_ENCODED;
- stream.data.encoded.data = mapinfo.data;
- stream.data.encoded.length_data = stream.length_total;
- /*
- _mmcam_dbg_log("MJPEG[num_planes:%d] [0]p:%p,size:%d",
- stream.num_planes, stream.data.encoded.data, stream.data.encoded.length_data);
- */
- break;
- case MM_PIXEL_FORMAT_INVZ:
- stream.data_type = MM_CAM_STREAM_DATA_DEPTH;
- stream.data.depth.data = mapinfo.data;
- stream.data.depth.length_data = stream.length_total;
- stream.stride[0] = stream.width << 1;
- stream.elevation[0] = stream.height;
- break;
- case MM_PIXEL_FORMAT_RGBA:
- case MM_PIXEL_FORMAT_ARGB:
- stream.data_type = MM_CAM_STREAM_DATA_RGB;
- stream.data.rgb.data = mapinfo.data;
- stream.data.rgb.length_data = stream.length_total;
- stream.stride[0] = stream.width << 2;
- stream.elevation[0] = stream.height;
- break;
- default:
- stream.data_type = MM_CAM_STREAM_DATA_YUV420;
- stream.data.yuv420.yuv = mapinfo.data;
- stream.data.yuv420.length_yuv = stream.length_total;
- stream.stride[0] = (stream.width * 3) >> 1;
- stream.elevation[0] = stream.height;
- break;
- }
-
- stream.num_planes = 1;
- /*
- _mmcam_dbg_log("%c%c%c%c[num_planes:%d] [0]p:%p,size:%d",
- fourcc, fourcc>>8, fourcc>>16, fourcc>>24,
- stream.num_planes, stream.data.yuv420.yuv, stream.data.yuv420.length_yuv);
- */
- }
-
- /* call application callback */
- _MMCAMCORDER_LOCK_VSTREAM_CALLBACK(hcamcorder);
- if (hcamcorder->vstream_cb) {
- hcamcorder->vstream_cb(&stream, hcamcorder->vstream_cb_param);
-
- 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]);
- }
- }
-
- _MMCAMCORDER_UNLOCK_VSTREAM_CALLBACK(hcamcorder);
-
- /* unmap memory */
- if (mapinfo.data)
- gst_memory_unmap(memory, &mapinfo);
- if (_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format))
- gst_memory_unref(memory);
+ /* The first H.264 frame should not be skipped for vstream cb. */
+ if (hcamcorder->state < MM_CAMCORDER_STATE_PREPARE &&
+ sc->info_image->preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
+ _mmcam_dbg_warn("Not ready for stream callback");
+ return GST_PAD_PROBE_OK;
}
- return GST_PAD_PROBE_OK;
+ if (_mmcamcorder_invoke_video_stream_cb((MMHandleType)hcamcorder, buffer, TRUE))
+ return GST_PAD_PROBE_OK;
+ else
+ return GST_PAD_PROBE_DROP;
}