Removal of gstreamer-0.10 support
[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 #include "gstvaapiuploader.h"
34
35 #ifdef HAVE_GST_GL_GL_H
36 # include <gst/gl/gstglcontext.h>
37 #endif
38
39 G_BEGIN_DECLS
40
41 typedef struct _GstVaapiPluginBase GstVaapiPluginBase;
42 typedef struct _GstVaapiPluginBaseClass GstVaapiPluginBaseClass;
43
44 #define GST_VAAPI_PLUGIN_BASE(plugin) \
45   ((GstVaapiPluginBase *)(plugin))
46 #define GST_VAAPI_PLUGIN_BASE_CLASS(plugin) \
47   ((GstVaapiPluginBaseClass *)(plugin))
48 #define GST_VAAPI_PLUGIN_BASE_GET_CLASS(plugin) \
49   GST_VAAPI_PLUGIN_BASE_CLASS(GST_ELEMENT_GET_CLASS( \
50       GST_VAAPI_PLUGIN_BASE_ELEMENT(plugin)))
51 #define GST_VAAPI_PLUGIN_BASE_PARENT(plugin) \
52   (&GST_VAAPI_PLUGIN_BASE(plugin)->parent_instance)
53 #define GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin) \
54   (&GST_VAAPI_PLUGIN_BASE_CLASS(plugin)->parent_class)
55 #define GST_VAAPI_PLUGIN_BASE_ELEMENT(plugin) \
56   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->element)
57 #define GST_VAAPI_PLUGIN_BASE_ELEMENT_CLASS(plugin) \
58   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->element)
59 #define GST_VAAPI_PLUGIN_BASE_DECODER(plugin) \
60   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->decoder)
61 #define GST_VAAPI_PLUGIN_BASE_DECODER_CLASS(plugin) \
62   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->decoder)
63 #define GST_VAAPI_PLUGIN_BASE_ENCODER(plugin) \
64   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->encoder)
65 #define GST_VAAPI_PLUGIN_BASE_ENCODER_CLASS(plugin) \
66   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->encoder)
67 #define GST_VAAPI_PLUGIN_BASE_TRANSFORM(plugin) \
68   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->transform)
69 #define GST_VAAPI_PLUGIN_BASE_TRANSFORM_CLASS(plugin) \
70   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->transform)
71 #define GST_VAAPI_PLUGIN_BASE_SINK(plugin) \
72   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->sink)
73 #define GST_VAAPI_PLUGIN_BASE_SINK_CLASS(plugin) \
74   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->sink)
75
76 #define GST_VAAPI_PLUGIN_BASE_INIT_INTERFACES \
77   gst_vaapi_plugin_base_init_interfaces(g_define_type_id);
78
79 #define GST_VAAPI_PLUGIN_BASE_SINK_PAD(plugin) \
80   (GST_VAAPI_PLUGIN_BASE(plugin)->sinkpad)
81 #define GST_VAAPI_PLUGIN_BASE_SINK_PAD_CAPS(plugin) \
82   (GST_VAAPI_PLUGIN_BASE(plugin)->sinkpad_caps)
83 #define GST_VAAPI_PLUGIN_BASE_SINK_PAD_INFO(plugin) \
84   (&GST_VAAPI_PLUGIN_BASE(plugin)->sinkpad_info)
85 #define GST_VAAPI_PLUGIN_BASE_SINK_PAD_QUERYFUNC(plugin) \
86   (GST_VAAPI_PLUGIN_BASE(plugin)->sinkpad_query)
87 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD(plugin) \
88   (GST_VAAPI_PLUGIN_BASE(plugin)->srcpad)
89 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD_CAPS(plugin) \
90   (GST_VAAPI_PLUGIN_BASE(plugin)->srcpad_caps)
91 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD_INFO(plugin) \
92   (&GST_VAAPI_PLUGIN_BASE(plugin)->srcpad_info)
93 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD_QUERYFYNC(plugin) \
94   (GST_VAAPI_PLUGIN_BASE(plugin)->srcpad_query)
95
96 #define GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin) \
97   (GST_VAAPI_PLUGIN_BASE(plugin)->display)
98 #define GST_VAAPI_PLUGIN_BASE_DISPLAY_TYPE(plugin) \
99   (GST_VAAPI_PLUGIN_BASE(plugin)->display_type)
100 #define GST_VAAPI_PLUGIN_BASE_DISPLAY_NAME(plugin) \
101   (GST_VAAPI_PLUGIN_BASE(plugin)->display_name)
102 #define GST_VAAPI_PLUGIN_BASE_DISPLAY_REPLACE(plugin, new_display) \
103   (gst_vaapi_display_replace(&GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin), \
104        (new_display)))
105
106 #define GST_VAAPI_PLUGIN_BASE_UPLOADER(plugin) \
107   (GST_VAAPI_PLUGIN_BASE(plugin)->uploader)
108 #define GST_VAAPI_PLUGIN_BASE_UPLOADER_CAPS(plugin) \
109   (gst_vaapi_uploader_get_caps(GST_VAAPI_PLUGIN_BASE_UPLOADER(plugin)))
110 #define GST_VAAPI_PLUGIN_BASE_UPLOADER_USED(plugin) \
111   (GST_VAAPI_PLUGIN_BASE(plugin)->uploader_used)
112
113 struct _GstVaapiPluginBase
114 {
115   /*< private >*/
116   union
117   {
118     GstElement element;
119     GstVideoDecoder decoder;
120     GstVideoEncoder encoder;
121     GstBaseTransform transform;
122     GstVideoSink sink;
123   } parent_instance;
124
125   GstDebugCategory *debug_category;
126
127   GstPad *sinkpad;
128   GstCaps *sinkpad_caps;
129   gboolean sinkpad_caps_changed;
130   gboolean sinkpad_caps_is_raw;
131   GstVideoInfo sinkpad_info;
132   GstPadQueryFunction sinkpad_query;
133   GstBufferPool *sinkpad_buffer_pool;
134   guint sinkpad_buffer_size;
135
136   GstPad *srcpad;
137   GstCaps *srcpad_caps;
138   gboolean srcpad_caps_changed;
139   GstVideoInfo srcpad_info;
140   GstPadQueryFunction srcpad_query;
141   GstBufferPool *srcpad_buffer_pool;
142
143   GstVaapiDisplay *display;
144   GstVaapiDisplayType display_type;
145   GstVaapiDisplayType display_type_req;
146   gchar *display_name;
147
148   GstObject *gl_context;
149
150   GstVaapiUploader *uploader;
151   gboolean uploader_used;
152 };
153
154 struct _GstVaapiPluginBaseClass
155 {
156   /*< private >*/
157   union
158   {
159     GstElementClass element;
160     GstVideoDecoderClass decoder;
161     GstVideoEncoderClass encoder;
162     GstBaseTransformClass transform;
163     GstVideoSinkClass sink;
164   } parent_class;
165
166   gboolean  (*has_interface) (GstVaapiPluginBase * plugin, GType type);
167   void (*display_changed) (GstVaapiPluginBase * plugin);
168 };
169
170 G_GNUC_INTERNAL
171 void
172 gst_vaapi_plugin_base_init_interfaces (GType type);
173
174 G_GNUC_INTERNAL
175 void
176 gst_vaapi_plugin_base_class_init (GstVaapiPluginBaseClass * klass);
177
178 G_GNUC_INTERNAL
179 void
180 gst_vaapi_plugin_base_init (GstVaapiPluginBase * plugin,
181     GstDebugCategory * debug_category);
182
183 G_GNUC_INTERNAL
184 void
185 gst_vaapi_plugin_base_finalize (GstVaapiPluginBase * plugin);
186
187 G_GNUC_INTERNAL
188 gboolean
189 gst_vaapi_plugin_base_open (GstVaapiPluginBase * plugin);
190
191 G_GNUC_INTERNAL
192 void
193 gst_vaapi_plugin_base_close (GstVaapiPluginBase * plugin);
194
195 G_GNUC_INTERNAL
196 gboolean
197 gst_vaapi_plugin_base_has_display_type (GstVaapiPluginBase * plugin,
198     GstVaapiDisplayType display_type_req);
199
200 G_GNUC_INTERNAL
201 void
202 gst_vaapi_plugin_base_set_display_type (GstVaapiPluginBase * plugin,
203     GstVaapiDisplayType display_type);
204
205 G_GNUC_INTERNAL
206 void
207 gst_vaapi_plugin_base_set_display_name (GstVaapiPluginBase * plugin,
208     const gchar * display_name);
209
210 G_GNUC_INTERNAL
211 gboolean
212 gst_vaapi_plugin_base_ensure_display (GstVaapiPluginBase * plugin);
213
214 G_GNUC_INTERNAL
215 gboolean
216 gst_vaapi_plugin_base_ensure_uploader (GstVaapiPluginBase * plugin);
217
218 G_GNUC_INTERNAL
219 gboolean
220 gst_vaapi_plugin_base_set_caps (GstVaapiPluginBase * plugin, GstCaps * incaps,
221     GstCaps * outcaps);
222
223 G_GNUC_INTERNAL
224 gboolean
225 gst_vaapi_plugin_base_propose_allocation (GstVaapiPluginBase * plugin,
226     GstQuery * query);
227
228 G_GNUC_INTERNAL
229 gboolean
230 gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
231     GstQuery * query, guint feature);
232
233 G_GNUC_INTERNAL
234 GstFlowReturn
235 gst_vaapi_plugin_base_allocate_input_buffer (GstVaapiPluginBase * plugin,
236     GstCaps * caps, GstBuffer ** outbuf_ptr);
237
238 G_GNUC_INTERNAL
239 GstFlowReturn
240 gst_vaapi_plugin_base_get_input_buffer (GstVaapiPluginBase * plugin,
241     GstBuffer * inbuf, GstBuffer ** outbuf_ptr);
242
243 G_GNUC_INTERNAL
244 void
245 gst_vaapi_plugin_base_set_gl_context (GstVaapiPluginBase * plugin,
246     GstObject * object);
247
248 G_END_DECLS
249
250 #endif /* GST_VAAPI_PLUGIN_BASE_H */