summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Santos <thiago.sousa.santos@collabora.com>2013-03-19 10:11:56 -0300
committerThiago Santos <thiago.sousa.santos@collabora.com>2013-04-16 16:08:50 -0300
commit6b0aaa95a47a71b7ab7af93d24cbed91b43e3756 (patch)
tree8109ed8e45503a21b7928c9a9dd2679999d8df93
parent0278b69c8c737c66de3569a4c0b3e6f70e82da05 (diff)
downloadgstreamer-plugins-bad-6b0aaa95a47a71b7ab7af93d24cbed91b43e3756.tar.gz
egladaptation: remove the egl display/window variables from main code
Keep it separated for egl/eagl as those use different data types for displays/windows
-rw-r--r--ext/eglgles/gstegladaptation.c7
-rw-r--r--ext/eglgles/gstegladaptation.h8
-rw-r--r--ext/eglgles/gstegladaptation_egl.c77
-rw-r--r--ext/eglgles/gsteglglessink.c31
4 files changed, 71 insertions, 52 deletions
diff --git a/ext/eglgles/gstegladaptation.c b/ext/eglgles/gstegladaptation.c
index 585fbc046..e272730c2 100644
--- a/ext/eglgles/gstegladaptation.c
+++ b/ext/eglgles/gstegladaptation.c
@@ -709,13 +709,6 @@ got_gl_error (const char *wtf)
return FALSE;
}
-void
-gst_egl_adaptation_context_set_window (GstEglAdaptationContext * ctx,
- EGLNativeWindowType window)
-{
- ctx->window = window;
-}
-
GLuint
gst_egl_adaptation_context_get_texture (GstEglAdaptationContext * ctx, gint i)
{
diff --git a/ext/eglgles/gstegladaptation.h b/ext/eglgles/gstegladaptation.h
index 917dd03b3..b020ca585 100644
--- a/ext/eglgles/gstegladaptation.h
+++ b/ext/eglgles/gstegladaptation.h
@@ -63,7 +63,6 @@
#endif
#include <gst/video/video.h>
-#include "video_platform_wrapper.h"
#define GST_EGLGLESSINK_IMAGE_NOFMT 0
#define GST_EGLGLESSINK_IMAGE_RGB888 1
@@ -111,9 +110,6 @@ struct GstEglAdaptationContext
{
GstElement *element;
- EGLNativeWindowType window, used_window;
- EGLDisplay display;
-
unsigned int position_buffer, index_buffer;
gboolean have_vbo;
@@ -175,7 +171,9 @@ void gst_egl_adaptation_context_bind_API (GstEglAdaptationContext * ctx);
gboolean gst_egl_adaptation_context_swap_buffers (GstEglAdaptationContext * ctx);
/* get/set */
-void gst_egl_adaptation_context_set_window (GstEglAdaptationContext * ctx, EGLNativeWindowType window);
+void gst_egl_adaptation_context_set_window (GstEglAdaptationContext * ctx, guintptr window);
+void gst_egl_adaptation_context_update_used_window (GstEglAdaptationContext * ctx);
+guintptr gst_egl_adaptation_context_get_window (GstEglAdaptationContext * ctx);
GLuint gst_egl_adaptation_context_get_texture (GstEglAdaptationContext * ctx, gint i);
gint gst_egl_adaptation_context_get_surface_width (GstEglAdaptationContext * ctx);
gint gst_egl_adaptation_context_get_surface_height (GstEglAdaptationContext * ctx);
diff --git a/ext/eglgles/gstegladaptation_egl.c b/ext/eglgles/gstegladaptation_egl.c
index 25dda61b7..4fe3ce28e 100644
--- a/ext/eglgles/gstegladaptation_egl.c
+++ b/ext/eglgles/gstegladaptation_egl.c
@@ -79,6 +79,10 @@ struct _GstEglGlesRenderContext
EGLContext eglcontext;
EGLSurface surface;
EGLint egl_minor, egl_major;
+
+ EGLNativeWindowType window, used_window;
+ EGLDisplay display;
+
};
/* Some EGL implementations are reporting wrong
@@ -114,7 +118,7 @@ gst_egl_adaptation_init_display (GstEglAdaptationContext * ctx)
GST_ERROR_OBJECT (ctx->element, "Could not get EGL display connection");
goto HANDLE_ERROR; /* No EGL error is set by eglGetDisplay() */
}
- ctx->display = display;
+ ctx->eglglesctx->display = display;
if (!eglInitialize (display,
&ctx->eglglesctx->egl_major, &ctx->eglglesctx->egl_minor)) {
@@ -151,9 +155,9 @@ HANDLE_ERROR:
void
gst_egl_adaptation_context_terminate_display (GstEglAdaptationContext * ctx)
{
- if (ctx->display) {
- eglTerminate (ctx->display);
- ctx->display = NULL;
+ if (ctx->eglglesctx->display) {
+ eglTerminate (ctx->eglglesctx->display);
+ ctx->eglglesctx->display = NULL;
}
}
@@ -169,7 +173,7 @@ _gst_egl_choose_config (GstEglAdaptationContext * ctx, gboolean try_only,
if (!try_only)
config = &ctx->eglglesctx->config;
- ret = eglChooseConfig (ctx->display,
+ ret = eglChooseConfig (ctx->eglglesctx->display,
eglglessink_RGBA8888_attribs, config, 1, &cfg_number) != EGL_FALSE;
if (num_configs)
@@ -183,7 +187,7 @@ gst_egl_adaptation_create_egl_context (GstEglAdaptationContext * ctx)
EGLint con_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
ctx->eglglesctx->eglcontext =
- eglCreateContext (ctx->display,
+ eglCreateContext (ctx->eglglesctx->display,
ctx->eglglesctx->config, EGL_NO_CONTEXT, con_attribs);
if (ctx->eglglesctx->eglcontext == EGL_NO_CONTEXT) {
@@ -200,7 +204,7 @@ gboolean
gst_egl_adaptation_context_make_current (GstEglAdaptationContext * ctx,
gboolean bind)
{
- g_assert (ctx->display != NULL);
+ g_assert (ctx->eglglesctx->display != NULL);
if (bind && ctx->eglglesctx->surface && ctx->eglglesctx->eglcontext) {
EGLContext *cur_ctx = eglGetCurrentContext ();
@@ -213,7 +217,7 @@ 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,
+ if (!eglMakeCurrent (ctx->eglglesctx->display,
ctx->eglglesctx->surface, ctx->eglglesctx->surface,
ctx->eglglesctx->eglcontext)) {
got_egl_error ("eglMakeCurrent");
@@ -223,7 +227,7 @@ gst_egl_adaptation_context_make_current (GstEglAdaptationContext * ctx,
} else {
GST_DEBUG_OBJECT (ctx->element, "Detaching context from thread %p",
g_thread_self ());
- if (!eglMakeCurrent (ctx->display, EGL_NO_SURFACE,
+ if (!eglMakeCurrent (ctx->eglglesctx->display, EGL_NO_SURFACE,
EGL_NO_SURFACE, EGL_NO_CONTEXT)) {
got_egl_error ("eglMakeCurrent");
GST_ERROR_OBJECT (ctx->element, "Couldn't unbind context");
@@ -238,8 +242,8 @@ gboolean
gst_egl_adaptation_create_surface (GstEglAdaptationContext * ctx)
{
ctx->eglglesctx->surface =
- eglCreateWindowSurface (ctx->display,
- ctx->eglglesctx->config, ctx->used_window, NULL);
+ eglCreateWindowSurface (ctx->eglglesctx->display,
+ ctx->eglglesctx->config, ctx->eglglesctx->used_window, NULL);
if (ctx->eglglesctx->surface == EGL_NO_SURFACE) {
got_egl_error ("eglCreateWindowSurface");
@@ -255,7 +259,7 @@ gst_egl_adaptation_query_buffer_preserved (GstEglAdaptationContext * ctx)
EGLint swap_behavior;
ctx->buffer_preserved = FALSE;
- if (eglQuerySurface (ctx->display,
+ if (eglQuerySurface (ctx->eglglesctx->display,
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;
@@ -283,7 +287,7 @@ gst_egl_adaptation_query_par (GstEglAdaptationContext * ctx)
EGL_DISPLAY_SCALING, EGL_DISPLAY_SCALING);
ctx->pixel_aspect_ratio = EGL_DISPLAY_SCALING;
} else {
- eglQuerySurface (ctx->display,
+ eglQuerySurface (ctx->eglglesctx->display,
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
@@ -311,8 +315,10 @@ 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->eglglesctx->display, ctx->eglglesctx->surface,
+ EGL_WIDTH, &width);
+ eglQuerySurface (ctx->eglglesctx->display, ctx->eglglesctx->surface,
+ EGL_HEIGHT, &height);
if (width != ctx->surface_width || height != ctx->surface_height) {
ctx->surface_width = width;
@@ -336,7 +342,7 @@ gst_egl_adaptation_context_init_egl_exts (GstEglAdaptationContext * ctx)
const char *eglexts;
unsigned const char *glexts;
- eglexts = eglQueryString (ctx->display, EGL_EXTENSIONS);
+ eglexts = eglQueryString (ctx->eglglesctx->display, EGL_EXTENSIONS);
glexts = glGetString (GL_EXTENSIONS);
GST_DEBUG_OBJECT (ctx->element, "Available EGL extensions: %s\n",
@@ -351,7 +357,7 @@ void
gst_egl_adaptation_destroy_surface (GstEglAdaptationContext * ctx)
{
if (ctx->eglglesctx->surface) {
- eglDestroySurface (ctx->display, ctx->eglglesctx->surface);
+ eglDestroySurface (ctx->eglglesctx->display, ctx->eglglesctx->surface);
ctx->eglglesctx->surface = NULL;
ctx->have_surface = FALSE;
}
@@ -361,7 +367,7 @@ void
gst_egl_adaptation_destroy_context (GstEglAdaptationContext * ctx)
{
if (ctx->eglglesctx->eglcontext) {
- eglDestroyContext (ctx->display, ctx->eglglesctx->eglcontext);
+ eglDestroyContext (ctx->eglglesctx->display, ctx->eglglesctx->eglcontext);
ctx->eglglesctx->eglcontext = NULL;
}
}
@@ -375,7 +381,8 @@ 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->eglglesctx->display, ctx->eglglesctx->surface);
if (ret == EGL_FALSE) {
got_egl_error ("eglSwapBuffers");
}
@@ -386,16 +393,21 @@ gboolean
gst_egl_adaptation_create_native_window (GstEglAdaptationContext * ctx,
gint width, gint height, gpointer * own_window_data)
{
- return platform_create_native_window (width, height, own_window_data);
+ EGLNativeWindowType window =
+ platform_create_native_window (width, height, own_window_data);
+ if (window)
+ gst_egl_adaptation_context_set_window (ctx, window);
+ GST_DEBUG_OBJECT (ctx->element, "Using window handle %p", window);
+ return window != 0;
}
void
gst_egl_adaptation_destroy_native_window (GstEglAdaptationContext * ctx,
gpointer * own_window_data)
{
- platform_destroy_native_window (ctx->display, ctx->used_window,
- own_window_data);
- ctx->used_window = 0;
+ platform_destroy_native_window (ctx->eglglesctx->display,
+ ctx->eglglesctx->used_window, own_window_data);
+ ctx->eglglesctx->used_window = 0;
}
void
@@ -409,3 +421,22 @@ gst_egl_adaptation_context_deinit (GstEglAdaptationContext * ctx)
{
g_free (ctx->eglglesctx);
}
+
+void
+gst_egl_adaptation_context_set_window (GstEglAdaptationContext * ctx,
+ guintptr window)
+{
+ ctx->eglglesctx->window = (EGLNativeWindowType) window;
+}
+
+void
+gst_egl_adaptation_context_update_used_window (GstEglAdaptationContext * ctx)
+{
+ ctx->eglglesctx->used_window = ctx->eglglesctx->window;
+}
+
+guintptr
+gst_egl_adaptation_context_get_window (GstEglAdaptationContext * ctx)
+{
+ return ctx->eglglesctx->window;
+}
diff --git a/ext/eglgles/gsteglglessink.c b/ext/eglgles/gsteglglessink.c
index 22d1353a9..65635330b 100644
--- a/ext/eglgles/gsteglglessink.c
+++ b/ext/eglgles/gsteglglessink.c
@@ -183,7 +183,7 @@ static void gst_eglglessink_set_render_rectangle (GstXOverlay * overlay, gint x,
gint y, gint width, gint height);
/* Utility */
-static EGLNativeWindowType gst_eglglessink_create_window (GstEglGlesSink *
+static gboolean gst_eglglessink_create_window (GstEglGlesSink *
eglglessink, gint width, gint height);
static gboolean gst_eglglessink_setup_vbo (GstEglGlesSink * eglglessink,
gboolean reset);
@@ -401,7 +401,6 @@ gst_eglglessink_stop (GstEglGlesSink * eglglessink)
&eglglessink->own_window_data);
eglglessink->have_window = FALSE;
}
- eglglessink->egl_context->used_window = 0;
if (eglglessink->current_caps) {
gst_caps_unref (eglglessink->current_caps);
eglglessink->current_caps = NULL;
@@ -432,27 +431,26 @@ gst_eglglessink_implements_init (GstImplementsInterfaceClass * klass)
klass->supported = gst_eglglessink_interface_supported;
}
-static EGLNativeWindowType
+static gboolean
gst_eglglessink_create_window (GstEglGlesSink * eglglessink, gint width,
gint height)
{
- EGLNativeWindowType window = 0;
+ gboolean ret;
if (!eglglessink->create_window) {
GST_ERROR_OBJECT (eglglessink, "This sink can't create a window by itself");
- return window;
+ return FALSE;
} else
GST_INFO_OBJECT (eglglessink, "Attempting internal window creation");
- window =
+ ret =
gst_egl_adaptation_create_native_window (eglglessink->egl_context, width,
height, &eglglessink->own_window_data);
- if (!window) {
+ if (!ret) {
GST_ERROR_OBJECT (eglglessink, "Could not create window");
- return window;
}
- return window;
+ return ret;
}
static void
@@ -642,7 +640,7 @@ gst_eglglessink_set_window_handle (GstXOverlay * overlay, guintptr id)
/* OK, we have a new window */
GST_OBJECT_LOCK (eglglessink);
- eglglessink->egl_context->window = (EGLNativeWindowType) id;
+ gst_egl_adaptation_context_set_window (eglglessink->egl_context, id);
eglglessink->have_window = ((gpointer) id != NULL);
GST_OBJECT_UNLOCK (eglglessink);
@@ -1057,6 +1055,7 @@ gst_eglglessink_configure_caps (GstEglGlesSink * eglglessink, GstCaps * caps)
gboolean ret = TRUE;
gint width, height;
int par_n, par_d;
+ guintptr used_window = 0;
if (!(ret = gst_video_format_parse_caps (caps, &eglglessink->format, &width,
&height))) {
@@ -1108,25 +1107,23 @@ gst_eglglessink_configure_caps (GstEglGlesSink * eglglessink, GstCaps * caps)
*/
GST_OBJECT_LOCK (eglglessink);
if (!eglglessink->have_window) {
- EGLNativeWindowType window;
GST_INFO_OBJECT (eglglessink,
"No window. Will attempt internal window creation");
- if (!(window = gst_eglglessink_create_window (eglglessink, width, height))) {
+ if (!gst_eglglessink_create_window (eglglessink, width, height)) {
GST_ERROR_OBJECT (eglglessink, "Internal window creation failed!");
GST_OBJECT_UNLOCK (eglglessink);
goto HANDLE_ERROR;
}
eglglessink->using_own_window = TRUE;
- eglglessink->egl_context->window = window;
+ gst_egl_adaptation_context_update_used_window (eglglessink->egl_context);
eglglessink->have_window = TRUE;
}
- GST_DEBUG_OBJECT (eglglessink, "Using window handle %p",
- eglglessink->egl_context->window);
- eglglessink->egl_context->used_window = eglglessink->egl_context->window;
+ used_window =
+ gst_egl_adaptation_context_get_window (eglglessink->egl_context);
GST_OBJECT_UNLOCK (eglglessink);
gst_x_overlay_got_window_handle (GST_X_OVERLAY (eglglessink),
- (guintptr) eglglessink->egl_context->used_window);
+ (guintptr) used_window);
if (!eglglessink->egl_context->have_surface) {
if (!gst_egl_adaptation_init_egl_surface (eglglessink->egl_context,