2001-01-07 04:51:31 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
2002-02-04 20:33:14 +00:00
|
|
|
* gst-register.c: Plugin subsystem for loading elements, types, and libs
|
2001-01-07 04:51:31 +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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2000-08-28 20:20:55 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2001-01-07 16:14:35 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2001-01-07 04:51:31 +00:00
|
|
|
#include <fcntl.h>
|
2004-05-10 18:07:24 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2001-01-07 04:51:31 +00:00
|
|
|
#include <unistd.h>
|
2004-05-10 18:07:24 +00:00
|
|
|
#endif
|
2001-01-07 04:51:31 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
2003-08-19 08:11:58 +00:00
|
|
|
#include <locale.h>
|
2001-01-07 04:51:31 +00:00
|
|
|
|
2004-06-26 13:09:37 +00:00
|
|
|
#include "gst/gst-i18n-app.h"
|
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
static gint num_features = 0;
|
|
|
|
static gint num_plugins = 0;
|
2001-01-17 01:59:57 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
plugin_added_func (GstRegistry * registry, GstPlugin * plugin,
|
|
|
|
gpointer user_data)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
2004-06-26 13:09:37 +00:00
|
|
|
g_print (_("Added plugin %s with %d %s.\n"), plugin->desc.name,
|
|
|
|
plugin->numfeatures,
|
|
|
|
ngettext ("feature", "features", plugin->numfeatures));
|
2001-01-17 01:59:57 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
num_features += plugin->numfeatures;
|
|
|
|
num_plugins++;
|
2001-01-07 04:51:31 +00:00
|
|
|
}
|
|
|
|
|
2003-08-19 07:58:53 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
spawn_all_in_dir (const char *dirname)
|
2003-08-19 07:58:53 +00:00
|
|
|
{
|
|
|
|
char *argv[2] = { NULL, NULL };
|
|
|
|
GDir *dir;
|
|
|
|
const char *file;
|
|
|
|
|
|
|
|
/* g_print("spawning all in %s\n", dirname); */
|
|
|
|
|
|
|
|
dir = g_dir_open (dirname, 0, NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
if (dir == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
while ((file = g_dir_read_name (dir))) {
|
|
|
|
argv[0] = g_build_filename (dirname, file, NULL);
|
|
|
|
g_print ("running %s\n", argv[0]);
|
|
|
|
g_spawn_sync (NULL, argv, NULL, G_SPAWN_FILE_AND_ARGV_ZERO, NULL, NULL,
|
2004-03-15 19:27:17 +00:00
|
|
|
NULL, NULL, NULL, NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
g_free (argv[0]);
|
2003-08-19 07:58:53 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
g_dir_close (dir);
|
2003-08-19 07:58:53 +00:00
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
GList *registries;
|
2004-03-15 19:27:17 +00:00
|
|
|
GList *path_spill = NULL; /* used for path spill from failing registries */
|
2001-01-07 04:51:31 +00:00
|
|
|
|
2004-06-26 13:09:37 +00:00
|
|
|
#ifdef GETTEXT_PACKAGE
|
|
|
|
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
|
|
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
|
|
|
textdomain (GETTEXT_PACKAGE);
|
|
|
|
#endif
|
2003-08-19 08:11:58 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
/* Init gst */
|
2002-05-08 20:40:48 +00:00
|
|
|
_gst_registry_auto_load = FALSE;
|
|
|
|
gst_init (&argc, &argv);
|
2001-01-07 16:14:35 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
registries = gst_registry_pool_list ();
|
|
|
|
registries = g_list_reverse (registries);
|
2001-12-14 20:56:51 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
while (registries) {
|
|
|
|
GstRegistry *registry = GST_REGISTRY (registries->data);
|
2003-08-19 23:49:49 +00:00
|
|
|
GList *dir_list;
|
|
|
|
GList *iter;
|
|
|
|
char *dir;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (path_spill) {
|
2002-08-11 21:51:56 +00:00
|
|
|
GList *iter;
|
|
|
|
|
|
|
|
/* add spilled paths to this registry;
|
|
|
|
* since they're spilled they probably weren't loaded correctly
|
|
|
|
* so we should give a lower priority registry the chance to do them */
|
2004-03-13 15:27:01 +00:00
|
|
|
for (iter = path_spill; iter; iter = iter->next) {
|
2004-06-26 13:09:37 +00:00
|
|
|
g_print (_("Added path %s to %s \n"),
|
2004-03-15 19:27:17 +00:00
|
|
|
(const char *) iter->data, registry->name);
|
|
|
|
gst_registry_add_path (registry, (const gchar *) iter->data);
|
2002-08-11 21:51:56 +00:00
|
|
|
}
|
|
|
|
g_list_free (path_spill);
|
|
|
|
path_spill = NULL;
|
|
|
|
}
|
2001-01-07 16:14:35 +00:00
|
|
|
|
2002-12-08 14:39:38 +00:00
|
|
|
g_signal_connect (G_OBJECT (registry), "plugin_added",
|
2004-03-15 19:27:17 +00:00
|
|
|
G_CALLBACK (plugin_added_func), NULL);
|
2001-01-17 01:59:57 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
if (registry->flags & GST_REGISTRY_WRITABLE) {
|
2003-04-23 19:59:38 +00:00
|
|
|
char *location;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-04-23 19:59:38 +00:00
|
|
|
g_object_get (registry, "location", &location, NULL);
|
2004-06-26 13:09:37 +00:00
|
|
|
g_print (_("Rebuilding %s (%s) ...\n"), registry->name, location);
|
2003-04-23 19:59:38 +00:00
|
|
|
g_free (location);
|
2002-05-08 20:40:48 +00:00
|
|
|
gst_registry_rebuild (registry);
|
|
|
|
gst_registry_save (registry);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else {
|
2004-06-26 13:09:37 +00:00
|
|
|
g_print (_("Trying to load %s ...\n"), registry->name);
|
2004-03-13 15:27:01 +00:00
|
|
|
if (!gst_registry_load (registry)) {
|
2004-06-26 13:09:37 +00:00
|
|
|
g_print (_("Error loading %s\n"), registry->name);
|
2004-03-15 19:27:17 +00:00
|
|
|
/* move over paths from this registry to the next one */
|
|
|
|
path_spill = g_list_concat (path_spill,
|
|
|
|
gst_registry_get_path_list (registry));
|
2004-07-25 15:01:52 +00:00
|
|
|
/* this assertion triggers for a non-readable/writable user registry,
|
|
|
|
* see #148283 */
|
|
|
|
/* g_assert (path_spill != NULL); */
|
2002-08-11 21:51:56 +00:00
|
|
|
}
|
2004-03-01 17:15:28 +00:00
|
|
|
/* also move over paths if the registry wasn't writable
|
|
|
|
* FIXME: we should check if the paths that were loaded from this
|
2004-03-13 15:27:01 +00:00
|
|
|
registry get removed from the path_list so we only try to
|
|
|
|
spill paths that could not be registered */
|
2004-03-14 16:40:24 +00:00
|
|
|
/* Until that is done, don't spill paths when registry is not writable
|
|
|
|
(e.g. case of user running gst-register and sysreg not writable) */
|
2004-03-14 16:44:04 +00:00
|
|
|
|
2004-03-14 16:40:24 +00:00
|
|
|
/*
|
|
|
|
path_spill = g_list_concat (path_spill,
|
|
|
|
gst_registry_get_path_list (registry));
|
|
|
|
*/
|
2001-01-17 01:59:57 +00:00
|
|
|
}
|
2003-08-19 07:58:53 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
dir_list = gst_registry_get_path_list (registry);
|
|
|
|
for (iter = dir_list; iter; iter = iter->next) {
|
|
|
|
dir =
|
2004-03-15 19:27:17 +00:00
|
|
|
g_build_filename ((const char *) iter->data, "register-scripts",
|
|
|
|
NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
spawn_all_in_dir (dir);
|
|
|
|
g_free (dir);
|
2003-08-19 07:58:53 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
g_list_free (dir_list);
|
2003-08-19 07:58:53 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
registries = g_list_next (registries);
|
|
|
|
}
|
2000-08-28 20:20:55 +00:00
|
|
|
|
2004-06-26 13:09:37 +00:00
|
|
|
g_print (_("Loaded %d plugins with %d %s.\n"), num_plugins, num_features,
|
|
|
|
ngettext ("feature", "features", num_features));
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2002-09-12 19:26:12 +00:00
|
|
|
return (0);
|
2000-08-28 20:20:55 +00:00
|
|
|
}
|