• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  *
3  * Copyright (C) 2014 Matthew Waters <matthew@centricular.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 #ifdef HAVE_CONFIG_H
22 #  include "config.h"
23 #endif
24 
25 #include <gst/check/gstcheck.h>
26 
27 #include <gst/gl/gl.h>
28 
29 /* *INDENT-OFF* */
30 static struct
31 {
32   GstGLAPI api;
33   const gchar *str;
34 } api_strings[] = {
35   {GST_GL_API_OPENGL, "opengl"},
36   {GST_GL_API_OPENGL3, "opengl3"},
37   {GST_GL_API_GLES1, "gles1"},
38   {GST_GL_API_GLES2, "gles2"},
39   {GST_GL_API_ANY, "any"},
40   {GST_GL_API_NONE, "none"},
41 };
42 
43 static struct
44 {
45   GstGLAPI api;
46   const gchar *str;
47 } from_api_strings[] = {
48   {GST_GL_API_ANY, ""},
49   {GST_GL_API_ANY, NULL},
50   {GST_GL_API_NONE, "invalid-api"},
51 };
52 /* *INDENT-ON* */
53 
GST_START_TEST(gl_api_serialization)54 GST_START_TEST (gl_api_serialization)
55 {
56   int i;
57 
58   for (i = 0; i < G_N_ELEMENTS (api_strings); i++) {
59     gchar *new_str;
60 
61     new_str = gst_gl_api_to_string (api_strings[i].api);
62     GST_DEBUG ("\'%s\' ?= \'%s\'", new_str, api_strings[i].str);
63     fail_unless_equals_int (0, g_strcmp0 (new_str, api_strings[i].str));
64     fail_unless_equals_int (gst_gl_api_from_string (api_strings[i].str),
65         api_strings[i].api);
66     g_free (new_str);
67   }
68 
69   for (i = 0; i < G_N_ELEMENTS (from_api_strings); i++) {
70     fail_unless_equals_int (gst_gl_api_from_string (from_api_strings[i].str),
71         from_api_strings[i].api);
72   }
73 }
74 
75 GST_END_TEST;
76 
77 /* *INDENT-OFF* */
78 static struct
79 {
80   GstGLPlatform platform;
81   const gchar *str;
82 } platform_strings[] = {
83   {GST_GL_PLATFORM_GLX, "glx"},
84   {GST_GL_PLATFORM_EGL, "egl"},
85   {GST_GL_PLATFORM_WGL, "wgl"},
86   {GST_GL_PLATFORM_CGL, "cgl"},
87   {GST_GL_PLATFORM_EAGL, "eagl"},
88   {GST_GL_PLATFORM_ANY, "any"},
89   {GST_GL_PLATFORM_NONE, "none"},
90 };
91 
92 static struct
93 {
94   GstGLPlatform platform;
95   const gchar *str;
96 } from_platform_strings[] = {
97   {GST_GL_PLATFORM_ANY, ""},
98   {GST_GL_PLATFORM_ANY, NULL},
99   {GST_GL_PLATFORM_NONE, "invalid-platform"},
100 };
101 /* *INDENT-ON* */
102 
GST_START_TEST(gl_platform_serialization)103 GST_START_TEST (gl_platform_serialization)
104 {
105   int i;
106 
107   for (i = 0; i < G_N_ELEMENTS (platform_strings); i++) {
108     gchar *new_str;
109 
110     new_str = gst_gl_platform_to_string (platform_strings[i].platform);
111     GST_DEBUG ("\'%s\' ?= \'%s\'", new_str, platform_strings[i].str);
112     fail_unless_equals_int (0, g_strcmp0 (new_str, platform_strings[i].str));
113     fail_unless_equals_int (gst_gl_platform_from_string (platform_strings
114             [i].str), platform_strings[i].platform);
115     g_free (new_str);
116   }
117 
118   for (i = 0; i < G_N_ELEMENTS (from_platform_strings); i++) {
119     fail_unless_equals_int (gst_gl_platform_from_string (from_platform_strings
120             [i].str), from_platform_strings[i].platform);
121   }
122 }
123 
124 GST_END_TEST;
125 
126 static Suite *
gst_gl_color_convert_suite(void)127 gst_gl_color_convert_suite (void)
128 {
129   Suite *s = suite_create ("GstGLAPI");
130   TCase *tc_chain = tcase_create ("api");
131 
132   suite_add_tcase (s, tc_chain);
133   tcase_add_test (tc_chain, gl_platform_serialization);
134   tcase_add_test (tc_chain, gl_api_serialization);
135 
136   return s;
137 }
138 
139 GST_CHECK_MAIN (gst_gl_color_convert);
140