• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/gstglbuffer.h>
36 #include <gst/gl/gstglbufferpool.h>
37 #include <gst/gl/gstglcolorconvert.h>
38 #include <gst/gl/gstglconfig.h>
39 #include <gst/gl/gstglcontext.h>
40 #include <gst/gl/gstgldebug.h>
41 #include <gst/gl/gstgldisplay.h>
42 #include <gst/gl/gstglfeature.h>
43 #include <gst/gl/gstglfilter.h>
44 #include <gst/gl/gstglformat.h>
45 #include <gst/gl/gstglframebuffer.h>
46 #include <gst/gl/gstglsl.h>
47 #include <gst/gl/gstglslstage.h>
48 #include <gst/gl/gstglmemory.h>
49 #include <gst/gl/gstglmemorypbo.h>
50 #include <gst/gl/gstglquery.h>
51 #include <gst/gl/gstgloverlaycompositor.h>
52 #include <gst/gl/gstglrenderbuffer.h>
53 #include <gst/gl/gstglshader.h>
54 #include <gst/gl/gstglshaderstrings.h>
55 #include <gst/gl/gstglsyncmeta.h>
56 #include <gst/gl/gstglupload.h>
57 #include <gst/gl/gstglutils.h>
58 #include <gst/gl/gstglviewconvert.h>
59 #include <gst/gl/gstglwindow.h>
60 
61 #if GST_GL_HAVE_PLATFORM_EGL
62 #include <gst/gl/egl/gstgldisplay_egl.h>
63 #include <gst/gl/egl/gstglcontext_egl.h>
64 #include <gst/gl/egl/gstglmemoryegl.h>
65 #endif
66 
67 #if GST_GL_HAVE_PLATFORM_GLX
68 #include <gst/gl/x11/gstgldisplay_x11.h>
69 #include <gst/gl/x11/gstglwindow_x11.h>
70 #endif
71 
72 #include <gst/gl/gl.h>
73 
74 #if defined(GLint) || defined(GLAPI) || defined(GL_GLEXT_VERSION)
75 #error gl headers should not be included
76 #endif
77 
78 #if defined(EGLint) || defined(EGLBoolean) || defined(EGLAPI)
79 #error egl headers should not be included
80 #endif
81 
82 static GstGLDisplay *display;
83 static GstGLContext *context;
84 
85 static void
setup(void)86 setup (void)
87 {
88   display = gst_gl_display_new ();
89   context = gst_gl_context_new (display);
90   gst_gl_context_create (context, 0, NULL);
91   gst_gl_buffer_init_once ();
92   gst_gl_memory_init_once ();
93   gst_gl_memory_pbo_init_once ();
94   gst_gl_renderbuffer_init_once ();
95 }
96 
97 static void
teardown(void)98 teardown (void)
99 {
100   gst_object_unref (context);
101   gst_object_unref (display);
102 }
103 
GST_START_TEST(test_constructors)104 GST_START_TEST (test_constructors)
105 {
106   GstBufferPool *pool = NULL;
107   GstGLColorConvert *convert = NULL;
108   GstGLOverlayCompositor *compositor = NULL;
109   GstGLUpload *upload = NULL;
110 
111   pool = gst_gl_buffer_pool_new (context);
112   fail_if (pool == NULL);
113   gst_object_unref (pool);
114 
115   convert = gst_gl_color_convert_new (context);
116   fail_if (convert == NULL);
117   gst_object_unref (convert);
118 
119   compositor = gst_gl_overlay_compositor_new (context);
120   fail_if (compositor == NULL);
121   gst_object_unref (compositor);
122 
123   upload = gst_gl_upload_new (context);
124   fail_if (upload == NULL);
125   gst_object_unref (upload);
126 }
127 
128 GST_END_TEST;
129 
130 static void
_construct_with_activated_context(GstGLContext * context,gpointer unused)131 _construct_with_activated_context (GstGLContext * context, gpointer unused)
132 {
133   GstGLFramebuffer *framebuffer = NULL;
134   GstGLShader *shader = NULL;
135   GstGLSLStage *stage = NULL;
136 
137   framebuffer = gst_gl_framebuffer_new (context);
138   fail_if (framebuffer == NULL);
139   gst_object_unref (framebuffer);
140 
141   shader = gst_gl_shader_new (context);
142   fail_if (shader == NULL);
143   gst_object_unref (shader);
144 
145   stage = gst_glsl_stage_new_default_fragment (context);
146   fail_if (stage == NULL);
147   gst_object_unref (stage);
148 }
149 
GST_START_TEST(test_constructors_require_activated_context)150 GST_START_TEST (test_constructors_require_activated_context)
151 {
152   gst_gl_context_thread_add (context, _construct_with_activated_context, NULL);
153 }
154 
155 GST_END_TEST;
156 
157 
158 static Suite *
gst_gl_headers_suite(void)159 gst_gl_headers_suite (void)
160 {
161   Suite *s = suite_create ("Gst GL Headers");
162   TCase *tc_chain = tcase_create ("general");
163 
164   suite_add_tcase (s, tc_chain);
165   tcase_add_checked_fixture (tc_chain, setup, teardown);
166   tcase_add_test (tc_chain, test_constructors);
167   tcase_add_test (tc_chain, test_constructors_require_activated_context);
168 
169   return s;
170 }
171 
172 GST_CHECK_MAIN (gst_gl_headers);
173