2011-11-18 16:26:35 +00:00
|
|
|
/*
|
2008-06-11 18:33:53 +00:00
|
|
|
* GStreamer
|
2008-09-20 13:44:24 +00:00
|
|
|
* Copyright (C) 2007 David Schleef <ds@schleef.org>
|
2008-06-11 18:33:53 +00:00
|
|
|
* Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
|
2008-08-11 07:52:16 +00:00
|
|
|
* Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
|
2008-06-11 18:33:53 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-08 11:53:56 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2008-06-11 18:33:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _GST_GL_FILTER_H_
|
|
|
|
#define _GST_GL_FILTER_H_
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gst/video/video.h>
|
|
|
|
|
2013-07-11 09:03:31 +00:00
|
|
|
#include <gst/gl/gl.h>
|
2008-06-11 18:33:53 +00:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2018-03-13 10:57:15 +00:00
|
|
|
GST_GL_API
|
2012-09-27 05:53:46 +00:00
|
|
|
GType gst_gl_filter_get_type(void);
|
2008-06-11 18:33:53 +00:00
|
|
|
#define GST_TYPE_GL_FILTER (gst_gl_filter_get_type())
|
|
|
|
#define GST_GL_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_FILTER,GstGLFilter))
|
|
|
|
#define GST_IS_GL_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_FILTER))
|
|
|
|
#define GST_GL_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_GL_FILTER,GstGLFilterClass))
|
|
|
|
#define GST_IS_GL_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_GL_FILTER))
|
|
|
|
#define GST_GL_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_GL_FILTER,GstGLFilterClass))
|
2012-09-27 05:53:46 +00:00
|
|
|
|
2016-11-03 01:03:24 +00:00
|
|
|
/**
|
|
|
|
* GstGLFilterRenderFunc:
|
2018-04-02 06:34:58 +00:00
|
|
|
* @filter: the #GstGLFilter
|
2016-11-03 01:03:24 +00:00
|
|
|
* @in_tex: the input #GstGLMemory to render
|
|
|
|
* @user_data: user data
|
|
|
|
*
|
|
|
|
* Returns: whether the render succeeded
|
|
|
|
*
|
|
|
|
* Since: 1.10
|
|
|
|
*/
|
2016-07-15 03:39:54 +00:00
|
|
|
typedef gboolean (*GstGLFilterRenderFunc) (GstGLFilter * filter, GstGLMemory * in_tex, gpointer user_data);
|
|
|
|
|
2012-09-27 05:53:46 +00:00
|
|
|
/**
|
|
|
|
* GstGLFilter:
|
|
|
|
* @in_info: the video info for input buffers
|
|
|
|
* @out_info: the video info for output buffers
|
2018-02-27 07:28:16 +00:00
|
|
|
* @in_texture_target: The texture target of the input buffers (usually 2D)
|
|
|
|
* @out_texture_target: The texture target of the output buffers (usually 2D)
|
2016-11-03 01:03:24 +00:00
|
|
|
* @out_caps: the output #GstCaps
|
2018-04-02 06:34:58 +00:00
|
|
|
* @fbo: #GstGLFramebuffer object used for transformations (only for subclass usage)
|
2012-09-27 05:53:46 +00:00
|
|
|
*/
|
2008-06-11 18:33:53 +00:00
|
|
|
struct _GstGLFilter
|
|
|
|
{
|
2015-02-10 14:48:11 +00:00
|
|
|
GstGLBaseFilter parent;
|
2008-06-11 18:33:53 +00:00
|
|
|
|
2018-04-02 06:34:58 +00:00
|
|
|
/*< public >*/
|
2012-09-27 05:53:46 +00:00
|
|
|
GstVideoInfo in_info;
|
|
|
|
GstVideoInfo out_info;
|
2018-02-27 07:28:16 +00:00
|
|
|
GstGLTextureTarget in_texture_target;
|
|
|
|
GstGLTextureTarget out_texture_target;
|
2014-09-24 03:13:19 +00:00
|
|
|
|
|
|
|
GstCaps *out_caps;
|
|
|
|
|
2018-04-02 06:34:58 +00:00
|
|
|
/* protected */
|
2016-07-12 02:59:57 +00:00
|
|
|
GstGLFramebuffer *fbo;
|
|
|
|
|
2018-04-02 06:34:58 +00:00
|
|
|
/*< private >*/
|
2016-07-11 14:30:22 +00:00
|
|
|
gboolean gl_result;
|
|
|
|
GstBuffer *inbuf;
|
|
|
|
GstBuffer *outbuf;
|
2009-11-17 22:47:24 +00:00
|
|
|
|
2012-09-27 05:53:46 +00:00
|
|
|
GstGLShader *default_shader;
|
2016-03-09 13:27:53 +00:00
|
|
|
gboolean valid_attributes;
|
2012-09-27 05:53:46 +00:00
|
|
|
|
2017-07-07 15:15:12 +00:00
|
|
|
guint vao;
|
|
|
|
guint vbo_indices;
|
|
|
|
guint vertex_buffer;
|
|
|
|
gint draw_attr_position_loc;
|
|
|
|
gint draw_attr_texture_loc;
|
2016-09-28 05:20:25 +00:00
|
|
|
|
|
|
|
gpointer _padding[GST_PADDING];
|
2008-06-11 18:33:53 +00:00
|
|
|
};
|
|
|
|
|
2012-09-27 05:53:46 +00:00
|
|
|
/**
|
|
|
|
* GstGLFilterClass:
|
|
|
|
* @set_caps: mirror from #GstBaseTransform
|
|
|
|
* @filter: perform operations on the input and output buffers. In general,
|
|
|
|
* you should avoid using this method if at all possible. One valid
|
|
|
|
* use-case for using this is keeping previous buffers for future calculations.
|
|
|
|
* Note: If @filter exists, then @filter_texture is not run
|
|
|
|
* @filter_texture: given @in_tex, transform it into @out_tex. Not used
|
|
|
|
* if @filter exists
|
2015-04-26 19:42:03 +00:00
|
|
|
* @init_fbo: perform initialization when the Framebuffer object is created
|
2015-05-29 16:29:47 +00:00
|
|
|
* @transform_internal_caps: Perform sub-class specific modifications of the
|
|
|
|
* caps to be processed between upload on input and before download for output.
|
2012-09-27 05:53:46 +00:00
|
|
|
*/
|
2008-06-11 18:33:53 +00:00
|
|
|
struct _GstGLFilterClass
|
|
|
|
{
|
2015-02-10 14:48:11 +00:00
|
|
|
GstGLBaseFilterClass parent_class;
|
2011-11-18 16:26:35 +00:00
|
|
|
|
2018-04-02 06:34:58 +00:00
|
|
|
/*< public >*/
|
2012-09-27 05:53:46 +00:00
|
|
|
gboolean (*set_caps) (GstGLFilter* filter, GstCaps* incaps, GstCaps* outcaps);
|
|
|
|
gboolean (*filter) (GstGLFilter *filter, GstBuffer *inbuf, GstBuffer *outbuf);
|
2016-07-11 14:30:22 +00:00
|
|
|
gboolean (*filter_texture) (GstGLFilter *filter, GstGLMemory *in_tex, GstGLMemory *out_tex);
|
2015-04-26 19:42:03 +00:00
|
|
|
gboolean (*init_fbo) (GstGLFilter *filter);
|
2012-09-27 05:53:46 +00:00
|
|
|
|
2015-05-29 16:29:47 +00:00
|
|
|
GstCaps *(*transform_internal_caps) (GstGLFilter *filter,
|
|
|
|
GstPadDirection direction, GstCaps * caps, GstCaps * filter_caps);
|
|
|
|
|
2018-04-02 06:34:58 +00:00
|
|
|
/*< private >*/
|
2016-09-28 05:20:25 +00:00
|
|
|
gpointer _padding[GST_PADDING];
|
2008-06-11 18:33:53 +00:00
|
|
|
};
|
|
|
|
|
2018-03-13 10:57:15 +00:00
|
|
|
GST_GL_API
|
2017-07-06 11:09:50 +00:00
|
|
|
void gst_gl_filter_add_rgba_pad_templates (GstGLFilterClass *klass);
|
|
|
|
|
2018-03-13 10:57:15 +00:00
|
|
|
GST_GL_API
|
2012-09-20 13:06:49 +00:00
|
|
|
gboolean gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
|
|
|
|
GstBuffer * outbuf);
|
2008-08-10 09:22:34 +00:00
|
|
|
|
2018-03-13 10:57:15 +00:00
|
|
|
GST_GL_API
|
2016-07-15 03:39:54 +00:00
|
|
|
gboolean gst_gl_filter_render_to_target (GstGLFilter *filter,
|
2016-07-11 14:30:22 +00:00
|
|
|
GstGLMemory * input,
|
|
|
|
GstGLMemory * output,
|
2016-07-15 03:39:54 +00:00
|
|
|
GstGLFilterRenderFunc func,
|
2016-07-11 14:30:22 +00:00
|
|
|
gpointer data);
|
2008-08-10 09:22:34 +00:00
|
|
|
|
2018-03-13 10:57:15 +00:00
|
|
|
GST_GL_API
|
2016-07-11 12:44:16 +00:00
|
|
|
void gst_gl_filter_draw_fullscreen_quad (GstGLFilter *filter);
|
2018-03-13 10:57:15 +00:00
|
|
|
GST_GL_API
|
2016-07-11 14:30:22 +00:00
|
|
|
void gst_gl_filter_render_to_target_with_shader (GstGLFilter * filter,
|
|
|
|
GstGLMemory * input,
|
|
|
|
GstGLMemory * output,
|
|
|
|
GstGLShader *shader);
|
2008-08-10 09:22:34 +00:00
|
|
|
|
2008-06-11 18:33:53 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
2012-09-27 05:53:46 +00:00
|
|
|
#endif /* _GST_GL_FILTER_H_ */
|