Commit 610e9e82 authored by Richard Boulton's avatar Richard Boulton

Merged from BRANCH-PLUGINVER1

Original commit message from CVS:
Merged from BRANCH-PLUGINVER1
parent faf4bde9
......@@ -335,23 +335,17 @@ gst_example_get_arg (GtkObject *object,GtkArg *arg,guint id)
/* This is the entry into the plugin itself. When the plugin loads,
* this function is called to register everything that the plugin provides.
*/
GstPlugin*
plugin_init (GModule *module)
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
GstPlugin *plugin;
GstElementFactory *factory;
/* First we try to create a new Plugin structure. */
plugin = gst_plugin_new("example");
/* If we get a NULL back, chances are we're already loaded. */
g_return_val_if_fail(plugin != NULL, NULL);
/* We need to create an ElementFactory for each element we provide.
* This consists of the name of the element, the GtkType identifier,
* and a pointer to the details structure at the top of the file.
*/
factory = gst_elementfactory_new("example", GST_TYPE_EXAMPLE, &example_details);
g_return_val_if_fail(factory != NULL, NULL);
g_return_val_if_fail(factory != NULL, FALSE);
/* The pad templates can be easily generated from the factories above,
* and then added to the list of padtemplates for the elementfactory.
......@@ -367,10 +361,27 @@ plugin_init (GModule *module)
/* The very last thing is to register the elementfactory with the plugin. */
gst_plugin_add_factory (plugin, factory);
/* Now we can return the pointer to the newly created Plugin object. */
return plugin;
/* Now we can return successfully. */
return TRUE;
/* At this point, the GStreamer core registers the plugin, its
* elementfactories, padtemplates, etc., for use in you application.
*/
}
/* This structure describes the plugin to the system for dynamically loading
* plugins, so that the version number and name can be checked in a uniform
* way.
*
* The symbol pointing to this structure is the only symbol looked up when
* loading the plugin.
*/
GstPluginDesc plugin_desc = {
GST_VERSION_MAJOR, /* The major version of the core that this was built with */
GST_VERSION_MINOR, /* The minor version of the core that this was built with */
"example", /* The name of the plugin. This must be unique: plugins with
* the same name will be assumed to be identical, and only
* one will be loaded. */
plugin_init /* Pointer to the initialisation function for the plugin. */
};
......@@ -80,15 +80,11 @@ gst_static_autoplug_class_init(GstStaticAutoplugClass *klass)
static void gst_static_autoplug_init(GstStaticAutoplug *autoplug) {
}
GstPlugin*
plugin_init (GModule *module)
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
GstPlugin *plugin;
GstAutoplugFactory *factory;
plugin = gst_plugin_new("gststaticautoplug");
g_return_val_if_fail(plugin != NULL,NULL);
gst_plugin_set_longname (plugin, "A static autoplugger");
factory = gst_autoplugfactory_new ("static",
......@@ -98,9 +94,16 @@ plugin_init (GModule *module)
if (factory != NULL) {
gst_plugin_add_autoplugger (plugin, factory);
}
return plugin;
return TRUE;
}
GstPluginDesc plugin_desc = {
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gststaticautoplug",
plugin_init
};
static gboolean
gst_autoplug_can_match (GstElementFactory *src, GstElementFactory *dest)
{
......
......@@ -80,15 +80,11 @@ gst_static_autoplug_render_class_init(GstStaticAutoplugRenderClass *klass)
static void gst_static_autoplug_render_init(GstStaticAutoplugRender *autoplug) {
}
GstPlugin*
plugin_init (GModule *module)
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
GstPlugin *plugin;
GstAutoplugFactory *factory;
plugin = gst_plugin_new("gststaticautoplugrender");
g_return_val_if_fail(plugin != NULL,NULL);
gst_plugin_set_longname (plugin, "A static autoplugger");
factory = gst_autoplugfactory_new ("staticrender",
......@@ -98,9 +94,16 @@ plugin_init (GModule *module)
if (factory != NULL) {
gst_plugin_add_autoplugger (plugin, factory);
}
return plugin;
return TRUE;
}
GstPluginDesc plugin_desc = {
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gststaticautoplugrender",
plugin_init
};
static gboolean
gst_autoplug_can_match (GstElementFactory *src, GstElementFactory *dest)
{
......
......@@ -67,15 +67,12 @@ static struct _elements_entry _elements[] = {
{ NULL, 0 },
};
GstPlugin *plugin_init (GModule *module)
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
GstPlugin *plugin;
GstElementFactory *factory;
gint i = 0;
plugin = gst_plugin_new("gstelements");
g_return_val_if_fail(plugin != NULL,NULL);
gst_plugin_set_longname (plugin, "Standard GST Elements");
while (_elements[i].name) {
......@@ -94,5 +91,13 @@ GstPlugin *plugin_init (GModule *module)
// INFO (GST_INFO_PLUGIN_LOAD,"gstelements: loaded %d standard elements", i);
return plugin;
return TRUE;
}
GstPluginDesc plugin_desc = {
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gstelements",
plugin_init
};
......@@ -27,6 +27,7 @@
#include "gst_private.h"
#include "gstplugin.h"
#include "gstversion.h"
#include "config.h"
......@@ -347,7 +348,7 @@ gboolean
gst_plugin_load_absolute (const gchar *name)
{
GModule *module;
GstPluginInitFunc initfunc;
GstPluginDesc *desc;
GstPlugin *plugin;
struct stat file_status;
......@@ -363,10 +364,19 @@ gst_plugin_load_absolute (const gchar *name)
module = g_module_open(name,G_MODULE_BIND_LAZY);
if (module != NULL) {
if (g_module_symbol(module,"plugin_init",(gpointer *)&initfunc)) {
GST_INFO (GST_CAT_PLUGIN_LOADING,"loading plugin \"%s\"...",
name);
if ((plugin = (initfunc)(module))) {
if (g_module_symbol(module,"plugin_desc",(gpointer *)&desc)) {
GST_INFO (GST_CAT_PLUGIN_LOADING,"loading plugin \"%s\"...", name);
plugin = gst_plugin_new(desc->name, desc->major_version, desc->minor_version);
if (plugin != NULL) {
if (!((desc->plugin_init)(module, plugin))) {
GST_INFO (GST_CAT_PLUGIN_LOADING,"plugin \"%s\" failed to initialise",
plugin->name);
g_free(plugin);
plugin = NULL;
}
}
if (plugin != NULL) {
GST_INFO (GST_CAT_PLUGIN_LOADING,"plugin \"%s\" loaded: %d elements, %d types",
plugin->name,plugin->numelements,plugin->numtypes);
plugin->filename = g_strdup(name);
......@@ -392,16 +402,23 @@ gst_plugin_load_absolute (const gchar *name)
/**
* gst_plugin_new:
* @name: name of new plugin
* @major: major version number of core that plugin is compatible with
* @minor: minor version number of core that plugin is compatible with
*
* Create a new plugin with given name.
*
* Returns: new plugin
* Returns: new plugin, or NULL if plugin couldn't be created, due to
* incompatible version number, or name already being allocated)
*/
GstPlugin*
gst_plugin_new (const gchar *name)
gst_plugin_new (const gchar *name, gint major, gint minor)
{
GstPlugin *plugin;
// return NULL if the major and minor version numbers are not compatible
// with ours.
if (major != GST_VERSION_MAJOR || minor != GST_VERSION_MINOR) return NULL;
// return NULL if the plugin is allready loaded
plugin = gst_plugin_find (name);
if (plugin) return NULL;
......
......@@ -40,7 +40,7 @@
typedef struct _GstPlugin GstPlugin;
typedef struct _GstPluginElement GstPluginElement;
typedef struct _GstPluginDesc GstPluginDesc;
struct _GstPlugin {
gchar *name; /* name of the plugin */
......@@ -57,12 +57,19 @@ struct _GstPlugin {
gboolean loaded; /* if the plugin is in memory */
};
/* Initialiser function: returns TRUE if plugin initialised successfully */
typedef gboolean (*GstPluginInitFunc) (GModule *module, GstPlugin *plugin);
typedef GstPlugin* (*GstPluginInitFunc) (GModule *module);
struct _GstPluginDesc {
gint major_version; /* major version of core that plugin was compiled for */
gint minor_version; /* minor version of core that plugin was compiled for */
gchar *name; /* name of plugin */
GstPluginInitFunc plugin_init; /* pointer to plugin_init function */
};
void _gst_plugin_initialize (void);
GstPlugin* gst_plugin_new (const gchar *name);
GstPlugin* gst_plugin_new (const gchar *name, gint major, gint minor);
void gst_plugin_add_path (const gchar *path);
......
......@@ -28,15 +28,11 @@ GstTypeFactory _factories[] = {
};
GstPlugin*
plugin_init (GModule *module)
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
GstPlugin *plugin;
gint i = 0;
plugin = gst_plugin_new ("gsttypes");
g_return_val_if_fail (plugin != NULL,NULL);
while (_factories[i].mime) {
gst_type_register (&_factories[i]);
gst_plugin_add_type (plugin, &_factories[i]);
......@@ -46,5 +42,12 @@ plugin_init (GModule *module)
//gst_info ("gsttypes: loaded %d standard types\n",i);
return plugin;
return TRUE;
}
GstPluginDesc plugin_desc = {
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gsttypes",
plugin_init
};
......@@ -67,15 +67,12 @@ static struct _elements_entry _elements[] = {
{ NULL, 0 },
};
GstPlugin *plugin_init (GModule *module)
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
GstPlugin *plugin;
GstElementFactory *factory;
gint i = 0;
plugin = gst_plugin_new("gstelements");
g_return_val_if_fail(plugin != NULL,NULL);
gst_plugin_set_longname (plugin, "Standard GST Elements");
while (_elements[i].name) {
......@@ -94,5 +91,13 @@ GstPlugin *plugin_init (GModule *module)
// INFO (GST_INFO_PLUGIN_LOAD,"gstelements: loaded %d standard elements", i);
return plugin;
return TRUE;
}
GstPluginDesc plugin_desc = {
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gstelements",
plugin_init
};
......@@ -335,23 +335,17 @@ gst_example_get_arg (GtkObject *object,GtkArg *arg,guint id)
/* This is the entry into the plugin itself. When the plugin loads,
* this function is called to register everything that the plugin provides.
*/
GstPlugin*
plugin_init (GModule *module)
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
GstPlugin *plugin;
GstElementFactory *factory;
/* First we try to create a new Plugin structure. */
plugin = gst_plugin_new("example");
/* If we get a NULL back, chances are we're already loaded. */
g_return_val_if_fail(plugin != NULL, NULL);
/* We need to create an ElementFactory for each element we provide.
* This consists of the name of the element, the GtkType identifier,
* and a pointer to the details structure at the top of the file.
*/
factory = gst_elementfactory_new("example", GST_TYPE_EXAMPLE, &example_details);
g_return_val_if_fail(factory != NULL, NULL);
g_return_val_if_fail(factory != NULL, FALSE);
/* The pad templates can be easily generated from the factories above,
* and then added to the list of padtemplates for the elementfactory.
......@@ -367,10 +361,27 @@ plugin_init (GModule *module)
/* The very last thing is to register the elementfactory with the plugin. */
gst_plugin_add_factory (plugin, factory);
/* Now we can return the pointer to the newly created Plugin object. */
return plugin;
/* Now we can return successfully. */
return TRUE;
/* At this point, the GStreamer core registers the plugin, its
* elementfactories, padtemplates, etc., for use in you application.
*/
}
/* This structure describes the plugin to the system for dynamically loading
* plugins, so that the version number and name can be checked in a uniform
* way.
*
* The symbol pointing to this structure is the only symbol looked up when
* loading the plugin.
*/
GstPluginDesc plugin_desc = {
GST_VERSION_MAJOR, /* The major version of the core that this was built with */
GST_VERSION_MINOR, /* The minor version of the core that this was built with */
"example", /* The name of the plugin. This must be unique: plugins with
* the same name will be assumed to be identical, and only
* one will be loaded. */
plugin_init /* Pointer to the initialisation function for the plugin. */
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment