Commit 51675e0c authored by Jan Schmidt's avatar Jan Schmidt

registry: Add registry helper phase 1

Phase 1 of adding the registry scan helper
parent 1f4e4770
......@@ -681,6 +681,7 @@ libs/gst/check/libcheck/Makefile
libs/gst/check/libcheck/check.h
libs/gst/controller/Makefile
libs/gst/dataprotocol/Makefile
libs/gst/helpers/Makefile
libs/gst/net/Makefile
plugins/Makefile
plugins/indexers/Makefile
......
......@@ -33,6 +33,8 @@ gst_update_registry
<SUBSECTION Private>
GST_QUARK
GstQuarkId
GstPluginLoader
GstPluginLoaderFuncs
</SECTION>
<SECTION>
......
......@@ -82,11 +82,13 @@ libgstreamer_@GST_MAJORMINOR@_la_SOURCES = \
gstpipeline.c \
gstplugin.c \
gstpluginfeature.c \
gstpluginloader.c \
gstpoll.c \
gstpreset.c \
gstquark.c \
gstquery.c \
gstregistry.c \
gstregistrychunks.c \
gstsegment.c \
gststructure.c \
gstsystemclock.c \
......@@ -200,8 +202,10 @@ noinst_HEADERS = \
glib-compat-private.h \
gst-i18n-lib.h \
gst-i18n-app.h \
gstpluginloader.h \
gstquark.h \
gstregistrybinary.h \
gstregistrychunks.h \
gst_private.h
gstmarshal.h: gstmarshal.list
......
......@@ -99,13 +99,13 @@ void _gst_value_initialize (void);
/* Private registry functions */
gboolean _priv_gst_registry_remove_cache_plugins (GstRegistry *registry);
void _priv_gst_registry_cleanup (void);
gboolean _gst_plugin_loader_client_run (void);
/* used in both gststructure.c and gstcaps.c; numbers are completely made up */
#define STRUCTURE_ESTIMATED_STRING_LEN(s) (16 + (s)->fields->len * 22)
gboolean priv_gst_structure_append_to_gstring (const GstStructure * structure,
GString * s);
/* registry cache backends */
/* FIXME 0.11: use priv_ prefix */
gboolean gst_registry_binary_read_cache (GstRegistry * registry, const char *location);
......@@ -117,6 +117,11 @@ gboolean gst_registry_binary_write_cache (GstRegistry * registry, const char *
((c) == '-') || ((c) == '+') || ((c) == '/') || ((c) == ':') || \
((c) == '.'))
#ifndef GST_DISABLE_REGISTRY
/* Secret variable to initialise gst without registry cache */
extern gboolean _gst_disable_registry_cache;
#endif
/*** debugging categories *****************************************************/
#ifndef GST_REMOVE_GST_DEBUG
......
This diff is collapsed.
/* GStreamer
* Copyright (C) 2008 Jan Schmidt <jan.schmidt@sun.com>
*
* gstpluginloader.h: Helper for out-of-process plugin loading. Private header.
*
* 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.
*/
#ifndef __GST_PLUGINLOADER_H__
#define __GST_PLUGINLOADER_H__
G_BEGIN_DECLS
typedef struct _GstPluginLoader GstPluginLoader;
typedef struct _GstPluginLoaderFuncs {
GstPluginLoader * (*create)(GstRegistry *registry);
gboolean (*destroy)(GstPluginLoader *loader);
gboolean (*load)(GstPluginLoader *loader, const gchar *filename);
} GstPluginLoaderFuncs;
extern const GstPluginLoaderFuncs _priv_gst_plugin_loader_funcs;
G_END_DECLS
#endif /* __GST_PLUGINLOADER_H__ */
This diff is collapsed.
......@@ -24,7 +24,6 @@
#ifndef __GST_REGISTRY_H__
#define __GST_REGISTRY_H__
#include <stdio.h> /* FIXME: because of cache_file below */
#include <gst/gstconfig.h>
#include <gst/gstplugin.h>
#include <gst/gstpluginfeature.h>
......
This diff is collapsed.
......@@ -33,6 +33,8 @@
#include <gst/gstpad.h>
#include <gst/gstregistry.h>
G_BEGIN_DECLS
/*
* GST_MAGIC_BINARY_REGISTRY_STR:
*
......@@ -68,117 +70,11 @@ typedef struct _GstBinaryRegistryMagic
gchar 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
{
gpointer data;
guint size;
guint flags;
gboolean align;
} GstBinaryChunk;
/*
* GstBinaryPluginElement:
*
* @nfeatures: says how many binary plugin feature structures we will have
* right after the structure itself.
*
* A structure containing (staticely) every information needed for a plugin
*/
typedef struct _GstBinaryPluginElement
{
gulong file_size;
gulong file_mtime;
guint n_deps;
guint nfeatures;
} GstBinaryPluginElement;
/* GstBinaryDep:
*/
typedef struct _GstBinaryDep
{
guint flags;
guint n_env_vars;
guint n_paths;
guint n_names;
guint env_hash;
guint stat_hash;
} GstBinaryDep;
/*
* GstBinaryPluginFeature:
* @rank: rank of the feature
*
* A structure containing the plugin features
*/
typedef struct _GstBinaryPluginFeature
{
gulong rank;
} GstBinaryPluginFeature;
/*
* GstBinaryElementFactory:
* @npadtemplates: stores the number of GstBinaryPadTemplate structures
* following the structure
* @ninterfaces: stores the number of interface names following the structure
* @nuriprotocols: stores the number of protocol strings following the structure
*
* A structure containing the element factory fields
*/
typedef struct _GstBinaryElementFactory
{
GstBinaryPluginFeature plugin_feature;
guint npadtemplates;
guint ninterfaces;
guint nuriprotocols;
} GstBinaryElementFactory;
/*
* GstBinaryTypeFindFactory:
* @nextensions: stores the number of typefind extensions
*
* A structure containing the element factory fields
*/
typedef struct _GstBinaryTypeFindFactory
{
GstBinaryPluginFeature plugin_feature;
guint nextensions;
} GstBinaryTypeFindFactory;
/*
* GstBinaryPadTemplate:
*
* A structure containing the static pad templates of a plugin feature
*/
typedef struct _GstBinaryPadTemplate
{
guint direction; /* Either 0:"sink" or 1:"src" */
GstPadPresence presence;
} GstBinaryPadTemplate;
/* Function prototypes */
gboolean gst_registry_binary_write_cache(GstRegistry *registry, const char *location);
gboolean gst_registry_binary_read_cache(GstRegistry *registry, const char *location);
G_END_DECLS
#endif /* !__GST_REGISTRYBINARY_H__ */
This diff is collapsed.
/* GStreamer
* Copyright (C) 2006 Josep Torra <josep@fluendo.com>
* Copyright (C) 2006 Mathieu Garcia <matthieu@fluendo.com>
* Copyright (C) 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.
*/
#ifndef __GST_REGISTRYCHUNKS_H__
#define __GST_REGISTRYCHUNKS_H__
#include <gst/gstpad.h>
#include <gst/gstregistry.h>
/*
* we reference strings directly from the plugins and in this case set CONST to
* avoid freeing them
*/
enum {
GST_REGISTRY_CHUNK_FLAG_NONE = 0,
GST_REGISTRY_CHUNK_FLAG_CONST = 1
};
/*
* GstRegistryChunk:
*
* Header for binary blobs
*/
typedef struct _GstRegistryChunk
{
gpointer data;
guint size;
guint flags;
gboolean align;
} GstRegistryChunk;
/*
* GstRegistryChunkPluginElement:
*
* @n_deps: Says how many dependency structures follows.
*
* @nfeatures: says how many binary plugin feature structures we will have
* right after the structure itself.
*
* A structure containing (staticely) every information needed for a plugin
*/
typedef struct _GstRegistryChunkPluginElement
{
gulong file_size;
gulong file_mtime;
guint n_deps;
guint nfeatures;
} GstRegistryChunkPluginElement;
/* GstRegistryChunkDep:
*/
typedef struct _GstRegistryChunkDep
{
guint flags;
guint n_env_vars;
guint n_paths;
guint n_names;
guint env_hash;
guint stat_hash;
} GstRegistryChunkDep;
/*
* GstRegistryChunkPluginFeature:
* @rank: rank of the feature
*
* A structure containing the plugin features
*/
typedef struct _GstRegistryChunkPluginFeature
{
gulong rank;
} GstRegistryChunkPluginFeature;
/*
* GstRegistryChunkElementFactory:
* @npadtemplates: stores the number of GstRegistryChunkPadTemplate structures
* following the structure
* @ninterfaces: stores the number of interface names following the structure
* @nuriprotocols: stores the number of protocol strings following the structure
*
* A structure containing the element factory fields
*/
typedef struct _GstRegistryChunkElementFactory
{
GstRegistryChunkPluginFeature plugin_feature;
guint npadtemplates;
guint ninterfaces;
guint nuriprotocols;
} GstRegistryChunkElementFactory;
/*
* GstRegistryChunkTypeFindFactory:
* @nextensions: stores the number of typefind extensions
*
* A structure containing the element factory fields
*/
typedef struct _GstRegistryChunkTypeFindFactory
{
GstRegistryChunkPluginFeature plugin_feature;
guint nextensions;
} GstRegistryChunkTypeFindFactory;
/*
* GstRegistryChunkPadTemplate:
*
* A structure containing the static pad templates of a plugin feature
*/
typedef struct _GstRegistryChunkPadTemplate
{
guint direction; /* Either 0:"sink" or 1:"src" */
GstPadPresence presence;
} GstRegistryChunkPadTemplate;
G_BEGIN_DECLS
gboolean
_priv_gst_registry_chunks_save_plugin (GList ** list, GstRegistry * registry,
GstPlugin * plugin);
gboolean
_priv_gst_registry_chunks_load_plugin (GstRegistry * registry, gchar ** in,
gchar *end, GstPlugin **out_plugin);
G_END_DECLS
#endif /* __GST_REGISTRYCHUNKS_H__ */
......@@ -18,7 +18,13 @@ endif
endif
endif
if GST_DISABLE_REGISTRY
SUBDIRS_HELPERS =
else
SUBDIRS_HELPERS = helpers
endif
SUBDIRS_ALWAYS = base controller dataprotocol
SUBDIRS = $(SUBDIRS_ALWAYS) $(SUBDIRS_CHECK) $(SUBDIRS_NET)
DIST_SUBDIRS = $(SUBDIRS_ALWAYS) check net
SUBDIRS = $(SUBDIRS_ALWAYS) $(SUBDIRS_CHECK) $(SUBDIRS_NET) $(SUBDIRS_HELPERS)
DIST_SUBDIRS = $(SUBDIRS_ALWAYS) check net helpers
# helpers_PROGRAMS = plugin-scanner
# FIXME: Subst helpersdir in configure.ac
noinst_PROGRAMS = plugin-scanner
plugin_scanner_SOURCES = plugin-scanner.c
plugin_scanner_CFLAGS = $(GST_OBJ_CFLAGS)
plugin_scanner_LDFLAGS = $(GST_OBJ_LIBS)
/* GStreamer
* Copyright (C) 2008 Jan Schmidt <jan.schmidt@sun.com>
*
* plugin-scanner.c: tool to load plugins out of process for scanning
*
* 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.
*
* Helper binary that does plugin-loading out of process and feeds results
* back to the parent over fds.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h>
#include <gst/gst.h>
#include <gst/gst_private.h>
int
main (int argc, char *argv[])
{
gboolean res;
char **my_argv;
int my_argc;
if (argc != 2 || strcmp (argv[1], "-l"))
return 1;
if (!g_thread_supported ())
g_thread_init (NULL);
my_argc = 2;
my_argv = g_malloc (my_argc * sizeof (char *));
my_argv[0] = argv[0];
my_argv[1] = "--gst-disable-registry-update";
#ifndef GST_DISABLE_REGISTRY
_gst_disable_registry_cache = TRUE;
#endif
res = gst_init_check (&my_argc, &my_argv, NULL);
g_free (my_argv);
if (!res)
return 1;
/* Create registry scanner listener and run */
if (!_gst_plugin_loader_client_run ())
return 1;
return 0;
}
......@@ -34,6 +34,11 @@ plugin_name_cmp (GstPlugin * a, GstPlugin * b)
return strcmp (name_a, name_b);
}
static gint
plugin_ptr_cmp (GstPlugin * a, GstPlugin * b)
{
return (a == b) ? 0 : 1;
}
static void
print_plugin (const gchar * marker, GstRegistry * registry, GstPlugin * plugin)
......@@ -43,8 +48,9 @@ print_plugin (const gchar * marker, GstRegistry * registry, GstPlugin * plugin)
name = gst_plugin_get_name (plugin);
GST_DEBUG ("%s: plugin %p %d %s", marker, plugin,
GST_OBJECT_REFCOUNT (plugin), name);
GST_DEBUG ("%s: plugin %p %d %s file: %s", marker, plugin,
GST_OBJECT_REFCOUNT (plugin), name,
GST_STR_NULL (gst_plugin_get_filename (plugin)));
features = gst_registry_get_feature_list_by_plugin (registry, name);
for (f = features; f != NULL; f = f->next) {
......@@ -100,9 +106,9 @@ GST_START_TEST (test_registry_update)
GST_LOG (" -----------------------------------");
/* static plugins should have the same refcount as before (ie. 2), whereas
* file-based plugins should have been replaced by a newly-created objects
* (when reading the updated registry.xml file), so there should be only one
* reference left for those, and that's ours */
* file-based plugins *may* have been replaced by a newly-created object
* if the on-disk file changed (and was not yet loaded). There should be
* only one reference left for those, and that's ours */
for (l = plugins_before; l; l = l->next) {
GstPlugin *plugin;
......@@ -111,8 +117,8 @@ GST_START_TEST (test_registry_update)
print_plugin ("before2", registry, plugin);
if (gst_plugin_get_filename (plugin)) {
/* file-based plugin */
ASSERT_OBJECT_REFCOUNT (plugin, "plugin", 1);
/* file-based plugin. */
ASSERT_OBJECT_REFCOUNT_BETWEEN (plugin, "plugin", 1, 2);
} else {
/* static plugin */
ASSERT_OBJECT_REFCOUNT (plugin, "plugin", 2);
......@@ -123,20 +129,27 @@ GST_START_TEST (test_registry_update)
plugins_after = gst_registry_get_plugin_list (registry);
for (l = plugins_after; l; l = l->next) {
GstPlugin *plugin;
plugin = GST_PLUGIN (l->data);
GstPlugin *plugin = GST_PLUGIN (l->data);
print_plugin ("after ", registry, plugin);
/* file-based plugins should have a refcount of 2 (one for the registry,
* one for us for the list), static plugins should have one of 3 (one for
* the registry, one for the new list and one for the old list).
* one for us for the list) or 3 (one for the registry, one for the before
* list, one for the after list), static plugins should have one of 3
* (one for the registry, one for the new list and one for the old list).
* This implicitly also makes sure that all static plugins are the same
* objects as they were before and that all non-static ones have been
* objects as they were before. Non-static ones may or may not have been
* replaced by new objects */
if (gst_plugin_get_filename (plugin)) {
ASSERT_OBJECT_REFCOUNT (plugin, "plugin", 2);
if (g_list_find_custom (plugins_before, plugin,
(GCompareFunc) plugin_ptr_cmp) != NULL) {
/* Same plugin existed in the before list. Refcount must be 3 */
ASSERT_OBJECT_REFCOUNT (plugin, "plugin", 3);
} else {
/* This plugin is newly created, so should only exist in the after list
* and the registry: Refcount must be 2 */
ASSERT_OBJECT_REFCOUNT (plugin, "plugin", 2);
}
} else {
ASSERT_OBJECT_REFCOUNT (plugin, "plugin", 3);
}
......@@ -165,15 +178,19 @@ GST_START_TEST (test_registry_update)
new_identity = gst_registry_lookup_feature (registry, "identity");
fail_unless (new_identity != NULL, "Can't find plugin feature 'identity'");
#if 0
fail_unless (old_identity != new_identity, "Old and new 'identity' feature "
"should be different but are the same object");
ASSERT_OBJECT_REFCOUNT (old_identity, "old identity feature after update", 1);
#endif
new_pipeline = gst_registry_lookup_feature (registry, "pipeline");
fail_unless (new_pipeline != NULL, "Can't find plugin feature 'pipeline'");
#if 0
fail_unless (old_pipeline == new_pipeline, "Old and new 'pipeline' feature "
"objects should be the same, but are different objects");
#endif
gst_plugin_list_free (plugins_before);
plugins_before = NULL;
......
......@@ -42,8 +42,10 @@ EXPORTS
_gst_debug_get_category
_gst_debug_nameof_funcptr
_gst_debug_register_funcptr
_gst_disable_registry_cache DATA
_gst_element_error_printf
_gst_elementclass_factory DATA
_gst_plugin_loader_client_run
_gst_plugin_register_static
_gst_trace_add_entry
_gst_trace_mutex DATA
......
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