summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Santos <thiago.sousa.santos@collabora.com>2013-03-18 14:39:45 -0300
committerThiago Santos <thiago.sousa.santos@collabora.com>2013-04-16 16:08:50 -0300
commit0278b69c8c737c66de3569a4c0b3e6f70e82da05 (patch)
tree6da7a8042fecc94d313ead199b5a6816cea69dc2
parent418efdd636c542ab52131ee3469956d13a4dbe42 (diff)
downloadgstreamer-plugins-bad-0278b69c8c737c66de3569a4c0b3e6f70e82da05.tar.gz
eglglessink: removing egl parts for common code
-rw-r--r--configure.ac4
-rw-r--r--ext/eglgles/Makefile.am4
-rw-r--r--ext/eglgles/gstegladaptation.c18
-rw-r--r--ext/eglgles/gstegladaptation.h70
-rw-r--r--ext/eglgles/gstegladaptation_eagl.m (renamed from ext/eglgles/gstegladaptation_ios.m)19
-rw-r--r--ext/eglgles/gstegladaptation_egl.c (renamed from ext/eglgles/gstegladaptation_pc.c)105
-rw-r--r--ext/eglgles/gsteglglessink.c6
-rw-r--r--ext/eglgles/gsteglglessink.h6
8 files changed, 129 insertions, 103 deletions
diff --git a/configure.ac b/configure.ac
index 5b6a1a9c0..29b10a6f7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -671,9 +671,7 @@ case "$host" in
;;
esac
HAVE_IOS="no"
-if test "x$HAVE_APPLE_MEDIA" = "xyes"; then
- AC_CHECK_HEADER(MobileCoreServices/MobileCoreServices.h, HAVE_IOS="yes", HAVE_IOS="no", [-])
-fi
+AC_CHECK_HEADER(MobileCoreServices/MobileCoreServices.h, HAVE_IOS="yes", HAVE_IOS="no", [-])
AM_CONDITIONAL(HAVE_IOS, test "x$HAVE_IOS" = "xyes")
if test "x$HAVE_IOS" = "xyes"; then
diff --git a/ext/eglgles/Makefile.am b/ext/eglgles/Makefile.am
index 9d50f949a..ad1e17915 100644
--- a/ext/eglgles/Makefile.am
+++ b/ext/eglgles/Makefile.am
@@ -1,9 +1,9 @@
plugin_LTLIBRARIES = libgsteglglessink.la
if HAVE_IOS
-DISTRO_SRC = gstegladaptation_ios.m
+DISTRO_SRC = gstegladaptation_eagl.m
else
-DISTRO_SRC = gstegladaptation_pc.c
+DISTRO_SRC = gstegladaptation_egl.c
endif
libgsteglglessink_la_SOURCES = gsteglglessink.c video_platform_wrapper.c gstegladaptation.c $(DISTRO_SRC)
diff --git a/ext/eglgles/gstegladaptation.c b/ext/eglgles/gstegladaptation.c
index e075ea9f5..585fbc046 100644
--- a/ext/eglgles/gstegladaptation.c
+++ b/ext/eglgles/gstegladaptation.c
@@ -45,6 +45,22 @@
#include <gst/video/video.h>
#include "gstegladaptation.h"
+/*
+ * GstEglGlesImageFmt:
+ * @fmt: Internal identifier for the EGL attribs / GST caps pairing
+ * @attribs: Pointer to the set of EGL attributes asociated with this format
+ * @caps: Pointer to the GST caps asociated with this format
+ *
+ * This struct holds a pairing between GST caps and the matching EGL attributes
+ * associated with a given pixel format
+ */
+struct _GstEglGlesImageFmt
+{
+ gint fmt; /* Private identifier */
+ const EGLint *attribs; /* EGL Attributes */
+ GstCaps *caps; /* Matching caps for the attribs */
+};
+
/* GLESv2 GLSL Shaders
*
* OpenGL ES Standard does not mandate YUV support. This is
@@ -302,6 +318,8 @@ gst_egl_adaptation_context_new (GstElement * element)
ctx->element = gst_object_ref (element);
+ gst_egl_adaptation_context_init (ctx);
+
return ctx;
}
diff --git a/ext/eglgles/gstegladaptation.h b/ext/eglgles/gstegladaptation.h
index 4aca04d5d..917dd03b3 100644
--- a/ext/eglgles/gstegladaptation.h
+++ b/ext/eglgles/gstegladaptation.h
@@ -45,11 +45,18 @@
#ifndef __GST_EGL_ADAPTATION_H__
#define __GST_EGL_ADAPTATION_H__
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <gst/gst.h>
+
+#ifndef HAVE_IOS
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
+#endif
#ifdef USE_EGL_RPI
#include <bcm_host.h>
@@ -79,6 +86,7 @@ static const EGLint eglglessink_RGBA8888_attribs[] = {
typedef struct GstEglAdaptationContext GstEglAdaptationContext;
typedef struct _GstEglGlesRenderContext GstEglGlesRenderContext;
typedef struct _GstEglGlesImageFmt GstEglGlesImageFmt;
+typedef struct _GstEaglContext GstEaglContext;
typedef struct _coord5
{
@@ -90,58 +98,6 @@ typedef struct _coord5
} coord5;
/*
- * GstEglGlesRenderContext:
- * @config: Current EGL config
- * @eglcontext: Current EGL context
- * @display: Current EGL display connection
- * @window: Current EGL window asociated with the display connection
- * @used_window: Last seen EGL window asociated with the display connection
- * @surface: EGL surface the sink is rendering into
- * @fragshader: Fragment shader
- * @vertshader: Vertex shader
- * @glslprogram: Compiled and linked GLSL program in use for rendering
- * @texture Texture units in use
- * @pixel_aspect_ratio: EGL display aspect ratio
- * @egl_minor: EGL version (minor)
- * @egl_major: EGL version (major)
- * @n_textures: Texture units count
- * @position_loc: Index of the position vertex attribute array
- * @texpos_loc: Index of the textpos vertex attribute array
- * @position_array: VBO position array
- * @texpos_array: VBO texpos array
- * @index_array: VBO index array
- * @position_buffer: Position buffer object name
- * @texpos_buffer: Texpos buffer object name
- * @index_buffer: Index buffer object name
- *
- * This struct holds the sink's EGL/GLES rendering context.
- */
-struct _GstEglGlesRenderContext
-{
- EGLConfig config;
- EGLContext eglcontext;
- EGLSurface surface;
- EGLint egl_minor, egl_major;
-};
-
-/*
- * GstEglGlesImageFmt:
- * @fmt: Internal identifier for the EGL attribs / GST caps pairing
- * @attribs: Pointer to the set of EGL attributes asociated with this format
- * @caps: Pointer to the GST caps asociated with this format
- *
- * This struct holds a pairing between GST caps and the matching EGL attributes
- * associated with a given pixel format
- */
-struct _GstEglGlesImageFmt
-{
- gint fmt; /* Private identifier */
- const EGLint *attribs; /* EGL Attributes */
- GstCaps *caps; /* Matching caps for the attribs */
-};
-
-
-/*
* GstEglAdaptationContext:
* @have_vbo: Set if the GLES VBO setup has been performed
* @have_texture: Set if the GLES texture setup has been performed
@@ -183,16 +139,16 @@ struct GstEglAdaptationContext
coord5 position_array[12]; /* 4 x Frame, 4 x Border1, 4 x Border2 */
unsigned short index_array[4];
-#if USE_IOS
- EAGLContext *eagl_context;
- GLUint framebuffer;
- GLUint color_renderbuffer;
+#if HAVE_IOS
+ GstEaglContext *eaglctx;
#else
- GstEglGlesRenderContext eglglesctx;
+ GstEglGlesRenderContext *eglglesctx;
#endif
};
GstEglAdaptationContext * gst_egl_adaptation_context_new (GstElement * element);
+void gst_egl_adaptation_context_init (GstEglAdaptationContext * ctx);
+void gst_egl_adaptation_context_deinit (GstEglAdaptationContext * ctx);
void gst_egl_adaptation_context_free (GstEglAdaptationContext * ctx);
/* platform window */
diff --git a/ext/eglgles/gstegladaptation_ios.m b/ext/eglgles/gstegladaptation_eagl.m
index e4eb5576a..55c0a23fc 100644
--- a/ext/eglgles/gstegladaptation_ios.m
+++ b/ext/eglgles/gstegladaptation_eagl.m
@@ -42,6 +42,25 @@
* Boston, MA 02111-1307, USA.
*/
+typedef struct _GstEaglContext
+{
+ EAGLContext *eagl_context;
+ GLUint framebuffer;
+ GLUint color_renderbuffer;
+} GstEaglContext;
+
+void
+gst_egl_adaptation_context_init (GstEglAdaptationContext * ctx)
+{
+ ctx->eaglctx = g_new0 (GstEaglContext, 1);
+}
+
+void
+gst_egl_adaptation_context_deinit (GstEglAdaptationContext * ctx)
+{
+ g_free (ctx->eaglctx);
+}
+
gboolean
gst_egl_adaptation_init_display (GstEglAdaptationContext * ctx)
{
diff --git a/ext/eglgles/gstegladaptation_pc.c b/ext/eglgles/gstegladaptation_egl.c
index 1ece48bb6..25dda61b7 100644
--- a/ext/eglgles/gstegladaptation_pc.c
+++ b/ext/eglgles/gstegladaptation_egl.c
@@ -46,6 +46,41 @@
#include "video_platform_wrapper.h"
+/*
+ * GstEglGlesRenderContext:
+ * @config: Current EGL config
+ * @eglcontext: Current EGL context
+ * @display: Current EGL display connection
+ * @window: Current EGL window asociated with the display connection
+ * @used_window: Last seen EGL window asociated with the display connection
+ * @surface: EGL surface the sink is rendering into
+ * @fragshader: Fragment shader
+ * @vertshader: Vertex shader
+ * @glslprogram: Compiled and linked GLSL program in use for rendering
+ * @texture Texture units in use
+ * @pixel_aspect_ratio: EGL display aspect ratio
+ * @egl_minor: EGL version (minor)
+ * @egl_major: EGL version (major)
+ * @n_textures: Texture units count
+ * @position_loc: Index of the position vertex attribute array
+ * @texpos_loc: Index of the textpos vertex attribute array
+ * @position_array: VBO position array
+ * @texpos_array: VBO texpos array
+ * @index_array: VBO index array
+ * @position_buffer: Position buffer object name
+ * @texpos_buffer: Texpos buffer object name
+ * @index_buffer: Index buffer object name
+ *
+ * This struct holds the sink's EGL/GLES rendering context.
+ */
+struct _GstEglGlesRenderContext
+{
+ EGLConfig config;
+ EGLContext eglcontext;
+ EGLSurface surface;
+ EGLint egl_minor, egl_major;
+};
+
/* Some EGL implementations are reporting wrong
* values for the display's EGL_PIXEL_ASPECT_RATIO.
* They are required by the khronos specs to report
@@ -82,7 +117,7 @@ gst_egl_adaptation_init_display (GstEglAdaptationContext * ctx)
ctx->display = display;
if (!eglInitialize (display,
- &ctx->eglglesctx.egl_major, &ctx->eglglesctx.egl_minor)) {
+ &ctx->eglglesctx->egl_major, &ctx->eglglesctx->egl_minor)) {
got_egl_error ("eglInitialize");
GST_ERROR_OBJECT (ctx->element, "Could not init EGL display connection");
goto HANDLE_EGL_ERROR;
@@ -91,15 +126,15 @@ gst_egl_adaptation_init_display (GstEglAdaptationContext * ctx)
/* Check against required EGL version
* XXX: Need to review the version requirement in terms of the needed API
*/
- if (ctx->eglglesctx.egl_major < GST_EGLGLESSINK_EGL_MIN_VERSION) {
+ if (ctx->eglglesctx->egl_major < GST_EGLGLESSINK_EGL_MIN_VERSION) {
GST_ERROR_OBJECT (ctx->element, "EGL v%d needed, but you only have v%d.%d",
- GST_EGLGLESSINK_EGL_MIN_VERSION, ctx->eglglesctx.egl_major,
- ctx->eglglesctx.egl_minor);
+ GST_EGLGLESSINK_EGL_MIN_VERSION, ctx->eglglesctx->egl_major,
+ ctx->eglglesctx->egl_minor);
goto HANDLE_ERROR;
}
GST_INFO_OBJECT (ctx->element, "System reports supported EGL version v%d.%d",
- ctx->eglglesctx.egl_major, ctx->eglglesctx.egl_minor);
+ ctx->eglglesctx->egl_major, ctx->eglglesctx->egl_minor);
eglBindAPI (EGL_OPENGL_ES_API);
@@ -132,7 +167,7 @@ _gst_egl_choose_config (GstEglAdaptationContext * ctx, gboolean try_only,
EGLConfig *config = NULL;
if (!try_only)
- config = &ctx->eglglesctx.config;
+ config = &ctx->eglglesctx->config;
ret = eglChooseConfig (ctx->display,
eglglessink_RGBA8888_attribs, config, 1, &cfg_number) != EGL_FALSE;
@@ -147,16 +182,16 @@ gst_egl_adaptation_create_egl_context (GstEglAdaptationContext * ctx)
{
EGLint con_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
- ctx->eglglesctx.eglcontext =
+ ctx->eglglesctx->eglcontext =
eglCreateContext (ctx->display,
- ctx->eglglesctx.config, EGL_NO_CONTEXT, con_attribs);
+ ctx->eglglesctx->config, EGL_NO_CONTEXT, con_attribs);
- if (ctx->eglglesctx.eglcontext == EGL_NO_CONTEXT) {
+ if (ctx->eglglesctx->eglcontext == EGL_NO_CONTEXT) {
return FALSE;
}
GST_DEBUG_OBJECT (ctx->element, "EGL Context: %p",
- ctx->eglglesctx.eglcontext);
+ ctx->eglglesctx->eglcontext);
return TRUE;
}
@@ -167,10 +202,10 @@ gst_egl_adaptation_context_make_current (GstEglAdaptationContext * ctx,
{
g_assert (ctx->display != NULL);
- if (bind && ctx->eglglesctx.surface && ctx->eglglesctx.eglcontext) {
+ if (bind && ctx->eglglesctx->surface && ctx->eglglesctx->eglcontext) {
EGLContext *cur_ctx = eglGetCurrentContext ();
- if (cur_ctx == ctx->eglglesctx.eglcontext) {
+ if (cur_ctx == ctx->eglglesctx->eglcontext) {
GST_DEBUG_OBJECT (ctx->element,
"Already attached the context to thread %p", g_thread_self ());
return TRUE;
@@ -179,8 +214,8 @@ gst_egl_adaptation_context_make_current (GstEglAdaptationContext * ctx,
GST_DEBUG_OBJECT (ctx->element, "Attaching context to thread %p",
g_thread_self ());
if (!eglMakeCurrent (ctx->display,
- ctx->eglglesctx.surface, ctx->eglglesctx.surface,
- ctx->eglglesctx.eglcontext)) {
+ ctx->eglglesctx->surface, ctx->eglglesctx->surface,
+ ctx->eglglesctx->eglcontext)) {
got_egl_error ("eglMakeCurrent");
GST_ERROR_OBJECT (ctx->element, "Couldn't bind context");
return FALSE;
@@ -202,11 +237,11 @@ gst_egl_adaptation_context_make_current (GstEglAdaptationContext * ctx,
gboolean
gst_egl_adaptation_create_surface (GstEglAdaptationContext * ctx)
{
- ctx->eglglesctx.surface =
+ ctx->eglglesctx->surface =
eglCreateWindowSurface (ctx->display,
- ctx->eglglesctx.config, ctx->used_window, NULL);
+ ctx->eglglesctx->config, ctx->used_window, NULL);
- if (ctx->eglglesctx.surface == EGL_NO_SURFACE) {
+ if (ctx->eglglesctx->surface == EGL_NO_SURFACE) {
got_egl_error ("eglCreateWindowSurface");
GST_ERROR_OBJECT (ctx->element, "Can't create surface");
return FALSE;
@@ -221,7 +256,7 @@ gst_egl_adaptation_query_buffer_preserved (GstEglAdaptationContext * ctx)
ctx->buffer_preserved = FALSE;
if (eglQuerySurface (ctx->display,
- ctx->eglglesctx.surface, EGL_SWAP_BEHAVIOR, &swap_behavior)) {
+ ctx->eglglesctx->surface, EGL_SWAP_BEHAVIOR, &swap_behavior)) {
GST_DEBUG_OBJECT (ctx->element, "Buffer swap behavior %x", swap_behavior);
ctx->buffer_preserved = swap_behavior == EGL_BUFFER_PRESERVED;
} else {
@@ -243,13 +278,13 @@ gst_egl_adaptation_query_par (GstEglAdaptationContext * ctx)
* or some other one time check. Right now it's being called once
* per frame.
*/
- if (ctx->eglglesctx.egl_major == 1 && ctx->eglglesctx.egl_minor < 2) {
+ if (ctx->eglglesctx->egl_major == 1 && ctx->eglglesctx->egl_minor < 2) {
GST_DEBUG_OBJECT (ctx->element, "Can't query PAR. Using default: %dx%d",
EGL_DISPLAY_SCALING, EGL_DISPLAY_SCALING);
ctx->pixel_aspect_ratio = EGL_DISPLAY_SCALING;
} else {
eglQuerySurface (ctx->display,
- ctx->eglglesctx.surface, EGL_PIXEL_ASPECT_RATIO, &display_par);
+ ctx->eglglesctx->surface, EGL_PIXEL_ASPECT_RATIO, &display_par);
/* Fix for outbound DAR reporting on some implementations not
* honoring the 'should return w/h * EGL_DISPLAY_SCALING' spec
* requirement
@@ -276,8 +311,8 @@ gst_egl_adaptation_context_update_surface_dimensions (GstEglAdaptationContext *
gint width, height;
/* Save surface dims */
- eglQuerySurface (ctx->display, ctx->eglglesctx.surface, EGL_WIDTH, &width);
- eglQuerySurface (ctx->display, ctx->eglglesctx.surface, EGL_HEIGHT, &height);
+ eglQuerySurface (ctx->display, ctx->eglglesctx->surface, EGL_WIDTH, &width);
+ eglQuerySurface (ctx->display, ctx->eglglesctx->surface, EGL_HEIGHT, &height);
if (width != ctx->surface_width || height != ctx->surface_height) {
ctx->surface_width = width;
@@ -315,9 +350,9 @@ gst_egl_adaptation_context_init_egl_exts (GstEglAdaptationContext * ctx)
void
gst_egl_adaptation_destroy_surface (GstEglAdaptationContext * ctx)
{
- if (ctx->eglglesctx.surface) {
- eglDestroySurface (ctx->display, ctx->eglglesctx.surface);
- ctx->eglglesctx.surface = NULL;
+ if (ctx->eglglesctx->surface) {
+ eglDestroySurface (ctx->display, ctx->eglglesctx->surface);
+ ctx->eglglesctx->surface = NULL;
ctx->have_surface = FALSE;
}
}
@@ -325,9 +360,9 @@ gst_egl_adaptation_destroy_surface (GstEglAdaptationContext * ctx)
void
gst_egl_adaptation_destroy_context (GstEglAdaptationContext * ctx)
{
- if (ctx->eglglesctx.eglcontext) {
- eglDestroyContext (ctx->display, ctx->eglglesctx.eglcontext);
- ctx->eglglesctx.eglcontext = NULL;
+ if (ctx->eglglesctx->eglcontext) {
+ eglDestroyContext (ctx->display, ctx->eglglesctx->eglcontext);
+ ctx->eglglesctx->eglcontext = NULL;
}
}
@@ -340,7 +375,7 @@ gst_egl_adaptation_context_bind_API (GstEglAdaptationContext * ctx)
gboolean
gst_egl_adaptation_context_swap_buffers (GstEglAdaptationContext * ctx)
{
- gboolean ret = eglSwapBuffers (ctx->display, ctx->eglglesctx.surface);
+ gboolean ret = eglSwapBuffers (ctx->display, ctx->eglglesctx->surface);
if (ret == EGL_FALSE) {
got_egl_error ("eglSwapBuffers");
}
@@ -362,3 +397,15 @@ gst_egl_adaptation_destroy_native_window (GstEglAdaptationContext * ctx,
own_window_data);
ctx->used_window = 0;
}
+
+void
+gst_egl_adaptation_context_init (GstEglAdaptationContext * ctx)
+{
+ ctx->eglglesctx = g_new0 (GstEglGlesRenderContext, 1);
+}
+
+void
+gst_egl_adaptation_context_deinit (GstEglAdaptationContext * ctx)
+{
+ g_free (ctx->eglglesctx);
+}
diff --git a/ext/eglgles/gsteglglessink.c b/ext/eglgles/gsteglglessink.c
index 3d34dbba1..22d1353a9 100644
--- a/ext/eglgles/gsteglglessink.c
+++ b/ext/eglgles/gsteglglessink.c
@@ -118,11 +118,6 @@
#include <gst/video/gstvideosink.h>
#include <gst/interfaces/xoverlay.h>
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
#ifdef USE_EGL_RPI
#include <bcm_host.h>
#endif
@@ -132,7 +127,6 @@
GST_DEBUG_CATEGORY_STATIC (gst_eglglessink_debug);
#define GST_CAT_DEFAULT gst_eglglessink_debug
-
/* Input capabilities. */
static GstStaticPadTemplate gst_eglglessink_sink_template_factory =
GST_STATIC_PAD_TEMPLATE ("sink",
diff --git a/ext/eglgles/gsteglglessink.h b/ext/eglgles/gsteglglessink.h
index 899d45336..9733f1e4b 100644
--- a/ext/eglgles/gsteglglessink.h
+++ b/ext/eglgles/gsteglglessink.h
@@ -50,11 +50,6 @@
#include <gst/video/gstvideosink.h>
#include <gst/base/gstdataqueue.h>
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
#include "gstegladaptation.h"
G_BEGIN_DECLS
@@ -80,7 +75,6 @@ typedef struct _GstEglGlesSinkClass GstEglGlesSinkClass;
* @sinkcaps: Full set of suported caps
* @current_caps: Current caps
* @rendering_path: Rendering path (Slow/Fast)
- * @eglglesctx: Pointer to the associated EGL/GLESv2 rendering context
* @flow_lock: Simple concurrent access ward to the sink's runtime state
* @have_window: Set if the sink has access to a window to hold it's canvas
* @using_own_window: Set if the sink created its own window