[gst-devel] Plugin versioning.

Richard Boulton richard at tartarus.org
Sat Apr 21 11:47:41 CEST 2001


I've added a first attempt at a plugin versioning fix to the PLUGINVER1
branch in CVS.  This works by adding a major and minor version parameter
to gst_plugin_new(), which plugins should supply the major and minor
version number of the library they were built against.  The core can then
decide whether the versions are compatible (for now, it just checks exact
equality), and gst_plugin_new() can return NULL if not.

This all seems to work well enough for now, but it may break things for
other people: please check the branch out and check it.


While doing this it occurred to me that we could reduce the duplicated
code in plugin_init() and make this work more neatly by storing some
details of the plugin in a struct and using that as the symbol to look up,
rather than using a function pointer.  So, we'd have, in the plugin
(taking esdsink as an example):


GstPluginDesc plugin_desc {
  GST_VERSION_MAJOR,
  GST_VERSION_MINOR,
  "esdsink",
  plugin_init
};

gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
  GstElementFactory *factory;

  factory = gst_elementfactory_new("esdsink", GST_TYPE_ESDSINK,
                                   &esdsink_details);
  g_return_val_if_fail(factory != NULL, FALSE);

  sink_template = sink_factory ();
  gst_elementfactory_add_padtemplate(factory, sink_template);

  gst_plugin_add_factory(plugin, factory);

  return TRUE; // Plugin init succeeded
}

The core would just read the version numbers from the struct, check them,
check that the name wasn't already taken, and only call plugin_init() if
that were really true.

There's a small memory leak in esdsink if the plugin gets created but then
init fails due to elementfactory failing: this would fix this type of error
too.

Thoughts?

-- 
Richard




More information about the gstreamer-devel mailing list