plugins: remove unused variables
[platform/upstream/gstreamer.git] / 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 #if USE_GST_GL_HELPERS
35 # include <gst/gl/gstglcontext.h>
36 #endif
37
38 G_BEGIN_DECLS
39
40 typedef struct _GstVaapiPluginBase GstVaapiPluginBase;
41 typedef struct _GstVaapiPluginBaseClass GstVaapiPluginBaseClass;
42
43 #define GST_VAAPI_PLUGIN_BASE(plugin) \
44   ((GstVaapiPluginBase *)(plugin))
45 #define GST_VAAPI_PLUGIN_BASE_CLASS(plugin) \
46   ((GstVaapiPluginBaseClass *)(plugin))
47 #define GST_VAAPI_PLUGIN_BASE_GET_CLASS(plugin) \
48   GST_VAAPI_PLUGIN_BASE_CLASS(GST_ELEMENT_GET_CLASS( \
49       GST_VAAPI_PLUGIN_BASE_ELEMENT(plugin)))
50 #define GST_VAAPI_PLUGIN_BASE_PARENT(plugin) \
51   (&GST_VAAPI_PLUGIN_BASE(plugin)->parent_instance)
52 #define GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin) \
53   (&GST_VAAPI_PLUGIN_BASE_CLASS(plugin)->parent_class)
54 #define GST_VAAPI_PLUGIN_BASE_ELEMENT(plugin) \
55   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->element)
56 #define GST_VAAPI_PLUGIN_BASE_ELEMENT_CLASS(plugin) \
57   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->element)
58 #define GST_VAAPI_PLUGIN_BASE_DECODER(plugin) \
59   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->decoder)
60 #define GST_VAAPI_PLUGIN_BASE_DECODER_CLASS(plugin) \
61   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->decoder)
62 #define GST_VAAPI_PLUGIN_BASE_ENCODER(plugin) \
63   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->encoder)
64 #define GST_VAAPI_PLUGIN_BASE_ENCODER_CLASS(plugin) \
65   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->encoder)
66 #define GST_VAAPI_PLUGIN_BASE_TRANSFORM(plugin) \
67   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->transform)
68 #define GST_VAAPI_PLUGIN_BASE_TRANSFORM_CLASS(plugin) \
69   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->transform)
70 #define GST_VAAPI_PLUGIN_BASE_SINK(plugin) \
71   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->sink)
72 #define GST_VAAPI_PLUGIN_BASE_SINK_CLASS(plugin) \
73   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->sink)
74
75 #define GST_VAAPI_PLUGIN_BASE_INIT_INTERFACES \
76   gst_vaapi_plugin_base_init_interfaces(g_define_type_id);
77
78 #define GST_VAAPI_PLUGIN_BASE_SINK_PAD(plugin) \
79   (GST_VAAPI_PLUGIN_BASE(plugin)->sinkpad)
80 #define GST_VAAPI_PLUGIN_BASE_SINK_PAD_CAPS(plugin) \
81   (GST_VAAPI_PLUGIN_BASE(plugin)->sinkpad_caps)
82 #define GST_VAAPI_PLUGIN_BASE_SINK_PAD_INFO(plugin) \
83   (&GST_VAAPI_PLUGIN_BASE(plugin)->sinkpad_info)
84 #define GST_VAAPI_PLUGIN_BASE_SINK_PAD_QUERYFUNC(plugin) \
85   (GST_VAAPI_PLUGIN_BASE(plugin)->sinkpad_query)
86 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD(plugin) \
87   (GST_VAAPI_PLUGIN_BASE(plugin)->srcpad)
88 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD_CAPS(plugin) \
89   (GST_VAAPI_PLUGIN_BASE(plugin)->srcpad_caps)
90 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD_INFO(plugin) \
91   (&GST_VAAPI_PLUGIN_BASE(plugin)->srcpad_info)
92 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD_QUERYFYNC(plugin) \
93   (GST_VAAPI_PLUGIN_BASE(plugin)->srcpad_query)
94
95 #define GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin) \
96   (GST_VAAPI_PLUGIN_BASE(plugin)->display)
97 #define GST_VAAPI_PLUGIN_BASE_DISPLAY_TYPE(plugin) \
98   (GST_VAAPI_PLUGIN_BASE(plugin)->display_type)
99 #define GST_VAAPI_PLUGIN_BASE_DISPLAY_NAME(plugin) \
100   (GST_VAAPI_PLUGIN_BASE(plugin)->display_name)
101 #define GST_VAAPI_PLUGIN_BASE_DISPLAY_REPLACE(plugin, new_display) \
102   (gst_vaapi_display_replace(&GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin), \
103        (new_display)))
104
105 #define GST_VAAPI_PLUGIN_BASE_DEFINE_VMETHODS(parent_class) \
106   GST_VAAPI_PLUGIN_BASE_DEFINE_SET_CONTEXT(parent_class) \
107   GST_VAAPI_PLUGIN_BASE_DEFINE_CHANGE_STATE(parent_class)
108
109 #define GST_VAAPI_PLUGIN_BASE_DEFINE_SET_CONTEXT(parent_class) \
110   static void \
111   gst_vaapi_base_set_context (GstElement * element, GstContext * context) \
112   { \
113     GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (element); \
114     \
115     gst_vaapi_plugin_base_set_context (plugin, context); \
116     GST_ELEMENT_CLASS (parent_class)->set_context (element, context); \
117   }
118
119 #define GST_VAAPI_PLUGIN_BASE_DEFINE_CHANGE_STATE(parent_class) \
120   static GstStateChangeReturn \
121   gst_vaapi_base_change_state (GstElement * element, \
122       GstStateChange transition) \
123   { \
124     GstStateChangeReturn ret; \
125     \
126     ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, \
127         transition);  \
128     if (ret == GST_STATE_CHANGE_FAILURE) \
129       return ret; \
130     \
131     switch (transition) { \
132       case GST_STATE_CHANGE_NULL_TO_READY:{ \
133         GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (element); \
134         if (!gst_vaapi_plugin_base_driver_is_whitelisted (plugin)) \
135           ret = GST_STATE_CHANGE_FAILURE; \
136         break; \
137       } \
138       default: \
139         break; \
140     }          \
141     return ret; \
142   }
143
144 struct _GstVaapiPluginBase
145 {
146   /*< private >*/
147   union
148   {
149     GstElement element;
150     GstVideoDecoder decoder;
151     GstVideoEncoder encoder;
152     GstBaseTransform transform;
153     GstVideoSink sink;
154   } parent_instance;
155
156   GstDebugCategory *debug_category;
157
158   GstPad *sinkpad;
159   GstCaps *sinkpad_caps;
160   gboolean sinkpad_caps_is_raw;
161   GstVideoInfo sinkpad_info;
162   GstBufferPool *sinkpad_buffer_pool;
163   guint sinkpad_buffer_size;
164
165   GstPad *srcpad;
166   GstCaps *srcpad_caps;
167   GstVideoInfo srcpad_info;
168   GstBufferPool *srcpad_buffer_pool;
169
170   GstVaapiDisplay *display;
171   GstVaapiDisplayType display_type;
172   GstVaapiDisplayType display_type_req;
173   gchar *display_name;
174
175   GstObject *gl_context;
176
177   GstCaps *allowed_raw_caps;
178 };
179
180 struct _GstVaapiPluginBaseClass
181 {
182   /*< private >*/
183   union
184   {
185     GstElementClass element;
186     GstVideoDecoderClass decoder;
187     GstVideoEncoderClass encoder;
188     GstBaseTransformClass transform;
189     GstVideoSinkClass sink;
190   } parent_class;
191
192   gboolean  (*has_interface) (GstVaapiPluginBase * plugin, GType type);
193   void (*display_changed) (GstVaapiPluginBase * plugin);
194 };
195
196 G_GNUC_INTERNAL
197 void
198 gst_vaapi_plugin_base_init_interfaces (GType type);
199
200 G_GNUC_INTERNAL
201 void
202 gst_vaapi_plugin_base_class_init (GstVaapiPluginBaseClass * klass);
203
204 G_GNUC_INTERNAL
205 void
206 gst_vaapi_plugin_base_init (GstVaapiPluginBase * plugin,
207     GstDebugCategory * debug_category);
208
209 G_GNUC_INTERNAL
210 void
211 gst_vaapi_plugin_base_finalize (GstVaapiPluginBase * plugin);
212
213 G_GNUC_INTERNAL
214 gboolean
215 gst_vaapi_plugin_base_open (GstVaapiPluginBase * plugin);
216
217 G_GNUC_INTERNAL
218 void
219 gst_vaapi_plugin_base_close (GstVaapiPluginBase * plugin);
220
221 G_GNUC_INTERNAL
222 gboolean
223 gst_vaapi_plugin_base_has_display_type (GstVaapiPluginBase * plugin,
224     GstVaapiDisplayType display_type_req);
225
226 G_GNUC_INTERNAL
227 void
228 gst_vaapi_plugin_base_set_display_type (GstVaapiPluginBase * plugin,
229     GstVaapiDisplayType display_type);
230
231 G_GNUC_INTERNAL
232 void
233 gst_vaapi_plugin_base_set_display_name (GstVaapiPluginBase * plugin,
234     const gchar * display_name);
235
236 G_GNUC_INTERNAL
237 gboolean
238 gst_vaapi_plugin_base_ensure_display (GstVaapiPluginBase * plugin);
239
240 G_GNUC_INTERNAL
241 gboolean
242 gst_vaapi_plugin_base_set_caps (GstVaapiPluginBase * plugin, GstCaps * incaps,
243     GstCaps * outcaps);
244
245 G_GNUC_INTERNAL
246 gboolean
247 gst_vaapi_plugin_base_propose_allocation (GstVaapiPluginBase * plugin,
248     GstQuery * query);
249
250 G_GNUC_INTERNAL
251 gboolean
252 gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
253     GstQuery * query);
254
255 G_GNUC_INTERNAL
256 GstFlowReturn
257 gst_vaapi_plugin_base_get_input_buffer (GstVaapiPluginBase * plugin,
258     GstBuffer * inbuf, GstBuffer ** outbuf_ptr);
259
260 G_GNUC_INTERNAL
261 gboolean
262 gst_vaapi_plugin_base_driver_is_whitelisted (GstVaapiPluginBase * plugin);
263
264 G_GNUC_INTERNAL
265 void
266 gst_vaapi_plugin_base_set_context (GstVaapiPluginBase * plugin,
267     GstContext * context);
268
269 G_GNUC_INTERNAL
270 void
271 gst_vaapi_plugin_base_set_gl_context (GstVaapiPluginBase * plugin,
272     GstObject * object);
273
274 G_GNUC_INTERNAL
275 GstCaps *
276 gst_vaapi_plugin_base_get_allowed_raw_caps (GstVaapiPluginBase * plugin);
277
278 G_END_DECLS
279
280 #endif /* GST_VAAPI_PLUGIN_BASE_H */