Top |
A GstUri object can be used to parse and split a URI string into its constituant parts. Two GstUri objects can be joined to make a new GstUri using the algorithm described in RFC3986.
GstUri * gst_uri_new (const gchar *scheme
,const gchar *userinfo
,const gchar *host
,guint port
,const gchar *path
,const gchar *query
,const gchar *fragment
);
Creates a new GstUri object with the given URI parts. The path and query strings will be broken down into their elements. All strings should not be escaped except where indicated.
scheme |
The scheme for the new URI. |
[nullable] |
userinfo |
The user-info for the new URI. |
[nullable] |
host |
The host name for the new URI. |
[nullable] |
port |
The port number for the new URI or |
|
path |
The path for the new URI with '/' separating path elements. |
[nullable] |
query |
The query string for the new URI with '&' separating query elements. Elements containing '&' characters should encode them as "%26". |
[nullable] |
fragment |
The fragment name for the new URI. |
[nullable] |
Since: 1.6
GstUri * gst_uri_new_with_base (GstUri *base
,const gchar *scheme
,const gchar *userinfo
,const gchar *host
,guint port
,const gchar *path
,const gchar *query
,const gchar *fragment
);
Like gst_uri_new()
, but joins the new URI onto a base URI.
base |
The base URI to join the new URI to. |
[transfer none][nullable] |
scheme |
The scheme for the new URI. |
[nullable] |
userinfo |
The user-info for the new URI. |
[nullable] |
host |
The host name for the new URI. |
[nullable] |
port |
The port number for the new URI or |
|
path |
The path for the new URI with '/' separating path elements. |
[nullable] |
query |
The query string for the new URI with '&' separating query elements. Elements containing '&' characters should encode them as "%26". |
[nullable] |
fragment |
The fragment name for the new URI. |
[nullable] |
Since: 1.6
GstUri *
gst_uri_from_string (const gchar *uri
);
Parses a URI string into a new GstUri object. Will return NULL if the URI cannot be parsed.
Since: 1.6
GstUri * gst_uri_from_string_with_base (GstUri *base
,const gchar *uri
);
Like gst_uri_from_string()
but also joins with a base URI.
base |
The base URI to join the new URI with. |
[transfer none][nullable] |
uri |
The URI string to parse. |
Since: 1.6
GstUri *
gst_uri_copy (const GstUri *uri
);
Create a new GstUri object with the same data as this GstUri object.
If uri
is NULL
then returns NULL
.
gboolean gst_uri_equal (const GstUri *first
,const GstUri *second
);
Compares two GstUri objects to see if they represent the same normalized URI.
Since: 1.6
GstUri * gst_uri_join (GstUri *base_uri
,GstUri *ref_uri
);
Join a reference URI onto a base URI using the method from RFC 3986.
If either URI is NULL
then the other URI will be returned with the ref count
increased.
base_uri |
The base URI to join another to. |
[transfer none][nullable] |
ref_uri |
The reference URI to join onto the base URI. |
[transfer none][nullable] |
Since: 1.6
gchar * gst_uri_join_strings (const gchar *base_uri
,const gchar *ref_uri
);
This is a convenience function to join two URI strings and return the result.
The returned string should be g_free()
'd after use.
base_uri |
The percent-encoded base URI. |
|
ref_uri |
The percent-encoded reference URI to join to the |
Since: 1.6
gboolean
gst_uri_is_writable (const GstUri *uri
);
Check if it is safe to write to this GstUri.
Check if the refcount of uri
is exactly 1, meaning that no other
reference exists to the GstUri and that the GstUri is therefore writable.
Modification of a GstUri should only be done after verifying that it is writable.
Since: 1.6
GstUri *
gst_uri_make_writable (GstUri *uri
);
Make the GstUri writable.
Checks if uri
is writable, and if so the original object is returned. If
not, then a writable copy is made and returned. This gives away the
reference to uri
and returns a reference to the new GstUri.
If uri
is NULL
then NULL
is returned.
Since: 1.6
gchar *
gst_uri_to_string (const GstUri *uri
);
Convert the URI to a string.
Returns the URI as held in this object as a gchar* nul-terminated string.
The caller should g_free()
the string once they are finished with it.
The string is put together as described in RFC 3986.
Since: 1.6
GstUri *
gst_uri_ref (GstUri *uri
);
Add a reference to this GstUri object. See gst_mini_object_ref()
for further
info.
void
gst_uri_unref (GstUri *uri
);
Decrement the reference count to this GstUri object.
If the reference count drops to 0 then finalize this object.
See gst_mini_object_unref()
for further info.
gboolean
gst_uri_is_normalized (const GstUri *uri
);
Tests the uri
to see if it is normalized. A NULL
uri
is considered to be
normalized.
Since: 1.6
gboolean
gst_uri_normalize (GstUri *uri
);
Normalization will remove extra path segments ("." and "..") from the URI. It will also convert the scheme and host name to lower case and any percent-encoded values to uppercase.
The GstUri object must be writable. Check with gst_uri_is_writable()
or use
gst_uri_make_writable()
first.
Since: 1.6
const gchar *
gst_uri_get_scheme (const GstUri *uri
);
Get the scheme name from the URI or NULL
if it doesn't exist.
If uri
is NULL
then returns NULL
.
gboolean gst_uri_set_scheme (GstUri *uri
,const gchar *scheme
);
Set or unset the scheme for the URI.
Since: 1.6
const gchar *
gst_uri_get_userinfo (const GstUri *uri
);
Get the userinfo (usually in the form "username:password") from the URI
or NULL
if it doesn't exist. If uri
is NULL
then returns NULL
.
Since: 1.6
gboolean gst_uri_set_userinfo (GstUri *uri
,const gchar *userinfo
);
Set or unset the user information for the URI.
Since: 1.6
const gchar *
gst_uri_get_host (const GstUri *uri
);
Get the host name from the URI or NULL
if it doesn't exist.
If uri
is NULL
then returns NULL
.
Since: 1.6
gboolean gst_uri_set_host (GstUri *uri
,const gchar *host
);
Set or unset the host for the URI.
Since: 1.6
guint
gst_uri_get_port (const GstUri *uri
);
Get the port number from the URI or GST_URI_NO_PORT
if it doesn't exist.
If uri
is NULL
then returns GST_URI_NO_PORT
.
Since: 1.6
gboolean gst_uri_set_port (GstUri *uri
,guint port
);
Set or unset the port number for the URI.
uri |
The GstUri to modify. |
[transfer none][nullable] |
port |
The new port number to set or |
Since: 1.6
gchar *
gst_uri_get_path (const GstUri *uri
);
Extract the path string from the URI object.
Since: 1.6
gboolean gst_uri_set_path (GstUri *uri
,const gchar *path
);
Sets or unsets the path in the URI.
Since: 1.6
gchar *
gst_uri_get_path_string (const GstUri *uri
);
Extract the path string from the URI object as a percent encoded URI path.
Since: 1.6
gboolean gst_uri_set_path_string (GstUri *uri
,const gchar *path
);
Sets or unsets the path in the URI.
Since: 1.6
GList *
gst_uri_get_path_segments (const GstUri *uri
);
Get a list of path segments from the URI.
A GList of path segment
strings or NULL
if no path segments are available. Free the list
when no longer needed with g_list_free_full(list, g_free).
[transfer full][element-type gchar*]
Since: 1.6
gboolean gst_uri_set_path_segments (GstUri *uri
,GList *path_segments
);
Replace the path segments list in the URI.
uri |
The GstUri to modify. |
[transfer none][nullable] |
path_segments |
The new path list to set. |
[transfer full][nullable][element-type gchar*] |
Since: 1.6
gboolean gst_uri_append_path (GstUri *uri
,const gchar *relative_path
);
Append a path onto the end of the path in the URI. The path is not
normalized, call gst_uri_normalize()
to normalize the path.
uri |
The GstUri to modify. |
[transfer none][nullable] |
relative_path |
Relative path to append to the end of the current path. |
Since: 1.6
gboolean gst_uri_append_path_segment (GstUri *uri
,const gchar *path_segment
);
Append a single path segment onto the end of the URI path.
uri |
The GstUri to modify. |
[transfer none][nullable] |
path_segment |
The path segment string to append to the URI path. |
Since: 1.6
gchar *
gst_uri_get_query_string (const GstUri *uri
);
Get a percent encoded URI query string from the uri
.
Since: 1.6
gboolean gst_uri_set_query_string (GstUri *uri
,const gchar *query
);
Sets or unsets the query table in the URI.
Since: 1.6
GHashTable *
gst_uri_get_query_table (const GstUri *uri
);
Get the query table from the URI. Keys and values in the table are freed
with g_free when they are deleted. A value may be NULL
to indicate that
the key should appear in the query string in the URI, but does not have a
value. Free the returned GHashTable with
when it is
no longer required. Modifying this hash table will modify the query in the
URI.g_hash_table_unref()
Since: 1.6
gboolean gst_uri_set_query_table (GstUri *uri
,GHashTable *query_table
);
Set the query table to use in the URI. The old table is unreferenced and a
reference to the new one is used instead. A value if NULL
for query_table
will remove the query string from the URI.
uri |
The GstUri to modify. |
[transfer none][nullable] |
query_table |
The new query table to use. |
[transfer none][nullable][element-type gchar* gchar*] |
Since: 1.6
const gchar * gst_uri_get_query_value (const GstUri *uri
,const gchar *query_key
);
Get the value associated with the query_key
key. Will return NULL
if the
key has no value or if the key does not exist in the URI query table. Because
NULL
is returned for both missing keys and keys with no value, you should
use gst_uri_query_has_key()
to determine if a key is present in the URI
query.
Since: 1.6
gboolean gst_uri_set_query_value (GstUri *uri
,const gchar *query_key
,const gchar *query_value
);
This inserts or replaces a key in the query table. A query_value
of NULL
indicates that the key has no associated value, but will still be present in
the query string.
uri |
The GstUri to modify. |
[transfer none][nullable] |
query_key |
The key for the query entry. |
[transfer none] |
query_value |
The value for the key. |
[transfer none][nullable] |
Since: 1.6
gboolean gst_uri_remove_query_key (GstUri *uri
,const gchar *query_key
);
Remove an entry from the query table by key.
Since: 1.6
gboolean gst_uri_query_has_key (const GstUri *uri
,const gchar *query_key
);
Check if there is a query table entry for the query_key
key.
Since: 1.6
GList *
gst_uri_get_query_keys (const GstUri *uri
);
Get a list of the query keys from the URI.
A list of keys from
the URI query. Free the list with g_list_free()
.
[transfer container][element-type gchar*]
Since: 1.6
const gchar *
gst_uri_get_fragment (const GstUri *uri
);
Get the fragment name from the URI or NULL
if it doesn't exist.
If uri
is NULL
then returns NULL
.
Since: 1.6
gboolean gst_uri_set_fragment (GstUri *uri
,const gchar *fragment
);
Sets the fragment string in the URI. Use a value of NULL
in fragment
to
unset the fragment string.
uri |
The GstUri to modify. |
[transfer none][nullable] |
fragment |
The fragment string to set. |
[nullable] |
Since: 1.6