Instead of prividing texture and size directly.
And apply changes to examples.
https://bugzilla.gnome.org/show_bug.cgi?id=739681
static gboolean
_on_client_draw (GstGLImageSink * sink, GstGLContext * context,
- guint tex_id, guint width, guint height, gpointer data)
+ GstSample * sample, gpointer data)
{
gboolean ret;
g_signal_emit (data, gst_gl_image_sink_bin_signals[SIGNAL_BIN_CLIENT_DRAW], 0,
- context, tex_id, width, height, &ret);
+ context, sample, &ret);
return ret;
}
gst_gl_image_sink_bin_signals[SIGNAL_BIN_CLIENT_DRAW] =
g_signal_new ("client-draw", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_generic,
- G_TYPE_BOOLEAN, 4, GST_GL_TYPE_CONTEXT,
- G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
+ G_TYPE_BOOLEAN, 2, GST_GL_TYPE_CONTEXT, GST_TYPE_SAMPLE);
gst_gl_image_sink_bin_signals[SIGNAL_BIN_CLIENT_RESHAPE] =
g_signal_new ("client-reshape", G_TYPE_FROM_CLASS (klass),
gst_glimage_sink_signals[CLIENT_DRAW_SIGNAL] =
g_signal_new ("client-draw", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_generic,
- G_TYPE_BOOLEAN, 4, GST_GL_TYPE_CONTEXT,
- G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
+ G_TYPE_BOOLEAN, 2, GST_GL_TYPE_CONTEXT, GST_TYPE_SAMPLE);
/**
* GstGLImageSink::client-reshape:
const GstGLFuncs *gl = NULL;
GstGLWindow *window = NULL;
- gboolean do_redisplay;
- GstGLSyncMeta *sync_meta;
+ gboolean do_redisplay = FALSE;
+ GstGLSyncMeta *sync_meta = NULL;
+ GstSample *sample = NULL;
g_return_if_fail (GST_IS_GLIMAGE_SINK (gl_sink));
gl->BindTexture (GL_TEXTURE_2D, 0);
+ sample = gst_sample_new (gl_sink->stored_buffer,
+ gst_video_info_to_caps (&gl_sink->info),
+ &GST_BASE_SINK (gl_sink)->segment, NULL);
+
g_signal_emit (gl_sink, gst_glimage_sink_signals[CLIENT_DRAW_SIGNAL], 0,
- gl_sink->context,
- gl_sink->redisplay_texture, GST_VIDEO_INFO_WIDTH (&gl_sink->info),
- GST_VIDEO_INFO_HEIGHT (&gl_sink->info), &do_redisplay);
+ gl_sink->context, sample, &do_redisplay);
+
+ gst_sample_unref (sample);
if (!do_redisplay) {
gfloat alpha = gl_sink->ignore_alpha ? 1.0f : 0.0f;
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)
* 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>
}
//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;
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 (¤t_time);
nbFrames++ ;
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;
}
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)
* 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>
//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;
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 (¤t_time);
nbFrames++ ;
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;
}
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)
* 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>
//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;
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 (¤t_time);
nbFrames++ ;
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;
}
}
//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 (¤t_time);
nbFrames++ ;
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;
}
}
//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;
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 (¤t_time);
nbFrames++ ;
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;
}