Commit 907e3e97 authored by Benjamin Otte's avatar Benjamin Otte

update plugin initialization restructuring (see email for details

Original commit message from CVS:
update plugin initialization restructuring (see email for details
parent 37d3d6ec
......@@ -464,9 +464,31 @@ dnl ############################
dnl # Set up some more defines #
dnl ############################
dnl Set location of registry dir.
AC_DEFINE_UNQUOTED(GST_CACHE_DIR, "$GST_CACHE_DIR", [Define the registry directory])
AC_SUBST(GST_CACHE_DIR)
dnl set license and copyright notice
AC_DEFINE(GST_LICENSE, "LGPL", [GStreamer license])
AC_DEFINE(GST_COPYRIGHT, "(c) 1999-2003 The GStreamer Team", [copyright message in plugins])
dnl package name in plugins
AC_ARG_WITH(package-name,
AC_HELP_STRING([--with-package-name],[specify package name to use in plugins]),
[case "${withval}" in
yes) AC_MSG_ERROR(bad value ${withval} for --with-package-name) ;;
no) AC_MSG_ERROR(bad value ${withval} for --with-package-name) ;;
*) GST_PACKAGE="${withval}" ;;
esac],
[GST_PACKAGE="Gstreamer"]) dnl Default value
AC_MSG_NOTICE(Using $GST_PACKAGE as package name)
AC_DEFINE_UNQUOTED(GST_PACKAGE, "$GST_PACKAGE", [package name in plugins])
dnl package origin URL
AC_ARG_WITH(package-origin,
AC_HELP_STRING([--with-package-origin],[specify package origin URL to use in plugins]),
[case "${withval}" in
yes) AC_MSG_ERROR(bad value ${withval} for --with-package-origin) ;;
no) AC_MSG_ERROR(bad value ${withval} for --with-package-origin) ;;
*) GST_ORIGIN="${withval}" ;;
esac],
[GST_ORIGIN="http://gstreamer.net"]) dnl Default value
AC_MSG_NOTICE(Using $GST_ORIGIN as package origin)
AC_DEFINE_UNQUOTED(GST_ORIGIN, "$GST_ORIGIN", [package origin])
dnl Set location of plugin directory
if test "x${prefix}" = "xNONE"; then
......
......@@ -23,18 +23,16 @@
#include <string.h>
#include "example.h"
/* The ElementDetails structure gives a human-readable description
* of the plugin, as well as author and version data.
/* The ElementDetails structure gives a human-readable description of the
* plugin, as well as author and version data. Use the GST_ELEMENT_DETAILS
* macro when defining it.
*/
static GstElementDetails example_details = {
static GstElementDetails example_details = GST_ELEMENT_DETAILS (
"An example plugin",
"Example/FirstExample",
"LGPL",
"Shows the basic structure of a plugin",
"0.1",
"your name <your.name@your.isp>",
"(C) 2001",
};
"your name <your.name@your.isp>"
);
/* These are the signals that this element can fire. They are zero-
* based because the numbers themselves are private to the object.
......@@ -186,6 +184,13 @@ gst_example_class_init (GstExampleClass *klass)
/* we also override the default state change handler with our own
* implementation */
gstelement_class->change_state = gst_example_change_state;
/* We can now provide the details for this element, that we defined earlier. */
gst_element_class_set_details (gstelement_class, &example_details);
/* The pad templates can be easily generated from the factories above,
* and then added to the list of padtemplates for the class.
*/
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (sink_factory));
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (src_factory));
}
/* This function is responsible for initializing a specific instance of
......@@ -386,31 +391,20 @@ gst_example_change_state (GstElement *element)
* this function is called to register everything that the plugin provides.
*/
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
plugin_init (GstPlugin *plugin)
{
GstElementFactory *factory;
/* We need to create an ElementFactory for each element we provide.
* This consists of the name of the element, the GType identifier,
* and a pointer to the details structure at the top of the file.
/* We need to register each element we provide with the plugin. This consists
* of the name of the element, a rank that gives the importance of the element
* when compared to similar plugins and the GType identifier.
*/
factory = gst_element_factory_new("example", GST_TYPE_EXAMPLE, &example_details);
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.
*/
gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (sink_factory));
gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (src_factory));
/* The very last thing is to register the elementfactory with the plugin. */
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
if (!gst_element_register (plugin, "example", GST_RANK_MARGINAL, GST_TYPE_EXAMPLE))
return FALSE;
/* 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.
* elementfactories, padtemplates, etc., for use in your application.
*/
}
......@@ -421,12 +415,26 @@ plugin_init (GModule *module, GstPlugin *plugin)
* 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. */
};
GST_PLUGIN_DEFINE (
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. */
"an example plugin", /* a short description of the plugin in English */
plugin_init, /* Pointer to the initialisation function for the plugin. */
"0.1", /* The version number of the plugin */
"LGPL", /* ieffective license the plugin can be shipped with. Must be
* valid for all libraries it links to, too. */
"(c) 2003 E. Xamplewriter",
/* Copyright holder for this plugin. This does not include
* the libraries it links to, contrary to the license. This
* field should be considered informational and not legally
* binding */
"my nifty plugin package",
/* package this plugin belongs to. */
"http://www.mydomain.com"
/* originating URL for this plugin. This is the place to look
* for updates, information and so on. */
);
......@@ -28,15 +28,12 @@
GST_DEBUG_CATEGORY_STATIC(debug_category);
#define GST_CAT_DEFAULT debug_category
GstElementDetails gst_autoplugcache_details = {
GstElementDetails gst_autoplugcache_details = GST_ELEMENT_DETAILS (
"AutoplugCache",
"Generic",
"LGPL",
"Data cache for the dynamic autoplugger",
VERSION,
"Erik Walthinsen <omega@temple-baptist.com>",
"(C) 2001 RidgeRun, Inc. (www.ridgerun.com)",
};
"Erik Walthinsen <omega@temple-baptist.com>"
);
#define GST_TYPE_AUTOPLUGCACHE \
(gst_autoplugcache_get_type())
......@@ -162,6 +159,7 @@ gst_autoplugcache_class_init (GstAutoplugCacheClass *klass)
gobject_class->get_property = gst_autoplugcache_get_property;
gstelement_class->change_state = gst_autoplugcache_change_state;
gst_element_class_set_details (gstelement_class, &gst_autoplugcache_details);
}
static void
......@@ -345,24 +343,25 @@ gst_autoplugcache_get_property (GObject *object, guint prop_id, GValue *value, G
}
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
plugin_init (GstPlugin *plugin)
{
GstElementFactory *factory;
GST_DEBUG_CATEGORY_INIT (debug_category, "AUTOPLUGCACHE", 0, "autoplugcache element");
factory = gst_element_factory_new ("autoplugcache", GST_TYPE_AUTOPLUGCACHE,
&gst_autoplugcache_details);
g_return_val_if_fail (factory != NULL, FALSE);
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
if (!gst_element_register (plugin, "autoplugcache", GST_RANK_NONE, GST_TYPE_AUTOPLUGCACHE))
return FALSE;
return TRUE;
}
GstPluginDesc plugin_desc = {
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"autoplugcache",
plugin_init
};
"an autoplug cache",
plugin_init,
VERSION,
GST_LICENSE,
GST_COPYRIGHT,
GST_PACKAGE,
GST_ORIGIN
)
......@@ -25,15 +25,12 @@
#include <gst/gst.h>
GstElementDetails gst_autoplugger_details = {
GstElementDetails gst_autoplugger_details = GST_ELEMENT_DETAILS (
"Dynamic autoplugger",
"Generic",
"LGPL",
"Magic element that converts from any type to any other",
VERSION,
"Erik Walthinsen <omega@temple-baptist.com>",
"(C) 2001 RidgeRun, Inc. (www.ridgerun.com)",
};
"Erik Walthinsen <omega@temple-baptist.com>"
);
#define GST_TYPE_AUTOPLUGGER \
(gst_autoplugger_get_type())
......@@ -164,6 +161,7 @@ gst_autoplugger_class_init (GstAutopluggerClass *klass)
gobject_class->get_property = gst_autoplugger_get_property;
/* gstelement_class->change_state = gst_autoplugger_change_state; */
gst_element_class_set_details (gstelement_class, &gst_autoplugger_details);
}
static void
......@@ -596,23 +594,24 @@ gst_autoplugger_get_property (GObject *object, guint prop_id, GValue *value, GPa
}
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
plugin_init (GstPlugin *plugin)
{
GstElementFactory *factory;
factory = gst_element_factory_new ("autoplugger", GST_TYPE_AUTOPLUGGER,
&gst_autoplugger_details);
g_return_val_if_fail (factory != NULL, FALSE);
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
if (!gst_element_register (plugin, "autoplugger", GST_RANK_NONE, GST_TYPE_AUTOPLUGGER))
return FALSE;
return TRUE;
}
GstPluginDesc plugin_desc = {
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"autoplugger",
plugin_init
};
"magic element that converts from any type tom any other",
plugin_init,
VERSION,
GST_LICENSE,
GST_COPYRIGHT,
GST_PACKAGE,
GST_ORIGIN
)
......@@ -352,17 +352,17 @@ gst_autoplug_sp (GstCaps *srccaps, GstCaps *sinkcaps, GList *factories)
GstAutoplugNode *node = g_new0 (GstAutoplugNode, 1);
node->prev = NULL;
node->fac = (GstElementFactory *) factories->data;
GST_DEBUG ("trying with %s", node->fac->details->longname);
GST_DEBUG ("trying with %s", node->fac->details.longname);
node->templ = gst_autoplug_can_connect_src (node->fac, srccaps);
node->cost = (node->templ ? gst_autoplug_get_cost (node->fac)
: GST_AUTOPLUG_MAX_COST);
node->endpoint = gst_autoplug_can_connect_sink (node->fac, sinkcaps);
if (node->templ && node->endpoint)
GST_DEBUG ("%s makes connection possible",
node->fac->details->longname);
node->fac->details.longname);
else
GST_DEBUG ("direct connection with %s not possible",
node->fac->details->longname);
node->fac->details.longname);
if ((node->endpoint != NULL) &&
((bestnode == NULL) || (node->cost < bestnode->cost)))
{
......
......@@ -153,6 +153,7 @@ gst_spider_class_init (GstSpiderClass *klass)
gobject_class->dispose = gst_spider_dispose;
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (spider_src_factory));
gst_element_class_set_details (gstelement_class, &gst_spider_details);
gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_spider_request_new_pad);
}
......@@ -554,7 +555,8 @@ gst_spider_find_element_to_plug (GstElement *src, GstElementFactory *fac, GstPad
{
/* is the element the pad is linked to of the right type? */
GstElement *element = GST_PAD_PARENT (pad);
if (GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element))->elementfactory == fac) {
if (G_TYPE_FROM_INSTANCE (element) == gst_element_factory_get_element_type (fac)) {
return element;
}
}
......@@ -632,44 +634,35 @@ gst_spider_plug_from_srcpad (GstSpiderConnection *conn, GstPad *srcpad)
return result;
}
GstElementDetails gst_spider_details = {
GstElementDetails gst_spider_details = GST_ELEMENT_DETAILS (
"Spider",
"Generic",
"LGPL",
"Automatically link sinks and sources",
VERSION,
"Benjamin Otte <in7y118@public.uni-hamburg.de>",
"(C) 2002",
};
"Benjamin Otte <in7y118@public.uni-hamburg.de>"
);
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
plugin_init (GstPlugin *plugin)
{
GstElementFactory *factory;
GST_DEBUG_CATEGORY_INIT (gst_spider_debug, "spider", 0, "spider autoplugging element");
GST_DEBUG_CATEGORY_INIT (gst_spider_identity_debug, "spideridentity", 0, "spider autoplugging proxy element");
factory = gst_element_factory_new("spider", GST_TYPE_SPIDER,
&gst_spider_details);
gst_plugin_set_longname (plugin, "Spider autoplugging elements");
g_return_val_if_fail(factory != NULL, FALSE);
gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (spider_src_factory));
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
/* add spideridentity */
factory = gst_element_factory_new ("spideridentity", GST_TYPE_SPIDER_IDENTITY,
&gst_spider_identity_details);
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
if (!gst_element_register (plugin, "spider", GST_RANK_SECONDARY, GST_TYPE_SPIDER))
return FALSE;
if (!gst_element_register (plugin, "spideridentity", GST_RANK_NONE, GST_TYPE_SPIDER_IDENTITY))
return FALSE;
return TRUE;
}
GstPluginDesc plugin_desc = {
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gstspider",
plugin_init
};
"a 1:n autoplugger",
plugin_init,
VERSION,
GST_LICENSE,
GST_COPYRIGHT,
GST_PACKAGE,
GST_ORIGIN
)
......@@ -27,18 +27,15 @@
#include "gstspideridentity.h"
#include "gstspider.h"
GST_DEBUG_CATEGORY (gst_spider_identity_debug);
GST_DEBUG_CATEGORY_STATIC (gst_spider_identity_debug);
#define GST_CAT_DEFAULT gst_spider_identity_debug
GstElementDetails gst_spider_identity_details = {
static GstElementDetails gst_spider_identity_details = GST_ELEMENT_DETAILS (
"SpiderIdentity",
"Generic",
"LGPL",
"Link between spider and outside elements",
VERSION,
"Benjamin Otte <in7y118@public.uni-hamburg.de>",
"(C) 2002",
};
"Benjamin Otte <in7y118@public.uni-hamburg.de>"
);
/* generic templates
......@@ -47,14 +44,14 @@ GstElementDetails gst_spider_identity_details = {
GST_PAD_TEMPLATE_FACTORY (spider_src_factory,
"src",
GST_PAD_SRC,
GST_PAD_REQUEST,
GST_PAD_ALWAYS,
NULL /* no caps */
);
GST_PAD_TEMPLATE_FACTORY (spider_sink_factory,
"sink",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_PAD_ALWAYS,
NULL /* no caps */
);
......@@ -108,7 +105,10 @@ gst_spider_identity_get_type (void)
0,
(GInstanceInitFunc)gst_spider_identity_init,
};
spider_identity_type = g_type_register_static (GST_TYPE_ELEMENT, "GstSpiderIdentity", &spider_identity_info, 0);
spider_identity_type = g_type_register_static (GST_TYPE_ELEMENT, "GstSpiderIdentity",
&spider_identity_info, 0);
GST_DEBUG_CATEGORY_INIT (gst_spider_identity_debug, "spideridentity",
0, "spider autoplugging proxy element");
}
return spider_identity_type;
}
......@@ -123,6 +123,7 @@ gst_spider_identity_class_init (GstSpiderIdentityClass *klass)
/* add our two pad templates */
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (spider_src_factory));
gst_element_class_add_pad_template (gstelement_class, GST_PAD_TEMPLATE_GET (spider_sink_factory));
gst_element_class_set_details (gstelement_class, &gst_spider_identity_details);
gstelement_class->change_state = GST_DEBUG_FUNCPTR(gst_spider_identity_change_state);
gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_spider_identity_request_new_pad);
......@@ -156,7 +157,6 @@ gst_spider_identity_init (GstSpiderIdentity *ident)
/* variables */
ident->plugged = FALSE;
}
static void
......
......@@ -28,9 +28,6 @@
G_BEGIN_DECLS
extern GstElementDetails gst_spider_identity_details;
GST_DEBUG_CATEGORY_EXTERN(gst_spider_identity_debug);
#define GST_TYPE_SPIDER_IDENTITY \
(gst_spider_identity_get_type())
#define GST_SPIDER_IDENTITY(obj) \
......
......@@ -20,6 +20,10 @@
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "gststaticautoplug.h"
#include <gst/gst.h>
......@@ -85,14 +89,12 @@ static void gst_static_autoplug_init(GstStaticAutoplug *autoplug) {
}
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
plugin_init (GstPlugin *plugin)
{
GstAutoplugFactory *factory;
GST_DEBUG_CATEGORY_INIT (debug_category, "STATIC_AUTOPLUG", 0, "static autoplugger element");
gst_plugin_set_longname (plugin, "A static autoplugger");
factory = gst_autoplug_factory_new ("static",
"A static autoplugger, it constructs the complete element before running it",
gst_static_autoplug_get_type ());
......@@ -103,12 +105,18 @@ plugin_init (GModule *module, GstPlugin *plugin)
return TRUE;
}
GstPluginDesc plugin_desc = {
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gststaticautoplug",
plugin_init
};
"a static autoplugger",
plugin_init,
VERSION,
GST_LICENSE,
GST_COPYRIGHT,
GST_PACKAGE,
GST_ORIGIN
)
static gboolean
gst_autoplug_can_match (GstElementFactory *src, GstElementFactory *dest)
......
......@@ -20,6 +20,10 @@
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "gststaticautoplugrender.h"
#include <gst/gst.h>
......@@ -85,12 +89,10 @@ static void gst_static_autoplug_render_init(GstStaticAutoplugRender *autoplug) {
}
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
plugin_init (GstPlugin *plugin)
{
GstAutoplugFactory *factory;
gst_plugin_set_longname (plugin, "A static autoplugger");
GST_DEBUG_CATEGORY_INIT (debug_category, "STATIC_AUTOPLUG", 0, "static autoplug render element");
factory = gst_autoplug_factory_new ("staticrender",
......@@ -106,12 +108,18 @@ plugin_init (GModule *module, GstPlugin *plugin)
return TRUE;
}
GstPluginDesc plugin_desc = {
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"gststaticautoplugrender",
plugin_init
};
"a static autoplugger",
plugin_init,
VERSION,
GST_LICENSE,
GST_COPYRIGHT,
GST_PACKAGE,
GST_ORIGIN
)
static GstPadTemplate*
gst_autoplug_match_caps (GstElementFactory *factory, GstPadDirection direction, GstCaps *caps)
......
......@@ -26,18 +26,15 @@
#include "gstaggregator.h"
GST_DEBUG_CATEGORY (gst_aggregator_debug);
GST_DEBUG_CATEGORY_STATIC (gst_aggregator_debug);
#define GST_CAT_DEFAULT gst_aggregator_debug
GstElementDetails gst_aggregator_details = {
GstElementDetails gst_aggregator_details = GST_ELEMENT_DETAILS (
"Aggregator pipe fitting",
"Generic",
"LGPL",
"N-to-1 pipe fitting",
VERSION,
"Wim Taymans <wim.taymans@chello.be>",
"(C) 2001",
};
"Wim Taymans <wim.taymans@chello.be>"
);
/* Aggregator signals and args */
enum {
......@@ -80,6 +77,7 @@ gst_aggregator_sched_get_type (void)
#define AGGREGATOR_IS_LOOP_BASED(ag) ((ag)->sched != AGGREGATOR_CHAIN)
static void gst_aggregator_base_init (gpointer g_class);
static void gst_aggregator_class_init (GstAggregatorClass *klass);
static void gst_aggregator_init (GstAggregator *aggregator);
......@@ -106,7 +104,7 @@ gst_aggregator_get_type (void)
if (!aggregator_type) {
static const GTypeInfo aggregator_info = {
sizeof(GstAggregatorClass),
NULL,