mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
[143/906] Add init and reset callbacks in GstGLFilter to run arbitrary gl code at start and stop. Useful to init and cleanup custom gl resources.
This commit is contained in:
parent
396afd5ef3
commit
b0f30ff125
5 changed files with 236 additions and 173 deletions
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* GStreamer
|
||||
* Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
|
||||
* Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* GStreamer
|
||||
* Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
|
||||
* Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* GStreamer
|
||||
* Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
|
||||
* Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -68,6 +69,9 @@ static gboolean gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps,
|
|||
GstCaps * outcaps);
|
||||
static gboolean gst_gl_filter_do_transform (GstGLFilter * filter,
|
||||
GstGLBuffer * inbuf, GstGLBuffer * outbuf);
|
||||
/* GstGLDisplayThreadFunc */
|
||||
static void gst_gl_filter_start_gl (GstGLDisplay *display, gpointer data);
|
||||
static void gst_gl_filter_stop_gl (GstGLDisplay *display, gpointer data);
|
||||
|
||||
|
||||
static void
|
||||
|
@ -102,6 +106,8 @@ gst_gl_filter_class_init (GstGLFilterClass * klass)
|
|||
|
||||
klass->set_caps = NULL;
|
||||
klass->filter = NULL;
|
||||
klass->display_init_cb = NULL;
|
||||
klass->display_reset_cb = NULL;
|
||||
klass->onInitFBO = NULL;
|
||||
klass->onReset = NULL;
|
||||
}
|
||||
|
@ -155,6 +161,9 @@ gst_gl_filter_reset (GstGLFilter* filter)
|
|||
|
||||
if (filter->display)
|
||||
{
|
||||
if (filter_class->display_reset_cb != NULL) {
|
||||
gst_gl_display_thread_add (filter->display, gst_gl_filter_stop_gl, filter);
|
||||
}
|
||||
//blocking call, delete the FBO
|
||||
gst_gl_display_del_fbo (filter->display, filter->fbo,
|
||||
filter->depthbuffer);
|
||||
|
@ -183,6 +192,24 @@ gst_gl_filter_stop (GstBaseTransform* bt)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_filter_start_gl (GstGLDisplay *display, gpointer data)
|
||||
{
|
||||
GstGLFilter *filter = GST_GL_FILTER (data);
|
||||
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
|
||||
|
||||
filter_class->display_init_cb (filter);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_filter_stop_gl (GstGLDisplay *display, gpointer data)
|
||||
{
|
||||
GstGLFilter *filter = GST_GL_FILTER (data);
|
||||
GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
|
||||
|
||||
filter_class->display_reset_cb (filter);
|
||||
}
|
||||
|
||||
static GstCaps*
|
||||
gst_gl_filter_transform_caps (GstBaseTransform* bt,
|
||||
GstPadDirection direction, GstCaps* caps)
|
||||
|
@ -250,6 +277,10 @@ gst_gl_filter_prepare_output_buffer (GstBaseTransform* trans,
|
|||
gst_gl_display_gen_fbo (filter->display, filter->width, filter->height,
|
||||
&filter->fbo, &filter->depthbuffer);
|
||||
|
||||
if (filter_class->display_init_cb != NULL) {
|
||||
gst_gl_display_thread_add (filter->display, gst_gl_filter_start_gl, filter);
|
||||
}
|
||||
|
||||
if (filter_class->onInitFBO)
|
||||
filter_class->onInitFBO (filter);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* GStreamer
|
||||
* Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
|
||||
* Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -46,6 +47,9 @@ typedef gboolean (*GstGLFilterProcessFunc) (GstGLFilter *filter,
|
|||
typedef void (*GstGLFilterOnInitFBO) (GstGLFilter *filter);
|
||||
typedef void (*GstGLFilterOnReset) (GstGLFilter *filter);
|
||||
|
||||
typedef void (*GstGLFilterGLStartFunc) (GstGLFilter *filter);
|
||||
typedef void (*GstGLFilterGLStopFunc) (GstGLFilter *filter);
|
||||
|
||||
struct _GstGLFilter
|
||||
{
|
||||
GstBaseTransform base_transform;
|
||||
|
@ -67,7 +71,12 @@ struct _GstGLFilterClass
|
|||
GstGLFilterSetCaps set_caps;
|
||||
GstGLFilterProcessFunc filter;
|
||||
GstGLFilterOnInitFBO onInitFBO;
|
||||
|
||||
GstGLFilterOnReset onReset;
|
||||
|
||||
/* useful to init and cleanup custom gl resources */
|
||||
GstGLFilterGLStartFunc display_init_cb; /* run arbitrary gl code at start */
|
||||
GstGLFilterGLStopFunc display_reset_cb; /* run arbitrary gl code at stop */
|
||||
};
|
||||
|
||||
GType gst_gl_filter_get_type(void);
|
||||
|
|
|
@ -94,6 +94,25 @@ static gboolean gst_gl_filterblur_filter (GstGLFilter * filter,
|
|||
static void gst_gl_filterblur_hcallback (gint width, gint height, guint texture, gpointer stuff);
|
||||
static void gst_gl_filterblur_vcallback (gint width, gint height, guint texture, gpointer stuff);
|
||||
|
||||
|
||||
static void
|
||||
gst_gl_filterblur_init_resources (GstGLFilter *filter)
|
||||
{
|
||||
// GstGLFilterBlur *filterblur = GST_GL_FILTERBLUR (filter);
|
||||
|
||||
/* dummy gl call to test if we really are in a gl context */
|
||||
g_print ("\nStart!!!: %s\n\n", glGetString (GL_VERSION));
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_filterblur_reset_resources (GstGLFilter *filter)
|
||||
{
|
||||
// GstGLFilterBlur *filterblur = GST_GL_FILTERBLUR (filter);
|
||||
|
||||
/* dummy gl call to test if we really are in a gl context */
|
||||
g_print ("\nStop!!!: %s\n\n", glGetString (GL_VENDOR));
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_filterblur_base_init (gpointer klass)
|
||||
{
|
||||
|
@ -112,6 +131,8 @@ gst_gl_filterblur_class_init (GstGLFilterBlurClass * klass)
|
|||
gobject_class->get_property = gst_gl_filterblur_get_property;
|
||||
|
||||
GST_GL_FILTER_CLASS (klass)->filter = gst_gl_filterblur_filter;
|
||||
GST_GL_FILTER_CLASS (klass)->display_init_cb = gst_gl_filterblur_init_resources;
|
||||
GST_GL_FILTER_CLASS (klass)->display_reset_cb = gst_gl_filterblur_reset_resources;
|
||||
GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_filterblur_init_shader;
|
||||
GST_GL_FILTER_CLASS (klass)->onReset = gst_gl_filter_filterblur_reset;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue