mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 00:31:13 +00:00
[903/906] api: add GstGLPlatform to/from string
This commit is contained in:
parent
d6e6ac471d
commit
f772bc1afc
2 changed files with 91 additions and 1 deletions
|
@ -129,3 +129,90 @@ gst_gl_api_from_string (const gchar * apis_s)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
return "unknown";
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ typedef enum {
|
|||
|
||||
typedef enum
|
||||
{
|
||||
GST_GL_PLATFORM_UNKNOWN = 0,
|
||||
GST_GL_PLATFORM_NONE = 0,
|
||||
GST_GL_PLATFORM_EGL = (1 << 0),
|
||||
GST_GL_PLATFORM_GLX = (1 << 1),
|
||||
GST_GL_PLATFORM_WGL = (1 << 2),
|
||||
|
@ -119,6 +119,9 @@ typedef struct _GstGLFuncs
|
|||
gchar * gst_gl_api_to_string (GstGLAPI api);
|
||||
GstGLAPI gst_gl_api_from_string (const gchar * api_s);
|
||||
|
||||
gchar * gst_gl_platform_to_string (GstGLPlatform api);
|
||||
GstGLPlatform gst_gl_platform_from_string (const gchar * platform_s);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_GL_API_H__ */
|
||||
|
|
Loading…
Reference in a new issue