2000-08-22 21:18:18 +00:00
|
|
|
<chapter id="cha-plugins">
|
2002-09-06 16:10:31 +00:00
|
|
|
<title>Plugins</title>
|
|
|
|
<!-- FIXME: introduce type definitions before this chapter -->
|
2000-08-22 21:18:18 +00:00
|
|
|
<para>
|
2002-09-06 16:10:31 +00:00
|
|
|
A plugin is a shared library that contains at least one of the following
|
|
|
|
items:
|
2000-08-22 21:18:18 +00:00
|
|
|
</para>
|
|
|
|
|
2001-01-06 02:35:17 +00:00
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2002-09-06 16:10:31 +00:00
|
|
|
one or more element factories
|
2001-01-06 02:35:17 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2002-09-06 16:10:31 +00:00
|
|
|
one or more type definitions
|
2001-01-06 02:35:17 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
2001-03-17 17:50:35 +00:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2002-09-06 16:10:31 +00:00
|
|
|
one or more auto-pluggers
|
2001-03-17 17:50:35 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
2002-04-07 23:32:16 +00:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
exported symbols for use in other plugins
|
|
|
|
</para>
|
|
|
|
</listitem>
|
2001-01-06 02:35:17 +00:00
|
|
|
</itemizedlist>
|
|
|
|
<para>
|
2002-09-06 16:10:31 +00:00
|
|
|
All plugins should implement one function, <function>plugin_init</function>,
|
|
|
|
that creates all the element factories and registers all the type
|
|
|
|
definitions contained in the plugin.
|
|
|
|
Without this function, a plugin cannot be registered.
|
2001-01-06 02:35:17 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
2002-09-06 16:10:31 +00:00
|
|
|
The plugins are maintained in the plugin system. Optionally, the
|
|
|
|
type definitions and the element factories can be saved into an XML
|
|
|
|
representation so that the plugin system does not have to load all
|
|
|
|
available plugins in order to know their definition.
|
2001-01-06 02:35:17 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
The basic plugin structure has the following fields:
|
|
|
|
</para>
|
|
|
|
<programlisting>
|
2002-09-06 16:10:31 +00:00
|
|
|
typedef struct _GstPlugin GstPlugin;
|
|
|
|
|
2001-01-06 02:35:17 +00:00
|
|
|
struct _GstPlugin {
|
|
|
|
gchar *name; /* name of the plugin */
|
|
|
|
gchar *longname; /* long name of plugin */
|
|
|
|
gchar *filename; /* filename it came from */
|
|
|
|
|
|
|
|
GList *types; /* list of types provided */
|
|
|
|
gint numtypes;
|
|
|
|
GList *elements; /* list of elements provided */
|
|
|
|
gint numelements;
|
2001-03-17 17:50:35 +00:00
|
|
|
GList *autopluggers; /* list of autopluggers provided */
|
|
|
|
gint numautopluggers;
|
2001-01-06 02:35:17 +00:00
|
|
|
|
|
|
|
gboolean loaded; /* if the plugin is in memory */
|
|
|
|
};
|
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
<para>
|
2002-09-06 16:10:31 +00:00
|
|
|
You can query a <classname>GList</classname> of available plugins with the
|
|
|
|
function <function>gst_plugin_get_list</function> as this example shows:
|
2001-01-06 02:35:17 +00:00
|
|
|
</para>
|
|
|
|
<programlisting>
|
|
|
|
GList *plugins;
|
|
|
|
|
|
|
|
plugins = gst_plugin_get_list ();
|
|
|
|
|
|
|
|
while (plugins) {
|
|
|
|
GstPlugin *plugin = (GstPlugin *)plugins->data;
|
|
|
|
|
2002-07-09 18:43:13 +00:00
|
|
|
g_print ("plugin: %s\n", gst_plugin_get_name (plugin));
|
2001-01-06 02:35:17 +00:00
|
|
|
|
|
|
|
plugins = g_list_next (plugins);
|
|
|
|
}
|
|
|
|
</programlisting>
|
2000-08-22 21:18:18 +00:00
|
|
|
</chapter>
|