Change GST_.*_PADDING to _gst_padding[GST_PADDING];
[platform/upstream/gstreamer.git] / gst / gstplugin.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *
5  * gstplugin.h: Header for plugin subsystem
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_PLUGIN_H__
25 #define __GST_PLUGIN_H__
26
27 #include <gst/gstconfig.h>
28
29 #include <gmodule.h>
30 #include <gst/gstpluginfeature.h>
31 #include <gst/gstmacros.h>
32
33 G_BEGIN_DECLS
34
35 GQuark gst_plugin_error_quark (void);
36 #define GST_PLUGIN_ERROR gst_plugin_error_quark ()
37
38 typedef enum
39 {
40   GST_PLUGIN_ERROR_MODULE,
41   GST_PLUGIN_ERROR_DEPENDENCIES,
42   GST_PLUGIN_ERROR_NAME_MISMATCH
43 } GstPluginError;
44
45 #define GST_PLUGIN(plugin)              ((GstPlugin *) (plugin))
46
47 typedef struct _GstPlugin               GstPlugin;
48 typedef struct _GstPluginDesc           GstPluginDesc;
49
50 /* Initialiser function: returns TRUE if plugin initialised successfully */
51 typedef gboolean (*GstPluginInitFunc) (GstPlugin *plugin);
52 /* exiting function when plugin is unloaded */
53 typedef void (*GstPluginExitFunc) (GstPlugin *plugin);
54
55 struct _GstPluginDesc {
56   gint major_version;                   /* major version of core that plugin was compiled for */
57   gint minor_version;                   /* minor version of core that plugin was compiled for */
58   gchar *name;                          /* unique name of plugin */
59   gchar *description;                   /* description of plugin */
60   GstPluginInitFunc plugin_init;        /* pointer to plugin_init function */
61   GstPluginExitFunc plugin_exit;        /* pointer to exiting function */
62   gchar *version;                       /* version of the plugin */
63   gchar *license;                       /* effective license of plugin */
64   gchar *package;                       /* package plugin belongs to */
65   gchar *origin;                        /* URL to provider of plugin */
66   
67   gpointer _gst_reserved[GST_PADDING];
68 };
69
70 struct _GstPlugin {
71   GstPluginDesc desc;
72
73   gchar *       filename;
74   GList *       features;               /* list of features provided */
75   gint          numfeatures;
76
77   gpointer      manager;                /* managing registry */
78   GModule *     module;                 /* contains the module if the plugin is loaded */
79
80   gpointer _gst_reserved[GST_PADDING];
81 };
82
83 #ifndef GST_PLUGIN_STATIC                               
84 #define GST_PLUGIN_DEFINE_DYNAMIC(major,minor,name,description,init,version,license,package,origin)     \
85 GstPluginDesc gst_plugin_desc = {                       \
86   major,                                                \
87   minor,                                                \
88   name,                                                 \
89   description,                                          \
90   init,                                                 \
91   NULL,                                                 \
92   version,                                              \
93   license,                                              \
94   package,                                              \
95   origin,                                               \
96   GST_PADDING_INIT                                      \
97 };                                                      
98 #define GST_PLUGIN_DEFINE_STATIC(major,minor,name,description,init,version,license,package,origin)
99 #else
100 #define GST_PLUGIN_DEFINE_DYNAMIC(major,minor,name,description,init,version,license,package,origin)
101 #define GST_PLUGIN_DEFINE_STATIC(major,minor,name,description,init,version,license,package,origin)  \
102 static void GST_GNUC_CONSTRUCTOR                        \
103 _gst_plugin_static_init__ ##init (void)                 \
104 {                                                       \
105   static GstPluginDesc plugin_desc_ = {                 \
106     major,                                              \
107     minor,                                              \
108     name,                                               \
109     description,                                        \
110     init,                                               \
111     NULL,                                               \
112     version,                                            \
113     license,                                            \
114     package,                                            \
115     origin,                                             \
116     GST_PADDING_INIT                                    \
117   };                                                    \
118   _gst_plugin_register_static (&plugin_desc_);          \
119 }                       
120 #endif
121
122 #define GST_PLUGIN_DEFINE(major,minor,name,description,init,version,license,package,origin)\
123   GST_PLUGIN_DEFINE_STATIC(major,minor,name,description,init,version,license,package,origin)\
124   GST_PLUGIN_DEFINE_DYNAMIC(major,minor,name,description,init,version,license,package,origin)
125   
126 #define GST_LICENSE_UNKNOWN "unknown"
127
128
129 /* function for filters */
130 typedef gboolean        (*GstPluginFilter)              (GstPlugin *plugin,
131                                                          gpointer user_data);
132
133 #define GST_TYPE_PLUGIN   (gst_plugin_get_type())
134 GType                   gst_plugin_get_type             (void);
135 void                    _gst_plugin_initialize          (void);
136 void                    _gst_plugin_register_static     (GstPluginDesc *desc);
137
138 G_CONST_RETURN gchar*   gst_plugin_get_name             (GstPlugin *plugin);
139 void                    gst_plugin_set_name             (GstPlugin *plugin, const gchar *name);
140 G_CONST_RETURN gchar*   gst_plugin_get_longname         (GstPlugin *plugin);
141 G_CONST_RETURN gchar*   gst_plugin_get_filename         (GstPlugin *plugin);
142 G_CONST_RETURN gchar*   gst_plugin_get_license          (GstPlugin *plugin);
143 G_CONST_RETURN gchar*   gst_plugin_get_package          (GstPlugin *plugin);
144 G_CONST_RETURN gchar*   gst_plugin_get_origin           (GstPlugin *plugin);
145 GModule *               gst_plugin_get_module           (GstPlugin *plugin);
146 gboolean                gst_plugin_is_loaded            (GstPlugin *plugin);
147
148 GList*                  gst_plugin_feature_filter       (GstPlugin *plugin, 
149                                                          GstPluginFeatureFilter filter,
150                                                          gboolean first,
151                                                          gpointer user_data);
152 GList*                  gst_plugin_list_feature_filter  (GList *list, 
153                                                          GstPluginFeatureFilter filter,
154                                                          gboolean first,
155                                                          gpointer user_data);
156 gboolean                gst_plugin_name_filter          (GstPlugin *plugin, const gchar *name);
157
158 GList*                  gst_plugin_get_feature_list     (GstPlugin *plugin);
159 GstPluginFeature*       gst_plugin_find_feature         (GstPlugin *plugin, const gchar *name, GType type);
160
161 GstPlugin *             gst_plugin_load_file            (const gchar *filename, GError** error);
162 gboolean                gst_plugin_unload_plugin        (GstPlugin *plugin);
163
164 void                    gst_plugin_add_feature          (GstPlugin *plugin, GstPluginFeature *feature);
165
166 /* shortcuts to load from the registry pool */
167 gboolean                gst_plugin_load                 (const gchar *name);
168 gboolean                gst_library_load                (const gchar *name);
169
170 G_END_DECLS
171
172 #endif /* __GST_PLUGIN_H__ */