summaryrefslogtreecommitdiff
path: root/tests/examples/gl
diff options
context:
space:
mode:
authorJulien Isorce <j.isorce@samsung.com>2015-03-14 15:16:55 +0000
committerJulien Isorce <j.isorce@samsung.com>2015-03-14 17:56:21 +0000
commit0150255a46da756f42e6f2e3776e2d39ed70dcec (patch)
treed7f3550daae1fb913b97ae4b2766e9b807843d32 /tests/examples/gl
parent94d4ae1840c652862b8caa505d525a7c4873ea38 (diff)
downloadgstreamer-plugins-bad-0150255a46da756f42e6f2e3776e2d39ed70dcec.tar.gz
glimagesink: provide GstSample in client-draw signal
Instead of prividing texture and size directly. And apply changes to examples. https://bugzilla.gnome.org/show_bug.cgi?id=739681
Diffstat (limited to 'tests/examples/gl')
-rw-r--r--tests/examples/gl/generic/cube/Makefile.am2
-rw-r--r--tests/examples/gl/generic/cube/main.cpp25
-rw-r--r--tests/examples/gl/generic/cubeyuv/Makefile.am2
-rw-r--r--tests/examples/gl/generic/cubeyuv/main.cpp34
-rw-r--r--tests/examples/gl/generic/doublecube/Makefile.am2
-rw-r--r--tests/examples/gl/generic/doublecube/main.cpp34
-rw-r--r--tests/examples/gl/qt/mousevideooverlay/pipeline.cpp22
-rw-r--r--tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.cpp22
8 files changed, 98 insertions, 45 deletions
diff --git a/tests/examples/gl/generic/cube/Makefile.am b/tests/examples/gl/generic/cube/Makefile.am
index b6bd60b4e..7262533e5 100644
--- a/tests/examples/gl/generic/cube/Makefile.am
+++ b/tests/examples/gl/generic/cube/Makefile.am
@@ -5,5 +5,5 @@ cube_SOURCES = main.cpp
cube_CXXFLAGS=-I$(top_srcdir)/gst-libs -I$(top_builddir)/gst-libs \
$(GST_CXXFLAGS) $(GL_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS)
-cube_LDADD=$(GST_LIBS) $(GL_LIBS)
+cube_LDADD=$(GST_LIBS) -lgstvideo-$(GST_API_VERSION) $(GL_LIBS)
diff --git a/tests/examples/gl/generic/cube/main.cpp b/tests/examples/gl/generic/cube/main.cpp
index c67140174..c3ace9fbe 100644
--- a/tests/examples/gl/generic/cube/main.cpp
+++ b/tests/examples/gl/generic/cube/main.cpp
@@ -18,11 +18,8 @@
* Boston, MA 02110-1301, USA.
*/
-#include <GL/gl.h>
-#if __WIN32__ || _WIN32
-# include <GL/glext.h>
-#endif
#include <gst/gst.h>
+#include <gst/gl/gl.h>
#include <iostream>
#include <string>
@@ -75,7 +72,7 @@ static gboolean reshapeCallback (void *gl_sink, void *context, GLuint width, GLu
}
//client draw callback
-static gboolean drawCallback (void * gl_sink, void *context, GLuint texture, GLuint width, GLuint height, gpointer data)
+static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSample * sample, gpointer data)
{
static GLfloat xrot = 0;
static GLfloat yrot = 0;
@@ -84,6 +81,21 @@ static gboolean drawCallback (void * gl_sink, void *context, GLuint texture, GLu
static glong last_sec = current_time.tv_sec;
static gint nbFrames = 0;
+ GstVideoFrame v_frame;
+ GstVideoInfo v_info;
+ guint texture = 0;
+ GstBuffer *buf = gst_sample_get_buffer (sample);
+ GstCaps *caps = gst_sample_get_caps (sample);
+
+ gst_video_info_from_caps (&v_info, caps);
+
+ if (!gst_video_frame_map (&v_frame, &v_info, buf, (GstMapFlags) (GST_MAP_READ | GST_MAP_GL))) {
+ g_warning ("Failed to map the video buffer");
+ return TRUE;
+ }
+
+ texture = *(guint *) v_frame.data[0];
+
g_get_current_time (&current_time);
nbFrames++ ;
@@ -147,11 +159,12 @@ static gboolean drawCallback (void * gl_sink, void *context, GLuint texture, GLu
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glEnd();
+ gst_video_frame_unmap (&v_frame);
+
xrot+=0.3f;
yrot+=0.2f;
zrot+=0.4f;
- //return TRUE causes a postRedisplay
return TRUE;
}
diff --git a/tests/examples/gl/generic/cubeyuv/Makefile.am b/tests/examples/gl/generic/cubeyuv/Makefile.am
index 289cbd3f3..98697f002 100644
--- a/tests/examples/gl/generic/cubeyuv/Makefile.am
+++ b/tests/examples/gl/generic/cubeyuv/Makefile.am
@@ -5,5 +5,5 @@ cubeyuv_SOURCES = main.cpp
cubeyuv_CXXFLAGS=-I$(top_srcdir)/gst-libs -I$(top_builddir)/gst-libs \
$(GST_CXXFLAGS) $(GL_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS)
-cubeyuv_LDADD=$(GST_LIBS) $(GL_LIBS)
+cubeyuv_LDADD=$(GST_LIBS) $(GL_LIBS) -lgstvideo-$(GST_API_VERSION)
diff --git a/tests/examples/gl/generic/cubeyuv/main.cpp b/tests/examples/gl/generic/cubeyuv/main.cpp
index 75bc30afb..9c4b2ccbd 100644
--- a/tests/examples/gl/generic/cubeyuv/main.cpp
+++ b/tests/examples/gl/generic/cubeyuv/main.cpp
@@ -18,11 +18,8 @@
* Boston, MA 02110-1301, USA.
*/
-#include <GL/gl.h>
-#if __WIN32__ || _WIN32
-# include <GL/glext.h>
-#endif
#include <gst/gst.h>
+#include <gst/gl/gl.h>
#include <iostream>
#include <sstream>
@@ -98,7 +95,7 @@ static gboolean reshapeCallback (void * gl_sink, void *context, GLuint width, GL
//client draw callback
-static gboolean drawCallback (void * gl_sink, void *context, GLuint texture, GLuint width, GLuint height, gpointer data)
+static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSample * sample, gpointer data)
{
static GLfloat xrot = 0;
static GLfloat yrot = 0;
@@ -107,6 +104,21 @@ static gboolean drawCallback (void * gl_sink, void *context, GLuint texture, GLu
static glong last_sec = current_time.tv_sec;
static gint nbFrames = 0;
+ GstVideoFrame v_frame;
+ GstVideoInfo v_info;
+ guint texture = 0;
+ GstBuffer *buf = gst_sample_get_buffer (sample);
+ GstCaps *caps = gst_sample_get_caps (sample);
+
+ gst_video_info_from_caps (&v_info, caps);
+
+ if (!gst_video_frame_map (&v_frame, &v_info, buf, (GstMapFlags) (GST_MAP_READ | GST_MAP_GL))) {
+ g_warning ("Failed to map the video buffer");
+ return TRUE;
+ }
+
+ texture = *(guint *) v_frame.data[0];
+
g_get_current_time (&current_time);
nbFrames++ ;
@@ -170,20 +182,12 @@ static gboolean drawCallback (void * gl_sink, void *context, GLuint texture, GLu
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glEnd();
+ gst_video_frame_unmap (&v_frame);
+
xrot+=0.03f;
yrot+=0.02f;
zrot+=0.04f;
- //return TRUE causes a postRedisplay
- //so you have to return FALSE to synchronise to have a graphic FPS
- //equals to the input video frame rate
-
- //Usually, we will not always return TRUE (or FALSE)
- //For example, if you want a fixed graphic FPS equals to 60
- //then you have to use the timeclock to return TRUE or FALSE
- //in order to increase or decrease the FPS in real time
- //to reach the 60.
-
return TRUE;
}
diff --git a/tests/examples/gl/generic/doublecube/Makefile.am b/tests/examples/gl/generic/doublecube/Makefile.am
index 3f220de7a..a13182906 100644
--- a/tests/examples/gl/generic/doublecube/Makefile.am
+++ b/tests/examples/gl/generic/doublecube/Makefile.am
@@ -5,5 +5,5 @@ doublecube_SOURCES = main.cpp
doublecube_CXXFLAGS=-I$(top_srcdir)/gst-libs -I$(top_builddir)/gst-libs \
$(GST_CXXFLAGS) $(GL_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS)
-doublecube_LDADD=$(GST_LIBS) $(GL_LIBS)
+doublecube_LDADD=$(GST_LIBS) $(GL_LIBS) -lgstvideo-$(GST_API_VERSION)
diff --git a/tests/examples/gl/generic/doublecube/main.cpp b/tests/examples/gl/generic/doublecube/main.cpp
index e72969904..98d782556 100644
--- a/tests/examples/gl/generic/doublecube/main.cpp
+++ b/tests/examples/gl/generic/doublecube/main.cpp
@@ -18,11 +18,8 @@
* Boston, MA 02110-1301, USA.
*/
-#include <GL/gl.h>
-#if __WIN32__ || _WIN32
-# include <GL/glext.h>
-#endif
#include <gst/gst.h>
+#include <gst/gl/gl.h>
#include <iostream>
#include <sstream>
@@ -100,7 +97,7 @@ static gboolean reshapeCallback (void *gl_sink, void *context, GLuint width, GLu
//client draw callback
-static gboolean drawCallback (void * gl_sink, void *context, GLuint texture, GLuint width, GLuint height)
+static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSample * sample, gpointer data)
{
static GLfloat xrot = 0;
static GLfloat yrot = 0;
@@ -109,6 +106,21 @@ static gboolean drawCallback (void * gl_sink, void *context, GLuint texture, GLu
static glong last_sec = current_time.tv_sec;
static gint nbFrames = 0;
+ GstVideoFrame v_frame;
+ GstVideoInfo v_info;
+ guint texture = 0;
+ GstBuffer *buf = gst_sample_get_buffer (sample);
+ GstCaps *caps = gst_sample_get_caps (sample);
+
+ gst_video_info_from_caps (&v_info, caps);
+
+ if (!gst_video_frame_map (&v_frame, &v_info, buf, (GstMapFlags) (GST_MAP_READ | GST_MAP_GL))) {
+ g_warning ("Failed to map the video buffer");
+ return TRUE;
+ }
+
+ texture = *(guint *) v_frame.data[0];
+
g_get_current_time (&current_time);
nbFrames++ ;
@@ -172,20 +184,12 @@ static gboolean drawCallback (void * gl_sink, void *context, GLuint texture, GLu
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glEnd();
+ gst_video_frame_unmap (&v_frame);
+
xrot+=0.03f;
yrot+=0.02f;
zrot+=0.04f;
- //return TRUE causes a postRedisplay
- //so you have to return FALSE to synchronise to have a graphic FPS
- //equals to the input video frame rate
-
- //Usually, we will not always return TRUE (or FALSE)
- //For example, if you want a fixed graphic FPS equals to 60
- //then you have to use the timeclock to return TRUE or FALSE
- //in order to increase or decrease the FPS in real time
- //to reach the 60.
-
return TRUE;
}
diff --git a/tests/examples/gl/qt/mousevideooverlay/pipeline.cpp b/tests/examples/gl/qt/mousevideooverlay/pipeline.cpp
index 897b28c6b..8ee60ffa5 100644
--- a/tests/examples/gl/qt/mousevideooverlay/pipeline.cpp
+++ b/tests/examples/gl/qt/mousevideooverlay/pipeline.cpp
@@ -170,11 +170,26 @@ gboolean Pipeline::reshapeCallback (void *sink, void *context, guint width, guin
}
//client draw callback
-gboolean Pipeline::drawCallback (void *sink, void *context, uint texture, uint width, uint height, gpointer data)
+gboolean Pipeline::drawCallback (GstElement * gl_sink, GstGLContext *context, GstSample * sample, gpointer data)
{
static GTimeVal current_time;
static glong last_sec = current_time.tv_sec;
- static gint nbFrames = 0;
+ static gint nbFrames = 0;
+
+ GstVideoFrame v_frame;
+ GstVideoInfo v_info;
+ guint texture = 0;
+ GstBuffer *buf = gst_sample_get_buffer (sample);
+ GstCaps *caps = gst_sample_get_caps (sample);
+
+ gst_video_info_from_caps (&v_info, caps);
+
+ if (!gst_video_frame_map (&v_frame, &v_info, buf, (GstMapFlags) (GST_MAP_READ | GST_MAP_GL))) {
+ g_warning ("Failed to map the video buffer");
+ return TRUE;
+ }
+
+ texture = *(guint *) v_frame.data[0];
g_get_current_time (&current_time);
nbFrames++ ;
@@ -239,7 +254,8 @@ gboolean Pipeline::drawCallback (void *sink, void *context, uint texture, uint w
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glEnd();
- //return TRUE causes a postRedisplay
+ gst_video_frame_unmap (&v_frame);
+
return TRUE;
}
diff --git a/tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.cpp b/tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.cpp
index 69e277472..90c6be8c5 100644
--- a/tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.cpp
+++ b/tests/examples/gl/qt/qglwidgetvideooverlay/pipeline.cpp
@@ -167,7 +167,7 @@ gboolean Pipeline::reshapeCallback (void *sink, void *context, guint width, guin
}
//client draw callback
-gboolean Pipeline::drawCallback (void *sink, void *context, guint texture, guint width, guint height, gpointer data)
+gboolean Pipeline::drawCallback (GstElement * gl_sink, GstGLContext *context, GstSample * sample, gpointer data)
{
static GLfloat xrot = 0;
static GLfloat yrot = 0;
@@ -176,6 +176,21 @@ gboolean Pipeline::drawCallback (void *sink, void *context, guint texture, guint
static glong last_sec = current_time.tv_sec;
static gint nbFrames = 0;
+ GstVideoFrame v_frame;
+ GstVideoInfo v_info;
+ guint texture = 0;
+ GstBuffer *buf = gst_sample_get_buffer (sample);
+ GstCaps *caps = gst_sample_get_caps (sample);
+
+ gst_video_info_from_caps (&v_info, caps);
+
+ if (!gst_video_frame_map (&v_frame, &v_info, buf, (GstMapFlags) (GST_MAP_READ | GST_MAP_GL))) {
+ g_warning ("Failed to map the video buffer");
+ return TRUE;
+ }
+
+ texture = *(guint *) v_frame.data[0];
+
g_get_current_time (&current_time);
nbFrames++ ;
@@ -237,13 +252,14 @@ gboolean Pipeline::drawCallback (void *sink, void *context, guint texture, guint
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
- glEnd();
+ glEnd();
+
+ gst_video_frame_unmap (&v_frame);
xrot+=0.03f;
yrot+=0.02f;
zrot+=0.04f;
- //return TRUE causes a postRedisplay
return TRUE;
}