2000-12-28 22:12:02 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
|
|
|
* gstplugin.c: Plugin subsystem for loading elements, types, and libs
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
2000-12-28 22:12:02 +00:00
|
|
|
*
|
2000-01-30 09:03:00 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2000-12-28 22:12:02 +00:00
|
|
|
#include "gst_private.h"
|
2000-12-15 01:57:34 +00:00
|
|
|
#include "gstplugin.h"
|
2001-04-22 12:30:14 +00:00
|
|
|
#include "gstversion.h"
|
2001-01-07 05:30:07 +00:00
|
|
|
#include "config.h"
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
static GModule *main_module;
|
|
|
|
|
|
|
|
GList *_gst_plugin_static = NULL;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
/* global list of plugins and its sequence number */
|
2001-08-21 20:16:48 +00:00
|
|
|
GList *_gst_plugins = NULL;
|
|
|
|
gint _gst_plugins_seqno = 0;
|
2000-01-30 09:03:00 +00:00
|
|
|
/* list of paths to check for plugins */
|
2001-08-21 20:16:48 +00:00
|
|
|
GList *_gst_plugin_paths = NULL;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
GList *_gst_libraries = NULL;
|
|
|
|
gint _gst_libraries_seqno = 0;
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/* whether or not to spew library load issues */
|
2000-12-15 01:57:34 +00:00
|
|
|
gboolean _gst_plugin_spew = FALSE;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-01-07 15:20:49 +00:00
|
|
|
/* whether or not to warn if registry needs rebuild (gstreamer-register sets
|
|
|
|
* this to false.) */
|
|
|
|
gboolean _gst_warn_old_registry = TRUE;
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
|
|
|
static gboolean plugin_times_older_than (time_t regtime);
|
|
|
|
static time_t get_time (const char * path);
|
|
|
|
#endif
|
|
|
|
static void gst_plugin_register_statics (GModule *module);
|
|
|
|
static GstPlugin* gst_plugin_register_func (GstPluginDesc *desc, GstPlugin *plugin,
|
|
|
|
GModule *module);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
void
|
|
|
|
_gst_plugin_initialize (void)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
2001-08-06 20:37:21 +00:00
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
2000-08-28 20:20:55 +00:00
|
|
|
xmlDocPtr doc;
|
2001-08-06 20:37:21 +00:00
|
|
|
#endif
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
main_module = g_module_open (NULL, G_MODULE_BIND_LAZY);
|
|
|
|
gst_plugin_register_statics (main_module);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-02-25 03:40:43 +00:00
|
|
|
/* add the main (installed) library path */
|
|
|
|
_gst_plugin_paths = g_list_prepend (_gst_plugin_paths, PLUGINS_DIR);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
/* if this is set, we add build-directory paths to the list */
|
2001-06-19 07:57:06 +00:00
|
|
|
#ifdef PLUGINS_USE_BUILDDIR
|
2000-01-30 09:03:00 +00:00
|
|
|
/* the catch-all plugins directory */
|
2000-12-15 01:57:34 +00:00
|
|
|
_gst_plugin_paths = g_list_prepend (_gst_plugin_paths,
|
2001-06-19 07:57:06 +00:00
|
|
|
PLUGINS_BUILDDIR "/plugins");
|
2000-03-19 00:59:05 +00:00
|
|
|
/* the libreary directory */
|
2000-12-15 01:57:34 +00:00
|
|
|
_gst_plugin_paths = g_list_prepend (_gst_plugin_paths,
|
2001-06-19 07:57:06 +00:00
|
|
|
PLUGINS_BUILDDIR "/libs");
|
2000-01-30 09:03:00 +00:00
|
|
|
/* location libgstelements.so */
|
2000-12-15 01:57:34 +00:00
|
|
|
_gst_plugin_paths = g_list_prepend (_gst_plugin_paths,
|
2001-06-19 07:57:06 +00:00
|
|
|
PLUGINS_BUILDDIR "/gst/elements");
|
2000-12-15 01:57:34 +00:00
|
|
|
_gst_plugin_paths = g_list_prepend (_gst_plugin_paths,
|
2001-06-19 07:57:06 +00:00
|
|
|
PLUGINS_BUILDDIR "/gst/types");
|
2001-03-07 21:52:56 +00:00
|
|
|
_gst_plugin_paths = g_list_prepend (_gst_plugin_paths,
|
2001-06-19 07:57:06 +00:00
|
|
|
PLUGINS_BUILDDIR "/gst/autoplug");
|
2001-12-04 22:12:50 +00:00
|
|
|
_gst_plugin_paths = g_list_prepend (_gst_plugin_paths,
|
|
|
|
PLUGINS_BUILDDIR "/gst/schedulers");
|
2001-06-19 07:57:06 +00:00
|
|
|
#endif /* PLUGINS_USE_BUILDDIR */
|
2001-02-23 01:57:43 +00:00
|
|
|
|
2001-08-06 20:37:21 +00:00
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
2001-01-07 05:30:07 +00:00
|
|
|
doc = xmlParseFile (GST_CONFIG_DIR"/reg.xml");
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-04-03 04:38:35 +00:00
|
|
|
if (!doc ||
|
|
|
|
!doc->xmlRootNode ||
|
|
|
|
doc->xmlRootNode->name == 0 ||
|
|
|
|
strcmp (doc->xmlRootNode->name, "GST-PluginRegistry") ||
|
2001-01-07 07:01:37 +00:00
|
|
|
!plugin_times_older_than(get_time(GST_CONFIG_DIR"/reg.xml"))) {
|
2001-01-07 15:20:49 +00:00
|
|
|
if (_gst_warn_old_registry)
|
2001-12-13 23:14:39 +00:00
|
|
|
g_error ("gstplugin: registry needs rebuild: run gstreamer-register\n");
|
2000-12-15 01:57:34 +00:00
|
|
|
gst_plugin_load_all ();
|
2001-08-21 20:16:48 +00:00
|
|
|
//gst_plugin_unload_all ();
|
2000-08-28 20:20:55 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-01-18 11:16:53 +00:00
|
|
|
gst_plugin_load_thyself (doc->xmlRootNode);
|
2001-01-07 07:45:54 +00:00
|
|
|
|
|
|
|
xmlFreeDoc (doc);
|
2001-10-17 10:21:27 +00:00
|
|
|
#endif /* GST_DISABLE_REGISTRY */
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
void
|
|
|
|
_gst_plugin_register_static (GstPluginDesc *desc)
|
|
|
|
{
|
|
|
|
_gst_plugin_static = g_list_prepend (_gst_plugin_static, desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_plugin_register_statics (GModule *module)
|
|
|
|
{
|
|
|
|
GList *walk = _gst_plugin_static;
|
|
|
|
|
|
|
|
while (walk) {
|
|
|
|
GstPluginDesc *desc = (GstPluginDesc *) walk->data;
|
|
|
|
GstPlugin *plugin;
|
|
|
|
|
|
|
|
plugin = g_new0 (GstPlugin, 1);
|
|
|
|
plugin->filename = NULL;
|
|
|
|
plugin->module = NULL;
|
|
|
|
plugin = gst_plugin_register_func (desc, plugin, module);
|
|
|
|
|
|
|
|
if (plugin) {
|
|
|
|
_gst_plugins = g_list_prepend (_gst_plugins, plugin);
|
|
|
|
_gst_plugins_seqno++;
|
|
|
|
plugin->module = module;
|
|
|
|
}
|
|
|
|
|
|
|
|
walk = g_list_next (walk);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-23 19:22:48 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_add_path:
|
|
|
|
* @path: the directory to add to the search path
|
|
|
|
*
|
|
|
|
* Add a directory to the path searched for plugins.
|
|
|
|
*/
|
2001-02-23 19:09:18 +00:00
|
|
|
void
|
|
|
|
gst_plugin_add_path (const gchar *path)
|
|
|
|
{
|
|
|
|
_gst_plugin_paths = g_list_prepend (_gst_plugin_paths,g_strdup(path));
|
|
|
|
}
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
2001-01-07 07:01:37 +00:00
|
|
|
static time_t
|
|
|
|
get_time(const char * path)
|
|
|
|
{
|
|
|
|
struct stat statbuf;
|
|
|
|
if (stat(path, &statbuf)) return 0;
|
|
|
|
if (statbuf.st_mtime > statbuf.st_ctime) return statbuf.st_mtime;
|
|
|
|
return statbuf.st_ctime;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
plugin_times_older_than_recurse(gchar *path, time_t regtime)
|
|
|
|
{
|
|
|
|
DIR *dir;
|
|
|
|
struct dirent *dirent;
|
2001-01-09 04:36:51 +00:00
|
|
|
gchar *pluginname;
|
2001-01-07 07:01:37 +00:00
|
|
|
|
|
|
|
time_t pathtime = get_time(path);
|
|
|
|
|
|
|
|
if (pathtime > regtime) {
|
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING,
|
|
|
|
"time for %s was %ld; more recent than registry time of %ld\n",
|
|
|
|
path, (long)pathtime, (long)regtime);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2001-01-07 07:01:37 +00:00
|
|
|
dir = opendir(path);
|
|
|
|
if (dir) {
|
|
|
|
while ((dirent = readdir(dir))) {
|
|
|
|
/* don't want to recurse in place or backwards */
|
|
|
|
if (strcmp(dirent->d_name,".") && strcmp(dirent->d_name,"..")) {
|
2001-01-09 04:36:51 +00:00
|
|
|
pluginname = g_strjoin("/",path,dirent->d_name,NULL);
|
|
|
|
if (!plugin_times_older_than_recurse(pluginname , regtime)) {
|
|
|
|
g_free (pluginname);
|
|
|
|
closedir(dir);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
g_free (pluginname);
|
2001-01-07 07:01:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir(dir);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
plugin_times_older_than(time_t regtime)
|
|
|
|
{
|
|
|
|
// return true iff regtime is more recent than the times of all the files
|
|
|
|
// in the plugin dirs.
|
|
|
|
GList *path;
|
|
|
|
path = _gst_plugin_paths;
|
|
|
|
while (path != NULL) {
|
|
|
|
GST_DEBUG (GST_CAT_PLUGIN_LOADING,
|
|
|
|
"comparing plugin times from %s with %ld\n",
|
|
|
|
(gchar *)path->data, (long) regtime);
|
|
|
|
if(!plugin_times_older_than_recurse(path->data, regtime))
|
|
|
|
return FALSE;
|
|
|
|
path = g_list_next(path);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2001-08-21 20:16:48 +00:00
|
|
|
#endif
|
2001-01-07 07:01:37 +00:00
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
static gboolean
|
|
|
|
gst_plugin_load_recurse (gchar *directory, gchar *name)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
DIR *dir;
|
|
|
|
struct dirent *dirent;
|
|
|
|
gboolean loaded = FALSE;
|
2001-01-07 07:45:54 +00:00
|
|
|
gchar *dirname;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
//g_print("recursive load of '%s' in '%s'\n", name, directory);
|
2000-01-30 09:03:00 +00:00
|
|
|
dir = opendir(directory);
|
|
|
|
if (dir) {
|
2000-02-27 23:18:38 +00:00
|
|
|
while ((dirent = readdir(dir))) {
|
2000-01-30 09:03:00 +00:00
|
|
|
/* don't want to recurse in place or backwards */
|
|
|
|
if (strcmp(dirent->d_name,".") && strcmp(dirent->d_name,"..")) {
|
2001-01-07 07:45:54 +00:00
|
|
|
dirname = g_strjoin("/",directory,dirent->d_name,NULL);
|
|
|
|
loaded = gst_plugin_load_recurse(dirname,name);
|
|
|
|
g_free(dirname);
|
|
|
|
if (loaded && name) {
|
|
|
|
closedir(dir);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir(dir);
|
|
|
|
} else {
|
|
|
|
if (strstr(directory,".so")) {
|
|
|
|
gchar *temp;
|
|
|
|
if (name) {
|
2001-01-29 00:06:02 +00:00
|
|
|
if ((temp = strstr(directory,name)) &&
|
2000-01-30 09:03:00 +00:00
|
|
|
(!strcmp(temp,name))) {
|
2000-03-20 20:25:03 +00:00
|
|
|
loaded = gst_plugin_load_absolute(directory);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
} else if ((temp = strstr(directory,".so")) &&
|
|
|
|
(!strcmp(temp,".so"))) {
|
2000-03-20 20:25:03 +00:00
|
|
|
loaded = gst_plugin_load_absolute(directory);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return loaded;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_plugin_load_all:
|
|
|
|
*
|
|
|
|
* Load all plugins in the path.
|
|
|
|
*/
|
2001-01-29 00:06:02 +00:00
|
|
|
void
|
2001-08-21 20:16:48 +00:00
|
|
|
gst_plugin_load_all (void)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GList *path;
|
|
|
|
|
|
|
|
path = _gst_plugin_paths;
|
|
|
|
while (path != NULL) {
|
2001-03-20 18:29:00 +00:00
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING,"loading plugins from %s",(gchar *)path->data);
|
2000-01-30 09:03:00 +00:00
|
|
|
gst_plugin_load_recurse(path->data,NULL);
|
|
|
|
path = g_list_next(path);
|
|
|
|
}
|
2001-08-21 20:16:48 +00:00
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING,"loaded %d plugins", _gst_plugins_seqno);
|
|
|
|
}
|
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_unload_all:
|
|
|
|
*
|
|
|
|
* Unload all plugins in memory.
|
|
|
|
*/
|
2001-08-21 20:16:48 +00:00
|
|
|
void
|
|
|
|
gst_plugin_unload_all (void)
|
|
|
|
{
|
|
|
|
GList *walk = _gst_plugins;
|
|
|
|
|
|
|
|
while (walk) {
|
|
|
|
GstPlugin *plugin = (GstPlugin *) walk->data;
|
|
|
|
|
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING, "unloading plugin %s", plugin->name);
|
|
|
|
if (plugin->module) {
|
|
|
|
GList *features = gst_plugin_get_feature_list (plugin);
|
|
|
|
|
|
|
|
while (features) {
|
|
|
|
GstPluginFeature *feature = GST_PLUGIN_FEATURE (features->data);
|
|
|
|
|
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING, "unloading feature %s", GST_OBJECT_NAME (feature));
|
|
|
|
gst_plugin_feature_unload_thyself (feature);
|
|
|
|
|
|
|
|
features = g_list_next (features);
|
|
|
|
}
|
|
|
|
if (g_module_close (plugin->module)) {
|
|
|
|
plugin->module = NULL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
g_warning ("error closing module");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
walk = g_list_next (walk);
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2000-03-20 20:25:03 +00:00
|
|
|
/**
|
|
|
|
* gst_library_load:
|
2000-03-21 19:54:30 +00:00
|
|
|
* @name: name of library to load
|
2000-03-20 20:25:03 +00:00
|
|
|
*
|
2000-03-21 19:54:30 +00:00
|
|
|
* Load the named library. Name should be given as
|
|
|
|
* "liblibrary.so".
|
2000-03-20 20:25:03 +00:00
|
|
|
*
|
2000-03-21 19:54:30 +00:00
|
|
|
* Returns: whether the library was loaded or not
|
2000-03-20 20:25:03 +00:00
|
|
|
*/
|
2001-01-29 00:06:02 +00:00
|
|
|
gboolean
|
|
|
|
gst_library_load (const gchar *name)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
2000-08-28 20:20:55 +00:00
|
|
|
gboolean res;
|
|
|
|
GList *libraries = _gst_libraries;
|
|
|
|
|
|
|
|
while (libraries) {
|
|
|
|
if (!strcmp((gchar *)libraries->data, name)) return TRUE;
|
|
|
|
|
|
|
|
libraries = g_list_next(libraries);
|
|
|
|
}
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2000-03-21 19:54:30 +00:00
|
|
|
// for now this is the same
|
2000-08-28 20:20:55 +00:00
|
|
|
res = gst_plugin_load(name);
|
|
|
|
|
|
|
|
if (res) {
|
2001-01-06 02:35:17 +00:00
|
|
|
_gst_libraries = g_list_prepend(_gst_libraries, g_strdup (name));
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
2000-03-20 20:25:03 +00:00
|
|
|
}
|
2000-03-21 19:54:30 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_load:
|
|
|
|
* @name: name of plugin to load
|
|
|
|
*
|
|
|
|
* Load the named plugin. Name should be given as
|
|
|
|
* "libplugin.so".
|
|
|
|
*
|
|
|
|
* Returns: whether the plugin was loaded or not
|
|
|
|
*/
|
2001-01-29 00:06:02 +00:00
|
|
|
gboolean
|
|
|
|
gst_plugin_load (const gchar *name)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GList *path;
|
|
|
|
gchar *libspath;
|
2001-01-07 07:45:54 +00:00
|
|
|
gchar *pluginname;
|
2001-08-21 20:16:48 +00:00
|
|
|
GstPlugin *plugin;
|
|
|
|
|
|
|
|
g_return_val_if_fail (name != NULL, FALSE);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
plugin = gst_plugin_find (name);
|
2001-08-21 20:16:48 +00:00
|
|
|
|
|
|
|
if (plugin && plugin->module)
|
|
|
|
return TRUE;
|
2000-12-15 01:57:34 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
path = _gst_plugin_paths;
|
|
|
|
while (path != NULL) {
|
2001-01-07 07:45:54 +00:00
|
|
|
pluginname = g_module_build_path(path->data,name);
|
|
|
|
if (gst_plugin_load_absolute(pluginname)) {
|
|
|
|
g_free(pluginname);
|
2000-01-30 09:03:00 +00:00
|
|
|
return TRUE;
|
2001-01-07 07:45:54 +00:00
|
|
|
}
|
|
|
|
g_free(pluginname);
|
2000-01-30 09:03:00 +00:00
|
|
|
libspath = g_strconcat(path->data,"/.libs",NULL);
|
2000-03-20 20:25:03 +00:00
|
|
|
//g_print("trying to load '%s'\n",g_module_build_path(libspath,name));
|
2001-01-07 07:45:54 +00:00
|
|
|
pluginname = g_module_build_path(libspath,name);
|
|
|
|
g_free(libspath);
|
|
|
|
if (gst_plugin_load_absolute(pluginname)) {
|
|
|
|
g_free(pluginname);
|
2000-01-30 09:03:00 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-01-07 07:45:54 +00:00
|
|
|
g_free(pluginname);
|
2000-03-20 20:25:03 +00:00
|
|
|
//g_print("trying to load '%s' from '%s'\n",name,path->data);
|
2001-01-07 07:45:54 +00:00
|
|
|
pluginname = g_module_build_path("",name);
|
|
|
|
if (gst_plugin_load_recurse(path->data,pluginname)) {
|
|
|
|
g_free(pluginname);
|
2000-01-30 09:03:00 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-01-07 07:45:54 +00:00
|
|
|
g_free(pluginname);
|
2000-01-30 09:03:00 +00:00
|
|
|
path = g_list_next(path);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
/**
|
2001-10-21 18:00:31 +00:00
|
|
|
* gst_plugin_load_absolute:
|
2001-08-21 20:16:48 +00:00
|
|
|
* @name: name of plugin to load
|
|
|
|
*
|
|
|
|
* Load the named plugin. Name should be given as
|
2001-10-21 18:00:31 +00:00
|
|
|
* "/path/to/plugin/libplugin.so".
|
2001-08-21 20:16:48 +00:00
|
|
|
*
|
|
|
|
* Returns: whether the plugin was loaded or not
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_plugin_load_absolute (const gchar *filename)
|
|
|
|
{
|
|
|
|
GstPlugin *plugin = NULL;
|
|
|
|
GList *plugins = _gst_plugins;
|
|
|
|
|
|
|
|
g_return_val_if_fail (filename != NULL, FALSE);
|
|
|
|
|
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING, "plugin \"%s\" absolute loading", filename);
|
|
|
|
|
|
|
|
while (plugins) {
|
|
|
|
GstPlugin *testplugin = (GstPlugin *)plugins->data;
|
|
|
|
|
|
|
|
if (testplugin->filename) {
|
|
|
|
if (!strcmp (testplugin->filename, filename)) {
|
|
|
|
plugin = testplugin;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
plugins = g_list_next (plugins);
|
|
|
|
}
|
|
|
|
if (!plugin) {
|
|
|
|
plugin = g_new0 (GstPlugin, 1);
|
|
|
|
plugin->filename = g_strdup (filename);
|
|
|
|
_gst_plugins = g_list_prepend (_gst_plugins, plugin);
|
|
|
|
_gst_plugins_seqno++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return gst_plugin_load_plugin (plugin);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_plugin_check_version (gint major, gint minor)
|
|
|
|
{
|
|
|
|
// return NULL if the major and minor version numbers are not compatible
|
|
|
|
// with ours.
|
|
|
|
if (major != GST_VERSION_MAJOR || minor != GST_VERSION_MINOR)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstPlugin*
|
|
|
|
gst_plugin_register_func (GstPluginDesc *desc, GstPlugin *plugin, GModule *module)
|
|
|
|
{
|
|
|
|
if (!gst_plugin_check_version (desc->major_version, desc->minor_version)) {
|
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING,"plugin \"%s\" has incompatible version, not loading",
|
|
|
|
plugin->filename);
|
|
|
|
g_free(plugin);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
plugin->name = g_strdup(desc->name);
|
|
|
|
|
|
|
|
if (!((desc->plugin_init) (module, plugin))) {
|
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING,"plugin \"%s\" failed to initialise",
|
|
|
|
plugin->filename);
|
|
|
|
g_free(plugin);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return plugin;
|
|
|
|
}
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/**
|
2001-10-21 18:00:31 +00:00
|
|
|
* gst_plugin_load_plugin:
|
|
|
|
* @plugin: The plugin to load
|
|
|
|
*
|
|
|
|
* Load the given plugin.
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
|
|
|
* Returns: whether or not the plugin loaded
|
|
|
|
*/
|
2001-01-29 00:06:02 +00:00
|
|
|
gboolean
|
2001-08-21 20:16:48 +00:00
|
|
|
gst_plugin_load_plugin (GstPlugin *plugin)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GModule *module;
|
2001-04-22 12:30:14 +00:00
|
|
|
GstPluginDesc *desc;
|
2000-12-04 09:32:43 +00:00
|
|
|
struct stat file_status;
|
2001-08-21 20:16:48 +00:00
|
|
|
gchar *filename;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
g_return_val_if_fail (plugin != NULL, FALSE);
|
2001-05-25 21:39:54 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
if (plugin->module)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
filename = plugin->filename;
|
|
|
|
|
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING, "plugin \"%s\" loading", filename);
|
|
|
|
|
|
|
|
if (g_module_supported () == FALSE) {
|
2000-12-28 00:18:26 +00:00
|
|
|
g_warning("gstplugin: wow, you built this on a platform without dynamic loading???\n");
|
2000-02-27 23:18:38 +00:00
|
|
|
return FALSE;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
if (stat (filename, &file_status)) {
|
|
|
|
//g_print("problem opening file %s\n",filename);
|
2000-12-04 09:32:43 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
module = g_module_open (filename, G_MODULE_BIND_LAZY);
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
if (module != NULL) {
|
2001-08-21 20:16:48 +00:00
|
|
|
if (g_module_symbol (module, "plugin_desc", (gpointer *)&desc)) {
|
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING,"loading plugin \"%s\"...", filename);
|
|
|
|
|
|
|
|
plugin->filename = g_strdup (filename);
|
|
|
|
plugin = gst_plugin_register_func (desc, plugin, module);
|
2001-04-22 12:30:14 +00:00
|
|
|
|
|
|
|
if (plugin != NULL) {
|
2001-08-21 20:16:48 +00:00
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING,"plugin \"%s\" loaded",
|
|
|
|
plugin->filename);
|
|
|
|
plugin->module = module;
|
2000-01-30 09:03:00 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
2000-08-28 20:20:55 +00:00
|
|
|
return TRUE;
|
2000-01-30 09:03:00 +00:00
|
|
|
} else if (_gst_plugin_spew) {
|
2001-02-23 19:09:18 +00:00
|
|
|
// FIXME this should be some standard gst mechanism!!!
|
2001-08-21 20:16:48 +00:00
|
|
|
g_printerr ("error loading plugin %s, reason: %s\n", filename, g_module_error());
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2001-05-25 21:39:54 +00:00
|
|
|
else {
|
2001-08-21 20:16:48 +00:00
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING, "error loading plugin %s, reason: %s\n", filename, g_module_error());
|
2001-05-25 21:39:54 +00:00
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-06 02:35:17 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_get_name:
|
|
|
|
* @plugin: plugin to get the name of
|
|
|
|
*
|
|
|
|
* Get the short name of the plugin
|
|
|
|
*
|
|
|
|
* Returns: the name of the plugin
|
|
|
|
*/
|
|
|
|
const gchar*
|
|
|
|
gst_plugin_get_name (GstPlugin *plugin)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (plugin != NULL, NULL);
|
|
|
|
|
|
|
|
return plugin->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_plugin_set_name:
|
|
|
|
* @plugin: plugin to set name of
|
|
|
|
* @name: new name
|
|
|
|
*
|
|
|
|
* Sets the name (should be short) of the plugin.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_plugin_set_name (GstPlugin *plugin, const gchar *name)
|
|
|
|
{
|
|
|
|
g_return_if_fail (plugin != NULL);
|
|
|
|
|
|
|
|
if (plugin->name)
|
|
|
|
g_free (plugin->name);
|
|
|
|
|
|
|
|
plugin->name = g_strdup (name);
|
|
|
|
}
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_set_longname:
|
|
|
|
* @plugin: plugin to set long name of
|
|
|
|
* @longname: new long name
|
|
|
|
*
|
|
|
|
* Sets the long name (should be descriptive) of the plugin.
|
|
|
|
*/
|
2001-01-29 00:06:02 +00:00
|
|
|
void
|
|
|
|
gst_plugin_set_longname (GstPlugin *plugin, const gchar *longname)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
g_return_if_fail(plugin != NULL);
|
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
if (plugin->longname)
|
2001-01-06 02:35:17 +00:00
|
|
|
g_free(plugin->longname);
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
plugin->longname = g_strdup(longname);
|
|
|
|
}
|
|
|
|
|
2001-01-06 02:35:17 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_get_longname:
|
|
|
|
* @plugin: plugin to get long name of
|
|
|
|
*
|
|
|
|
* Get the long descriptive name of the plugin
|
|
|
|
*
|
|
|
|
* Returns: the long name of the plugin
|
|
|
|
*/
|
|
|
|
const gchar*
|
|
|
|
gst_plugin_get_longname (GstPlugin *plugin)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (plugin != NULL, NULL);
|
|
|
|
|
|
|
|
return plugin->longname;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_plugin_get_filename:
|
|
|
|
* @plugin: plugin to get the filename of
|
|
|
|
*
|
|
|
|
* get the filename of the plugin
|
|
|
|
*
|
|
|
|
* Returns: the filename of the plugin
|
|
|
|
*/
|
|
|
|
const gchar*
|
|
|
|
gst_plugin_get_filename (GstPlugin *plugin)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (plugin != NULL, NULL);
|
|
|
|
|
|
|
|
return plugin->filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_plugin_is_loaded:
|
|
|
|
* @plugin: plugin to query
|
|
|
|
*
|
|
|
|
* queries if the plugin is loaded into memory
|
|
|
|
*
|
|
|
|
* Returns: TRUE is loaded, FALSE otherwise
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_plugin_is_loaded (GstPlugin *plugin)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (plugin != NULL, FALSE);
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
return (plugin->module != NULL);
|
2001-01-06 02:35:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_find:
|
|
|
|
* @name: name of plugin to find
|
|
|
|
*
|
|
|
|
* Search the list of registered plugins for one of the given name
|
|
|
|
*
|
|
|
|
* Returns: pointer to the #GstPlugin if found, NULL otherwise
|
|
|
|
*/
|
2000-12-15 01:57:34 +00:00
|
|
|
GstPlugin*
|
2001-01-29 00:06:02 +00:00
|
|
|
gst_plugin_find (const gchar *name)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GList *plugins = _gst_plugins;
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
while (plugins) {
|
|
|
|
GstPlugin *plugin = (GstPlugin *)plugins->data;
|
2001-08-21 20:16:48 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
if (plugin->name) {
|
2001-08-21 20:16:48 +00:00
|
|
|
if (!strcmp (plugin->name, name)) {
|
2000-01-30 09:03:00 +00:00
|
|
|
return plugin;
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2001-08-21 20:16:48 +00:00
|
|
|
plugins = g_list_next (plugins);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
static GstPluginFeature*
|
|
|
|
gst_plugin_find_feature_func (GstPlugin *plugin, const gchar *name, GType type)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
2001-08-21 20:16:48 +00:00
|
|
|
GList *features = plugin->features;
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
while (features) {
|
|
|
|
GstPluginFeature *feature = GST_PLUGIN_FEATURE (features->data);
|
2001-01-29 00:06:02 +00:00
|
|
|
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
if (!strcmp(GST_OBJECT_NAME (feature), name) && G_OBJECT_TYPE (feature) == type)
|
|
|
|
return GST_PLUGIN_FEATURE (feature);
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
features = g_list_next (features);
|
2001-03-07 21:52:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 22:16:47 +00:00
|
|
|
static GstPluginFeature*
|
2001-08-21 20:16:48 +00:00
|
|
|
gst_plugin_find_feature (const gchar *name, GType type)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
2001-08-21 20:16:48 +00:00
|
|
|
GList *plugins;
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
plugins = _gst_plugins;
|
2000-08-28 20:20:55 +00:00
|
|
|
while (plugins) {
|
2001-08-21 20:16:48 +00:00
|
|
|
GstPlugin *plugin = (GstPlugin *)plugins->data;
|
|
|
|
GstPluginFeature *feature;
|
2000-12-30 19:04:51 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
feature = gst_plugin_find_feature_func (plugin, name, type);
|
|
|
|
if (feature)
|
|
|
|
return feature;
|
|
|
|
|
2000-08-28 20:20:55 +00:00
|
|
|
plugins = g_list_next(plugins);
|
|
|
|
}
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
return NULL;
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/**
|
2001-08-21 20:16:48 +00:00
|
|
|
* gst_plugin_add_feature:
|
|
|
|
* @plugin: plugin to add feature to
|
|
|
|
* @feature: feature to add
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
2001-08-21 20:16:48 +00:00
|
|
|
* Add feature to the list of those provided by the plugin.
|
2000-01-30 09:03:00 +00:00
|
|
|
*/
|
2001-01-29 00:06:02 +00:00
|
|
|
void
|
2001-08-21 20:16:48 +00:00
|
|
|
gst_plugin_add_feature (GstPlugin *plugin, GstPluginFeature *feature)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
2001-08-21 20:16:48 +00:00
|
|
|
GstPluginFeature *oldfeature;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
g_return_if_fail (plugin != NULL);
|
2001-08-21 20:16:48 +00:00
|
|
|
g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
|
|
|
|
g_return_if_fail (feature != NULL);
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
oldfeature = gst_plugin_find_feature_func (plugin, GST_OBJECT_NAME (feature), G_OBJECT_TYPE (feature));
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
if (!oldfeature) {
|
|
|
|
feature->manager = plugin;
|
|
|
|
plugin->features = g_list_prepend (plugin->features, feature);
|
|
|
|
plugin->numfeatures++;
|
|
|
|
}
|
2001-03-07 21:52:56 +00:00
|
|
|
}
|
|
|
|
|
2000-03-27 19:53:43 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_get_list:
|
|
|
|
*
|
|
|
|
* get the currently loaded plugins
|
|
|
|
*
|
|
|
|
* Returns; a GList of GstPlugin elements
|
|
|
|
*/
|
2000-12-15 01:57:34 +00:00
|
|
|
GList*
|
2001-03-07 21:52:56 +00:00
|
|
|
gst_plugin_get_list (void)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
2001-06-05 01:15:29 +00:00
|
|
|
return g_list_copy (_gst_plugins);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-08-06 20:37:21 +00:00
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
2000-10-25 19:09:53 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_save_thyself:
|
|
|
|
* @parent: the parent node to save the plugin to
|
|
|
|
*
|
|
|
|
* saves the plugin into an XML representation
|
|
|
|
*
|
|
|
|
* Returns: the new XML node
|
|
|
|
*/
|
2001-01-29 00:06:02 +00:00
|
|
|
xmlNodePtr
|
|
|
|
gst_plugin_save_thyself (xmlNodePtr parent)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
2000-08-28 20:20:55 +00:00
|
|
|
xmlNodePtr tree, subtree;
|
2001-08-21 20:16:48 +00:00
|
|
|
GList *plugins = NULL;
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
plugins = _gst_plugins;
|
2000-08-28 20:20:55 +00:00
|
|
|
while (plugins) {
|
|
|
|
GstPlugin *plugin = (GstPlugin *)plugins->data;
|
2001-08-21 20:16:48 +00:00
|
|
|
GList *features;
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
plugins = g_list_next (plugins);
|
|
|
|
|
|
|
|
if (!plugin->name)
|
|
|
|
continue;
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
tree = xmlNewChild (parent, NULL, "plugin", NULL);
|
|
|
|
xmlNewChild (tree, NULL, "name", plugin->name);
|
|
|
|
xmlNewChild (tree, NULL, "longname", plugin->longname);
|
|
|
|
xmlNewChild (tree, NULL, "filename", plugin->filename);
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
features = plugin->features;
|
|
|
|
while (features) {
|
|
|
|
GstPluginFeature *feature = GST_PLUGIN_FEATURE (features->data);
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
subtree = xmlNewChild(tree, NULL, "feature", NULL);
|
|
|
|
xmlNewProp (subtree, "typename", g_type_name (G_OBJECT_TYPE (feature)));
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
gst_object_save_thyself (GST_OBJECT (feature), subtree);
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
features = g_list_next (features);
|
2001-03-07 21:52:56 +00:00
|
|
|
}
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
2000-10-25 19:09:53 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_load_thyself:
|
|
|
|
* @parent: the parent node to load the plugin from
|
|
|
|
*
|
|
|
|
* load the plugin from an XML representation
|
|
|
|
*/
|
2001-01-29 00:06:02 +00:00
|
|
|
void
|
|
|
|
gst_plugin_load_thyself (xmlNodePtr parent)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
2001-01-29 00:06:02 +00:00
|
|
|
xmlNodePtr kinderen;
|
2001-08-21 20:16:48 +00:00
|
|
|
gint featurecount = 0;
|
2001-01-07 07:45:54 +00:00
|
|
|
gchar *pluginname;
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2001-01-18 11:16:53 +00:00
|
|
|
kinderen = parent->xmlChildrenNode; // Dutch invasion :-)
|
2000-08-28 20:20:55 +00:00
|
|
|
while (kinderen) {
|
2001-03-07 21:52:56 +00:00
|
|
|
if (!strcmp (kinderen->name, "plugin")) {
|
2001-01-18 11:16:53 +00:00
|
|
|
xmlNodePtr field = kinderen->xmlChildrenNode;
|
2000-12-11 00:04:25 +00:00
|
|
|
GstPlugin *plugin = g_new0 (GstPlugin, 1);
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
plugin->numfeatures = 0;
|
|
|
|
plugin->features = NULL;
|
|
|
|
plugin->module = NULL;
|
2000-08-28 20:20:55 +00:00
|
|
|
|
|
|
|
while (field) {
|
2001-03-07 21:52:56 +00:00
|
|
|
if (!strcmp (field->name, "name")) {
|
|
|
|
pluginname = xmlNodeGetContent (field);
|
|
|
|
if (gst_plugin_find (pluginname)) {
|
|
|
|
g_free (pluginname);
|
|
|
|
g_free (plugin);
|
2000-08-28 20:20:55 +00:00
|
|
|
plugin = NULL;
|
|
|
|
break;
|
2001-01-07 07:45:54 +00:00
|
|
|
} else {
|
|
|
|
plugin->name = pluginname;
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
}
|
2001-03-07 21:52:56 +00:00
|
|
|
else if (!strcmp (field->name, "longname")) {
|
|
|
|
plugin->longname = xmlNodeGetContent (field);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
2001-03-07 21:52:56 +00:00
|
|
|
else if (!strcmp (field->name, "filename")) {
|
|
|
|
plugin->filename = xmlNodeGetContent (field);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
2001-08-21 20:16:48 +00:00
|
|
|
else if (!strcmp (field->name, "feature")) {
|
|
|
|
GstPluginFeature *feature;
|
|
|
|
gchar *prop;
|
|
|
|
|
|
|
|
prop = xmlGetProp (field, "typename");
|
|
|
|
feature = GST_PLUGIN_FEATURE (g_object_new (g_type_from_name (prop), NULL));
|
|
|
|
|
|
|
|
if (feature) {
|
|
|
|
gst_object_restore_thyself (GST_OBJECT (feature), field);
|
|
|
|
gst_plugin_add_feature (plugin, feature);
|
|
|
|
featurecount++;
|
|
|
|
}
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
field = field->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (plugin) {
|
2001-03-07 21:52:56 +00:00
|
|
|
_gst_plugins = g_list_prepend (_gst_plugins, plugin);
|
2001-08-21 20:16:48 +00:00
|
|
|
_gst_plugins_seqno++;
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
kinderen = kinderen->next;
|
|
|
|
}
|
2001-08-21 20:16:48 +00:00
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING, "added %d features ", featurecount);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
2001-10-17 10:21:27 +00:00
|
|
|
#endif /* GST_DISABLE_REGISTRY */
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-01-04 10:54:27 +00:00
|
|
|
|
2001-01-06 02:35:17 +00:00
|
|
|
/**
|
2001-08-21 20:16:48 +00:00
|
|
|
* gst_plugin_get_feature_list:
|
|
|
|
* @plugin: the plugin to get the features from
|
2001-03-07 21:52:56 +00:00
|
|
|
*
|
2001-08-21 20:16:48 +00:00
|
|
|
* get a list of all the features that this plugin provides
|
2001-03-07 21:52:56 +00:00
|
|
|
*
|
2001-08-21 20:16:48 +00:00
|
|
|
* Returns: a GList of features
|
2001-03-07 21:52:56 +00:00
|
|
|
*/
|
|
|
|
GList*
|
2001-08-21 20:16:48 +00:00
|
|
|
gst_plugin_get_feature_list (GstPlugin *plugin)
|
2001-03-07 21:52:56 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (plugin != NULL, NULL);
|
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
return plugin->features;
|
2001-03-07 21:52:56 +00:00
|
|
|
}
|