From 3af0d65cae4a435597cec0137464ccb6569d13c6 Mon Sep 17 00:00:00 2001 From: Hyuntae Kim Date: Wed, 18 Sep 2019 11:23:38 +0900 Subject: [PATCH] Bugfix - H.264 stream data probe issue 1. before prepare, I-frame will comes to preview cb with h.264 stream. If drop, preview does not work as soon as possible 2. h.264 stream needs to use gst_buffer_get_all_memory for getting correct memory size 3. with gst_buffer_get_all_memory, buffer should be unref Change-Id: I68b7f14d8a70306daa0e92d9924401bcbc886938 --- src/mm_camcorder_gstcommon.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/mm_camcorder_gstcommon.c b/src/mm_camcorder_gstcommon.c index 4ccac2e..3e19d7c 100644 --- a/src/mm_camcorder_gstcommon.c +++ b/src/mm_camcorder_gstcommon.c @@ -1700,10 +1700,12 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_preview(GstPad *pad, GstP GstMemory *memory = NULL; GstMapInfo mapinfo; - 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; + if (sc->info_image->preview_format != MM_PIXEL_FORMAT_ENCODED_H264) { + 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); @@ -1749,7 +1751,10 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_preview(GstPad *pad, GstP } /* set size and timestamp */ - memory = gst_buffer_peek_memory(buffer, 0); + if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) + 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; @@ -1935,6 +1940,8 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_preview(GstPad *pad, GstP /* unmap memory */ if (mapinfo.data) gst_memory_unmap(memory, &mapinfo); + if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) + gst_memory_unref(memory); } return GST_PAD_PROBE_OK; -- 2.7.4