9 GST_DEBUG_CATEGORY_STATIC (debug_compprep);
10 #define GST_CAT_DEFAULT debug_compprep
11 #define GST_COMPREG_FILE (GST_CACHE_DIR "/compreg.xml")
14 #if LIBXML_VERSION >= 20600
16 handle_xmlerror (void *userData, xmlErrorPtr error)
18 g_print ("Error writing the completion registry: %s, %s\n", GST_COMPREG_FILE,
25 main (int argc, char *argv[])
28 xmlNodePtr factorynode, padnode, argnode, optionnode;
29 GList *plugins, *features, *padtemplates;
33 GstPadTemplate *padtemplate;
34 GParamSpec **property_specs;
35 guint num_properties, i;
37 setlocale (LC_ALL, "");
39 gst_init (&argc, &argv);
40 GST_DEBUG_CATEGORY_INIT (debug_compprep, "compprep", GST_DEBUG_BOLD,
41 "gst-compprep application");
43 doc = xmlNewDoc ("1.0");
44 doc->xmlRootNode = xmlNewDocNode (doc, NULL, "GST-CompletionRegistry", NULL);
46 plugins = g_list_copy (gst_registry_pool_plugin_list ());
50 plugin = (GstPlugin *) (plugins->data);
51 plugins = g_list_next (plugins);
53 features = g_list_copy (gst_plugin_get_feature_list (plugin));
55 GstPluginFeature *feature;
56 GstElementFactory *factory;
58 feature = GST_PLUGIN_FEATURE (features->data);
59 features = g_list_next (features);
61 if (!GST_IS_ELEMENT_FACTORY (feature))
64 factory = GST_ELEMENT_FACTORY (feature);
66 factorynode = xmlNewChild (doc->xmlRootNode, NULL, "element", NULL);
67 xmlNewChild (factorynode, NULL, "name",
68 GST_PLUGIN_FEATURE_NAME (factory));
70 element = gst_element_factory_create (factory, NULL);
71 GST_DEBUG ("adding factory %s", GST_PLUGIN_FEATURE_NAME (factory));
72 if (element == NULL) {
73 GST_ERROR ("couldn't construct element from factory %s\n",
74 gst_object_get_name (GST_OBJECT (factory)));
78 /* write out the padtemplates */
79 padtemplates = factory->padtemplates;
80 while (padtemplates) {
81 padtemplate = (GstPadTemplate *) (padtemplates->data);
82 padtemplates = g_list_next (padtemplates);
84 if (padtemplate->direction == GST_PAD_SRC)
86 xmlNewChild (factorynode, NULL, "srcpadtemplate",
87 padtemplate->name_template);
88 else if (padtemplate->direction == GST_PAD_SINK)
90 xmlNewChild (factorynode, NULL, "sinkpadtemplate",
91 padtemplate->name_template);
96 pad = (GstPad *) (pads->data);
97 pads = g_list_next (pads);
99 if (GST_PAD_DIRECTION (pad) == GST_PAD_SRC)
101 xmlNewChild (factorynode, NULL, "srcpad", GST_PAD_NAME (pad));
102 else if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK)
104 xmlNewChild (factorynode, NULL, "sinkpad", GST_PAD_NAME (pad));
107 /* write out the args */
109 g_object_class_list_properties (G_OBJECT_GET_CLASS (element),
111 for (i = 0; i < num_properties; i++) {
112 GParamSpec *param = property_specs[i];
114 argnode = xmlNewChild (factorynode, NULL, "argument", param->name);
115 if (param->value_type == GST_TYPE_URI) {
116 xmlNewChild (argnode, NULL, "filename", NULL);
117 } else if (G_IS_PARAM_SPEC_ENUM (param) == G_TYPE_ENUM) {
121 values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
122 for (j = 0; values[j].value_name; j++) {
123 gchar *value = g_strdup_printf ("%d", values[j].value);
125 optionnode = xmlNewChild (argnode, NULL, "option", value);
126 xmlNewChild (optionnode, NULL, "value_nick", values[j].value_nick);
135 #if LIBXML_VERSION >= 20600
136 xmlSetStructuredErrorFunc (NULL, handle_xmlerror);
138 xmlSaveFormatFile (GST_COMPREG_FILE, doc, 1);
140 xmlSaveFile (GST_COMPREG_FILE, doc);