gl/examples: Port to using signals instead of properties

Based on patch by Mathieu Duponchelle <mathieu.duponchelle@epitech.eu>

https://bugzilla.gnome.org/show_bug.cgi?id=704507
This commit is contained in:
Matthew Waters 2014-06-12 12:09:56 +10:00
parent 2ed84ac40f
commit e36f5b1326
7 changed files with 36 additions and 25 deletions

View file

@ -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);

View file

@ -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,

View file

@ -25,6 +25,8 @@
#endif
#include <gst/gst.h>
#include <gst/gl/gl.h>
#include <iostream>
#include <sstream>
#include <string>
@ -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,

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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);