vaapidecode: handle flush() vmethod
[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 #if GST_CHECK_VERSION(1,0,0)
134   GstBufferPool *sinkpad_buffer_pool;
135   guint sinkpad_buffer_size;
136 #endif
137
138   GstPad *srcpad;
139   GstCaps *srcpad_caps;
140   gboolean srcpad_caps_changed;
141   GstVideoInfo srcpad_info;
142   GstPadQueryFunction srcpad_query;
143 #if GST_CHECK_VERSION(1,0,0)
144   GstBufferPool *srcpad_buffer_pool;
145 #endif
146
147   GstVaapiDisplay *display;
148   GstVaapiDisplayType display_type;
149   GstVaapiDisplayType display_type_req;
150   gchar *display_name;
151
152   GstObject *gl_context;
153
154   GstVaapiUploader *uploader;
155   gboolean uploader_used;
156 };
157
158 struct _GstVaapiPluginBaseClass
159 {
160   /*< private >*/
161   union
162   {
163     GstElementClass element;
164     GstVideoDecoderClass decoder;
165     GstVideoEncoderClass encoder;
166     GstBaseTransformClass transform;
167     GstVideoSinkClass sink;
168   } parent_class;
169
170   gboolean  (*has_interface) (GstVaapiPluginBase * plugin, GType type);
171   void (*display_changed) (GstVaapiPluginBase * plugin);
172 };
173
174 G_GNUC_INTERNAL
175 void
176 gst_vaapi_plugin_base_init_interfaces (GType type);
177
178 G_GNUC_INTERNAL
179 void
180 gst_vaapi_plugin_base_class_init (GstVaapiPluginBaseClass * klass);
181
182 G_GNUC_INTERNAL
183 void
184 gst_vaapi_plugin_base_init (GstVaapiPluginBase * plugin,
185     GstDebugCategory * debug_category);
186
187 G_GNUC_INTERNAL
188 void
189 gst_vaapi_plugin_base_finalize (GstVaapiPluginBase * plugin);
190
191 G_GNUC_INTERNAL
192 gboolean
193 gst_vaapi_plugin_base_open (GstVaapiPluginBase * plugin);
194
195 G_GNUC_INTERNAL
196 void
197 gst_vaapi_plugin_base_close (GstVaapiPluginBase * plugin);
198
199 G_GNUC_INTERNAL
200 gboolean
201 gst_vaapi_plugin_base_has_display_type (GstVaapiPluginBase * plugin,
202     GstVaapiDisplayType display_type_req);
203
204 G_GNUC_INTERNAL
205 void
206 gst_vaapi_plugin_base_set_display_type (GstVaapiPluginBase * plugin,
207     GstVaapiDisplayType display_type);
208
209 G_GNUC_INTERNAL
210 void
211 gst_vaapi_plugin_base_set_display_name (GstVaapiPluginBase * plugin,
212     const gchar * display_name);
213
214 G_GNUC_INTERNAL
215 gboolean
216 gst_vaapi_plugin_base_ensure_display (GstVaapiPluginBase * plugin);
217
218 G_GNUC_INTERNAL
219 gboolean
220 gst_vaapi_plugin_base_ensure_uploader (GstVaapiPluginBase * plugin);
221
222 G_GNUC_INTERNAL
223 gboolean
224 gst_vaapi_plugin_base_set_caps (GstVaapiPluginBase * plugin, GstCaps * incaps,
225     GstCaps * outcaps);
226
227 G_GNUC_INTERNAL
228 gboolean
229 gst_vaapi_plugin_base_propose_allocation (GstVaapiPluginBase * plugin,
230     GstQuery * query);
231
232 G_GNUC_INTERNAL
233 gboolean
234 gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
235     GstQuery * query, guint feature);
236
237 G_GNUC_INTERNAL
238 GstFlowReturn
239 gst_vaapi_plugin_base_allocate_input_buffer (GstVaapiPluginBase * plugin,
240     GstCaps * caps, GstBuffer ** outbuf_ptr);
241
242 G_GNUC_INTERNAL
243 GstFlowReturn
244 gst_vaapi_plugin_base_get_input_buffer (GstVaapiPluginBase * plugin,
245     GstBuffer * inbuf, GstBuffer ** outbuf_ptr);
246
247 G_GNUC_INTERNAL
248 void
249 gst_vaapi_plugin_base_set_gl_context (GstVaapiPluginBase * plugin,
250     GstObject * object);
251
252 G_END_DECLS
253
254 #endif /* GST_VAAPI_PLUGIN_BASE_H */