From 31ee764a8a7d5dcbc4af2ff8d0e60241c3e63b94 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Thu, 12 Jun 2014 12:09:56 +1000 Subject: [PATCH] gl/examples: Port to using signals instead of properties Based on patch by Mathieu Duponchelle https://bugzilla.gnome.org/show_bug.cgi?id=704507 --- tests/examples/gl/generic/cube/main.cpp | 11 ++++++----- tests/examples/gl/generic/cubeyuv/main.cpp | 10 ++++++---- tests/examples/gl/generic/doublecube/main.cpp | 12 ++++++++---- tests/examples/gl/qt/mousevideooverlay/pipeline.cpp | 12 +++++++----- tests/examples/gl/qt/mousevideooverlay/pipeline.h | 4 ++-- .../gl/qt/qglwidgetvideooverlay/pipeline.cpp | 8 +++++--- .../examples/gl/qt/qglwidgetvideooverlay/pipeline.h | 4 ++-- 7 files changed, 36 insertions(+), 25 deletions(-) diff --git a/tests/examples/gl/generic/cube/main.cpp b/tests/examples/gl/generic/cube/main.cpp index e7ebaaebab..ebe90d0cb1 100644 --- a/tests/examples/gl/generic/cube/main.cpp +++ b/tests/examples/gl/generic/cube/main.cpp @@ -65,17 +65,19 @@ static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data) } //client reshape callback -static void reshapeCallback (GLuint width, GLuint height, gpointer data) +static gboolean reshapeCallback (void *gl_sink, GLuint width, GLuint height, gpointer data) { glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100); glMatrixMode(GL_MODELVIEW); + + return TRUE; } //client draw callback -static gboolean drawCallback (GLuint texture, GLuint width, GLuint height, gpointer data) +static gboolean drawCallback (void * gl_sink, GLuint texture, GLuint width, GLuint height, gpointer data) { static GLfloat xrot = 0; static GLfloat yrot = 0; @@ -200,9 +202,8 @@ gint main (gint argc, gchar *argv[]) /* configure elements */ g_object_set(G_OBJECT(videosrc), "num-buffers", 400, NULL); - g_object_set(G_OBJECT(glimagesink), "client-reshape-callback", reshapeCallback, NULL); - g_object_set(G_OBJECT(glimagesink), "client-draw-callback", drawCallback, NULL); - g_object_set(G_OBJECT(glimagesink), "client-data", NULL, NULL); + g_signal_connect(G_OBJECT(glimagesink), "client-reshape", G_CALLBACK (reshapeCallback), NULL); + g_signal_connect(G_OBJECT(glimagesink), "client-draw", G_CALLBACK (drawCallback), NULL); /* add elements */ gst_bin_add_many (GST_BIN (pipeline), videosrc, glimagesink, NULL); diff --git a/tests/examples/gl/generic/cubeyuv/main.cpp b/tests/examples/gl/generic/cubeyuv/main.cpp index 1796447905..8a8180a649 100644 --- a/tests/examples/gl/generic/cubeyuv/main.cpp +++ b/tests/examples/gl/generic/cubeyuv/main.cpp @@ -87,18 +87,20 @@ static void identityCallback (GstElement *src, GstBuffer *buffer, GstElement* t //client reshape callback -static void reshapeCallback (GLuint width, GLuint height) +static gboolean reshapeCallback (void * gl_sink, GLuint width, GLuint height, gpointer data) { glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100); glMatrixMode(GL_MODELVIEW); + + return TRUE; } //client draw callback -static gboolean drawCallback (GLuint texture, GLuint width, GLuint height) +static gboolean drawCallback (void * gl_sink, GLuint texture, GLuint width, GLuint height, gpointer data) { static GLfloat xrot = 0; static GLfloat yrot = 0; @@ -264,8 +266,8 @@ gint main (gint argc, gchar *argv[]) g_object_set(G_OBJECT(videosrc), "location", video_location.c_str(), NULL); g_signal_connect(identity, "handoff", G_CALLBACK(identityCallback), textoverlay) ; g_object_set(G_OBJECT(textoverlay), "font_desc", "Ahafoni CLM Bold 30", NULL); - g_object_set(G_OBJECT(glimagesink), "client-reshape-callback", reshapeCallback, NULL); - g_object_set(G_OBJECT(glimagesink), "client-draw-callback", drawCallback, NULL); + g_signal_connect(G_OBJECT(glimagesink), "client-reshape", G_CALLBACK (reshapeCallback), NULL); + g_signal_connect(G_OBJECT(glimagesink), "client-draw", G_CALLBACK (drawCallback), NULL); /* add elements */ gst_bin_add_many (GST_BIN (pipeline), videosrc, decodebin, identity, diff --git a/tests/examples/gl/generic/doublecube/main.cpp b/tests/examples/gl/generic/doublecube/main.cpp index 4ff6338984..8aa5620430 100644 --- a/tests/examples/gl/generic/doublecube/main.cpp +++ b/tests/examples/gl/generic/doublecube/main.cpp @@ -25,6 +25,8 @@ #endif #include +#include + #include #include #include @@ -89,18 +91,20 @@ static GstPadProbeReturn textoverlay_sink_pad_probe_cb (GstPad *pad, GstPadProbe //client reshape callback -static void reshapeCallback (GLuint width, GLuint height) +static gboolean reshapeCallback (void *gl_sink, GLuint width, GLuint height) { glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100); glMatrixMode(GL_MODELVIEW); + + return TRUE; } //client draw callback -static gboolean drawCallback (GLuint texture, GLuint width, GLuint height) +static gboolean drawCallback (void * gl_sink, GLuint texture, GLuint width, GLuint height) { static GLfloat xrot = 0; static GLfloat yrot = 0; @@ -281,8 +285,8 @@ gint main (gint argc, gchar *argv[]) g_object_set(G_OBJECT(videosrc), "num-buffers", 1000, NULL); g_object_set(G_OBJECT(videosrc), "location", video_location.c_str(), NULL); g_object_set(G_OBJECT(textoverlay), "font_desc", "Ahafoni CLM Bold 30", NULL); - g_object_set(G_OBJECT(glimagesink0), "client-reshape-callback", reshapeCallback, NULL); - g_object_set(G_OBJECT(glimagesink0), "client-draw-callback", drawCallback, NULL); + g_signal_connect(G_OBJECT(glimagesink0), "client-reshape", G_CALLBACK (reshapeCallback), NULL); + g_signal_connect(G_OBJECT(glimagesink0), "client-draw", G_CALLBACK (drawCallback), NULL); /* add elements */ gst_bin_add_many (GST_BIN (pipeline), videosrc, decodebin, videoconvert, textoverlay, tee, diff --git a/tests/examples/gl/qt/mousevideooverlay/pipeline.cpp b/tests/examples/gl/qt/mousevideooverlay/pipeline.cpp index 9f8cc76228..941f8d1a0e 100644 --- a/tests/examples/gl/qt/mousevideooverlay/pipeline.cpp +++ b/tests/examples/gl/qt/mousevideooverlay/pipeline.cpp @@ -65,8 +65,8 @@ void Pipeline::create() g_object_set(G_OBJECT(videosrc), "num-buffers", 800, NULL); g_object_set(G_OBJECT(videosrc), "location", m_videoLocation.toAscii().data(), NULL); - g_object_set(G_OBJECT(m_glimagesink), "client-reshape-callback", reshapeCallback, NULL); - g_object_set(G_OBJECT(m_glimagesink), "client-draw-callback", drawCallback, NULL); + g_signal_connect(G_OBJECT(m_glimagesink), "client-reshape", G_CALLBACK (reshapeCallback), NULL); + g_signal_connect(G_OBJECT(m_glimagesink), "client-draw", G_CALLBACK (drawCallback), NULL); gst_bin_add_many (GST_BIN (m_pipeline), videosrc, decodebin, m_glimagesink, NULL); @@ -159,17 +159,19 @@ float Pipeline::m_yrot = 0; float Pipeline::m_zrot = 0; //client reshape callback -void Pipeline::reshapeCallback (uint width, uint height) +gboolean Pipeline::reshapeCallback (void *sink, guint width, guint height, gpointer data) { glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100); - glMatrixMode(GL_MODELVIEW); + glMatrixMode(GL_MODELVIEW); + + return TRUE; } //client draw callback -gboolean Pipeline::drawCallback (uint texture, uint width, uint height) +gboolean Pipeline::drawCallback (void *sink, uint texture, uint width, uint height, gpointer data) { static GTimeVal current_time; static glong last_sec = current_time.tv_sec; diff --git a/tests/examples/gl/qt/mousevideooverlay/pipeline.h b/tests/examples/gl/qt/mousevideooverlay/pipeline.h index 5cdadaf5ff..326e465f83 100644 --- a/tests/examples/gl/qt/mousevideooverlay/pipeline.h +++ b/tests/examples/gl/qt/mousevideooverlay/pipeline.h @@ -60,8 +60,8 @@ private: void doExpose() const; void doRotate(); - static void reshapeCallback (uint width, uint height); - static gboolean drawCallback (uint texture, uint width, uint height); + static gboolean reshapeCallback (void *sink, guint width, guint height, gpointer data); + static gboolean drawCallback (void *sink, guint texture, guint width, guint height, gpointer data); static gboolean bus_call (GstBus *bus, GstMessage *msg, Pipeline* p); static void cb_new_pad (GstElement* decodebin, GstPad* pad, gboolean last, Pipeline* p); static gboolean cb_expose (gpointer data); diff --git a/tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.cpp b/tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.cpp index 617524a66e..bed38b4470 100644 --- a/tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.cpp +++ b/tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.cpp @@ -156,17 +156,19 @@ void Pipeline::exposeRequested() //----------------------------------------------------------------------- //client reshape callback -void Pipeline::reshapeCallback (uint width, uint height) +gboolean Pipeline::reshapeCallback (void *sink, guint width, guint height, gpointer data) { glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45, (gfloat)width/(gfloat)height, 0.1, 100); - glMatrixMode(GL_MODELVIEW); + glMatrixMode(GL_MODELVIEW); + + return TRUE; } //client draw callback -gboolean Pipeline::drawCallback (uint texture, uint width, uint height) +gboolean Pipeline::drawCallback (void *sink, guint texture, guint width, guint height, gpointer data) { static GLfloat xrot = 0; static GLfloat yrot = 0; diff --git a/tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.h b/tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.h index 51c48fc20a..b702647709 100644 --- a/tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.h +++ b/tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.h @@ -59,8 +59,8 @@ private: WId winId() const { return m_winId; } void doExpose() const; - static void reshapeCallback (uint width, uint height); - static gboolean drawCallback (uint texture, uint width, uint height); + static gboolean reshapeCallback (void *sink, guint width, guint height, gpointer data); + static gboolean drawCallback (void *sink, guint texture, guint width, guint height, gpointer data); static gboolean bus_call (GstBus *bus, GstMessage *msg, Pipeline* p); static void cb_new_pad (GstElement* decodebin, GstPad* pad, gboolean last, Pipeline* p); static gboolean cb_expose (gpointer data);