[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
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* GStreamer
|
* GStreamer
|
||||||
* Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
|
* 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
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Library General Public
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* GStreamer
|
* GStreamer
|
||||||
* Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
|
* 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
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Library General Public
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* GStreamer
|
* GStreamer
|
||||||
* Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
|
* 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
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Library General Public
|
* 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);
|
GstCaps * outcaps);
|
||||||
static gboolean gst_gl_filter_do_transform (GstGLFilter * filter,
|
static gboolean gst_gl_filter_do_transform (GstGLFilter * filter,
|
||||||
GstGLBuffer * inbuf, GstGLBuffer * outbuf);
|
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
|
static void
|
||||||
@ -102,6 +106,8 @@ gst_gl_filter_class_init (GstGLFilterClass * klass)
|
|||||||
|
|
||||||
klass->set_caps = NULL;
|
klass->set_caps = NULL;
|
||||||
klass->filter = NULL;
|
klass->filter = NULL;
|
||||||
|
klass->display_init_cb = NULL;
|
||||||
|
klass->display_reset_cb = NULL;
|
||||||
klass->onInitFBO = NULL;
|
klass->onInitFBO = NULL;
|
||||||
klass->onReset = NULL;
|
klass->onReset = NULL;
|
||||||
}
|
}
|
||||||
@ -155,6 +161,9 @@ gst_gl_filter_reset (GstGLFilter* filter)
|
|||||||
|
|
||||||
if (filter->display)
|
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
|
//blocking call, delete the FBO
|
||||||
gst_gl_display_del_fbo (filter->display, filter->fbo,
|
gst_gl_display_del_fbo (filter->display, filter->fbo,
|
||||||
filter->depthbuffer);
|
filter->depthbuffer);
|
||||||
@ -183,6 +192,24 @@ gst_gl_filter_stop (GstBaseTransform* bt)
|
|||||||
return TRUE;
|
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*
|
static GstCaps*
|
||||||
gst_gl_filter_transform_caps (GstBaseTransform* bt,
|
gst_gl_filter_transform_caps (GstBaseTransform* bt,
|
||||||
GstPadDirection direction, GstCaps* caps)
|
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,
|
gst_gl_display_gen_fbo (filter->display, filter->width, filter->height,
|
||||||
&filter->fbo, &filter->depthbuffer);
|
&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)
|
if (filter_class->onInitFBO)
|
||||||
filter_class->onInitFBO (filter);
|
filter_class->onInitFBO (filter);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* GStreamer
|
* GStreamer
|
||||||
* Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
|
* 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
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Library General Public
|
* 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 (*GstGLFilterOnInitFBO) (GstGLFilter *filter);
|
||||||
typedef void (*GstGLFilterOnReset) (GstGLFilter *filter);
|
typedef void (*GstGLFilterOnReset) (GstGLFilter *filter);
|
||||||
|
|
||||||
|
typedef void (*GstGLFilterGLStartFunc) (GstGLFilter *filter);
|
||||||
|
typedef void (*GstGLFilterGLStopFunc) (GstGLFilter *filter);
|
||||||
|
|
||||||
struct _GstGLFilter
|
struct _GstGLFilter
|
||||||
{
|
{
|
||||||
GstBaseTransform base_transform;
|
GstBaseTransform base_transform;
|
||||||
@ -67,7 +71,12 @@ struct _GstGLFilterClass
|
|||||||
GstGLFilterSetCaps set_caps;
|
GstGLFilterSetCaps set_caps;
|
||||||
GstGLFilterProcessFunc filter;
|
GstGLFilterProcessFunc filter;
|
||||||
GstGLFilterOnInitFBO onInitFBO;
|
GstGLFilterOnInitFBO onInitFBO;
|
||||||
|
|
||||||
GstGLFilterOnReset onReset;
|
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);
|
GType gst_gl_filter_get_type(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user