plugins: factor out pad caps.
[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 G_BEGIN_DECLS
35
36 typedef struct _GstVaapiPluginBase GstVaapiPluginBase;
37 typedef struct _GstVaapiPluginBaseClass GstVaapiPluginBaseClass;
38
39 #define GST_VAAPI_PLUGIN_BASE(plugin) \
40   ((GstVaapiPluginBase *)(plugin))
41 #define GST_VAAPI_PLUGIN_BASE_CLASS(plugin) \
42   ((GstVaapiPluginBaseClass *)(plugin))
43 #define GST_VAAPI_PLUGIN_BASE_GET_CLASS(plugin) \
44   GST_VAAPI_PLUGIN_BASE_CLASS(GST_ELEMENT_GET_CLASS( \
45       GST_VAAPI_PLUGIN_BASE_ELEMENT(plugin)))
46 #define GST_VAAPI_PLUGIN_BASE_PARENT(plugin) \
47   (&GST_VAAPI_PLUGIN_BASE(plugin)->parent_instance)
48 #define GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin) \
49   (&GST_VAAPI_PLUGIN_BASE_CLASS(plugin)->parent_class)
50 #define GST_VAAPI_PLUGIN_BASE_ELEMENT(plugin) \
51   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->element)
52 #define GST_VAAPI_PLUGIN_BASE_ELEMENT_CLASS(plugin) \
53   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->element)
54 #define GST_VAAPI_PLUGIN_BASE_DECODER(plugin) \
55   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->decoder)
56 #define GST_VAAPI_PLUGIN_BASE_DECODER_CLASS(plugin) \
57   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->decoder)
58 #define GST_VAAPI_PLUGIN_BASE_ENCODER(plugin) \
59   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->encoder)
60 #define GST_VAAPI_PLUGIN_BASE_ENCODER_CLASS(plugin) \
61   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->encoder)
62 #define GST_VAAPI_PLUGIN_BASE_TRANSFORM(plugin) \
63   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->transform)
64 #define GST_VAAPI_PLUGIN_BASE_TRANSFORM_CLASS(plugin) \
65   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->transform)
66 #define GST_VAAPI_PLUGIN_BASE_SINK(plugin) \
67   (&GST_VAAPI_PLUGIN_BASE_PARENT(plugin)->sink)
68 #define GST_VAAPI_PLUGIN_BASE_SINK_CLASS(plugin) \
69   (&GST_VAAPI_PLUGIN_BASE_PARENT_CLASS(plugin)->sink)
70
71 #define GST_VAAPI_PLUGIN_BASE_INIT_INTERFACES \
72   gst_vaapi_plugin_base_init_interfaces(g_define_type_id);
73
74 #define GST_VAAPI_PLUGIN_BASE_SINK_PAD(plugin) \
75   (GST_VAAPI_PLUGIN_BASE(plugin)->sinkpad)
76 #define GST_VAAPI_PLUGIN_BASE_SINK_PAD_CAPS(plugin) \
77   (GST_VAAPI_PLUGIN_BASE(plugin)->sinkpad_caps)
78 #define GST_VAAPI_PLUGIN_BASE_SINK_PAD_INFO(plugin) \
79   (&GST_VAAPI_PLUGIN_BASE(plugin)->sinkpad_info)
80 #define GST_VAAPI_PLUGIN_BASE_SINK_PAD_QUERYFUNC(plugin) \
81   (GST_VAAPI_PLUGIN_BASE(plugin)->sinkpad_query)
82 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD(plugin) \
83   (GST_VAAPI_PLUGIN_BASE(plugin)->srcpad)
84 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD_CAPS(plugin) \
85   (GST_VAAPI_PLUGIN_BASE(plugin)->srcpad_caps)
86 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD_INFO(plugin) \
87   (&GST_VAAPI_PLUGIN_BASE(plugin)->srcpad_info)
88 #define GST_VAAPI_PLUGIN_BASE_SRC_PAD_QUERYFYNC(plugin) \
89   (GST_VAAPI_PLUGIN_BASE(plugin)->srcpad_query)
90
91 #define GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin) \
92   (GST_VAAPI_PLUGIN_BASE(plugin)->display)
93 #define GST_VAAPI_PLUGIN_BASE_DISPLAY_TYPE(plugin) \
94   (GST_VAAPI_PLUGIN_BASE(plugin)->display_type)
95 #define GST_VAAPI_PLUGIN_BASE_DISPLAY_REPLACE(plugin, new_display) \
96   (gst_vaapi_display_replace(&GST_VAAPI_PLUGIN_BASE_DISPLAY(plugin), \
97        (new_display)))
98
99 struct _GstVaapiPluginBase
100 {
101   /*< private >*/
102   union
103   {
104     GstElement element;
105     GstVideoDecoder decoder;
106     GstVideoEncoder encoder;
107     GstBaseTransform transform;
108     GstVideoSink sink;
109   } parent_instance;
110
111   GstDebugCategory *debug_category;
112
113   GstPad *sinkpad;
114   GstCaps *sinkpad_caps;
115   gboolean sinkpad_caps_changed;
116   GstVideoInfo sinkpad_info;
117   GstPadQueryFunction sinkpad_query;
118
119   GstPad *srcpad;
120   GstCaps *srcpad_caps;
121   gboolean srcpad_caps_changed;
122   GstVideoInfo srcpad_info;
123   GstPadQueryFunction srcpad_query;
124
125   GstVaapiDisplay *display;
126   GstVaapiDisplayType display_type;
127   GstVaapiDisplayType display_type_req;
128 };
129
130 struct _GstVaapiPluginBaseClass
131 {
132   /*< private >*/
133   union
134   {
135     GstElementClass element;
136     GstVideoDecoderClass decoder;
137     GstVideoEncoderClass encoder;
138     GstBaseTransformClass transform;
139     GstVideoSinkClass sink;
140   } parent_class;
141
142   gboolean  (*has_interface) (GstVaapiPluginBase * plugin, GType type);
143   void (*display_changed) (GstVaapiPluginBase * plugin);
144 };
145
146 G_GNUC_INTERNAL
147 void
148 gst_vaapi_plugin_base_init_interfaces (GType type);
149
150 G_GNUC_INTERNAL
151 void
152 gst_vaapi_plugin_base_class_init (GstVaapiPluginBaseClass * klass);
153
154 G_GNUC_INTERNAL
155 void
156 gst_vaapi_plugin_base_init (GstVaapiPluginBase * plugin,
157     GstDebugCategory * debug_category);
158
159 G_GNUC_INTERNAL
160 void
161 gst_vaapi_plugin_base_finalize (GstVaapiPluginBase * plugin);
162
163 G_GNUC_INTERNAL
164 gboolean
165 gst_vaapi_plugin_base_open (GstVaapiPluginBase * plugin);
166
167 G_GNUC_INTERNAL
168 void
169 gst_vaapi_plugin_base_close (GstVaapiPluginBase * plugin);
170
171 G_GNUC_INTERNAL
172 void
173 gst_vaapi_plugin_base_set_display_type (GstVaapiPluginBase * plugin,
174     GstVaapiDisplayType display_type);
175
176 G_GNUC_INTERNAL
177 gboolean
178 gst_vaapi_plugin_base_ensure_display (GstVaapiPluginBase * plugin);
179
180 G_GNUC_INTERNAL
181 gboolean
182 gst_vaapi_plugin_base_set_caps (GstVaapiPluginBase * plugin, GstCaps * incaps,
183     GstCaps * outcaps);
184
185 G_END_DECLS
186
187 #endif /* GST_VAAPI_PLUGIN_BASE_H */