4 int main(int argc,char *argv[]) {
6 xmlNodePtr factorynode, padnode, argnode, optionnode;
7 GList *plugins, *features, *padtemplates, *pads;
10 GstPadTemplate *padtemplate;
11 GParamSpec **property_specs;
12 gint num_properties,i;
14 gst_debug_set_categories(0);
15 gst_info_set_categories(0);
16 gst_init(&argc,&argv);
18 doc = xmlNewDoc("1.0");
19 doc->xmlRootNode = xmlNewDocNode(doc, NULL, "GST-CompletionRegistry", NULL);
21 plugins = gst_plugin_get_list();
25 plugin = (GstPlugin *)(plugins->data);
26 plugins = g_list_next (plugins);
28 features = gst_plugin_get_feature_list(plugin);
30 GstPluginFeature *feature;
31 GstElementFactory *factory;
33 feature = GST_PLUGIN_FEATURE (features->data);
34 features = g_list_next (features);
36 if (!GST_IS_ELEMENTFACTORY (feature))
39 factory = GST_ELEMENTFACTORY (feature);
41 factorynode = xmlNewChild (doc->xmlRootNode, NULL, "element", NULL);
42 xmlNewChild (factorynode, NULL, "name", gst_object_get_name (GST_OBJECT (factory)));
44 element = gst_elementfactory_create(factory,"element");
45 GST_DEBUG(GST_CAT_PLUGIN_LOADING, "adding factory %s\n",
46 gst_object_get_name (GST_OBJECT (factory)));
47 if (element == NULL) {
48 fprintf(stderr,"couldn't construct element from factory %s\n",
49 gst_object_get_name (GST_OBJECT (factory)));
53 /* write out the padtemplates */
54 padtemplates = factory->padtemplates;
55 while (padtemplates) {
56 padtemplate = (GstPadTemplate *)(padtemplates->data);
57 padtemplates = g_list_next (padtemplates);
59 if (padtemplate->direction == GST_PAD_SRC)
60 padnode = xmlNewChild (factorynode, NULL, "srcpadtemplate", padtemplate->name_template);
61 else if (padtemplate->direction == GST_PAD_SINK)
62 padnode = xmlNewChild (factorynode, NULL, "sinkpadtemplate", padtemplate->name_template);
65 pads = gst_element_get_pad_list (element);
67 pad = (GstPad *)(pads->data);
68 pads = g_list_next (pads);
70 if (GST_PAD_DIRECTION(pad) == GST_PAD_SRC)
71 padnode = xmlNewChild (factorynode, NULL, "srcpad", GST_PAD_NAME(pad));
72 else if (GST_PAD_DIRECTION(pad) == GST_PAD_SINK)
73 padnode = xmlNewChild (factorynode, NULL, "sinkpad", GST_PAD_NAME(pad));
76 /* write out the args */
77 property_specs = g_object_class_list_properties(G_OBJECT_GET_CLASS (element), &num_properties);
78 for (i=0;i<num_properties;i++) {
79 GParamSpec *param = property_specs[i];
80 argnode = xmlNewChild (factorynode, NULL, "argument", param->name);
81 if (param->value_type == GST_TYPE_FILENAME) {
82 xmlNewChild (argnode, NULL, "filename", NULL);
83 } else if (G_IS_PARAM_SPEC_ENUM (param) == G_TYPE_ENUM) {
87 values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
88 for (j=0;values[j].value_name;j++) {
89 gchar *value = g_strdup_printf("%d",values[j].value);
90 optionnode = xmlNewChild (argnode, NULL, "option", value);
91 xmlNewChild (optionnode, NULL, "value_nick", values[j].value_nick);
100 xmlSaveFormatFile(GST_CONFIG_DIR "/compreg.xml",doc,1);
102 xmlSaveFile(GST_CONFIG_DIR "/compreg.xml",doc);