2 * gstvaapipluginbase.h - Base GStreamer VA-API Plugin element
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>
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.
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.
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
25 #ifndef GST_VAAPI_PLUGIN_BASE_H
26 #define GST_VAAPI_PLUGIN_BASE_H
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"
35 #ifdef HAVE_GST_GL_GL_H
36 # include <gst/gl/gstglcontext.h>
41 typedef struct _GstVaapiPluginBase GstVaapiPluginBase;
42 typedef struct _GstVaapiPluginBaseClass GstVaapiPluginBaseClass;
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)
76 #define GST_VAAPI_PLUGIN_BASE_INIT_INTERFACES \
77 gst_vaapi_plugin_base_init_interfaces(g_define_type_id);
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)
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), \
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)
113 struct _GstVaapiPluginBase
119 GstVideoDecoder decoder;
120 GstVideoEncoder encoder;
121 GstBaseTransform transform;
125 GstDebugCategory *debug_category;
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;
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;
147 GstVaapiDisplay *display;
148 GstVaapiDisplayType display_type;
149 GstVaapiDisplayType display_type_req;
152 GstObject *gl_context;
154 GstVaapiUploader *uploader;
155 gboolean uploader_used;
158 struct _GstVaapiPluginBaseClass
163 GstElementClass element;
164 GstVideoDecoderClass decoder;
165 GstVideoEncoderClass encoder;
166 GstBaseTransformClass transform;
167 GstVideoSinkClass sink;
170 gboolean (*has_interface) (GstVaapiPluginBase * plugin, GType type);
171 void (*display_changed) (GstVaapiPluginBase * plugin);
176 gst_vaapi_plugin_base_init_interfaces (GType type);
180 gst_vaapi_plugin_base_class_init (GstVaapiPluginBaseClass * klass);
184 gst_vaapi_plugin_base_init (GstVaapiPluginBase * plugin,
185 GstDebugCategory * debug_category);
189 gst_vaapi_plugin_base_finalize (GstVaapiPluginBase * plugin);
193 gst_vaapi_plugin_base_open (GstVaapiPluginBase * plugin);
197 gst_vaapi_plugin_base_close (GstVaapiPluginBase * plugin);
201 gst_vaapi_plugin_base_has_display_type (GstVaapiPluginBase * plugin,
202 GstVaapiDisplayType display_type_req);
206 gst_vaapi_plugin_base_set_display_type (GstVaapiPluginBase * plugin,
207 GstVaapiDisplayType display_type);
211 gst_vaapi_plugin_base_set_display_name (GstVaapiPluginBase * plugin,
212 const gchar * display_name);
216 gst_vaapi_plugin_base_ensure_display (GstVaapiPluginBase * plugin);
220 gst_vaapi_plugin_base_ensure_uploader (GstVaapiPluginBase * plugin);
224 gst_vaapi_plugin_base_set_caps (GstVaapiPluginBase * plugin, GstCaps * incaps,
229 gst_vaapi_plugin_base_propose_allocation (GstVaapiPluginBase * plugin,
234 gst_vaapi_plugin_base_decide_allocation (GstVaapiPluginBase * plugin,
235 GstQuery * query, guint feature);
239 gst_vaapi_plugin_base_allocate_input_buffer (GstVaapiPluginBase * plugin,
240 GstCaps * caps, GstBuffer ** outbuf_ptr);
244 gst_vaapi_plugin_base_get_input_buffer (GstVaapiPluginBase * plugin,
245 GstBuffer * inbuf, GstBuffer ** outbuf_ptr);
249 gst_vaapi_plugin_base_set_gl_context (GstVaapiPluginBase * plugin,
254 #endif /* GST_VAAPI_PLUGIN_BASE_H */