# Plugins

A plugin is a shared library that contains at least one of the following items:

- one or more element factories

- one or more type definitions

- one or more auto-pluggers

- exported symbols for use in other plugins

All plugins should implement one function, `plugin_init`, that creates all the element factories and registers all the type definitions contained in the plugin. Without this function, a plugin cannot be registered.

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.

The basic plugin structure has the following fields:

    typedef struct _GstPlugin   GstPlugin;

    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;
      GList *autopluggers;          /* list of autopluggers provided */
      gint numautopluggers;

      gboolean loaded;              /* if the plugin is in memory */
    };

You can query a `GList` of available plugins with the function `gst_plugin_get_list` as this example shows:

        GList *plugins;

        plugins = gst_plugin_get_list ();

        while (plugins) {
          GstPlugin *plugin = (GstPlugin *)plugins->data;

          g_print ("plugin: %s\n", gst_plugin_get_name (plugin));

          plugins = g_list_next (plugins);
        }