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
|
|
|
|
|
|
|
|
|
|
|
/* 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;
|
2000-12-31 22:18:05 +00:00
|
|
|
gint _gst_plugin_elementfactories = 0;
|
|
|
|
gint _gst_plugin_types = 0;
|
2000-01-30 09:03:00 +00:00
|
|
|
/* 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
|
|
|
|
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-01-07 07:01:37 +00:00
|
|
|
static gboolean plugin_times_older_than(time_t regtime);
|
|
|
|
static time_t get_time(const char * path);
|
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
|
|
|
{
|
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
|
|
|
|
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 */
|
|
|
|
#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");
|
2001-03-07 21:52:56 +00:00
|
|
|
_gst_plugin_paths = g_list_prepend (_gst_plugin_paths,
|
|
|
|
PLUGINS_SRCDIR "/gst/autoplug");
|
2001-02-23 01:57:43 +00:00
|
|
|
#endif /* PLUGINS_USE_SRCDIR */
|
|
|
|
|
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-03-02 16:50:46 +00:00
|
|
|
g_warning ("gstplugin: registry needs rebuild: run gstreamer-register\n");
|
2000-12-15 01:57:34 +00:00
|
|
|
gst_plugin_load_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);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
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-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-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
|
|
|
|
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-01-01 03:14:40 +00:00
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING,"loaded %d plugins with %d elements and %d types",
|
2000-12-31 22:18:05 +00:00
|
|
|
_gst_plugins_seqno,_gst_plugin_elementfactories,_gst_plugin_types);
|
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
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
static void
|
|
|
|
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);
|
|
|
|
}
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2000-12-11 00:04:25 +00:00
|
|
|
_gst_plugins = g_list_remove(_gst_plugins, plugin);
|
2000-12-30 19:04:51 +00:00
|
|
|
|
|
|
|
// don't free the stuct because someone can have a handle to it
|
2000-12-11 00:04:25 +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;
|
2000-12-15 01:57:34 +00:00
|
|
|
GstPlugin *plugin;
|
2001-01-07 07:45:54 +00:00
|
|
|
gchar *pluginname;
|
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) {
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_plugin_load_absolute:
|
|
|
|
* @name: name of plugin to load
|
|
|
|
*
|
|
|
|
* Returns: whether or not the plugin loaded
|
|
|
|
*/
|
2001-01-29 00:06:02 +00:00
|
|
|
gboolean
|
|
|
|
gst_plugin_load_absolute (const gchar *name)
|
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-01-30 09:03:00 +00:00
|
|
|
GstPlugin *plugin;
|
2000-12-04 09:32:43 +00:00
|
|
|
struct stat file_status;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-05-25 21:39:54 +00:00
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING,"plugin \"%s\" loading", name);
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2000-12-04 09:32:43 +00:00
|
|
|
if (stat(name,&file_status)) {
|
2001-05-25 21:42:14 +00:00
|
|
|
//g_print("problem opening file %s\n",name);
|
2000-12-04 09:32:43 +00:00
|
|
|
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) {
|
2001-04-22 12:30:14 +00:00
|
|
|
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) {
|
2001-05-05 02:16:28 +00:00
|
|
|
plugin->filename = g_strdup(name);
|
2001-04-22 12:30:14 +00:00
|
|
|
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) {
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING,"plugin \"%s\" loaded: %d elements, %d types",
|
2000-12-31 22:18:05 +00:00
|
|
|
plugin->name,plugin->numelements,plugin->numtypes);
|
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++;
|
2000-12-31 22:18:05 +00:00
|
|
|
_gst_plugin_elementfactories += plugin->numelements;
|
|
|
|
_gst_plugin_types += plugin->numtypes;
|
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!!!
|
|
|
|
g_printerr ("error loading plugin %s, reason: %s\n", name, g_module_error());
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2001-05-25 21:39:54 +00:00
|
|
|
else {
|
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING, "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
|
2001-04-22 12:30:14 +00:00
|
|
|
* @major: major version number of core that plugin is compatible with
|
|
|
|
* @minor: minor version number of core that plugin is compatible with
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
|
|
|
* Create a new plugin with given name.
|
|
|
|
*
|
2001-04-22 12:30:14 +00:00
|
|
|
* Returns: new plugin, or NULL if plugin couldn't be created, due to
|
|
|
|
* incompatible version number, or name already being allocated)
|
2000-01-30 09:03:00 +00:00
|
|
|
*/
|
2000-12-15 01:57:34 +00:00
|
|
|
GstPlugin*
|
2001-04-22 12:30:14 +00:00
|
|
|
gst_plugin_new (const gchar *name, gint major, gint minor)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
|
|
|
GstPlugin *plugin;
|
|
|
|
|
2001-04-22 12:30:14 +00:00
|
|
|
// 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;
|
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
// 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->elements = NULL;
|
2000-12-31 22:18:05 +00:00
|
|
|
plugin->numelements = 0;
|
|
|
|
plugin->types = NULL;
|
|
|
|
plugin->numtypes = 0;
|
2001-03-07 21:52:56 +00:00
|
|
|
plugin->autopluggers = NULL;
|
|
|
|
plugin->numautopluggers = 0;
|
2000-12-11 00:04:25 +00:00
|
|
|
plugin->loaded = TRUE;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
return plugin;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
return plugin->loaded;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
static GstElementFactory*
|
2001-01-29 00:06:02 +00:00
|
|
|
gst_plugin_find_elementfactory (const gchar *name)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
/**
|
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*
|
2001-01-29 00:06:02 +00:00
|
|
|
gst_plugin_load_elementfactory (const gchar *name)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
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;
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2000-08-28 20:20:55 +00:00
|
|
|
while (factories) {
|
|
|
|
factory = (GstElementFactory*)(factories->data);
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2000-08-28 20:20:55 +00:00
|
|
|
if (!strcmp(factory->name,name)) {
|
|
|
|
if (!plugin->loaded) {
|
2000-12-11 00:04:25 +00:00
|
|
|
gchar *filename = g_strdup (plugin->filename);
|
2000-12-29 18:23:41 +00:00
|
|
|
gchar *pluginname = g_strdup (plugin->name);
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING,"loaded elementfactory %s from plugin %s",name,plugin->name);
|
2000-12-11 00:04:25 +00:00
|
|
|
gst_plugin_remove(plugin);
|
|
|
|
if (!gst_plugin_load_absolute(filename)) {
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"gstplugin: error loading element factory %s from plugin %s\n", name, pluginname);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
2000-12-29 18:23:41 +00:00
|
|
|
g_free (pluginname);
|
2000-12-11 00:04:25 +00:00
|
|
|
g_free (filename);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
2000-12-28 00:18:26 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
static GstAutoplugFactory*
|
|
|
|
gst_plugin_find_autoplugfactory (const gchar *name)
|
|
|
|
{
|
|
|
|
GList *plugins, *factories;
|
|
|
|
GstAutoplugFactory *factory;
|
|
|
|
|
|
|
|
g_return_val_if_fail(name != NULL, NULL);
|
|
|
|
|
|
|
|
plugins = _gst_plugins;
|
|
|
|
while (plugins) {
|
|
|
|
factories = ((GstPlugin *)(plugins->data))->autopluggers;
|
|
|
|
while (factories) {
|
|
|
|
factory = (GstAutoplugFactory*)(factories->data);
|
|
|
|
if (!strcmp(factory->name, name))
|
|
|
|
return (GstAutoplugFactory*)(factory);
|
|
|
|
factories = g_list_next(factories);
|
|
|
|
}
|
|
|
|
plugins = g_list_next(plugins);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* gst_plugin_load_autoplugfactory:
|
|
|
|
* @name: name of autoplugfactory to load
|
|
|
|
*
|
|
|
|
* Load a registered autoplugfactory by name.
|
|
|
|
*
|
|
|
|
* Returns: @GstAutoplugFactory if loaded, NULL if not
|
|
|
|
*/
|
|
|
|
GstAutoplugFactory*
|
|
|
|
gst_plugin_load_autoplugfactory (const gchar *name)
|
|
|
|
{
|
|
|
|
GList *plugins, *factories;
|
|
|
|
GstAutoplugFactory *factory = NULL;
|
|
|
|
GstPlugin *plugin;
|
|
|
|
|
|
|
|
g_return_val_if_fail(name != NULL, NULL);
|
|
|
|
|
|
|
|
plugins = _gst_plugins;
|
|
|
|
while (plugins) {
|
|
|
|
plugin = (GstPlugin *)plugins->data;
|
|
|
|
factories = plugin->autopluggers;
|
|
|
|
|
|
|
|
while (factories) {
|
|
|
|
factory = (GstAutoplugFactory*)(factories->data);
|
|
|
|
|
|
|
|
if (!strcmp(factory->name,name)) {
|
|
|
|
if (!plugin->loaded) {
|
|
|
|
gchar *filename = g_strdup (plugin->filename);
|
|
|
|
gchar *pluginname = g_strdup (plugin->name);
|
|
|
|
|
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING,"loaded autoplugfactory %s from plugin %s",name,plugin->name);
|
|
|
|
gst_plugin_remove(plugin);
|
|
|
|
if (!gst_plugin_load_absolute(filename)) {
|
|
|
|
GST_DEBUG (0,"gstplugin: error loading autoplug factory %s from plugin %s\n", name, pluginname);
|
|
|
|
}
|
|
|
|
g_free (pluginname);
|
|
|
|
g_free (filename);
|
|
|
|
}
|
|
|
|
factory = gst_plugin_find_autoplugfactory(name);
|
|
|
|
return factory;
|
|
|
|
}
|
|
|
|
factories = g_list_next(factories);
|
|
|
|
}
|
|
|
|
plugins = g_list_next(plugins);
|
|
|
|
}
|
|
|
|
|
|
|
|
return factory;
|
|
|
|
}
|
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
/**
|
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.
|
|
|
|
*/
|
2001-01-29 00:06:02 +00:00
|
|
|
void
|
|
|
|
gst_plugin_load_typefactory (const gchar *mime)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
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
|
|
|
|
2000-12-30 19:04:51 +00:00
|
|
|
plugins = g_list_copy (_gst_plugins);
|
2000-08-28 20:20:55 +00:00
|
|
|
while (plugins) {
|
|
|
|
plugin = (GstPlugin *)plugins->data;
|
2000-12-30 19:04:51 +00:00
|
|
|
factories = g_list_copy (plugin->types);
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2000-08-28 20:20:55 +00:00
|
|
|
while (factories) {
|
|
|
|
factory = (GstTypeFactory*)(factories->data);
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2000-08-28 20:20:55 +00:00
|
|
|
if (!strcmp(factory->mime,mime)) {
|
|
|
|
if (!plugin->loaded) {
|
2000-12-11 00:04:25 +00:00
|
|
|
gchar *filename = g_strdup (plugin->filename);
|
2000-12-29 18:23:41 +00:00
|
|
|
gchar *pluginname = g_strdup (plugin->name);
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING,"loading type factory for \"%s\" from plugin %s",mime,plugin->name);
|
2000-12-31 16:12:48 +00:00
|
|
|
plugin->loaded = TRUE;
|
2000-12-11 00:04:25 +00:00
|
|
|
gst_plugin_remove(plugin);
|
|
|
|
if (!gst_plugin_load_absolute(filename)) {
|
2001-01-01 03:14:40 +00:00
|
|
|
GST_DEBUG (0,"gstplugin: error loading type factory \"%s\" from plugin %s\n", mime, pluginname);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
2000-12-11 00:04:25 +00:00
|
|
|
g_free (filename);
|
2000-12-29 18:23:41 +00:00
|
|
|
g_free (pluginname);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
2000-12-30 17:42:15 +00:00
|
|
|
//return;
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
factories = g_list_next(factories);
|
|
|
|
}
|
2000-12-30 19:04:51 +00:00
|
|
|
|
|
|
|
g_list_free (factories);
|
2000-08-28 20:20:55 +00:00
|
|
|
plugins = g_list_next(plugins);
|
|
|
|
}
|
2000-12-30 19:04:51 +00:00
|
|
|
g_list_free (plugins);
|
2000-08-28 20:20:55 +00:00
|
|
|
|
|
|
|
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
|
|
|
*/
|
2001-01-29 00:06:02 +00:00
|
|
|
void
|
|
|
|
gst_plugin_add_factory (GstPlugin *plugin, GstElementFactory *factory)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
|
|
|
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-12-31 22:18:05 +00:00
|
|
|
plugin->numelements++;
|
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.
|
|
|
|
*/
|
2001-01-29 00:06:02 +00:00
|
|
|
void
|
|
|
|
gst_plugin_add_type (GstPlugin *plugin, GstTypeFactory *factory)
|
2000-12-15 01:57:34 +00:00
|
|
|
{
|
|
|
|
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-31 22:18:05 +00:00
|
|
|
plugin->numtypes++;
|
2000-12-15 16:43:26 +00:00
|
|
|
gst_type_register (factory);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
/**
|
2001-03-21 21:43:56 +00:00
|
|
|
* gst_plugin_add_autoplugger:
|
|
|
|
* @plugin: plugin to add the autoplugger to
|
|
|
|
* @factory: the autoplugfactory to add
|
2001-03-07 21:52:56 +00:00
|
|
|
*
|
2001-03-21 21:43:56 +00:00
|
|
|
* Add an autoplugfactory to the list of those provided by the plugin.
|
2001-03-07 21:52:56 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_plugin_add_autoplugger (GstPlugin *plugin, GstAutoplugFactory *factory)
|
|
|
|
{
|
|
|
|
g_return_if_fail (plugin != NULL);
|
|
|
|
g_return_if_fail (factory != NULL);
|
|
|
|
|
|
|
|
// g_print("adding factory to plugin\n");
|
|
|
|
plugin->autopluggers = g_list_prepend (plugin->autopluggers, factory);
|
|
|
|
plugin->numautopluggers++;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
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
|
|
|
|
*/
|
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-03-07 21:52:56 +00:00
|
|
|
GList *plugins = NULL, *elements = NULL, *types = NULL, *autopluggers = NULL;
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
plugins = gst_plugin_get_list ();
|
2000-08-28 20:20:55 +00:00
|
|
|
while (plugins) {
|
|
|
|
GstPlugin *plugin = (GstPlugin *)plugins->data;
|
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);
|
|
|
|
|
2000-08-28 20:20:55 +00:00
|
|
|
types = plugin->types;
|
|
|
|
while (types) {
|
|
|
|
GstTypeFactory *factory = (GstTypeFactory *)types->data;
|
2001-03-07 21:52:56 +00:00
|
|
|
subtree = xmlNewChild(tree, NULL, "typefactory", NULL);
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
gst_typefactory_save_thyself (factory, subtree);
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
types = g_list_next (types);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
elements = plugin->elements;
|
|
|
|
while (elements) {
|
|
|
|
GstElementFactory *factory = (GstElementFactory *)elements->data;
|
2001-03-07 21:52:56 +00:00
|
|
|
subtree = xmlNewChild (tree, NULL, "elementfactory", NULL);
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
gst_elementfactory_save_thyself (factory, subtree);
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2001-03-07 21:52:56 +00:00
|
|
|
elements = g_list_next (elements);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
2001-03-07 21:52:56 +00:00
|
|
|
autopluggers = plugin->autopluggers;
|
|
|
|
while (autopluggers) {
|
|
|
|
GstAutoplugFactory *factory = (GstAutoplugFactory *)autopluggers->data;
|
|
|
|
subtree = xmlNewChild (tree, NULL, "autoplugfactory", NULL);
|
|
|
|
|
|
|
|
gst_autoplugfactory_save_thyself (factory, subtree);
|
|
|
|
|
|
|
|
autopluggers = g_list_next (autopluggers);
|
|
|
|
}
|
|
|
|
plugins = g_list_next (plugins);
|
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;
|
2000-08-28 20:20:55 +00:00
|
|
|
gint elementcount = 0;
|
2001-03-07 21:52:56 +00:00
|
|
|
gint autoplugcount = 0;
|
2000-08-28 20:20:55 +00:00
|
|
|
gint typecount = 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
|
|
|
|
2000-08-28 20:20:55 +00:00
|
|
|
plugin->elements = NULL;
|
|
|
|
plugin->types = NULL;
|
|
|
|
plugin->loaded = FALSE;
|
|
|
|
|
|
|
|
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-03-07 21:52:56 +00:00
|
|
|
else if (!strcmp (field->name, "elementfactory")) {
|
|
|
|
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++;
|
|
|
|
}
|
2001-03-07 21:52:56 +00:00
|
|
|
else if (!strcmp (field->name, "autoplugfactory")) {
|
|
|
|
GstAutoplugFactory *factory = gst_autoplugfactory_load_thyself (field);
|
|
|
|
gst_plugin_add_autoplugger (plugin, factory);
|
|
|
|
autoplugcount++;
|
|
|
|
}
|
|
|
|
else if (!strcmp (field->name, "typefactory")) {
|
|
|
|
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) {
|
2001-03-07 21:52:56 +00:00
|
|
|
_gst_plugins = g_list_prepend (_gst_plugins, plugin);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
kinderen = kinderen->next;
|
|
|
|
}
|
2001-03-07 21:52:56 +00:00
|
|
|
GST_INFO (GST_CAT_PLUGIN_LOADING, "added %d registered factories, %d autopluggers and %d types",
|
|
|
|
elementcount, autoplugcount, typecount);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|
|
|
|
|
2001-01-04 10:54:27 +00:00
|
|
|
|
2001-01-06 02:35:17 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_get_factory_list:
|
|
|
|
* @plugin: the plugin to get the factories from
|
|
|
|
*
|
|
|
|
* get a list of all the factories that this plugin provides
|
|
|
|
*
|
|
|
|
* Returns: a GList of factories
|
|
|
|
*/
|
2001-01-04 10:54:27 +00:00
|
|
|
GList*
|
|
|
|
gst_plugin_get_factory_list (GstPlugin *plugin)
|
|
|
|
{
|
2001-01-06 02:35:17 +00:00
|
|
|
g_return_val_if_fail (plugin != NULL, NULL);
|
|
|
|
|
2001-01-04 10:54:27 +00:00
|
|
|
return plugin->elements;
|
|
|
|
}
|
|
|
|
|
2001-01-06 02:35:17 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_get_type_list:
|
|
|
|
* @plugin: the plugin to get the typefactories from
|
|
|
|
*
|
|
|
|
* get a list of all the typefactories that this plugin provides
|
|
|
|
*
|
|
|
|
* Returns: a GList of factories
|
|
|
|
*/
|
|
|
|
GList*
|
|
|
|
gst_plugin_get_type_list (GstPlugin *plugin)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (plugin != NULL, NULL);
|
|
|
|
|
|
|
|
return plugin->types;
|
|
|
|
}
|
2001-03-07 21:52:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_plugin_get_autoplug_list:
|
|
|
|
* @plugin: the plugin to get the autoplugfactories from
|
|
|
|
*
|
|
|
|
* get a list of all the autoplugfactories that this plugin provides
|
|
|
|
*
|
|
|
|
* Returns: a GList of factories
|
|
|
|
*/
|
|
|
|
GList*
|
|
|
|
gst_plugin_get_autoplug_list (GstPlugin *plugin)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (plugin != NULL, NULL);
|
|
|
|
|
|
|
|
return plugin->autopluggers;
|
|
|
|
}
|