va: Fix struct empty initialization syntax
[platform/upstream/gstreamer.git] / subprojects / gstreamer-vaapi / gst / vaapi / gstvaapipluginbase.h
1 /*
2  *  gstvaapipluginbase.h - Base GStreamer VA-API Plugin element
3  *
4  *  Copyright (C) 2010-2011 Splitted-Desktop Systems
5  *    Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
6  *  Copyright (C) 2011-2013 Intel Corporation
7  *    Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
8  *
9  *  This library is free software; you can redistribute it and/or
10  *  modify it under the terms of the GNU Lesser General Public License
11  *  as published by the Free Software Foundation; either version 2.1
12  *  of the License, or (at your option) any later version.
13  *
14  *  This library is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  *  Lesser General Public License for more details.
18  *
19  *  You should have received a copy of the GNU Lesser General Public
20  *  License along with this library; if not, write to the Free
21  *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  *  Boston, MA 02110-1301 USA
23  */
24
25 #ifndef GST_VAAPI_PLUGIN_BASE_H
26 #define GST_VAAPI_PLUGIN_BASE_H
27
28 #include <gst/base/gstbasetransform.h>
29 #include <gst/video/gstvideodecoder.h>
30 #include <gst/video/gstvideoencoder.h>
31 #include <gst/video/gstvideosink.h>
32 #include <gst/vaapi/gstvaapidisplay.h>
33
34 G_BEGIN_DECLS
35
36 typedef struct _GstVaapiPluginBase GstVaapiPluginBase;
37 typedef struct _GstVaapiPluginBaseClass GstVaapiPluginBaseClass;
38 typedef struct _GstVaapiPadPrivate GstVaapiPadPrivate;
39
40 #define GST_VAAPI_PLUGIN_BASE(plugin) \
41   ((GstVaapiPluginBase *)(plugin))
42 #define GST_VAAPI_PLUGIN_BASE_CLASS(plugin) \
43   ((GstVaapiPluginBaseClass *)(plugin))
44 #define GST_VAAPI_PLUGIN_BASE_GET_CLASS(plugin) \
45   GST_VAAPI_PLUGIN_BASE_CLASS(GST_ELEMENT_GET_CLASS( \
46       GST_VAAPI_PLUGIN_BASE_ELEMENT(plugin)))
47 #define GST_VAAPI_PLUGIN_BASE_PARENT(plugin) \
48   (&GST_VAAPI_PLUGIN_BASE(plugin)->parent_instance)
49 #define GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin) \
50   (&GST_VAAPI_PLUGIN_BASE_CLASS(plugin)->parent_class)
51 #define GST_VAAPI_PLUGIN_BASE_ELEMENT(plugin) \
52   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->element)
53 #define GST_VAAPI_PLUGIN_BASE_ELEMENT_CLASS(plugin) \
54   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->element)
55 #define GST_VAAPI_PLUGIN_BASE_DECODER(plugin) \
56   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->decoder)
57 #define GST_VAAPI_PLUGIN_BASE_DECODER_CLASS(plugin) \
58   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->decoder)
59 #define GST_VAAPI_PLUGIN_BASE_ENCODER(plugin) \
60   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->encoder)
61 #define GST_VAAPI_PLUGIN_BASE_ENCODER_CLASS(plugin) \
62   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->encoder)
63 #define GST_VAAPI_PLUGIN_BASE_TRANSFORM(plugin) \
64   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->transform)
65 #define GST_VAAPI_PLUGIN_BASE_TRANSFORM_CLASS(plugin) \
66   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->transform)
67 #define GST_VAAPI_PLUGIN_BASE_SINK(plugin) \
68   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->sink)
69 #define GST_VAAPI_PLUGIN_BASE_SINK_CLASS(plugin) \
70   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->sink)
71
72 #define GST_VAAPI_PLUGIN_BASE_INIT_INTERFACES \
73   gst_vaapi_plugin_base_init_interfaces(g_define_type_id);
74
75 #define GST_VAAPI_PLUGIN_BASE_SINK_PAD(plugin) \
76   (GST_VAAPI_PLUGIN_BASE(plugin)->sinkpad)
77 #define GST_VAAPI_PLUGIN_BASE_SINK_PAD_PRIVATE(plugin) \
78   (GST_VAAPI_PLUGIN_BASE(plugin)->sinkpriv)
79 #define GST_VAAPI_PLUGIN_BASE_SINK_PAD_CAPS(plugin) \
80   (GST_VAAPI_PLUGIN_BASE_SINK_PAD_PRIVATE(plugin)->caps)
81 #define GST_VAAPI_PLUGIN_BASE_SINK_PAD_INFO(plugin) \
82   (&GST_VAAPI_PLUGIN_BASE_SINK_PAD_PRIVATE(plugin)->info)
83
84 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD(plugin) \
85   (GST_VAAPI_PLUGIN_BASE(plugin)->srcpad)
86 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin) \
87   (GST_VAAPI_PLUGIN_BASE(plugin)->srcpriv)
88 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD_CAPS(plugin) \
89   (GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->caps)
90 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD_INFO(plugin) \
91   (&GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->info)
92 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD_CAN_DMABUF(plugin) \
93   (GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->can_dmabuf)
94 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD_BUFFER_POOL(plugin) \
95   (GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->buffer_pool)
96 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD_ALLOCATOR(plugin) \
97   (GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->allocator)
98 #define GST_VAAPI_PLUGIN_BASE_OTHER_ALLOCATOR(plugin) \
99   (GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->other_allocator)
100 #define GST_VAAPI_PLUGIN_BASE_OTHER_ALLOCATOR_PARAMS(plugin) \
101   (GST_VAAPI_PLUGIN_BASE_SRC_PAD_PRIVATE(plugin)->other_allocator_params)
102
103 #define GST_VAAPI_PLUGIN_BASE_COPY_OUTPUT_FRAME(plugin) \
104   (GST_VAAPI_PLUGIN_BASE(plugin)->copy_output_frame)
105
106 #define GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin) \
107   (GST_VAAPI_PLUGIN_BASE(plugin)->display)
108 #define GST_VAAPI_PLUGIN_BASE_DISPLAY_TYPE(plugin) \
109   (GST_VAAPI_PLUGIN_BASE(plugin)->display_type)
110 #define GST_VAAPI_PLUGIN_BASE_DISPLAY_NAME(plugin) \
111   (GST_VAAPI_PLUGIN_BASE(plugin)->display_name)
112 #define GST_VAAPI_PLUGIN_BASE_DISPLAY_REPLACE(plugin, new_display) \
113   (gst_vaapi_display_replace(&GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin), \
114        (new_display)))
115
116 #define GST_VAAPI_PLUGIN_BASE_DEFINE_SET_CONTEXT(parent_class) \
117   static void \
118   gst_vaapi_base_set_context (GstElement * element, GstContext * context) \
119   { \
120     GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (element); \
121     \
122     gst_vaapi_plugin_base_set_context (plugin, context); \
123     GST_ELEMENT_CLASS (parent_class)->set_context (element, context); \
124   }
125
126 struct _GstVaapiPadPrivate
127 {
128   GstCaps *caps;
129   GstVideoInfo info;
130   GstBufferPool *buffer_pool;
131   GstAllocator *allocator;
132   guint buffer_size;
133   gboolean caps_is_raw;
134
135   gboolean can_dmabuf;
136
137   GstAllocator *other_allocator;
138   GstAllocationParams other_allocator_params;
139 };
140
141 G_GNUC_INTERNAL
142 GstVaapiPadPrivate *
143 gst_vaapi_pad_private_new (void);
144
145 G_GNUC_INTERNAL
146 void
147 gst_vaapi_pad_private_reset (GstVaapiPadPrivate * priv);
148
149 G_GNUC_INTERNAL
150 void
151 gst_vaapi_pad_private_finalize (GstVaapiPadPrivate * priv);
152
153 struct _GstVaapiPluginBase
154 {
155   /*< private >*/
156   union
157   {
158     GstElement element;
159     GstVideoDecoder decoder;
160     GstVideoEncoder encoder;
161     GstBaseTransform transform;
162     GstVideoSink sink;
163     GstVideoAggregator aggregator;
164   } parent_instance;
165
166   GstDebugCategory *debug_category;
167
168   GstPad *sinkpad;
169   GstPad *srcpad;
170
171   GstVaapiPadPrivate *sinkpriv;
172   GstVaapiPadPrivate *srcpriv;
173
174   GstVaapiDisplay *display;
175   GstVaapiDisplayType display_type;
176   GstVaapiDisplayType display_type_req;
177   gchar *display_name;
178
179   GstObject *gl_context;
180   GstObject *gl_display;
181   GstObject *gl_other_context;
182
183   GstCaps *allowed_raw_caps;
184
185   gboolean enable_direct_rendering;
186   gboolean copy_output_frame;
187 };
188
189 struct _GstVaapiPluginBaseClass
190 {
191   /*< private >*/
192   union
193   {
194     GstElementClass element;
195     GstVideoDecoderClass decoder;
196     GstVideoEncoderClass encoder;
197     GstBaseTransformClass transform;
198     GstVideoSinkClass sink;
199     GstVideoAggregatorClass aggregator;
200   } parent_class;
201
202   gboolean  (*has_interface) (GstVaapiPluginBase * plugin, GType type);
203   void (*display_changed) (GstVaapiPluginBase * plugin);
204   GstVaapiPadPrivate * (*get_vaapi_pad_private) (GstVaapiPluginBase * plugin, GstPad * pad);
205 };
206
207 G_GNUC_INTERNAL
208 void
209 gst_vaapi_plugin_base_init_interfaces (GType type);
210
211 G_GNUC_INTERNAL
212 void
213 gst_vaapi_plugin_base_class_init (GstVaapiPluginBaseClass * klass);
214
215 G_GNUC_INTERNAL
216 void
217 gst_vaapi_plugin_base_init (GstVaapiPluginBase * plugin,
218     GstDebugCategory * debug_category);
219
220 G_GNUC_INTERNAL
221 void
222 gst_vaapi_plugin_base_finalize (GstVaapiPluginBase * plugin);
223
224 G_GNUC_INTERNAL
225 gboolean
226 gst_vaapi_plugin_base_open (GstVaapiPluginBase * plugin);
227
228 G_GNUC_INTERNAL
229 void
230 gst_vaapi_plugin_base_close (GstVaapiPluginBase * plugin);
231
232 G_GNUC_INTERNAL
233 gboolean
234 gst_vaapi_plugin_base_has_display_type (GstVaapiPluginBase * plugin,
235     GstVaapiDisplayType display_type_req);
236
237 G_GNUC_INTERNAL
238 void
239 gst_vaapi_plugin_base_set_display_type (GstVaapiPluginBase * plugin,
240     GstVaapiDisplayType display_type);
241
242 G_GNUC_INTERNAL
243 void
244 gst_vaapi_plugin_base_set_display_name (GstVaapiPluginBase * plugin,
245     const gchar * display_name);
246
247 G_GNUC_INTERNAL
248 gboolean
249 gst_vaapi_plugin_base_ensure_display (GstVaapiPluginBase * plugin);
250
251 G_GNUC_INTERNAL
252 gboolean
253 gst_vaapi_plugin_base_set_caps (GstVaapiPluginBase * plugin, GstCaps * incaps,
254     GstCaps * outcaps);
255
256 G_GNUC_INTERNAL
257 gboolean
258 gst_vaapi_plugin_base_pad_set_caps (GstVaapiPluginBase *plugin,
259     GstPad * sinkpad, GstCaps * incaps, GstPad * srcpad, GstCaps * outcaps);
260
261 G_GNUC_INTERNAL
262 gboolean
263 gst_vaapi_plugin_base_propose_allocation (GstVaapiPluginBase * plugin,
264     GstQuery * query);
265
266 G_GNUC_INTERNAL
267 gboolean
268 gst_vaapi_plugin_base_pad_propose_allocation (GstVaapiPluginBase * plugin,
269     GstPad * sinkpad, GstQuery * query);
270
271 G_GNUC_INTERNAL
272 gboolean
273 gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
274     GstQuery * query);
275
276 G_GNUC_INTERNAL
277 GstFlowReturn
278 gst_vaapi_plugin_base_get_input_buffer (GstVaapiPluginBase * plugin,
279     GstBuffer * inbuf, GstBuffer ** outbuf_ptr);
280
281 G_GNUC_INTERNAL
282 GstFlowReturn
283 gst_vaapi_plugin_base_pad_get_input_buffer (GstVaapiPluginBase * plugin,
284     GstPad * sinkpad, GstBuffer * inbuf, GstBuffer ** outbuf_ptr);
285
286 G_GNUC_INTERNAL
287 void
288 gst_vaapi_plugin_base_set_context (GstVaapiPluginBase * plugin,
289     GstContext * context);
290
291 G_GNUC_INTERNAL
292 void
293 gst_vaapi_plugin_base_set_gl_context (GstVaapiPluginBase * plugin,
294     GstObject * object);
295
296 G_GNUC_INTERNAL
297 GstObject *
298 gst_vaapi_plugin_base_create_gl_context (GstVaapiPluginBase * plugin);
299
300 G_GNUC_INTERNAL
301 GstCaps *
302 gst_vaapi_plugin_base_get_allowed_sinkpad_raw_caps (GstVaapiPluginBase * plugin);
303
304 G_GNUC_INTERNAL
305 void
306 gst_vaapi_plugin_base_set_srcpad_can_dmabuf (GstVaapiPluginBase * plugin,
307     GstObject * object);
308
309 G_GNUC_INTERNAL
310 gboolean
311 gst_vaapi_plugin_copy_va_buffer (GstVaapiPluginBase * plugin,
312     GstBuffer * inbuf, GstBuffer * outbuf);
313
314
315 G_END_DECLS
316
317 #endif /* GST_VAAPI_PLUGIN_BASE_H */