3 * Copyright (C) 2007 David Schleef <ds@schleef.org>
4 * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
5 * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
23 #ifndef _GST_GL_FILTER_H_
24 #define _GST_GL_FILTER_H_
27 #include <gst/video/video.h>
29 #include <gst/gl/gl.h>
34 GType gst_gl_filter_get_type(void);
35 #define GST_TYPE_GL_FILTER (gst_gl_filter_get_type())
36 #define GST_GL_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_FILTER,GstGLFilter))
37 #define GST_IS_GL_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_FILTER))
38 #define GST_GL_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_GL_FILTER,GstGLFilterClass))
39 #define GST_IS_GL_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_GL_FILTER))
40 #define GST_GL_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_GL_FILTER,GstGLFilterClass))
43 * GstGLFilterRenderFunc:
44 * @filter: the #GstGLFilter
45 * @in_tex: the input #GstGLMemory to render
46 * @user_data: user data
48 * Returns: whether the render succeeded
52 typedef gboolean (*GstGLFilterRenderFunc) (GstGLFilter * filter, GstGLMemory * in_tex, gpointer user_data);
56 * @in_info: the video info for input buffers
57 * @out_info: the video info for output buffers
58 * @in_texture_target: The texture target of the input buffers (usually 2D)
59 * @out_texture_target: The texture target of the output buffers (usually 2D)
60 * @out_caps: the output #GstCaps
61 * @fbo: #GstGLFramebuffer object used for transformations (only for subclass usage)
65 GstGLBaseFilter parent;
69 GstVideoInfo out_info;
70 GstGLTextureTarget in_texture_target;
71 GstGLTextureTarget out_texture_target;
76 GstGLFramebuffer *fbo;
83 GstGLShader *default_shader;
84 gboolean valid_attributes;
89 gint draw_attr_position_loc;
90 gint draw_attr_texture_loc;
92 gpointer _padding[GST_PADDING];
97 * @set_caps: mirror from #GstBaseTransform
98 * @filter: perform operations on the input and output buffers. In general,
99 * you should avoid using this method if at all possible. One valid
100 * use-case for using this is keeping previous buffers for future calculations.
101 * Note: If @filter exists, then @filter_texture is not run
102 * @filter_texture: given @in_tex, transform it into @out_tex. Not used
104 * @init_fbo: perform initialization when the Framebuffer object is created
105 * @transform_internal_caps: Perform sub-class specific modifications of the
106 * caps to be processed between upload on input and before download for output.
108 struct _GstGLFilterClass
110 GstGLBaseFilterClass parent_class;
113 gboolean (*set_caps) (GstGLFilter* filter, GstCaps* incaps, GstCaps* outcaps);
114 gboolean (*filter) (GstGLFilter *filter, GstBuffer *inbuf, GstBuffer *outbuf);
115 gboolean (*filter_texture) (GstGLFilter *filter, GstGLMemory *input, GstGLMemory *output);
116 gboolean (*init_fbo) (GstGLFilter *filter);
118 GstCaps *(*transform_internal_caps) (GstGLFilter *filter,
119 GstPadDirection direction, GstCaps * caps, GstCaps * filter_caps);
122 gpointer _padding[GST_PADDING];
126 void gst_gl_filter_add_rgba_pad_templates (GstGLFilterClass *klass);
129 gboolean gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * input,
133 gboolean gst_gl_filter_render_to_target (GstGLFilter *filter,
135 GstGLMemory * output,
136 GstGLFilterRenderFunc func,
140 void gst_gl_filter_draw_fullscreen_quad (GstGLFilter *filter);
142 void gst_gl_filter_render_to_target_with_shader (GstGLFilter * filter,
144 GstGLMemory * output,
145 GstGLShader *shader);
149 #endif /* _GST_GL_FILTER_H_ */