diff --git a/gst-libs/gst/gl/glprototypes/gles1.h b/gst-libs/gst/gl/glprototypes/gles1.h index 174cf63f60..6a0d06ec32 100644 --- a/gst-libs/gst/gl/glprototypes/gles1.h +++ b/gst-libs/gst/gl/glprototypes/gles1.h @@ -40,7 +40,7 @@ GST_GL_EXT_BEGIN (only_in_gles1, 255, 255, - GST_GL_API_GLES, + GST_GL_API_GLES1, "\0", "\0") GST_GL_EXT_FUNCTION (void, ClipPlanef, (GLenum plane, const GLfloat *equation)) diff --git a/gst-libs/gst/gl/glprototypes/gles1gles2.h b/gst-libs/gst/gl/glprototypes/gles1gles2.h index 1f6e3eafc4..9c301a72d4 100644 --- a/gst-libs/gst/gl/glprototypes/gles1gles2.h +++ b/gst-libs/gst/gl/glprototypes/gles1gles2.h @@ -40,7 +40,7 @@ GST_GL_EXT_BEGIN (only_in_both_gles, 255, 255, - GST_GL_API_GLES | + GST_GL_API_GLES1 | GST_GL_API_GLES2, "\0", "\0") diff --git a/gst-libs/gst/gl/glprototypes/gles1gles2opengl.h b/gst-libs/gst/gl/glprototypes/gles1gles2opengl.h index b4cf62d4da..63da140b91 100644 --- a/gst-libs/gst/gl/glprototypes/gles1gles2opengl.h +++ b/gst-libs/gst/gl/glprototypes/gles1gles2opengl.h @@ -43,7 +43,7 @@ available */ GST_GL_EXT_BEGIN (core, 0, 0, - GST_GL_API_GLES | GST_GL_API_GLES2, + GST_GL_API_GLES1 | GST_GL_API_GLES2, "\0", "\0") GST_GL_EXT_FUNCTION (void, BindTexture, @@ -181,7 +181,7 @@ GST_GL_EXT_END () GST_GL_EXT_BEGIN (only_in_both_gles_and_gl_1_3, 1, 3, - GST_GL_API_GLES | + GST_GL_API_GLES1 | GST_GL_API_GLES2, "\0", "\0") @@ -210,7 +210,7 @@ GST_GL_EXT_END () GST_GL_EXT_BEGIN (only_in_both_gles_and_gl_1_5, 1, 5, - GST_GL_API_GLES | + GST_GL_API_GLES1 | GST_GL_API_GLES2, "\0", "\0") @@ -219,7 +219,7 @@ GST_GL_EXT_FUNCTION (void, GetBufferParameteriv, GST_GL_EXT_END () GST_GL_EXT_BEGIN (vbos, 1, 5, - GST_GL_API_GLES | + GST_GL_API_GLES1 | GST_GL_API_GLES2, "ARB\0", "vertex_buffer_object\0") @@ -249,7 +249,7 @@ GST_GL_EXT_END () /* Available in GL 1.3, the multitexture extension or GLES. These are required */ GST_GL_EXT_BEGIN (multitexture_part0, 1, 3, - GST_GL_API_GLES | + GST_GL_API_GLES1 | GST_GL_API_GLES2, "ARB\0", "multitexture\0") diff --git a/gst-libs/gst/gl/glprototypes/gles1opengl.h b/gst-libs/gst/gl/glprototypes/gles1opengl.h index c371a777b8..ad6230d5bc 100644 --- a/gst-libs/gst/gl/glprototypes/gles1opengl.h +++ b/gst-libs/gst/gl/glprototypes/gles1opengl.h @@ -39,7 +39,7 @@ */ GST_GL_EXT_BEGIN (multitexture_part1, 1, 3, - GST_GL_API_GLES, + GST_GL_API_GLES1, "ARB\0", "multitexture\0") GST_GL_EXT_FUNCTION (void, ClientActiveTexture, @@ -50,7 +50,7 @@ GST_GL_EXT_END () supports fixed-function (ie, GL and GLES1.1) */ GST_GL_EXT_BEGIN (fixed_function_core, 0, 0, - GST_GL_API_GLES, + GST_GL_API_GLES1, "\0", "\0") GST_GL_EXT_FUNCTION (void, AlphaFunc, diff --git a/gst-libs/gst/gl/gstglapi.c b/gst-libs/gst/gl/gstglapi.c index ee3cb36630..c67567234b 100644 --- a/gst-libs/gst/gl/gstglapi.c +++ b/gst-libs/gst/gl/gstglapi.c @@ -23,8 +23,15 @@ #include "gstglapi.h" +/** + * gst_gl_api_to_string(): + * + * @api: a #GstGLAPI to stringify + * + * Returns: A space seperated string of the OpenGL api's enabled in @api + */ gchar * -gst_gl_api_string (GstGLAPI api) +gst_gl_api_to_string (GstGLAPI api) { GString *str = NULL; gchar *ret; @@ -38,34 +45,34 @@ gst_gl_api_string (GstGLAPI api) } if (api & GST_GL_API_OPENGL) { - str = g_string_new ("opengl"); + str = g_string_new (GST_GL_API_OPENGL_NAME); } if (api & GST_GL_API_OPENGL3) { if (str) { - g_string_append (str, " opengl3"); + g_string_append (str, " " GST_GL_API_OPENGL3_NAME); } else { - str = g_string_new ("opengl3"); + str = g_string_new (GST_GL_API_OPENGL3_NAME); } } - if (api & GST_GL_API_GLES) { + if (api & GST_GL_API_GLES1) { if (str) { - g_string_append (str, " gles1"); + g_string_append (str, " " GST_GL_API_GLES1_NAME); } else { - str = g_string_new ("gles1"); + str = g_string_new (GST_GL_API_GLES1_NAME); } } if (api & GST_GL_API_GLES2) { if (str) { - g_string_append (str, " gles2"); + g_string_append (str, " " GST_GL_API_GLES2_NAME); } else { - str = g_string_new ("gles2"); + str = g_string_new (GST_GL_API_GLES2_NAME); } } if (api & GST_GL_API_GLES3) { if (str) { - g_string_append (str, " gles3"); + g_string_append (str, " " GST_GL_API_GLES3_NAME); } else { - str = g_string_new ("gles3"); + str = g_string_new (GST_GL_API_GLES3_NAME); } } @@ -73,3 +80,49 @@ gst_gl_api_string (GstGLAPI api) return ret; } + +/** + * 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 if (g_strstr_len (apis, 5, GST_GL_API_GLES3_NAME)) { + ret |= GST_GL_API_GLES3; + apis = &apis[5]; + } else { + GST_ERROR ("Error parsing \'%s\'", apis); + break; + } + } + } + + return ret; +} diff --git a/gst-libs/gst/gl/gstglapi.h b/gst-libs/gst/gl/gstglapi.h index b5969c285b..6c6fdbb917 100644 --- a/gst-libs/gst/gl/gstglapi.h +++ b/gst-libs/gst/gl/gstglapi.h @@ -63,13 +63,19 @@ typedef enum { GST_GL_API_NONE = 0, GST_GL_API_OPENGL = (1 << 0), GST_GL_API_OPENGL3 = (1 << 1), - GST_GL_API_GLES = (1 << 15), + GST_GL_API_GLES1 = (1 << 15), GST_GL_API_GLES2 = (1 << 16), GST_GL_API_GLES3 = (1 << 17), GST_GL_API_ANY = G_MAXUINT32 } GstGLAPI; +#define GST_GL_API_OPENGL_NAME "opengl" +#define GST_GL_API_OPENGL3_NAME "opengl3" +#define GST_GL_API_GLES1_NAME "gles1" +#define GST_GL_API_GLES2_NAME "gles2" +#define GST_GL_API_GLES3_NAME "gles3" + typedef enum { GST_GL_PLATFORM_UNKNOWN = 0, @@ -110,7 +116,8 @@ typedef struct _GstGLFuncs #undef GST_GL_EXT_FUNCTION #undef GST_GL_EXT_END -gchar * gst_gl_api_string (GstGLAPI api); +gchar * gst_gl_api_to_string (GstGLAPI api); +GstGLAPI gst_gl_api_from_string (const gchar * api_s); G_END_DECLS diff --git a/gst-libs/gst/gl/gstglcontext.c b/gst-libs/gst/gl/gstglcontext.c index 16a985b557..c385682cfe 100644 --- a/gst-libs/gst/gl/gstglcontext.c +++ b/gst-libs/gst/gl/gstglcontext.c @@ -572,43 +572,6 @@ _compiled_api (void) return ret; } -GstGLAPI -_parse_gl_api (const gchar * apis_s) -{ - GstGLAPI ret = GST_GL_API_NONE; - gchar *apis = (gchar *) apis_s; - - while (apis) { - if (apis[0] == '\0') { - break; - } else if (apis[0] == ' ' || apis[0] == ',') { - apis = &apis[1]; - } else if (g_strstr_len (apis, 7, "opengl3")) { - ret |= GST_GL_API_OPENGL3; - apis = &apis[7]; - } else if (g_strstr_len (apis, 6, "opengl")) { - ret |= GST_GL_API_OPENGL; - apis = &apis[6]; - } else if (g_strstr_len (apis, 5, "gles1")) { - ret |= GST_GL_API_GLES; - apis = &apis[5]; - } else if (g_strstr_len (apis, 5, "gles2")) { - ret |= GST_GL_API_GLES2; - apis = &apis[5]; - } else if (g_strstr_len (apis, 5, "gles3")) { - ret |= GST_GL_API_GLES3; - apis = &apis[5]; - } else { - break; - } - } - - if (ret == GST_GL_API_NONE) - ret = GST_GL_API_ANY; - - return ret; -} - static void _unlock_create_thread (GstGLContext * context) { @@ -653,10 +616,10 @@ gst_gl_context_create_thread (GstGLContext * context) user_choice = g_getenv ("GST_GL_API"); - user_api = _parse_gl_api (user_choice); - user_api_string = gst_gl_api_string (user_api); + user_api = gst_gl_api_from_string (user_choice); + user_api_string = gst_gl_api_to_string (user_api); - compiled_api_s = gst_gl_api_string (compiled_api); + compiled_api_s = gst_gl_api_to_string (compiled_api); if ((user_api & compiled_api) == GST_GL_API_NONE) { g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_WRONG_API, @@ -700,7 +663,7 @@ gst_gl_context_create_thread (GstGLContext * context) g_assert (display->gl_api != GST_GL_API_NONE && display->gl_api != GST_GL_API_ANY); - api_string = gst_gl_api_string (display->gl_api); + api_string = gst_gl_api_to_string (display->gl_api); GST_INFO ("available GL APIs: %s", api_string); if (((compiled_api & display->gl_api) & user_api) == GST_GL_API_NONE) {