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>
34 #include <gst/gstconfig.h>
37 GQuark gst_uri_error_quark (void);
42 * Get access to the error quark of the uri subsystem.
44 #define GST_URI_ERROR gst_uri_error_quark ()
48 * @GST_URI_ERROR_UNSUPPORTED_PROTOCOL: The protocol is not supported
49 * @GST_URI_ERROR_BAD_URI: There was a problem with the URI
50 * @GST_URI_ERROR_BAD_STATE: Could not set or change the URI because the
51 * URI handler was in a state where that is not possible or not permitted
52 * @GST_URI_ERROR_BAD_REFERENCE: There was a problem with the entity that
55 * Different URI-related errors that can occur.
59 GST_URI_ERROR_UNSUPPORTED_PROTOCOL,
60 GST_URI_ERROR_BAD_URI,
61 GST_URI_ERROR_BAD_STATE,
62 GST_URI_ERROR_BAD_REFERENCE
67 * @GST_URI_UNKNOWN: The URI direction is unknown
68 * @GST_URI_SINK: The URI is a consumer.
69 * @GST_URI_SRC: The URI is a producer.
71 * The different types of URI direction.
81 * GST_URI_TYPE_IS_VALID:
82 * @type: A #GstURIType
84 * Tests if the type direction is valid.
86 #define GST_URI_TYPE_IS_VALID(type) ((type) == GST_URI_SRC || (type) == GST_URI_SINK)
88 /* uri handler functions */
89 #define GST_TYPE_URI_HANDLER (gst_uri_handler_get_type ())
90 #define GST_URI_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_URI_HANDLER, GstURIHandler))
91 #define GST_IS_URI_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_URI_HANDLER))
92 #define GST_URI_HANDLER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_URI_HANDLER, GstURIHandlerInterface))
97 * Opaque #GstURIHandler structure.
99 typedef struct _GstURIHandler GstURIHandler;
100 typedef struct _GstURIHandlerInterface GstURIHandlerInterface;
102 #include <gst/gstelement.h>
103 #include "gstminiobject.h"
106 * GstURIHandlerInterface:
107 * @parent: The parent interface type
108 * @get_type: Method to tell whether the element handles source or sink URI.
109 * @get_protocols: Method to return the list of protocols handled by the element.
110 * @get_uri: Method to return the URI currently handled by the element.
111 * @set_uri: Method to set a new URI.
113 * Any #GstElement using this interface should implement these methods.
115 struct _GstURIHandlerInterface {
116 GTypeInterface parent;
120 /* querying capabilities */
121 GstURIType (* get_type) (GType type);
122 const gchar * const * (* get_protocols) (GType type);
124 /* using the interface */
125 gchar * (* get_uri) (GstURIHandler * handler);
126 gboolean (* set_uri) (GstURIHandler * handler,
131 /* general URI functions */
134 gboolean gst_uri_protocol_is_valid (const gchar * protocol);
137 gboolean gst_uri_protocol_is_supported (const GstURIType type,
138 const gchar *protocol);
140 gboolean gst_uri_is_valid (const gchar * uri);
143 gchar * gst_uri_get_protocol (const gchar * uri) G_GNUC_MALLOC;
146 gboolean gst_uri_has_protocol (const gchar * uri,
147 const gchar * protocol);
149 gchar * gst_uri_get_location (const gchar * uri) G_GNUC_MALLOC;
151 GST_DEPRECATED_FOR(gst_uri_new)
152 gchar * gst_uri_construct (const gchar * protocol,
153 const gchar * location) G_GNUC_MALLOC;
155 gchar * gst_filename_to_uri (const gchar * filename,
156 GError ** error) G_GNUC_MALLOC;
158 GstElement * gst_element_make_from_uri (const GstURIType type,
160 const gchar * elementname,
161 GError ** error) G_GNUC_MALLOC;
163 /* accessing the interface */
166 GType gst_uri_handler_get_type (void);
169 GstURIType gst_uri_handler_get_uri_type (GstURIHandler * handler);
172 const gchar * const * gst_uri_handler_get_protocols (GstURIHandler * handler);
175 gchar * gst_uri_handler_get_uri (GstURIHandler * handler) G_GNUC_MALLOC;
178 gboolean gst_uri_handler_set_uri (GstURIHandler * handler,
183 * GstUri Type macros.
185 #define GST_TYPE_URI (gst_uri_get_type ())
186 #define GST_IS_URI(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_URI))
187 #define GST_URI_CAST(obj) ((GstUri *)(obj))
188 #define GST_URI_CONST_CAST(obj) ((const GstUri *)(obj))
189 #define GST_URI(obj) (GST_URI_CAST(obj))
194 * This is a private structure that holds the various parts of a parsed URI.
197 typedef struct _GstUri GstUri;
202 * Value for #GstUri<!-- -->.port to indicate no port number.
204 #define GST_URI_NO_PORT 0
206 /* used by GST_TYPE_URI */
209 GType gst_uri_get_type (void);
212 * Method definitions.
216 GstUri * gst_uri_new (const gchar * scheme,
217 const gchar * userinfo,
222 const gchar * fragment) G_GNUC_MALLOC;
224 GstUri * gst_uri_new_with_base (GstUri * base,
225 const gchar * scheme,
226 const gchar * userinfo,
231 const gchar * fragment) G_GNUC_MALLOC;
233 GstUri * gst_uri_from_string (const gchar * uri) G_GNUC_MALLOC;
236 GstUri * gst_uri_from_string_with_base (GstUri * base,
237 const gchar * uri) G_GNUC_MALLOC;
239 gboolean gst_uri_equal (const GstUri * first,
240 const GstUri * second);
242 GstUri * gst_uri_join (GstUri * base_uri,
243 GstUri * ref_uri) G_GNUC_WARN_UNUSED_RESULT;
245 gchar * gst_uri_join_strings (const gchar * base_uri,
246 const gchar * ref_uri) G_GNUC_MALLOC;
248 gboolean gst_uri_is_writable (const GstUri * uri);
251 GstUri * gst_uri_make_writable (GstUri * uri) G_GNUC_WARN_UNUSED_RESULT;
254 gchar * gst_uri_to_string (const GstUri * uri) G_GNUC_MALLOC;
257 gboolean gst_uri_is_normalized (const GstUri * uri);
260 gboolean gst_uri_normalize (GstUri * uri);
263 const gchar * gst_uri_get_scheme (const GstUri * uri);
266 gboolean gst_uri_set_scheme (GstUri * uri, const gchar * scheme);
269 const gchar * gst_uri_get_userinfo (const GstUri * uri);
272 gboolean gst_uri_set_userinfo (GstUri * uri, const gchar * userinfo);
275 const gchar * gst_uri_get_host (const GstUri * uri);
278 gboolean gst_uri_set_host (GstUri * uri, const gchar * host);
281 guint gst_uri_get_port (const GstUri * uri);
284 gboolean gst_uri_set_port (GstUri * uri, guint port);
287 gchar * gst_uri_get_path (const GstUri * uri);
290 gboolean gst_uri_set_path (GstUri * uri, const gchar * path);
293 gchar * gst_uri_get_path_string (const GstUri * uri);
296 gboolean gst_uri_set_path_string (GstUri * uri, const gchar * path);
299 GList * gst_uri_get_path_segments (const GstUri * uri);
302 gboolean gst_uri_set_path_segments (GstUri * uri, GList * path_segments);
305 gboolean gst_uri_append_path (GstUri * uri,
306 const gchar * relative_path);
308 gboolean gst_uri_append_path_segment (GstUri * uri,
309 const gchar * path_segment);
311 gchar * gst_uri_get_query_string (const GstUri * uri);
314 gboolean gst_uri_set_query_string (GstUri * uri, const gchar * query);
317 GHashTable * gst_uri_get_query_table (const GstUri * uri);
320 gboolean gst_uri_set_query_table (GstUri * uri,
321 GHashTable * query_table);
323 gboolean gst_uri_set_query_value (GstUri * uri, const gchar * query_key,
324 const gchar * query_value);
326 gboolean gst_uri_remove_query_key (GstUri * uri, const gchar * query_key);
329 gboolean gst_uri_query_has_key (const GstUri * uri,
330 const gchar * query_key);
333 const gchar * gst_uri_get_query_value (const GstUri * uri,
334 const gchar * query_key);
337 GList * gst_uri_get_query_keys (const GstUri * uri);
340 const gchar * gst_uri_get_fragment (const GstUri * uri);
343 gboolean gst_uri_set_fragment (GstUri * uri, const gchar * fragment);
346 GHashTable * gst_uri_get_media_fragment_table (const GstUri * uri);
350 * @uri: This #GstUri object.
352 * Create a new #GstUri object with the same data as this #GstUri object.
353 * If @uri is %NULL then returns %NULL.
355 * Returns: (transfer full): A new #GstUri object which is a copy of this
358 static inline GstUri *
359 gst_uri_copy (const GstUri * uri)
361 return GST_URI_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (uri)));
366 * @uri: (transfer none): This #GstUri object.
368 * Add a reference to this #GstUri object. See gst_mini_object_ref() for further
371 * Returns: This object with the reference count incremented.
373 static inline GstUri *
374 gst_uri_ref (GstUri * uri)
376 return GST_URI_CAST (gst_mini_object_ref (GST_MINI_OBJECT_CAST (uri)));
381 * @uri: (transfer full): This #GstUri object.
383 * Decrement the reference count to this #GstUri object.
385 * If the reference count drops to 0 then finalize this object.
387 * See gst_mini_object_unref() for further info.
390 gst_uri_unref (GstUri * uri)
392 gst_mini_object_unref (GST_MINI_OBJECT_CAST (uri));
395 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
396 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstUri, gst_uri_unref)
401 #endif /* __GST_URI_H__ */