2012-12-08 22:32:48 +00:00
|
|
|
/*
|
|
|
|
* GStreamer
|
|
|
|
* Copyright (C) 2012 Matthew Waters <ystreet00@gmail.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
2013-07-10 09:24:34 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2012-12-08 22:32:48 +00:00
|
|
|
|
|
|
|
#include "gstglapi.h"
|
|
|
|
|
2014-02-10 21:23:39 +00:00
|
|
|
/**
|
|
|
|
* gst_gl_api_to_string():
|
|
|
|
*
|
|
|
|
* @api: a #GstGLAPI to stringify
|
|
|
|
*
|
|
|
|
* Returns: A space seperated string of the OpenGL api's enabled in @api
|
|
|
|
*/
|
2012-12-08 22:32:48 +00:00
|
|
|
gchar *
|
2014-02-10 21:23:39 +00:00
|
|
|
gst_gl_api_to_string (GstGLAPI api)
|
2012-12-08 22:32:48 +00:00
|
|
|
{
|
|
|
|
GString *str = NULL;
|
2013-06-11 01:26:38 +00:00
|
|
|
gchar *ret;
|
2012-12-08 22:32:48 +00:00
|
|
|
|
|
|
|
if (api == GST_GL_API_NONE) {
|
|
|
|
str = g_string_new ("none");
|
2014-03-04 12:28:01 +00:00
|
|
|
goto out;
|
2012-12-08 22:32:48 +00:00
|
|
|
} else if (api == GST_GL_API_ANY) {
|
|
|
|
str = g_string_new ("any");
|
2014-03-04 12:28:01 +00:00
|
|
|
goto out;
|
2012-12-08 22:32:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (api & GST_GL_API_OPENGL) {
|
2014-02-10 21:23:39 +00:00
|
|
|
str = g_string_new (GST_GL_API_OPENGL_NAME);
|
2012-12-08 22:32:48 +00:00
|
|
|
}
|
|
|
|
if (api & GST_GL_API_OPENGL3) {
|
|
|
|
if (str) {
|
2014-02-10 21:23:39 +00:00
|
|
|
g_string_append (str, " " GST_GL_API_OPENGL3_NAME);
|
2012-12-08 22:32:48 +00:00
|
|
|
} else {
|
2014-02-10 21:23:39 +00:00
|
|
|
str = g_string_new (GST_GL_API_OPENGL3_NAME);
|
2012-12-08 22:32:48 +00:00
|
|
|
}
|
|
|
|
}
|
2014-02-10 21:23:39 +00:00
|
|
|
if (api & GST_GL_API_GLES1) {
|
2012-12-08 22:32:48 +00:00
|
|
|
if (str) {
|
2014-02-10 21:23:39 +00:00
|
|
|
g_string_append (str, " " GST_GL_API_GLES1_NAME);
|
2012-12-08 22:32:48 +00:00
|
|
|
} else {
|
2014-02-10 21:23:39 +00:00
|
|
|
str = g_string_new (GST_GL_API_GLES1_NAME);
|
2012-12-08 22:32:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (api & GST_GL_API_GLES2) {
|
|
|
|
if (str) {
|
2014-02-10 21:23:39 +00:00
|
|
|
g_string_append (str, " " GST_GL_API_GLES2_NAME);
|
2012-12-08 22:32:48 +00:00
|
|
|
} else {
|
2014-02-10 21:23:39 +00:00
|
|
|
str = g_string_new (GST_GL_API_GLES2_NAME);
|
2012-12-08 22:32:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-04 12:28:01 +00:00
|
|
|
out:
|
|
|
|
if (!str)
|
2014-03-16 14:06:37 +00:00
|
|
|
str = g_string_new ("unknown");
|
2013-06-11 01:26:38 +00:00
|
|
|
|
2014-03-04 12:28:01 +00:00
|
|
|
ret = g_string_free (str, FALSE);
|
2013-06-11 01:26:38 +00:00
|
|
|
return ret;
|
2012-12-08 22:32:48 +00:00
|
|
|
}
|
2014-02-10 21:23:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_gl_api_from_string():
|
|
|
|
*
|
|
|
|
* @apis_s: a space seperated string of OpenGL apis
|
|
|
|
*
|
|
|
|
* Returns: The #GstGLAPI represented by @apis_s
|
|
|
|
*/
|
|
|
|
GstGLAPI
|
|
|
|
gst_gl_api_from_string (const gchar * apis_s)
|
|
|
|
{
|
|
|
|
GstGLAPI ret = GST_GL_API_NONE;
|
|
|
|
gchar *apis = (gchar *) apis_s;
|
|
|
|
|
|
|
|
if (!apis || apis[0] == '\0') {
|
|
|
|
ret = GST_GL_API_ANY;
|
|
|
|
} else {
|
|
|
|
while (apis) {
|
|
|
|
if (apis[0] == '\0') {
|
|
|
|
break;
|
|
|
|
} else if (apis[0] == ' ' || apis[0] == ',') {
|
|
|
|
apis = &apis[1];
|
|
|
|
} else if (g_strstr_len (apis, 7, GST_GL_API_OPENGL3_NAME)) {
|
|
|
|
ret |= GST_GL_API_OPENGL3;
|
|
|
|
apis = &apis[7];
|
|
|
|
} else if (g_strstr_len (apis, 6, GST_GL_API_OPENGL_NAME)) {
|
|
|
|
ret |= GST_GL_API_OPENGL;
|
|
|
|
apis = &apis[6];
|
|
|
|
} else if (g_strstr_len (apis, 5, GST_GL_API_GLES1_NAME)) {
|
|
|
|
ret |= GST_GL_API_GLES1;
|
|
|
|
apis = &apis[5];
|
|
|
|
} else if (g_strstr_len (apis, 5, GST_GL_API_GLES2_NAME)) {
|
|
|
|
ret |= GST_GL_API_GLES2;
|
|
|
|
apis = &apis[5];
|
|
|
|
} else {
|
|
|
|
GST_ERROR ("Error parsing \'%s\'", apis);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2014-03-15 12:51:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_gl_platform_to_string():
|
|
|
|
*
|
|
|
|
* @api: a #GstGLPlatform to stringify
|
|
|
|
*
|
|
|
|
* Returns: A space seperated string of the OpenGL platforms enabled in @api
|
|
|
|
*/
|
|
|
|
gchar *
|
|
|
|
gst_gl_platform_to_string (GstGLPlatform platform)
|
|
|
|
{
|
|
|
|
GString *str = NULL;
|
|
|
|
gchar *ret;
|
|
|
|
|
|
|
|
if (platform == GST_GL_PLATFORM_NONE) {
|
|
|
|
str = g_string_new ("none");
|
|
|
|
goto out;
|
|
|
|
} else if (platform == GST_GL_PLATFORM_ANY) {
|
|
|
|
str = g_string_new ("any");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
str = g_string_new ("");
|
|
|
|
|
|
|
|
if (platform & GST_GL_PLATFORM_GLX) {
|
|
|
|
str = g_string_append (str, "glx ");
|
|
|
|
}
|
|
|
|
if (platform & GST_GL_PLATFORM_EGL) {
|
|
|
|
str = g_string_append (str, "egl ");
|
|
|
|
}
|
|
|
|
if (platform & GST_GL_PLATFORM_WGL) {
|
|
|
|
str = g_string_append (str, "wgl ");
|
|
|
|
}
|
|
|
|
if (platform & GST_GL_PLATFORM_CGL) {
|
|
|
|
str = g_string_append (str, "cgl ");
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
if (!str)
|
2014-03-16 14:06:37 +00:00
|
|
|
str = g_string_new ("unknown");
|
2014-03-15 12:51:44 +00:00
|
|
|
|
|
|
|
ret = g_string_free (str, FALSE);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_gl_platform_from_string():
|
|
|
|
*
|
|
|
|
* @platform_s: a space seperated string of OpenGL platformss
|
|
|
|
*
|
|
|
|
* Returns: The #GstGLPlatform represented by @platform_s
|
|
|
|
*/
|
|
|
|
GstGLPlatform
|
|
|
|
gst_gl_platform_from_string (const gchar * platform_s)
|
|
|
|
{
|
|
|
|
GstGLPlatform ret = GST_GL_PLATFORM_NONE;
|
|
|
|
gchar *platform = (gchar *) platform_s;
|
|
|
|
|
|
|
|
if (!platform || platform[0] == '\0') {
|
|
|
|
ret = GST_GL_PLATFORM_ANY;
|
|
|
|
} else {
|
|
|
|
while (platform) {
|
|
|
|
if (platform[0] == '\0') {
|
|
|
|
break;
|
|
|
|
} else if (platform[0] == ' ' || platform[0] == ',') {
|
|
|
|
platform = &platform[1];
|
|
|
|
} else if (g_strstr_len (platform, 3, "glx")) {
|
|
|
|
ret |= GST_GL_PLATFORM_GLX;
|
|
|
|
platform = &platform[3];
|
|
|
|
} else if (g_strstr_len (platform, 3, "egl")) {
|
|
|
|
ret |= GST_GL_PLATFORM_EGL;
|
|
|
|
platform = &platform[3];
|
|
|
|
} else if (g_strstr_len (platform, 3, "wgl")) {
|
|
|
|
ret |= GST_GL_PLATFORM_WGL;
|
|
|
|
platform = &platform[3];
|
|
|
|
} else if (g_strstr_len (platform, 3, "cgl")) {
|
|
|
|
ret |= GST_GL_PLATFORM_CGL;
|
|
|
|
platform = &platform[3];
|
|
|
|
} else {
|
|
|
|
GST_ERROR ("Error parsing \'%s\'", platform);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|