Gst.Uri¶
Fields¶
None
Methods¶
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class Gst.Uri¶
A
Gst.Uri
object can be used to parse and split a URI string into its constituent parts. TwoGst.Uri
objects can be joined to make a newGst.Uri
using the algorithm described in RFC3986.- classmethod construct(protocol, location)[source]¶
- Parameters:
- Returns:
a new string for this URI.
- Return type:
Constructs a URI for a given valid protocol and location.
Free-function:
GLib.free
Deprecated since version ???: Use GstURI instead.
- classmethod from_string(uri)[source]¶
- Parameters:
uri (
str
) – The URI string to parse.- Returns:
- Return type:
Parses a URI string into a new
Gst.Uri
object. Will returnNone
if the URI cannot be parsed.New in version 1.6.
- classmethod from_string_escaped(uri)[source]¶
- Parameters:
uri (
str
) – The URI string to parse.- Returns:
- Return type:
Parses a URI string into a new
Gst.Uri
object. Will returnNone
if the URI cannot be parsed. This is identical toGst.Uri.from_string
() except that the userinfo and fragment components of the URI will not be unescaped while parsing.Use this when you need to extract a username and password from the userinfo such as https://user:password`example`.com since either may contain a URI-escaped ‘:’ character.
Gst.Uri.from_string
() will unescape the entire userinfo component, which will make it impossible to know which ‘:’ delineates the username and password.The same applies to the fragment component of the URI, such as https://example.com/path#fragment which may contain a URI-escaped ‘#’.
New in version 1.18.
- classmethod get_location(uri)[source]¶
- Parameters:
uri (
str
) – A URI string- Returns:
the location for this URI. Returns
None
if the URI isn’t valid. If the URI does not contain a location, an empty string is returned.- Return type:
Extracts the location out of a given valid URI, ie. the protocol and “://” are stripped from the URI, which means that the location returned includes the hostname if one is specified. The returned string must be freed using
GLib.free
().Free-function:
GLib.free
- classmethod get_protocol(uri)[source]¶
-
Extracts the protocol out of a given valid URI. The returned string must be freed using
GLib.free
().
- classmethod has_protocol(uri, protocol)[source]¶
- Parameters:
- Returns:
True
if the protocol matches.- Return type:
Checks if the protocol of a given valid URI matches protocol.
- classmethod is_valid(uri)[source]¶
-
Tests if the given string is a valid URI identifier. URIs start with a valid scheme followed by “:” and maybe a string identifying the location.
- classmethod join_strings(base_uri, ref_uri)[source]¶
- Parameters:
- Returns:
A string representing the percent-encoded join of the two URIs.
- Return type:
This is a convenience function to join two URI strings and return the result. The returned string should be
GLib.free
()’d after use.New in version 1.6.
- classmethod new(scheme, userinfo, host, port, path, query, fragment)[source]¶
- Parameters:
port (
int
) – The port number for the new URI orGst.URI_NO_PORT
.path (
str
orNone
) – The path for the new URI with ‘/’ separating path elements.query (
str
orNone
) – The query string for the new URI with ‘&’ separating query elements. Elements containing ‘&’ characters should encode them as “%26”.
- Returns:
A new
Gst.Uri
object.- Return type:
Creates a new
Gst.Uri
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.New in version 1.6.
- classmethod protocol_is_supported(type, protocol)[source]¶
- Parameters:
type (
Gst.URIType
) – Whether to check for a source or a sinkprotocol (
str
) – Protocol that should be checked for (e.g. “http” or “smb”)
- Returns:
- Return type:
Checks if an element exists that supports the given URI protocol. Note that a positive return value does not imply that a subsequent call to
Gst.Element.make_from_uri
() is guaranteed to work.
- classmethod protocol_is_valid(protocol)[source]¶
- Parameters:
protocol (
str
) – A string- Returns:
True
if the string is a valid protocol identifier,False
otherwise.- Return type:
Tests if the given string is a valid protocol identifier. Protocols must consist of alphanumeric characters, ‘+’, ‘-’ and ‘.’ and must start with a alphabetic character. See RFC 3986 Section 3.1.
- append_path(relative_path)[source]¶
- Parameters:
relative_path (
str
orNone
) – Relative path to append to the end of the current path.- Returns:
True
if the path was appended successfully.- Return type:
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.New in version 1.6.
- append_path_segment(path_segment)[source]¶
- Parameters:
path_segment (
str
orNone
) – The path segment string to append to the URI path.- Returns:
True
if the path was appended successfully.- Return type:
Append a single path segment onto the end of the URI path.
New in version 1.6.
- equal(second)[source]¶
- Parameters:
- Returns:
True
if the normalized versions of the two URI’s would be equal.- Return type:
Compares two
Gst.Uri
objects to see if they represent the same normalized URI.New in version 1.6.
- from_string_with_base(uri)[source]¶
-
Like
Gst.Uri.from_string
() but also joins with a base URI.New in version 1.6.
- get_fragment()[source]¶
-
Get the fragment name from the URI or
None
if it doesn’t exist. If self isNone
then returnsNone
.New in version 1.6.
- get_host()[source]¶
-
Get the host name from the URI or
None
if it doesn’t exist. If self isNone
then returnsNone
.New in version 1.6.
- get_media_fragment_table()[source]¶
-
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 split by “=” sub-delims. The “key” returned by this API may be undefined keyword by standard. A value may be
None
to indicate that the key should appear in the fragment string in the URI, but does not have a value. Free the returnedGLib.HashTable
withGLib.HashTable.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/
New in version 1.12.
- get_path()[source]¶
- Returns:
The path from the URI. Once finished with the string should be
GLib.free
()’d.- Return type:
Extract the path string from the URI object.
New in version 1.6.
- get_path_segments()[source]¶
- Returns:
A
GLib.List
of path segment strings orNone
if no path segments are available. Free the list when no longer needed with g_list_free_full(list,GLib.free
).- Return type:
[
str
]
Get a list of path segments from the URI.
New in version 1.6.
- get_path_string()[source]¶
- Returns:
The path from the URI. Once finished with the string should be
GLib.free
()’d.- Return type:
Extract the path string from the URI object as a percent encoded URI path.
New in version 1.6.
- get_port()[source]¶
- Returns:
The port number from the
Gst.Uri
object orGst.URI_NO_PORT
.- Return type:
Get the port number from the URI or
Gst.URI_NO_PORT
if it doesn’t exist. If self isNone
then returnsGst.URI_NO_PORT
.New in version 1.6.
- get_query_keys()[source]¶
- Returns:
A list of keys from the URI query. Free the list with g_list_free().
- Return type:
[
str
]
Get a list of the query keys from the URI.
New in version 1.6.
- get_query_string()[source]¶
- Returns:
A percent encoded query string. Use
GLib.free
() when no longer needed.- Return type:
Get a percent encoded URI query string from the self.
New in version 1.6.
- get_query_string_ordered(keys)[source]¶
- Parameters:
keys ([
str
] orNone
) – AGLib.List
containing the query argument key strings.- Returns:
A percent encoded query string. Use
GLib.free
() when no longer needed.- Return type:
Get a percent encoded URI query string from the self, with query parameters in the order provided by the keys list. Only parameter keys in the list will be added to the resulting URI string. This method can be used by retrieving the keys with
Gst.Uri.get_query_keys
() and then sorting the list, for example.New in version 1.24.
- get_query_table()[source]¶
-
Get the query table from the URI. Keys and values in the table are freed with
GLib.free
when they are deleted. A value may beNone
to indicate that the key should appear in the query string in the URI, but does not have a value. Free the returnedGLib.HashTable
withGLib.HashTable.unref
() when it is no longer required. Modifying this hash table will modify the query in the URI.New in version 1.6.
- get_query_value(query_key)[source]¶
- Parameters:
query_key (
str
) – The key to lookup.- Returns:
The value for the given key, or
None
if not found.- Return type:
Get the value associated with the query_key key. Will return
None
if the key has no value or if the key does not exist in the URI query table. BecauseNone
is returned for both missing keys and keys with no value, you should useGst.Uri.query_has_key
() to determine if a key is present in the URI query.New in version 1.6.
- get_scheme()[source]¶
-
Get the scheme name from the URI or
None
if it doesn’t exist. If self isNone
then returnsNone
.
- get_userinfo()[source]¶
-
Get the userinfo (usually in the form “username:password”) from the URI or
None
if it doesn’t exist. If self isNone
then returnsNone
.New in version 1.6.
- is_normalized()[source]¶
-
Tests the self to see if it is normalized. A
None
self is considered to be normalized.New in version 1.6.
- is_writable()[source]¶
-
Check if it is safe to write to this
Gst.Uri
.Check if the refcount of self is exactly 1, meaning that no other reference exists to the
Gst.Uri
and that theGst.Uri
is therefore writable.Modification of a
Gst.Uri
should only be done after verifying that it is writable.New in version 1.6.
- join(ref_uri)[source]¶
- Parameters:
ref_uri (
Gst.Uri
orNone
) – The reference URI to join onto the base URI.- Returns:
A
Gst.Uri
which represents the base with the reference URI joined on.- Return type:
Join a reference URI onto a base URI using the method from RFC 3986. If either URI is
None
then the other URI will be returned with the ref count increased.New in version 1.6.
- make_writable()[source]¶
- Returns:
A writable version of self.
- Return type:
Make the
Gst.Uri
writable.Checks if self 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 self and returns a reference to the new
Gst.Uri
. If self isNone
thenNone
is returned.New in version 1.6.
- new_with_base(scheme, userinfo, host, port, path, query, fragment)[source]¶
- Parameters:
port (
int
) – The port number for the new URI orGst.URI_NO_PORT
.path (
str
orNone
) – The path for the new URI with ‘/’ separating path elements.query (
str
orNone
) – The query string for the new URI with ‘&’ separating query elements. Elements containing ‘&’ characters should encode them as “%26”.
- Returns:
The new URI joined onto self.
- Return type:
Like
Gst.Uri.new
(), but joins the new URI onto a base URI.New in version 1.6.
- normalize()[source]¶
-
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
Gst.Uri
object must be writable. Check withGst.Uri.is_writable
() or useGst.Uri.make_writable
() first.New in version 1.6.
- query_has_key(query_key)[source]¶
- Parameters:
query_key (
str
) – The key to lookup.- Returns:
True
if query_key exists in the URI query table.- Return type:
Check if there is a query table entry for the query_key key.
New in version 1.6.
- remove_query_key(query_key)[source]¶
- Parameters:
query_key (
str
) – The key to remove.- Returns:
True
if the key existed in the table and was removed.- Return type:
Remove an entry from the query table by key.
New in version 1.6.
- set_fragment(fragment)[source]¶
- Parameters:
- Returns:
True
if the fragment was set/unset successfully.- Return type:
Sets the fragment string in the URI. Use a value of
None
in fragment to unset the fragment string.New in version 1.6.
- set_host(host)[source]¶
- Parameters:
- Returns:
True
if the host was set/unset successfully.- Return type:
Set or unset the host for the URI.
New in version 1.6.
- set_path(path)[source]¶
- Parameters:
path (
str
orNone
) – The new path to set with path segments separated by ‘/’, or useNone
to unset the path.- Returns:
True
if the path was set successfully.- Return type:
Sets or unsets the path in the URI.
New in version 1.6.
- set_path_segments(path_segments)[source]¶
- Parameters:
- Returns:
True
if the path segments were set successfully.- Return type:
Replace the path segments list in the URI.
New in version 1.6.
- set_path_string(path)[source]¶
- Parameters:
path (
str
) – The new percent encoded path to set with path segments separated by ‘/’, or useNone
to unset the path.- Returns:
True
if the path was set successfully.- Return type:
Sets or unsets the path in the URI.
New in version 1.6.
- set_port(port)[source]¶
- Parameters:
port (
int
) – The new port number to set orGst.URI_NO_PORT
to unset.- Returns:
True
if the port number was set/unset successfully.- Return type:
Set or unset the port number for the URI.
New in version 1.6.
- set_query_string(query)[source]¶
- Parameters:
query (
str
orNone
) – The new percent encoded query string to use to populate the query table, or useNone
to unset the query table.- Returns:
True
if the query table was set successfully.- Return type:
Sets or unsets the query table in the URI.
New in version 1.6.
- set_query_table(query_table)[source]¶
- Parameters:
query_table ({
str
:str
} orNone
) – The new query table to use.- Returns:
True
if the new table was successfully used for the query table.- Return type:
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
None
for query_table will remove the query string from the URI.New in version 1.6.
- set_query_value(query_key, query_value)[source]¶
- Parameters:
- Returns:
True
if the query table was successfully updated.- Return type:
This inserts or replaces a key in the query table. A query_value of
None
indicates that the key has no associated value, but will still be present in the query string.New in version 1.6.
- set_scheme(scheme)[source]¶
- Parameters:
scheme (
str
) – The new scheme to set orNone
to unset the scheme.- Returns:
True
if the scheme was set/unset successfully.- Return type:
Set or unset the scheme for the URI.
New in version 1.6.
- set_userinfo(userinfo)[source]¶
- Parameters:
userinfo (
str
) – The new user-information string to set orNone
to unset.- Returns:
True
if the user information was set/unset successfully.- Return type:
Set or unset the user information for the URI.
New in version 1.6.
- to_string()[source]¶
- Returns:
The string version of the URI.
- Return type:
Convert the URI to a string.
Returns the URI as held in this object as a
str
nul-terminated string. The caller shouldGLib.free
() the string once they are finished with it. The string is put together as described in RFC 3986.New in version 1.6.
- to_string_with_keys(keys)[source]¶
- Parameters:
keys ([
str
] orNone
) – AGLib.List
containing the query argument key strings.- Returns:
The string version of the URI.
- Return type:
Convert the URI to a string, with the query arguments in a specific order. Only the keys in the keys list will be added to the resulting string.
Returns the URI as held in this object as a
str
nul-terminated string. The caller shouldGLib.free
() the string once they are finished with it. The string is put together as described in RFC 3986.New in version 1.24.