2002-05-08 20:40:48 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
|
|
|
* gstxml_registry.c: GstXMLRegistry object, support routines
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
#include <stdio.h>
|
2002-05-08 21:16:41 +00:00
|
|
|
#include <errno.h>
|
2002-05-08 20:40:48 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <dirent.h>
|
2004-05-10 18:07:24 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#include <sys/utime.h>
|
|
|
|
#include <io.h>
|
|
|
|
#ifndef F_OK
|
|
|
|
#define F_OK 0
|
|
|
|
#define W_OK 2
|
|
|
|
#define R_OK 4
|
|
|
|
#endif
|
|
|
|
#ifndef S_ISREG
|
|
|
|
#define S_ISREG(mode) ((mode)&_S_IFREG)
|
|
|
|
#endif
|
|
|
|
#ifndef S_ISDIR
|
|
|
|
#define S_ISDIR(mode) ((mode)&_S_IFDIR)
|
|
|
|
#endif
|
|
|
|
#else /* _MSC_VER */
|
2004-04-28 23:26:06 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2002-05-08 20:40:48 +00:00
|
|
|
#include <unistd.h>
|
2004-04-28 23:26:06 +00:00
|
|
|
#endif
|
2002-05-10 18:26:14 +00:00
|
|
|
#include <utime.h>
|
2004-05-10 18:07:24 +00:00
|
|
|
#endif
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
#include <gst/gst_private.h>
|
|
|
|
#include <gst/gstelement.h>
|
2003-10-28 20:25:30 +00:00
|
|
|
#include <gst/gsttypefind.h>
|
2002-05-08 20:40:48 +00:00
|
|
|
#include <gst/gstscheduler.h>
|
2003-01-16 21:22:06 +00:00
|
|
|
#include <gst/gsturi.h>
|
2003-06-29 14:05:49 +00:00
|
|
|
#include <gst/gstinfo.h>
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
#include "gstxmlregistry.h"
|
|
|
|
|
|
|
|
#define BLOCK_SIZE 1024*10
|
|
|
|
|
|
|
|
#define CLASS(registry) GST_XML_REGISTRY_CLASS (G_OBJECT_GET_CLASS (registry))
|
|
|
|
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
enum
|
2002-05-10 18:26:14 +00:00
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_LOCATION
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void gst_xml_registry_class_init (GstXMLRegistryClass * klass);
|
|
|
|
static void gst_xml_registry_init (GstXMLRegistry * registry);
|
|
|
|
|
|
|
|
static void gst_xml_registry_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_xml_registry_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
|
|
|
|
|
|
|
static gboolean gst_xml_registry_load (GstRegistry * registry);
|
|
|
|
static gboolean gst_xml_registry_save (GstRegistry * registry);
|
|
|
|
static gboolean gst_xml_registry_rebuild (GstRegistry * registry);
|
|
|
|
|
|
|
|
static void gst_xml_registry_get_perms_func (GstXMLRegistry * registry);
|
|
|
|
static void gst_xml_registry_add_path_list_func (GstXMLRegistry * registry);
|
|
|
|
static gboolean gst_xml_registry_open_func (GstXMLRegistry * registry,
|
|
|
|
GstXMLRegistryMode mode);
|
|
|
|
static gboolean gst_xml_registry_load_func (GstXMLRegistry * registry,
|
|
|
|
gchar * data, gssize * size);
|
|
|
|
static gboolean gst_xml_registry_save_func (GstXMLRegistry * registry,
|
|
|
|
gchar * format, ...);
|
|
|
|
static gboolean gst_xml_registry_close_func (GstXMLRegistry * registry);
|
|
|
|
|
|
|
|
static GstRegistryReturn gst_xml_registry_load_plugin (GstRegistry * registry,
|
|
|
|
GstPlugin * plugin);
|
|
|
|
|
|
|
|
static void gst_xml_registry_start_element (GMarkupParseContext * context,
|
|
|
|
const gchar * element_name,
|
|
|
|
const gchar ** attribute_names,
|
|
|
|
const gchar ** attribute_values, gpointer user_data, GError ** error);
|
|
|
|
static void gst_xml_registry_end_element (GMarkupParseContext * context,
|
|
|
|
const gchar * element_name, gpointer user_data, GError ** error);
|
|
|
|
static void gst_xml_registry_text (GMarkupParseContext * context,
|
|
|
|
const gchar * text, gsize text_len, gpointer user_data, GError ** error);
|
|
|
|
static void gst_xml_registry_passthrough (GMarkupParseContext * context,
|
|
|
|
const gchar * passthrough_text,
|
|
|
|
gsize text_len, gpointer user_data, GError ** error);
|
|
|
|
static void gst_xml_registry_error (GMarkupParseContext * context,
|
|
|
|
GError * error, gpointer user_data);
|
|
|
|
|
|
|
|
|
|
|
|
static void gst_xml_registry_paths_start_element (GMarkupParseContext * context,
|
|
|
|
const gchar * element_name,
|
|
|
|
const gchar ** attribute_names,
|
|
|
|
const gchar ** attribute_values, gpointer user_data, GError ** error);
|
|
|
|
static void gst_xml_registry_paths_end_element (GMarkupParseContext * context,
|
|
|
|
const gchar * element_name, gpointer user_data, GError ** error);
|
|
|
|
static void gst_xml_registry_paths_text (GMarkupParseContext * context,
|
|
|
|
const gchar * text, gsize text_len, gpointer user_data, GError ** error);
|
2002-05-11 20:30:05 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
static GstRegistryClass *parent_class = NULL;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
/* static guint gst_xml_registry_signals[LAST_SIGNAL] = { 0 }; */
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static const GMarkupParser gst_xml_registry_parser = {
|
2002-05-08 20:40:48 +00:00
|
|
|
gst_xml_registry_start_element,
|
|
|
|
gst_xml_registry_end_element,
|
|
|
|
gst_xml_registry_text,
|
|
|
|
gst_xml_registry_passthrough,
|
|
|
|
gst_xml_registry_error,
|
|
|
|
};
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static const GMarkupParser gst_xml_registry_paths_parser = {
|
2002-05-11 20:30:05 +00:00
|
|
|
gst_xml_registry_paths_start_element,
|
|
|
|
gst_xml_registry_paths_end_element,
|
|
|
|
gst_xml_registry_paths_text,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GType
|
|
|
|
gst_xml_registry_get_type (void)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
static GType xml_registry_type = 0;
|
|
|
|
|
|
|
|
if (!xml_registry_type) {
|
|
|
|
static const GTypeInfo xml_registry_info = {
|
|
|
|
sizeof (GstXMLRegistryClass),
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) gst_xml_registry_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-13 15:27:01 +00:00
|
|
|
sizeof (GstXMLRegistry),
|
2002-05-08 20:40:48 +00:00
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) gst_xml_registry_init,
|
|
|
|
NULL
|
|
|
|
};
|
2004-03-14 17:54:22 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
xml_registry_type = g_type_register_static (GST_TYPE_REGISTRY,
|
2004-03-15 19:27:17 +00:00
|
|
|
"GstXMLRegistry", &xml_registry_info, 0);
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
return xml_registry_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_class_init (GstXMLRegistryClass * klass)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstRegistryClass *gstregistry_class;
|
|
|
|
GstXMLRegistryClass *gstxmlregistry_class;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstregistry_class = (GstRegistryClass *) klass;
|
|
|
|
gstxmlregistry_class = (GstXMLRegistryClass *) klass;
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
parent_class = g_type_class_ref (GST_TYPE_REGISTRY);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gobject_class->get_property =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_xml_registry_get_property);
|
|
|
|
gobject_class->set_property =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_xml_registry_set_property);
|
2002-05-10 18:26:14 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_LOCATION,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_string ("location", "Location",
|
2004-03-15 19:27:17 +00:00
|
|
|
"Location of the registry file", NULL, G_PARAM_READWRITE));
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
gstregistry_class->load = GST_DEBUG_FUNCPTR (gst_xml_registry_load);
|
|
|
|
gstregistry_class->save = GST_DEBUG_FUNCPTR (gst_xml_registry_save);
|
|
|
|
gstregistry_class->rebuild = GST_DEBUG_FUNCPTR (gst_xml_registry_rebuild);
|
|
|
|
|
|
|
|
gstregistry_class->load_plugin =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_xml_registry_load_plugin);
|
|
|
|
|
|
|
|
gstxmlregistry_class->get_perms_func =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_xml_registry_get_perms_func);
|
|
|
|
gstxmlregistry_class->add_path_list_func =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_xml_registry_add_path_list_func);
|
|
|
|
gstxmlregistry_class->open_func =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_xml_registry_open_func);
|
|
|
|
gstxmlregistry_class->load_func =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_xml_registry_load_func);
|
|
|
|
gstxmlregistry_class->save_func =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_xml_registry_save_func);
|
|
|
|
gstxmlregistry_class->close_func =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_xml_registry_close_func);
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_init (GstXMLRegistry * registry)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
registry->location = NULL;
|
|
|
|
registry->context = NULL;
|
|
|
|
registry->state = GST_XML_REGISTRY_NONE;
|
|
|
|
registry->current_plugin = NULL;
|
|
|
|
registry->current_feature = NULL;
|
|
|
|
registry->open_tags = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_xml_registry_new:
|
|
|
|
* @name: the name of the registry
|
|
|
|
* @location: the location of the registry file
|
|
|
|
*
|
|
|
|
* Create a new xml registry with the given name and location.
|
|
|
|
*
|
|
|
|
* Returns: a new GstXMLRegistry with the given name an location.
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GstRegistry *
|
|
|
|
gst_xml_registry_new (const gchar * name, const gchar * location)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
GstXMLRegistry *xmlregistry;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
xmlregistry = GST_XML_REGISTRY (g_object_new (GST_TYPE_XML_REGISTRY, NULL));
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-10 18:26:14 +00:00
|
|
|
g_object_set (G_OBJECT (xmlregistry), "location", location, NULL);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
GST_REGISTRY (xmlregistry)->name = g_strdup (name);
|
|
|
|
|
|
|
|
return GST_REGISTRY (xmlregistry);
|
|
|
|
}
|
|
|
|
|
2002-05-10 18:26:14 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2002-05-10 18:26:14 +00:00
|
|
|
{
|
|
|
|
GstXMLRegistry *registry;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-10 18:26:14 +00:00
|
|
|
registry = GST_XML_REGISTRY (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_LOCATION:
|
|
|
|
if (registry->open) {
|
2004-03-15 19:27:17 +00:00
|
|
|
CLASS (object)->close_func (registry);
|
|
|
|
g_return_if_fail (registry->open == FALSE);
|
2002-05-10 18:26:14 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-10 18:26:14 +00:00
|
|
|
if (registry->location)
|
2004-03-15 19:27:17 +00:00
|
|
|
g_free (registry->location);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-10 18:26:14 +00:00
|
|
|
registry->location = g_strdup (g_value_get_string (value));
|
|
|
|
GST_REGISTRY (registry)->flags = 0x0;
|
|
|
|
|
|
|
|
if (CLASS (object)->get_perms_func)
|
2004-03-15 19:27:17 +00:00
|
|
|
CLASS (object)->get_perms_func (registry);
|
2002-05-11 20:30:05 +00:00
|
|
|
|
|
|
|
if (CLASS (object)->add_path_list_func)
|
2004-03-15 19:27:17 +00:00
|
|
|
CLASS (object)->add_path_list_func (registry);
|
2002-05-10 18:26:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
2002-05-10 18:26:14 +00:00
|
|
|
{
|
|
|
|
GstXMLRegistry *registry;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-10 18:26:14 +00:00
|
|
|
registry = GST_XML_REGISTRY (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_LOCATION:
|
|
|
|
g_value_set_string (value, g_strdup (registry->location));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-05-08 21:16:41 +00:00
|
|
|
|
2002-08-11 20:57:48 +00:00
|
|
|
/* this function returns the biggest of the path's mtime and ctime
|
|
|
|
* mtime is updated through an actual write (data)
|
|
|
|
* ctime is updated through changing inode information
|
|
|
|
* so this function returns the last time *anything* changed to this path
|
2004-07-06 17:55:25 +00:00
|
|
|
* it also sets the given boolean to TRUE if the given path is a directory
|
2002-08-11 20:57:48 +00:00
|
|
|
*/
|
2002-05-10 01:13:40 +00:00
|
|
|
static time_t
|
2004-03-29 22:17:28 +00:00
|
|
|
get_time (const char *path, gboolean * is_dir)
|
2002-05-10 01:13:40 +00:00
|
|
|
{
|
|
|
|
struct stat statbuf;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-03-29 22:17:28 +00:00
|
|
|
if (stat (path, &statbuf)) {
|
|
|
|
*is_dir = FALSE;
|
2004-03-13 15:27:01 +00:00
|
|
|
return 0;
|
2004-03-29 22:17:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (is_dir)
|
|
|
|
*is_dir = S_ISDIR (statbuf.st_mode);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (statbuf.st_mtime > statbuf.st_ctime)
|
|
|
|
return statbuf.st_mtime;
|
2002-05-10 01:13:40 +00:00
|
|
|
return statbuf.st_ctime;
|
|
|
|
}
|
|
|
|
|
2005-01-05 11:15:04 +00:00
|
|
|
#if defined(_MSC_VER) || defined(__MINGW32__)
|
2004-05-10 18:07:24 +00:00
|
|
|
#define xmkdir(dirname) _mkdir (dirname)
|
|
|
|
#else
|
2004-05-11 03:05:00 +00:00
|
|
|
#define xmkdir(dirname) mkdir (dirname, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
|
2004-05-10 18:07:24 +00:00
|
|
|
#endif
|
2002-05-10 18:26:14 +00:00
|
|
|
|
2002-05-20 23:11:10 +00:00
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
make_dir (gchar * filename)
|
2002-05-10 18:26:14 +00:00
|
|
|
{
|
|
|
|
struct stat dirstat;
|
|
|
|
gchar *dirname;
|
2002-05-20 23:11:10 +00:00
|
|
|
|
|
|
|
if (strrchr (filename, '/') == NULL)
|
|
|
|
return FALSE;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
dirname = g_strndup (filename, strrchr (filename, '/') - filename);
|
2002-05-20 23:11:10 +00:00
|
|
|
|
|
|
|
if (stat (dirname, &dirstat) == -1 && errno == ENOENT) {
|
2004-05-10 18:07:24 +00:00
|
|
|
if (xmkdir (dirname) != 0) {
|
2002-05-20 23:11:10 +00:00
|
|
|
if (make_dir (dirname) != TRUE) {
|
2004-03-15 19:27:17 +00:00
|
|
|
g_free (dirname);
|
|
|
|
return FALSE;
|
2002-05-20 23:11:10 +00:00
|
|
|
} else {
|
2004-05-10 18:07:24 +00:00
|
|
|
if (xmkdir (dirname) != 0) {
|
2004-03-15 19:27:17 +00:00
|
|
|
return FALSE;
|
2004-05-10 18:07:24 +00:00
|
|
|
}
|
2002-05-20 23:11:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
g_free (dirname);
|
2002-05-20 23:11:10 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_get_perms_func (GstXMLRegistry * registry)
|
2002-05-20 23:11:10 +00:00
|
|
|
{
|
2004-03-20 17:59:08 +00:00
|
|
|
gchar *dirname;
|
2002-05-10 18:26:14 +00:00
|
|
|
|
|
|
|
/* if the dir does not exist, make it. if that can't be done, flags = 0x0.
|
|
|
|
if the file can be appended to, it's writable. if it can then be read,
|
2002-08-11 20:57:48 +00:00
|
|
|
it's readable.
|
|
|
|
After that check if it exists. */
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-20 23:11:10 +00:00
|
|
|
if (make_dir (registry->location) != TRUE) {
|
|
|
|
/* we can't do anything with it, leave flags as 0x0 */
|
|
|
|
return;
|
2002-05-10 18:26:14 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-03-20 17:59:08 +00:00
|
|
|
dirname = g_path_get_dirname (registry->location);
|
2002-05-10 18:26:14 +00:00
|
|
|
|
2002-08-11 20:57:48 +00:00
|
|
|
if (g_file_test (registry->location, G_FILE_TEST_EXISTS)) {
|
|
|
|
GST_REGISTRY (registry)->flags |= GST_REGISTRY_EXISTS;
|
|
|
|
}
|
|
|
|
|
2004-03-20 17:59:08 +00:00
|
|
|
if (!access (dirname, W_OK)) {
|
|
|
|
GST_REGISTRY (registry)->flags |= GST_REGISTRY_WRITABLE;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-03-20 17:59:08 +00:00
|
|
|
if (!access (dirname, R_OK)) {
|
|
|
|
GST_REGISTRY (registry)->flags |= GST_REGISTRY_READABLE;
|
2002-05-10 18:26:14 +00:00
|
|
|
}
|
2004-03-20 17:59:08 +00:00
|
|
|
|
|
|
|
g_free (dirname);
|
2002-05-10 18:26:14 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-11 20:30:05 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_add_path_list_func (GstXMLRegistry * registry)
|
2002-05-11 20:30:05 +00:00
|
|
|
{
|
2004-02-02 20:25:02 +00:00
|
|
|
FILE *reg = NULL;
|
2002-05-11 20:30:05 +00:00
|
|
|
GMarkupParseContext *context;
|
2004-02-02 20:25:02 +00:00
|
|
|
gchar *text = NULL;
|
2002-05-11 20:30:05 +00:00
|
|
|
gssize size;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
context = g_markup_parse_context_new (&gst_xml_registry_paths_parser, 0,
|
|
|
|
registry, NULL);
|
2002-05-11 20:30:05 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (!(reg = fopen (registry->location, "r"))) {
|
2004-02-02 20:25:02 +00:00
|
|
|
goto finished;
|
2002-05-11 20:30:05 +00:00
|
|
|
}
|
|
|
|
|
2002-06-17 19:23:05 +00:00
|
|
|
/* slightly allocate more as gmarkup reads too much */
|
|
|
|
text = g_malloc0 (BLOCK_SIZE + 32);
|
2002-05-11 20:30:05 +00:00
|
|
|
|
|
|
|
size = fread (text, 1, BLOCK_SIZE, reg);
|
|
|
|
|
|
|
|
while (size) {
|
|
|
|
g_markup_parse_context_parse (context, text, size, &error);
|
|
|
|
|
|
|
|
if (error) {
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_ERROR ("parsing registry %s: %s\n",
|
2004-03-15 19:27:17 +00:00
|
|
|
registry->location, error->message);
|
2004-02-02 20:25:02 +00:00
|
|
|
goto finished;
|
2002-05-11 20:30:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (registry->state == GST_XML_REGISTRY_PATHS_DONE)
|
|
|
|
break;
|
|
|
|
|
|
|
|
size = fread (text, 1, BLOCK_SIZE, reg);
|
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
finished:
|
2004-02-02 20:25:02 +00:00
|
|
|
|
|
|
|
g_markup_parse_context_free (context);
|
|
|
|
|
|
|
|
if (reg)
|
|
|
|
fclose (reg);
|
2002-05-11 20:30:05 +00:00
|
|
|
|
|
|
|
g_free (text);
|
|
|
|
}
|
|
|
|
|
2004-07-06 17:55:25 +00:00
|
|
|
/* return TRUE iff regtime is more recent than the times of all the .so files
|
|
|
|
* in the plugin dirs; ie return TRUE if this path does not need to trigger
|
|
|
|
* a rebuild of registry
|
|
|
|
*
|
|
|
|
* - if it's a directory, recurse on subdirs
|
|
|
|
* - if it's a file
|
|
|
|
* - if entry is not newer, return TRUE.
|
|
|
|
* - if it's newer
|
|
|
|
* - and it's a plugin, return FALSE
|
|
|
|
* - otherwise return TRUE
|
|
|
|
*/
|
2002-05-10 01:13:40 +00:00
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
plugin_times_older_than_recurse (gchar * path, time_t regtime)
|
2002-05-10 01:13:40 +00:00
|
|
|
{
|
|
|
|
DIR *dir;
|
|
|
|
struct dirent *dirent;
|
2004-03-29 22:17:28 +00:00
|
|
|
gboolean is_dir;
|
2004-07-06 17:55:25 +00:00
|
|
|
gchar *new_path;
|
2002-05-10 01:13:40 +00:00
|
|
|
|
2004-03-29 22:17:28 +00:00
|
|
|
time_t pathtime = get_time (path, &is_dir);
|
2002-05-10 01:13:40 +00:00
|
|
|
|
2004-07-06 17:55:25 +00:00
|
|
|
if (is_dir) {
|
|
|
|
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, "..")) {
|
|
|
|
new_path = g_build_filename (path, dirent->d_name, NULL);
|
|
|
|
if (!plugin_times_older_than_recurse (new_path, regtime)) {
|
|
|
|
GST_CAT_INFO (GST_CAT_PLUGIN_LOADING,
|
|
|
|
"path %s is more recent than registry time of %ld",
|
|
|
|
new_path, (long) regtime);
|
|
|
|
g_free (new_path);
|
|
|
|
closedir (dir);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
g_free (new_path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir (dir);
|
|
|
|
}
|
|
|
|
return TRUE;
|
2002-05-10 01:13:40 +00:00
|
|
|
}
|
|
|
|
|
2004-07-06 17:55:25 +00:00
|
|
|
/* it's a file */
|
|
|
|
if (pathtime <= regtime) {
|
2004-03-29 22:17:28 +00:00
|
|
|
return TRUE;
|
2004-07-06 17:55:25 +00:00
|
|
|
}
|
2004-03-29 22:17:28 +00:00
|
|
|
|
2004-07-06 17:55:25 +00:00
|
|
|
/* it's a file, and it's more recent */
|
|
|
|
if (g_str_has_suffix (path, ".so") || g_str_has_suffix (path, ".dll")) {
|
|
|
|
if (!gst_plugin_check_file (path, NULL))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* it's a newer GStreamer plugin */
|
|
|
|
GST_CAT_INFO (GST_CAT_PLUGIN_LOADING,
|
|
|
|
"%s looks like a plugin and is more recent than registry time of %ld",
|
|
|
|
path, (long) regtime);
|
|
|
|
return FALSE;
|
2002-05-10 01:13:40 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-07-06 17:55:25 +00:00
|
|
|
/* return TRUE iff regtime is more recent than the times of all the .so files
|
|
|
|
* in the plugin dirs; ie return TRUE if registry is up to date.
|
|
|
|
*/
|
2002-05-10 01:13:40 +00:00
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
plugin_times_older_than (GList * paths, time_t regtime)
|
2002-05-10 01:13:40 +00:00
|
|
|
{
|
|
|
|
while (paths) {
|
2004-02-20 13:18:32 +00:00
|
|
|
GST_CAT_LOG (GST_CAT_PLUGIN_LOADING,
|
2004-03-15 19:27:17 +00:00
|
|
|
"comparing plugin times from %s with %ld",
|
|
|
|
(gchar *) paths->data, (long) regtime);
|
2004-03-13 15:27:01 +00:00
|
|
|
if (!plugin_times_older_than_recurse (paths->data, regtime))
|
2002-05-10 01:13:40 +00:00
|
|
|
return FALSE;
|
2004-03-13 15:27:01 +00:00
|
|
|
paths = g_list_next (paths);
|
2002-05-10 01:13:40 +00:00
|
|
|
}
|
2004-07-06 17:55:25 +00:00
|
|
|
GST_CAT_LOG (GST_CAT_PLUGIN_LOADING,
|
|
|
|
"everything's fine, no registry rebuild needed.");
|
2002-05-10 01:13:40 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_open_func (GstXMLRegistry * registry, GstXMLRegistryMode mode)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
2002-05-10 18:26:14 +00:00
|
|
|
GstRegistry *gst_registry;
|
|
|
|
GList *paths;
|
|
|
|
|
|
|
|
gst_registry = GST_REGISTRY (registry);
|
|
|
|
paths = gst_registry->paths;
|
2004-03-15 15:16:04 +00:00
|
|
|
GST_CAT_DEBUG (GST_CAT_GST_INIT, "opening registry %s", registry->location);
|
2002-05-10 18:26:14 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (registry->open == FALSE, FALSE);
|
2002-05-10 01:13:40 +00:00
|
|
|
|
2002-08-11 20:57:48 +00:00
|
|
|
/* if it doesn't exist, first try to build it, and check if it worked
|
|
|
|
* if it's not readable, return false
|
|
|
|
* if it's out of date, rebuild it */
|
2002-05-10 01:13:40 +00:00
|
|
|
if (mode == GST_XML_REGISTRY_READ) {
|
2004-03-13 15:27:01 +00:00
|
|
|
if (!(gst_registry->flags & GST_REGISTRY_EXISTS)) {
|
2002-08-11 21:50:37 +00:00
|
|
|
/* if it's not writable, then don't bother */
|
2004-03-13 15:27:01 +00:00
|
|
|
if (!(gst_registry->flags & GST_REGISTRY_WRITABLE)) {
|
2004-03-15 19:27:17 +00:00
|
|
|
GST_CAT_INFO (GST_CAT_GST_INIT, "Registry isn't writable");
|
|
|
|
return FALSE;
|
2002-08-11 21:50:37 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_CAT_INFO (GST_CAT_GST_INIT,
|
2004-03-15 19:27:17 +00:00
|
|
|
"Registry doesn't exist, trying to build...");
|
2002-08-11 20:57:48 +00:00
|
|
|
gst_registry_rebuild (gst_registry);
|
|
|
|
gst_registry_save (gst_registry);
|
|
|
|
/* FIXME: verify that the flags actually get updated ! */
|
2004-03-13 15:27:01 +00:00
|
|
|
if (!(gst_registry->flags & GST_REGISTRY_EXISTS)) {
|
2004-03-15 19:27:17 +00:00
|
|
|
return FALSE;
|
2002-08-11 20:57:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* at this point we know it exists */
|
2002-05-10 18:26:14 +00:00
|
|
|
g_return_val_if_fail (gst_registry->flags & GST_REGISTRY_READABLE, FALSE);
|
|
|
|
|
2004-03-29 22:17:28 +00:00
|
|
|
if (!plugin_times_older_than (paths, get_time (registry->location, NULL))) {
|
2002-07-05 16:18:18 +00:00
|
|
|
if (gst_registry->flags & GST_REGISTRY_WRITABLE) {
|
2004-03-15 19:27:17 +00:00
|
|
|
GST_CAT_INFO (GST_CAT_GST_INIT, "Registry out of date, rebuilding...");
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
gst_registry_rebuild (gst_registry);
|
2002-05-10 01:13:40 +00:00
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
gst_registry_save (gst_registry);
|
2002-07-05 16:18:18 +00:00
|
|
|
|
2004-03-29 22:17:28 +00:00
|
|
|
if (!plugin_times_older_than (paths, get_time (registry->location,
|
|
|
|
NULL))) {
|
2004-03-15 19:27:17 +00:00
|
|
|
GST_CAT_INFO (GST_CAT_GST_INIT,
|
|
|
|
"Registry still out of date, something is wrong...");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-07-05 16:18:18 +00:00
|
|
|
} else {
|
2004-03-15 19:27:17 +00:00
|
|
|
GST_CAT_INFO (GST_CAT_GST_INIT,
|
|
|
|
"Can't write to this registry and it's out of date, ignoring it");
|
|
|
|
return FALSE;
|
2002-05-10 01:13:40 +00:00
|
|
|
}
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-03-15 15:16:04 +00:00
|
|
|
GST_CAT_DEBUG (GST_CAT_GST_INIT, "opening registry %s for reading",
|
2004-03-15 19:27:17 +00:00
|
|
|
registry->location);
|
2002-05-08 20:40:48 +00:00
|
|
|
registry->regfile = fopen (registry->location, "r");
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (mode == GST_XML_REGISTRY_WRITE) {
|
2004-03-20 20:24:49 +00:00
|
|
|
char *tmploc;
|
|
|
|
int fd;
|
|
|
|
|
2002-05-10 18:26:14 +00:00
|
|
|
g_return_val_if_fail (gst_registry->flags & GST_REGISTRY_WRITABLE, FALSE);
|
2002-05-08 21:16:41 +00:00
|
|
|
|
2004-03-20 20:24:49 +00:00
|
|
|
tmploc = g_strconcat (registry->location, ".tmp", NULL);
|
|
|
|
|
|
|
|
GST_CAT_DEBUG (GST_CAT_GST_INIT, "opening registry %s for writing", tmploc);
|
|
|
|
|
2004-08-10 17:28:19 +00:00
|
|
|
if ((fd = open (tmploc, O_WRONLY | O_CREAT, 0644)) < 0) {
|
2004-03-20 20:24:49 +00:00
|
|
|
g_free (tmploc);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
g_free (tmploc);
|
|
|
|
|
|
|
|
registry->regfile = fdopen (fd, "w");
|
2002-05-08 21:16:41 +00:00
|
|
|
}
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
if (!registry->regfile)
|
|
|
|
return FALSE;
|
|
|
|
|
2002-05-10 18:26:14 +00:00
|
|
|
registry->open = TRUE;
|
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_load_func (GstXMLRegistry * registry, gchar * data,
|
|
|
|
gssize * size)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
*size = fread (data, 1, *size, registry->regfile);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_save_func (GstXMLRegistry * registry, gchar * format, ...)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
va_list var_args;
|
|
|
|
|
|
|
|
va_start (var_args, format);
|
|
|
|
|
|
|
|
vfprintf (registry->regfile, format, var_args);
|
|
|
|
|
|
|
|
va_end (var_args);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_close_func (GstXMLRegistry * registry)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
2004-03-20 20:24:49 +00:00
|
|
|
char *tmploc;
|
|
|
|
|
2004-03-15 15:16:04 +00:00
|
|
|
GST_CAT_DEBUG (GST_CAT_GST_INIT, "closing registry %s", registry->location);
|
2002-05-08 20:40:48 +00:00
|
|
|
fclose (registry->regfile);
|
|
|
|
|
2004-03-20 20:24:49 +00:00
|
|
|
/* If we opened for writing, rename our temporary file. */
|
|
|
|
tmploc = g_strconcat (registry->location, ".tmp", NULL);
|
2004-07-24 10:43:57 +00:00
|
|
|
if (g_file_test (tmploc, G_FILE_TEST_EXISTS)) {
|
2004-07-24 11:48:26 +00:00
|
|
|
#ifdef WIN32
|
2004-07-24 10:43:57 +00:00
|
|
|
remove (registry->location);
|
2004-07-24 11:48:26 +00:00
|
|
|
#endif
|
2004-03-20 20:24:49 +00:00
|
|
|
rename (tmploc, registry->location);
|
2004-07-24 10:43:57 +00:00
|
|
|
}
|
2004-03-20 20:24:49 +00:00
|
|
|
g_free (tmploc);
|
|
|
|
|
2002-05-10 18:26:14 +00:00
|
|
|
registry->open = FALSE;
|
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_load (GstRegistry * registry)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
2002-05-11 20:30:05 +00:00
|
|
|
GstXMLRegistry *xmlregistry;
|
2002-05-08 20:40:48 +00:00
|
|
|
gchar *text;
|
|
|
|
gssize size;
|
|
|
|
GError *error = NULL;
|
|
|
|
GTimer *timer;
|
|
|
|
gdouble seconds;
|
|
|
|
|
2002-05-11 20:30:05 +00:00
|
|
|
xmlregistry = GST_XML_REGISTRY (registry);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
timer = g_timer_new ();
|
|
|
|
|
|
|
|
xmlregistry->context =
|
|
|
|
g_markup_parse_context_new (&gst_xml_registry_parser, 0, registry, NULL);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
if (!CLASS (xmlregistry)->open_func (xmlregistry, GST_XML_REGISTRY_READ)) {
|
2004-03-09 13:33:11 +00:00
|
|
|
g_timer_destroy (timer);
|
2002-05-08 20:40:48 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-06-17 19:23:05 +00:00
|
|
|
text = g_malloc0 (BLOCK_SIZE + 32);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
size = BLOCK_SIZE;
|
|
|
|
CLASS (xmlregistry)->load_func (xmlregistry, text, &size);
|
|
|
|
|
|
|
|
while (size) {
|
|
|
|
g_markup_parse_context_parse (xmlregistry->context, text, size, &error);
|
|
|
|
|
2002-05-11 20:30:05 +00:00
|
|
|
if (error) {
|
2003-10-31 19:32:47 +00:00
|
|
|
GST_ERROR ("parsing registry: %s\n", error->message);
|
2002-05-11 20:30:05 +00:00
|
|
|
g_free (text);
|
|
|
|
CLASS (xmlregistry)->close_func (xmlregistry);
|
2004-03-09 13:33:11 +00:00
|
|
|
g_timer_destroy (timer);
|
2002-05-11 20:30:05 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
size = BLOCK_SIZE;
|
|
|
|
CLASS (xmlregistry)->load_func (xmlregistry, text, &size);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (text);
|
|
|
|
|
|
|
|
g_timer_stop (timer);
|
|
|
|
|
|
|
|
seconds = g_timer_elapsed (timer, NULL);
|
2002-09-15 13:45:26 +00:00
|
|
|
g_timer_destroy (timer);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_INFO ("loaded %s in %f seconds (%s)",
|
|
|
|
registry->name, seconds, xmlregistry->location);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
CLASS (xmlregistry)->close_func (xmlregistry);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static GstRegistryReturn
|
|
|
|
gst_xml_registry_load_plugin (GstRegistry * registry, GstPlugin * plugin)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
2003-02-02 19:13:43 +00:00
|
|
|
GError *error = NULL;
|
2003-10-31 19:32:47 +00:00
|
|
|
GstPlugin *loaded_plugin;
|
2003-02-02 19:13:43 +00:00
|
|
|
|
2002-05-20 23:11:10 +00:00
|
|
|
/* FIXME: add gerror support */
|
2003-10-31 19:32:47 +00:00
|
|
|
loaded_plugin = gst_plugin_load_file (plugin->filename, &error);
|
|
|
|
if (!plugin) {
|
2003-02-02 19:13:43 +00:00
|
|
|
if (error) {
|
2004-03-13 15:27:01 +00:00
|
|
|
g_warning ("could not load plugin %s: %s", plugin->desc.name,
|
2004-03-15 19:27:17 +00:00
|
|
|
error->message);
|
2004-03-14 17:54:22 +00:00
|
|
|
g_error_free (error);
|
2003-02-02 19:13:43 +00:00
|
|
|
}
|
2002-05-08 20:40:48 +00:00
|
|
|
return GST_REGISTRY_PLUGIN_LOAD_ERROR;
|
2003-10-31 19:32:47 +00:00
|
|
|
} else if (loaded_plugin != plugin) {
|
|
|
|
g_critical ("how to remove plugins?");
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return GST_REGISTRY_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_parse_plugin (GMarkupParseContext * context, const gchar * tag,
|
|
|
|
const gchar * text, gsize text_len, GstXMLRegistry * registry,
|
|
|
|
GError ** error)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
GstPlugin *plugin = registry->current_plugin;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
if (!strcmp (tag, "name")) {
|
2003-10-31 19:32:47 +00:00
|
|
|
plugin->desc.name = g_strndup (text, text_len);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strcmp (tag, "description")) {
|
2003-10-31 19:32:47 +00:00
|
|
|
plugin->desc.description = g_strndup (text, text_len);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strcmp (tag, "filename")) {
|
2002-05-08 20:40:48 +00:00
|
|
|
plugin->filename = g_strndup (text, text_len);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strcmp (tag, "version")) {
|
2003-10-31 19:32:47 +00:00
|
|
|
plugin->desc.version = g_strndup (text, text_len);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strcmp (tag, "license")) {
|
2003-10-31 19:32:47 +00:00
|
|
|
plugin->desc.license = g_strndup (text, text_len);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strcmp (tag, "package")) {
|
2003-10-31 19:32:47 +00:00
|
|
|
plugin->desc.package = g_strndup (text, text_len);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strcmp (tag, "origin")) {
|
2003-10-31 19:32:47 +00:00
|
|
|
plugin->desc.origin = g_strndup (text, text_len);
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
add_to_char_array (gchar *** array, gchar * value)
|
2003-11-24 03:21:54 +00:00
|
|
|
{
|
|
|
|
gchar **new;
|
|
|
|
gchar **old = *array;
|
|
|
|
gint i = 0;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
/* expensive, but cycles are cheap... */
|
|
|
|
if (old)
|
2004-03-13 15:27:01 +00:00
|
|
|
while (old[i])
|
|
|
|
i++;
|
2003-11-24 03:21:54 +00:00
|
|
|
new = g_new0 (gchar *, i + 2);
|
|
|
|
new[i] = value;
|
|
|
|
while (i > 0) {
|
|
|
|
i--;
|
|
|
|
new[i] = old[i];
|
|
|
|
}
|
|
|
|
g_free (old);
|
|
|
|
*array = new;
|
|
|
|
}
|
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_parse_element_factory (GMarkupParseContext * context,
|
|
|
|
const gchar * tag, const gchar * text, gsize text_len,
|
|
|
|
GstXMLRegistry * registry, GError ** error)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
GstElementFactory *factory = GST_ELEMENT_FACTORY (registry->current_feature);
|
|
|
|
|
|
|
|
if (!strcmp (tag, "name")) {
|
2003-11-24 02:09:23 +00:00
|
|
|
gchar *name = g_strndup (text, text_len);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
gst_plugin_feature_set_name (registry->current_feature, name);
|
|
|
|
g_free (name);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strcmp (tag, "longname")) {
|
2003-10-31 19:32:47 +00:00
|
|
|
g_free (factory->details.longname);
|
|
|
|
factory->details.longname = g_strndup (text, text_len);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strcmp (tag, "class")) {
|
2003-10-31 19:32:47 +00:00
|
|
|
g_free (factory->details.klass);
|
|
|
|
factory->details.klass = g_strndup (text, text_len);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strcmp (tag, "description")) {
|
2003-10-31 19:32:47 +00:00
|
|
|
g_free (factory->details.description);
|
|
|
|
factory->details.description = g_strndup (text, text_len);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strcmp (tag, "author")) {
|
2003-10-31 19:32:47 +00:00
|
|
|
g_free (factory->details.author);
|
|
|
|
factory->details.author = g_strndup (text, text_len);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strcmp (tag, "rank")) {
|
2003-09-27 18:51:16 +00:00
|
|
|
gint rank;
|
|
|
|
gchar *ret;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
rank = strtol (text, &ret, 0);
|
2003-09-27 18:51:16 +00:00
|
|
|
if (ret == text + text_len) {
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank);
|
2003-09-27 18:51:16 +00:00
|
|
|
}
|
2003-11-24 03:21:54 +00:00
|
|
|
} else if (!strcmp (tag, "uri_type")) {
|
2004-04-28 23:26:06 +00:00
|
|
|
if (g_ascii_strncasecmp (text, "sink", 4) == 0) {
|
2003-11-24 03:21:54 +00:00
|
|
|
factory->uri_type = GST_URI_SINK;
|
2004-04-28 23:26:06 +00:00
|
|
|
} else if (g_ascii_strncasecmp (text, "source", 5) == 0) {
|
2003-11-24 03:21:54 +00:00
|
|
|
factory->uri_type = GST_URI_SRC;
|
|
|
|
}
|
|
|
|
} else if (!strcmp (tag, "uri_protocol")) {
|
|
|
|
add_to_char_array (&factory->uri_protocols, g_strndup (text, text_len));
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strcmp (tag, "interface")) {
|
2003-11-24 02:09:23 +00:00
|
|
|
gchar *tmp = g_strndup (text, text_len);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
__gst_element_factory_add_interface (factory, tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
}
|
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_parse_type_find_factory (GMarkupParseContext * context,
|
|
|
|
const gchar * tag, const gchar * text, gsize text_len,
|
|
|
|
GstXMLRegistry * registry, GError ** error)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GstTypeFindFactory *factory =
|
|
|
|
GST_TYPE_FIND_FACTORY (registry->current_feature);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
if (!strcmp (tag, "name")) {
|
|
|
|
registry->current_feature->name = g_strndup (text, text_len);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strcmp (tag, "rank")) {
|
2003-10-28 20:25:30 +00:00
|
|
|
glong rank;
|
|
|
|
gchar *ret;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
rank = strtol (text, &ret, 0);
|
2003-10-28 20:25:30 +00:00
|
|
|
if (ret == text + text_len) {
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank);
|
2003-10-28 20:25:30 +00:00
|
|
|
}
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
2003-10-28 20:25:30 +00:00
|
|
|
/* FIXME!!
|
2004-03-13 15:27:01 +00:00
|
|
|
else if (!strcmp (tag, "caps")) {
|
|
|
|
factory->caps = g_strndup (text, text_len);
|
|
|
|
} */
|
|
|
|
else if (!strcmp (tag, "extension")) {
|
2003-11-24 03:21:54 +00:00
|
|
|
add_to_char_array (&factory->extensions, g_strndup (text, text_len));
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_parse_scheduler_factory (GMarkupParseContext * context,
|
|
|
|
const gchar * tag, const gchar * text, gsize text_len,
|
|
|
|
GstXMLRegistry * registry, GError ** error)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GstSchedulerFactory *factory =
|
|
|
|
GST_SCHEDULER_FACTORY (registry->current_feature);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
if (!strcmp (tag, "name")) {
|
|
|
|
registry->current_feature->name = g_strndup (text, text_len);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strcmp (tag, "longdesc")) {
|
2002-05-08 20:40:48 +00:00
|
|
|
factory->longdesc = g_strndup (text, text_len);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-11-29 18:15:01 +00:00
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_parse_index_factory (GMarkupParseContext * context,
|
|
|
|
const gchar * tag, const gchar * text, gsize text_len,
|
|
|
|
GstXMLRegistry * registry, GError ** error)
|
2002-11-29 18:15:01 +00:00
|
|
|
{
|
2002-12-12 22:14:36 +00:00
|
|
|
GstIndexFactory *factory = GST_INDEX_FACTORY (registry->current_feature);
|
2002-11-29 18:15:01 +00:00
|
|
|
|
|
|
|
if (!strcmp (tag, "name")) {
|
|
|
|
registry->current_feature->name = g_strndup (text, text_len);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strcmp (tag, "longdesc")) {
|
2002-11-29 18:15:01 +00:00
|
|
|
factory->longdesc = g_strndup (text, text_len);
|
|
|
|
}
|
2002-05-08 20:40:48 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_parse_padtemplate (GMarkupParseContext * context,
|
|
|
|
const gchar * tag, const gchar * text, gsize text_len,
|
|
|
|
GstXMLRegistry * registry, GError ** error)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
if (!strcmp (tag, "nametemplate")) {
|
|
|
|
registry->name_template = g_strndup (text, text_len);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strcmp (tag, "direction")) {
|
|
|
|
if (!strncmp (text, "sink", text_len)) {
|
2002-05-08 20:40:48 +00:00
|
|
|
registry->direction = GST_PAD_SINK;
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strncmp (text, "src", text_len)) {
|
2002-05-08 20:40:48 +00:00
|
|
|
registry->direction = GST_PAD_SRC;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strcmp (tag, "presence")) {
|
|
|
|
if (!strncmp (text, "always", text_len)) {
|
2002-05-08 20:40:48 +00:00
|
|
|
registry->presence = GST_PAD_ALWAYS;
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strncmp (text, "sometimes", text_len)) {
|
2002-05-08 20:40:48 +00:00
|
|
|
registry->presence = GST_PAD_SOMETIMES;
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strncmp (text, "request", text_len)) {
|
2002-05-08 20:40:48 +00:00
|
|
|
registry->presence = GST_PAD_REQUEST;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (!strncmp (tag, "caps", 4)) {
|
2003-12-22 01:39:35 +00:00
|
|
|
char *s;
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
s = g_strndup (text, text_len);
|
2004-02-02 20:25:02 +00:00
|
|
|
g_assert (registry->caps == NULL);
|
2003-12-22 01:39:35 +00:00
|
|
|
registry->caps = gst_caps_from_string (s);
|
|
|
|
if (registry->caps == NULL) {
|
2004-07-06 17:55:25 +00:00
|
|
|
g_critical ("Could not parse caps: length %d, content: %*s",
|
2004-05-22 20:46:25 +00:00
|
|
|
(int) text_len, (int) text_len, text);
|
2003-12-22 01:39:35 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
g_free (s);
|
2003-12-22 01:39:35 +00:00
|
|
|
return TRUE;
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_start_element (GMarkupParseContext * context,
|
|
|
|
const gchar * element_name,
|
|
|
|
const gchar ** attribute_names,
|
|
|
|
const gchar ** attribute_values, gpointer user_data, GError ** error)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (user_data);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
xmlregistry->open_tags = g_list_prepend (xmlregistry->open_tags,
|
|
|
|
g_strdup (element_name));
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
switch (xmlregistry->state) {
|
|
|
|
case GST_XML_REGISTRY_NONE:
|
|
|
|
if (!strcmp (element_name, "GST-PluginRegistry")) {
|
2004-03-15 19:27:17 +00:00
|
|
|
xmlregistry->state = GST_XML_REGISTRY_TOP;
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_XML_REGISTRY_TOP:
|
|
|
|
if (!strncmp (element_name, "plugin", 6)) {
|
2004-03-15 19:27:17 +00:00
|
|
|
xmlregistry->state = GST_XML_REGISTRY_PLUGIN;
|
|
|
|
xmlregistry->parser = gst_xml_registry_parse_plugin;
|
|
|
|
xmlregistry->current_plugin = (GstPlugin *) g_new0 (GstPlugin, 1);
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_XML_REGISTRY_PLUGIN:
|
|
|
|
if (!strncmp (element_name, "feature", 7)) {
|
2004-03-15 19:27:17 +00:00
|
|
|
gint i = 0;
|
|
|
|
GstPluginFeature *feature = NULL;
|
|
|
|
|
|
|
|
xmlregistry->state = GST_XML_REGISTRY_FEATURE;
|
|
|
|
|
|
|
|
while (attribute_names[i]) {
|
|
|
|
if (!strncmp (attribute_names[i], "typename", 8)) {
|
|
|
|
feature =
|
|
|
|
GST_PLUGIN_FEATURE (g_object_new (g_type_from_name
|
|
|
|
(attribute_values[i]), NULL));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if (feature) {
|
|
|
|
xmlregistry->current_feature = feature;
|
|
|
|
|
|
|
|
if (GST_IS_ELEMENT_FACTORY (feature)) {
|
|
|
|
GstElementFactory *factory = GST_ELEMENT_FACTORY (feature);
|
|
|
|
|
|
|
|
factory->padtemplates = NULL;
|
|
|
|
xmlregistry->parser = gst_xml_registry_parse_element_factory;
|
|
|
|
break;
|
|
|
|
} else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
|
|
|
|
xmlregistry->parser = gst_xml_registry_parse_type_find_factory;
|
|
|
|
} else if (GST_IS_SCHEDULER_FACTORY (feature)) {
|
|
|
|
xmlregistry->parser = gst_xml_registry_parse_scheduler_factory;
|
|
|
|
GST_SCHEDULER_FACTORY (feature)->type = 0;
|
|
|
|
} else if (GST_IS_INDEX_FACTORY (feature)) {
|
|
|
|
xmlregistry->parser = gst_xml_registry_parse_index_factory;
|
|
|
|
} else {
|
|
|
|
g_warning ("unknown feature type");
|
|
|
|
}
|
|
|
|
}
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_XML_REGISTRY_FEATURE:
|
|
|
|
if (!strncmp (element_name, "padtemplate", 11)) {
|
2004-03-15 19:27:17 +00:00
|
|
|
xmlregistry->state = GST_XML_REGISTRY_PADTEMPLATE;
|
|
|
|
xmlregistry->parser = gst_xml_registry_parse_padtemplate;
|
|
|
|
xmlregistry->name_template = NULL;
|
|
|
|
xmlregistry->direction = 0;
|
|
|
|
xmlregistry->presence = 0;
|
|
|
|
xmlregistry->caps = NULL;
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_end_element (GMarkupParseContext * context,
|
|
|
|
const gchar * element_name, gpointer user_data, GError ** error)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (user_data);
|
2004-03-13 15:27:01 +00:00
|
|
|
gchar *open_tag = (gchar *) xmlregistry->open_tags->data;
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
xmlregistry->open_tags = g_list_remove (xmlregistry->open_tags, open_tag);
|
|
|
|
g_free (open_tag);
|
|
|
|
|
|
|
|
switch (xmlregistry->state) {
|
|
|
|
case GST_XML_REGISTRY_TOP:
|
|
|
|
if (!strcmp (element_name, "GST-PluginRegistry")) {
|
2004-03-15 19:27:17 +00:00
|
|
|
xmlregistry->state = GST_XML_REGISTRY_NONE;
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_XML_REGISTRY_PLUGIN:
|
|
|
|
if (!strcmp (element_name, "plugin")) {
|
2004-03-15 19:27:17 +00:00
|
|
|
xmlregistry->state = GST_XML_REGISTRY_TOP;
|
|
|
|
xmlregistry->parser = NULL;
|
|
|
|
gst_registry_add_plugin (GST_REGISTRY (xmlregistry),
|
|
|
|
xmlregistry->current_plugin);
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_XML_REGISTRY_FEATURE:
|
|
|
|
if (!strcmp (element_name, "feature")) {
|
2004-03-15 19:27:17 +00:00
|
|
|
xmlregistry->state = GST_XML_REGISTRY_PLUGIN;
|
|
|
|
xmlregistry->parser = gst_xml_registry_parse_plugin;
|
|
|
|
gst_plugin_add_feature (xmlregistry->current_plugin,
|
|
|
|
xmlregistry->current_feature);
|
|
|
|
xmlregistry->current_feature = NULL;
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_XML_REGISTRY_PADTEMPLATE:
|
|
|
|
if (!strcmp (element_name, "padtemplate")) {
|
2004-03-15 19:27:17 +00:00
|
|
|
GstPadTemplate *template;
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
template = gst_pad_template_new (xmlregistry->name_template,
|
|
|
|
xmlregistry->direction, xmlregistry->presence, xmlregistry->caps);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
g_free (xmlregistry->name_template);
|
|
|
|
xmlregistry->name_template = NULL;
|
|
|
|
xmlregistry->caps = NULL;
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
__gst_element_factory_add_pad_template (GST_ELEMENT_FACTORY
|
|
|
|
(xmlregistry->current_feature), template);
|
|
|
|
xmlregistry->state = GST_XML_REGISTRY_FEATURE;
|
|
|
|
xmlregistry->parser = gst_xml_registry_parse_element_factory;
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_text (GMarkupParseContext * context, const gchar * text,
|
|
|
|
gsize text_len, gpointer user_data, GError ** error)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (user_data);
|
|
|
|
gchar *open_tag;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
if (xmlregistry->open_tags) {
|
2004-03-13 15:27:01 +00:00
|
|
|
open_tag = (gchar *) xmlregistry->open_tags->data;
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
if (!strcmp (open_tag, "plugin-path")) {
|
|
|
|
//gst_plugin_add_path (g_strndup (text, text_len));
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (xmlregistry->parser) {
|
|
|
|
xmlregistry->parser (context, open_tag, text, text_len, xmlregistry,
|
2004-03-15 19:27:17 +00:00
|
|
|
error);
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_passthrough (GMarkupParseContext * context,
|
|
|
|
const gchar * passthrough_text, gsize text_len, gpointer user_data,
|
|
|
|
GError ** error)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_error (GMarkupParseContext * context, GError * error,
|
|
|
|
gpointer user_data)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
2003-10-31 19:32:47 +00:00
|
|
|
GST_ERROR ("%s\n", error->message);
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
2002-05-11 20:30:05 +00:00
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_paths_start_element (GMarkupParseContext * context,
|
|
|
|
const gchar * element_name,
|
|
|
|
const gchar ** attribute_names,
|
|
|
|
const gchar ** attribute_values, gpointer user_data, GError ** error)
|
2002-05-11 20:30:05 +00:00
|
|
|
{
|
|
|
|
GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (user_data);
|
|
|
|
|
|
|
|
switch (xmlregistry->state) {
|
|
|
|
case GST_XML_REGISTRY_NONE:
|
|
|
|
if (!strcmp (element_name, "GST-PluginRegistry")) {
|
2004-03-15 19:27:17 +00:00
|
|
|
xmlregistry->state = GST_XML_REGISTRY_TOP;
|
2002-05-11 20:30:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_XML_REGISTRY_TOP:
|
|
|
|
if (!strcmp (element_name, "gst-registry-paths")) {
|
2004-03-15 19:27:17 +00:00
|
|
|
xmlregistry->state = GST_XML_REGISTRY_PATHS;
|
2002-05-11 20:30:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_XML_REGISTRY_PATHS:
|
|
|
|
if (!strcmp (element_name, "path")) {
|
2004-03-15 19:27:17 +00:00
|
|
|
xmlregistry->state = GST_XML_REGISTRY_PATH;
|
2002-05-11 20:30:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_paths_end_element (GMarkupParseContext * context,
|
|
|
|
const gchar * element_name, gpointer user_data, GError ** error)
|
2002-05-11 20:30:05 +00:00
|
|
|
{
|
|
|
|
GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (user_data);
|
|
|
|
|
|
|
|
switch (xmlregistry->state) {
|
|
|
|
case GST_XML_REGISTRY_PATH:
|
|
|
|
if (!strcmp (element_name, "path")) {
|
2004-03-15 19:27:17 +00:00
|
|
|
xmlregistry->state = GST_XML_REGISTRY_PATHS;
|
2002-05-11 20:30:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_XML_REGISTRY_PATHS:
|
|
|
|
if (!strcmp (element_name, "gst-plugin-paths")) {
|
2004-03-15 19:27:17 +00:00
|
|
|
xmlregistry->state = GST_XML_REGISTRY_PATHS_DONE;
|
2002-05-11 20:30:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_paths_text (GMarkupParseContext * context, const gchar * text,
|
|
|
|
gsize text_len, gpointer user_data, GError ** error)
|
2002-05-11 20:30:05 +00:00
|
|
|
{
|
|
|
|
GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (user_data);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-11 20:30:05 +00:00
|
|
|
if (xmlregistry->state == GST_XML_REGISTRY_PATH)
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_registry_add_path (GST_REGISTRY (xmlregistry), g_strndup (text,
|
2004-03-15 19:27:17 +00:00
|
|
|
text_len));
|
2002-05-11 20:30:05 +00:00
|
|
|
}
|
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
/*
|
|
|
|
* Save
|
|
|
|
*/
|
|
|
|
#define PUT_ESCAPED(tag,value) \
|
|
|
|
G_STMT_START{ \
|
|
|
|
const gchar *toconv = value; \
|
2003-10-28 20:25:30 +00:00
|
|
|
if (toconv) { \
|
2002-05-08 20:40:48 +00:00
|
|
|
gchar *v = g_markup_escape_text (toconv, strlen (toconv)); \
|
|
|
|
CLASS (xmlregistry)->save_func (xmlregistry, "<%s>%s</%s>\n", tag, v, tag); \
|
|
|
|
g_free (v); \
|
|
|
|
} \
|
|
|
|
}G_STMT_END
|
2003-10-28 20:25:30 +00:00
|
|
|
#define PUT_ESCAPED_INT(tag,value) \
|
|
|
|
G_STMT_START{ \
|
|
|
|
gchar *save = g_strdup_printf ("%ld", (glong) value); \
|
|
|
|
CLASS (xmlregistry)->save_func (xmlregistry, "<%s>%s</%s>\n", tag, save, tag); \
|
|
|
|
g_free (save); \
|
|
|
|
}G_STMT_END
|
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_save_caps (GstXMLRegistry * xmlregistry, const GstCaps * caps)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
2003-12-22 01:39:35 +00:00
|
|
|
char *s = gst_caps_to_string (caps);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-12-22 01:39:35 +00:00
|
|
|
PUT_ESCAPED ("caps", s);
|
2004-01-29 01:44:08 +00:00
|
|
|
g_free (s);
|
2002-05-08 20:40:48 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_save_pad_template (GstXMLRegistry * xmlregistry,
|
|
|
|
GstPadTemplate * template)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
gchar *presence;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
PUT_ESCAPED ("nametemplate", template->name_template);
|
2004-03-13 15:27:01 +00:00
|
|
|
CLASS (xmlregistry)->save_func (xmlregistry, "<direction>%s</direction>\n",
|
|
|
|
(template->direction == GST_PAD_SINK ? "sink" : "src"));
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
switch (template->presence) {
|
|
|
|
case GST_PAD_ALWAYS:
|
|
|
|
presence = "always";
|
|
|
|
break;
|
|
|
|
case GST_PAD_SOMETIMES:
|
|
|
|
presence = "sometimes";
|
|
|
|
break;
|
|
|
|
case GST_PAD_REQUEST:
|
|
|
|
presence = "request";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
presence = "unknown";
|
|
|
|
break;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
CLASS (xmlregistry)->save_func (xmlregistry, "<presence>%s</presence>\n",
|
|
|
|
presence);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
if (GST_PAD_TEMPLATE_CAPS (template)) {
|
|
|
|
gst_xml_registry_save_caps (xmlregistry, GST_PAD_TEMPLATE_CAPS (template));
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_save_feature (GstXMLRegistry * xmlregistry,
|
|
|
|
GstPluginFeature * feature)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
PUT_ESCAPED ("name", feature->name);
|
|
|
|
|
2003-08-18 21:14:16 +00:00
|
|
|
if (feature->rank > 0) {
|
|
|
|
gint rank = feature->rank;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-08-18 21:14:16 +00:00
|
|
|
CLASS (xmlregistry)->save_func (xmlregistry, "<rank>%d</rank>\n", rank);
|
2004-03-13 15:27:01 +00:00
|
|
|
}
|
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
if (GST_IS_ELEMENT_FACTORY (feature)) {
|
|
|
|
GstElementFactory *factory = GST_ELEMENT_FACTORY (feature);
|
2003-11-24 02:09:23 +00:00
|
|
|
GList *walk;
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
PUT_ESCAPED ("longname", factory->details.longname);
|
|
|
|
PUT_ESCAPED ("class", factory->details.klass);
|
|
|
|
PUT_ESCAPED ("description", factory->details.description);
|
|
|
|
PUT_ESCAPED ("author", factory->details.author);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
walk = factory->padtemplates;
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
while (walk) {
|
|
|
|
GstPadTemplate *template = GST_PAD_TEMPLATE (walk->data);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
CLASS (xmlregistry)->save_func (xmlregistry, "<padtemplate>\n");
|
|
|
|
gst_xml_registry_save_pad_template (xmlregistry, template);
|
|
|
|
CLASS (xmlregistry)->save_func (xmlregistry, "</padtemplate>\n");
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 02:09:23 +00:00
|
|
|
walk = g_list_next (walk);
|
|
|
|
}
|
|
|
|
|
|
|
|
walk = factory->interfaces;
|
|
|
|
while (walk) {
|
|
|
|
PUT_ESCAPED ("interface", (gchar *) walk->data);
|
|
|
|
walk = g_list_next (walk);
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
2003-11-24 03:21:54 +00:00
|
|
|
|
|
|
|
if (GST_URI_TYPE_IS_VALID (factory->uri_type)) {
|
|
|
|
gchar **protocol;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
PUT_ESCAPED ("uri_type",
|
2004-03-15 19:27:17 +00:00
|
|
|
factory->uri_type == GST_URI_SINK ? "sink" : "source");
|
2003-11-24 03:21:54 +00:00
|
|
|
g_assert (factory->uri_protocols);
|
|
|
|
protocol = factory->uri_protocols;
|
|
|
|
while (*protocol) {
|
2004-03-15 19:27:17 +00:00
|
|
|
PUT_ESCAPED ("uri_protocol", *protocol);
|
|
|
|
protocol++;
|
2003-11-24 03:21:54 +00:00
|
|
|
}
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
|
2003-10-28 20:25:30 +00:00
|
|
|
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature);
|
|
|
|
gint i = 0;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
if (factory->caps) {
|
|
|
|
gst_xml_registry_save_caps (xmlregistry, factory->caps);
|
2003-12-22 01:39:35 +00:00
|
|
|
}
|
2003-10-29 23:10:49 +00:00
|
|
|
if (factory->extensions) {
|
|
|
|
while (factory->extensions[i]) {
|
2004-03-15 19:27:17 +00:00
|
|
|
PUT_ESCAPED ("extension", factory->extensions[i]);
|
|
|
|
i++;
|
2003-10-29 23:10:49 +00:00
|
|
|
}
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (GST_IS_SCHEDULER_FACTORY (feature)) {
|
2002-05-08 20:40:48 +00:00
|
|
|
PUT_ESCAPED ("longdesc", GST_SCHEDULER_FACTORY (feature)->longdesc);
|
2004-03-13 15:27:01 +00:00
|
|
|
} else if (GST_IS_INDEX_FACTORY (feature)) {
|
2002-12-12 22:14:36 +00:00
|
|
|
PUT_ESCAPED ("longdesc", GST_INDEX_FACTORY (feature)->longdesc);
|
2002-11-29 18:15:01 +00:00
|
|
|
}
|
2002-05-08 20:40:48 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_save_plugin (GstXMLRegistry * xmlregistry, GstPlugin * plugin)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
GList *walk;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
PUT_ESCAPED ("name", plugin->desc.name);
|
|
|
|
PUT_ESCAPED ("description", plugin->desc.description);
|
2002-05-08 20:40:48 +00:00
|
|
|
PUT_ESCAPED ("filename", plugin->filename);
|
2003-10-31 19:32:47 +00:00
|
|
|
PUT_ESCAPED ("version", plugin->desc.version);
|
|
|
|
PUT_ESCAPED ("license", plugin->desc.license);
|
|
|
|
PUT_ESCAPED ("package", plugin->desc.package);
|
|
|
|
PUT_ESCAPED ("origin", plugin->desc.origin);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
walk = plugin->features;
|
|
|
|
|
|
|
|
while (walk) {
|
|
|
|
GstPluginFeature *feature = GST_PLUGIN_FEATURE (walk->data);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
CLASS (xmlregistry)->save_func (xmlregistry, "<feature typename=\"%s\">\n",
|
2004-03-15 19:27:17 +00:00
|
|
|
g_type_name (G_OBJECT_TYPE (feature)));
|
2002-05-08 20:40:48 +00:00
|
|
|
gst_xml_registry_save_feature (xmlregistry, feature);
|
|
|
|
CLASS (xmlregistry)->save_func (xmlregistry, "</feature>\n");
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
walk = g_list_next (walk);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_save (GstRegistry * registry)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
GList *walk;
|
|
|
|
GstXMLRegistry *xmlregistry;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
|
|
|
|
g_return_val_if_fail (registry->flags & GST_REGISTRY_WRITABLE, FALSE);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
xmlregistry = GST_XML_REGISTRY (registry);
|
|
|
|
|
|
|
|
if (!CLASS (xmlregistry)->open_func (xmlregistry, GST_XML_REGISTRY_WRITE)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
CLASS (xmlregistry)->save_func (xmlregistry, "<?xml version=\"1.0\"?>\n");
|
|
|
|
CLASS (xmlregistry)->save_func (xmlregistry, "<GST-PluginRegistry>\n");
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-11 20:30:05 +00:00
|
|
|
walk = g_list_last (gst_registry_get_path_list (GST_REGISTRY (registry)));
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-11 20:30:05 +00:00
|
|
|
CLASS (xmlregistry)->save_func (xmlregistry, "<gst-plugin-paths>\n");
|
|
|
|
while (walk) {
|
|
|
|
CLASS (xmlregistry)->save_func (xmlregistry, "<path>");
|
2004-03-13 15:27:01 +00:00
|
|
|
CLASS (xmlregistry)->save_func (xmlregistry, (gchar *) walk->data);
|
2002-05-11 20:30:05 +00:00
|
|
|
CLASS (xmlregistry)->save_func (xmlregistry, "</path>\n");
|
|
|
|
walk = g_list_previous (walk);
|
|
|
|
}
|
|
|
|
CLASS (xmlregistry)->save_func (xmlregistry, "</gst-plugin-paths>\n");
|
|
|
|
|
|
|
|
walk = g_list_last (registry->plugins);
|
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
while (walk) {
|
|
|
|
GstPlugin *plugin = GST_PLUGIN (walk->data);
|
|
|
|
|
|
|
|
CLASS (xmlregistry)->save_func (xmlregistry, "<plugin>\n");
|
|
|
|
gst_xml_registry_save_plugin (xmlregistry, plugin);
|
|
|
|
CLASS (xmlregistry)->save_func (xmlregistry, "</plugin>\n");
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
walk = g_list_previous (walk);
|
|
|
|
}
|
|
|
|
CLASS (xmlregistry)->save_func (xmlregistry, "</GST-PluginRegistry>\n");
|
|
|
|
|
|
|
|
CLASS (xmlregistry)->close_func (xmlregistry);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static GList *
|
|
|
|
gst_xml_registry_rebuild_recurse (GstXMLRegistry * registry,
|
|
|
|
const gchar * directory)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
2002-05-20 23:11:10 +00:00
|
|
|
GList *ret = NULL;
|
2004-04-01 18:28:44 +00:00
|
|
|
gint dr_len, sf_len;
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2004-06-06 20:40:29 +00:00
|
|
|
if (g_file_test (directory, G_FILE_TEST_IS_DIR)) {
|
|
|
|
GDir *dir = g_dir_open (directory, 0, NULL);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2004-06-06 20:40:29 +00:00
|
|
|
if (dir) {
|
|
|
|
const gchar *dirent;
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2004-06-06 20:40:29 +00:00
|
|
|
while ((dirent = g_dir_read_name (dir))) {
|
|
|
|
gchar *dirname;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-06-06 20:40:29 +00:00
|
|
|
if (*dirent == '=') {
|
|
|
|
/* =build, =inst, etc. -- automake distcheck directories */
|
|
|
|
continue;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-06-06 20:40:29 +00:00
|
|
|
dirname = g_strjoin ("/", directory, dirent, NULL);
|
|
|
|
ret =
|
|
|
|
g_list_concat (ret, gst_xml_registry_rebuild_recurse (registry,
|
|
|
|
dirname));
|
|
|
|
g_free (dirname);
|
|
|
|
}
|
|
|
|
g_dir_close (dir);
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
} else {
|
2004-04-01 18:28:44 +00:00
|
|
|
dr_len = strlen (directory);
|
|
|
|
sf_len = strlen (G_MODULE_SUFFIX);
|
|
|
|
if (dr_len >= sf_len &&
|
|
|
|
strcmp (directory + dr_len - sf_len, G_MODULE_SUFFIX) == 0) {
|
2003-10-31 19:32:47 +00:00
|
|
|
ret = g_list_prepend (ret, g_strdup (directory));
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
}
|
2002-05-20 23:11:10 +00:00
|
|
|
|
|
|
|
return ret;
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_xml_registry_rebuild (GstRegistry * registry)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
2002-05-20 23:11:10 +00:00
|
|
|
GList *walk = NULL, *plugins = NULL, *prune = NULL;
|
|
|
|
GError *error = NULL;
|
2003-10-09 19:13:19 +00:00
|
|
|
guint length;
|
2003-10-31 19:32:47 +00:00
|
|
|
GstPlugin *plugin;
|
2002-05-08 20:40:48 +00:00
|
|
|
GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (registry);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
walk = registry->paths;
|
|
|
|
|
|
|
|
while (walk) {
|
|
|
|
gchar *path = (gchar *) walk->data;
|
2002-05-10 03:27:42 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_CAT_INFO (GST_CAT_PLUGIN_LOADING,
|
2004-03-15 19:27:17 +00:00
|
|
|
"Rebuilding registry %p in directory %s...", registry, path);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
plugins = g_list_concat (plugins,
|
2004-03-15 19:27:17 +00:00
|
|
|
gst_xml_registry_rebuild_recurse (xmlregistry, path));
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
walk = g_list_next (walk);
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-20 23:11:10 +00:00
|
|
|
plugins = g_list_reverse (plugins);
|
|
|
|
|
|
|
|
do {
|
|
|
|
length = g_list_length (plugins);
|
|
|
|
|
|
|
|
walk = plugins;
|
|
|
|
while (walk) {
|
|
|
|
g_assert (walk->data);
|
2003-10-31 19:32:47 +00:00
|
|
|
plugin = gst_plugin_load_file ((gchar *) walk->data, NULL);
|
|
|
|
if (plugin) {
|
2004-03-15 19:27:17 +00:00
|
|
|
prune = g_list_prepend (prune, walk->data);
|
|
|
|
gst_registry_add_plugin (registry, plugin);
|
2002-05-20 23:11:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
walk = g_list_next (walk);
|
|
|
|
}
|
|
|
|
|
|
|
|
walk = prune;
|
|
|
|
while (walk) {
|
|
|
|
plugins = g_list_remove (plugins, walk->data);
|
2003-10-31 19:32:47 +00:00
|
|
|
g_free (walk->data);
|
2002-05-20 23:11:10 +00:00
|
|
|
walk = g_list_next (walk);
|
|
|
|
}
|
|
|
|
g_list_free (prune);
|
|
|
|
prune = NULL;
|
|
|
|
} while (g_list_length (plugins) != length);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-20 23:11:10 +00:00
|
|
|
walk = plugins;
|
|
|
|
while (walk) {
|
2003-10-31 19:32:47 +00:00
|
|
|
if ((plugin = gst_plugin_load_file ((gchar *) walk->data, &error))) {
|
2004-03-13 15:27:01 +00:00
|
|
|
g_warning ("Bizarre behavior: plugin %s actually loaded",
|
2004-03-15 19:27:17 +00:00
|
|
|
(gchar *) walk->data);
|
2003-10-31 19:32:47 +00:00
|
|
|
gst_registry_add_plugin (registry, plugin);
|
2002-05-25 17:45:51 +00:00
|
|
|
} else {
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "Plugin %s failed to load: %s",
|
2004-03-15 19:27:17 +00:00
|
|
|
(gchar *) walk->data, error->message);
|
2002-05-25 17:45:51 +00:00
|
|
|
|
|
|
|
g_free (walk->data);
|
|
|
|
g_error_free (error);
|
|
|
|
error = NULL;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-05-20 23:11:10 +00:00
|
|
|
walk = g_list_next (walk);
|
|
|
|
}
|
2002-05-08 20:40:48 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|