1 /*
2 * GStreamer
3 * Copyright (C) 2020 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 /**
22 * SECTION:gstglcontextconfig
23 * @short_description: OpenGL context configuration values
24 * @title: GstGLContext
25 * @see_also: #GstGLContext, #GstGLWindow
26 *
27 * A common list of well-known values for what a config retrievable from or set
28 * on a `GstGLContext` may contain.
29 */
30
31 #ifdef HAVE_CONFIG_H
32 # include "config.h"
33 #endif
34
35 #include "gstglcontextconfig.h"
36 #include <gst/gl/gl.h>
37
38 /**
39 * GST_GL_CONFIG_ATTRIB_CONFIG_ID_NAME:
40 *
41 * The platform-specific config-id. This value is not stable across different
42 * machines or even different versions of the same underlying OpenGL
43 * implementation.
44 *
45 * Since: 1.20
46 */
47 /**
48 * GST_GL_CONFIG_ATTRIB_CONFIG_ID_GTYPE:
49 *
50 * The #GType of the config-id field.
51 *
52 * Since: 1.20
53 */
54 const gchar *GST_GL_CONFIG_ATTRIB_CONFIG_ID_NAME = "config-id";
55 /**
56 * GST_GL_CONFIG_ATTRIB_PLATFORM_NAME:
57 *
58 * The #GstGLPlatform this config was made for.
59 *
60 * Since: 1.20
61 */
62 /**
63 * GST_GL_CONFIG_ATTRIB_PLATFORM_GTYPE:
64 *
65 * The #GType of the 'platform' field.
66 *
67 * Since: 1.20
68 */
69 const gchar *GST_GL_CONFIG_ATTRIB_PLATFORM_NAME = "platform";
70 /**
71 * GST_GL_CONFIG_ATTRIB_CAVEAT_NAME:
72 *
73 * Any #GstGLConfigCaveat's applied to this configuration.
74 *
75 * Since: 1.20
76 */
77 /**
78 * GST_GL_CONFIG_ATTRIB_CAVEAT_GTYPE:
79 *
80 * The #GType of the 'caveat' field.
81 *
82 * Since: 1.20
83 */
84 const gchar *GST_GL_CONFIG_ATTRIB_CAVEAT_NAME = "caveat";
85 /**
86 * GST_GL_CONFIG_ATTRIB_SURFACE_TYPE_NAME:
87 *
88 * Flags of #GstGLConfigSurfaceType's that can apply to this configuration.
89 *
90 * Since: 1.20
91 */
92 /**
93 * GST_GL_CONFIG_ATTRIB_SURFACE_TYPE_GTYPE:
94 *
95 * The #GType of the 'surface-type' field.
96 *
97 * Since: 1.20
98 */
99 const gchar *GST_GL_CONFIG_ATTRIB_SURFACE_TYPE_NAME = "surface-type";
100 /**
101 * GST_GL_CONFIG_ATTRIB_CONFORMANT_API_NAME:
102 *
103 * The #GstGLAPI's that this configuration meets the conformance requirements
104 * for.
105 *
106 * Since: 1.20
107 */
108 /**
109 * GST_GL_CONFIG_ATTRIB_CONFORMANT_API_GTYPE:
110 *
111 * The #GType of the 'conformant-api' field.
112 *
113 * Since: 1.20
114 */
115 const gchar *GST_GL_CONFIG_ATTRIB_CONFORMANT_API_NAME = "conformant-api";
116 /**
117 * GST_GL_CONFIG_ATTRIB_RENDERABLE_API_NAME:
118 *
119 * The #GstGLAPI's that this configuration can be rendered with.
120 *
121 * Since: 1.20
122 */
123 /**
124 * GST_GL_CONFIG_ATTRIB_RENDERABLE_API_GTYPE:
125 *
126 * The #GType of the 'renderable-api' field.
127 *
128 * Since: 1.20
129 */
130 const gchar *GST_GL_CONFIG_ATTRIB_RENDERABLE_API_NAME = "renderable-api";
131 /**
132 * GST_GL_CONFIG_ATTRIB_RED_SIZE_NAME:
133 *
134 * The size of the red buffer with a colour backing buffer.
135 *
136 * Since: 1.20
137 */
138 /**
139 * GST_GL_CONFIG_ATTRIB_RED_SIZE_GTYPE:
140 *
141 * The #GType of the 'red-size' field.
142 *
143 * Since: 1.20
144 */
145 const gchar *GST_GL_CONFIG_ATTRIB_RED_SIZE_NAME = "red-size";
146 /**
147 * GST_GL_CONFIG_ATTRIB_GREEN_SIZE_NAME:
148 *
149 * The size of the green buffer with a colour backing buffer.
150 *
151 * Since: 1.20
152 */
153 /**
154 * GST_GL_CONFIG_ATTRIB_GREEN_SIZE_GTYPE:
155 *
156 * The #GType of the 'green-size' field.
157 *
158 * Since: 1.20
159 */
160 const gchar *GST_GL_CONFIG_ATTRIB_GREEN_SIZE_NAME = "green-size";
161 /**
162 * GST_GL_CONFIG_ATTRIB_BLUE_SIZE_NAME:
163 *
164 * The size of the blue buffer with a colour backing buffer.
165 *
166 * Since: 1.20
167 */
168 /**
169 * GST_GL_CONFIG_ATTRIB_BLUE_SIZE_GTYPE:
170 *
171 * The #GType of the 'blue-size' field.
172 *
173 * Since: 1.20
174 */
175 const gchar *GST_GL_CONFIG_ATTRIB_BLUE_SIZE_NAME = "blue-size";
176 /**
177 * GST_GL_CONFIG_ATTRIB_ALPHA_SIZE_NAME:
178 *
179 * The size of the alpha buffer with a colour backing buffer.
180 *
181 * Since: 1.20
182 */
183 /**
184 * GST_GL_CONFIG_ATTRIB_ALPHA_SIZE_GTYPE:
185 *
186 * The #GType of the 'alpha-size' field.
187 *
188 * Since: 1.20
189 */
190 const gchar *GST_GL_CONFIG_ATTRIB_ALPHA_SIZE_NAME = "alpha-size";
191 /**
192 * GST_GL_CONFIG_ATTRIB_LUMINANCE_SIZE_NAME:
193 *
194 * The size of the backing luminance buffer.
195 *
196 * Since: 1.20
197 */
198 /**
199 * GST_GL_CONFIG_ATTRIB_LUMINANCE_SIZE_GTYPE:
200 *
201 * The #GType of the 'luminance-size' field.
202 *
203 * Since: 1.20
204 */
205 const gchar *GST_GL_CONFIG_ATTRIB_LUMINANCE_SIZE_NAME = "luminance-size";
206 /**
207 * GST_GL_CONFIG_ATTRIB_DEPTH_SIZE_NAME:
208 *
209 * The size of the backing depth buffer.
210 *
211 * Since: 1.20
212 */
213 /**
214 * GST_GL_CONFIG_ATTRIB_DEPTH_SIZE_GTYPE:
215 *
216 * The #GType of the 'depth-size' field.
217 *
218 * Since: 1.20
219 */
220 const gchar *GST_GL_CONFIG_ATTRIB_DEPTH_SIZE_NAME = "depth-size";
221 /**
222 * GST_GL_CONFIG_ATTRIB_STENCIL_SIZE_NAME:
223 *
224 * The size of the backing stencil buffer.
225 *
226 * Since: 1.20
227 */
228 /**
229 * GST_GL_CONFIG_ATTRIB_STENCIL_SIZE_GTYPE:
230 *
231 * The #GType of the 'stencil-size' field.
232 *
233 * Since: 1.20
234 */
235 const gchar *GST_GL_CONFIG_ATTRIB_STENCIL_SIZE_NAME = "stencil-size";
236 /**
237 * GST_GL_CONFIG_ATTRIB_MAX_PBUFFER_WIDTH_NAME:
238 *
239 * The maximum width of a pbuffer created with this config.
240 *
241 * Since: 1.20
242 */
243 /**
244 * GST_GL_CONFIG_ATTRIB_MAX_PBUFFER_WIDTH_GTYPE:
245 *
246 * The #GType of the 'max-pbuffer-width' field.
247 *
248 * Since: 1.20
249 */
250 const gchar *GST_GL_CONFIG_ATTRIB_MAX_PBUFFER_WIDTH_NAME = "max-pbuffer-width";
251 /**
252 * GST_GL_CONFIG_ATTRIB_MAX_PBUFFER_HEIGHT_NAME:
253 *
254 * The maximum height of a pbuffer created with this config.
255 *
256 * Since: 1.20
257 */
258 /**
259 * GST_GL_CONFIG_ATTRIB_MAX_PBUFFER_HEIGHT_GTYPE:
260 *
261 * The #GType of the 'max-pbuffer-height' field.
262 *
263 * Since: 1.20
264 */
265 const gchar *GST_GL_CONFIG_ATTRIB_MAX_PBUFFER_HEIGHT_NAME =
266 "max-pbuffer-height";
267 /**
268 * GST_GL_CONFIG_ATTRIB_MAX_PBUFFER_PIXELS_NAME:
269 *
270 * The maximum number of pixels that a pbuffer can be created with this config.
271 *
272 * Since: 1.20
273 */
274 /**
275 * GST_GL_CONFIG_ATTRIB_MAX_PBUFFER_PIXELS_GTYPE:
276 *
277 * The #GType of the 'max-pbuffer-pixels' field.
278 *
279 * Since: 1.20
280 */
281 const gchar *GST_GL_CONFIG_ATTRIB_MAX_PBUFFER_PIXELS_NAME =
282 "max-pbuffer-pixels";
283 /**
284 * GST_GL_CONFIG_ATTRIB_SAMPLE_BUFFERS_NAME:
285 *
286 * The number of sample buffers for this config.
287 *
288 * Since: 1.20
289 */
290 /**
291 * GST_GL_CONFIG_ATTRIB_SAMPLE_BUFFERS_GTYPE:
292 *
293 * The #GType of the 'sample-buffers' field.
294 *
295 * Since: 1.20
296 */
297 const gchar *GST_GL_CONFIG_ATTRIB_SAMPLE_BUFFERS_NAME = "sample-buffers";
298 /**
299 * GST_GL_CONFIG_ATTRIB_SAMPLES_NAME:
300 *
301 * The number of samples per pixel for this config.
302 *
303 * Since: 1.20
304 */
305 /**
306 * GST_GL_CONFIG_ATTRIB_SAMPLES_GTYPE:
307 *
308 * The #GType of the 'samples' field.
309 *
310 * Since: 1.20
311 */
312 const gchar *GST_GL_CONFIG_ATTRIB_SAMPLES_NAME = "samples";
313 /**
314 * GST_GL_CONFIG_ATTRIB_NATIVE_RENDERABLE_NAME:
315 *
316 * Whether this configuration is renderable to by the native drawing API.
317 *
318 * Since: 1.20
319 */
320 /**
321 * GST_GL_CONFIG_ATTRIB_NATIVE_RENDERABLE_GTYPE:
322 *
323 * The #GType of the 'native-renderable' field.
324 *
325 * Since: 1.20
326 */
327 const gchar *GST_GL_CONFIG_ATTRIB_NATIVE_RENDERABLE_NAME = "native-renderable";
328 /**
329 * GST_GL_CONFIG_ATTRIB_NATIVE_VISUAL_ID_NAME:
330 *
331 * The native visual ID of this config. This value may not be consistent
332 * across machines or even dependency versions.
333 *
334 * Since: 1.20
335 */
336 /**
337 * GST_GL_CONFIG_ATTRIB_NATIVE_VISUAL_ID_GTYPE:
338 *
339 * The #GType of the 'native-visual-id' field.
340 *
341 * Since: 1.20
342 */
343 const gchar *GST_GL_CONFIG_ATTRIB_NATIVE_VISUAL_ID_NAME = "native-visual-id";
344 /**
345 * GST_GL_CONFIG_ATTRIB_LEVEL_NAME:
346 *
347 * Level of the under/overlay of this config. Positive values correspond to
348 * overlay, negative values are underlay.
349 *
350 * Since: 1.20
351 */
352 /**
353 * GST_GL_CONFIG_ATTRIB_LEVEL_GTYPE:
354 *
355 * The #GType of the 'level' field.
356 *
357 * Since: 1.20
358 */
359 const gchar *GST_GL_CONFIG_ATTRIB_LEVEL_NAME = "level";
360 /**
361 * GST_GL_CONFIG_ATTRIB_MIN_SWAP_INTERVAL_NAME:
362 *
363 * The minimum value available for vsync synchronisation.
364 *
365 * Since: 1.20
366 */
367 /**
368 * GST_GL_CONFIG_ATTRIB_MIN_SWAP_INTERVAL_GTYPE:
369 *
370 * The #GType of the 'min-swap-interval' field.
371 *
372 * Since: 1.20
373 */
374 const gchar *GST_GL_CONFIG_ATTRIB_MIN_SWAP_INTERVAL_NAME = "min-swap-interval";
375 /**
376 * GST_GL_CONFIG_ATTRIB_MAX_SWAP_INTERVAL_NAME:
377 *
378 * The maximum value available for vsync synchronisation.
379 *
380 * Since: 1.20
381 */
382 /**
383 * GST_GL_CONFIG_ATTRIB_MAX_SWAP_INTERVAL_GTYPE:
384 *
385 * The #GType of the 'max-swap-interval' field.
386 *
387 * Since: 1.20
388 */
389 const gchar *GST_GL_CONFIG_ATTRIB_MAX_SWAP_INTERVAL_NAME = "max-swap-interval";
390
391 static const gchar *
gst_gl_enum_value_to_const_string(GType type,guint value)392 gst_gl_enum_value_to_const_string (GType type, guint value)
393 {
394 GEnumClass *enum_class;
395 GEnumValue *enum_value;
396 const gchar *str = NULL;
397
398 enum_class = g_type_class_ref (type);
399 enum_value = g_enum_get_value (enum_class, value);
400
401 if (enum_value)
402 str = enum_value->value_nick;
403
404 g_type_class_unref (enum_class);
405
406 return str;
407 }
408
409 /**
410 * gst_gl_config_caveat_to_string:
411 * @caveat: the #GstGLConfigCaveat
412 *
413 * Returns: (nullable): a string version of @caveat or %NULL if @caveat does not
414 * exist.
415 *
416 * Since: 1.20
417 */
418 const gchar *
gst_gl_config_caveat_to_string(GstGLConfigCaveat caveat)419 gst_gl_config_caveat_to_string (GstGLConfigCaveat caveat)
420 {
421 return gst_gl_enum_value_to_const_string (GST_TYPE_GL_CONFIG_CAVEAT, caveat);
422 }
423
424 /**
425 * gst_gl_config_surface_type_to_string:
426 * @surface_type: the #GstGLConfigSurfaceType
427 *
428 * Returns: (nullable): a string version of @caveat or %NULL if @surface_type does not
429 * exist.
430 *
431 * Since: 1.20
432 */
433 const gchar *
gst_gl_config_surface_type_to_string(GstGLConfigSurfaceType surface_type)434 gst_gl_config_surface_type_to_string (GstGLConfigSurfaceType surface_type)
435 {
436 return gst_gl_enum_value_to_const_string (GST_TYPE_GL_CONFIG_SURFACE_TYPE,
437 surface_type);
438 }
439