- Removed unused locking from the cothreads
[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
32 G_BEGIN_DECLS
33
34 GQuark gst_plugin_error_quark (void);
35 #define GST_PLUGIN_ERROR gst_plugin_error_quark ()
36
37 typedef enum
38 {
39   GST_PLUGIN_ERROR_MODULE,
40   GST_PLUGIN_ERROR_DEPENDENCIES
41 } GstPluginError;
42
43 #define GST_PLUGIN(plugin)              ((GstPlugin *) (plugin))
44
45 typedef struct _GstPlugin               GstPlugin;
46 typedef struct _GstPluginDesc           GstPluginDesc;
47
48 struct _GstPlugin {
49   gchar         *name;                  /* name of the plugin */
50   gchar         *longname;              /* long name of plugin */
51   gchar         *filename;              /* filename it came from */
52
53   GList         *features;              /* list of features provided */
54   gint           numfeatures;
55
56   gpointer       manager;               /* managing registry */
57   GModule       *module;                /* contains the module if the plugin is loaded */
58   gboolean       init_called;           /* if the init function has been called */
59 };
60
61 /* Initialiser function: returns TRUE if plugin initialised successfully */
62 typedef gboolean (*GstPluginInitFunc) (GModule *module, GstPlugin *plugin);
63
64 struct _GstPluginDesc {
65   gint major_version; /* major version of core that plugin was compiled for */
66   gint minor_version; /* minor version of core that plugin was compiled for */
67   gchar *name;        /* name of plugin */
68   GstPluginInitFunc plugin_init; /* pointer to plugin_init function */
69 };
70
71 #ifndef GST_PLUGIN_STATIC                               
72 #define GST_PLUGIN_DESC_DYNAMIC(major,minor,name,init)  \
73 GstPluginDesc plugin_desc = {                           \
74   major,                                                \
75   minor,                                                \
76   name,                                                 \
77   init                                                  \
78 };                                                      
79 #else
80 #define GST_PLUGIN_DESC_DYNAMIC(major,minor,name,init)
81 #endif
82 #define GST_PLUGIN_DESC_STATIC(major,minor,name,init)   \
83 static void __attribute__ ((constructor))               \
84 _gst_plugin_static_init__ ##init (void)                         \
85 {                                                       \
86   static GstPluginDesc plugin_desc_ = {                 \
87     major,                                              \
88     minor,                                              \
89     name,                                               \
90     init                                                \
91   };                                                    \
92   _gst_plugin_register_static (&plugin_desc_);          \
93 }                       
94
95 #define GST_PLUGIN_DESC(major,minor,name,init)          \
96   GST_PLUGIN_DESC_DYNAMIC (major,minor,name,init)       \
97   GST_PLUGIN_DESC_STATIC (major,minor,name,init)        
98
99 void                    _gst_plugin_initialize          (void);
100 void                    _gst_plugin_register_static     (GstPluginDesc *desc);
101
102 GstPlugin*              gst_plugin_new                  (const gchar *filename);
103
104 const gchar*            gst_plugin_get_name             (GstPlugin *plugin);
105 void                    gst_plugin_set_name             (GstPlugin *plugin, const gchar *name);
106 const gchar*            gst_plugin_get_longname         (GstPlugin *plugin);
107 void                    gst_plugin_set_longname         (GstPlugin *plugin, const gchar *longname);
108 const gchar*            gst_plugin_get_filename         (GstPlugin *plugin);
109 gboolean                gst_plugin_is_loaded            (GstPlugin *plugin);
110
111 GList*                  gst_plugin_get_feature_list     (GstPlugin *plugin);
112 GstPluginFeature*       gst_plugin_find_feature         (GstPlugin *plugin, const gchar *name, GType type);
113
114 gboolean                gst_plugin_load_plugin          (GstPlugin *plugin, GError** error);
115 gboolean                gst_plugin_unload_plugin        (GstPlugin *plugin);
116
117 void                    gst_plugin_add_feature          (GstPlugin *plugin, GstPluginFeature *feature);
118
119 /* shortcuts to load from the registry pool */
120 gboolean                gst_plugin_load                 (const gchar *name);
121 gboolean                gst_library_load                (const gchar *name);
122
123 G_END_DECLS
124
125 #endif /* __GST_PLUGIN_H__ */