Bugfix - H.264 stream data probe issue 88/214088/1
authorHyuntae Kim <ht1211.kim@samsung.com>
Wed, 18 Sep 2019 02:23:38 +0000 (11:23 +0900)
committerHyuntae Kim <ht1211.kim@samsung.com>
Wed, 18 Sep 2019 02:24:26 +0000 (11:24 +0900)
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

index 4ccac2e..3e19d7c 100644 (file)
@@ -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;