summaryrefslogtreecommitdiffstats
path: root/recipes-multimedia/gstreamer/gst-plugins-gl/IMX_MMCODEC_3.0.35_4.0.0.patch
diff options
context:
space:
mode:
authorTudor Florea <tudor.florea@enea.com>2014-10-10 03:19:58 +0200
committerTudor Florea <tudor.florea@enea.com>2014-10-10 03:19:58 +0200
commitf98b448ee835646be48f530b3e6fe13b32b093f5 (patch)
tree9d1062f1e8893e72829df650f5e558c5fb255955 /recipes-multimedia/gstreamer/gst-plugins-gl/IMX_MMCODEC_3.0.35_4.0.0.patch
downloadmeta-fsl-arm-f98b448ee835646be48f530b3e6fe13b32b093f5.tar.gz
initial commit for Enea Linux 4.0-140929daisy-140929
Migrated from the internal git server on the daisy-enea-point-release branch Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'recipes-multimedia/gstreamer/gst-plugins-gl/IMX_MMCODEC_3.0.35_4.0.0.patch')
-rw-r--r--recipes-multimedia/gstreamer/gst-plugins-gl/IMX_MMCODEC_3.0.35_4.0.0.patch2438
1 files changed, 2438 insertions, 0 deletions
diff --git a/recipes-multimedia/gstreamer/gst-plugins-gl/IMX_MMCODEC_3.0.35_4.0.0.patch b/recipes-multimedia/gstreamer/gst-plugins-gl/IMX_MMCODEC_3.0.35_4.0.0.patch
new file mode 100644
index 0000000..d4f5576
--- /dev/null
+++ b/recipes-multimedia/gstreamer/gst-plugins-gl/IMX_MMCODEC_3.0.35_4.0.0.patch
@@ -0,0 +1,2438 @@
1diff --git a/configure.ac b/configure.ac
2index 6a4efe0..fa277fa 100644
3--- a/configure.ac
4+++ b/configure.ac
5@@ -5,7 +5,7 @@ dnl please read gstreamer/docs/random/autotools before changing this file
6 dnl initialize autoconf
7 dnl releases only do -Wall, git and prerelease does -Werror too
8 dnl use a three digit version number for releases, and four for git/prerelease
9-AC_INIT(GStreamer OpenGL Plug-ins, 0.10.3,
10+AC_INIT(GStreamer OpenGL Plug-ins, 0.10.3.1,
11 http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer,
12 gst-plugins-gl)
13
14@@ -61,7 +61,7 @@ dnl AS_LIBTOOL_TAGS
15
16 AC_LIBTOOL_WIN32_DLL
17 AM_PROG_LIBTOOL
18-AS_PROG_OBJC
19+AC_PROG_OBJC
20
21 dnl *** required versions of GStreamer stuff ***
22 GST_REQ=0.10.35
23@@ -83,6 +83,8 @@ AG_GST_GETTEXT([gst-plugins-gl-$GST_MAJORMINOR])
24
25 dnl *** check for arguments to configure ***
26
27+AG_GST_ARG_DISABLE_FATAL_WARNINGS
28+
29 AG_GST_ARG_DEBUG
30 AG_GST_ARG_PROFILING
31 AG_GST_ARG_VALGRIND
32@@ -160,36 +162,48 @@ AG_GST_CHECK_FUNCTION
33 dnl *** checks for dependency libraries ***
34
35 dnl GLib is required
36-AG_GST_GLIB_CHECK([2.6])
37+AG_GST_GLIB_CHECK([2.22])
38
39 #dnl Check for OpenGL, GLU and GLEW
40 echo host is $host
41 case $host in
42 *-linux* | *-cygwin* | *-solaris* | *-netbsd* | *-freebsd* | *-openbsd* | *-kfreebsd* | *-dragonflybsd* | *-gnu* )
43- AG_GST_CHECK_X
44 save_CPPFLAGS="$CPPFLAGS"
45 save_LIBS="$LIBS"
46- CPPFLAGS="$CPPFLAGS $X_CFLAGS"
47- LIBS="$LIBS $X_LIBS"
48- #PKG_CHECK_MODULES(GL, gl, HAVE_GL=yes, HAVE_GL=no)
49- AC_CHECK_HEADERS([GL/gl.h], [HAVE_GL=yes], [HAVE_GL=no])
50- if test "x$HAVE_GL" = "xyes"; then
51- AG_GST_CHECK_LIBHEADER(GL, GL, glTexImage2D,, GL/gl.h,, AC_MSG_ERROR([OpenGL is required]))
52- AG_GST_CHECK_LIBHEADER(GLU, GLU, gluSphere,, GL/glu.h,, AC_MSG_ERROR([GLU is required]))
53- AG_GST_CHECK_LIBHEADER(GLEW, GLEW, glewInit,, GL/glew.h,, AC_MSG_ERROR([GLEW is required]))
54- GL_LIBS="$LIBS $X_LIBS -lGL -lGLU -lGLEW"
55- GL_BACKEND=x11
56- GL_TYPE=gl
57+ AC_CHECK_LIB(EGL, fbGetDisplay, HAVE_EGL_FB=yes, HAVE_EGL_FB=no)
58+ if test "x$HAVE_EGL_FB" = "xyes"; then
59+ GL_LIBS="$LIBS -lGLESv2 -lEGL"
60+ GL_BACKEND=fbES2
61+ GL_TYPE=gles
62+ save_CPPFLAGS="$save_CPPFLAGS -DLINUX -DEGL_API_FB"
63 else
64+ AG_GST_CHECK_X
65+ CPPFLAGS="$CPPFLAGS $X_CFLAGS -DLINUX"
66+ LIBS="$LIBS $X_LIBS"
67 AC_CHECK_HEADERS([EGL/egl.h], [HAVE_EGL=yes], [HAVE_EGL=no])
68 if test "x$HAVE_EGL" = "xyes"; then
69 AG_GST_CHECK_LIBHEADER(EGL, EGL, eglGetError,, EGL/egl.h,, AC_MSG_ERROR([EGL is required]))
70+ s_LIBS="$LIBS"
71+ LIBS="-lEGL $LIBS"
72 AG_GST_CHECK_LIBHEADER(GLES2, GLESv2, glTexImage2D,, GLES2/gl2.h,, AC_MSG_ERROR([OpenGLES2 is required]))
73- GL_LIBS="$LIBS $X_LIBS -lEGL -lGLESv2"
74+ LIBS="$s_LIBS"
75+ GL_LIBS="$LIBS -lGLESv2 -lEGL"
76 GL_BACKEND=x11ES2
77 GL_TYPE=gles
78+ save_CPPFLAGS="$save_CPPFLAGS -DLINUX"
79 else
80- AC_MSG_ERROR([GL or EGL is required, consider installing libgl1-mesa-dev])
81+ #PKG_CHECK_MODULES(GL, gl, HAVE_GL=yes, HAVE_GL=no)
82+ AC_CHECK_HEADERS([GL/gl.h], [HAVE_GL=yes], [HAVE_GL=no])
83+ if test "x$HAVE_GL" = "xyes"; then
84+ AG_GST_CHECK_LIBHEADER(GL, GL, glTexImage2D,, GL/gl.h,, AC_MSG_ERROR([OpenGL is required]))
85+ AG_GST_CHECK_LIBHEADER(GLU, GLU, gluSphere,, GL/glu.h,, AC_MSG_ERROR([GLU is required]))
86+ AG_GST_CHECK_LIBHEADER(GLEW, GLEW, glewInit,, GL/glew.h,, AC_MSG_ERROR([GLEW is required]))
87+ GL_LIBS="$LIBS $X_LIBS -lGL -lGLU -lGLEW"
88+ GL_BACKEND=x11
89+ GL_TYPE=gl
90+ else
91+ AC_MSG_ERROR([GL or EGL is required, consider installing libgl1-mesa-dev])
92+ fi
93 fi
94 fi
95 CPPFLAGS="$save_CPPFLAGS"
96@@ -230,6 +244,7 @@ AC_SUBST(GL_BACKEND)
97 AC_SUBST(OPENGL_ES2)
98 AM_CONDITIONAL(GL_BACKEND_X11, test "x$GL_BACKEND" = "xx11")
99 AM_CONDITIONAL(GL_BACKEND_X11ES2, test "x$GL_BACKEND" = "xx11ES2")
100+AM_CONDITIONAL(GL_BACKEND_FBES2, test "x$GL_BACKEND" = "xfbES2")
101 AM_CONDITIONAL(GL_BACKEND_COCOA, test "x$GL_BACKEND" = "xcocoa")
102 AM_CONDITIONAL(GL_BACKEND_WIN32, test "x$GL_BACKEND" = "xwin32")
103 AM_CONDITIONAL(GL_IS_OPENGL, test "x$GL_TYPE" = "xgl")
104@@ -251,6 +266,18 @@ AC_SUBST(GLIB_PREFIX)
105 AC_SUBST(GST_PREFIX)
106 AC_SUBST(GSTPB_PREFIX)
107
108+GST_FSL_CFLAGS="`$PKG_CONFIG --cflags gstreamer-fsl-$GST_MAJORMINOR`"
109+GST_FSL_LIBS="`$PKG_CONFIG --libs gstreamer-fsl-$GST_MAJORMINOR`"
110+AC_CHECK_HEADERS([EGL/eglvivante.h], HAVE_VIVANTE=[yes], HAVE_VIVANTE=[no])
111+if test "x$HAVE_VIVANTE" = "xyes"; then
112+ if test "x$GST_FSL_CFLAGS" = "x"; then
113+ AC_MSG_ERROR([gstreamer-fsl is required])
114+ fi
115+ AC_DEFINE(GPU_VIVANTE, [1], [Use Vivante GPU])
116+fi
117+AM_CONDITIONAL(USE_VIVANTE, test "x$HAVE_VIVANTE" = "xyes")
118+AC_SUBST(GST_FSL_CFLAGS)
119+AC_SUBST(GST_FSL_LIBS)
120
121 dnl libpng is optional
122 PKG_CHECK_MODULES(LIBPNG, libpng >= 1.0, HAVE_PNG=yes, HAVE_PNG=no)
123@@ -269,12 +296,15 @@ if test x$with_jpeg_mmx != x; then
124 LIBS="$LIBS -L$with_jpeg_mmx"
125 fi
126 AC_CHECK_LIB(jpeg-mmx, jpeg_set_defaults, HAVE_JPEG="yes", HAVE_JPEG="no")
127-JPEG_LIBS="$LIBS -ljpeg-mmx"
128-LIBS="$OLD_LIBS"
129 if test x$HAVE_JPEG != xyes; then
130 AC_CHECK_LIB(jpeg, jpeg_set_defaults, HAVE_JPEG="yes", HAVE_JPEG="no")
131- JPEG_LIBS="-ljpeg"
132- AC_DEFINE(HAVE_JPEG, [1] , [Use libjpeg])
133+ if test x$HAVE_JPEG = xyes; then
134+ JPEG_LIBS="-ljpeg"
135+ AC_DEFINE(HAVE_JPEG, [1] , [Use libjpeg])
136+ fi
137+else
138+ JPEG_LIBS="$LIBS -ljpeg-mmx"
139+ LIBS="$OLD_LIBS"
140 fi
141 AC_SUBST(HAVE_JPEG)
142 AC_SUBST(JPEG_LIBS)
143@@ -383,8 +413,14 @@ AG_GST_SET_PACKAGE_RELEASE_DATETIME_WITH_NANO([$PACKAGE_VERSION_NANO],
144 [$PACKAGE_VERSION_MAJOR.$PACKAGE_VERSION_MINOR.$PACKAGE_VERSION_MICRO])
145
146 dnl define an ERROR_CFLAGS Makefile variable
147-AG_GST_SET_ERROR_CFLAGS($GST_GIT)
148-AG_GST_SET_ERROR_CXXFLAGS($GST_GIT)
149+AG_GST_SET_ERROR_CFLAGS($FATAL_WARNINGS)
150+AG_GST_SET_ERROR_CXXFLAGS($FATAL_WARNINGS)
151+dnl define an ERROR_OBJCFLAGS Makefile variable
152+AG_GST_SET_ERROR_OBJCFLAGS($FATAL_WARNINGS, [
153+ -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls
154+ -Wwrite-strings -Wold-style-definition
155+ -Winit-self -Wmissing-include-dirs -Wno-multichar
156+ -Wnested-externs $NO_WARNINGS])
157
158 dnl define correct level for debugging messages
159 AG_GST_SET_LEVEL_DEFAULT($GST_GIT)
160@@ -460,8 +496,10 @@ AC_SUBST(DEPRECATED_CFLAGS)
161 dnl every flag in GST_OPTION_CFLAGS can be overridden at make time
162 GST_OPTION_CFLAGS="\$(WARNING_CFLAGS) \$(ERROR_CFLAGS) \$(DEBUG_CFLAGS) \$(PROFILE_CFLAGS) \$(GCOV_CFLAGS) \$(OPT_CFLAGS) \$(DEPRECATED_CFLAGS)"
163 GST_OPTION_CXXFLAGS="\$(WARNING_CXXFLAGS) \$(ERROR_CXXFLAGS) \$(DEBUG_CFLAGS) \$(PROFILE_CFLAGS) \$(GCOV_CFLAGS) \$(OPT_CFLAGS) \$(DEPRECATED_CFLAGS)"
164+GST_OPTION_OBJCFLAGS="\$(WARNING_OBJCFLAGS) \$(ERROR_OBJCFLAGS) \$(DEBUG_CFLAGS) \$(PROFILE_CFLAGS) \$(GCOV_CFLAGS) \$(OPT_CFLAGS) \$(DEPRECATED_CFLAGS)"
165 AC_SUBST(GST_OPTION_CFLAGS)
166 AC_SUBST(GST_OPTION_CXXFLAGS)
167+AC_SUBST(GST_OPTION_OBJCFLAGS)
168
169 dnl our libraries need to be versioned correctly
170 AC_SUBST(GST_LT_LDFLAGS)
171@@ -474,10 +512,12 @@ AC_SUBST(GST_PLUGINS_GL_CFLAGS)
172
173 dnl FIXME: do we want to rename to GST_ALL_* ?
174 dnl add GST_OPTION_CFLAGS, but overridable
175+GST_OBJCFLAGS="-I\$(top_srcdir)/gst-libs $GST_CFLAGS $GLIB_EXTRA_CFLAGS \$(GST_OPTION_OBJCFLAGS)"
176 GST_CXXFLAGS="-I\$(top_srcdir)/gst-libs -I\$(top_builddir)/gst-libs $GST_CFLAGS $GST_CXXFLAGS $GLIB_EXTRA_CFLAGS \$(GST_OPTION_CXXFLAGS)"
177 GST_CFLAGS="-I\$(top_srcdir)/gst-libs -I\$(top_builddir)/gst-libs $GST_CFLAGS $GLIB_EXTRA_CFLAGS \$(GST_OPTION_CFLAGS)"
178 AC_SUBST(GST_CFLAGS)
179 AC_SUBST(GST_CXXFLAGS)
180+AC_SUBST(GST_OBJCFLAGS)
181
182 dnl add GCOV libs because libtool strips -fprofile-arcs -ftest-coverage
183 GST_LIBS="$GST_LIBS \$(GCOV_LIBS)"
184diff --git a/docs/libs/Makefile.am b/docs/libs/Makefile.am
185index defa340..18016cf 100644
186--- a/docs/libs/Makefile.am
187+++ b/docs/libs/Makefile.am
188@@ -50,7 +50,7 @@ extra_files =
189 # CFLAGS and LDFLAGS for compiling scan program. Only needed if your app/lib
190 # contains GtkObjects/GObjects and you want to document signals and properties.
191 GTKDOC_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) \
192- -I$(top_srcdir)/gst-libs/gst/gl
193+ -I$(top_srcdir)/gst-libs/gst/gl -I$(top_srcdir) -DHAVE_CONFIG_H -DLINUX
194 GTKDOC_LIBS = \
195 $(top_builddir)/gst-libs/gst/gl/libgstgl-@GST_MAJORMINOR@.la \
196 $(GST_BASE_LIBS)
197diff --git a/docs/plugins/inspect/plugin-libvisual-gl.xml b/docs/plugins/inspect/plugin-libvisual-gl.xml
198index da5a3d5..477c811 100644
199--- a/docs/plugins/inspect/plugin-libvisual-gl.xml
200+++ b/docs/plugins/inspect/plugin-libvisual-gl.xml
201@@ -3,10 +3,10 @@
202 <description>libvisual-gl visualization plugins</description>
203 <filename>../../ext/libvisual/.libs/libgstlibvisualgl.so</filename>
204 <basename>libgstlibvisualgl.so</basename>
205- <version>0.10.3</version>
206+ <version>0.10.3.1</version>
207 <license>LGPL</license>
208 <source>gst-plugins-gl</source>
209- <package>GStreamer OpenGL Plug-ins source release</package>
210+ <package>GStreamer OpenGL Plug-ins git</package>
211 <origin>Unknown package origin</origin>
212 <elements>
213 <element>
214diff --git a/docs/plugins/inspect/plugin-opengl.xml b/docs/plugins/inspect/plugin-opengl.xml
215index dbfa9fb..9b7b663 100644
216--- a/docs/plugins/inspect/plugin-opengl.xml
217+++ b/docs/plugins/inspect/plugin-opengl.xml
218@@ -3,10 +3,10 @@
219 <description>OpenGL plugin</description>
220 <filename>../../gst/gl/.libs/libgstopengl.so</filename>
221 <basename>libgstopengl.so</basename>
222- <version>0.10.3</version>
223+ <version>0.10.3.1</version>
224 <license>LGPL</license>
225 <source>gst-plugins-gl</source>
226- <package>GStreamer OpenGL Plug-ins source release</package>
227+ <package>GStreamer OpenGL Plug-ins git</package>
228 <origin>Unknown package origin</origin>
229 <elements>
230 <element>
231diff --git a/gst-libs/gst/gl/Makefile.am b/gst-libs/gst/gl/Makefile.am
232index 2ef7afc..d55a513 100644
233--- a/gst-libs/gst/gl/Makefile.am
234+++ b/gst-libs/gst/gl/Makefile.am
235@@ -4,6 +4,7 @@ lib_LTLIBRARIES = libgstgl-@GST_MAJORMINOR@.la
236 EXTRA_DIST = \
237 gstglwindow_x11.c \
238 gstglwindow_x11ES2.c \
239+ gstglwindow_fbES2.c \
240 gstglwindow_win32.c \
241 gstglwindow_winCE.c \
242 gstglwindow_cocoa.m
243@@ -28,6 +29,13 @@ endif
244 if GL_BACKEND_X11ES2
245 libgstgl_@GST_MAJORMINOR@_la_SOURCES += gstglwindow_x11ES2.c
246 endif
247+if GL_BACKEND_FBES2
248+libgstgl_@GST_MAJORMINOR@_la_SOURCES += gstglwindow_fbES2.c
249+endif
250+
251+if USE_VIVANTE
252+libgstgl_@GST_MAJORMINOR@_la_SOURCES += gstglvivante.c
253+endif
254
255 libgstgl_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/gl
256 libgstgl_@GST_MAJORMINOR@include_HEADERS = \
257@@ -41,13 +49,19 @@ libgstgl_@GST_MAJORMINOR@include_HEADERS = \
258 gstglshadervariables.h \
259 gstglshader.h
260
261+if USE_VIVANTE
262+libgstgl_@GST_MAJORMINOR@include_HEADERS += gstglvivante.h
263+endif
264+
265 libgstgl_@GST_MAJORMINOR@_la_LIBADD = \
266 $(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_MAJORMINOR) -lgstcontroller-$(GST_MAJORMINOR) \
267+ $(GST_FSL_LIBS) \
268 $(GST_BASE_LIBS) $(GST_LIBS) \
269 $(GL_LIBS)
270
271 libgstgl_@GST_MAJORMINOR@_la_CFLAGS = \
272 $(GL_CFLAGS) $(X_CFLAGS) \
273+ $(GST_FSL_CFLAGS) \
274 $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
275 libgstgl_@GST_MAJORMINOR@_la_OBJCFLAGS = \
276 $(GL_CFLAGS) $(X_CFLAGS) \
277diff --git a/gst-libs/gst/gl/gstgldisplay.c b/gst-libs/gst/gl/gstgldisplay.c
278index 64c6c2c..da2e602 100644
279--- a/gst-libs/gst/gl/gstgldisplay.c
280+++ b/gst-libs/gst/gl/gstgldisplay.c
281@@ -28,6 +28,9 @@
282
283 #include <gst/video/gstvideosink.h>
284 #include "gstgldisplay.h"
285+#ifdef GPU_VIVANTE
286+#include "gstglvivante.h"
287+#endif
288
289 #ifndef GLEW_VERSION_MAJOR
290 #define GLEW_VERSION_MAJOR 4
291@@ -468,6 +471,10 @@ gst_gl_display_init (GstGLDisplay * display, GstGLDisplayClass * klass)
292 #endif
293
294 display->error_message = NULL;
295+
296+#ifdef GPU_VIVANTE
297+ display->gpu_priv = gst_gl_vivante_new ();
298+#endif
299 }
300
301 static void
302@@ -539,6 +546,12 @@ gst_gl_display_finalize (GObject * object)
303 g_free (display->error_message);
304 display->error_message = NULL;
305 }
306+#ifdef GPU_VIVANTE
307+ if (display->gpu_priv) {
308+ gst_gl_vivante_delete (display->gpu_priv);
309+ display->gpu_priv = NULL;
310+ }
311+#endif
312 }
313
314
315@@ -1135,6 +1148,17 @@ gst_gl_display_thread_init_upload (GstGLDisplay * display)
316 void
317 gst_gl_display_thread_do_upload (GstGLDisplay * display)
318 {
319+ if (display->gpu_priv &&
320+ display->upload_width == display->upload_data_width &&
321+ display->upload_height == display->upload_data_height) {
322+#ifdef GPU_VIVANTE
323+ if (gst_gl_vivante_tex_upload (display->gpu_priv, display))
324+ return;
325+#endif
326+ }
327+
328+ GST_WARNING ("%s: Fall into non direct uploading", __func__);
329+
330 gst_gl_display_thread_do_upload_fill (display);
331
332 switch (display->upload_video_format) {
333@@ -1950,14 +1974,13 @@ gst_gl_display_on_draw (GstGLDisplay * display)
334
335 glBegin (GL_QUADS);
336 /* gst images are top-down while opengl plane is bottom-up */
337- glTexCoord2i (display->redisplay_texture_width, 0);
338+ glTexCoord2i (1, 0);
339 glVertex2f (1.0f, 1.0f);
340 glTexCoord2i (0, 0);
341 glVertex2f (-1.0f, 1.0f);
342- glTexCoord2i (0, display->redisplay_texture_height);
343+ glTexCoord2i (0, 1);
344 glVertex2f (-1.0f, -1.0f);
345- glTexCoord2i (display->redisplay_texture_width,
346- display->redisplay_texture_height);
347+ glTexCoord2i (1, 1);
348 glVertex2f (1.0f, -1.0f);
349 /*glTexCoord2i (display->redisplay_texture_width, 0);
350 glVertex2i (1, -1);
351@@ -1974,7 +1997,8 @@ gst_gl_display_on_draw (GstGLDisplay * display)
352
353 #else //OPENGL_ES2
354
355- const GLfloat vVertices[] = { 1.0f, 1.0f, 0.0f,
356+ GLfloat left, right, top, bottom;
357+ GLfloat vVertices[] = { 1.0f, 1.0f, 0.0f,
358 1.0f, 0.0f,
359 -1.0f, 1.0f, 0.0f,
360 0.0f, 0.0f,
361@@ -1986,6 +2010,17 @@ gst_gl_display_on_draw (GstGLDisplay * display)
362
363 GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
364
365+#ifdef GPU_VIVANTE
366+ if (display->gpu_priv) {
367+ gst_gl_vivante_get_sampler_rect (display->gpu_priv, &left, &right, &top,
368+ &bottom);
369+ vVertices[3] = vVertices[18] = right;
370+ vVertices[4] = vVertices[9] = bottom;
371+ vVertices[8] = vVertices[13] = left;
372+ vVertices[14] = vVertices[19] = top;
373+ }
374+#endif
375+
376 glClear (GL_COLOR_BUFFER_BIT);
377
378 gst_gl_shader_use (display->redisplay_shader);
379@@ -2067,6 +2102,9 @@ gst_gl_display_glgen_texture (GstGLDisplay * display, GLuint * pTexture,
380 case GST_VIDEO_FORMAT_I420:
381 case GST_VIDEO_FORMAT_YV12:
382 case GST_VIDEO_FORMAT_AYUV:
383+#ifdef GPU_VIVANTE
384+ case GST_VIDEO_FORMAT_NV12:
385+#endif
386 glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
387 width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
388 break;
389@@ -2177,11 +2215,11 @@ gst_gl_display_check_framebuffer_status (void)
390 GST_ERROR ("GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS");
391 break;
392
393-#if defined(GL_ARB_framebuffer_object)
394+/*
395 case GL_FRAMEBUFFER_UNDEFINED:
396 GST_ERROR ("GL_FRAMEBUFFER_UNDEFINED");
397 break;
398-#endif
399+*/
400
401 default:
402 GST_ERROR ("General FBO error");
403@@ -2350,8 +2388,13 @@ gst_gl_display_init_upload (GstGLDisplay * display, GstVideoFormat video_format,
404 display->upload_height = gl_height;
405 display->upload_data_width = video_width;
406 display->upload_data_height = video_height;
407- gst_gl_window_send_message (display->gl_window,
408- GST_GL_WINDOW_CB (gst_gl_display_thread_init_upload), display);
409+
410+#ifdef GPU_VIVANTE
411+ if (!gst_gl_vivante_check_format (display->gpu_priv, video_format,
412+ video_width, video_height))
413+#endif
414+ gst_gl_window_send_message (display->gl_window,
415+ GST_GL_WINDOW_CB (gst_gl_display_thread_init_upload), display);
416 isAlive = display->isAlive;
417 gst_gl_display_unlock (display);
418
419@@ -2364,6 +2407,14 @@ gboolean
420 gst_gl_display_do_upload (GstGLDisplay * display, GLuint texture,
421 gint data_width, gint data_height, gpointer data)
422 {
423+ return gst_gl_display_do_upload_with_meta (display, texture, data_width,
424+ data_height, data, NULL);
425+}
426+
427+gboolean
428+gst_gl_display_do_upload_with_meta (GstGLDisplay * display, GLuint texture,
429+ gint data_width, gint data_height, gpointer data, gpointer meta)
430+{
431 gboolean isAlive = TRUE;
432
433 gst_gl_display_lock (display);
434@@ -2373,6 +2424,7 @@ gst_gl_display_do_upload (GstGLDisplay * display, GLuint texture,
435 display->upload_data_width = data_width;
436 display->upload_data_height = data_height;
437 display->upload_data = data;
438+ display->upload_meta = meta;
439 gst_gl_window_send_message (display->gl_window,
440 GST_GL_WINDOW_CB (gst_gl_display_thread_do_upload), display);
441 isAlive = display->isAlive;
442@@ -2975,11 +3027,11 @@ gst_gl_display_thread_do_upload_draw (GstGLDisplay * display)
443
444 #ifdef OPENGL_ES2
445 GLint viewport_dim[4];
446-
447- const GLfloat vVertices[] = { 1.0f, -1.0f, 0.0f,
448+ GLfloat left, right, top, bottom;
449+ GLfloat vVertices[] = { 1.0f, -1.0f, 0.0f,
450 1.0f, 0.0f,
451 -1.0f, -1.0f, 0.0f,
452- 0.0f, .0f,
453+ 0.0f, 0.0f,
454 -1.0f, 1.0f, 0.0f,
455 0.0f, 1.0f,
456 1.0f, 1.0f, 0.0f,
457@@ -2987,6 +3039,18 @@ gst_gl_display_thread_do_upload_draw (GstGLDisplay * display)
458 };
459
460 GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
461+
462+#ifdef GPU_VIVANTE
463+ if (display->gpu_priv) {
464+ gst_gl_vivante_get_sampler_rect (display->gpu_priv, &left, &right, &top,
465+ &bottom);
466+ vVertices[3] = vVertices[18] = right;
467+ vVertices[4] = vVertices[9] = bottom;
468+ vVertices[8] = vVertices[13] = left;
469+ vVertices[14] = vVertices[19] = top;
470+ }
471+#endif
472+
473 #endif
474
475 glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, display->upload_fbo);
476@@ -3260,13 +3324,13 @@ gst_gl_display_thread_do_upload_draw (GstGLDisplay * display)
477
478 #ifndef OPENGL_ES2
479 glBegin (GL_QUADS);
480- glTexCoord2i (display->upload_data_width, 0);
481+ glTexCoord2i (1, 0);
482 glVertex2f (1.0f, -1.0f);
483 glTexCoord2i (0, 0);
484 glVertex2f (-1.0f, -1.0f);
485- glTexCoord2i (0, display->upload_data_height);
486+ glTexCoord2i (0, 1);
487 glVertex2f (-1.0f, 1.0f);
488- glTexCoord2i (display->upload_data_width, display->upload_data_height);
489+ glTexCoord2i (1, 1);
490 glVertex2f (1.0f, 1.0f);
491 glEnd ();
492
493@@ -3554,11 +3618,11 @@ gst_gl_display_thread_do_download_draw_yuv (GstGLDisplay * display)
494 glBegin (GL_QUADS);
495 glTexCoord2i (0, 0);
496 glVertex2f (-1.0f, -1.0f);
497- glTexCoord2i (width, 0);
498+ glTexCoord2i (1, 0);
499 glVertex2f (1.0f, -1.0f);
500- glTexCoord2i (width, height);
501+ glTexCoord2i (1, 1);
502 glVertex2f (1.0f, 1.0f);
503- glTexCoord2i (0, height);
504+ glTexCoord2i (0, 1);
505 glVertex2f (-1.0f, 1.0f);
506 glEnd ();
507
508diff --git a/gst-libs/gst/gl/gstgldisplay.h b/gst-libs/gst/gl/gstgldisplay.h
509index f657e1e..31dfe26 100644
510--- a/gst-libs/gst/gl/gstgldisplay.h
511+++ b/gst-libs/gst/gl/gstgldisplay.h
512@@ -229,6 +229,9 @@ struct _GstGLDisplay
513
514 gchar *error_message;
515
516+ gpointer gpu_priv;
517+ gpointer upload_meta;
518+ gboolean upload_buf_mapped;
519 };
520
521
522@@ -264,6 +267,8 @@ gboolean gst_gl_display_init_upload (GstGLDisplay * display,
523 gint video_width, gint video_height);
524 gboolean gst_gl_display_do_upload (GstGLDisplay * display, GLuint texture,
525 gint data_width, gint data_height, gpointer data);
526+gboolean gst_gl_display_do_upload_with_meta (GstGLDisplay * display, GLuint texture,
527+ gint data_width, gint data_height, gpointer data, gpointer meta);
528 gboolean gst_gl_display_init_download (GstGLDisplay * display,
529 GstVideoFormat video_format, gint width, gint height);
530 gboolean gst_gl_display_do_download (GstGLDisplay * display, GLuint texture,
531diff --git a/gst-libs/gst/gl/gstglshader.h b/gst-libs/gst/gl/gstglshader.h
532index ddeb99c..aec69f1 100644
533--- a/gst-libs/gst/gl/gstglshader.h
534+++ b/gst-libs/gst/gl/gstglshader.h
535@@ -21,6 +21,10 @@
536 #ifndef __GST_GL_SHADER_H__
537 #define __GST_GL_SHADER_H__
538
539+#ifdef HAVE_CONFIG_H
540+#include "config.h"
541+#endif
542+
543 /* OpenGL 2.0 for Embedded Systems */
544 #ifdef OPENGL_ES2
545 #include <GLES2/gl2.h>
546diff --git a/gst-libs/gst/gl/gstglshadervariables.c b/gst-libs/gst/gl/gstglshadervariables.c
547index 69d5b75..be6e58c 100644
548--- a/gst-libs/gst/gl/gstglshadervariables.c
549+++ b/gst-libs/gst/gl/gstglshadervariables.c
550@@ -550,6 +550,7 @@ gst_gl_shadervariable_set (GstGLShader * shader,
551 (float *) ret->value);
552 break;
553
554+#ifndef OPENGL_ES2
555 case _mat2x3:
556 gst_gl_shader_set_uniform_matrix_2x3fv (shader, ret->name, ret->count, 0,
557 (float *) ret->value);
558@@ -569,6 +570,7 @@ gst_gl_shadervariable_set (GstGLShader * shader,
559 gst_gl_shader_set_uniform_matrix_4x2fv (shader, ret->name, ret->count, 0,
560 (float *) ret->value);
561 break;
562+#endif
563
564 case _mat3:
565 case _mat3x3:
566@@ -576,6 +578,7 @@ gst_gl_shadervariable_set (GstGLShader * shader,
567 (float *) ret->value);
568 break;
569
570+#ifndef OPENGL_ES2
571 case _mat3x4:
572 gst_gl_shader_set_uniform_matrix_3x4fv (shader, ret->name, ret->count, 0,
573 (float *) ret->value);
574@@ -585,6 +588,7 @@ gst_gl_shadervariable_set (GstGLShader * shader,
575 gst_gl_shader_set_uniform_matrix_4x3fv (shader, ret->name, ret->count, 0,
576 (float *) ret->value);
577 break;
578+#endif
579
580 case _mat4:
581 case _mat4x4:
582diff --git a/gst-libs/gst/gl/gstglvivante.c b/gst-libs/gst/gl/gstglvivante.c
583new file mode 100644
584index 0000000..2b8c9ae
585--- /dev/null
586+++ b/gst-libs/gst/gl/gstglvivante.c
587@@ -0,0 +1,218 @@
588+/*
589+ * Copyright (c) 2012, Freescale Semiconductor, Inc. All rights reserved.
590+ *
591+ * This library is free software; you can redistribute it and/or
592+ * modify it under the terms of the GNU Lesser General Public
593+ * License as published by the Free Software Foundation; either
594+ * version 2.1 of the License, or (at your option) any later version.
595+ *
596+ * This library is distributed in the hope that it will be useful,
597+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
598+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
599+ * Lesser General Public License for more details.
600+ *
601+ * You should have received a copy of the GNU Lesser General Public
602+ * License along with this library; if not, write to the Free Software
603+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
604+ */
605+
606+#ifdef HAVE_CONFIG_H
607+#include "config.h"
608+#endif
609+
610+#include <string.h>
611+
612+#include "gstglvivante.h"
613+#include <gstbufmeta.h>
614+
615+#define GL_GLEXT_PROTOTYPES
616+#include <GLES2/gl2ext.h>
617+
618+typedef struct
619+{
620+ gfloat sampler_left;
621+ gfloat sampler_right;
622+ gfloat sampler_top;
623+ gfloat sampler_bottom;
624+} GstGLVivante;
625+
626+gpointer
627+gst_gl_vivante_new ()
628+{
629+ GstGLVivante *viv = g_new (GstGLVivante, 1);
630+
631+ viv->sampler_left = 0.0f;
632+ viv->sampler_right = 1.0f;
633+ viv->sampler_top = 1.0f;
634+ viv->sampler_bottom = 0.0f;
635+
636+ return viv;
637+}
638+
639+void
640+gst_gl_vivante_delete (gpointer gpu)
641+{
642+ g_free (gpu);
643+}
644+
645+gboolean
646+gst_gl_vivante_check_format (gpointer gpu, GstVideoFormat format, gint width,
647+ gint height)
648+{
649+ switch (format) {
650+ case GST_VIDEO_FORMAT_YV12:
651+ case GST_VIDEO_FORMAT_NV12:
652+ if ((width & 15) == 0)
653+ return TRUE;
654+ break;
655+ default:
656+ GST_WARNING ("GstVideoFormat %d not supported by vivante", format);
657+ }
658+ GST_WARNING
659+ ("Check format %d, width,height [%d, %d] failed, can't direct render",
660+ format, width, height);
661+ return FALSE;
662+}
663+
664+GLenum
665+gst_gl_vivante_get_gl_format (gpointer gpu, GstVideoFormat format)
666+{
667+ switch (format) {
668+ case GST_VIDEO_FORMAT_YV12:
669+ return GL_VIV_YV12;
670+ case GST_VIDEO_FORMAT_NV12:
671+ return GL_VIV_NV12;
672+ default:
673+ GST_WARNING ("GstVideoFormat %d not supported by vivante", format);
674+ }
675+ return GL_NONE;
676+}
677+
678+static gboolean
679+format_is_yuv (GstVideoFormat format)
680+{
681+ switch (format) {
682+ case GST_VIDEO_FORMAT_YV12:
683+ case GST_VIDEO_FORMAT_NV12:
684+ return TRUE;
685+ default:
686+ return FALSE;
687+ }
688+}
689+
690+static void
691+copy_data_to_gpu (gpointer gpu, GstVideoFormat format, gpointer data,
692+ gpointer planes[], gint width, gint height)
693+{
694+ gint src_height;
695+ gint src_y_size, src_uv_size;
696+ gint dst_y_size, dst_uv_size;
697+
698+ /* width is already 16 aligned */
699+ switch (format) {
700+ case GST_VIDEO_FORMAT_YV12:
701+ src_height = GST_ROUND_UP_2 (height);
702+ src_y_size = width * src_height;
703+ src_uv_size = src_y_size / 4;
704+ dst_y_size = width * height;
705+ dst_uv_size = dst_y_size / 4;
706+ memcpy (planes[0], data, dst_y_size);
707+ memcpy (planes[1], (gchar *) data + src_y_size, dst_uv_size);
708+ memcpy (planes[2], (gchar *) data + src_y_size + src_uv_size,
709+ dst_uv_size);
710+ break;
711+ case GST_VIDEO_FORMAT_NV12:
712+ src_height = GST_ROUND_UP_2 (height);
713+ src_y_size = width * src_height;
714+ dst_y_size = width * height;
715+ dst_uv_size = dst_y_size / 2;
716+ memcpy (planes[0], data, dst_y_size);
717+ memcpy (planes[1], (gchar *) data + src_y_size, dst_uv_size);
718+ break;
719+ default:
720+ return;
721+ }
722+}
723+
724+gboolean
725+gst_gl_vivante_tex_upload (gpointer gpu, GstGLDisplay * display)
726+{
727+ GstVideoFormat format = display->upload_video_format;
728+ gint width = display->upload_data_width;
729+ gint height = display->upload_data_height;
730+ gpointer data = display->upload_data;
731+ GstBufferMeta *meta = GST_BUFFER_META (display->upload_meta);
732+ gpointer planes[3];
733+ GLuint physical = meta ? (GLuint) (meta->physical_data) : ~0U;
734+
735+ GST_INFO ("gst_gl_vivante_tex_upload physical address 0x%x, data %p, tex %d",
736+ physical, data, display->upload_outtex);
737+
738+ if (!gst_gl_vivante_check_format (gpu, format, width, height))
739+ return FALSE;
740+
741+ glBindTexture (GL_TEXTURE_2D, display->upload_outtex);
742+
743+ if (((guint) data & 0x3F) != 0) { /* not aligned, need additional copy */
744+ if (!format_is_yuv (format)) { /* rgb is left to default handler */
745+ GST_WARNING ("Format %d unaligned data is not supported for"
746+ " direct rendering", format);
747+ return FALSE;
748+ }
749+
750+ GST_WARNING ("Data not aligned, need additional copy");
751+
752+ glTexDirectVIV (GL_TEXTURE_2D, width, height,
753+ gst_gl_vivante_get_gl_format (gpu, format), (GLvoid **) & planes);
754+ if (glGetError () != GL_NO_ERROR)
755+ return FALSE;
756+
757+ copy_data_to_gpu (gpu, format, data, planes, width, height);
758+ } else {
759+ glTexDirectVIVMap (GL_TEXTURE_2D, width, height,
760+ gst_gl_vivante_get_gl_format (gpu, format), &data, &physical);
761+ if (glGetError () != GL_NO_ERROR)
762+ return FALSE;
763+ display->upload_buf_mapped = TRUE;
764+ }
765+
766+ glTexDirectInvalidateVIV (GL_TEXTURE_2D);
767+
768+ return TRUE;
769+}
770+
771+void
772+gst_gl_vivante_set_caps (gpointer gpu, GstCaps * caps)
773+{
774+ GstVideoFormat format;
775+ gint width;
776+ gint height;
777+ GstStructure *s;
778+ gint left = 0, right = 0, top = 0, bottom = 0;
779+ GstGLVivante *viv = (GstGLVivante *) gpu;
780+
781+ s = gst_caps_get_structure (caps, 0);
782+ gst_structure_get_int (s, "crop-left", &left);
783+ gst_structure_get_int (s, "crop-top", &top);
784+ gst_structure_get_int (s, "crop-right", &right);
785+ gst_structure_get_int (s, "crop-bottom", &bottom);
786+
787+ gst_video_format_parse_caps (caps, &format, &width, &height);
788+
789+ viv->sampler_left = ((gfloat) left) / width;
790+ viv->sampler_right = ((gfloat) (width - right)) / width;
791+ viv->sampler_top = ((gfloat) (height - bottom)) / height;
792+ viv->sampler_bottom = ((gfloat) top) / height;
793+}
794+
795+void
796+gst_gl_vivante_get_sampler_rect (gpointer gpu, gfloat * left, gfloat * right,
797+ gfloat * top, gfloat * bottom)
798+{
799+ GstGLVivante *viv = (GstGLVivante *) gpu;
800+
801+ *left = viv->sampler_left;
802+ *right = viv->sampler_right;
803+ *top = viv->sampler_top;
804+ *bottom = viv->sampler_bottom;
805+}
806diff --git a/gst-libs/gst/gl/gstglvivante.h b/gst-libs/gst/gl/gstglvivante.h
807new file mode 100644
808index 0000000..f763f80
809--- /dev/null
810+++ b/gst-libs/gst/gl/gstglvivante.h
811@@ -0,0 +1,41 @@
812+/*
813+ * Copyright (c) 2012, Freescale Semiconductor, Inc. All rights reserved.
814+ *
815+ * This library is free software; you can redistribute it and/or
816+ * modify it under the terms of the GNU Library General Public
817+ * License as published by the Free Software Foundation; either
818+ * version 2 of the License, or (at your option) any later version.
819+ *
820+ * This library is distributed in the hope that it will be useful,
821+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
822+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
823+ * Library General Public License for more details.
824+ *
825+ * You should have received a copy of the GNU Library General Public
826+ * License along with this library; if not, write to the
827+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
828+ * Boston, MA 02111-1307, USA.
829+ */
830+
831+#ifndef __GST_GL_VIVANTE_H__
832+#define __GST_GL_VIVANTE_H__
833+
834+#include "gstgldisplay.h"
835+#include <GLES2/gl2.h>
836+
837+G_BEGIN_DECLS
838+
839+gpointer gst_gl_vivante_new();
840+void gst_gl_vivante_delete(gpointer gpu);
841+
842+gboolean gst_gl_vivante_check_format(gpointer gpu, GstVideoFormat format, gint width, gint height);
843+GLenum gst_gl_vivante_get_gl_format(gpointer gpu, GstVideoFormat format);
844+
845+gboolean gst_gl_vivante_tex_upload (gpointer gpu, GstGLDisplay * display);
846+void gst_gl_vivante_set_caps (gpointer gpu, GstCaps * caps);
847+
848+void gst_gl_vivante_get_sampler_rect (gpointer gpu, gfloat *left, gfloat *right, gfloat *top, gfloat *bottom);
849+
850+G_END_DECLS
851+
852+#endif /* __GST_GL_VIVANTE_H__ */
853diff --git a/gst-libs/gst/gl/gstglwindow.h b/gst-libs/gst/gl/gstglwindow.h
854index 499d47a..c3cafb2 100644
855--- a/gst-libs/gst/gl/gstglwindow.h
856+++ b/gst-libs/gst/gl/gstglwindow.h
857@@ -21,6 +21,10 @@
858 #ifndef __GST_GL_WINDOW_H__
859 #define __GST_GL_WINDOW_H__
860
861+#ifdef HAVE_CONFIG_H
862+#include "config.h"
863+#endif
864+
865 /* OpenGL 2.0 for Embedded Systems */
866 #ifdef OPENGL_ES2
867 #undef UNICODE
868diff --git a/gst-libs/gst/gl/gstglwindow_fbES2.c b/gst-libs/gst/gl/gstglwindow_fbES2.c
869new file mode 100644
870index 0000000..57c02e1
871--- /dev/null
872+++ b/gst-libs/gst/gl/gstglwindow_fbES2.c
873@@ -0,0 +1,709 @@
874+/*
875+ * GStreamer
876+ * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
877+ *
878+ * This library is free software; you can redistribute it and/or
879+ * modify it under the terms of the GNU Library General Public
880+ * License as published by the Free Software Foundation; either
881+ * version 2 of the License, or (at your option) any later version.
882+ *
883+ * This library is distributed in the hope that it will be useful,
884+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
885+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
886+ * Library General Public License for more details.
887+ *
888+ * You should have received a copy of the GNU Library General Public
889+ * License along with this library; if not, write to the
890+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
891+ * Boston, MA 02111-1307, USA.
892+ */
893+
894+#ifdef HAVE_CONFIG_H
895+#include "config.h"
896+#endif
897+
898+#include "gstglwindow.h"
899+#include "EGL/eglvivante.h"
900+
901+#include <locale.h>
902+#include <stdio.h>
903+#include <stdlib.h>
904+
905+#define GST_GL_WINDOW_GET_PRIVATE(o) \
906+ (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_GL_TYPE_WINDOW, GstGLWindowPrivate))
907+
908+/* A gl window is created and deleted in a thread dedicated to opengl calls
909+ The name contains "window" because an opengl context is used in cooperation
910+ with a window */
911+
912+const gchar *EGLErrorString ();
913+
914+enum
915+{
916+ ARG_0,
917+ ARG_DISPLAY
918+};
919+
920+enum GstGLFbEventType
921+{
922+ FB_EVENT_DRAW,
923+ FB_EVENT_CALLBACK,
924+ FB_EVENT_QUIT,
925+};
926+
927+typedef struct _GstGLFbEvent
928+{
929+ enum GstGLFbEventType type;
930+ GstGLWindowCB callback;
931+ gpointer data;
932+} GstGLFbEvent;
933+
934+struct _GstGLWindowPrivate
935+{
936+ /* X is not thread safe */
937+ GMutex *lock;
938+ GCond *cond_send_message;
939+ GCond *cond_queue_message;
940+ gboolean running;
941+ gboolean allow_extra_expose_events;
942+
943+ /* fb queue */
944+ GList *queue;
945+
946+ /* X context */
947+ gchar *display_name;
948+ gint device_width;
949+ gint device_height;
950+
951+ EGLNativeWindowType internal_win_id;
952+ EGLNativeDisplayType device;
953+
954+ /* EGL */
955+ EGLContext gl_context;
956+ EGLDisplay gl_display;
957+ EGLSurface gl_surface;
958+
959+ /* frozen callbacks */
960+ GstGLWindowCB draw_cb;
961+ gpointer draw_data;
962+ GstGLWindowCB2 resize_cb;
963+ gpointer resize_data;
964+ GstGLWindowCB close_cb;
965+ gpointer close_data;
966+};
967+
968+G_DEFINE_TYPE (GstGLWindow, gst_gl_window, G_TYPE_OBJECT);
969+
970+#undef G_LOG_DOMAIN
971+#define G_LOG_DOMAIN "GstGLWindow"
972+
973+gboolean _gst_gl_window_debug = FALSE;
974+
975+void
976+gst_gl_window_init_platform ()
977+{
978+}
979+
980+static void
981+free_event (gpointer event, gpointer data)
982+{
983+ g_slice_free (GstGLFbEvent, event);
984+}
985+
986+/* Must be called in the gl thread */
987+static void
988+gst_gl_window_finalize (GObject * object)
989+{
990+ GstGLWindow *window = GST_GL_WINDOW (object);
991+ GstGLWindowPrivate *priv = window->priv;
992+ gboolean ret = TRUE;
993+
994+ g_mutex_lock (priv->lock);
995+
996+ g_debug ("about to finalize gl window\n");
997+
998+ if (priv->gl_context) {
999+ ret =
1000+ eglMakeCurrent (priv->gl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
1001+ EGL_NO_CONTEXT);
1002+ if (!ret)
1003+ g_debug ("failed to release opengl context\n");
1004+
1005+ eglDestroyContext (priv->gl_display, priv->gl_context);
1006+ }
1007+
1008+ if (priv->gl_display)
1009+ eglTerminate (priv->gl_display);
1010+
1011+ if (priv->device)
1012+ fbDestroyDisplay (priv->device);
1013+
1014+ g_list_foreach (priv->queue, free_event, NULL);
1015+ g_list_free (priv->queue);
1016+ priv->queue = NULL;
1017+
1018+ if (priv->cond_send_message) {
1019+ g_cond_free (priv->cond_send_message);
1020+ priv->cond_send_message = NULL;
1021+ }
1022+
1023+ if (priv->cond_queue_message) {
1024+ g_cond_free (priv->cond_queue_message);
1025+ priv->cond_queue_message = NULL;
1026+ }
1027+
1028+ g_mutex_unlock (priv->lock);
1029+
1030+ if (priv->lock) {
1031+ g_mutex_free (priv->lock);
1032+ priv->lock = NULL;
1033+ }
1034+
1035+ G_OBJECT_CLASS (gst_gl_window_parent_class)->finalize (object);
1036+}
1037+
1038+static void
1039+gst_gl_window_set_property (GObject * object, guint prop_id,
1040+ const GValue * value, GParamSpec * pspec)
1041+{
1042+ GstGLWindow *window;
1043+ GstGLWindowPrivate *priv;
1044+
1045+ g_return_if_fail (GST_GL_IS_WINDOW (object));
1046+
1047+ window = GST_GL_WINDOW (object);
1048+
1049+ priv = window->priv;
1050+
1051+ switch (prop_id) {
1052+ case ARG_DISPLAY:
1053+ priv->display_name = g_strdup (g_value_get_string (value));
1054+ break;
1055+ default:
1056+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1057+ break;
1058+ }
1059+}
1060+
1061+static void
1062+gst_gl_window_get_property (GObject * object, guint prop_id,
1063+ GValue * value, GParamSpec * pspec)
1064+{
1065+ GstGLWindow *window;
1066+ GstGLWindowPrivate *priv;
1067+
1068+ g_return_if_fail (GST_GL_IS_WINDOW (object));
1069+
1070+ window = GST_GL_WINDOW (object);
1071+
1072+ priv = window->priv;
1073+
1074+ switch (prop_id) {
1075+ case ARG_DISPLAY:
1076+ g_value_set_string (value, priv->display_name);
1077+ break;
1078+ default:
1079+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1080+ break;
1081+ }
1082+}
1083+
1084+static void
1085+gst_gl_window_log_handler (const gchar * domain, GLogLevelFlags flags,
1086+ const gchar * message, gpointer user_data)
1087+{
1088+ if (_gst_gl_window_debug) {
1089+ g_log_default_handler (domain, flags, message, user_data);
1090+ }
1091+}
1092+
1093+static void
1094+gst_gl_window_class_init (GstGLWindowClass * klass)
1095+{
1096+ GObjectClass *obj_class = G_OBJECT_CLASS (klass);
1097+
1098+ g_type_class_add_private (klass, sizeof (GstGLWindowPrivate));
1099+
1100+ obj_class->finalize = gst_gl_window_finalize;
1101+ obj_class->set_property = gst_gl_window_set_property;
1102+ obj_class->get_property = gst_gl_window_get_property;
1103+
1104+ g_object_class_install_property (obj_class, ARG_DISPLAY,
1105+ g_param_spec_string ("display", "Display", "X Display name", NULL,
1106+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
1107+}
1108+
1109+static void
1110+gst_gl_window_init (GstGLWindow * window)
1111+{
1112+ GstGLWindowPrivate *priv = NULL;
1113+ window->priv = GST_GL_WINDOW_GET_PRIVATE (window);
1114+ priv = window->priv;
1115+
1116+ if (g_getenv ("GST_GL_WINDOW_DEBUG") != NULL)
1117+ _gst_gl_window_debug = TRUE;
1118+
1119+ g_log_set_handler ("GstGLWindow", G_LOG_LEVEL_DEBUG,
1120+ gst_gl_window_log_handler, NULL);
1121+
1122+ priv->lock = NULL;
1123+ priv->cond_send_message = NULL;
1124+ priv->running = FALSE;
1125+ priv->allow_extra_expose_events = FALSE;
1126+
1127+ priv->queue = NULL;
1128+
1129+ /* X context */
1130+ priv->display_name = NULL;
1131+ priv->device_width = 0;
1132+ priv->device_height = 0;
1133+
1134+ /* EGL */
1135+ priv->gl_context = EGL_NO_CONTEXT;
1136+ priv->gl_display = 0;
1137+ priv->gl_surface = EGL_NO_SURFACE;
1138+
1139+ /* frozen callbacks */
1140+ priv->draw_cb = NULL;
1141+ priv->draw_data = NULL;
1142+ priv->resize_cb = NULL;
1143+ priv->resize_data = NULL;
1144+ priv->close_cb = NULL;
1145+ priv->close_data = NULL;
1146+}
1147+
1148+/* Must be called in the gl thread */
1149+GstGLWindow *
1150+gst_gl_window_new (gulong external_gl_context)
1151+{
1152+ GstGLWindow *window = g_object_new (GST_GL_TYPE_WINDOW, NULL);
1153+ GstGLWindowPrivate *priv = window->priv;
1154+
1155+ EGLint config_attrib[] = {
1156+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
1157+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
1158+ EGL_DEPTH_SIZE, 16,
1159+ EGL_NONE
1160+ };
1161+
1162+ EGLint context_attrib[] = {
1163+ EGL_CONTEXT_CLIENT_VERSION, 2,
1164+ EGL_NONE
1165+ };
1166+
1167+ EGLint majorVersion;
1168+ EGLint minorVersion;
1169+ EGLint numConfigs;
1170+ EGLConfig config;
1171+
1172+ int index = 0;
1173+
1174+ setlocale (LC_NUMERIC, "C");
1175+
1176+ priv->lock = g_mutex_new ();
1177+ priv->cond_send_message = g_cond_new ();
1178+ priv->cond_queue_message = g_cond_new ();
1179+ priv->running = TRUE;
1180+ priv->allow_extra_expose_events = TRUE;
1181+
1182+ g_mutex_lock (priv->lock);
1183+
1184+ if (priv->display_name)
1185+ index = strtol (priv->display_name, NULL, 0);
1186+
1187+ priv->device = fbGetDisplayByIndex (index);
1188+
1189+ if (!priv->device) {
1190+ g_debug ("failed to get fb display by index %d\n", index);
1191+ goto failure;
1192+ }
1193+
1194+ priv->internal_win_id = fbCreateWindow (priv->device, -1, -1, 0, 0);
1195+
1196+ fbGetDisplayGeometry (priv->device, &priv->device_width,
1197+ &priv->device_height);
1198+
1199+ priv->gl_display = eglGetDisplay (priv->device);
1200+
1201+ if (eglInitialize (priv->gl_display, &majorVersion, &minorVersion))
1202+ g_debug ("egl initialized: %d.%d\n", majorVersion, minorVersion);
1203+ else {
1204+ g_debug ("failed to initialize egl %ld, %s\n", (gulong) priv->gl_display,
1205+ EGLErrorString ());
1206+ goto failure;
1207+ }
1208+
1209+ if (eglChooseConfig (priv->gl_display, config_attrib, &config, 1,
1210+ &numConfigs))
1211+ g_debug ("config set: %ld, %ld\n", (gulong) config, (gulong) numConfigs);
1212+ else {
1213+ g_debug ("failed to set config %ld, %s\n", (gulong) priv->gl_display,
1214+ EGLErrorString ());
1215+ goto failure;
1216+ }
1217+
1218+ priv->gl_surface =
1219+ eglCreateWindowSurface (priv->gl_display, config, priv->internal_win_id,
1220+ NULL);
1221+ if (priv->gl_surface != EGL_NO_SURFACE)
1222+ g_debug ("surface created: %ld\n", (gulong) priv->gl_surface);
1223+ else {
1224+ g_debug ("failed to create surface %ld, %ld, %ld, %s\n",
1225+ (gulong) priv->gl_display, (gulong) priv->gl_surface,
1226+ (gulong) priv->gl_display, EGLErrorString ());
1227+ goto failure;
1228+ }
1229+
1230+ g_debug ("about to create gl context\n");
1231+
1232+ priv->gl_context =
1233+ eglCreateContext (priv->gl_display, config,
1234+ (EGLContext) (guint) external_gl_context, context_attrib);
1235+
1236+ if (priv->gl_context != EGL_NO_CONTEXT)
1237+ g_debug ("gl context created: %ld\n", (gulong) priv->gl_context);
1238+ else {
1239+ g_debug ("failed to create glcontext %ld, %ld, %s\n",
1240+ (gulong) priv->gl_context, (gulong) priv->gl_display,
1241+ EGLErrorString ());
1242+ goto failure;
1243+ }
1244+
1245+ if (!eglMakeCurrent (priv->gl_display, priv->gl_surface, priv->gl_surface,
1246+ priv->gl_context)) {
1247+ g_debug ("failed to make opengl context current %ld, %s\n",
1248+ (gulong) priv->gl_display, EGLErrorString ());
1249+ goto failure;
1250+ }
1251+
1252+ g_mutex_unlock (priv->lock);
1253+ printf ("device WxH:%dx%d\n", priv->device_width, priv->device_height);
1254+ return window;
1255+
1256+failure:
1257+ g_mutex_unlock (priv->lock);
1258+ g_object_unref (G_OBJECT (window));
1259+ return NULL;
1260+}
1261+
1262+GQuark
1263+gst_gl_window_error_quark (void)
1264+{
1265+ return g_quark_from_static_string ("gst-gl-window-error");
1266+}
1267+
1268+gulong
1269+gst_gl_window_get_internal_gl_context (GstGLWindow * window)
1270+{
1271+ GstGLWindowPrivate *priv = window->priv;
1272+ return (gulong) priv->gl_context;
1273+}
1274+
1275+void
1276+callback_activate_gl_context (GstGLWindowPrivate * priv)
1277+{
1278+ if (!eglMakeCurrent (priv->gl_display, priv->gl_surface, priv->gl_surface,
1279+ priv->gl_context))
1280+ g_debug ("failed to activate opengl context %lud\n",
1281+ (gulong) priv->gl_context);
1282+}
1283+
1284+void
1285+callback_inactivate_gl_context (GstGLWindowPrivate * priv)
1286+{
1287+ if (!eglMakeCurrent (priv->device, EGL_NO_SURFACE, EGL_NO_SURFACE,
1288+ EGL_NO_CONTEXT))
1289+ g_debug ("failed to inactivate opengl context %lud\n",
1290+ (gulong) priv->gl_context);
1291+}
1292+
1293+void
1294+gst_gl_window_activate_gl_context (GstGLWindow * window, gboolean activate)
1295+{
1296+ GstGLWindowPrivate *priv = window->priv;
1297+ if (activate)
1298+ gst_gl_window_send_message (window,
1299+ GST_GL_WINDOW_CB (callback_activate_gl_context), priv);
1300+ else
1301+ gst_gl_window_send_message (window,
1302+ GST_GL_WINDOW_CB (callback_inactivate_gl_context), priv);
1303+}
1304+
1305+/* Not called by the gl thread */
1306+void
1307+gst_gl_window_set_external_window_id (GstGLWindow * window, gulong id)
1308+{
1309+}
1310+
1311+void
1312+gst_gl_window_set_draw_callback (GstGLWindow * window, GstGLWindowCB callback,
1313+ gpointer data)
1314+{
1315+ GstGLWindowPrivate *priv = window->priv;
1316+
1317+ g_mutex_lock (priv->lock);
1318+
1319+ priv->draw_cb = callback;
1320+ priv->draw_data = data;
1321+
1322+ g_mutex_unlock (priv->lock);
1323+}
1324+
1325+void
1326+gst_gl_window_set_resize_callback (GstGLWindow * window,
1327+ GstGLWindowCB2 callback, gpointer data)
1328+{
1329+ GstGLWindowPrivate *priv = window->priv;
1330+
1331+ g_mutex_lock (priv->lock);
1332+
1333+ priv->resize_cb = callback;
1334+ priv->resize_data = data;
1335+
1336+ g_mutex_unlock (priv->lock);
1337+}
1338+
1339+void
1340+gst_gl_window_set_close_callback (GstGLWindow * window, GstGLWindowCB callback,
1341+ gpointer data)
1342+{
1343+ GstGLWindowPrivate *priv = window->priv;
1344+
1345+ g_mutex_lock (priv->lock);
1346+
1347+ priv->close_cb = callback;
1348+ priv->close_data = data;
1349+
1350+ g_mutex_unlock (priv->lock);
1351+}
1352+
1353+/* Called in the gl thread */
1354+void
1355+gst_gl_window_draw_unlocked (GstGLWindow * window, gint width, gint height)
1356+{
1357+ GstGLWindowPrivate *priv = window->priv;
1358+
1359+ if (priv->running && priv->allow_extra_expose_events) {
1360+ GstGLFbEvent *event = g_slice_new0 (GstGLFbEvent);
1361+ event->type = FB_EVENT_DRAW;
1362+ priv->queue = g_list_append (priv->queue, event);
1363+ g_cond_signal (priv->cond_queue_message);
1364+ /* block until opengl calls have been executed in the gl thread */
1365+ g_cond_wait (priv->cond_send_message, priv->lock);
1366+ }
1367+}
1368+
1369+/* Not called by the gl thread */
1370+void
1371+gst_gl_window_draw (GstGLWindow * window, gint width, gint height)
1372+{
1373+ if (window) {
1374+ GstGLWindowPrivate *priv = window->priv;
1375+
1376+ g_mutex_lock (priv->lock);
1377+
1378+ if (priv->running) {
1379+ GstGLFbEvent *event = g_slice_new0 (GstGLFbEvent);
1380+ event->type = FB_EVENT_DRAW;
1381+ priv->queue = g_list_append (priv->queue, event);
1382+ g_cond_signal (priv->cond_queue_message);
1383+ /* block until opengl calls have been executed in the gl thread */
1384+ g_cond_wait (priv->cond_send_message, priv->lock);
1385+ }
1386+
1387+ g_mutex_unlock (priv->lock);
1388+ }
1389+}
1390+
1391+static void
1392+gst_gl_fb_queue_flush (GList * queue, GCond * cond)
1393+{
1394+ GstGLFbEvent *event;
1395+ GList *first;
1396+
1397+ while ((first = g_list_first (queue))) {
1398+ event = first->data;
1399+ queue = g_list_delete_link (queue, first);
1400+
1401+ if (event->type == FB_EVENT_CALLBACK) {
1402+ g_debug ("execute last pending custom x events\n");
1403+
1404+ if (!event->callback || !event->data)
1405+ g_debug ("custom cb not initialized\n");
1406+
1407+ event->callback (event->data);
1408+
1409+ g_cond_signal (cond);
1410+ }
1411+
1412+ g_slice_free (GstGLFbEvent, event);
1413+ }
1414+}
1415+
1416+/* Called in the gl thread */
1417+void
1418+gst_gl_window_run_loop (GstGLWindow * window)
1419+{
1420+ GstGLWindowPrivate *priv = window->priv;
1421+ GstGLFbEvent *event;
1422+ GList *first;
1423+
1424+ g_debug ("begin loop\n");
1425+
1426+ g_mutex_lock (priv->lock);
1427+
1428+ while (priv->running) {
1429+
1430+ if (!priv->queue)
1431+ g_cond_wait (priv->cond_queue_message, priv->lock);
1432+
1433+ first = g_list_first (priv->queue);
1434+ event = first->data;
1435+ priv->queue = g_list_delete_link (priv->queue, first);
1436+
1437+ // use in generic/cube and other related uses
1438+ priv->allow_extra_expose_events = g_list_length (priv->queue) <= 2;
1439+
1440+ switch (event->type) {
1441+ case FB_EVENT_CALLBACK:
1442+ {
1443+ if (priv->running) {
1444+ if (!event->callback || !event->data)
1445+ g_debug ("custom cb not initialized\n");
1446+ event->callback (event->data);
1447+ g_cond_signal (priv->cond_send_message);
1448+ }
1449+ break;
1450+ }
1451+
1452+ case FB_EVENT_QUIT:
1453+ {
1454+ g_debug ("Quit loop message %lud\n", (gulong) priv->internal_win_id);
1455+
1456+ /* exit loop */
1457+ priv->running = FALSE;
1458+
1459+ /* make sure last pendings send message calls are executed */
1460+ gst_gl_fb_queue_flush (priv->queue, priv->cond_send_message);
1461+ priv->queue = NULL;
1462+
1463+ /* Finally we can destroy opengl ressources (texture/shaders/fbo) */
1464+ if (!event->callback || !event->data)
1465+ g_debug ("destroy cb not correclty set\n");
1466+
1467+ event->callback (event->data);
1468+ g_cond_signal (priv->cond_send_message);
1469+ break;
1470+ }
1471+
1472+ case FB_EVENT_DRAW:
1473+ if (priv->draw_cb) {
1474+ priv->draw_cb (priv->draw_data);
1475+ glFlush ();
1476+ eglSwapBuffers (priv->gl_display, priv->gl_surface);
1477+ g_cond_signal (priv->cond_send_message);
1478+ }
1479+ break;
1480+
1481+ default:
1482+ g_debug ("unknown GstGLFbEvent type: %ud\n", event->type);
1483+ break;
1484+ } // switch
1485+
1486+ g_slice_free (GstGLFbEvent, event);
1487+
1488+ } // while running
1489+
1490+ g_mutex_unlock (priv->lock);
1491+
1492+ g_debug ("end loop\n");
1493+}
1494+
1495+/* Not called by the gl thread */
1496+void
1497+gst_gl_window_quit_loop (GstGLWindow * window, GstGLWindowCB callback,
1498+ gpointer data)
1499+{
1500+ if (window) {
1501+ GstGLWindowPrivate *priv = window->priv;
1502+
1503+ g_mutex_lock (priv->lock);
1504+
1505+ if (priv->running) {
1506+ GstGLFbEvent *event = g_slice_new0 (GstGLFbEvent);
1507+ event->type = FB_EVENT_QUIT;
1508+ event->callback = callback;
1509+ event->data = data;
1510+ priv->queue = g_list_append (priv->queue, event);
1511+
1512+ g_cond_signal (priv->cond_queue_message);
1513+ g_cond_wait (priv->cond_send_message, priv->lock);
1514+ }
1515+
1516+ g_mutex_unlock (priv->lock);
1517+ }
1518+}
1519+
1520+/* Not called by the gl thread */
1521+void
1522+gst_gl_window_send_message (GstGLWindow * window, GstGLWindowCB callback,
1523+ gpointer data)
1524+{
1525+ if (window) {
1526+ GstGLWindowPrivate *priv = window->priv;
1527+
1528+ g_mutex_lock (priv->lock);
1529+
1530+ if (priv->running) {
1531+ GstGLFbEvent *event = g_slice_new0 (GstGLFbEvent);
1532+ event->type = FB_EVENT_CALLBACK;
1533+ event->callback = callback;
1534+ event->data = data;
1535+ priv->queue = g_list_append (priv->queue, event);
1536+ g_cond_signal (priv->cond_queue_message);
1537+
1538+ /* block until opengl calls have been executed in the gl thread */
1539+ g_cond_wait (priv->cond_send_message, priv->lock);
1540+ }
1541+
1542+ g_mutex_unlock (priv->lock);
1543+ }
1544+}
1545+
1546+const gchar *
1547+EGLErrorString ()
1548+{
1549+ EGLint nErr = eglGetError ();
1550+ switch (nErr) {
1551+ case EGL_SUCCESS:
1552+ return "EGL_SUCCESS";
1553+ case EGL_BAD_DISPLAY:
1554+ return "EGL_BAD_DISPLAY";
1555+ case EGL_NOT_INITIALIZED:
1556+ return "EGL_NOT_INITIALIZED";
1557+ case EGL_BAD_ACCESS:
1558+ return "EGL_BAD_ACCESS";
1559+ case EGL_BAD_ALLOC:
1560+ return "EGL_BAD_ALLOC";
1561+ case EGL_BAD_ATTRIBUTE:
1562+ return "EGL_BAD_ATTRIBUTE";
1563+ case EGL_BAD_CONFIG:
1564+ return "EGL_BAD_CONFIG";
1565+ case EGL_BAD_CONTEXT:
1566+ return "EGL_BAD_CONTEXT";
1567+ case EGL_BAD_CURRENT_SURFACE:
1568+ return "EGL_BAD_CURRENT_SURFACE";
1569+ case EGL_BAD_MATCH:
1570+ return "EGL_BAD_MATCH";
1571+ case EGL_BAD_NATIVE_PIXMAP:
1572+ return "EGL_BAD_NATIVE_PIXMAP";
1573+ case EGL_BAD_NATIVE_WINDOW:
1574+ return "EGL_BAD_NATIVE_WINDOW";
1575+ case EGL_BAD_PARAMETER:
1576+ return "EGL_BAD_PARAMETER";
1577+ case EGL_BAD_SURFACE:
1578+ return "EGL_BAD_SURFACE";
1579+ default:
1580+ return "unknown";
1581+ }
1582+}
1583diff --git a/gst-libs/gst/gl/gstglwindow_x11ES2.c b/gst-libs/gst/gl/gstglwindow_x11ES2.c
1584index 260fd2e..65afb50 100644
1585--- a/gst-libs/gst/gl/gstglwindow_x11ES2.c
1586+++ b/gst-libs/gst/gl/gstglwindow_x11ES2.c
1587@@ -116,16 +116,16 @@ gst_gl_window_finalize (GObject * object)
1588
1589 if (priv->gl_context) {
1590 ret =
1591- eglMakeCurrent (priv->device, EGL_NO_SURFACE, EGL_NO_SURFACE,
1592+ eglMakeCurrent (priv->gl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
1593 EGL_NO_CONTEXT);
1594 if (!ret)
1595 g_debug ("failed to release opengl context\n");
1596
1597- eglDestroyContext (priv->device, priv->gl_context);
1598+ eglDestroyContext (priv->gl_display, priv->gl_context);
1599 }
1600
1601- if (priv->device)
1602- eglTerminate (priv->device);
1603+ if (priv->gl_display)
1604+ eglTerminate (priv->gl_display);
1605
1606 XFree (priv->visual_info);
1607
1608@@ -510,7 +510,7 @@ callback_activate_gl_context (GstGLWindowPrivate * priv)
1609 void
1610 callback_inactivate_gl_context (GstGLWindowPrivate * priv)
1611 {
1612- if (!eglMakeCurrent (priv->device, EGL_NO_SURFACE, EGL_NO_SURFACE,
1613+ if (!eglMakeCurrent (priv->gl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
1614 EGL_NO_CONTEXT))
1615 g_debug ("failed to inactivate opengl context %lud\n",
1616 (gulong) priv->gl_context);
1617@@ -622,7 +622,7 @@ gst_gl_window_draw_unlocked (GstGLWindow * window, gint width, gint height)
1618
1619 XSendEvent (priv->device, priv->internal_win_id, FALSE, ExposureMask,
1620 &event);
1621- XSync (priv->disp_send, FALSE);
1622+ XSync (priv->device, FALSE);
1623 }
1624 }
1625
1626diff --git a/gst/gl/gstglbumper.c b/gst/gl/gstglbumper.c
1627index 12efe7d..2daec5b 100644
1628--- a/gst/gl/gstglbumper.c
1629+++ b/gst/gl/gstglbumper.c
1630@@ -157,7 +157,6 @@ gst_gl_bumper_init_resources (GstGLFilter * filter)
1631
1632 png_structp png_ptr;
1633 png_infop info_ptr;
1634- guint sig_read = 0;
1635 png_uint_32 width = 0;
1636 png_uint_32 height = 0;
1637 gint bit_depth = 0;
1638@@ -209,7 +208,7 @@ gst_gl_bumper_init_resources (GstGLFilter * filter)
1639
1640 png_init_io (png_ptr, fp);
1641
1642- png_set_sig_bytes (png_ptr, sig_read);
1643+ png_set_sig_bytes (png_ptr, sizeof (magic));
1644
1645 png_read_info (png_ptr, info_ptr);
1646
1647diff --git a/gst/gl/gstglimagesink.c b/gst/gl/gstglimagesink.c
1648index d57f5b5..369d7f1 100644
1649--- a/gst/gl/gstglimagesink.c
1650+++ b/gst/gl/gstglimagesink.c
1651@@ -1,6 +1,6 @@
1652 /*
1653- * GStreamer
1654- * Copyright (C) 2003 Julien Moutte <julien@moutte.net>
1655+ * GStreamerfor
1656+ * Copyright (C) 2003 Julien Moutte <julien@moutte.net>for
1657 * Copyright (C) 2005,2006,2007 David A. Schleef <ds@schleef.org>
1658 * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
1659 *
1660@@ -86,6 +86,9 @@
1661 #include <gst/interfaces/xoverlay.h>
1662
1663 #include "gstglimagesink.h"
1664+#ifdef GPU_VIVANTE
1665+#include "gstglvivante.h"
1666+#endif
1667
1668 GST_DEBUG_CATEGORY (gst_debug_glimage_sink);
1669 #define GST_CAT_DEFAULT gst_debug_glimage_sink
1670@@ -137,11 +140,13 @@ static GstStaticPadTemplate gst_glimage_sink_template =
1671 GST_PAD_SINK,
1672 GST_PAD_ALWAYS,
1673 GST_STATIC_CAPS (GST_GL_VIDEO_CAPS ";"
1674- GST_VIDEO_CAPS_RGB ";"
1675- GST_VIDEO_CAPS_RGBx ";"
1676- GST_VIDEO_CAPS_RGBA ";"
1677- GST_VIDEO_CAPS_YUV ("{ I420, YV12, YUY2, UYVY, AYUV }"))
1678- );
1679+ GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_RGBA ";"
1680+#ifdef GPU_VIVANTE
1681+ GST_VIDEO_CAPS_YUV ("{ NV12, I420, YV12, YUY2, UYVY, AYUV }")
1682+#else
1683+ GST_VIDEO_CAPS_YUV ("{ I420, YV12, YUY2, UYVY, AYUV }")
1684+#endif
1685+ ));
1686 #endif
1687
1688 enum
1689@@ -152,7 +157,8 @@ enum
1690 PROP_CLIENT_DRAW_CALLBACK,
1691 PROP_CLIENT_DATA,
1692 PROP_FORCE_ASPECT_RATIO,
1693- PROP_PIXEL_ASPECT_RATIO
1694+ PROP_PIXEL_ASPECT_RATIO,
1695+ PROP_RENDERED_FRAMES
1696 };
1697
1698 GST_BOILERPLATE_FULL (GstGLImageSink, gst_glimage_sink, GstVideoSink,
1699@@ -241,6 +247,10 @@ gst_glimage_sink_class_init (GstGLImageSinkClass * klass)
1700 "The pixel aspect ratio of the device", "1/1",
1701 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
1702
1703+ g_object_class_install_property (gobject_class, PROP_RENDERED_FRAMES,
1704+ g_param_spec_int ("rendered", "rendered",
1705+ "Get the total rendered frames", 0, G_MAXINT, 0, G_PARAM_READABLE));
1706+
1707 gobject_class->finalize = gst_glimage_sink_finalize;
1708
1709 gstelement_class->change_state = gst_glimage_sink_change_state;
1710@@ -261,6 +271,7 @@ gst_glimage_sink_init (GstGLImageSink * glimage_sink,
1711 glimage_sink->new_window_id = 0;
1712 glimage_sink->display = NULL;
1713 glimage_sink->stored_buffer = NULL;
1714+ glimage_sink->stored_input_buffer = NULL;
1715 glimage_sink->clientReshapeCallback = NULL;
1716 glimage_sink->clientDrawCallback = NULL;
1717 glimage_sink->client_data = NULL;
1718@@ -370,6 +381,9 @@ gst_glimage_sink_get_property (GObject * object, guint prop_id,
1719 if (!g_value_transform (glimage_sink->par, value))
1720 g_warning ("Could not transform string to aspect ratio");
1721 break;
1722+ case PROP_RENDERED_FRAMES:
1723+ g_value_set_int (value, glimage_sink->rendered);
1724+ break;
1725 default:
1726 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1727 break;
1728@@ -435,6 +449,7 @@ gst_glimage_sink_change_state (GstElement * element, GstStateChange transition)
1729
1730 return GST_STATE_CHANGE_FAILURE;
1731 }
1732+ glimage_sink->rendered = 0;
1733 }
1734 break;
1735 case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
1736@@ -456,6 +471,10 @@ gst_glimage_sink_change_state (GstElement * element, GstStateChange transition)
1737 gst_buffer_unref (GST_BUFFER_CAST (glimage_sink->stored_buffer));
1738 glimage_sink->stored_buffer = NULL;
1739 }
1740+ if (glimage_sink->stored_input_buffer) {
1741+ gst_buffer_unref (glimage_sink->stored_input_buffer);
1742+ glimage_sink->stored_input_buffer = NULL;
1743+ }
1744 if (glimage_sink->display) {
1745 g_object_unref (glimage_sink->display);
1746 glimage_sink->display = NULL;
1747@@ -533,6 +552,14 @@ gst_glimage_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
1748 if (!ok)
1749 return FALSE;
1750
1751+#ifdef GPU_VIVANTE
1752+ /* special case for format that vivante can't handle */
1753+ if (format == GST_VIDEO_FORMAT_NV12 &&
1754+ !gst_gl_vivante_check_format (glimage_sink->display->gpu_priv, format,
1755+ width, height))
1756+ return FALSE;
1757+#endif
1758+
1759 /* init colorspace conversion if needed */
1760 ok = gst_gl_display_init_upload (glimage_sink->display, format,
1761 width, height, width, height);
1762@@ -609,6 +636,11 @@ gst_glimage_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
1763 if (!glimage_sink->window_id && !glimage_sink->new_window_id)
1764 gst_x_overlay_prepare_xwindow_id (GST_X_OVERLAY (glimage_sink));
1765
1766+#ifdef GPU_VIVANTE
1767+ if (glimage_sink->display->gpu_priv)
1768+ gst_gl_vivante_set_caps (glimage_sink->display->gpu_priv, caps);
1769+#endif
1770+
1771 return TRUE;
1772 }
1773
1774@@ -617,11 +649,18 @@ gst_glimage_sink_render (GstBaseSink * bsink, GstBuffer * buf)
1775 {
1776 GstGLImageSink *glimage_sink = NULL;
1777 GstGLBuffer *gl_buffer = NULL;
1778+ gint index;
1779+ GstFlowReturn res;
1780
1781 glimage_sink = GST_GLIMAGE_SINK (bsink);
1782
1783 GST_INFO ("buffer size: %d", GST_BUFFER_SIZE (buf));
1784
1785+ if (buf == glimage_sink->stored_input_buffer)
1786+ return GST_FLOW_OK;
1787+
1788+ glimage_sink->display->upload_buf_mapped = FALSE;
1789+
1790 //is gl
1791 if (glimage_sink->is_gl) {
1792 //increment gl buffer ref before storage
1793@@ -633,9 +672,16 @@ gst_glimage_sink_render (GstBaseSink * bsink, GstBuffer * buf)
1794 gl_buffer = gst_gl_buffer_new (glimage_sink->display,
1795 glimage_sink->width, glimage_sink->height);
1796
1797- //blocking call
1798- gst_gl_display_do_upload (glimage_sink->display, gl_buffer->texture,
1799- glimage_sink->width, glimage_sink->height, GST_BUFFER_DATA (buf));
1800+ index = G_N_ELEMENTS (buf->_gst_reserved) - 1;
1801+
1802+ if (index >= 0)
1803+ //blocking call
1804+ gst_gl_display_do_upload_with_meta (glimage_sink->display,
1805+ gl_buffer->texture, glimage_sink->width, glimage_sink->height,
1806+ GST_BUFFER_DATA (buf), buf->_gst_reserved[index]);
1807+ else
1808+ gst_gl_display_do_upload (glimage_sink->display, gl_buffer->texture,
1809+ glimage_sink->width, glimage_sink->height, GST_BUFFER_DATA (buf));
1810
1811 //gl_buffer is created in this block, so the gl buffer is already referenced
1812 }
1813@@ -645,26 +691,36 @@ gst_glimage_sink_render (GstBaseSink * bsink, GstBuffer * buf)
1814 gst_gl_display_set_window_id (glimage_sink->display,
1815 glimage_sink->window_id);
1816 }
1817- //the buffer is cleared when an other comes in
1818- if (glimage_sink->stored_buffer) {
1819- gst_buffer_unref (GST_BUFFER_CAST (glimage_sink->stored_buffer));
1820- glimage_sink->stored_buffer = NULL;
1821- }
1822- //store current buffer
1823- glimage_sink->stored_buffer = gl_buffer;
1824-
1825 //redisplay opengl scene
1826 if (gl_buffer->texture &&
1827 gst_gl_display_redisplay (glimage_sink->display,
1828 gl_buffer->texture, gl_buffer->width, gl_buffer->height,
1829 glimage_sink->window_width, glimage_sink->window_height,
1830 glimage_sink->keep_aspect_ratio))
1831- return GST_FLOW_OK;
1832+ res = GST_FLOW_OK;
1833 else {
1834 GST_ELEMENT_ERROR (glimage_sink, RESOURCE, NOT_FOUND,
1835 GST_GL_DISPLAY_ERR_MSG (glimage_sink->display), (NULL));
1836- return GST_FLOW_ERROR;
1837+ res = GST_FLOW_ERROR;
1838 }
1839+
1840+ //the buffer is cleared when an other comes in
1841+ if (glimage_sink->stored_buffer) {
1842+ gst_buffer_unref (GST_BUFFER_CAST (glimage_sink->stored_buffer));
1843+ glimage_sink->stored_buffer = NULL;
1844+ }
1845+ if (glimage_sink->stored_input_buffer) {
1846+ gst_buffer_unref (glimage_sink->stored_input_buffer);
1847+ glimage_sink->stored_input_buffer = NULL;
1848+ }
1849+ //store current buffer
1850+ glimage_sink->stored_buffer = gl_buffer;
1851+ if (glimage_sink->display->upload_buf_mapped)
1852+ glimage_sink->stored_input_buffer = gst_buffer_ref (buf);
1853+
1854+ glimage_sink->rendered++;
1855+
1856+ return res;
1857 }
1858
1859
1860diff --git a/gst/gl/gstglimagesink.h b/gst/gl/gstglimagesink.h
1861index c61b5c5..bd40bc4 100644
1862--- a/gst/gl/gstglimagesink.h
1863+++ b/gst/gl/gstglimagesink.h
1864@@ -51,6 +51,7 @@ struct _GstGLImageSink
1865
1866 //properties
1867 gchar *display_name;
1868+ gint rendered;
1869
1870 gulong window_id;
1871 gulong new_window_id;
1872@@ -67,6 +68,7 @@ struct _GstGLImageSink
1873
1874 GstGLDisplay *display;
1875 GstGLBuffer *stored_buffer;
1876+ GstBuffer *stored_input_buffer;
1877
1878 CRCB clientReshapeCallback;
1879 CDCB clientDrawCallback;
1880diff --git a/gst/gl/gstglupload.c b/gst/gl/gstglupload.c
1881index 09bc96d..8e12532 100644
1882--- a/gst/gl/gstglupload.c
1883+++ b/gst/gl/gstglupload.c
1884@@ -70,6 +70,9 @@
1885
1886 #include "gstglupload.h"
1887
1888+#ifdef GPU_VIVANTE
1889+#include "gstglvivante.h"
1890+#endif
1891
1892 #define GST_CAT_DEFAULT gst_gl_upload_debug
1893 GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
1894@@ -106,10 +109,13 @@ static GstStaticPadTemplate gst_gl_upload_sink_pad_template =
1895 GST_PAD_SINK,
1896 GST_PAD_ALWAYS,
1897 GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB ";"
1898- GST_VIDEO_CAPS_RGBx ";"
1899- GST_VIDEO_CAPS_RGBA ";"
1900- GST_VIDEO_CAPS_YUV ("{ I420, YV12, YUY2, UYVY, AYUV }"))
1901- );
1902+ GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_RGBA ";"
1903+#ifdef GPU_VIVANTE
1904+ GST_VIDEO_CAPS_YUV ("{ NV12, I420, YV12, YUY2, UYVY, AYUV }")
1905+#else
1906+ GST_VIDEO_CAPS_YUV ("{ I420, YV12, YUY2, UYVY, AYUV }")
1907+#endif
1908+ ));
1909 #endif
1910
1911 /* Properties */
1912@@ -504,6 +510,14 @@ gst_gl_upload_set_caps (GstBaseTransform * bt, GstCaps * incaps,
1913 GST_DEBUG ("caps connot be parsed");
1914 return FALSE;
1915 }
1916+#ifdef GPU_VIVANTE
1917+ /* special case for format that vivante can't handle */
1918+ if (upload->video_format == GST_VIDEO_FORMAT_NV12 &&
1919+ !gst_gl_vivante_check_format (upload->display->gpu_priv,
1920+ upload->video_format, upload->video_width, upload->video_height))
1921+ return FALSE;
1922+#endif
1923+
1924 //init colorspace conversion if needed
1925 ret = gst_gl_display_init_upload (upload->display, upload->video_format,
1926 upload->gl_width, upload->gl_height,
1927diff --git a/tests/examples/cocoa/videoxoverlay/Makefile.am b/tests/examples/cocoa/videoxoverlay/Makefile.am
1928index 5a85bb4..b4a4932 100755
1929--- a/tests/examples/cocoa/videoxoverlay/Makefile.am
1930+++ b/tests/examples/cocoa/videoxoverlay/Makefile.am
1931@@ -4,7 +4,7 @@ noinst_PROGRAMS = videoxoverlay
1932
1933 videoxoverlay_SOURCES = main.m
1934
1935-videoxoverlay_OBJCFLAGS=$(GST_PLUGINS_GL_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \
1936+videoxoverlay_OBJCFLAGS=$(GST_PLUGINS_GL_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_OBJCFLAGS) \
1937 $(GL_CFLAGS) -I/usr/local/include/gstreamer-0.10
1938 videoxoverlay_LDADD=$(GST_PLUGINS_GL_LIBS) $(GST_PLUGINS_BASE_LIBS) $(GST_LIBS) \
1939 $(GL_LIBS) -lgstinterfaces-$(GST_MAJORMINOR)
1940diff --git a/common/check.mak b/common/check.mak
1941index 30487f1..bc44620 100644
1942--- a/common/check.mak
1943+++ b/common/check.mak
1944@@ -24,6 +24,12 @@ LOOPS = 10
1945 CK_DEFAULT_TIMEOUT=20 \
1946 $*
1947
1948+# just like 'check', but don't run it again if it fails (useful for debugging)
1949+%.check-norepeat: %
1950+ @$(TESTS_ENVIRONMENT) \
1951+ CK_DEFAULT_TIMEOUT=20 \
1952+ $*
1953+
1954 # run any given test in a loop
1955 %.torture: %
1956 @for i in `seq 1 $(LOOPS)`; do \
1957@@ -152,7 +158,8 @@ help:
1958 @echo
1959 @echo "make check -- run all checks"
1960 @echo "make torture -- run all checks $(LOOPS) times"
1961- @echo "make (dir)/(test).check -- run the given check once"
1962+ @echo "make (dir)/(test).check -- run the given check once, repeat with GST_DEBUG=*:2 if it fails"
1963+ @echo "make (dir)/(test).check-norepeat -- run the given check once, but don't run it again if it fails"
1964 @echo "make (dir)/(test).forever -- run the given check forever"
1965 @echo "make (dir)/(test).torture -- run the given check $(LOOPS) times"
1966 @echo
1967diff --git a/common/gtk-doc-plugins.mak b/common/gtk-doc-plugins.mak
1968index 8cc42e7..084f9ae 100644
1969--- a/common/gtk-doc-plugins.mak
1970+++ b/common/gtk-doc-plugins.mak
1971@@ -13,8 +13,7 @@ help:
1972 @echo
1973
1974 # update the stuff maintained by doc maintainers
1975-update:
1976- $(MAKE) scanobj-update
1977+update: scanobj-update
1978 $(MAKE) check-outdated-docs
1979
1980 # We set GPATH here; this gives us semantics for GNU make
1981@@ -130,7 +129,7 @@ scanobj-build.stamp: $(SCANOBJ_DEPS) $(basefiles)
1982 --module=$(DOC_MODULE) --source=$(PACKAGE) --inspect-dir=$(INSPECT_DIR) && \
1983 echo " DOC Merging introspection data" && \
1984 $(PYTHON) \
1985- $(top_srcdir)/common/scangobj-merge.py $(DOC_MODULE); \
1986+ $(top_srcdir)/common/scangobj-merge.py $(DOC_MODULE) || exit 1; \
1987 if test x"$(srcdir)" != x. ; then \
1988 for f in $(SCANOBJ_FILES); \
1989 do \
1990diff --git a/common/m4/Makefile.am b/common/m4/Makefile.am
1991index 2ddb8a7..856d6e3 100644
1992--- a/common/m4/Makefile.am
1993+++ b/common/m4/Makefile.am
1994@@ -8,7 +8,6 @@ EXTRA_DIST = \
1995 as-gcc-inline-assembly.m4 \
1996 as-libtool.m4 \
1997 as-libtool-tags.m4 \
1998- as-objc.m4 \
1999 as-python.m4 \
2000 as-scrub-include.m4 \
2001 as-version.m4 \
2002diff --git a/common/m4/as-compiler-flag.m4 b/common/m4/as-compiler-flag.m4
2003index 882a4c7..8bb853a 100644
2004--- a/common/m4/as-compiler-flag.m4
2005+++ b/common/m4/as-compiler-flag.m4
2006@@ -62,3 +62,35 @@ AC_DEFUN([AS_CXX_COMPILER_FLAG],
2007 AC_MSG_RESULT([$flag_ok])
2008 ])
2009
2010+dnl AS_OBJC_COMPILER_FLAG(CPPFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
2011+dnl Tries to compile with the given CPPFLAGS.
2012+dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
2013+dnl and ACTION-IF-NOT-ACCEPTED otherwise.
2014+
2015+AC_DEFUN([AS_OBJC_COMPILER_FLAG],
2016+[
2017+ AC_REQUIRE([AC_PROG_OBJC])
2018+
2019+ AC_MSG_CHECKING([to see if Objective C compiler understands $1])
2020+
2021+ save_CPPFLAGS="$CPPFLAGS"
2022+ CPPFLAGS="$CPPFLAGS $1"
2023+
2024+ AC_LANG_PUSH([Objective C])
2025+
2026+ AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
2027+ CPPFLAGS="$save_CPPFLAGS"
2028+
2029+ if test "X$flag_ok" = Xyes ; then
2030+ $2
2031+ true
2032+ else
2033+ $3
2034+ true
2035+ fi
2036+
2037+ AC_LANG_POP([Objective C])
2038+
2039+ AC_MSG_RESULT([$flag_ok])
2040+])
2041+
2042diff --git a/common/m4/as-objc.m4 b/common/m4/as-objc.m4
2043deleted file mode 100644
2044index 1e7066a..0000000
2045--- a/common/m4/as-objc.m4
2046+++ /dev/null
2047@@ -1,56 +0,0 @@
2048-
2049-
2050-# AC_PROG_OBJC([LIST-OF-COMPILERS])
2051-#
2052-AC_DEFUN([AS_PROG_OBJC],
2053-[
2054-AC_CHECK_TOOLS(OBJC,
2055- [m4_default([$1], [objcc objc gcc cc CC])],
2056- none)
2057-AC_SUBST(OBJC)
2058-OBJC_LDFLAGS="-lobjc"
2059-AC_SUBST(OBJC_LDFLAGS)
2060-if test "x$OBJC" != xnone ; then
2061- _AM_DEPENDENCIES(OBJC)
2062- AC_MSG_CHECKING([if Objective C compiler works])
2063- cat >>conftest.m <<EOF
2064-#include <objc/Object.h>
2065-@interface Moo:Object
2066-{
2067-}
2068-- moo;
2069-int main();
2070-@end
2071-
2072-@implementation Moo
2073-- moo
2074-{
2075- exit(0);
2076-}
2077-
2078-int main()
2079-{
2080- id moo;
2081- moo = [[Moo new]];
2082- [[moo moo]];
2083- return 1;
2084-}
2085-@end
2086-EOF
2087- ${OBJC} conftest.m ${OBJC_LDFLAGS} >&5 2>&5
2088- if test -f a.out -o -f a.exe ; then
2089- result=yes
2090- else
2091- result=no
2092- echo failed program is: >&5
2093- cat conftest.m >&5
2094- fi
2095- rm -f conftest.m a.out a.exe
2096- AC_MSG_RESULT([$result])
2097-else
2098- _AM_DEPENDENCIES(OBJC)
2099-fi
2100-
2101-])
2102-
2103-
2104diff --git a/common/m4/gst-arch.m4 b/common/m4/gst-arch.m4
2105index 2e935d2..077a20b 100644
2106--- a/common/m4/gst-arch.m4
2107+++ b/common/m4/gst-arch.m4
2108@@ -5,32 +5,30 @@ dnl defines HOST_CPU
2109
2110 AC_DEFUN([AG_GST_ARCH],
2111 [
2112- AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use host_ variables
2113-
2114 dnl Determine CPU
2115- case "x${host_cpu}" in
2116+ case "x${target_cpu}" in
2117 xi?86 | xk? | xi?86_64)
2118- case $host_os in
2119+ case $target_os in
2120 solaris*)
2121 AC_CHECK_DECL([__i386], [I386_ABI="yes"], [I386_ABI="no"])
2122 AC_CHECK_DECL([__amd64], [AMD64_ABI="yes"], [AMD64_ABI="no"])
2123
2124 if test "x$I386_ABI" = "xyes" ; then
2125 HAVE_CPU_I386=yes
2126- AC_DEFINE(HAVE_CPU_I386, 1, [Define if the host CPU is an x86])
2127+ AC_DEFINE(HAVE_CPU_I386, 1, [Define if the target CPU is an x86])
2128 fi
2129 if test "x$AMD64_ABI" = "xyes" ; then
2130 HAVE_CPU_X86_64=yes
2131- AC_DEFINE(HAVE_CPU_X86_64, 1, [Define if the host CPU is a x86_64])
2132+ AC_DEFINE(HAVE_CPU_X86_64, 1, [Define if the target CPU is a x86_64])
2133 fi
2134 ;;
2135 *)
2136 HAVE_CPU_I386=yes
2137- AC_DEFINE(HAVE_CPU_I386, 1, [Define if the host CPU is an x86])
2138+ AC_DEFINE(HAVE_CPU_I386, 1, [Define if the target CPU is an x86])
2139
2140 dnl FIXME could use some better detection
2141 dnl (ie CPUID)
2142- case "x${host_cpu}" in
2143+ case "x${target_cpu}" in
2144 xi386 | xi486) ;;
2145 *)
2146 AC_DEFINE(HAVE_RDTSC, 1, [Define if RDTSC is available]) ;;
2147@@ -40,43 +38,43 @@ AC_DEFUN([AG_GST_ARCH],
2148 ;;
2149 xpowerpc)
2150 HAVE_CPU_PPC=yes
2151- AC_DEFINE(HAVE_CPU_PPC, 1, [Define if the host CPU is a PowerPC]) ;;
2152+ AC_DEFINE(HAVE_CPU_PPC, 1, [Define if the target CPU is a PowerPC]) ;;
2153 xpowerpc64)
2154 HAVE_CPU_PPC64=yes
2155- AC_DEFINE(HAVE_CPU_PPC64, 1, [Define if the host CPU is a 64 bit PowerPC]) ;;
2156+ AC_DEFINE(HAVE_CPU_PPC64, 1, [Define if the target CPU is a 64 bit PowerPC]) ;;
2157 xalpha*)
2158 HAVE_CPU_ALPHA=yes
2159- AC_DEFINE(HAVE_CPU_ALPHA, 1, [Define if the host CPU is an Alpha]) ;;
2160+ AC_DEFINE(HAVE_CPU_ALPHA, 1, [Define if the target CPU is an Alpha]) ;;
2161 xarm*)
2162 HAVE_CPU_ARM=yes
2163- AC_DEFINE(HAVE_CPU_ARM, 1, [Define if the host CPU is an ARM]) ;;
2164+ AC_DEFINE(HAVE_CPU_ARM, 1, [Define if the target CPU is an ARM]) ;;
2165 xsparc*)
2166 HAVE_CPU_SPARC=yes
2167- AC_DEFINE(HAVE_CPU_SPARC, 1, [Define if the host CPU is a SPARC]) ;;
2168+ AC_DEFINE(HAVE_CPU_SPARC, 1, [Define if the target CPU is a SPARC]) ;;
2169 xmips*)
2170 HAVE_CPU_MIPS=yes
2171- AC_DEFINE(HAVE_CPU_MIPS, 1, [Define if the host CPU is a MIPS]) ;;
2172+ AC_DEFINE(HAVE_CPU_MIPS, 1, [Define if the target CPU is a MIPS]) ;;
2173 xhppa*)
2174 HAVE_CPU_HPPA=yes
2175- AC_DEFINE(HAVE_CPU_HPPA, 1, [Define if the host CPU is a HPPA]) ;;
2176+ AC_DEFINE(HAVE_CPU_HPPA, 1, [Define if the target CPU is a HPPA]) ;;
2177 xs390*)
2178 HAVE_CPU_S390=yes
2179- AC_DEFINE(HAVE_CPU_S390, 1, [Define if the host CPU is a S390]) ;;
2180+ AC_DEFINE(HAVE_CPU_S390, 1, [Define if the target CPU is a S390]) ;;
2181 xia64*)
2182 HAVE_CPU_IA64=yes
2183- AC_DEFINE(HAVE_CPU_IA64, 1, [Define if the host CPU is a IA64]) ;;
2184+ AC_DEFINE(HAVE_CPU_IA64, 1, [Define if the target CPU is a IA64]) ;;
2185 xm68k*)
2186 HAVE_CPU_M68K=yes
2187- AC_DEFINE(HAVE_CPU_M68K, 1, [Define if the host CPU is a M68K]) ;;
2188+ AC_DEFINE(HAVE_CPU_M68K, 1, [Define if the target CPU is a M68K]) ;;
2189 xx86_64)
2190 HAVE_CPU_X86_64=yes
2191- AC_DEFINE(HAVE_CPU_X86_64, 1, [Define if the host CPU is a x86_64]) ;;
2192+ AC_DEFINE(HAVE_CPU_X86_64, 1, [Define if the target CPU is a x86_64]) ;;
2193 xcris)
2194 HAVE_CPU_CRIS=yes
2195- AC_DEFINE(HAVE_CPU_CRIS, 1, [Define if the host CPU is a CRIS]) ;;
2196+ AC_DEFINE(HAVE_CPU_CRIS, 1, [Define if the target CPU is a CRIS]) ;;
2197 xcrisv32)
2198 HAVE_CPU_CRISV32=yes
2199- AC_DEFINE(HAVE_CPU_CRISV32, 1, [Define if the host CPU is a CRISv32]) ;;
2200+ AC_DEFINE(HAVE_CPU_CRISV32, 1, [Define if the target CPU is a CRISv32]) ;;
2201 esac
2202
2203 dnl Determine endianness
2204@@ -98,6 +96,7 @@ AC_DEFUN([AG_GST_ARCH],
2205 AM_CONDITIONAL(HAVE_CPU_CRISV32, test "x$HAVE_CPU_CRISV32" = "xyes")
2206
2207 AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu", [the host CPU])
2208+ AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu", [the target CPU])
2209 ])
2210
2211 dnl check if unaligned memory access works correctly
2212diff --git a/common/m4/gst-args.m4 b/common/m4/gst-args.m4
2213index 030e7ac..e011ed4 100644
2214--- a/common/m4/gst-args.m4
2215+++ b/common/m4/gst-args.m4
2216@@ -19,6 +19,7 @@ dnl AG_GST_ARG_ENABLE_EXTERNAL
2217 dnl AG_GST_ARG_ENABLE_EXPERIMENTAL
2218 dnl AG_GST_ARG_ENABLE_BROKEN
2219
2220+dnl AG_GST_ARG_DISABLE_FATAL_WARNINGS
2221 AC_DEFUN([AG_GST_ARG_DEBUG],
2222 [
2223 dnl debugging stuff
2224@@ -110,13 +111,13 @@ AC_DEFUN([AG_GST_ARG_GCOV],
2225 dnl if gcov is used, we do not want default -O2 CFLAGS
2226 if test "x$GST_GCOV_ENABLED" = "xyes"
2227 then
2228- CFLAGS="-O0"
2229+ CFLAGS="$CFLAGS -O0"
2230 AC_SUBST(CFLAGS)
2231- CXXFLAGS="-O0"
2232+ CXXFLAGS="$CXXFLAGS -O0"
2233 AC_SUBST(CXXFLAGS)
2234- FFLAGS="-O0"
2235+ FFLAGS="$FFLAGS -O0"
2236 AC_SUBST(FFLAGS)
2237- CCASFLAGS="-O0"
2238+ CCASFLAGS="$CCASFLAGS -O0"
2239 AC_SUBST(CCASFLAGS)
2240 AC_MSG_NOTICE([gcov enabled, setting CFLAGS and friends to $CFLAGS])
2241 fi
2242@@ -325,3 +326,20 @@ AC_DEFUN([AG_GST_ARG_ENABLE_BROKEN],
2243 AC_MSG_NOTICE([not building broken plug-ins])
2244 ])
2245 ])
2246+
2247+dnl allow people (or build tools) to override default behaviour
2248+dnl for fatal compiler warnings
2249+AC_DEFUN([AG_GST_ARG_DISABLE_FATAL_WARNINGS],
2250+[
2251+ AC_ARG_ENABLE(fatal-warnings,
2252+ AC_HELP_STRING([--disable-fatal-warnings],
2253+ [Don't turn compiler warnings into fatal errors]),
2254+ [
2255+ case "${enableval}" in
2256+ yes) FATAL_WARNINGS=yes ;;
2257+ no) FATAL_WARNINGS=no ;;
2258+ *) AC_MSG_ERROR(bad value ${enableval} for --disable-fatal-warnings) ;;
2259+ esac
2260+ ],
2261+ [FATAL_WARNINGS=$GST_GIT]) dnl Default value
2262+])
2263diff --git a/common/m4/gst-check.m4 b/common/m4/gst-check.m4
2264index 3fd3acf..f3f39b4 100644
2265--- a/common/m4/gst-check.m4
2266+++ b/common/m4/gst-check.m4
2267@@ -117,6 +117,38 @@ AC_DEFUN([AG_GST_CHECK_GST_CHECK],
2268 ])
2269
2270 dnl ===========================================================================
2271+dnl AG_GST_CHECK_UNINSTALLED_SETUP([ACTION-IF-UNINSTALLED], [ACTION-IF-NOT])
2272+dnl
2273+dnl ACTION-IF-UNINSTALLED (optional) extra actions to perform if the setup
2274+dnl is an uninstalled setup
2275+dnl ACTION-IF-NOT (optional) extra actions to perform if the setup
2276+dnl is not an uninstalled setup
2277+dnl ===========================================================================
2278+AC_DEFUN([AG_GST_CHECK_UNINSTALLED_SETUP],
2279+[
2280+ AC_MSG_CHECKING([whether this is an uninstalled GStreamer setup])
2281+ AC_CACHE_VAL(gst_cv_is_uninstalled_setup,[
2282+ gst_cv_is_uninstalled_setup=no
2283+ if (set -u; : $GST_PLUGIN_SYSTEM_PATH) 2>/dev/null ; then
2284+ if test -z "$GST_PLUGIN_SYSTEM_PATH" \
2285+ -a -n "$GST_PLUGIN_SCANNER" \
2286+ -a -n "$GST_PLUGIN_PATH" \
2287+ -a -n "$GST_REGISTRY" \
2288+ -a -n "$DYLD_LIBRARY_PATH" \
2289+ -a -n "$LD_LIBRARY_PATH"; then
2290+ gst_cv_is_uninstalled_setup=yes;
2291+ fi
2292+ fi
2293+ ])
2294+ AC_MSG_RESULT($gst_cv_is_uninstalled_setup)
2295+ if test "x$gst_cv_is_uninstalled_setup" = "xyes"; then
2296+ ifelse([$1], , :, [$1])
2297+ else
2298+ ifelse([$2], , :, [$2])
2299+ fi
2300+])
2301+
2302+dnl ===========================================================================
2303 dnl AG_GST_CHECK_GST_PLUGINS_BASE([GST-MAJORMINOR], [MIN-VERSION], [REQUIRED])
2304 dnl
2305 dnl Sets GST_PLUGINS_BASE_CFLAGS and GST_PLUGINS_BASE_LIBS.
2306diff --git a/common/m4/gst-error.m4 b/common/m4/gst-error.m4
2307index f8f2364..e12a04c 100644
2308--- a/common/m4/gst-error.m4
2309+++ b/common/m4/gst-error.m4
2310@@ -196,6 +196,91 @@ AC_DEFUN([AG_GST_SET_ERROR_CXXFLAGS],
2311 AC_MSG_NOTICE([set ERROR_CXXFLAGS to $ERROR_CXXFLAGS])
2312 ])
2313
2314+dnl Sets WARNING_OBJCFLAGS and ERROR_OBJCFLAGS to something the compiler
2315+dnl will accept and AC_SUBST them so they are available in Makefile
2316+dnl
2317+dnl WARNING_OBJCFLAGS will contain flags to make the compiler emit more
2318+dnl warnings.
2319+dnl ERROR_OBJCFLAGS will contain flags to make those warnings fatal,
2320+dnl unless ADD-WERROR is set to "no"
2321+dnl
2322+dnl If MORE_FLAGS is set, tries to add each of the given flags
2323+dnl to WARNING_CFLAGS if the compiler supports them. Each flag is
2324+dnl tested separately.
2325+dnl
2326+dnl These flags can be overridden at make time:
2327+dnl make ERROR_OBJCFLAGS=
2328+AC_DEFUN([AG_GST_SET_ERROR_OBJCFLAGS],
2329+[
2330+ AC_REQUIRE([AC_PROG_OBJC])
2331+ AC_REQUIRE([AS_OBJC_COMPILER_FLAG])
2332+
2333+ ERROR_OBJCFLAGS=""
2334+ WARNING_OBJCFLAGS=""
2335+
2336+ dnl if we support -Wall, set it unconditionally
2337+ AS_OBJC_COMPILER_FLAG(-Wall, WARNING_OBJCFLAGS="$WARNING_OBJCFLAGS -Wall")
2338+
2339+ dnl if asked for, add -Werror if supported
2340+ if test "x$1" != "xno"
2341+ then
2342+ AS_OBJC_COMPILER_FLAG(-Werror, ERROR_OBJCFLAGS="$ERROR_OBJCFLAGS -Werror")
2343+
2344+ if test "x$ERROR_OBJCFLAGS" != "x"
2345+ then
2346+ dnl Add -fno-strict-aliasing for GLib versions before 2.19.8
2347+ dnl as before G_LOCK and friends caused strict aliasing compiler
2348+ dnl warnings.
2349+ PKG_CHECK_EXISTS([glib-2.0 < 2.19.8], [
2350+ AS_OBJC_COMPILER_FLAG([-fno-strict-aliasing],
2351+ ERROR_OBJCFLAGS="$ERROR_OBJCFLAGS -fno-strict-aliasing")
2352+ ])
2353+ else
2354+ dnl if -Werror isn't suported, try -errwarn=%all
2355+ AS_OBJC_COMPILER_FLAG([-errwarn=%all], ERROR_OBJCFLAGS="$ERROR_OBJCFLAGS -errwarn=%all")
2356+ if test "x$ERROR_OBJCFLAGS" != "x"; then
2357+ dnl try -errwarn=%all,no%E_EMPTY_DECLARATION,
2358+ dnl no%E_STATEMENT_NOT_REACHED,no%E_ARGUEMENT_MISMATCH,
2359+ dnl no%E_MACRO_REDEFINED (Sun Forte case)
2360+ dnl For Forte we need disable "empty declaration" warning produced by un-needed semicolon
2361+ dnl "statement not reached" disabled because there is g_assert_not_reached () in some places
2362+ dnl "macro redefined" because of gst/gettext.h
2363+ dnl FIXME: is it really supposed to be 'ARGUEMENT' and not 'ARGUMENT'?
2364+ dnl FIXME: do any of these work with the c++ compiler? if not, why
2365+ dnl do we check at all?
2366+ for f in 'no%E_EMPTY_DECLARATION' \
2367+ 'no%E_STATEMENT_NOT_REACHED' \
2368+ 'no%E_ARGUEMENT_MISMATCH' \
2369+ 'no%E_MACRO_REDEFINED' \
2370+ 'no%E_LOOP_NOT_ENTERED_AT_TOP'
2371+ do
2372+ AS_OBJC_COMPILER_FLAG([-errwarn=%all,$f], ERROR_OBJCFLAGS="$ERROR_OBJCFLAGS,$f")
2373+ done
2374+ fi
2375+ fi
2376+ fi
2377+
2378+ if test "x$2" != "x"
2379+ then
2380+ UNSUPPORTED=""
2381+ list="$2"
2382+ for each in $list
2383+ do
2384+ AS_OBJC_COMPILER_FLAG($each,
2385+ WARNING_OBJCFLAGS="$WARNING_OBJCFLAGS $each",
2386+ UNSUPPORTED="$UNSUPPORTED $each")
2387+ done
2388+ if test "X$UNSUPPORTED" != X ; then
2389+ AC_MSG_NOTICE([unsupported compiler flags: $UNSUPPORTED])
2390+ fi
2391+ fi
2392+
2393+ AC_SUBST(WARNING_OBJCFLAGS)
2394+ AC_SUBST(ERROR_OBJCFLAGS)
2395+ AC_MSG_NOTICE([set WARNING_OBJCFLAGS to $WARNING_OBJCFLAGS])
2396+ AC_MSG_NOTICE([set ERROR_OBJCFLAGS to $ERROR_OBJCFLAGS])
2397+])
2398+
2399 dnl Sets the default error level for debugging messages
2400 AC_DEFUN([AG_GST_SET_LEVEL_DEFAULT],
2401 [
2402diff --git a/common/m4/gst-feature.m4 b/common/m4/gst-feature.m4
2403index c072c79..cff7f30 100644
2404--- a/common/m4/gst-feature.m4
2405+++ b/common/m4/gst-feature.m4
2406@@ -232,10 +232,11 @@ AC_DEFUN([AG_GST_CHECK_GST_DEBUG_DISABLED],
2407 save_CFLAGS="$CFLAGS"
2408 CFLAGS="$GST_CFLAGS $CFLAGS"
2409 AC_COMPILE_IFELSE([
2410+ AC_LANG_SOURCE([[
2411 #include <gst/gstconfig.h>
2412 #ifdef GST_DISABLE_GST_DEBUG
2413 #error "debugging disabled, make compiler fail"
2414- #endif], [ debug_system_enabled=yes], [debug_system_enabled=no])
2415+ #endif]])], [ debug_system_enabled=yes], [debug_system_enabled=no])
2416 CFLAGS="$save_CFLAGS"
2417 AC_LANG_POP([C])
2418
2419diff --git a/common/m4/gst.m4 b/common/m4/gst.m4
2420index ddfde51..d4c53cb 100644
2421--- a/common/m4/gst.m4
2422+++ b/common/m4/gst.m4
2423@@ -3,10 +3,15 @@ dnl sets up use of GStreamer configure.ac macros
2424 dnl all GStreamer autoconf macros are prefixed
2425 dnl with AG_GST_ for public macros
2426 dnl with _AG_GST_ for private macros
2427+dnl
2428+dnl We call AC_CANONICAL_TARGET and AC_CANONICAL_HOST so that
2429+dnl it is valid before AC_ARG_PROGRAM is called
2430
2431 AC_DEFUN([AG_GST_INIT],
2432 [
2433 m4_pattern_forbid(^_?AG_GST_)
2434+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use host_ variables
2435+ AC_REQUIRE([AC_CANONICAL_TARGET]) dnl we use target_ variables
2436 ])
2437
2438 dnl AG_GST_PKG_CONFIG_PATH