--- a/gstreamer_core/gst/gsturi.c Wed Mar 31 22:03:18 2010 +0300
+++ b/gstreamer_core/gst/gsturi.c Tue Aug 31 15:30:33 2010 +0300
@@ -64,9 +64,10 @@
GType
gst_uri_handler_get_type (void)
{
- static GType urihandler_type = 0;
+ static volatile gsize urihandler_type = 0;
- if (G_UNLIKELY (urihandler_type == 0)) {
+ if (g_once_init_enter (&urihandler_type)) {
+ GType _type;
static const GTypeInfo urihandler_info = {
sizeof (GstURIHandlerInterface),
gst_uri_handler_base_init,
@@ -80,14 +81,16 @@
NULL
};
- urihandler_type = g_type_register_static (G_TYPE_INTERFACE,
+ _type = g_type_register_static (G_TYPE_INTERFACE,
"GstURIHandler", &urihandler_info, 0);
GST_DEBUG_CATEGORY_INIT (gst_uri_handler_debug, "GST_URI", GST_DEBUG_BOLD,
"handling of URIs");
+ g_once_init_leave (&urihandler_type, _type);
}
return urihandler_type;
}
+
static void
gst_uri_handler_base_init (gpointer g_class)
{
@@ -239,7 +242,7 @@
return -1;
}
- second_digit = hex_to_int (*scanner++);
+ second_digit = hex_to_int (*scanner);
if (second_digit < 0) {
return -1;
}
@@ -309,7 +312,8 @@
if (g_ascii_isalpha (*check)) {
check++;
- while (g_ascii_isalnum (*check))
+ while (g_ascii_isalnum (*check) || *check == '+'
+ || *check == '-' || *check == '.')
check++;
}
@@ -321,7 +325,8 @@
* @protocol: A string
*
* Tests if the given string is a valid protocol identifier. Protocols
- * must consist of alphanumeric characters and not start with a number.
+ * must consist of alphanumeric characters, '+', '-' and '.' and must
+ * start with a alphabetic character. See RFC 3986 Section 3.1.
*
* Returns: TRUE if the string is a valid protocol identifier, FALSE otherwise.
*/
@@ -346,7 +351,7 @@
* @uri: A URI string
*
* Tests if the given string is a valid URI identifier. URIs start with a valid
- * protocol followed by "://" and maybe a string identifying the location.
+ * scheme followed by ":" and maybe a string identifying the location.
*
* Returns: TRUE if the string is a valid URI
*/
@@ -363,7 +368,7 @@
gst_uri_protocol_check_internal (uri, &endptr);
- return (*endptr == ':' && *(endptr + 1) == '/' && *(endptr + 2) == '/');
+ return *endptr == ':';
}
/**
@@ -387,9 +392,9 @@
g_return_val_if_fail (uri != NULL, NULL);
g_return_val_if_fail (gst_uri_is_valid (uri), NULL);
- colon = strstr (uri, "://");
+ colon = strstr (uri, ":");
- return g_strdown (g_strndup (uri, colon - uri));
+ return g_ascii_strdown (uri, colon - uri);
}
/**
@@ -416,12 +421,12 @@
g_return_val_if_fail (protocol != NULL, FALSE);
g_return_val_if_fail (gst_uri_is_valid (uri), FALSE);
- colon = strstr (uri, "://");
+ colon = strstr (uri, ":");
if (colon == NULL)
return FALSE;
- return (strncmp (uri, protocol, (gsize) (colon - uri)) == 0);
+ return (g_ascii_strncasecmp (uri, protocol, (gsize) (colon - uri)) == 0);
}
/**
@@ -450,6 +455,8 @@
g_return_val_if_fail (gst_uri_is_valid (uri), NULL);
colon = strstr (uri, "://");
+ if (!colon)
+ return NULL;
unescaped = unescape_string (colon + 3, "/");
@@ -468,7 +475,7 @@
#endif
GST_LOG ("extracted location '%s' from URI '%s'", GST_STR_NULL (unescaped),
- uri);;
+ uri);
return unescaped;
}
@@ -489,15 +496,17 @@
gchar *
gst_uri_construct (const gchar * protocol, const gchar * location)
{
- char *escaped;
+ char *escaped, *proto_lowercase;
char *retval;
g_return_val_if_fail (gst_uri_protocol_is_valid (protocol), NULL);
g_return_val_if_fail (location != NULL, NULL);
+ proto_lowercase = g_ascii_strdown (protocol, -1);
escaped = escape_string (location);
- retval = g_strdup_printf ("%s://%s", protocol, escaped);
+ retval = g_strdup_printf ("%s://%s", proto_lowercase, escaped);
g_free (escaped);
+ g_free (proto_lowercase);
return retval;
}
@@ -678,8 +687,13 @@
iface = GST_URI_HANDLER_GET_INTERFACE (handler);
g_return_val_if_fail (iface != NULL, GST_URI_UNKNOWN);
- g_return_val_if_fail (iface->get_type != NULL, GST_URI_UNKNOWN);
- ret = iface->get_type ();
+ g_return_val_if_fail (iface->get_type != NULL
+ || iface->get_type_full != NULL, GST_URI_UNKNOWN);
+
+ if (iface->get_type != NULL)
+ ret = iface->get_type ();
+ else
+ ret = iface->get_type_full (G_OBJECT_TYPE (handler));
g_return_val_if_fail (GST_URI_TYPE_IS_VALID (ret), GST_URI_UNKNOWN);
return ret;
@@ -772,6 +786,8 @@
gst_uri_handler_set_uri (GstURIHandler * handler, const gchar * uri)
{
GstURIHandlerInterface *iface;
+ gboolean ret;
+ gchar *new_uri, *protocol, *location, *colon;
g_return_val_if_fail (GST_IS_URI_HANDLER (handler), FALSE);
g_return_val_if_fail (gst_uri_is_valid (uri), FALSE);
@@ -779,7 +795,21 @@
iface = GST_URI_HANDLER_GET_INTERFACE (handler);
g_return_val_if_fail (iface != NULL, FALSE);
g_return_val_if_fail (iface->set_uri != NULL, FALSE);
- return iface->set_uri (handler, uri);
+
+ protocol = gst_uri_get_protocol (uri);
+
+ colon = strstr (uri, ":");
+ location = g_strdup (colon);
+
+ new_uri = g_strdup_printf ("%s%s", protocol, location);
+
+ ret = iface->set_uri (handler, uri);
+
+ g_free (new_uri);
+ g_free (location);
+ g_free (protocol);
+
+ return ret;
}
/**