gstfunnel: avoid access of freed pad
[platform/upstream/gstreamer.git] / gst / gsturi.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *
5  * gsturi.h: Header for uri to element mappings
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23
24 #ifndef __GST_URI_H__
25 #define __GST_URI_H__
26
27 #include <glib.h>
28 #include <gst/gstelement.h>
29
30 G_BEGIN_DECLS
31
32 GQuark gst_uri_error_quark (void);
33
34 /**
35  * GST_URI_ERROR:
36  *
37  * Get access to the error quark of the uri subsystem.
38  */
39 #define GST_URI_ERROR gst_uri_error_quark ()
40
41 /**
42  * GstURIError:
43  * @GST_URI_ERROR_BAD_PROTOCOL: The protocol is not supported
44  * @GST_URI_ERROR_BAD_URI: There was a problem with the URI
45  * @GST_URI_ERROR_BAD_STATE: Could not set or change the URI because the
46  *     URI handler was in a state where that is not possible or not permitted
47  * @GST_URI_ERROR_BAD_REFERENCE: There was a problem with the entity that
48  *     the URI references
49  *
50  * Different URI-related errors that can occur.
51  */
52 typedef enum
53 {
54   GST_URI_ERROR_BAD_PROTOCOL,
55   GST_URI_ERROR_BAD_URI,
56   GST_URI_ERROR_BAD_STATE,
57   GST_URI_ERROR_BAD_REFERENCE
58 } GstURIError;
59
60 /**
61  * GstURIType:
62  * @GST_URI_UNKNOWN: The URI direction is unknown
63  * @GST_URI_SINK: The URI is a consumer.
64  * @GST_URI_SRC: The URI is a producer.
65  *
66  * The different types of URI direction.
67  */
68
69 typedef enum {
70   GST_URI_UNKNOWN,
71   GST_URI_SINK,
72   GST_URI_SRC
73 } GstURIType;
74
75 /**
76  * GST_URI_TYPE_IS_VALID:
77  * @type: A #GstURIType
78  *
79  * Tests if the type direction is valid.
80  */
81 #define GST_URI_TYPE_IS_VALID(type) ((type) == GST_URI_SRC || (type) == GST_URI_SINK)
82
83 /* uri handler functions */
84 #define GST_TYPE_URI_HANDLER               (gst_uri_handler_get_type ())
85 #define GST_URI_HANDLER(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_URI_HANDLER, GstURIHandler))
86 #define GST_IS_URI_HANDLER(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_URI_HANDLER))
87 #define GST_URI_HANDLER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_URI_HANDLER, GstURIHandlerInterface))
88
89 /**
90  * GstURIHandler:
91  *
92  * Opaque #GstURIHandler structure.
93  */
94 typedef struct _GstURIHandler GstURIHandler;
95 typedef struct _GstURIHandlerInterface GstURIHandlerInterface;
96
97 /**
98  * GstURIHandlerInterface:
99  * @parent: The parent interface type
100  * @get_type: Method to tell whether the element handles source or sink URI.
101  * @get_protocols: Method to return the list of protocols handled by the element.
102  * @get_uri: Method to return the URI currently handled by the element.
103  * @set_uri: Method to set a new URI.
104  *
105  * Any #GstElement using this interface should implement these methods.
106  */
107 struct _GstURIHandlerInterface {
108   GTypeInterface parent;
109
110   /* vtable */
111   /*< public >*/
112   /* querying capabilities */
113   GstURIType             (* get_type)           (GType type);
114   const gchar * const *  (* get_protocols)      (GType type);
115
116   /* using the interface */
117   gchar *                (* get_uri)            (GstURIHandler * handler);
118   gboolean               (* set_uri)            (GstURIHandler * handler,
119                                                  const gchar   * uri,
120                                                  GError       ** error);
121 };
122
123 /* general URI functions */
124
125 gboolean        gst_uri_protocol_is_valid       (const gchar * protocol);
126 gboolean        gst_uri_protocol_is_supported   (const GstURIType type,
127                                                  const gchar *protocol);
128 gboolean        gst_uri_is_valid                (const gchar * uri);
129 gchar *         gst_uri_get_protocol            (const gchar * uri) G_GNUC_MALLOC;
130 gboolean        gst_uri_has_protocol            (const gchar * uri,
131                                                  const gchar * protocol);
132 gchar *         gst_uri_get_location            (const gchar * uri) G_GNUC_MALLOC;
133 gchar *         gst_uri_construct               (const gchar * protocol,
134                                                  const gchar * location) G_GNUC_MALLOC;
135
136 gchar *         gst_filename_to_uri             (const gchar * filename,
137                                                  GError     ** error) G_GNUC_MALLOC;
138
139 GstElement *    gst_element_make_from_uri       (const GstURIType type,
140                                                  const gchar *    uri,
141                                                  const gchar *    elementname) G_GNUC_MALLOC;
142
143 /* accessing the interface */
144 GType                 gst_uri_handler_get_type (void);
145
146 GstURIType            gst_uri_handler_get_uri_type  (GstURIHandler * handler);
147 const gchar * const * gst_uri_handler_get_protocols (GstURIHandler * handler);
148 gchar *               gst_uri_handler_get_uri       (GstURIHandler * handler) G_GNUC_MALLOC;
149 gboolean              gst_uri_handler_set_uri       (GstURIHandler * handler,
150                                                      const gchar   * uri,
151                                                      GError       ** error);
152
153 G_END_DECLS
154
155 #endif /* __GST_URI_H__ */