7 GST_DEBUG_CATEGORY_STATIC(debug_compprep);
8 #define GST_CAT_DEFAULT debug_compprep
10 int main(int argc,char *argv[]) {
12 xmlNodePtr factorynode, padnode, argnode, optionnode;
13 GList *plugins, *features, *padtemplates;
17 GstPadTemplate *padtemplate;
18 GParamSpec **property_specs;
19 guint num_properties,i;
21 gst_init(&argc,&argv);
22 GST_DEBUG_CATEGORY_INIT (debug_compprep, "compprep", GST_DEBUG_BOLD, "gst-compprep application");
24 doc = xmlNewDoc("1.0");
25 doc->xmlRootNode = xmlNewDocNode(doc, NULL, "GST-CompletionRegistry", NULL);
27 plugins = g_list_copy(gst_registry_pool_plugin_list());
31 plugin = (GstPlugin *)(plugins->data);
32 plugins = g_list_next (plugins);
34 features = g_list_copy(gst_plugin_get_feature_list(plugin));
36 GstPluginFeature *feature;
37 GstElementFactory *factory;
39 feature = GST_PLUGIN_FEATURE (features->data);
40 features = g_list_next (features);
42 if (!GST_IS_ELEMENT_FACTORY (feature))
45 factory = GST_ELEMENT_FACTORY (feature);
47 factorynode = xmlNewChild (doc->xmlRootNode, NULL, "element", NULL);
48 xmlNewChild (factorynode, NULL, "name",
49 GST_PLUGIN_FEATURE_NAME(factory));
51 element = gst_element_factory_create(factory,NULL);
52 GST_DEBUG ("adding factory %s", GST_PLUGIN_FEATURE_NAME(factory));
53 if (element == NULL) {
54 GST_ERROR ("couldn't construct element from factory %s\n",
55 gst_object_get_name (GST_OBJECT (factory)));
59 /* write out the padtemplates */
60 padtemplates = factory->padtemplates;
61 while (padtemplates) {
62 padtemplate = (GstPadTemplate *)(padtemplates->data);
63 padtemplates = g_list_next (padtemplates);
65 if (padtemplate->direction == GST_PAD_SRC)
66 padnode = xmlNewChild (factorynode, NULL, "srcpadtemplate", padtemplate->name_template);
67 else if (padtemplate->direction == GST_PAD_SINK)
68 padnode = xmlNewChild (factorynode, NULL, "sinkpadtemplate", padtemplate->name_template);
71 pads = gst_element_get_pad_list (element);
73 pad = (GstPad *)(pads->data);
74 pads = g_list_next (pads);
76 if (GST_PAD_DIRECTION(pad) == GST_PAD_SRC)
77 padnode = xmlNewChild (factorynode, NULL, "srcpad", GST_PAD_NAME(pad));
78 else if (GST_PAD_DIRECTION(pad) == GST_PAD_SINK)
79 padnode = xmlNewChild (factorynode, NULL, "sinkpad", GST_PAD_NAME(pad));
82 /* write out the args */
83 property_specs = g_object_class_list_properties(G_OBJECT_GET_CLASS (element), &num_properties);
84 for (i=0;i<num_properties;i++) {
85 GParamSpec *param = property_specs[i];
86 argnode = xmlNewChild (factorynode, NULL, "argument", param->name);
87 if (param->value_type == GST_TYPE_URI) {
88 xmlNewChild (argnode, NULL, "filename", NULL);
89 } else if (G_IS_PARAM_SPEC_ENUM (param) == G_TYPE_ENUM) {
93 values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values;
94 for (j=0;values[j].value_name;j++) {
95 gchar *value = g_strdup_printf("%d",values[j].value);
96 optionnode = xmlNewChild (argnode, NULL, "option", value);
97 xmlNewChild (optionnode, NULL, "value_nick", values[j].value_nick);
106 xmlSaveFormatFile(GST_CACHE_DIR "/compreg.xml",doc,1);
108 xmlSaveFile(GST_CACHE_DIR "/compreg.xml",doc);