9 GST_DEBUG_CATEGORY_STATIC(debug_compprep);
10 #define GST_CAT_DEFAULT debug_compprep
12 int main(int argc,char *argv[]) {
14 xmlNodePtr factorynode, padnode, argnode, optionnode;
15 GList *plugins, *features, *padtemplates;
19 GstPadTemplate *padtemplate;
20 GParamSpec **property_specs;
21 guint num_properties,i;
23 setlocale (LC_ALL, "");
25 gst_init(&argc,&argv);
26 GST_DEBUG_CATEGORY_INIT (debug_compprep, "compprep", GST_DEBUG_BOLD, "gst-compprep application");
28 doc = xmlNewDoc("1.0");
29 doc->xmlRootNode = xmlNewDocNode(doc, NULL, "GST-CompletionRegistry", NULL);
31 plugins = g_list_copy(gst_registry_pool_plugin_list());
35 plugin = (GstPlugin *)(plugins->data);
36 plugins = g_list_next (plugins);
38 features = g_list_copy(gst_plugin_get_feature_list(plugin));
40 GstPluginFeature *feature;
41 GstElementFactory *factory;
43 feature = GST_PLUGIN_FEATURE (features->data);
44 features = g_list_next (features);
46 if (!GST_IS_ELEMENT_FACTORY (feature))
49 factory = GST_ELEMENT_FACTORY (feature);
51 factorynode = xmlNewChild (doc->xmlRootNode, NULL, "element", NULL);
52 xmlNewChild (factorynode, NULL, "name",
53 GST_PLUGIN_FEATURE_NAME(factory));
55 element = gst_element_factory_create(factory,NULL);
56 GST_DEBUG ("adding factory %s", GST_PLUGIN_FEATURE_NAME(factory));
57 if (element == NULL) {
58 GST_ERROR ("couldn't construct element from factory %s\n",
59 gst_object_get_name (GST_OBJECT (factory)));
63 /* write out the padtemplates */
64 padtemplates = factory->padtemplates;
65 while (padtemplates) {
66 padtemplate = (GstPadTemplate *)(padtemplates->data);
67 padtemplates = g_list_next (padtemplates);
69 if (padtemplate->direction == GST_PAD_SRC)
70 padnode = xmlNewChild (factorynode, NULL, "srcpadtemplate", padtemplate->name_template);
71 else if (padtemplate->direction == GST_PAD_SINK)
72 padnode = xmlNewChild (factorynode, NULL, "sinkpadtemplate", padtemplate->name_template);
75 pads = gst_element_get_pad_list (element);
77 pad = (GstPad *)(pads->data);
78 pads = g_list_next (pads);
80 if (GST_PAD_DIRECTION(pad) == GST_PAD_SRC)
81 padnode = xmlNewChild (factorynode, NULL, "srcpad", GST_PAD_NAME(pad));
82 else if (GST_PAD_DIRECTION(pad) == GST_PAD_SINK)
83 padnode = xmlNewChild (factorynode, NULL, "sinkpad", GST_PAD_NAME(pad));
86 /* write out the args */
87 property_specs = g_object_class_list_properties(G_OBJECT_GET_CLASS (element), &num_properties);
88 for (i=0;i<num_properties;i++) {
89 GParamSpec *param = property_specs[i];
90 argnode = xmlNewChild (factorynode, NULL, "argument", param->name);
91 if (param->value_type == GST_TYPE_URI) {
92 xmlNewChild (argnode, NULL, "filename", NULL);
93 } else if (G_IS_PARAM_SPEC_ENUM (param) == G_TYPE_ENUM) {
97 values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
98 for (j=0;values[j].value_name;j++) {
99 gchar *value = g_strdup_printf("%d",values[j].value);
100 optionnode = xmlNewChild (argnode, NULL, "option", value);
101 xmlNewChild (optionnode, NULL, "value_nick", values[j].value_nick);
110 xmlSaveFormatFile(GST_CACHE_DIR "/compreg.xml",doc,1);
112 xmlSaveFile(GST_CACHE_DIR "/compreg.xml",doc);