91800bfb1770f2ea8d5796fcabe479bda8e3020c
[platform/upstream/gstreamer.git] / ext / gl / gstopengl.c
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  *
27  * Cross-platform OpenGL plugin.
28  * <refsect2>
29  * <title>Debugging</title>
30  * </refsect2>
31  * <refsect2>
32  * <title>Examples</title>
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  * </refsect2>
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 "gstglfilterbin.h"
51 #include "gstglsinkbin.h"
52 #include "gstglsrcbin.h"
53 #include "gstglmixerbin.h"
54
55 #include "gstglfiltercube.h"
56 #include "gstgleffects.h"
57 #include "gstglcolorscale.h"
58 #include "gstglvideomixer.h"
59 #include "gstglfiltershader.h"
60 #include "gstglfilterapp.h"
61 #if HAVE_GRAPHENE
62 #include "gstgltransformation.h"
63 #endif
64 #if HAVE_JPEG
65 #if HAVE_PNG
66 #include "gstgloverlay.h"
67 #endif /* HAVE_PNG */
68 #endif /* HAVE_JPEG */
69
70 #if GST_GL_HAVE_OPENGL
71 #include "gstgltestsrc.h"
72 #include "gstglfilterglass.h"
73 /* #include "gstglfilterreflectedscreen.h" */
74 #include "gstgldeinterlace.h"
75 #include "gstglmosaic.h"
76 #if HAVE_PNG
77 #include "gstgldifferencematte.h"
78 /* #include "gstglbumper.h" */
79 #endif /* HAVE_PNG */
80 #endif /* GST_GL_HAVE_OPENGL */
81
82 #if GST_GL_HAVE_WINDOW_COCOA
83 /* avoid including Cocoa/CoreFoundation from a C file... */
84 extern GType gst_ca_opengl_layer_sink_bin_get_type (void);
85 #endif
86
87 #ifdef USE_EGL_RPI
88 #include <bcm_host.h>
89 #endif
90
91 #if GST_GL_HAVE_WINDOW_X11
92 #include <X11/Xlib.h>
93 #endif
94
95 #define GST_CAT_DEFAULT gst_gl_gstgl_debug
96 GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
97
98 /* Register filters that make up the gstgl plugin */
99 static gboolean
100 plugin_init (GstPlugin * plugin)
101 {
102   GST_DEBUG_CATEGORY_INIT (gst_gl_gstgl_debug, "gstopengl", 0, "gstopengl");
103
104 #ifdef USE_EGL_RPI
105   GST_DEBUG ("Initialize BCM host");
106   bcm_host_init ();
107 #endif
108
109 #if GST_GL_HAVE_WINDOW_X11
110   if (g_getenv ("GST_GL_XINITTHREADS"))
111     XInitThreads ();
112 #endif
113
114   if (!gst_element_register (plugin, "glimagesink",
115           GST_RANK_SECONDARY, gst_gl_image_sink_bin_get_type ())) {
116     return FALSE;
117   }
118
119   if (!gst_element_register (plugin, "glupload",
120           GST_RANK_SECONDARY, GST_TYPE_GL_UPLOAD_ELEMENT)) {
121     return FALSE;
122   }
123
124   if (!gst_element_register (plugin, "gldownload",
125           GST_RANK_SECONDARY, GST_TYPE_GL_DOWNLOAD_ELEMENT)) {
126     return FALSE;
127   }
128
129   if (!gst_element_register (plugin, "glcolorconvert",
130           GST_RANK_SECONDARY, GST_TYPE_GL_COLOR_CONVERT_ELEMENT)) {
131     return FALSE;
132   }
133
134   if (!gst_element_register (plugin, "glfilterbin",
135           GST_RANK_NONE, GST_TYPE_GL_FILTER_BIN)) {
136     return FALSE;
137   }
138
139   if (!gst_element_register (plugin, "glsinkbin",
140           GST_RANK_NONE, GST_TYPE_GL_SINK_BIN)) {
141     return FALSE;
142   }
143
144   if (!gst_element_register (plugin, "glsrcbin",
145           GST_RANK_NONE, GST_TYPE_GL_SRC_BIN)) {
146     return FALSE;
147   }
148
149   if (!gst_element_register (plugin, "glmixerbin",
150           GST_RANK_NONE, GST_TYPE_GL_MIXER_BIN)) {
151     return FALSE;
152   }
153
154   if (!gst_element_register (plugin, "glfiltercube",
155           GST_RANK_NONE, GST_TYPE_GL_FILTER_CUBE)) {
156     return FALSE;
157   }
158 #if HAVE_GRAPHENE
159   if (!gst_element_register (plugin, "gltransformation",
160           GST_RANK_NONE, GST_TYPE_GL_TRANSFORMATION)) {
161     return FALSE;
162   }
163 #endif
164   if (!gst_element_register (plugin, "gleffects",
165           GST_RANK_NONE, gst_gl_effects_get_type ())) {
166     return FALSE;
167   }
168
169   if (!gst_element_register (plugin, "glcolorscale",
170           GST_RANK_NONE, GST_TYPE_GL_COLORSCALE)) {
171     return FALSE;
172   }
173
174   if (!gst_element_register (plugin, "glvideomixer",
175           GST_RANK_NONE, gst_gl_video_mixer_bin_get_type ())) {
176     return FALSE;
177   }
178
179   if (!gst_element_register (plugin, "glshader",
180           GST_RANK_NONE, gst_gl_filtershader_get_type ())) {
181     return FALSE;
182   }
183
184   if (!gst_element_register (plugin, "glfilterapp",
185           GST_RANK_NONE, GST_TYPE_GL_FILTER_APP)) {
186     return FALSE;
187   }
188 #if HAVE_JPEG
189 #if HAVE_PNG
190   if (!gst_element_register (plugin, "gloverlay",
191           GST_RANK_NONE, gst_gl_overlay_get_type ())) {
192     return FALSE;
193   }
194 #endif /* HAVE_PNG */
195 #endif /* HAVE_JPEG */
196 #if GST_GL_HAVE_OPENGL
197   if (!gst_element_register (plugin, "gltestsrc",
198           GST_RANK_NONE, GST_TYPE_GL_TEST_SRC)) {
199     return FALSE;
200   }
201
202   if (!gst_element_register (plugin, "glfilterglass",
203           GST_RANK_NONE, GST_TYPE_GL_FILTER_GLASS)) {
204     return FALSE;
205   }
206 #if 0
207   if (!gst_element_register (plugin, "glfilterreflectedscreen",
208           GST_RANK_NONE, GST_TYPE_GL_FILTER_REFLECTED_SCREEN)) {
209     return FALSE;
210   }
211 #endif
212   if (!gst_element_register (plugin, "gldeinterlace",
213           GST_RANK_NONE, GST_TYPE_GL_DEINTERLACE)) {
214     return FALSE;
215   }
216
217   if (!gst_element_register (plugin, "glmosaic",
218           GST_RANK_NONE, GST_TYPE_GL_MOSAIC)) {
219     return FALSE;
220   }
221 #if HAVE_PNG
222   if (!gst_element_register (plugin, "gldifferencematte",
223           GST_RANK_NONE, gst_gl_differencematte_get_type ())) {
224     return FALSE;
225   }
226 #if 0
227   if (!gst_element_register (plugin, "glbumper",
228           GST_RANK_NONE, gst_gl_bumper_get_type ())) {
229     return FALSE;
230   }
231 #endif
232 #endif /* HAVE_PNG */
233 #endif /* GST_GL_HAVE_OPENGL */
234 #if GST_GL_HAVE_WINDOW_COCOA
235   if (!gst_element_register (plugin, "caopengllayersink",
236           GST_RANK_NONE, gst_ca_opengl_layer_sink_bin_get_type ())) {
237     return FALSE;
238   }
239 #endif
240
241   return TRUE;
242 }
243
244 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
245     GST_VERSION_MINOR,
246     opengl,
247     "OpenGL plugin",
248     plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)