mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +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
a54a462705
commit
ce17f1a2db
4 changed files with 215 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
|
||||
|
@ -29,14 +30,14 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
|||
|
||||
|
||||
static GstStaticPadTemplate gst_gl_filter_src_pad_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (GST_GL_VIDEO_CAPS)
|
||||
);
|
||||
|
||||
static GstStaticPadTemplate gst_gl_filter_sink_pad_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (GST_GL_VIDEO_CAPS)
|
||||
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue