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/base/gstbasetransform.h>
28 #include <gst/video/video.h>
30 #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))
42 typedef struct _GstGLFilter GstGLFilter;
43 typedef struct _GstGLFilterClass GstGLFilterClass;
47 * @base_transform: parent #GstBaseTransform
48 * @pool: the currently configured #GstBufferPool
49 * @display: the currently configured #GstGLDisplay
50 * @in_info: the video info for input buffers
51 * @out_info: the video info for output buffers
52 * @fbo: GL Framebuffer object used for transformations
53 * @depthbuffer: GL renderbuffer attached to @fbo
54 * @upload: the object used for uploading data, if needed
55 * @download: the object used for downloading data, if needed
57 * #GstGLFilter is a base class that provides the logic of getting the GL context
58 * from downstream and automatic upload/download for non-#GstGLMemory
59 * #GstBuffer<!-- -->s.
63 GstBaseTransform base_transform;
67 GstGLDisplay *display;
70 GstVideoInfo out_info;
75 GstGLDownload *download;
81 GstGLShader *default_shader;
83 GstGLContext *other_context;
88 * @base_transform_class: parent class
89 * @set_caps: mirror from #GstBaseTransform
90 * @filter: perform operations on the input and output buffers. In general,
91 * you should avoid using this method if at all possible. One valid
92 * use-case for using this is keeping previous buffers for future calculations.
93 * Note: If @filter exists, then @filter_texture is not run
94 * @filter_texture: given @in_tex, transform it into @out_tex. Not used
96 * @onInitFBO: perform initialization when the Framebuffer object is created
97 * @onStart: called when element activates see also #GstBaseTransform
98 * @onStop: called when the element deactivates e also #GstBaseTransform
99 * @onReset: called on inizialation and after @onStop
100 * @display_init_cb: execute arbitrary gl code on start
101 * @display_reset_cb: execute arbitrary gl code at stop
103 struct _GstGLFilterClass
105 GstBaseTransformClass base_transform_class;
107 gboolean (*set_caps) (GstGLFilter* filter, GstCaps* incaps, GstCaps* outcaps);
108 gboolean (*filter) (GstGLFilter *filter, GstBuffer *inbuf, GstBuffer *outbuf);
109 gboolean (*filter_texture) (GstGLFilter *filter, guint in_tex, guint out_tex);
110 gboolean (*onInitFBO) (GstGLFilter *filter);
112 void (*onStart) (GstGLFilter *filter);
113 void (*onStop) (GstGLFilter *filter);
114 void (*onReset) (GstGLFilter *filter);
116 /* useful to init and cleanup custom gl resources */
117 void (*display_init_cb) (GstGLFilter *filter);
118 void (*display_reset_cb) (GstGLFilter *filter);
121 gboolean gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
124 void gst_gl_filter_render_to_target (GstGLFilter *filter, gboolean resize, GLuint input,
125 GLuint target, GLCB func, gpointer data);
127 #if GST_GL_HAVE_OPENGL
128 void gst_gl_filter_render_to_target_with_shader (GstGLFilter * filter, gboolean resize,
129 GLuint input, GLuint target, GstGLShader *shader);
131 void gst_gl_filter_draw_texture (GstGLFilter *filter, GLuint texture, guint width, guint height);
132 #endif /* GST_GL_HAVE_OPENGL */
136 #endif /* _GST_GL_FILTER_H_ */