gchar * gst_glsl_version_profile_to_string (GstGLSLVersion version, GstGLSLProfile profile) { const gchar *version_s, *profile_s; if (!_is_valid_version_profile (version, profile)) return NULL; version_s = gst_glsl_version_to_string (version); /* no profiles in GL/ES <= 150 */ if (version <= GST_GLSL_VERSION_150) profile_s = NULL; else profile_s = gst_glsl_profile_to_string (profile); if (!version_s) return NULL; if (profile_s) return g_strdup_printf ("%s %s", version_s, profile_s); return g_strdup (version_s); }
gboolean gst_glsl_version_profile_from_string (const gchar * string, GstGLSLVersion * version_ret, GstGLSLProfile * profile_ret) { gchar *str, *version_s, *profile_s; GstGLSLVersion version = GST_GLSL_VERSION_NONE; GstGLSLProfile profile = GST_GLSL_PROFILE_NONE; gint i; _init_debug (); if (!string) goto error; str = g_strdup (string); version_s = g_strstrip (str); /* skip possible #version prefix */ if (str[0] == '#') { if (!(version_s = (gchar *) _check_valid_version_preprocessor_string (version_s))) { GST_WARNING ("Invalid preprocesser directive detected: %s", version_s); g_free (str); goto error; } } version_s = g_strstrip (version_s); i = 0; while (version_s && version_s[i] != '\0' && g_ascii_isdigit (version_s[i])) i++; /* wrong version length */ if (i != 3) { GST_WARNING ("version number has the wrong number of digits: %s", version_s); g_free (str); goto error; } if (version_s[i] != 0) { version_s[i] = '\0'; i++; profile_s = &version_s[i]; profile_s = g_strstrip (profile_s); profile = gst_glsl_profile_from_string (profile_s); } version = gst_glsl_version_from_string (version_s); g_free (str); /* check whether the parsed data is valid */ if (!version) { GST_WARNING ("Could not map the version number to a valid GLSL version:"); goto error; } if (!_is_valid_version_profile (version, profile)) { GST_WARNING ("Invalid version/profile combination specified: %s %s", gst_glsl_version_to_string (version), gst_glsl_profile_to_string (profile)); goto error; } /* got a profile when none was expected */ if (version <= GST_GLSL_VERSION_140 && profile != GST_GLSL_PROFILE_NONE) { GST_WARNING ("Found a profile (%s) with a version (%s) that does not support " "profiles", gst_glsl_version_to_string (version), gst_glsl_profile_to_string (profile)); goto error; } _fixup_version_profile (&version, &profile); if (profile_ret) *profile_ret = profile; if (version_ret) *version_ret = version; return TRUE; error: { if (profile_ret) *profile_ret = GST_GLSL_PROFILE_NONE; if (version_ret) *version_ret = GST_GLSL_VERSION_NONE; return FALSE; } }