2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
4 * 2014 David Waring, British Broadcasting Corporation
5 * <david.waring@rd.bbc.co.uk>
7 * gsturi.h: Header for uri to element mappings and URI manipulation.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
30 #include <glib-object.h>
35 GQuark gst_uri_error_quark (void);
40 * Get access to the error quark of the uri subsystem.
42 #define GST_URI_ERROR gst_uri_error_quark ()
46 * @GST_URI_ERROR_UNSUPPORTED_PROTOCOL: The protocol is not supported
47 * @GST_URI_ERROR_BAD_URI: There was a problem with the URI
48 * @GST_URI_ERROR_BAD_STATE: Could not set or change the URI because the
49 * URI handler was in a state where that is not possible or not permitted
50 * @GST_URI_ERROR_BAD_REFERENCE: There was a problem with the entity that
53 * Different URI-related errors that can occur.
57 GST_URI_ERROR_UNSUPPORTED_PROTOCOL,
58 GST_URI_ERROR_BAD_URI,
59 GST_URI_ERROR_BAD_STATE,
60 GST_URI_ERROR_BAD_REFERENCE
65 * @GST_URI_UNKNOWN: The URI direction is unknown
66 * @GST_URI_SINK: The URI is a consumer.
67 * @GST_URI_SRC: The URI is a producer.
69 * The different types of URI direction.
79 * GST_URI_TYPE_IS_VALID:
80 * @type: A #GstURIType
82 * Tests if the type direction is valid.
84 #define GST_URI_TYPE_IS_VALID(type) ((type) == GST_URI_SRC || (type) == GST_URI_SINK)
86 /* uri handler functions */
87 #define GST_TYPE_URI_HANDLER (gst_uri_handler_get_type ())
88 #define GST_URI_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_URI_HANDLER, GstURIHandler))
89 #define GST_IS_URI_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_URI_HANDLER))
90 #define GST_URI_HANDLER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_URI_HANDLER, GstURIHandlerInterface))
95 * Opaque #GstURIHandler structure.
97 typedef struct _GstURIHandler GstURIHandler;
98 typedef struct _GstURIHandlerInterface GstURIHandlerInterface;
100 #include <gst/gstelement.h>
101 #include <gst/gstconfig.h>
102 #include "gstminiobject.h"
105 * GstURIHandlerInterface:
106 * @parent: The parent interface type
107 * @get_type: Method to tell whether the element handles source or sink URI.
108 * @get_protocols: Method to return the list of protocols handled by the element.
109 * @get_uri: Method to return the URI currently handled by the element.
110 * @set_uri: Method to set a new URI.
112 * Any #GstElement using this interface should implement these methods.
114 struct _GstURIHandlerInterface {
115 GTypeInterface parent;
119 /* querying capabilities */
120 GstURIType (* get_type) (GType type);
121 const gchar * const * (* get_protocols) (GType type);
123 /* using the interface */
124 gchar * (* get_uri) (GstURIHandler * handler);
125 gboolean (* set_uri) (GstURIHandler * handler,
130 /* general URI functions */
133 gboolean gst_uri_protocol_is_valid (const gchar * protocol);
136 gboolean gst_uri_protocol_is_supported (const GstURIType type,
137 const gchar *protocol);
139 gboolean gst_uri_is_valid (const gchar * uri);
142 gchar * gst_uri_get_protocol (const gchar * uri) G_GNUC_MALLOC;
145 gboolean gst_uri_has_protocol (const gchar * uri,
146 const gchar * protocol);
148 gchar * gst_uri_get_location (const gchar * uri) G_GNUC_MALLOC;
150 GST_DEPRECATED_FOR(gst_uri_new)
151 gchar * gst_uri_construct (const gchar * protocol,
152 const gchar * location) G_GNUC_MALLOC;
154 gchar * gst_filename_to_uri (const gchar * filename,
155 GError ** error) G_GNUC_MALLOC;
157 GstElement * gst_element_make_from_uri (const GstURIType type,
159 const gchar * elementname,
160 GError ** error) G_GNUC_MALLOC;
162 /* accessing the interface */
165 GType gst_uri_handler_get_type (void);
168 GstURIType gst_uri_handler_get_uri_type (GstURIHandler * handler);
171 const gchar * const * gst_uri_handler_get_protocols (GstURIHandler * handler);
174 gchar * gst_uri_handler_get_uri (GstURIHandler * handler) G_GNUC_MALLOC;
177 gboolean gst_uri_handler_set_uri (GstURIHandler * handler,
182 * GstUri Type macros.
184 #define GST_TYPE_URI (gst_uri_get_type ())
185 #define GST_IS_URI(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_URI))
186 #define GST_URI_CAST(obj) ((GstUri *)(obj))
187 #define GST_URI_CONST_CAST(obj) ((const GstUri *)(obj))
188 #define GST_URI(obj) (GST_URI_CAST(obj))
193 * This is a private structure that holds the various parts of a parsed URI.
196 typedef struct _GstUri GstUri;
201 * Value for #GstUri<!-- -->.port to indicate no port number.
203 #define GST_URI_NO_PORT 0
205 /* used by GST_TYPE_URI */
208 GType gst_uri_get_type (void);
211 * Method definitions.
215 GstUri * gst_uri_new (const gchar * scheme,
216 const gchar * userinfo,
221 const gchar * fragment) G_GNUC_MALLOC;
223 GstUri * gst_uri_new_with_base (GstUri * base,
224 const gchar * scheme,
225 const gchar * userinfo,
230 const gchar * fragment) G_GNUC_MALLOC;
232 GstUri * gst_uri_from_string (const gchar * uri) G_GNUC_MALLOC;
235 GstUri * gst_uri_from_string_with_base (GstUri * base,
236 const gchar * uri) G_GNUC_MALLOC;
238 gboolean gst_uri_equal (const GstUri * first,
239 const GstUri * second);
241 GstUri * gst_uri_join (GstUri * base_uri,
242 GstUri * ref_uri) G_GNUC_WARN_UNUSED_RESULT;
244 gchar * gst_uri_join_strings (const gchar * base_uri,
245 const gchar * ref_uri) G_GNUC_MALLOC;
247 gboolean gst_uri_is_writable (const GstUri * uri);
250 GstUri * gst_uri_make_writable (GstUri * uri) G_GNUC_WARN_UNUSED_RESULT;
253 gchar * gst_uri_to_string (const GstUri * uri) G_GNUC_MALLOC;
256 gboolean gst_uri_is_normalized (const GstUri * uri);
259 gboolean gst_uri_normalize (GstUri * uri);
262 const gchar * gst_uri_get_scheme (const GstUri * uri);
265 gboolean gst_uri_set_scheme (GstUri * uri, const gchar * scheme);
268 const gchar * gst_uri_get_userinfo (const GstUri * uri);
271 gboolean gst_uri_set_userinfo (GstUri * uri, const gchar * userinfo);
274 const gchar * gst_uri_get_host (const GstUri * uri);
277 gboolean gst_uri_set_host (GstUri * uri, const gchar * host);
280 guint gst_uri_get_port (const GstUri * uri);
283 gboolean gst_uri_set_port (GstUri * uri, guint port);
286 gchar * gst_uri_get_path (const GstUri * uri);
289 gboolean gst_uri_set_path (GstUri * uri, const gchar * path);
292 gchar * gst_uri_get_path_string (const GstUri * uri);
295 gboolean gst_uri_set_path_string (GstUri * uri, const gchar * path);
298 GList * gst_uri_get_path_segments (const GstUri * uri);
301 gboolean gst_uri_set_path_segments (GstUri * uri, GList * path_segments);
304 gboolean gst_uri_append_path (GstUri * uri,
305 const gchar * relative_path);
307 gboolean gst_uri_append_path_segment (GstUri * uri,
308 const gchar * path_segment);
310 gchar * gst_uri_get_query_string (const GstUri * uri);
313 gboolean gst_uri_set_query_string (GstUri * uri, const gchar * query);
316 GHashTable * gst_uri_get_query_table (const GstUri * uri);
319 gboolean gst_uri_set_query_table (GstUri * uri,
320 GHashTable * query_table);
322 gboolean gst_uri_set_query_value (GstUri * uri, const gchar * query_key,
323 const gchar * query_value);
325 gboolean gst_uri_remove_query_key (GstUri * uri, const gchar * query_key);
328 gboolean gst_uri_query_has_key (const GstUri * uri,
329 const gchar * query_key);
332 const gchar * gst_uri_get_query_value (const GstUri * uri,
333 const gchar * query_key);
336 GList * gst_uri_get_query_keys (const GstUri * uri);
339 const gchar * gst_uri_get_fragment (const GstUri * uri);
342 gboolean gst_uri_set_fragment (GstUri * uri, const gchar * fragment);
345 GHashTable * gst_uri_get_media_fragment_table (const GstUri * uri);
349 * @uri: This #GstUri object.
351 * Create a new #GstUri object with the same data as this #GstUri object.
352 * If @uri is %NULL then returns %NULL.
354 * Returns: (transfer full): A new #GstUri object which is a copy of this
357 static inline GstUri *
358 gst_uri_copy (const GstUri * uri)
360 return GST_URI_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (uri)));
365 * @uri: (transfer none): This #GstUri object.
367 * Add a reference to this #GstUri object. See gst_mini_object_ref() for further
370 * Returns: This object with the reference count incremented.
372 static inline GstUri *
373 gst_uri_ref (GstUri * uri)
375 return GST_URI_CAST (gst_mini_object_ref (GST_MINI_OBJECT_CAST (uri)));
380 * @uri: (transfer full): This #GstUri object.
382 * Decrement the reference count to this #GstUri object.
384 * If the reference count drops to 0 then finalize this object.
386 * See gst_mini_object_unref() for further info.
389 gst_uri_unref (GstUri * uri)
391 gst_mini_object_unref (GST_MINI_OBJECT_CAST (uri));
394 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
395 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstUri, gst_uri_unref)
400 #endif /* __GST_URI_H__ */