2.0 beta init
[framework/multimedia/gstreamer0.10.git] / gst / gstregistry.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wim.taymans@chello.be>
4  *
5  * gstregistry.h: Header for registry handling
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_REGISTRY_H__
25 #define __GST_REGISTRY_H__
26
27 #include <gst/gstconfig.h>
28 #include <gst/gstplugin.h>
29 #include <gst/gstpluginfeature.h>
30
31 G_BEGIN_DECLS
32
33 #define GST_TYPE_REGISTRY               (gst_registry_get_type ())
34 #define GST_REGISTRY(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_REGISTRY, GstRegistry))
35 #define GST_IS_REGISTRY(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_REGISTRY))
36 #define GST_REGISTRY_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_REGISTRY, GstRegistryClass))
37 #define GST_IS_REGISTRY_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_REGISTRY))
38 #define GST_REGISTRY_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_REGISTRY, GstRegistryClass))
39
40 typedef struct _GstRegistry GstRegistry;
41 typedef struct _GstRegistryClass GstRegistryClass;
42 typedef struct _GstRegistryPrivate GstRegistryPrivate;
43
44 /**
45  * GstRegistry:
46  *
47  * Opaque #GstRegistry structure.
48  */
49 struct _GstRegistry {
50   GstObject      object;
51
52   /*< private >*/
53   GList *plugins;
54   GList *features;
55
56   GList         *paths;
57
58   /* FIXME move these elsewhere */
59   int            cache_file;
60
61   /* hash to speedup _lookup_feature_locked() */
62   GHashTable *feature_hash;
63   /* hash to speedup _lookup */
64   GHashTable *basename_hash;
65
66   GstRegistryPrivate *priv;
67
68   /*< private >*/
69   gpointer _gst_reserved[GST_PADDING-3];
70 };
71
72 struct _GstRegistryClass {
73   GstObjectClass        parent_class;
74
75   /* signals */
76   void                  (*plugin_added)         (GstRegistry *registry, GstPlugin *plugin);
77   void                  (*feature_added)        (GstRegistry *registry, GstPluginFeature *feature);
78
79   /*< private >*/
80   gpointer _gst_reserved[GST_PADDING];
81 };
82
83
84 /* normal GObject stuff */
85 GType                   gst_registry_get_type           (void);
86
87 GstRegistry *           gst_registry_get_default        (void);
88
89 gboolean                        gst_registry_scan_path          (GstRegistry *registry, const gchar *path);
90 void                    gst_registry_add_path           (GstRegistry * registry, const gchar * path);
91 GList*                  gst_registry_get_path_list      (GstRegistry *registry);
92
93 gboolean                gst_registry_add_plugin         (GstRegistry *registry, GstPlugin *plugin);
94 void                    gst_registry_remove_plugin      (GstRegistry *registry, GstPlugin *plugin);
95 gboolean                gst_registry_add_feature        (GstRegistry * registry, GstPluginFeature * feature);
96 void                    gst_registry_remove_feature     (GstRegistry * registry, GstPluginFeature * feature);
97
98 GList*                  gst_registry_get_plugin_list    (GstRegistry *registry);
99 GList*                  gst_registry_plugin_filter      (GstRegistry *registry,
100                                                          GstPluginFilter filter,
101                                                          gboolean first,
102                                                          gpointer user_data);
103 GList*                  gst_registry_feature_filter     (GstRegistry *registry,
104                                                          GstPluginFeatureFilter filter,
105                                                          gboolean first,
106                                                          gpointer user_data);
107 GList *                 gst_registry_get_feature_list   (GstRegistry *registry,
108                                                          GType type);
109 GList *                 gst_registry_get_feature_list_by_plugin (GstRegistry *registry, const gchar *name);
110 guint32                 gst_registry_get_feature_list_cookie (GstRegistry *registry);
111
112 GstPlugin*              gst_registry_find_plugin        (GstRegistry *registry, const gchar *name);
113 GstPluginFeature*       gst_registry_find_feature       (GstRegistry *registry, const gchar *name, GType type);
114
115 GstPlugin *             gst_registry_lookup             (GstRegistry *registry, const char *filename);
116 GstPluginFeature *      gst_registry_lookup_feature     (GstRegistry *registry, const char *name);
117
118 /* These are only here because at some point they were in a public header
119  * (even though they should have been private) and we can't really remove
120  * them now (FIXME: 0.11). They don't do anything other than return FALSE. */
121 #ifndef GST_DISABLE_DEPRECATED
122 gboolean                gst_registry_xml_read_cache     (GstRegistry * registry, const char *location);
123 gboolean                gst_registry_xml_write_cache    (GstRegistry * registry, const char *location);
124 #endif
125
126 /* convenience defines for the default registry */
127
128 /**
129  * gst_default_registry_add_plugin:
130  * @plugin: (transfer full): the plugin to add
131  *
132  * Add the plugin to the default registry.
133  * The plugin-added signal will be emitted.
134  *
135  * Returns: TRUE on success.
136  */
137 #define gst_default_registry_add_plugin(plugin) \
138   gst_registry_add_plugin (gst_registry_get_default(), plugin)
139
140 /**
141  * gst_default_registry_add_path:
142  * @path: the path to add to the registry
143  *
144  * Add the given path to the default registry. The syntax of the
145  * path is specific to the registry. If the path has already been
146  * added, do nothing.
147  */
148 #define gst_default_registry_add_path(path) \
149   gst_registry_add_path (gst_registry_get_default(), path)
150
151 /**
152  * gst_default_registry_get_path_list:
153  *
154  * Get the list of paths for the default registry.
155  *
156  * Returns: (transfer container) (element-type char*): a #GList of paths as
157  *     strings. g_list_free() after use.
158  */
159 #define gst_default_registry_get_path_list() \
160   gst_registry_get_path_list (gst_registry_get_default())
161   
162 /**
163  * gst_default_registry_get_plugin_list:
164  *
165  * Get a copy of all plugins registered in the default registry.
166  *
167  * Returns: (transfer full) (element-type Gst.Plugin): a copy of the list.
168  *     Free after use.
169  */
170 #define gst_default_registry_get_plugin_list() \
171   gst_registry_get_plugin_list (gst_registry_get_default())
172
173 /**
174  * gst_default_registry_find_feature:
175  * @name: the pluginfeature name to find
176  * @type: the pluginfeature type to find
177  *
178  * Find the pluginfeature with the given name and type in the default registry.
179  *
180  * Returns: (transfer full): the pluginfeature with the given name and type or
181  *    NULL if the plugin was not found.
182  */
183 #define gst_default_registry_find_feature(name,type) \
184   gst_registry_find_feature (gst_registry_get_default(),name,type)
185
186 /**
187  * gst_default_registry_find_plugin:
188  * @name: the plugin name to find
189  *
190  * Find the plugin with the given name in the default registry.
191  * The plugin will be reffed; caller is responsible for unreffing.
192  *
193  * Returns: (transfer full): The plugin with the given name or NULL if the
194  *     plugin was not found.
195  */
196 #define gst_default_registry_find_plugin(name) \
197   gst_registry_find_plugin (gst_registry_get_default(),name)
198
199 /**
200  * gst_default_registry_feature_filter:
201  * @filter: the filter to use
202  * @first: only return first match
203  * @user_data: user data passed to the filter function
204  *
205  * Runs a filter against all features of the plugins in the default registry
206  * and returns a GList with the results.
207  * If the first flag is set, only the first match is
208  * returned (as a list with a single object).
209  *
210  * Returns: (transfer full) (element-type Gst.PluginFeature): a #GList of
211  *     plugin features, gst_plugin_feature_list_free after use.
212  */
213 #define gst_default_registry_feature_filter(filter,first,user_data) \
214   gst_registry_feature_filter (gst_registry_get_default(),filter,first,user_data)
215
216 /**
217  * gst_default_registry_get_feature_list_cookie:
218  *
219  * Returns the default registrys feature list cookie. This changes
220  * every time a feature is added or removed from the registry.
221  *
222  * Returns: the feature list cookie.
223  *
224  * Since: 0.10.26
225  */
226 #define gst_default_registry_get_feature_list_cookie() \
227   gst_registry_get_feature_list_cookie (gst_registry_get_default())
228
229 gboolean                gst_default_registry_check_feature_version (const gchar *feature_name,
230                                                                     guint        min_major,
231                                                                     guint        min_minor,
232                                                                     guint        min_micro);
233
234 G_END_DECLS
235
236 #endif /* __GST_REGISTRY_H__ */
237