Commit ebf0c9d3 authored by Stefan Kost's avatar Stefan Kost

commit binary registry (disabled by default, see #359653)

Original commit message from CVS:
* configure.ac:
* docs/gst/gstreamer-sections.txt:
* gst/Makefile.am:
* gst/gstregistry.c: (gst_registry_lookup_feature_locked),
(gst_registry_lookup_locked):
* gst/gstregistry.h:
* gst/gstregistrybinary.c: (gst_registry_binary_write),
(gst_registry_binary_initialize_magic),
(gst_registry_binary_save_string),
(gst_registry_binary_save_pad_template),
(gst_registry_binary_save_feature),
(gst_registry_binary_save_plugin),
(gst_registry_binary_write_cache),
(gst_registry_binary_check_magic),
(gst_registry_binary_load_pad_template),
(gst_registry_binary_load_feature),
(gst_registry_binary_load_plugin),
(gst_registry_binary_read_cache):
* gst/gstregistrybinary.h:
* gst/gstregistryxml.c: (load_feature),
(gst_registry_xml_read_cache):
commit binary registry (disabled by default, see #359653)
parent 4a911a81
2007-01-11 Stefan Kost <ensonic@users.sf.net>
* configure.ac:
* docs/gst/gstreamer-sections.txt:
* gst/Makefile.am:
* gst/gstregistry.c: (gst_registry_lookup_feature_locked),
(gst_registry_lookup_locked):
* gst/gstregistry.h:
* gst/gstregistrybinary.c: (gst_registry_binary_write),
(gst_registry_binary_initialize_magic),
(gst_registry_binary_save_string),
(gst_registry_binary_save_pad_template),
(gst_registry_binary_save_feature),
(gst_registry_binary_save_plugin),
(gst_registry_binary_write_cache),
(gst_registry_binary_check_magic),
(gst_registry_binary_load_pad_template),
(gst_registry_binary_load_feature),
(gst_registry_binary_load_plugin),
(gst_registry_binary_read_cache):
* gst/gstregistrybinary.h:
* gst/gstregistryxml.c: (load_feature),
(gst_registry_xml_read_cache):
commit binary registry (disabled by default, see #359653)
2007-01-11 Tim-Philipp Müller <tim at centricular dot net>
* tests/check/gst/gstpad.c: (test_get_allowed_caps):
......
......@@ -191,6 +191,23 @@ if test "x$USE_POISONING" = xyes; then
[Define if we should poison deallocated memory])
fi
dnl Use binary registry
AC_ARG_ENABLE(binary-registry,
AC_HELP_STRING([--enable-binary-registry],
[enable experimental binary registry]),
[
case "${enableval}" in
yes) USE_BINARY_REGISTRY=yes ;;
no) USE_BINARY_REGISTRY=no ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-binary-registry) ;;
esac
],
[USE_BINARY_REGISTRY=no]) dnl Default value
if test "x$USE_BINARY_REGISTRY" = xyes; then
AC_DEFINE(USE_BINARY_REGISTRY, 1,
[Define if we should use binary registry instead xml registry])
fi
dnl *** checks for platform ***
dnl * hardware/architecture *
......
......@@ -1649,6 +1649,8 @@ gst_registry_find_plugin
gst_registry_find_feature
gst_registry_lookup_feature
gst_registry_scan_path
gst_registry_binary_read_cache
gst_registry_binary_write_cache
gst_registry_xml_read_cache
gst_registry_xml_write_cache
gst_registry_lookup
......@@ -1672,6 +1674,9 @@ GST_IS_REGISTRY_CLASS
GST_REGISTRY_GET_CLASS
GST_TYPE_REGISTRY
<SUBSECTION Private>
GST_MAGIC_BINARY_REGISTRY_LEN
GST_MAGIC_BINARY_REGISTRY_STR
GST_MAGIC_BINARY_VERSION_LEN
gst_registry_get_type
</SECTION>
......
......@@ -9,7 +9,7 @@ endif
if GST_DISABLE_REGISTRY
GST_REGISTRY_SRC =
else
GST_REGISTRY_SRC = gstregistryxml.c
GST_REGISTRY_SRC = gstregistryxml.c gstregistrybinary.c
endif
if GST_DISABLE_PARSE
......@@ -210,6 +210,7 @@ noinst_HEADERS = \
gst-i18n-lib.h \
gst-i18n-app.h \
gstquark.h \
gstregistrybinary.h \
gst_private.h
gstmarshal.h: gstmarshal.list
......
......@@ -684,6 +684,7 @@ gst_registry_lookup_feature_locked (GstRegistry * registry, const char *name)
if (G_UNLIKELY (name == NULL))
return NULL;
/* FIXME: use GTree speed up lookups */
for (g = registry->features; g; g = g_list_next (g)) {
feature = GST_PLUGIN_FEATURE_CAST (g->data);
if (feature->name && strcmp (name, feature->name) == 0) {
......@@ -734,6 +735,7 @@ gst_registry_lookup_locked (GstRegistry * registry, const char *filename)
return NULL;
basename = g_path_get_basename (filename);
/* FIXME: use GTree speed up lookups */
for (g = registry->plugins; g; g = g_list_next (g)) {
plugin = GST_PLUGIN_CAST (g->data);
if (plugin->basename && strcmp (basename, plugin->basename) == 0) {
......
......@@ -50,7 +50,10 @@ struct _GstRegistry {
GstObject object;
/*< private >*/
GList *plugins;
/* FIXME: shouldn't we use GTree for these to speedup
* gst_registry_lookup_feature_locked(), gst_registry_lookup_locked()
*/
GList *plugins;
GList *features;
GList *paths;
......@@ -106,8 +109,13 @@ GstPluginFeature* gst_registry_find_feature (GstRegistry *registry, const gchar
GstPlugin * gst_registry_lookup (GstRegistry *registry, const char *filename);
GstPluginFeature * gst_registry_lookup_feature (GstRegistry *registry, const char *name);
#ifdef USE_BINARY_REGISTRY
gboolean gst_registry_binary_read_cache (GstRegistry * registry, const char *location);
gboolean gst_registry_binary_write_cache (GstRegistry * registry, const char *location);
#else
gboolean gst_registry_xml_read_cache (GstRegistry * registry, const char *location);
gboolean gst_registry_xml_write_cache (GstRegistry * registry, const char *location);
#endif
/* convinience defines for the default registry */
......
This diff is collapsed.
/* GStreamer
* Copyright (C) 2006 Josep Torra <josep@fluendo.com>
* 2006 Mathieu Garcia <matthieu@fluendo.com>
* 2006 Stefan Kost <ensonic@sonicpulse.de>
*
* gstregistrybinary.h: Header for registry handling
*
* 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.
*/
/* SUGGESTIONS AND TODO :
** ====================
** - Use a compressed registry, but would induce performance loss
** - Encrypt the registry, for security purpose, but would also reduce performances
** - Also have a non-mmap based cache reading (work with file descriptors)
*/
#ifndef __GST_REGISTRYBINARY_H__
#define __GST_REGISTRYBINARY_H__
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <fcntl.h>
#include <sys/mman.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <gst/gstconfig.h>
#include <gst/gst_private.h>
#include <gst/gstelement.h>
#include <gst/gsttypefind.h>
#include <gst/gsttypefindfactory.h>
#include <gst/gsturi.h>
#include <gst/gstinfo.h>
#include <gst/gstenumtypes.h>
#include <gst/gstregistry.h>
#include <gst/gstpadtemplate.h>
#include "glib-compat-private.h"
#include <glib/gstdio.h>
/*
* GST_MAGIC_BINARY_REGISTRY_STR:
*
* A tag, written at the beginning of the file
*/
#define GST_MAGIC_BINARY_REGISTRY_STR "\xc0\xde\xf0\x0d"
/*
* GST_MAGIC_BINARY_REGISTRY_LEN:
*
* length of the header tag.
*/
#define GST_MAGIC_BINARY_REGISTRY_LEN (4)
/*
* GST_MAGIC_BINARY_VERSION_LEN:
*
* length of the version string.
*/
#define GST_MAGIC_BINARY_VERSION_LEN (64)
typedef struct _GstBinaryRegistryMagic
{
char magic[GST_MAGIC_BINARY_REGISTRY_LEN];
char version[GST_MAGIC_BINARY_VERSION_LEN];
} GstBinaryRegistryMagic;
/*
* we reference strings directly from the plugins and in this case set CONST to
* avoid freeing them
*/
enum {
GST_BINARY_REGISTRY_FLAG_NONE = 0,
GST_BINARY_REGISTRY_FLAG_CONST = 1
};
/* GstBinaryChunk:
*
* Header for binary blobs
*/
typedef struct _GstBinaryChunk
{
void *data;
unsigned int size;
unsigned int flags;
gboolean align;
} GstBinaryChunk;
/* A structure containing (staticely) every information needed for a plugin
**
** Notes :
** "nfeatures" is used to say how many GstBinaryPluginFeature structures we will have
** right after the structure itself.
*/
typedef struct _GstBinaryPluginElement
{
unsigned long file_size;
unsigned long file_mtime;
unsigned int nfeatures;
} GstBinaryPluginElement;
/* A structure containing the plugin features
**
** Note :
** "npadtemplates" is used to store the number of GstBinaryPadTemplate structures following the structure itself.
** "ninterfaces" is used to store the number of GstBinaryInterface structures following the structure itself.
** "nuritypes" is used to store the number of GstBinaryUriType structures following the structure itself.
*/
typedef struct _GstBinaryPluginFeature
{
unsigned long rank;
unsigned int npadtemplates;
unsigned int ninterfaces;
unsigned int nuritypes;
} GstBinaryPluginFeature;
/*
** A structure containing the static pad templates of a plugin feature
*/
typedef struct _GstBinaryPadTemplate
{
int direction; /* Either 0:"sink" or 1:"src" */
GstPadPresence presence;
} GstBinaryPadTemplate;
/*
** A very simple structure defining the plugin feature interface string
*/
//#define GST_BINARY_REGISTRY_INTERFACE_INTERFACE_LEN (512)
typedef struct _GstBinaryInterface
{
//char interface[GST_BINARY_REGISTRY_INTERFACE_INTERFACE_LEN];
unsigned long size;
} GstBinaryInterface;
/* Uri Type */
typedef struct _GstBinaryUriType
{
GstURIType type; /* GST_URI_SINK / GST_URI_SRC */
unsigned long nuriprotocols;
} GstBinaryUriType;
/* Function prototypes */
gboolean gst_registry_binary_write_cache(GstRegistry *registry, const char *location);
gboolean gst_registry_binary_read_cache(GstRegistry *registry, const char *location);
#endif /* !__GST_REGISTRYBINARY_H__ */
......@@ -249,7 +249,7 @@ load_feature (xmlTextReaderPtr reader)
feature_name =
(gchar *) xmlTextReaderGetAttribute (reader, BAD_CAST "typename");
GST_DEBUG ("loading feature");
GST_LOG ("loading feature");
if (!feature_name)
return NULL;
......@@ -480,10 +480,9 @@ load_plugin (xmlTextReaderPtr reader, GList ** feature_list)
* @registry: a #GstRegistry
* @location: a filename
*
* Read the contents of the XML cache file at location
* @location into @registry.
* Read the contents of the XML cache file at @location into @registry.
*
* Returns: TRUE on success.
* Returns: %TRUE on success.
*/
gboolean
gst_registry_xml_read_cache (GstRegistry * registry, const char *location)
......@@ -573,7 +572,7 @@ gst_registry_xml_read_cache (GstRegistry * registry, const char *location)
seconds = g_timer_elapsed (timer, NULL);
g_timer_destroy (timer);
GST_INFO ("loaded %s in %f seconds", location, seconds);
GST_INFO ("loaded %s in %lf seconds", location, seconds);
if (mapped)
g_mapped_file_free (mapped);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment