1/*
2 * GStreamer
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>
6 *
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.
11 *
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.
16 *
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.
21 */
22
23#ifndef _GST_GL_FILTER_H_
24#define _GST_GL_FILTER_H_
25
26#include <gst/gst.h>
27#include <gst/video/video.h>
28
29#include <gst/gl/gl.h>
30
31G_BEGIN_DECLS
32
33GST_GL_API
34GType 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))
41
42/**
43 * GstGLFilterRenderFunc:
44 * @filter: the #GstGLFilter
45 * @in_tex: the input #GstGLMemory to render
46 * @user_data: user data
47 *
48 * Returns: whether the render succeeded
49 *
50 * Since: 1.10
51 */
52typedef gboolean (*GstGLFilterRenderFunc) (GstGLFilter * filter, GstGLMemory * in_tex, gpointer user_data);
53
54/**
55 * GstGLFilter:
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)
62 */
63struct _GstGLFilter
64{
65 GstGLBaseFilter parent;
66
67 /*< public >*/
68 GstVideoInfo in_info;
69 GstVideoInfo out_info;
70 GstGLTextureTarget in_texture_target;
71 GstGLTextureTarget out_texture_target;
72
73 GstCaps *out_caps;
74
75 /* protected */
76 GstGLFramebuffer *fbo;
77
78 /*< private >*/
79 gboolean gl_result;
80 GstBuffer *inbuf;
81 GstBuffer *outbuf;
82
83 GstGLShader *default_shader;
84 gboolean valid_attributes;
85
86 guint vao;
87 guint vbo_indices;
88 guint vertex_buffer;
89 gint draw_attr_position_loc;
90 gint draw_attr_texture_loc;
91
92 gpointer _padding[GST_PADDING];
93};
94
95/**
96 * GstGLFilterClass:
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
103 * if @filter exists
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.
107 */
108struct _GstGLFilterClass
109{
110 GstGLBaseFilterClass parent_class;
111
112 /*< public >*/
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);
117
118 GstCaps *(*transform_internal_caps) (GstGLFilter *filter,
119 GstPadDirection direction, GstCaps * caps, GstCaps * filter_caps);
120
121 /*< private >*/
122 gpointer _padding[GST_PADDING];
123};
124
125GST_GL_API
126void gst_gl_filter_add_rgba_pad_templates (GstGLFilterClass *klass);
127
128GST_GL_API
129gboolean gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * input,
130 GstBuffer * output);
131
132GST_GL_API
133gboolean gst_gl_filter_render_to_target (GstGLFilter *filter,
134 GstGLMemory * input,
135 GstGLMemory * output,
136 GstGLFilterRenderFunc func,
137 gpointer data);
138
139GST_GL_API
140void gst_gl_filter_draw_fullscreen_quad (GstGLFilter *filter);
141GST_GL_API
142void gst_gl_filter_render_to_target_with_shader (GstGLFilter * filter,
143 GstGLMemory * input,
144 GstGLMemory * output,
145 GstGLShader *shader);
146
147G_END_DECLS
148
149#endif /* _GST_GL_FILTER_H_ */
150

source code of include/gstreamer-1.0/gst/gl/gstglfilter.h