/**
* SECTION:gsturihandler
+ * @title: GstUriHandler
* @short_description: Interface to ease URI handling in plugins.
*
* The #GstURIHandler is an interface that is implemented by Source and Sink
/**
* SECTION:gsturi
+ * @title: GstUri
* @short_description: URI parsing and manipulation.
*
* A #GstUri object can be used to parse and split a URI string into its
_gst_uri_new (void)
{
GstUri *uri;
+
+ g_return_val_if_fail (gst_is_initialized (), NULL);
+
uri = GST_URI_CAST (g_slice_new0 (GstUri));
if (uri)
if (eoh == NULL || eoh > eoa) {
GST_DEBUG ("Unable to parse the host part of the URI '%s'.",
orig_uri);
- _gst_uri_free (uri_obj);
+ gst_uri_unref (uri_obj);
return NULL;
}
reoh = eoh + 1;
if (uri[0] != ':' || strspn (uri + 1, "0123456789") != eoa - uri - 1) {
GST_DEBUG ("Unable to parse host/port part of the URI '%s'.",
orig_uri);
- _gst_uri_free (uri_obj);
+ gst_uri_unref (uri_obj);
return NULL;
}
/* otherwise treat port as unsigned decimal number */
uri->fragment = g_strdup (fragment);
return TRUE;
}
+
+/**
+ * gst_uri_get_media_fragment_table:
+ * @uri: (nullable): The #GstUri to get the fragment table from.
+ *
+ * Get the media fragment table from the URI, as defined by "Media Fragments URI 1.0".
+ * Hash table returned by this API is a list of "key-value" pairs, and the each
+ * pair is generated by splitting "URI fragment" per "&" sub-delims, then "key"
+ * and "value" are splitted by "=" sub-delims. The "key" returned by this API may
+ * be undefined keyword by standard.
+ * A value may be %NULL to indicate that the key should appear in the fragment
+ * string in the URI, but does not have a value. Free the returned #GHashTable
+ * with #g_hash_table_unref() when it is no longer required.
+ * Modifying this hash table does not affect the fragment in the URI.
+ *
+ * See more about Media Fragments URI 1.0 (W3C) at https://www.w3.org/TR/media-frags/
+ *
+ * Returns: (transfer full)(element-type gchar* gchar*): The fragment hash table
+ * from the URI.
+ *
+ * Since: 1.12
+ */
+GHashTable *
+gst_uri_get_media_fragment_table (const GstUri * uri)
+{
+ g_return_val_if_fail (uri == NULL || GST_IS_URI (uri), NULL);
+
+ if (!uri->fragment)
+ return NULL;
+ return _gst_uri_string_to_table (uri->fragment, "&", "=", TRUE, TRUE);
+}