Use libxml2 for registry parsing, use staticpadtemplates in elementfactories. Makes gst_init() +/- 10x faster.

Original commit message from CVS:
* docs/gst/tmpl/gstelementfactory.sgml:
* gst/gstelement.h:
* gst/gstelementfactory.c: (gst_element_factory_init),
(gst_element_factory_cleanup), (gst_element_register),
(__gst_element_factory_add_static_pad_template),
(gst_element_factory_get_static_pad_templates),
(gst_element_factory_can_src_caps),
(gst_element_factory_can_sink_caps):
* gst/registries/Makefile.am:
* gst/registries/gstlibxmlregistry.c: (gst_xml_registry_get_type),
(gst_xml_registry_class_init), (gst_xml_registry_init),
(gst_xml_registry_new), (gst_xml_registry_set_property),
(gst_xml_registry_get_property), (get_time), (make_dir),
(gst_xml_registry_get_perms_func),
(plugin_times_older_than_recurse), (plugin_times_older_than),
(gst_xml_registry_open_func), (gst_xml_registry_load_func),
(gst_xml_registry_save_func), (gst_xml_registry_close_func),
(add_to_char_array), (read_string), (read_uint), (read_enum),
(load_pad_template), (load_feature), (load_plugin), (load_paths),
(gst_xml_registry_load), (gst_xml_registry_load_plugin),
(gst_xml_registry_save_caps), (gst_xml_registry_save_pad_template),
(gst_xml_registry_save_feature), (gst_xml_registry_save_plugin),
(gst_xml_registry_save), (gst_xml_registry_rebuild_recurse),
(gst_xml_registry_rebuild):
* gst/registries/gstlibxmlregistry.h:
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_pad_templates_info):
* tools/gst-xmlinspect.c: (print_element_info):
Use libxml2 for registry parsing, use staticpadtemplates in
elementfactories. Makes gst_init() +/- 10x faster.
This commit is contained in:
Ronald S. Bultje 2005-04-12 15:00:30 +00:00
parent 499659f65f
commit 560d0ba1de
10 changed files with 1514 additions and 50 deletions

View file

@ -1,3 +1,36 @@
2005-04-12 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* docs/gst/tmpl/gstelementfactory.sgml:
* gst/gstelement.h:
* gst/gstelementfactory.c: (gst_element_factory_init),
(gst_element_factory_cleanup), (gst_element_register),
(__gst_element_factory_add_static_pad_template),
(gst_element_factory_get_static_pad_templates),
(gst_element_factory_can_src_caps),
(gst_element_factory_can_sink_caps):
* gst/registries/Makefile.am:
* gst/registries/gstlibxmlregistry.c: (gst_xml_registry_get_type),
(gst_xml_registry_class_init), (gst_xml_registry_init),
(gst_xml_registry_new), (gst_xml_registry_set_property),
(gst_xml_registry_get_property), (get_time), (make_dir),
(gst_xml_registry_get_perms_func),
(plugin_times_older_than_recurse), (plugin_times_older_than),
(gst_xml_registry_open_func), (gst_xml_registry_load_func),
(gst_xml_registry_save_func), (gst_xml_registry_close_func),
(add_to_char_array), (read_string), (read_uint), (read_enum),
(load_pad_template), (load_feature), (load_plugin), (load_paths),
(gst_xml_registry_load), (gst_xml_registry_load_plugin),
(gst_xml_registry_save_caps), (gst_xml_registry_save_pad_template),
(gst_xml_registry_save_feature), (gst_xml_registry_save_plugin),
(gst_xml_registry_save), (gst_xml_registry_rebuild_recurse),
(gst_xml_registry_rebuild):
* gst/registries/gstlibxmlregistry.h:
* tools/gst-compprep.c: (main):
* tools/gst-inspect.c: (print_pad_templates_info):
* tools/gst-xmlinspect.c: (print_element_info):
Use libxml2 for registry parsing, use staticpadtemplates in
elementfactories. Makes gst_init() +/- 10x faster.
2005-04-12 Wim Taymans <wim@fluendo.com>
* gst/base/Makefile.am:

View file

@ -137,15 +137,6 @@ so that the autopluggers can select a plugin more appropriatly
@Returns:
<!-- ##### FUNCTION gst_element_factory_get_pad_templates ##### -->
<para>
</para>
@factory:
@Returns:
<!-- ##### FUNCTION gst_element_factory_get_uri_type ##### -->
<para>

View file

@ -393,7 +393,7 @@ struct _GstElementFactory {
GstElementDetails details;
GList * padtemplates;
GList * staticpadtemplates;
guint numpadtemplates;
/* URI interface stuff */
@ -425,7 +425,7 @@ G_CONST_RETURN gchar * gst_element_factory_get_klass (GstElementFactory *factor
G_CONST_RETURN gchar * gst_element_factory_get_description (GstElementFactory *factory);
G_CONST_RETURN gchar * gst_element_factory_get_author (GstElementFactory *factory);
guint gst_element_factory_get_num_pad_templates (GstElementFactory *factory);
G_CONST_RETURN GList * gst_element_factory_get_pad_templates (GstElementFactory *factory);
G_CONST_RETURN GList * gst_element_factory_get_static_pad_templates (GstElementFactory *factory);
guint gst_element_factory_get_uri_type (GstElementFactory *factory);
gchar ** gst_element_factory_get_uri_protocols (GstElementFactory *factory);
@ -433,8 +433,8 @@ GstElement* gst_element_factory_create (GstElementFactory *factory,
const gchar *name);
GstElement* gst_element_factory_make (const gchar *factoryname, const gchar *name);
void __gst_element_factory_add_pad_template (GstElementFactory *elementfactory,
GstPadTemplate *templ);
void __gst_element_factory_add_static_pad_template (GstElementFactory *elementfactory,
GstStaticPadTemplate *templ);
void __gst_element_factory_add_interface (GstElementFactory *elementfactory,
const gchar *interfacename);

View file

@ -89,7 +89,7 @@ gst_element_factory_class_init (GstElementFactoryClass * klass)
static void
gst_element_factory_init (GstElementFactory * factory)
{
factory->padtemplates = NULL;
factory->staticpadtemplates = NULL;
factory->numpadtemplates = 0;
factory->uri_type = GST_URI_UNKNOWN;
@ -168,15 +168,23 @@ __gst_element_details_copy (GstElementDetails * dest,
static void
gst_element_factory_cleanup (GstElementFactory * factory)
{
GList *item;
__gst_element_details_clear (&factory->details);
if (factory->type) {
g_type_class_unref (g_type_class_peek (factory->type));
factory->type = 0;
}
g_list_foreach (factory->padtemplates, (GFunc) gst_object_unref, NULL);
g_list_free (factory->padtemplates);
factory->padtemplates = NULL;
for (item = factory->staticpadtemplates; item; item = item->next) {
GstStaticPadTemplate *templ = item->data;
g_free (templ->name_template);
/* FIXME: free caps... */
g_free (templ);
}
g_list_free (factory->staticpadtemplates);
factory->staticpadtemplates = NULL;
factory->numpadtemplates = 0;
factory->uri_type = GST_URI_UNKNOWN;
if (factory->uri_protocols) {
@ -209,6 +217,7 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank,
GType *interfaces;
guint n_interfaces, i;
GstElementClass *klass;
GList *item;
g_return_val_if_fail (name != NULL, FALSE);
g_return_val_if_fail (g_type_is_a (type, GST_TYPE_ELEMENT), FALSE);
@ -232,8 +241,18 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank,
klass = GST_ELEMENT_CLASS (g_type_class_ref (type));
factory->type = type;
__gst_element_details_copy (&factory->details, &klass->details);
factory->padtemplates = g_list_copy (klass->padtemplates);
g_list_foreach (factory->padtemplates, (GFunc) gst_object_ref, NULL);
for (item = klass->padtemplates; item; item = item->next) {
GstPadTemplate *templ = item->data;
GstStaticPadTemplate *newt;
newt = g_new0 (GstStaticPadTemplate, 1);
newt->name_template = g_strdup (templ->name_template);
newt->direction = templ->direction;
newt->presence = templ->presence;
newt->static_caps.string = gst_caps_to_string (templ->caps);
factory->staticpadtemplates =
g_list_append (factory->staticpadtemplates, newt);
}
factory->numpadtemplates = klass->numpadtemplates;
klass->elementfactory = factory;
@ -369,16 +388,14 @@ gst_element_factory_make (const gchar * factoryname, const gchar * name)
}
void
__gst_element_factory_add_pad_template (GstElementFactory * factory,
GstPadTemplate * templ)
__gst_element_factory_add_static_pad_template (GstElementFactory * factory,
GstStaticPadTemplate * templ)
{
g_return_if_fail (factory != NULL);
g_return_if_fail (templ != NULL);
gst_object_ref (GST_OBJECT (templ));
gst_object_sink (GST_OBJECT (templ));
factory->padtemplates = g_list_append (factory->padtemplates, templ);
factory->staticpadtemplates =
g_list_append (factory->staticpadtemplates, templ);
factory->numpadtemplates++;
}
@ -499,7 +516,7 @@ __gst_element_factory_add_interface (GstElementFactory * elementfactory,
}
/**
* gst_element_factory_get_pad_templates:
* gst_element_factory_get_static_pad_templates:
* @factory: a #GstElementFactory
*
* Gets the #GList of padtemplates for this factory.
@ -507,11 +524,11 @@ __gst_element_factory_add_interface (GstElementFactory * elementfactory,
* Returns: the padtemplates
*/
G_CONST_RETURN GList *
gst_element_factory_get_pad_templates (GstElementFactory * factory)
gst_element_factory_get_static_pad_templates (GstElementFactory * factory)
{
g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL);
return factory->padtemplates;
return factory->staticpadtemplates;
}
/**
@ -566,14 +583,14 @@ gst_element_factory_can_src_caps (GstElementFactory * factory,
g_return_val_if_fail (factory != NULL, FALSE);
g_return_val_if_fail (caps != NULL, FALSE);
templates = factory->padtemplates;
templates = factory->staticpadtemplates;
while (templates) {
GstPadTemplate *template = (GstPadTemplate *) templates->data;
GstStaticPadTemplate *template = (GstStaticPadTemplate *) templates->data;
if (template->direction == GST_PAD_SRC) {
if (gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (template),
caps))
if (gst_caps_is_always_compatible (gst_static_caps_get (&template->
static_caps), caps))
return TRUE;
}
templates = g_list_next (templates);
@ -600,14 +617,14 @@ gst_element_factory_can_sink_caps (GstElementFactory * factory,
g_return_val_if_fail (factory != NULL, FALSE);
g_return_val_if_fail (caps != NULL, FALSE);
templates = factory->padtemplates;
templates = factory->staticpadtemplates;
while (templates) {
GstPadTemplate *template = (GstPadTemplate *) templates->data;
GstStaticPadTemplate *template = (GstStaticPadTemplate *) templates->data;
if (template->direction == GST_PAD_SINK) {
if (gst_caps_is_always_compatible (caps,
GST_PAD_TEMPLATE_CAPS (template)))
gst_static_caps_get (&template->static_caps)))
return TRUE;
}
templates = g_list_next (templates);

View file

@ -1,11 +1,17 @@
noinst_LTLIBRARIES = libgstxmlregistry.la
libgstxmlregistry_la_SOURCES = gstxmlregistry.c
if GST_DISABLE_LOADSAVE
xmlregistry_sources = gstxmlregistry.c
else
xmlregistry_sources = gstlibxmlregistry.c
endif
libgstxmlregistry_la_SOURCES = $(xmlregistry_sources)
libgstxmlregistry_la_CFLAGS = $(GST_LIB_CFLAGS)
libgstxmlregistry_la_LIBADD = $(GST_LIB_LIBS)
noinst_HEADERS = gstxmlregistry.h
noinst_HEADERS = gstxmlregistry.h gstlibxmlregistry.h
check_PROGRAMS = registrytest
registrytest_SOURCES = registrytest.c

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,110 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
*
* gstpluginfeature.h: Header for base GstXMLRegistry
*
* 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_XML_REGISTRY_H__
#define __GST_XML_REGISTRY_H__
#include <gst/gstregistry.h>
G_BEGIN_DECLS
#define GST_TYPE_XML_REGISTRY \
(gst_xml_registry_get_type())
#define GST_XML_REGISTRY(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_XML_REGISTRY,GstXMLRegistry))
#define GST_XML_REGISTRY_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_XML_REGISTRY,GstXMLRegistryClass))
#define GST_IS_XML_REGISTRY(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_XML_REGISTRY))
#define GST_IS_XML_REGISTRY_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_XML_REGISTRY))
typedef struct _GstXMLRegistry GstXMLRegistry;
typedef struct _GstXMLRegistryClass GstXMLRegistryClass;
typedef enum {
GST_XML_REGISTRY_NONE,
GST_XML_REGISTRY_TOP,
GST_XML_REGISTRY_PATHS,
GST_XML_REGISTRY_PATH,
GST_XML_REGISTRY_PATHS_DONE,
GST_XML_REGISTRY_PLUGIN,
GST_XML_REGISTRY_FEATURE,
GST_XML_REGISTRY_PADTEMPLATE,
GST_XML_REGISTRY_CAPS,
GST_XML_REGISTRY_STRUCTURE,
GST_XML_REGISTRY_PROPERTIES
} GstXMLRegistryState;
typedef enum {
GST_XML_REGISTRY_READ,
GST_XML_REGISTRY_WRITE
} GstXMLRegistryMode;
typedef void (*GstXMLRegistryGetPerms) (GstXMLRegistry *registry);
typedef gboolean (*GstXMLRegistryParser) (GMarkupParseContext *context,
const gchar *tag,
const gchar *text,
gsize text_len,
GstXMLRegistry *registry,
GError **error);
typedef gboolean (*GstXMLRegistryOpen) (GstXMLRegistry *registry,
GstXMLRegistryMode mode);
typedef gboolean (*GstXMLRegistryLoad) (GstXMLRegistry *registry,
gchar *dest,
gssize *size);
typedef gboolean (*GstXMLRegistrySave) (GstXMLRegistry *registry,
gchar *format,
...);
typedef gboolean (*GstXMLRegistryClose) (GstXMLRegistry *registry);
struct _GstXMLRegistry {
GstRegistry object;
gchar *location;
gboolean open;
FILE *regfile;
};
struct _GstXMLRegistryClass {
GstRegistryClass parent_class;
GstXMLRegistryGetPerms get_perms_func;
GstXMLRegistryOpen open_func;
GstXMLRegistryLoad load_func;
GstXMLRegistrySave save_func;
GstXMLRegistryClose close_func;
};
/* normal GObject stuff */
GType gst_xml_registry_get_type (void);
GstRegistry* gst_xml_registry_new (const gchar *name, const gchar *location);
G_END_DECLS
#endif /* __GST_XML_REGISTRY_H__ */

View file

@ -30,7 +30,7 @@ main (int argc, char *argv[])
const GList *pads;
GstElement *element;
GstPad *pad;
GstPadTemplate *padtemplate;
GstStaticPadTemplate *padtemplate;
GParamSpec **property_specs;
guint num_properties, i;
@ -76,9 +76,9 @@ main (int argc, char *argv[])
}
/* write out the padtemplates */
padtemplates = factory->padtemplates;
padtemplates = factory->staticpadtemplates;
while (padtemplates) {
padtemplate = (GstPadTemplate *) (padtemplates->data);
padtemplate = (GstStaticPadTemplate *) (padtemplates->data);
padtemplates = g_list_next (padtemplates);
if (padtemplate->direction == GST_PAD_SRC)

View file

@ -455,7 +455,7 @@ print_pad_templates_info (GstElement * element, GstElementFactory * factory)
{
GstElementClass *gstelement_class;
const GList *pads;
GstPadTemplate *padtemplate;
GstStaticPadTemplate *padtemplate;
n_print ("Pad Templates:\n");
if (!factory->numpadtemplates) {
@ -465,9 +465,9 @@ print_pad_templates_info (GstElement * element, GstElementFactory * factory)
gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element));
pads = factory->padtemplates;
pads = factory->staticpadtemplates;
while (pads) {
padtemplate = (GstPadTemplate *) (pads->data);
padtemplate = (GstStaticPadTemplate *) (pads->data);
pads = g_list_next (pads);
if (padtemplate->direction == GST_PAD_SRC)
@ -488,9 +488,9 @@ print_pad_templates_info (GstElement * element, GstElementFactory * factory)
} else
n_print (" Availability: UNKNOWN!!!\n");
if (padtemplate->caps) {
if (padtemplate->static_caps.string) {
n_print (" Capabilities:\n");
print_caps (padtemplate->caps, " ");
print_caps (gst_static_caps_get (&padtemplate->static_caps), " ");
}
n_print ("\n");

View file

@ -471,7 +471,7 @@ print_element_info (GstElementFactory * factory)
GList *pads;
GstPad *pad;
GstRealPad *realpad;
GstPadTemplate *padtemplate;
GstStaticPadTemplate *padtemplate;
gint maxlevel = 0;
element = gst_element_factory_create (factory, "element");
@ -496,9 +496,9 @@ print_element_info (GstElementFactory * factory)
PUT_START_TAG (1, "pad-templates");
if (factory->numpadtemplates) {
pads = factory->padtemplates;
pads = factory->staticpadtemplates;
while (pads) {
padtemplate = (GstPadTemplate *) (pads->data);
padtemplate = (GstStaticPadTemplate *) (pads->data);
pads = g_list_next (pads);
PUT_START_TAG (2, "pad-template");
@ -522,8 +522,8 @@ print_element_info (GstElementFactory * factory)
} else
PUT_ESCAPED (3, "presence", "unknown");
if (padtemplate->caps) {
print_caps (padtemplate->caps, 3);
if (padtemplate->static_caps.string) {
print_caps (gst_static_caps_get (&padtemplate->static_caps), 3);
}
PUT_END_TAG (2, "pad-template");
}