2000-01-30 09:03:00 +00:00
|
|
|
/* Gnome-Streamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <unistd.h>
|
2000-02-04 02:25:34 +00:00
|
|
|
#include <string.h>
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
#include "gstplugin.h"
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
|
2000-12-04 09:32:43 +00:00
|
|
|
//#undef PLUGINS_USE_SRCDIR
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/* list of loaded modules and its sequence number */
|
|
|
|
GList *_gst_modules;
|
|
|
|
gint _gst_modules_seqno;
|
|
|
|
/* global list of plugins and its sequence number */
|
|
|
|
GList *_gst_plugins;
|
|
|
|
gint _gst_plugins_seqno;
|
|
|
|
/* list of paths to check for plugins */
|
|
|
|
GList *_gst_plugin_paths;
|
|
|
|
|
2000-08-28 20:20:55 +00:00
|
|
|
GList *_gst_libraries;
|
|
|
|
gint _gst_libraries_seqno;
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
void
|
|
|
|
_gst_plugin_initialize (void)
|
|
|
|
{
|
2000-08-28 20:20:55 +00:00
|
|
|
xmlDocPtr doc;
|
2000-01-30 09:03:00 +00:00
|
|
|
_gst_modules = NULL;
|
|
|
|
_gst_modules_seqno = 0;
|
|
|
|
_gst_plugins = NULL;
|
|
|
|
_gst_plugins_seqno = 0;
|
|
|
|
_gst_plugin_paths = NULL;
|
2000-08-28 20:20:55 +00:00
|
|
|
_gst_libraries = NULL;
|
|
|
|
_gst_libraries_seqno = 0;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* if this is set, we add build-directory paths to the list */
|
|
|
|
#ifdef PLUGINS_USE_SRCDIR
|
|
|
|
/* the catch-all plugins directory */
|
2000-12-15 01:57:34 +00:00
|
|
|
_gst_plugin_paths = g_list_prepend (_gst_plugin_paths,
|
|
|
|
PLUGINS_SRCDIR "/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,
|
|
|
|
PLUGINS_SRCDIR "/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,
|
|
|
|
PLUGINS_SRCDIR "/gst/elements");
|
|
|
|
_gst_plugin_paths = g_list_prepend (_gst_plugin_paths,
|
|
|
|
PLUGINS_SRCDIR "/gst/types");
|
2000-12-11 00:04:25 +00:00
|
|
|
#else
|
|
|
|
/* add the main (installed) library path */
|
2000-12-15 01:57:34 +00:00
|
|
|
_gst_plugin_paths = g_list_prepend (_gst_plugin_paths, PLUGINS_DIR);
|
2000-01-30 09:03:00 +00:00
|
|
|
#endif /* PLUGINS_USE_SRCDIR */
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
doc = xmlParseFile ("/etc/gstreamer/reg.xml");
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
if (!doc || strcmp (doc->root->name, "GST-PluginRegistry")) {
|
|
|
|
g_print ("gstplugin: registry needs rebuild\n");
|
|
|
|
gst_plugin_load_all ();
|
2000-08-28 20:20:55 +00:00
|
|
|
return;
|
|
|
|
}
|
2000-12-15 01:57:34 +00:00
|
|
|
gst_plugin_load_thyself (doc->root);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
static gboolean
|
|
|
|
gst_plugin_load_recurse (gchar *directory, gchar *name)
|
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
DIR *dir;
|
|
|
|
struct dirent *dirent;
|
|
|
|
gboolean loaded = FALSE;
|
|
|
|
|
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,"..")) {
|
2000-03-20 20:25:03 +00:00
|
|
|
loaded = gst_plugin_load_recurse(g_strjoin("/",directory,dirent->d_name,
|
2000-01-30 09:03:00 +00:00
|
|
|
NULL),name);
|
2000-12-15 01:57:34 +00:00
|
|
|
if (loaded && name) return TRUE;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir(dir);
|
|
|
|
} else {
|
|
|
|
if (strstr(directory,".so")) {
|
|
|
|
gchar *temp;
|
|
|
|
if (name) {
|
|
|
|
if ((temp = strstr(directory,name)) &&
|
|
|
|
(!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.
|
|
|
|
*/
|
2000-12-15 01:57:34 +00:00
|
|
|
void
|
|
|
|
gst_plugin_load_all(void)
|
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GList *path;
|
|
|
|
|
|
|
|
path = _gst_plugin_paths;
|
|
|
|
while (path != NULL) {
|
|
|
|
gst_plugin_load_recurse(path->data,NULL);
|
|
|
|
path = g_list_next(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
*/
|
2000-12-15 01:57:34 +00:00
|
|
|
gboolean
|
|
|
|
gst_library_load (gchar *name)
|
|
|
|
{
|
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);
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
_gst_libraries = g_list_prepend(_gst_libraries, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
2000-03-20 20:25:03 +00:00
|
|
|
}
|
2000-03-21 19:54:30 +00:00
|
|
|
|
2000-12-11 00:04:25 +00:00
|
|
|
static void
|
2000-12-15 01:57:34 +00:00
|
|
|
gst_plugin_remove (GstPlugin *plugin)
|
2000-12-11 00:04:25 +00:00
|
|
|
{
|
|
|
|
GList *factories;
|
|
|
|
|
|
|
|
factories = plugin->elements;
|
|
|
|
while (factories) {
|
2000-12-19 13:41:55 +00:00
|
|
|
gst_elementfactory_destroy ((GstElementFactory*)(factories->data));
|
2000-12-11 00:04:25 +00:00
|
|
|
factories = g_list_next(factories);
|
|
|
|
}
|
|
|
|
_gst_plugins = g_list_remove(_gst_plugins, plugin);
|
|
|
|
g_free (plugin);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
*/
|
2000-12-15 01:57:34 +00:00
|
|
|
gboolean
|
|
|
|
gst_plugin_load (gchar *name)
|
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GList *path;
|
|
|
|
gchar *libspath;
|
2000-12-15 01:57:34 +00:00
|
|
|
GstPlugin *plugin;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-08-28 20:20:55 +00:00
|
|
|
//g_print("attempting to load plugin '%s'\n",name);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
plugin = gst_plugin_find (name);
|
|
|
|
|
|
|
|
if (plugin && plugin->loaded) return TRUE;
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
path = _gst_plugin_paths;
|
|
|
|
while (path != NULL) {
|
|
|
|
if (gst_plugin_load_absolute(g_module_build_path(path->data,name)))
|
|
|
|
return TRUE;
|
|
|
|
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));
|
2000-01-30 09:03:00 +00:00
|
|
|
if (gst_plugin_load_absolute(g_module_build_path(libspath,name))) {
|
|
|
|
g_free(libspath);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
g_free(libspath);
|
2000-03-20 20:25:03 +00:00
|
|
|
//g_print("trying to load '%s' from '%s'\n",name,path->data);
|
|
|
|
if (gst_plugin_load_recurse(path->data,g_module_build_path("",name))) {
|
2000-01-30 09:03:00 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
path = g_list_next(path);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_plugin_load_absolute:
|
|
|
|
* @name: name of plugin to load
|
|
|
|
*
|
|
|
|
* Returns: whether or not the plugin loaded
|
|
|
|
*/
|
2000-12-15 01:57:34 +00:00
|
|
|
gboolean
|
|
|
|
gst_plugin_load_absolute (gchar *name)
|
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GModule *module;
|
|
|
|
GstPluginInitFunc initfunc;
|
|
|
|
GstPlugin *plugin;
|
2000-12-04 09:32:43 +00:00
|
|
|
struct stat file_status;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
if (g_module_supported() == FALSE) {
|
2000-08-28 20:20:55 +00:00
|
|
|
g_print("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
|
|
|
}
|
|
|
|
|
2000-12-04 09:32:43 +00:00
|
|
|
if (stat(name,&file_status)) {
|
|
|
|
// g_print("problem opening file %s\n",name);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-03-20 20:25:03 +00:00
|
|
|
module = g_module_open(name,G_MODULE_BIND_LAZY);
|
2000-01-30 09:03:00 +00:00
|
|
|
if (module != NULL) {
|
|
|
|
if (g_module_symbol(module,"plugin_init",(gpointer *)&initfunc)) {
|
2000-02-27 23:18:38 +00:00
|
|
|
if ((plugin = (initfunc)(module))) {
|
2000-08-28 20:20:55 +00:00
|
|
|
g_print("gstplugin: plugin %s loaded\n", plugin->name);
|
2000-01-30 09:03:00 +00:00
|
|
|
plugin->filename = g_strdup(name);
|
2000-08-28 20:20:55 +00:00
|
|
|
plugin->loaded = TRUE;
|
2000-12-15 01:57:34 +00:00
|
|
|
_gst_modules = g_list_prepend(_gst_modules,module);
|
2000-01-30 09:03:00 +00:00
|
|
|
_gst_modules_seqno++;
|
2000-12-11 00:04:25 +00:00
|
|
|
_gst_plugins = g_list_prepend(_gst_plugins,plugin);
|
2000-01-30 09:03:00 +00:00
|
|
|
_gst_plugins_seqno++;
|
|
|
|
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) {
|
2000-12-15 01:57:34 +00:00
|
|
|
gst_info("error loading plugin: %s, reason: %s\n", name, g_module_error());
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_plugin_new:
|
|
|
|
* @name: name of new plugin
|
|
|
|
*
|
|
|
|
* Create a new plugin with given name.
|
|
|
|
*
|
|
|
|
* Returns: new plugin
|
|
|
|
*/
|
2000-12-15 01:57:34 +00:00
|
|
|
GstPlugin*
|
|
|
|
gst_plugin_new (gchar *name)
|
|
|
|
{
|
|
|
|
GstPlugin *plugin;
|
|
|
|
|
|
|
|
// return NULL if the plugin is allready loaded
|
|
|
|
plugin = gst_plugin_find (name);
|
|
|
|
if (plugin) return NULL;
|
|
|
|
|
|
|
|
plugin = (GstPlugin *)g_malloc(sizeof(GstPlugin));
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
plugin->name = g_strdup(name);
|
|
|
|
plugin->longname = NULL;
|
|
|
|
plugin->types = NULL;
|
|
|
|
plugin->elements = NULL;
|
2000-12-11 00:04:25 +00:00
|
|
|
plugin->loaded = TRUE;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
return plugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2000-12-15 01:57:34 +00:00
|
|
|
void
|
|
|
|
gst_plugin_set_longname (GstPlugin *plugin, gchar *longname)
|
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
g_return_if_fail(plugin != NULL);
|
|
|
|
|
|
|
|
if (plugin->longname) g_free(plugin->longname);
|
|
|
|
plugin->longname = g_strdup(longname);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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*
|
|
|
|
gst_plugin_find (const gchar *name)
|
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GList *plugins = _gst_plugins;
|
|
|
|
|
2000-02-27 23:18:38 +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;
|
|
|
|
// g_print("plugin name is '%s'\n",plugin->name);
|
|
|
|
if (plugin->name) {
|
2000-08-28 20:20:55 +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
|
|
|
}
|
|
|
|
plugins = g_list_next(plugins);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_plugin_find_elementfactory:
|
|
|
|
* @name: name of elementfactory to find
|
|
|
|
*
|
|
|
|
* Find a registered elementfactory by name.
|
|
|
|
*
|
|
|
|
* Returns: @GstElementFactory if found, NULL if not
|
|
|
|
*/
|
2000-12-15 01:57:34 +00:00
|
|
|
GstElementFactory*
|
|
|
|
gst_plugin_find_elementfactory (gchar *name)
|
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
GList *plugins, *factories;
|
|
|
|
GstElementFactory *factory;
|
|
|
|
|
2000-02-27 23:18:38 +00:00
|
|
|
g_return_val_if_fail(name != NULL, NULL);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
plugins = _gst_plugins;
|
|
|
|
while (plugins) {
|
|
|
|
factories = ((GstPlugin *)(plugins->data))->elements;
|
|
|
|
while (factories) {
|
|
|
|
factory = (GstElementFactory*)(factories->data);
|
2000-12-11 00:04:25 +00:00
|
|
|
if (!strcmp(factory->name, name))
|
2000-01-30 09:03:00 +00:00
|
|
|
return (GstElementFactory*)(factory);
|
|
|
|
factories = g_list_next(factories);
|
|
|
|
}
|
|
|
|
plugins = g_list_next(plugins);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2000-10-25 19:09:53 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_load_elementfactory:
|
|
|
|
* @name: name of elementfactory to load
|
|
|
|
*
|
|
|
|
* Load a registered elementfactory by name.
|
|
|
|
*
|
|
|
|
* Returns: @GstElementFactory if loaded, NULL if not
|
|
|
|
*/
|
2000-12-15 01:57:34 +00:00
|
|
|
GstElementFactory*
|
|
|
|
gst_plugin_load_elementfactory (gchar *name)
|
|
|
|
{
|
2000-08-28 20:20:55 +00:00
|
|
|
GList *plugins, *factories;
|
|
|
|
GstElementFactory *factory = NULL;
|
|
|
|
GstPlugin *plugin;
|
|
|
|
|
|
|
|
g_return_val_if_fail(name != NULL, NULL);
|
|
|
|
|
|
|
|
plugins = _gst_plugins;
|
|
|
|
while (plugins) {
|
|
|
|
plugin = (GstPlugin *)plugins->data;
|
|
|
|
factories = plugin->elements;
|
|
|
|
while (factories) {
|
|
|
|
factory = (GstElementFactory*)(factories->data);
|
|
|
|
if (!strcmp(factory->name,name)) {
|
|
|
|
if (!plugin->loaded) {
|
2000-12-11 00:04:25 +00:00
|
|
|
gchar *filename = g_strdup (plugin->filename);
|
2000-08-28 20:20:55 +00:00
|
|
|
g_print("gstplugin: loading element factory %s from plugin %s\n", name, plugin->name);
|
2000-12-11 00:04:25 +00:00
|
|
|
gst_plugin_remove(plugin);
|
|
|
|
if (!gst_plugin_load_absolute(filename)) {
|
2000-08-28 20:20:55 +00:00
|
|
|
g_print("gstplugin: error loading element factory %s from plugin %s\n", name, plugin->name);
|
|
|
|
}
|
2000-12-11 00:04:25 +00:00
|
|
|
g_free (filename);
|
|
|
|
factory = gst_plugin_find_elementfactory(name);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
return factory;
|
|
|
|
}
|
|
|
|
factories = g_list_next(factories);
|
|
|
|
}
|
|
|
|
plugins = g_list_next(plugins);
|
|
|
|
}
|
|
|
|
|
|
|
|
return factory;
|
|
|
|
}
|
|
|
|
|
2000-10-25 19:09:53 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_load_typefactory:
|
|
|
|
* @mime: name of typefactory to load
|
|
|
|
*
|
|
|
|
* Load a registered typefactory by mime type.
|
|
|
|
*/
|
2000-12-15 01:57:34 +00:00
|
|
|
void
|
|
|
|
gst_plugin_load_typefactory (gchar *mime)
|
|
|
|
{
|
2000-08-28 20:20:55 +00:00
|
|
|
GList *plugins, *factories;
|
|
|
|
GstTypeFactory *factory;
|
|
|
|
GstPlugin *plugin;
|
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
g_return_if_fail (mime != NULL);
|
2000-08-28 20:20:55 +00:00
|
|
|
|
|
|
|
plugins = _gst_plugins;
|
|
|
|
while (plugins) {
|
|
|
|
plugin = (GstPlugin *)plugins->data;
|
|
|
|
factories = plugin->types;
|
|
|
|
while (factories) {
|
|
|
|
factory = (GstTypeFactory*)(factories->data);
|
|
|
|
if (!strcmp(factory->mime,mime)) {
|
|
|
|
if (!plugin->loaded) {
|
2000-12-11 00:04:25 +00:00
|
|
|
gchar *filename = g_strdup (plugin->filename);
|
2000-08-28 20:20:55 +00:00
|
|
|
g_print("gstplugin: loading type factory for \"%s\" from plugin %s\n", mime, plugin->name);
|
2000-12-11 00:04:25 +00:00
|
|
|
gst_plugin_remove(plugin);
|
|
|
|
if (!gst_plugin_load_absolute(filename)) {
|
2000-08-28 20:20:55 +00:00
|
|
|
g_print("gstplugin: error loading type factory \"%s\" from plugin %s\n", mime, plugin->name);
|
|
|
|
}
|
2000-12-11 00:04:25 +00:00
|
|
|
g_free (filename);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
factories = g_list_next(factories);
|
|
|
|
}
|
|
|
|
plugins = g_list_next(plugins);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_add_factory:
|
|
|
|
* @plugin: plugin to add factory to
|
|
|
|
* @factory: factory to add
|
|
|
|
*
|
2000-10-25 19:09:53 +00:00
|
|
|
* Add factory to the list of those provided by the plugin.
|
2000-01-30 09:03:00 +00:00
|
|
|
*/
|
2000-12-15 01:57:34 +00:00
|
|
|
void
|
|
|
|
gst_plugin_add_factory (GstPlugin *plugin, GstElementFactory *factory)
|
|
|
|
{
|
|
|
|
g_return_if_fail (plugin != NULL);
|
|
|
|
g_return_if_fail (factory != NULL);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
// g_print("adding factory to plugin\n");
|
2000-12-15 01:57:34 +00:00
|
|
|
plugin->elements = g_list_prepend (plugin->elements, factory);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2000-10-25 19:09:53 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_add_type:
|
|
|
|
* @plugin: plugin to add type to
|
|
|
|
* @factory: the typefactory to add
|
|
|
|
*
|
|
|
|
* Add a typefactory to the list of those provided by the plugin.
|
|
|
|
*/
|
2000-12-15 01:57:34 +00:00
|
|
|
void
|
|
|
|
gst_plugin_add_type (GstPlugin *plugin, GstTypeFactory *factory)
|
|
|
|
{
|
|
|
|
g_return_if_fail (plugin != NULL);
|
|
|
|
g_return_if_fail (factory != NULL);
|
2000-08-28 20:20:55 +00:00
|
|
|
|
|
|
|
// g_print("adding factory to plugin\n");
|
2000-12-15 01:57:34 +00:00
|
|
|
plugin->types = g_list_prepend (plugin->types, factory);
|
2000-12-15 16:43:26 +00:00
|
|
|
gst_type_register (factory);
|
2000-08-28 20:20:55 +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*
|
|
|
|
gst_plugin_get_list(void)
|
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
return _gst_plugins;
|
|
|
|
}
|
2000-08-28 20:20:55 +00:00
|
|
|
|
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
|
|
|
|
*/
|
2000-12-15 01:57:34 +00:00
|
|
|
xmlNodePtr
|
|
|
|
gst_plugin_save_thyself (xmlNodePtr parent)
|
|
|
|
{
|
2000-08-28 20:20:55 +00:00
|
|
|
xmlNodePtr tree, subtree;
|
|
|
|
GList *plugins = NULL, *elements = NULL, *types = NULL;
|
|
|
|
|
|
|
|
plugins = gst_plugin_get_list();
|
|
|
|
while (plugins) {
|
|
|
|
GstPlugin *plugin = (GstPlugin *)plugins->data;
|
|
|
|
tree = xmlNewChild(parent,NULL,"plugin",NULL);
|
|
|
|
xmlNewChild(tree,NULL,"name",plugin->name);
|
|
|
|
xmlNewChild(tree,NULL,"longname",plugin->longname);
|
|
|
|
xmlNewChild(tree,NULL,"filename",plugin->filename);
|
|
|
|
types = plugin->types;
|
|
|
|
while (types) {
|
|
|
|
GstTypeFactory *factory = (GstTypeFactory *)types->data;
|
|
|
|
subtree = xmlNewChild(tree,NULL,"type",NULL);
|
|
|
|
|
|
|
|
gst_typefactory_save_thyself(factory, subtree);
|
|
|
|
|
|
|
|
types = g_list_next(types);
|
|
|
|
}
|
|
|
|
elements = plugin->elements;
|
|
|
|
while (elements) {
|
|
|
|
GstElementFactory *factory = (GstElementFactory *)elements->data;
|
|
|
|
subtree = xmlNewChild(tree,NULL,"element",NULL);
|
|
|
|
|
|
|
|
gst_elementfactory_save_thyself(factory, subtree);
|
|
|
|
|
|
|
|
elements = g_list_next(elements);
|
|
|
|
}
|
|
|
|
plugins = g_list_next(plugins);
|
|
|
|
}
|
|
|
|
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
|
|
|
|
*/
|
2000-12-15 01:57:34 +00:00
|
|
|
void
|
|
|
|
gst_plugin_load_thyself (xmlNodePtr parent)
|
|
|
|
{
|
2000-08-28 20:20:55 +00:00
|
|
|
xmlNodePtr kinderen;
|
|
|
|
gint elementcount = 0;
|
|
|
|
gint typecount = 0;
|
|
|
|
|
|
|
|
kinderen = parent->childs; // Dutch invasion :-)
|
|
|
|
while (kinderen) {
|
|
|
|
if (!strcmp(kinderen->name, "plugin")) {
|
|
|
|
xmlNodePtr field = kinderen->childs;
|
2000-12-11 00:04:25 +00:00
|
|
|
GstPlugin *plugin = g_new0 (GstPlugin, 1);
|
2000-08-28 20:20:55 +00:00
|
|
|
plugin->elements = NULL;
|
|
|
|
plugin->types = NULL;
|
|
|
|
plugin->loaded = FALSE;
|
|
|
|
|
|
|
|
while (field) {
|
|
|
|
if (!strcmp(field->name, "name")) {
|
|
|
|
if (gst_plugin_find(xmlNodeGetContent(field))) {
|
|
|
|
g_free(plugin);
|
|
|
|
plugin = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
plugin->name = g_strdup(xmlNodeGetContent(field));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(field->name, "longname")) {
|
|
|
|
plugin->longname = g_strdup(xmlNodeGetContent(field));
|
|
|
|
}
|
|
|
|
else if (!strcmp(field->name, "filename")) {
|
|
|
|
plugin->filename = g_strdup(xmlNodeGetContent(field));
|
|
|
|
}
|
|
|
|
else if (!strcmp(field->name, "element")) {
|
|
|
|
GstElementFactory *factory = gst_elementfactory_load_thyself(field);
|
2000-12-11 00:04:25 +00:00
|
|
|
gst_plugin_add_factory (plugin, factory);
|
2000-08-28 20:20:55 +00:00
|
|
|
elementcount++;
|
|
|
|
}
|
|
|
|
else if (!strcmp(field->name, "type")) {
|
|
|
|
GstTypeFactory *factory = gst_typefactory_load_thyself(field);
|
2000-12-11 00:04:25 +00:00
|
|
|
gst_plugin_add_type (plugin, factory);
|
|
|
|
elementcount++;
|
2000-08-28 20:20:55 +00:00
|
|
|
typecount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
field = field->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (plugin) {
|
|
|
|
_gst_plugins = g_list_prepend(_gst_plugins, plugin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
kinderen = kinderen->next;
|
|
|
|
}
|
|
|
|
g_print("gstplugin: added %d registered factories and %d types\n", elementcount, typecount);
|
|
|
|
}
|
|
|
|
|