[v4l2] Change feature name
[platform/upstream/gst-plugins-good.git] / sys / v4l2 / gstv4l2allocator.h
index 282f855..25ec2d5 100644 (file)
 #include "ext/videodev2.h"
 #include <gst/gst.h>
 #include <gst/gstatomicqueue.h>
+#ifdef TIZEN_FEATURE_V4L2_TBM_SUPPORT
+#include <tbm_surface.h>
+#include <tbm_surface_internal.h>
+#endif /* TIZEN_FEATURE_V4L2_TBM_SUPPORT */
 
 G_BEGIN_DECLS
 
@@ -40,7 +44,13 @@ G_BEGIN_DECLS
 #define GST_V4L2_ALLOCATOR_CAN_REQUEST(obj,type) \
         (GST_OBJECT_FLAG_IS_SET (obj, GST_V4L2_ALLOCATOR_FLAG_ ## type ## _REQBUFS))
 #define GST_V4L2_ALLOCATOR_CAN_ALLOCATE(obj,type) \
-        (GST_OBJECT_FLAG_IS_SET (obj, GST_V4L2_ALLOCATOR_FLAG_ ## type ## _CREATE_BUF))
+        (GST_OBJECT_FLAG_IS_SET (obj, GST_V4L2_ALLOCATOR_FLAG_ ## type ## _CREATE_BUFS))
+#define GST_V4L2_ALLOCATOR_CAN_ORPHAN_BUFS(obj) \
+        (GST_OBJECT_FLAG_IS_SET (obj, GST_V4L2_ALLOCATOR_FLAG_SUPPORTS_ORPHANED_BUFS))
+#define GST_V4L2_ALLOCATOR_IS_ORPHANED(obj) \
+        (GST_OBJECT_FLAG_IS_SET (obj, GST_V4L2_ALLOCATOR_FLAG_ORPHANED))
+
+#define GST_V4L2_MEMORY_QUARK gst_v4l2_memory_quark ()
 
 typedef struct _GstV4l2Allocator GstV4l2Allocator;
 typedef struct _GstV4l2AllocatorClass GstV4l2AllocatorClass;
@@ -51,12 +61,14 @@ typedef enum _GstV4l2Return GstV4l2Return;
 
 enum _GstV4l2AllocatorFlags
 {
-  GST_V4L2_ALLOCATOR_FLAG_MMAP_REQBUF        = (GST_ALLOCATOR_FLAG_LAST << 0),
-  GST_V4L2_ALLOCATOR_FLAG_MMAP_CREATE_BUF    = (GST_ALLOCATOR_FLAG_LAST << 1),
-  GST_V4L2_ALLOCATOR_FLAG_USERPTR_REQBUF     = (GST_ALLOCATOR_FLAG_LAST << 2),
-  GST_V4L2_ALLOCATOR_FLAG_USERPTR_CREATE_BUF = (GST_ALLOCATOR_FLAG_LAST << 3),
-  GST_V4L2_ALLOCATOR_FLAG_DMABUF_REQBUF      = (GST_ALLOCATOR_FLAG_LAST << 4),
-  GST_V4L2_ALLOCATOR_FLAG_DMABUF_CREATE_BUF  = (GST_ALLOCATOR_FLAG_LAST << 5),
+  GST_V4L2_ALLOCATOR_FLAG_MMAP_REQBUFS        = (GST_ALLOCATOR_FLAG_LAST << 0),
+  GST_V4L2_ALLOCATOR_FLAG_MMAP_CREATE_BUFS    = (GST_ALLOCATOR_FLAG_LAST << 1),
+  GST_V4L2_ALLOCATOR_FLAG_USERPTR_REQBUFS     = (GST_ALLOCATOR_FLAG_LAST << 2),
+  GST_V4L2_ALLOCATOR_FLAG_USERPTR_CREATE_BUFS = (GST_ALLOCATOR_FLAG_LAST << 3),
+  GST_V4L2_ALLOCATOR_FLAG_DMABUF_REQBUFS      = (GST_ALLOCATOR_FLAG_LAST << 4),
+  GST_V4L2_ALLOCATOR_FLAG_DMABUF_CREATE_BUFS  = (GST_ALLOCATOR_FLAG_LAST << 5),
+  GST_V4L2_ALLOCATOR_FLAG_SUPPORTS_ORPHANED_BUFS = (GST_ALLOCATOR_FLAG_LAST << 6),
+  GST_V4L2_ALLOCATOR_FLAG_ORPHANED            = (GST_ALLOCATOR_FLAG_LAST << 7),
 };
 
 enum _GstV4l2Return
@@ -82,23 +94,28 @@ struct _GstV4l2MemoryGroup
   gint mems_allocated;
   struct v4l2_buffer buffer;
   struct v4l2_plane planes[VIDEO_MAX_PLANES];
+#ifdef TIZEN_FEATURE_V4L2_TBM_SUPPORT
+  tbm_surface_h surface;
+#endif /* TIZEN_FEATURE_V4L2_TBM_SUPPORT */
 };
 
 struct _GstV4l2Allocator
 {
   GstAllocator parent;
-  gint video_fd;
+  GstV4l2Object *obj;
   guint32 count;
-  guint32 type;
   guint32 memory;
-  struct v4l2_format format;
   gboolean can_allocate;
   gboolean active;
 
   GstV4l2MemoryGroup * groups[VIDEO_MAX_FRAME];
   GstAtomicQueue *free_queue;
   GstAtomicQueue *pending_queue;
-
+#ifdef TIZEN_FEATURE_V4L2_TBM_SUPPORT
+  tbm_bufmgr bufmgr;
+  tbm_surface_info_s s_info;
+  gint live_buffer_count;
+#endif /* TIZEN_FEATURE_V4L2_TBM_SUPPORT */
 };
 
 struct _GstV4l2AllocatorClass {
@@ -109,17 +126,20 @@ GType gst_v4l2_allocator_get_type(void);
 
 gboolean             gst_is_v4l2_memory                (GstMemory * mem);
 
+GQuark               gst_v4l2_memory_quark             (void);
+
 gboolean             gst_v4l2_allocator_is_active      (GstV4l2Allocator * allocator);
 
 guint                gst_v4l2_allocator_get_size       (GstV4l2Allocator * allocator);
 
-GstV4l2Allocator*    gst_v4l2_allocator_new            (GstObject *parent, gint video_fd,
-                                                        struct v4l2_format * format);
+GstV4l2Allocator*    gst_v4l2_allocator_new            (GstObject *parent, GstV4l2Object * obj);
 
 guint                gst_v4l2_allocator_start          (GstV4l2Allocator * allocator,
                                                         guint32 count, guint32 memory);
 
-gboolean             gst_v4l2_allocator_stop           (GstV4l2Allocator * allocator);
+GstV4l2Return        gst_v4l2_allocator_stop           (GstV4l2Allocator * allocator);
+
+gboolean             gst_v4l2_allocator_orphan         (GstV4l2Allocator * allocator);
 
 GstV4l2MemoryGroup*  gst_v4l2_allocator_alloc_mmap     (GstV4l2Allocator * allocator);
 
@@ -137,14 +157,15 @@ gboolean             gst_v4l2_allocator_import_dmabuf  (GstV4l2Allocator * alloc
 gboolean             gst_v4l2_allocator_import_userptr (GstV4l2Allocator * allocator,
                                                         GstV4l2MemoryGroup *group,
                                                         gsize img_size, int n_planes,
-                                                        gpointer * data, gsize * offset);
+                                                        gpointer * data, gsize * size);
 
 void                 gst_v4l2_allocator_flush          (GstV4l2Allocator * allocator);
 
 gboolean             gst_v4l2_allocator_qbuf           (GstV4l2Allocator * allocator,
                                                         GstV4l2MemoryGroup * group);
 
-GstV4l2MemoryGroup*  gst_v4l2_allocator_dqbuf          (GstV4l2Allocator * allocator);
+GstFlowReturn        gst_v4l2_allocator_dqbuf          (GstV4l2Allocator * allocator,
+                                                        GstV4l2MemoryGroup ** group);
 
 void                 gst_v4l2_allocator_reset_group    (GstV4l2Allocator * allocator,
                                                         GstV4l2MemoryGroup * group);