4 int main(int argc,char *argv[]) {
6 xmlNodePtr factorynode, padnode, argnode, optionnode;
7 GList *plugins, *features, *padtemplates;
11 GstPadTemplate *padtemplate;
12 GParamSpec **property_specs;
13 gint num_properties,i;
15 gst_debug_set_categories(0);
16 gst_info_set_categories(0);
17 gst_init(&argc,&argv);
19 doc = xmlNewDoc("1.0");
20 doc->xmlRootNode = xmlNewDocNode(doc, NULL, "GST-CompletionRegistry", NULL);
22 plugins = g_list_copy(gst_registry_pool_plugin_list());
26 plugin = (GstPlugin *)(plugins->data);
27 plugins = g_list_next (plugins);
29 features = g_list_copy(gst_plugin_get_feature_list(plugin));
31 GstPluginFeature *feature;
32 GstElementFactory *factory;
34 feature = GST_PLUGIN_FEATURE (features->data);
35 features = g_list_next (features);
37 if (!GST_IS_ELEMENT_FACTORY (feature))
40 factory = GST_ELEMENT_FACTORY (feature);
42 factorynode = xmlNewChild (doc->xmlRootNode, NULL, "element", NULL);
43 xmlNewChild (factorynode, NULL, "name",
44 GST_PLUGIN_FEATURE_NAME(factory));
46 element = gst_element_factory_create(factory,NULL);
47 GST_DEBUG(GST_CAT_PLUGIN_LOADING, "adding factory %s",
48 GST_PLUGIN_FEATURE_NAME(factory));
49 if (element == NULL) {
50 fprintf(stderr,"couldn't construct element from factory %s\n",
51 gst_object_get_name (GST_OBJECT (factory)));
55 /* write out the padtemplates */
56 padtemplates = factory->padtemplates;
57 while (padtemplates) {
58 padtemplate = (GstPadTemplate *)(padtemplates->data);
59 padtemplates = g_list_next (padtemplates);
61 if (padtemplate->direction == GST_PAD_SRC)
62 padnode = xmlNewChild (factorynode, NULL, "srcpadtemplate", padtemplate->name_template);
63 else if (padtemplate->direction == GST_PAD_SINK)
64 padnode = xmlNewChild (factorynode, NULL, "sinkpadtemplate", padtemplate->name_template);
67 pads = gst_element_get_pad_list (element);
69 pad = (GstPad *)(pads->data);
70 pads = g_list_next (pads);
72 if (GST_PAD_DIRECTION(pad) == GST_PAD_SRC)
73 padnode = xmlNewChild (factorynode, NULL, "srcpad", GST_PAD_NAME(pad));
74 else if (GST_PAD_DIRECTION(pad) == GST_PAD_SINK)
75 padnode = xmlNewChild (factorynode, NULL, "sinkpad", GST_PAD_NAME(pad));
78 /* write out the args */
79 property_specs = g_object_class_list_properties(G_OBJECT_GET_CLASS (element), &num_properties);
80 for (i=0;i<num_properties;i++) {
81 GParamSpec *param = property_specs[i];
82 argnode = xmlNewChild (factorynode, NULL, "argument", param->name);
83 if (param->value_type == GST_TYPE_FILENAME) {
84 xmlNewChild (argnode, NULL, "filename", NULL);
85 } else if (G_IS_PARAM_SPEC_ENUM (param) == G_TYPE_ENUM) {
89 values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
90 for (j=0;values[j].value_name;j++) {
91 gchar *value = g_strdup_printf("%d",values[j].value);
92 optionnode = xmlNewChild (argnode, NULL, "option", value);
93 xmlNewChild (optionnode, NULL, "value_nick", values[j].value_nick);
102 xmlSaveFormatFile(GST_CACHE_DIR "/compreg.xml",doc,1);
104 xmlSaveFile(GST_CACHE_DIR "/compreg.xml",doc);