2003-06-29 14:05:49 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2003-08-19 08:11:58 +00:00
|
|
|
#include <locale.h>
|
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
#include <gst/gst.h>
|
2003-06-29 14:05:49 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (debug_compprep);
|
2003-06-29 14:05:49 +00:00
|
|
|
#define GST_CAT_DEFAULT debug_compprep
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
2001-05-25 21:00:07 +00:00
|
|
|
xmlDocPtr doc;
|
|
|
|
xmlNodePtr factorynode, padnode, argnode, optionnode;
|
2002-09-12 20:52:03 +00:00
|
|
|
GList *plugins, *features, *padtemplates;
|
|
|
|
const GList *pads;
|
2001-05-25 21:00:07 +00:00
|
|
|
GstElement *element;
|
|
|
|
GstPad *pad;
|
|
|
|
GstPadTemplate *padtemplate;
|
2001-06-25 01:20:11 +00:00
|
|
|
GParamSpec **property_specs;
|
2004-03-13 15:27:01 +00:00
|
|
|
guint num_properties, i;
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2003-08-19 08:11:58 +00:00
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_init (&argc, &argv);
|
|
|
|
GST_DEBUG_CATEGORY_INIT (debug_compprep, "compprep", GST_DEBUG_BOLD,
|
|
|
|
"gst-compprep application");
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
doc = xmlNewDoc ("1.0");
|
|
|
|
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "GST-CompletionRegistry", NULL);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
plugins = g_list_copy (gst_registry_pool_plugin_list ());
|
2001-05-25 21:00:07 +00:00
|
|
|
while (plugins) {
|
2001-08-21 20:16:48 +00:00
|
|
|
GstPlugin *plugin;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
plugin = (GstPlugin *) (plugins->data);
|
2001-05-25 21:00:07 +00:00
|
|
|
plugins = g_list_next (plugins);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
features = g_list_copy (gst_plugin_get_feature_list (plugin));
|
2001-08-21 20:16:48 +00:00
|
|
|
while (features) {
|
|
|
|
GstPluginFeature *feature;
|
|
|
|
GstElementFactory *factory;
|
|
|
|
|
|
|
|
feature = GST_PLUGIN_FEATURE (features->data);
|
|
|
|
features = g_list_next (features);
|
|
|
|
|
2002-04-11 20:35:18 +00:00
|
|
|
if (!GST_IS_ELEMENT_FACTORY (feature))
|
2001-08-21 20:16:48 +00:00
|
|
|
continue;
|
|
|
|
|
2002-04-11 20:35:18 +00:00
|
|
|
factory = GST_ELEMENT_FACTORY (feature);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
|
|
|
factorynode = xmlNewChild (doc->xmlRootNode, NULL, "element", NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
xmlNewChild (factorynode, NULL, "name",
|
|
|
|
GST_PLUGIN_FEATURE_NAME (factory));
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
element = gst_element_factory_create (factory, NULL);
|
|
|
|
GST_DEBUG ("adding factory %s", GST_PLUGIN_FEATURE_NAME (factory));
|
2001-05-25 21:00:07 +00:00
|
|
|
if (element == NULL) {
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_ERROR ("couldn't construct element from factory %s\n",
|
|
|
|
gst_object_get_name (GST_OBJECT (factory)));
|
|
|
|
return 1;
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2001-12-14 20:56:51 +00:00
|
|
|
/* write out the padtemplates */
|
2001-05-25 21:00:07 +00:00
|
|
|
padtemplates = factory->padtemplates;
|
|
|
|
while (padtemplates) {
|
2004-03-13 15:27:01 +00:00
|
|
|
padtemplate = (GstPadTemplate *) (padtemplates->data);
|
|
|
|
padtemplates = g_list_next (padtemplates);
|
|
|
|
|
|
|
|
if (padtemplate->direction == GST_PAD_SRC)
|
|
|
|
padnode =
|
|
|
|
xmlNewChild (factorynode, NULL, "srcpadtemplate",
|
|
|
|
padtemplate->name_template);
|
|
|
|
else if (padtemplate->direction == GST_PAD_SINK)
|
|
|
|
padnode =
|
|
|
|
xmlNewChild (factorynode, NULL, "sinkpadtemplate",
|
|
|
|
padtemplate->name_template);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pads = gst_element_get_pad_list (element);
|
|
|
|
while (pads) {
|
2004-03-13 15:27:01 +00:00
|
|
|
pad = (GstPad *) (pads->data);
|
|
|
|
pads = g_list_next (pads);
|
|
|
|
|
|
|
|
if (GST_PAD_DIRECTION (pad) == GST_PAD_SRC)
|
|
|
|
padnode =
|
|
|
|
xmlNewChild (factorynode, NULL, "srcpad", GST_PAD_NAME (pad));
|
|
|
|
else if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK)
|
|
|
|
padnode =
|
|
|
|
xmlNewChild (factorynode, NULL, "sinkpad", GST_PAD_NAME (pad));
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
|
2001-12-14 20:56:51 +00:00
|
|
|
/* write out the args */
|
2004-03-13 15:27:01 +00:00
|
|
|
property_specs =
|
|
|
|
g_object_class_list_properties (G_OBJECT_GET_CLASS (element),
|
|
|
|
&num_properties);
|
|
|
|
for (i = 0; i < num_properties; i++) {
|
|
|
|
GParamSpec *param = property_specs[i];
|
|
|
|
|
|
|
|
argnode = xmlNewChild (factorynode, NULL, "argument", param->name);
|
|
|
|
if (param->value_type == GST_TYPE_URI) {
|
|
|
|
xmlNewChild (argnode, NULL, "filename", NULL);
|
|
|
|
} else if (G_IS_PARAM_SPEC_ENUM (param) == G_TYPE_ENUM) {
|
|
|
|
GEnumValue *values;
|
|
|
|
gint j;
|
|
|
|
|
|
|
|
values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
|
|
|
|
for (j = 0; values[j].value_name; j++) {
|
|
|
|
gchar *value = g_strdup_printf ("%d", values[j].value);
|
|
|
|
|
|
|
|
optionnode = xmlNewChild (argnode, NULL, "option", value);
|
|
|
|
xmlNewChild (optionnode, NULL, "value_nick", values[j].value_nick);
|
|
|
|
g_free (value);
|
|
|
|
}
|
|
|
|
}
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-26 06:58:25 +00:00
|
|
|
#ifdef HAVE_LIBXML2
|
2004-03-13 15:27:01 +00:00
|
|
|
xmlSaveFormatFile (GST_CACHE_DIR "/compreg.xml", doc, 1);
|
2001-12-26 06:58:25 +00:00
|
|
|
#else
|
2004-03-13 15:27:01 +00:00
|
|
|
xmlSaveFile (GST_CACHE_DIR "/compreg.xml", doc);
|
2001-12-26 06:58:25 +00:00
|
|
|
#endif
|
2001-05-25 21:00:07 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|