1 /* GStreamer
2 *
3 * unit test for state changes on all elements
4 *
5 * Copyright (C) <2017> Julien Isorce <julien.isorce@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 #ifdef HAVE_CONFIG_H
24 # include "config.h"
25 #endif
26
27 /* This test check that public gstgl headers does not include any
28 * GL headers. Except for gst/gl/gstglfuncs.h */
29
30 #include <gst/check/gstcheck.h>
31
32 #include <gst/gl/gstgl_enums.h>
33 #include <gst/gl/gstglapi.h>
34 #include <gst/gl/gstglbasefilter.h>
35 #include <gst/gl/gstglbasememory.h>
36 #include <gst/gl/gstglbasesrc.h>
37 #include <gst/gl/gstglbuffer.h>
38 #include <gst/gl/gstglbufferpool.h>
39 #include <gst/gl/gstglcolorconvert.h>
40 #include <gst/gl/gstglconfig.h>
41 #include <gst/gl/gstglcontext.h>
42 #include <gst/gl/gstgldebug.h>
43 #include <gst/gl/gstgldisplay.h>
44 #include <gst/gl/gstglfeature.h>
45 #include <gst/gl/gstglfilter.h>
46 #include <gst/gl/gstglformat.h>
47 #include <gst/gl/gstglframebuffer.h>
48 #include <gst/gl/gstglmemory.h>
49 #include <gst/gl/gstglmemorypbo.h>
50 #include <gst/gl/gstgloverlaycompositor.h>
51 #include <gst/gl/gstglquery.h>
52 #include <gst/gl/gstglrenderbuffer.h>
53 #include <gst/gl/gstglshader.h>
54 #include <gst/gl/gstglshaderstrings.h>
55 #include <gst/gl/gstglsl.h>
56 #include <gst/gl/gstglslstage.h>
57 #include <gst/gl/gstglsyncmeta.h>
58 #include <gst/gl/gstglupload.h>
59 #include <gst/gl/gstglutils.h>
60 #include <gst/gl/gstglviewconvert.h>
61 #include <gst/gl/gstglwindow.h>
62
63 #if GST_GL_HAVE_PLATFORM_EGL
64 #include <gst/gl/egl/gstgldisplay_egl.h>
65 #include <gst/gl/egl/gstgldisplay_egl_device.h>
66 #include <gst/gl/egl/gstglmemoryegl.h>
67 #include <gst/gl/egl/gsteglimage.h>
68 #endif
69
70 #if GST_GL_HAVE_WINDOW_X11
71 #include <gst/gl/x11/gstgldisplay_x11.h>
72 #endif
73
74 #if GST_GL_HAVE_WINDOW_WAYLAND
75 #include <gst/gl/wayland/gstgldisplay_wayland.h>
76 #endif
77
78 #include <gst/gl/gl.h>
79
80 #if defined(GLint) || defined(GLAPI) || defined(GL_GLEXT_VERSION)
81 #error gl headers should not be included
82 #endif
83
84 #if defined(EGLint) || defined(EGLBoolean) || defined(EGLAPI)
85 #error egl headers should not be included
86 #endif
87
88 static GstGLDisplay *display;
89 static GstGLContext *context;
90
91 static void
setup(void)92 setup (void)
93 {
94 display = gst_gl_display_new ();
95 context = gst_gl_context_new (display);
96 gst_gl_context_create (context, 0, NULL);
97 gst_gl_buffer_init_once ();
98 gst_gl_memory_init_once ();
99 gst_gl_memory_pbo_init_once ();
100 gst_gl_renderbuffer_init_once ();
101 }
102
103 static void
teardown(void)104 teardown (void)
105 {
106 gst_object_unref (context);
107 gst_object_unref (display);
108 }
109
GST_START_TEST(test_constructors)110 GST_START_TEST (test_constructors)
111 {
112 GstBufferPool *pool = NULL;
113 GstGLColorConvert *convert = NULL;
114 GstGLOverlayCompositor *compositor = NULL;
115 GstGLUpload *upload = NULL;
116
117 pool = gst_gl_buffer_pool_new (context);
118 fail_if (pool == NULL);
119 gst_object_unref (pool);
120
121 convert = gst_gl_color_convert_new (context);
122 fail_if (convert == NULL);
123 gst_object_unref (convert);
124
125 compositor = gst_gl_overlay_compositor_new (context);
126 fail_if (compositor == NULL);
127 gst_object_unref (compositor);
128
129 upload = gst_gl_upload_new (context);
130 fail_if (upload == NULL);
131 gst_object_unref (upload);
132 }
133
134 GST_END_TEST;
135
136 static void
_construct_with_activated_context(GstGLContext * context,gpointer unused)137 _construct_with_activated_context (GstGLContext * context, gpointer unused)
138 {
139 GstGLFramebuffer *framebuffer = NULL;
140 GstGLShader *shader = NULL;
141 GstGLSLStage *stage = NULL;
142
143 framebuffer = gst_gl_framebuffer_new (context);
144 fail_if (framebuffer == NULL);
145 gst_object_unref (framebuffer);
146
147 shader = gst_gl_shader_new (context);
148 fail_if (shader == NULL);
149 gst_object_unref (shader);
150
151 stage = gst_glsl_stage_new_default_fragment (context);
152 fail_if (stage == NULL);
153 gst_object_unref (stage);
154 }
155
GST_START_TEST(test_constructors_require_activated_context)156 GST_START_TEST (test_constructors_require_activated_context)
157 {
158 gst_gl_context_thread_add (context, _construct_with_activated_context, NULL);
159 }
160
161 GST_END_TEST;
162
163
164 static Suite *
gst_gl_headers_suite(void)165 gst_gl_headers_suite (void)
166 {
167 Suite *s = suite_create ("Gst GL Headers");
168 TCase *tc_chain = tcase_create ("general");
169
170 suite_add_tcase (s, tc_chain);
171 tcase_add_checked_fixture (tc_chain, setup, teardown);
172 tcase_add_test (tc_chain, test_constructors);
173 tcase_add_test (tc_chain, test_constructors_require_activated_context);
174
175 return s;
176 }
177
178 GST_CHECK_MAIN (gst_gl_headers);
179