summaryrefslogtreecommitdiff
path: root/tests/examples/gl
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2014-10-30 18:57:59 +1100
committerMatthew Waters <matthew@centricular.com>2014-10-30 18:58:50 +1100
commitc1f3cc9f1cb4d61e728424ac4ebfb03cd389a107 (patch)
treeb85e0cf357c7816135a1b5c1972f788f215a2939 /tests/examples/gl
parent567185a2775cfe581d71dc4ac365f4fc00da5b1e (diff)
gl/examples: update for other-context property removal
Diffstat (limited to 'tests/examples/gl')
-rw-r--r--tests/examples/gl/qt/qglwtextureshare/pipeline.cpp15
-rw-r--r--tests/examples/gl/sdl/sdlshare.c56
2 files changed, 49 insertions, 22 deletions
diff --git a/tests/examples/gl/qt/qglwtextureshare/pipeline.cpp b/tests/examples/gl/qt/qglwtextureshare/pipeline.cpp
index 6de2a3997..404323a30 100644
--- a/tests/examples/gl/qt/qglwtextureshare/pipeline.cpp
+++ b/tests/examples/gl/qt/qglwtextureshare/pipeline.cpp
@@ -74,16 +74,6 @@ Pipeline::configure ()
g_signal_connect (m_bus, "sync-message", G_CALLBACK (sync_bus_call), this);
gst_object_unref (m_bus);
- /* Retrieve the last gl element */
- GstElement *gl_element =
- gst_bin_get_by_name (GST_BIN (m_pipeline), "gleffects0");
- if (!gl_element) {
- qDebug ("gl element could not be found");
- return;
- }
- g_object_set (G_OBJECT (gl_element), "other-context", this->context, NULL);
- gst_object_unref (gl_element);
-
gst_element_set_state (GST_ELEMENT (this->m_pipeline), GST_STATE_PAUSED);
GstState state = GST_STATE_PAUSED;
if (gst_element_get_state (GST_ELEMENT (this->m_pipeline),
@@ -225,6 +215,11 @@ gboolean Pipeline::sync_bus_call (GstBus * bus, GstMessage * msg, Pipeline * p)
GstContext *display_context = gst_context_new (GST_GL_DISPLAY_CONTEXT_TYPE, TRUE);
gst_context_set_gl_display (display_context, p->display);
gst_element_set_context (GST_ELEMENT (msg->src), display_context);
+ } else if (g_strcmp0 (context_type, "gst.gl.app_context") == 0) {
+ GstContext *app_context = gst_context_new ("gst.gl.app_context", TRUE);
+ GstStructure *s = gst_context_writable_structure (app_context);
+ gst_structure_set (s, "context", GST_GL_TYPE_CONTEXT, p->context, NULL);
+ gst_element_set_context (GST_ELEMENT (msg->src), app_context);
}
break;
}
diff --git a/tests/examples/gl/sdl/sdlshare.c b/tests/examples/gl/sdl/sdlshare.c
index 9d8906d84..4f833d85a 100644
--- a/tests/examples/gl/sdl/sdlshare.c
+++ b/tests/examples/gl/sdl/sdlshare.c
@@ -39,6 +39,9 @@
#include <gst/gst.h>
#include <gst/gl/gl.h>
+static GstGLContext *sdl_context;
+static GstGLDisplay *sdl_gl_display;
+
/* rotation angle for the triangle. */
float rtri = 0.0f;
@@ -229,6 +232,39 @@ end_stream_cb (GstBus * bus, GstMessage * msg, GMainLoop * loop)
g_main_loop_quit (loop);
}
+static gboolean
+sync_bus_call (GstBus * bus, GstMessage * msg, gpointer data)
+{
+ switch (GST_MESSAGE_TYPE (msg)) {
+ case GST_MESSAGE_NEED_CONTEXT:
+ {
+ const gchar *context_type;
+
+ gst_message_parse_context_type (msg, &context_type);
+ g_print ("got need context %s\n", context_type);
+
+ if (g_strcmp0 (context_type, GST_GL_DISPLAY_CONTEXT_TYPE) == 0) {
+ GstContext *display_context =
+ gst_context_new (GST_GL_DISPLAY_CONTEXT_TYPE, TRUE);
+ gst_context_set_gl_display (display_context, sdl_gl_display);
+ gst_element_set_context (GST_ELEMENT (msg->src), display_context);
+ return TRUE;
+ } else if (g_strcmp0 (context_type, "gst.gl.app_context") == 0) {
+ GstContext *app_context = gst_context_new ("gst.gl.app_context", TRUE);
+ GstStructure *s = gst_context_writable_structure (app_context);
+ gst_structure_set (s, "context", GST_GL_TYPE_CONTEXT, sdl_context,
+ NULL);
+ gst_element_set_context (GST_ELEMENT (msg->src), app_context);
+ return TRUE;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ return FALSE;
+}
+
int
main (int argc, char **argv)
{
@@ -246,13 +282,10 @@ main (int argc, char **argv)
GMainLoop *loop = NULL;
GstPipeline *pipeline = NULL;
GstBus *bus = NULL;
- GstElement *glfilter = NULL;
GstElement *fakesink = NULL;
GstState state;
GAsyncQueue *queue_input_buf = NULL;
GAsyncQueue *queue_output_buf = NULL;
- GstGLDisplay *display;
- GstGLContext *sdl_context;
const gchar *platform;
/* Initialize SDL for video output */
@@ -284,22 +317,24 @@ main (int argc, char **argv)
sdl_dc = wglGetCurrentDC ();
wglMakeCurrent (0, 0);
platform = "wgl";
- display = gst_gl_display_new ();
+ sdl_gl_display = gst_gl_display_new ();
#else
SDL_VERSION (&info.version);
SDL_GetWMInfo (&info);
/* FIXME: This display is different to the one that SDL uses to create the
* GL context inside SDL_SetVideoMode() above which fails on Intel hardware
*/
- sdl_display = info.info.x11.display;
+ sdl_display = info.info.x11.gfxdisplay;
sdl_win = info.info.x11.window;
sdl_gl_context = glXGetCurrentContext ();
glXMakeCurrent (sdl_display, None, 0);
platform = "glx";
- display = (GstGLDisplay *) gst_gl_display_x11_new_with_display (sdl_display);
+ sdl_gl_display =
+ (GstGLDisplay *) gst_gl_display_x11_new_with_display (sdl_display);
#endif
- sdl_context = gst_gl_context_new_wrapped (display, (guintptr) sdl_gl_context,
+ sdl_context =
+ gst_gl_context_new_wrapped (sdl_gl_display, (guintptr) sdl_gl_context,
gst_gl_platform_from_string (platform), GST_GL_API_OPENGL);
pipeline =
@@ -312,13 +347,10 @@ main (int argc, char **argv)
g_signal_connect (bus, "message::error", G_CALLBACK (end_stream_cb), loop);
g_signal_connect (bus, "message::warning", G_CALLBACK (end_stream_cb), loop);
g_signal_connect (bus, "message::eos", G_CALLBACK (end_stream_cb), loop);
+ gst_bus_enable_sync_message_emission (bus);
+ g_signal_connect (bus, "sync-message", G_CALLBACK (sync_bus_call), NULL);
gst_object_unref (bus);
- /* sdl_gl_context is an external OpenGL context with which gst-plugins-gl want to share textures */
- glfilter = gst_bin_get_by_name (GST_BIN (pipeline), "gleffects0");
- g_object_set (G_OBJECT (glfilter), "other-context", sdl_context, NULL);
- gst_object_unref (glfilter);
-
/* NULL to PAUSED state pipeline to make sure the gst opengl context is created and
* shared with the sdl one */
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED);