plugins: base: manage pad-specific data in a single struct
[platform/upstream/gstreamer.git] / gst / vaapi / gstvaapipluginbase.h
index 717716a..e98b451 100644 (file)
 #include <gst/video/gstvideoencoder.h>
 #include <gst/video/gstvideosink.h>
 #include <gst/vaapi/gstvaapidisplay.h>
-#include "gstvaapiuploader.h"
-
-#ifdef HAVE_GST_GL_GL_H
-# include <gst/gl/gstglcontext.h>
-#endif
 
 G_BEGIN_DECLS
 
 typedef struct _GstVaapiPluginBase GstVaapiPluginBase;
 typedef struct _GstVaapiPluginBaseClass GstVaapiPluginBaseClass;
+typedef struct _GstVaapiPadPrivate GstVaapiPadPrivate;
 
 #define GST_VAAPI_PLUGIN_BASE(plugin) \
   ((GstVaapiPluginBase *)(plugin))
@@ -78,20 +74,34 @@ typedef struct _GstVaapiPluginBaseClass GstVaapiPluginBaseClass;
 
 #define GST_VAAPI_PLUGIN_BASE_SINK_PAD(plugin) \
   (GST_VAAPI_PLUGIN_BASE(plugin)->sinkpad)
+#define GST_VAAPI_PLUGIN_BASE_SINK_PAD_PRIVATE(plugin) \
+  (GST_VAAPI_PLUGIN_BASE(plugin)->sinkpriv)
 #define GST_VAAPI_PLUGIN_BASE_SINK_PAD_CAPS(plugin) \
-  (GST_VAAPI_PLUGIN_BASE(plugin)->sinkpad_caps)
+  (GST_VAAPI_PLUGIN_BASE_SINK_PAD_PRIVATE(plugin)->caps)
 #define GST_VAAPI_PLUGIN_BASE_SINK_PAD_INFO(plugin) \
-  (&GST_VAAPI_PLUGIN_BASE(plugin)->sinkpad_info)
-#define GST_VAAPI_PLUGIN_BASE_SINK_PAD_QUERYFUNC(plugin) \
-  (GST_VAAPI_PLUGIN_BASE(plugin)->sinkpad_query)
+  (&GST_VAAPI_PLUGIN_BASE_SINK_PAD_PRIVATE(plugin)->info)
+
 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD(plugin) \
   (GST_VAAPI_PLUGIN_BASE(plugin)->srcpad)
+#define GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin) \
+  (GST_VAAPI_PLUGIN_BASE(plugin)->srcpriv)
 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD_CAPS(plugin) \
-  (GST_VAAPI_PLUGIN_BASE(plugin)->srcpad_caps)
+  (GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->caps)
 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD_INFO(plugin) \
-  (&GST_VAAPI_PLUGIN_BASE(plugin)->srcpad_info)
-#define GST_VAAPI_PLUGIN_BASE_SRC_PAD_QUERYFYNC(plugin) \
-  (GST_VAAPI_PLUGIN_BASE(plugin)->srcpad_query)
+  (&GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->info)
+#define GST_VAAPI_PLUGIN_BASE_SRC_PAD_CAN_DMABUF(plugin) \
+  (GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->can_dmabuf)
+#define GST_VAAPI_PLUGIN_BASE_SRC_PAD_BUFFER_POOL(plugin) \
+  (GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->buffer_pool)
+#define GST_VAAPI_PLUGIN_BASE_SRC_PAD_ALLOCATOR(plugin) \
+  (GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->allocator)
+#define GST_VAAPI_PLUGIN_BASE_OTHER_ALLOCATOR(plugin) \
+  (GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->other_allocator)
+#define GST_VAAPI_PLUGIN_BASE_OTHER_ALLOCATOR_PARAMS(plugin) \
+  (GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->other_allocator_params)
+
+#define GST_VAAPI_PLUGIN_BASE_COPY_OUTPUT_FRAME(plugin) \
+  (GST_VAAPI_PLUGIN_BASE(plugin)->copy_output_frame)
 
 #define GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin) \
   (GST_VAAPI_PLUGIN_BASE(plugin)->display)
@@ -103,12 +113,30 @@ typedef struct _GstVaapiPluginBaseClass GstVaapiPluginBaseClass;
   (gst_vaapi_display_replace(&GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin), \
        (new_display)))
 
-#define GST_VAAPI_PLUGIN_BASE_UPLOADER(plugin) \
-  (GST_VAAPI_PLUGIN_BASE(plugin)->uploader)
-#define GST_VAAPI_PLUGIN_BASE_UPLOADER_CAPS(plugin) \
-  (gst_vaapi_uploader_get_caps(GST_VAAPI_PLUGIN_BASE_UPLOADER(plugin)))
-#define GST_VAAPI_PLUGIN_BASE_UPLOADER_USED(plugin) \
-  (GST_VAAPI_PLUGIN_BASE(plugin)->uploader_used)
+#define GST_VAAPI_PLUGIN_BASE_DEFINE_SET_CONTEXT(parent_class) \
+  static void \
+  gst_vaapi_base_set_context (GstElement * element, GstContext * context) \
+  { \
+    GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (element); \
+    \
+    gst_vaapi_plugin_base_set_context (plugin, context); \
+    GST_ELEMENT_CLASS (parent_class)->set_context (element, context); \
+  }
+
+struct _GstVaapiPadPrivate
+{
+  GstCaps *caps;
+  GstVideoInfo info;
+  GstBufferPool *buffer_pool;
+  GstAllocator *allocator;
+  guint buffer_size;
+  gboolean caps_is_raw;
+
+  gboolean can_dmabuf;
+
+  GstAllocator *other_allocator;
+  GstAllocationParams other_allocator_params;
+};
 
 struct _GstVaapiPluginBase
 {
@@ -125,24 +153,10 @@ struct _GstVaapiPluginBase
   GstDebugCategory *debug_category;
 
   GstPad *sinkpad;
-  GstCaps *sinkpad_caps;
-  gboolean sinkpad_caps_changed;
-  gboolean sinkpad_caps_is_raw;
-  GstVideoInfo sinkpad_info;
-  GstPadQueryFunction sinkpad_query;
-#if GST_CHECK_VERSION(1,0,0)
-  GstBufferPool *sinkpad_buffer_pool;
-  guint sinkpad_buffer_size;
-#endif
-
   GstPad *srcpad;
-  GstCaps *srcpad_caps;
-  gboolean srcpad_caps_changed;
-  GstVideoInfo srcpad_info;
-  GstPadQueryFunction srcpad_query;
-#if GST_CHECK_VERSION(1,0,0)
-  GstBufferPool *srcpad_buffer_pool;
-#endif
+
+  GstVaapiPadPrivate *sinkpriv;
+  GstVaapiPadPrivate *srcpriv;
 
   GstVaapiDisplay *display;
   GstVaapiDisplayType display_type;
@@ -150,9 +164,13 @@ struct _GstVaapiPluginBase
   gchar *display_name;
 
   GstObject *gl_context;
+  GstObject *gl_display;
+  GstObject *gl_other_context;
+
+  GstCaps *allowed_raw_caps;
 
-  GstVaapiUploader *uploader;
-  gboolean uploader_used;
+  gboolean enable_direct_rendering;
+  gboolean copy_output_frame;
 };
 
 struct _GstVaapiPluginBaseClass
@@ -169,6 +187,7 @@ struct _GstVaapiPluginBaseClass
 
   gboolean  (*has_interface) (GstVaapiPluginBase * plugin, GType type);
   void (*display_changed) (GstVaapiPluginBase * plugin);
+  GstVaapiPadPrivate * (*get_vaapi_pad_private) (GstVaapiPluginBase * plugin, GstPad * pad);
 };
 
 G_GNUC_INTERNAL
@@ -197,6 +216,11 @@ void
 gst_vaapi_plugin_base_close (GstVaapiPluginBase * plugin);
 
 G_GNUC_INTERNAL
+gboolean
+gst_vaapi_plugin_base_has_display_type (GstVaapiPluginBase * plugin,
+    GstVaapiDisplayType display_type_req);
+
+G_GNUC_INTERNAL
 void
 gst_vaapi_plugin_base_set_display_type (GstVaapiPluginBase * plugin,
     GstVaapiDisplayType display_type);
@@ -212,10 +236,6 @@ gst_vaapi_plugin_base_ensure_display (GstVaapiPluginBase * plugin);
 
 G_GNUC_INTERNAL
 gboolean
-gst_vaapi_plugin_base_ensure_uploader (GstVaapiPluginBase * plugin);
-
-G_GNUC_INTERNAL
-gboolean
 gst_vaapi_plugin_base_set_caps (GstVaapiPluginBase * plugin, GstCaps * incaps,
     GstCaps * outcaps);
 
@@ -227,12 +247,7 @@ gst_vaapi_plugin_base_propose_allocation (GstVaapiPluginBase * plugin,
 G_GNUC_INTERNAL
 gboolean
 gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
-    GstQuery * query, guint feature);
-
-G_GNUC_INTERNAL
-GstFlowReturn
-gst_vaapi_plugin_base_allocate_input_buffer (GstVaapiPluginBase * plugin,
-    GstCaps * caps, GstBuffer ** outbuf_ptr);
+    GstQuery * query);
 
 G_GNUC_INTERNAL
 GstFlowReturn
@@ -241,9 +256,38 @@ gst_vaapi_plugin_base_get_input_buffer (GstVaapiPluginBase * plugin,
 
 G_GNUC_INTERNAL
 void
+gst_vaapi_plugin_base_set_context (GstVaapiPluginBase * plugin,
+    GstContext * context);
+
+G_GNUC_INTERNAL
+void
 gst_vaapi_plugin_base_set_gl_context (GstVaapiPluginBase * plugin,
     GstObject * object);
 
+G_GNUC_INTERNAL
+GstObject *
+gst_vaapi_plugin_base_create_gl_context (GstVaapiPluginBase * plugin);
+
+G_GNUC_INTERNAL
+GstCaps *
+gst_vaapi_plugin_base_get_allowed_sinkpad_raw_caps (GstVaapiPluginBase * plugin);
+
+G_GNUC_INTERNAL
+GstCaps *
+gst_vaapi_plugin_base_get_allowed_srcpad_raw_caps (
+    GstVaapiPluginBase * plugin, GstVideoFormat format);
+
+G_GNUC_INTERNAL
+void
+gst_vaapi_plugin_base_set_srcpad_can_dmabuf (GstVaapiPluginBase * plugin,
+    GstObject * object);
+
+G_GNUC_INTERNAL
+gboolean
+gst_vaapi_plugin_copy_va_buffer (GstVaapiPluginBase * plugin,
+    GstBuffer * inbuf, GstBuffer * outbuf);
+
+
 G_END_DECLS
 
 #endif /* GST_VAAPI_PLUGIN_BASE_H */