• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * GStreamer
3  * Copyright (C) 2009 Julien Isorce <julien.isorce@gmail.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef _GST_GL_VIDEO_MIXER_H_
22 #define _GST_GL_VIDEO_MIXER_H_
23 
24 #include "gstglmixer.h"
25 
26 G_BEGIN_DECLS
27 
28 #define GST_TYPE_GL_VIDEO_MIXER            (gst_gl_video_mixer_get_type())
29 #define GST_GL_VIDEO_MIXER(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_VIDEO_MIXER,GstGLVideoMixer))
30 #define GST_IS_GL_VIDEO_MIXER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_VIDEO_MIXER))
31 #define GST_GL_VIDEO_MIXER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_GL_VIDEO_MIXER,GstGLVideoMixerClass))
32 #define GST_IS_GL_VIDEO_MIXER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_GL_VIDEO_MIXER))
33 #define GST_GL_VIDEO_MIXER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_GL_VIDEO_MIXER,GstGLVideoMixerClass))
34 
35 typedef struct _GstGLVideoMixer GstGLVideoMixer;
36 typedef struct _GstGLVideoMixerClass GstGLVideoMixerClass;
37 
38 /**
39  * GstGLVideoMixerBackground:
40  * @GST_GL_VIDEO_MIXER_BACKGROUND_CHECKER: checker pattern background
41  * @GST_GL_VIDEO_MIXER_BACKGROUND_BLACK: solid color black background
42  * @GST_GL_VIDEO_MIXER_BACKGROUND_WHITE: solid color white background
43  * @GST_GL_VIDEO_MIXER_BACKGROUND_TRANSPARENT: background is left transparent and layers are composited using "A OVER B" composition rules. This is only applicable to AYUV and ARGB (and variants) as it preserves the alpha channel and allows for further mixing.
44  *
45  * The different backgrounds compositor can blend over.
46  */
47 typedef enum
48 {
49   GST_GL_VIDEO_MIXER_BACKGROUND_CHECKER,
50   GST_GL_VIDEO_MIXER_BACKGROUND_BLACK,
51   GST_GL_VIDEO_MIXER_BACKGROUND_WHITE,
52   GST_GL_VIDEO_MIXER_BACKGROUND_TRANSPARENT,
53 }
54 GstGLVideoMixerBackground;
55 
56 /**
57  * GstGLVideoMixerBlendEquation:
58  * @GST_GL_VIDEO_MIXER_BLEND_EQUATION_ADD: Add the two results.
59  * @GST_GL_VIDEO_MIXER_BLEND_EQUATION_SUBTRACT: Subtract component-wise the destination from the source (S - D).
60  * @GST_GL_VIDEO_MIXER_BLEND_EQUATION_REVERSE_SUBTRACT: Subtract component-wise the source from the destination (D - S).
61  *
62  * The blending equation to use.  See the opengl specificition for
63  * glBlendEquationSeparate
64  */
65 typedef enum
66 {
67   GST_GL_VIDEO_MIXER_BLEND_EQUATION_ADD,
68   GST_GL_VIDEO_MIXER_BLEND_EQUATION_SUBTRACT,
69   GST_GL_VIDEO_MIXER_BLEND_EQUATION_REVERSE_SUBTRACT,
70 }
71 GstGLVideoMixerBlendEquation;
72 
73 /**
74  * GstGLVideoMixerBlendFunction:
75  * @GST_GL_VIDEO_MIXER_BLEND_FUNCTION_ZERO: All components are zero
76  * @GST_GL_VIDEO_MIXER_BLEND_FUNCTION_ONE: All components are one
77  * @GST_GL_VIDEO_MIXER_BLEND_FUNCTION_SRC_COLOR: Use the source color/alpha
78  * @GST_GL_VIDEO_MIXER_BLEND_FUNCTION_ONE_MINUS_SRC_COLOR: One minus the source color/alpha
79  * @GST_GL_VIDEO_MIXER_BLEND_FUNCTION_DST_COLOR: Use the destination color/alpha
80  * @GST_GL_VIDEO_MIXER_BLEND_FUNCTION_ONE_MINUS_DST_COLOR: One minus the destination color/alpha
81  * @GST_GL_VIDEO_MIXER_BLEND_FUNCTION_SRC_ALPHA: All components are the source alpha
82  * @GST_GL_VIDEO_MIXER_BLEND_FUNCTION_ONE_MINUS_SRC_ALPHA: All components are one minus the source alpha
83  * @GST_GL_VIDEO_MIXER_BLEND_FUNCTION_DST_ALPHA: All components are the destination alpha
84  * @GST_GL_VIDEO_MIXER_BLEND_FUNCTION_ONE_MINUS_DST_ALPHA: All components are one minus the destination alpha
85  * @GST_GL_VIDEO_MIXER_BLEND_FUNCTION_CONSTANT_COLOR: Use the constant color/alpha
86  * @GST_GL_VIDEO_MIXER_BLEND_FUNCTION_ONE_MINUS_CONSTANT_COLOR: Use one minus the constant color/alpha
87  * @GST_GL_VIDEO_MIXER_BLEND_FUNCTION_CONSTANT_ALPHA: All components are the constant alpha
88  * @GST_GL_VIDEO_MIXER_BLEND_FUNCTION_ONE_MINUS_CONSTANT_COLOR: All components are one minus the constant alpha
89  * @GST_GL_VIDEO_MIXER_BLEND_FUNCTION_SRC_ALPHA_SATURATE: All color components
90  *     are the minimum of source alpha and one minus the destination alpha.
91  *     Alpha is equal to one.
92  *
93  * The blending function to use.  See the opengl specificition for
94  * glBlendFuncSeparate
95  */
96 typedef enum
97 {
98   GST_GL_VIDEO_MIXER_BLEND_FUNCTION_ZERO,
99   GST_GL_VIDEO_MIXER_BLEND_FUNCTION_ONE,
100   GST_GL_VIDEO_MIXER_BLEND_FUNCTION_SRC_COLOR,
101   GST_GL_VIDEO_MIXER_BLEND_FUNCTION_ONE_MINUS_SRC_COLOR,
102   GST_GL_VIDEO_MIXER_BLEND_FUNCTION_DST_COLOR,
103   GST_GL_VIDEO_MIXER_BLEND_FUNCTION_ONE_MINUS_DST_COLOR,
104   GST_GL_VIDEO_MIXER_BLEND_FUNCTION_SRC_ALPHA,
105   GST_GL_VIDEO_MIXER_BLEND_FUNCTION_ONE_MINUS_SRC_ALPHA,
106   GST_GL_VIDEO_MIXER_BLEND_FUNCTION_DST_ALPHA,
107   GST_GL_VIDEO_MIXER_BLEND_FUNCTION_ONE_MINUS_DST_ALPHA,
108   GST_GL_VIDEO_MIXER_BLEND_FUNCTION_CONSTANT_COLOR,
109   GST_GL_VIDEO_MIXER_BLEND_FUNCTION_ONE_MINUS_CONSTANT_COLOR,
110   GST_GL_VIDEO_MIXER_BLEND_FUNCTION_CONSTANT_ALPHA,
111   GST_GL_VIDEO_MIXER_BLEND_FUNCTION_ONE_MINUS_CONSTANT_ALPHA,
112   GST_GL_VIDEO_MIXER_BLEND_FUNCTION_SRC_ALPHA_SATURATE,
113 }
114 GstGLVideoMixerBlendFunction;
115 
116 struct _GstGLVideoMixer
117 {
118     GstGLMixer mixer;
119 
120     GstGLVideoMixerBackground background;
121 
122     GstGLShader *shader;
123     GstGLShader *checker;
124 
125     GLuint vao;
126     GLuint vbo_indices;
127     GLuint checker_vbo;
128     GstGLMemory *out_tex;
129 
130     gboolean output_geo_change;
131 };
132 
133 struct _GstGLVideoMixerClass
134 {
135     GstGLMixerClass mixer_class;
136 };
137 
138 GType gst_gl_video_mixer_get_type (void);
139 GType gst_gl_video_mixer_bin_get_type (void);
140 
141 G_END_DECLS
142 
143 #endif /* _GST_GLFILTERCUBE_H_ */
144