good:v4l2: Add new property for TBM dump 80/272180/5
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 10 Mar 2022 12:45:51 +0000 (21:45 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Mon, 14 Mar 2022 02:25:05 +0000 (11:25 +0900)
[Version] 1.20.0-6
[Issue Type] New feature

Change-Id: Ia1233939ad58a9797840760cf2c35d4fa728f97c
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/gstreamer.spec
subprojects/gst-plugins-good/sys/v4l2/gstv4l2allocator.c
subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.c
subprojects/gst-plugins-good/sys/v4l2/gstv4l2bufferpool.h
subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.h
subprojects/gst-plugins-good/sys/v4l2/gstv4l2src.c
subprojects/gst-plugins-good/sys/v4l2/gstv4l2videodec.c

index e8619a6ab622134d6e2b8ae5b77440072886f058..89d2f104d6283bb4b581b517020edc471f55443d 100644 (file)
@@ -59,7 +59,7 @@
 
 Name:           %{_name}
 Version:        1.20.0
-Release:        5
+Release:        6
 Summary:        Streaming-Media Framework Runtime
 License:        LGPL-2.0+
 Group:          Multimedia/Framework
index 48429a5b2bb0e8a772eab3c64672cc34cd11fa77..07b3709e6ea199c887e0ebe5f652319bc68edc74 100644 (file)
@@ -639,7 +639,8 @@ _cleanup_failed_alloc (GstV4l2Allocator * allocator, GstV4l2MemoryGroup * group)
 }
 
 #ifdef TIZEN_FEATURE_V4L2_TBM_SUPPORT
-static tbm_format __get_tbm_format (GstVideoFormat gst_format)
+static tbm_format
+__get_tbm_format (GstVideoFormat gst_format)
 {
   switch (gst_format) {
   case GST_VIDEO_FORMAT_NV12:
index 7c3b9ebed9e162598f6ed287a6c750e7a14a9f26..b835162877be6aedc1d9c6929758b49b96c151a7 100644 (file)
@@ -47,6 +47,8 @@
 #include <gst/glib-compat-private.h>
 #ifdef TIZEN_FEATURE_V4L2_TBM_SUPPORT
 #include <gst/allocators/gsttizenmemory.h>
+
+#define TIZEN_BUFFER_DUMP_PATH "/tmp/v4l2_output.raw"
 #endif /* TIZEN_FEATURE_V4L2_TBM_SUPPORT */
 
 GST_DEBUG_CATEGORY_STATIC (v4l2bufferpool_debug);
@@ -97,7 +99,8 @@ struct _GstV4l2TizenBuffer {
   GstV4l2BufferPool *v4l2_pool;
 };
 
-static void gst_v4l2_tizen_buffer_finalize (GstV4l2TizenBuffer *tizen_buffer)
+static void
+gst_v4l2_tizen_buffer_finalize (GstV4l2TizenBuffer *tizen_buffer)
 {
   GstV4l2BufferPool *pool = NULL;
 
@@ -127,7 +130,8 @@ static void gst_v4l2_tizen_buffer_finalize (GstV4l2TizenBuffer *tizen_buffer)
   g_free(tizen_buffer);
 }
 
-static GstV4l2TizenBuffer *gst_v4l2_tizen_buffer_new (GstBuffer *v4l2_buffer, int index, GstV4l2BufferPool *v4l2_pool)
+static GstV4l2TizenBuffer *
+gst_v4l2_tizen_buffer_new (GstBuffer *v4l2_buffer, int index, GstV4l2BufferPool *v4l2_pool)
 {
   GstV4l2TizenBuffer *tizen_buffer = NULL;
   GstMemory *memory = NULL;
@@ -157,6 +161,41 @@ static GstV4l2TizenBuffer *gst_v4l2_tizen_buffer_new (GstBuffer *v4l2_buffer, in
 
   return tizen_buffer;
 }
+
+static void
+gst_v4l2_tizen_buffer_dump (tbm_surface_h surface)
+{
+  int i;
+  FILE *fp;
+  tbm_surface_info_s sinfo;
+
+  if (!surface) {
+    GST_WARNING ("NULL surface");
+    return;
+  }
+
+  memset (&sinfo, 0x0, sizeof(tbm_surface_info_s));
+
+  if (tbm_surface_get_info (surface, &sinfo) != TBM_ERROR_NONE) {
+    GST_ERROR ("get tbm surface[%p] info failed", surface);
+    return;
+  }
+
+  fp = fopen (TIZEN_BUFFER_DUMP_PATH, "a");
+  if (!fp) {
+    GST_ERROR ("file open failed[%s], errno[%d]", TIZEN_BUFFER_DUMP_PATH, errno);
+    return;
+  }
+
+  for (i = 0 ; i < sinfo.num_planes ; i++) {
+    GST_DEBUG ("[%d] %ux%u, stride[%u], size[%u], offset[%u]",
+      i, sinfo.width, sinfo.height, sinfo.planes[i].stride,
+      sinfo.planes[i].size, sinfo.planes[i].offset);
+    fwrite (sinfo.planes[i].ptr, 1, sinfo.planes[i].size, fp);
+  }
+
+  fclose(fp);
+}
 #endif /* TIZEN_FEATURE_V4L2_TBM_SUPPORT */
 
 static gboolean
@@ -1577,6 +1616,9 @@ gst_v4l2_buffer_pool_dqbuf (GstV4l2BufferPool * pool, GstBuffer ** buffer,
       goto no_buffer;
     }
     outbuf = tizen_buffer->gst_buffer;
+
+    if (pool->tbm_output_dump)
+      gst_v4l2_tizen_buffer_dump (group->surface);
   }
 #endif /* TIZEN_FEATURE_V4L2_TBM_SUPPORT */
 
@@ -1993,6 +2035,10 @@ gst_v4l2_buffer_pool_new (GstV4l2Object * obj, GstCaps * caps)
 
   g_mutex_init (&pool->buffer_lock);
   g_cond_init (&pool->buffer_cond);
+
+  pool->tbm_output_dump = obj->tbm_output_dump;
+
+  GST_INFO ("tbm output dump [%d]", pool->tbm_output_dump);
 #endif /* TIZEN_FEATURE_V4L2_TBM_SUPPORT */
   pool->vallocator = gst_v4l2_allocator_new (GST_OBJECT (pool), obj);
   if (pool->vallocator == NULL)
index 3c990e85e44324771169f7ca7f483c230142f4f6..52c111dbe795467e1cae199ecc8241a83edd9e9d 100644 (file)
@@ -80,6 +80,7 @@ struct _GstV4l2BufferPool
   gint live_buffer_count;
   GMutex buffer_lock;
   GCond buffer_cond;
+  gboolean tbm_output_dump;
 #endif /* TIZEN_FEATURE_V4L2_TBM_SUPPORT */
   GstAllocationParams params;
   GstBufferPool *other_pool;
index 3b97c5fd4f6684b9327dec953cae42f094e5a1a6..bf161f02d229935708f16da31be32db4d3c809b1 100644 (file)
@@ -136,6 +136,7 @@ struct _GstV4l2Object {
   gboolean auto_scan_device;
 #endif /* TIZEN_FEATURE_V4L2SRC_AUTO_SCAN_DEVICE_NODE */
 #ifdef TIZEN_FEATURE_V4L2_TBM_SUPPORT
+  gboolean tbm_output_dump;
   gboolean tbm_output;
 #endif /* TIZEN_FEATURE_V4L2_TBM_SUPPORT */
 
@@ -239,6 +240,26 @@ struct _GstV4l2ObjectClassHelper {
 
 GType gst_v4l2_object_get_type (void);
 
+#ifdef TIZEN_FEATURE_V4L2_TBM_SUPPORT
+#define V4L2_STD_OBJECT_PROPS \
+    PROP_DEVICE,              \
+    PROP_DEVICE_NAME,         \
+    PROP_DEVICE_FD,           \
+    PROP_FLAGS,               \
+    PROP_BRIGHTNESS,          \
+    PROP_CONTRAST,            \
+    PROP_SATURATION,          \
+    PROP_HUE,                 \
+    PROP_TV_NORM,             \
+    PROP_IO_MODE,             \
+    PROP_OUTPUT_IO_MODE,      \
+    PROP_CAPTURE_IO_MODE,     \
+    PROP_EXTRA_CONTROLS,      \
+    PROP_PIXEL_ASPECT_RATIO,  \
+    PROP_FORCE_ASPECT_RATIO,  \
+    PROP_TBM_OUTPUT,          \
+    PROP_TBM_OUTPUT_DUMP
+#else
 #define V4L2_STD_OBJECT_PROPS \
     PROP_DEVICE,              \
     PROP_DEVICE_NAME,         \
@@ -255,6 +276,7 @@ GType gst_v4l2_object_get_type (void);
     PROP_EXTRA_CONTROLS,      \
     PROP_PIXEL_ASPECT_RATIO,  \
     PROP_FORCE_ASPECT_RATIO
+#endif
 
 /* create/destroy */
 GstV4l2Object*  gst_v4l2_object_new       (GstElement * element,
index 56569a9fb41918c280d5d69d3d116e39656b62f3..573983a6a0a8ce2bb823ad98530915c5ea7cbd22 100644 (file)
@@ -78,9 +78,6 @@ enum
 #ifdef TIZEN_FEATURE_V4L2SRC_AUTO_SCAN_DEVICE_NODE
   PROP_AUTO_SCAN_DEVICE,
 #endif /* TIZEN_FEATURE_V4L2SRC_AUTO_SCAN_DEVICE_NODE */
-#ifdef TIZEN_FEATURE_V4L2_TBM_SUPPORT
-  PROP_TBM_OUTPUT,
-#endif /* TIZEN_FEATURE_V4L2_TBM_SUPPORT */
   PROP_LAST
 };
 
index f187e8c922dfcaf56f472b52852b29056385d116..2f865e66163d6043504425968dc52a3c44d072e3 100644 (file)
@@ -59,9 +59,6 @@ enum
 {
   PROP_0,
   V4L2_STD_OBJECT_PROPS
-#ifdef TIZEN_FEATURE_V4L2_TBM_SUPPORT
-  , PROP_TBM_OUTPUT
-#endif /* TIZEN_FEATURE_V4L2_TBM_SUPPORT */
 };
 
 #define gst_v4l2_video_dec_parent_class parent_class
@@ -71,7 +68,8 @@ G_DEFINE_ABSTRACT_TYPE (GstV4l2VideoDec, gst_v4l2_video_dec,
 static GstFlowReturn gst_v4l2_video_dec_finish (GstVideoDecoder * decoder);
 
 #ifdef TIZEN_FEATURE_V4L2_TBM_SUPPORT
-static void gst_v4l2_video_dec_flush_buffer_event (GstVideoDecoder * decoder)
+static void
+gst_v4l2_video_dec_flush_buffer_event (GstVideoDecoder * decoder)
 {
   gboolean ret = FALSE;
 
@@ -103,7 +101,14 @@ gst_v4l2_video_dec_set_property (GObject * object,
 #ifdef TIZEN_FEATURE_V4L2_TBM_SUPPORT
     case PROP_TBM_OUTPUT:
       self->v4l2capture->tbm_output = g_value_get_boolean (value);
-      GST_INFO_OBJECT (self, "tbm output [%d]", self->v4l2capture->tbm_output);
+      GST_INFO_OBJECT (self, "tbm output[%d]", self->v4l2capture->tbm_output);
+      break;
+    case PROP_TBM_OUTPUT_DUMP:
+      self->v4l2capture->tbm_output_dump = g_value_get_boolean (value);
+      GST_INFO_OBJECT (self, "tbm output dump[%d], pool[%p]",
+        self->v4l2capture->tbm_output_dump, self->v4l2capture->pool);
+      if (self->v4l2capture->pool)
+        GST_V4L2_BUFFER_POOL (self->v4l2capture->pool)->tbm_output_dump = self->v4l2capture->tbm_output_dump;
       break;
 #endif /* TIZEN_FEATURE_V4L2_TBM_SUPPORT */
 
@@ -133,9 +138,13 @@ gst_v4l2_video_dec_get_property (GObject * object,
       break;
 #ifdef TIZEN_FEATURE_V4L2_TBM_SUPPORT
     case PROP_TBM_OUTPUT:
-      GST_INFO_OBJECT (self, "tbm output [%d]", self->v4l2capture->tbm_output);
+      GST_INFO_OBJECT (self, "tbm output[%d]", self->v4l2capture->tbm_output);
       g_value_set_boolean (value, self->v4l2capture->tbm_output);
       break;
+    case PROP_TBM_OUTPUT_DUMP:
+      GST_INFO_OBJECT (self, "tbm output dump[%d]", self->v4l2capture->tbm_output_dump);
+      g_value_set_boolean (value, self->v4l2capture->tbm_output_dump);
+      break;
 #endif /* TIZEN_FEATURE_V4L2_TBM_SUPPORT */
 
       /* By default read from output */
@@ -1177,9 +1186,14 @@ gst_v4l2_video_dec_class_init (GstV4l2VideoDecClass * klass)
   gst_v4l2_object_install_m2m_properties_helper (gobject_class);
 #ifdef TIZEN_FEATURE_V4L2_TBM_SUPPORT
   g_object_class_install_property (gobject_class, PROP_TBM_OUTPUT,
-      g_param_spec_boolean ("tbm-output", "Enable TBM for output buffer",
-          "It works for only DMABUF mode.",
+      g_param_spec_boolean ("tbm-output", "Enable TBM output",
+          "Enable TBM for output buffer. It works for only DMABUF mode.",
           TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (gobject_class, PROP_TBM_OUTPUT_DUMP,
+      g_param_spec_boolean ("tbm-output-dump", "Enable dump for TBM output",
+          "Enable dump for TBM output buffer. It works for only DMABUF mode.",
+          FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 #endif /* TIZEN_FEATURE_V4L2_TBM_SUPPORT */
 }