Totally rewritten registry handling.
[platform/upstream/gstreamer.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/gstplugin.h>
28
29 #define GLOBAL_REGISTRY_DIR      GST_CONFIG_DIR
30 #define GLOBAL_REGISTRY_FILE     GLOBAL_REGISTRY_DIR"/registry.xml"
31 #define GLOBAL_REGISTRY_FILE_TMP GLOBAL_REGISTRY_DIR"/.registry.xml.tmp"
32
33 #define LOCAL_REGISTRY_DIR       ".gstreamer"
34 #define LOCAL_REGISTRY_FILE      LOCAL_REGISTRY_DIR"/registry.xml"
35 #define LOCAL_REGISTRY_FILE_TMP  LOCAL_REGISTRY_DIR"/.registry.xml.tmp"
36
37 #define REGISTRY_DIR_PERMS (S_ISGID | \
38                             S_IRUSR | S_IWUSR | S_IXUSR | \
39                             S_IRGRP | S_IXGRP | \
40                             S_IROTH | S_IXOTH)
41 #define REGISTRY_TMPFILE_PERMS (S_IRUSR | S_IWUSR)
42 #define REGISTRY_FILE_PERMS (S_IRUSR | S_IWUSR | \
43                              S_IRGRP | S_IWGRP | \
44                              S_IROTH | S_IWOTH)
45
46 G_BEGIN_DECLS
47
48 typedef struct _GstRegistryWrite GstRegistryWrite;
49 struct _GstRegistryWrite {
50   gchar *dir;
51   gchar *file;
52   gchar *tmp_file;
53 };
54
55 typedef struct _GstRegistryRead GstRegistryRead;
56 struct _GstRegistryRead {
57   gchar *global_reg;
58   gchar *local_reg;
59 };
60
61 GstRegistryWrite        *gst_registry_write_get         (void);
62 GstRegistryRead         *gst_registry_read_get          (void);
63 void                    gst_registry_option_set         (const gchar *registry);
64
65
66 typedef enum {
67   GST_REGISTRY_OK                       = (0),
68   GST_REGISTRY_LOAD_ERROR               = (1 << 1),
69   GST_REGISTRY_SAVE_ERROR               = (1 << 2),
70   GST_REGISTRY_PLUGIN_LOAD_ERROR        = (1 << 3),
71   GST_REGISTRY_PLUGIN_SIGNATURE_ERROR   = (1 << 4),
72 } GstRegistryReturn;
73
74 typedef enum {
75   GST_REGISTRY_READABLE                 = (1 << 1),
76   GST_REGISTRY_WRITABLE                 = (1 << 2),
77   GST_REGISTRY_REMOTE                   = (1 << 3),
78   GST_REGISTRY_DELAYED_LOADING          = (1 << 4),
79 } GstRegistryFlags;
80
81   
82 #define GST_TYPE_REGISTRY \
83   (gst_registry_get_type())
84 #define GST_REGISTRY(obj) \
85   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_REGISTRY,GstRegistry))
86 #define GST_REGISTRY_CLASS(klass) \
87   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_REGISTRY,GstRegistryClass))
88 #define GST_IS_REGISTRY(obj) \
89   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_REGISTRY))
90 #define GST_IS_REGISTRY_CLASS(obj) \
91   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_REGISTRY))
92
93 typedef struct _GstRegistry GstRegistry;
94 typedef struct _GstRegistryClass GstRegistryClass;
95
96 struct _GstRegistry {
97   GObject        object;
98
99   gint           priority;
100   GstRegistryFlags flags;
101
102   gchar         *name;
103   gchar         *details;
104
105   gboolean       loaded;
106   GList         *plugins;
107
108   GList         *paths;
109 };
110
111 struct _GstRegistryClass {
112   GObjectClass          parent_class;
113
114   /* vtable */
115   gboolean              (*load)                 (GstRegistry *registry);
116   gboolean              (*save)                 (GstRegistry *registry);
117   gboolean              (*rebuild)              (GstRegistry *registry);
118   gboolean              (*unload)               (GstRegistry *registry);
119
120   GstRegistryReturn     (*load_plugin)          (GstRegistry *registry, GstPlugin *plugin);
121   GstRegistryReturn     (*unload_plugin)        (GstRegistry *registry, GstPlugin *plugin);
122   GstRegistryReturn     (*update_plugin)        (GstRegistry *registry, GstPlugin *plugin);
123
124   /* signals */
125   void                  (*plugin_added)         (GstRegistry *registry, GstPlugin *plugin);
126 };
127
128
129 /* normal GObject stuff */
130 GType                   gst_registry_get_type           (void);
131
132 gboolean                gst_registry_load               (GstRegistry *registry);
133 gboolean                gst_registry_is_loaded          (GstRegistry *registry);
134 gboolean                gst_registry_save               (GstRegistry *registry);
135 gboolean                gst_registry_rebuild            (GstRegistry *registry);
136 gboolean                gst_registry_unload             (GstRegistry *registry);
137
138 void                    gst_registry_add_path           (GstRegistry *registry, const gchar *path);
139 GList*                  gst_registry_get_path_list      (GstRegistry *registry);
140 void                    gst_registry_clear_paths        (GstRegistry *registry);
141
142 gboolean                gst_registry_add_plugin         (GstRegistry *registry, GstPlugin *plugin);
143 void                    gst_registry_remove_plugin      (GstRegistry *registry, GstPlugin *plugin);
144
145 GstPlugin*              gst_registry_find_plugin        (GstRegistry *registry, const gchar *name);
146 GstPluginFeature*       gst_registry_find_feature       (GstRegistry *registry, const gchar *name, GType type);
147
148 GstRegistryReturn       gst_registry_load_plugin        (GstRegistry *registry, GstPlugin *plugin);
149 GstRegistryReturn       gst_registry_unload_plugin      (GstRegistry *registry, GstPlugin *plugin);
150 GstRegistryReturn       gst_registry_update_plugin      (GstRegistry *registry, GstPlugin *plugin);
151
152 /* the pool of registries */
153 GList*                  gst_registry_pool_list          (void);
154 void                    gst_registry_pool_add           (GstRegistry *registry, guint priority);
155 void                    gst_registry_pool_remove        (GstRegistry *registry);
156
157 void                    gst_registry_pool_add_plugin    (GstPlugin *plugin);
158
159 void                    gst_registry_pool_add           (GstRegistry *registry, guint priority);
160 void                    gst_registry_pool_load_all      (void);
161
162 GList*                  gst_registry_pool_plugin_list   (void);
163 GList*                  gst_registry_pool_feature_list  (GType type);
164
165 GstPlugin*              gst_registry_pool_find_plugin   (const gchar *name);
166 GstPluginFeature*       gst_registry_pool_find_feature  (const gchar *name, GType type);
167
168 GstRegistry*            gst_registry_pool_get_prefered  (GstRegistryFlags flags);
169
170 G_END_DECLS
171
172 #endif /* __GST_REGISTRY_H__ */