1 /*
2 * GStreamer
3 * Copyright (C) 2003 Julien Moutte <julien@moutte.net>
4 * Copyright (C) 2005,2006,2007 David A. Schleef <ds@schleef.org>
5 * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
6 * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 */
23
24 /**
25 * SECTION:plugin-opengl
26 * @title: GstOpengl
27 *
28 * Cross-platform OpenGL plugin.
29 *
30 * ## Debugging
31 *
32 * ## Examples
33 * |[
34 * gst-launch-1.0 --gst-debug=gldisplay:3 videotestsrc ! glimagesink
35 * ]| A debugging pipeline.
36 |[
37 * GST_DEBUG=gl*:6 gst-launch-1.0 videotestsrc ! glimagesink
38 * ]| A debugging pipelines related to shaders.
39 *
40 */
41
42 #ifdef HAVE_CONFIG_H
43 #include "config.h"
44 #endif
45
46 #include "gstglimagesink.h"
47 #include "gstgluploadelement.h"
48 #include "gstgldownloadelement.h"
49 #include "gstglcolorconvertelement.h"
50 #include "gstglcolorbalance.h"
51 #include "gstglfilterbin.h"
52 #include "gstglsinkbin.h"
53 #include "gstglsrcbin.h"
54
55 #include "gstglfiltercube.h"
56 #include "gstgleffects.h"
57 #include "gstglcolorscale.h"
58
59 #include "gstglmixerbin.h"
60 #include "gstglvideomixer.h"
61 #include "gstglstereomix.h"
62
63 #include "gstglfiltershader.h"
64 #include "gstglfilterapp.h"
65 #include "gstglstereosplit.h"
66 #include "gstglviewconvert.h"
67 #include "gstgltestsrc.h"
68 #include "gstgldeinterlace.h"
69 #include "gstglalpha.h"
70 #include "gstgloverlaycompositorelement.h"
71
72 #ifdef HAVE_GRAPHENE
73 #include "gstgltransformation.h"
74 #include "gstglvideoflip.h"
75 #endif
76 #if defined(HAVE_JPEG) && defined(HAVE_PNG)
77 #include "gstgloverlay.h"
78 #endif
79
80 #include "gstglmixerbin.h"
81 #include "gstglvideomixer.h"
82 #include "gstglstereomix.h"
83
84 #if GST_GL_HAVE_OPENGL
85 #endif /* GST_GL_HAVE_OPENGL */
86
87 #if GST_GL_HAVE_OPENGL
88 #include "gstglfilterglass.h"
89 /* #include "gstglfilterreflectedscreen.h" */
90 #include "gstglmosaic.h"
91 #ifdef HAVE_PNG
92 #include "gstgldifferencematte.h"
93 /* #include "gstglbumper.h" */
94 #endif /* HAVE_PNG */
95 #endif /* GST_GL_HAVE_OPENGL */
96
97 #if GST_GL_HAVE_WINDOW_COCOA
98 /* avoid including Cocoa/CoreFoundation from a C file... */
99 extern GType gst_ca_opengl_layer_sink_bin_get_type (void);
100 #endif
101
102 #if GST_GL_HAVE_WINDOW_DISPMANX
103 extern void bcm_host_init (void);
104 #endif
105
106 #if GST_GL_HAVE_WINDOW_X11
107 #include <X11/Xlib.h>
108 #endif
109
110 #define GST_CAT_DEFAULT gst_gl_gstgl_debug
111 GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
112
113 /* Register filters that make up the gstgl plugin */
114 static gboolean
plugin_init(GstPlugin * plugin)115 plugin_init (GstPlugin * plugin)
116 {
117 GST_DEBUG_CATEGORY_INIT (gst_gl_gstgl_debug, "gstopengl", 0, "gstopengl");
118
119 #if GST_GL_HAVE_WINDOW_DISPMANX
120 GST_DEBUG ("Initialize BCM host");
121 bcm_host_init ();
122 #endif
123
124 #if GST_GL_HAVE_WINDOW_X11
125 if (g_getenv ("GST_GL_XINITTHREADS"))
126 XInitThreads ();
127 #endif
128
129 if (!gst_element_register (plugin, "glimagesink",
130 GST_RANK_SECONDARY, gst_gl_image_sink_bin_get_type ())) {
131 return FALSE;
132 }
133
134 if (!gst_element_register (plugin, "glimagesinkelement",
135 GST_RANK_NONE, gst_glimage_sink_get_type ())) {
136 return FALSE;
137 }
138
139 if (!gst_element_register (plugin, "glupload",
140 GST_RANK_NONE, GST_TYPE_GL_UPLOAD_ELEMENT)) {
141 return FALSE;
142 }
143
144 if (!gst_element_register (plugin, "gldownload",
145 GST_RANK_NONE, GST_TYPE_GL_DOWNLOAD_ELEMENT)) {
146 return FALSE;
147 }
148
149 if (!gst_element_register (plugin, "glcolorconvert",
150 GST_RANK_NONE, GST_TYPE_GL_COLOR_CONVERT_ELEMENT)) {
151 return FALSE;
152 }
153
154 if (!gst_element_register (plugin, "glcolorbalance",
155 GST_RANK_NONE, GST_TYPE_GL_COLOR_BALANCE)) {
156 return FALSE;
157 }
158
159 if (!gst_element_register (plugin, "glfilterbin",
160 GST_RANK_NONE, GST_TYPE_GL_FILTER_BIN)) {
161 return FALSE;
162 }
163
164 if (!gst_element_register (plugin, "glsinkbin",
165 GST_RANK_NONE, GST_TYPE_GL_SINK_BIN)) {
166 return FALSE;
167 }
168
169 if (!gst_element_register (plugin, "glsrcbin",
170 GST_RANK_NONE, GST_TYPE_GL_SRC_BIN)) {
171 return FALSE;
172 }
173
174 if (!gst_element_register (plugin, "glmixerbin",
175 GST_RANK_NONE, GST_TYPE_GL_MIXER_BIN)) {
176 return FALSE;
177 }
178
179 if (!gst_element_register (plugin, "glfiltercube",
180 GST_RANK_NONE, GST_TYPE_GL_FILTER_CUBE)) {
181 return FALSE;
182 }
183 #ifdef HAVE_GRAPHENE
184 if (!gst_element_register (plugin, "gltransformation",
185 GST_RANK_NONE, GST_TYPE_GL_TRANSFORMATION)) {
186 return FALSE;
187 }
188
189 if (!gst_element_register (plugin, "glvideoflip",
190 GST_RANK_NONE, GST_TYPE_GL_VIDEO_FLIP)) {
191 return FALSE;
192 }
193 #endif
194
195 if (!gst_gl_effects_register_filters (plugin, GST_RANK_NONE)) {
196 return FALSE;
197 };
198
199 if (!gst_element_register (plugin, "glcolorscale",
200 GST_RANK_NONE, GST_TYPE_GL_COLORSCALE)) {
201 return FALSE;
202 }
203
204 if (!gst_element_register (plugin, "glvideomixer",
205 GST_RANK_NONE, gst_gl_video_mixer_bin_get_type ())) {
206 return FALSE;
207 }
208
209 if (!gst_element_register (plugin, "glvideomixerelement",
210 GST_RANK_NONE, gst_gl_video_mixer_get_type ())) {
211 return FALSE;
212 }
213
214 if (!gst_element_register (plugin, "glshader",
215 GST_RANK_NONE, gst_gl_filtershader_get_type ())) {
216 return FALSE;
217 }
218
219 if (!gst_element_register (plugin, "glfilterapp",
220 GST_RANK_NONE, GST_TYPE_GL_FILTER_APP)) {
221 return FALSE;
222 }
223
224 if (!gst_element_register (plugin, "glviewconvert",
225 GST_RANK_NONE, GST_TYPE_GL_VIEW_CONVERT_ELEMENT)) {
226 return FALSE;
227 }
228
229 if (!gst_element_register (plugin, "glstereosplit",
230 GST_RANK_NONE, GST_TYPE_GL_STEREOSPLIT)) {
231 return FALSE;
232 }
233
234 if (!gst_element_register (plugin, "glstereomix",
235 GST_RANK_NONE, GST_TYPE_GL_STEREO_MIX)) {
236 return FALSE;
237 }
238
239 if (!gst_element_register (plugin, "gltestsrc",
240 GST_RANK_NONE, GST_TYPE_GL_TEST_SRC)) {
241 return FALSE;
242 }
243
244 if (!gst_element_register (plugin, "gldeinterlace",
245 GST_RANK_NONE, GST_TYPE_GL_DEINTERLACE)) {
246 return FALSE;
247 }
248
249 if (!gst_element_register (plugin, "glalpha",
250 GST_RANK_NONE, GST_TYPE_GL_ALPHA)) {
251 return FALSE;
252 }
253
254 if (!gst_element_register (plugin, "gloverlaycompositor",
255 GST_RANK_NONE, GST_TYPE_GL_OVERLAY_COMPOSITOR_ELEMENT)) {
256 return FALSE;
257 }
258 #if defined(HAVE_JPEG) && defined(HAVE_PNG)
259 if (!gst_element_register (plugin, "gloverlay",
260 GST_RANK_NONE, gst_gl_overlay_get_type ())) {
261 return FALSE;
262 }
263 #endif
264 #if GST_GL_HAVE_OPENGL
265 if (!gst_element_register (plugin, "glfilterglass",
266 GST_RANK_NONE, GST_TYPE_GL_FILTER_GLASS)) {
267 return FALSE;
268 }
269 #if 0
270 if (!gst_element_register (plugin, "glfilterreflectedscreen",
271 GST_RANK_NONE, GST_TYPE_GL_FILTER_REFLECTED_SCREEN)) {
272 return FALSE;
273 }
274 #endif
275
276 if (!gst_element_register (plugin, "glmosaic",
277 GST_RANK_NONE, GST_TYPE_GL_MOSAIC)) {
278 return FALSE;
279 }
280 #ifdef HAVE_PNG
281 if (!gst_element_register (plugin, "gldifferencematte",
282 GST_RANK_NONE, gst_gl_differencematte_get_type ())) {
283 return FALSE;
284 }
285 #if 0
286 if (!gst_element_register (plugin, "glbumper",
287 GST_RANK_NONE, gst_gl_bumper_get_type ())) {
288 return FALSE;
289 }
290 #endif
291 #endif /* HAVE_PNG */
292 #endif /* GST_GL_HAVE_OPENGL */
293 #if GST_GL_HAVE_WINDOW_COCOA
294 if (!gst_element_register (plugin, "caopengllayersink",
295 GST_RANK_NONE, gst_ca_opengl_layer_sink_bin_get_type ())) {
296 return FALSE;
297 }
298 #endif
299
300 return TRUE;
301 }
302
303 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
304 GST_VERSION_MINOR,
305 opengl,
306 "OpenGL plugin",
307 plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
308