1 | #include <gst/gst.h> |
---|
2 | #include "config.h" |
---|
3 | |
---|
4 | int main(int argc,char *argv[]) { |
---|
5 | xmlDocPtr doc; |
---|
6 | xmlNodePtr factorynode, padnode, argnode, optionnode; |
---|
7 | GList *plugins, *features, *padtemplates; |
---|
8 | const GList *pads; |
---|
9 | GstElement *element; |
---|
10 | GstPad *pad; |
---|
11 | GstPadTemplate *padtemplate; |
---|
12 | GParamSpec **property_specs; |
---|
13 | gint num_properties,i; |
---|
14 | |
---|
15 | gst_debug_set_categories(0); |
---|
16 | gst_info_set_categories(0); |
---|
17 | gst_init(&argc,&argv); |
---|
18 | |
---|
19 | doc = xmlNewDoc("1.0"); |
---|
20 | doc->xmlRootNode = xmlNewDocNode(doc, NULL, "GST-CompletionRegistry", NULL); |
---|
21 | |
---|
22 | plugins = g_list_copy(gst_registry_pool_plugin_list()); |
---|
23 | while (plugins) { |
---|
24 | GstPlugin *plugin; |
---|
25 | |
---|
26 | plugin = (GstPlugin *)(plugins->data); |
---|
27 | plugins = g_list_next (plugins); |
---|
28 | |
---|
29 | features = g_list_copy(gst_plugin_get_feature_list(plugin)); |
---|
30 | while (features) { |
---|
31 | GstPluginFeature *feature; |
---|
32 | GstElementFactory *factory; |
---|
33 | |
---|
34 | feature = GST_PLUGIN_FEATURE (features->data); |
---|
35 | features = g_list_next (features); |
---|
36 | |
---|
37 | if (!GST_IS_ELEMENT_FACTORY (feature)) |
---|
38 | continue; |
---|
39 | |
---|
40 | factory = GST_ELEMENT_FACTORY (feature); |
---|
41 | |
---|
42 | factorynode = xmlNewChild (doc->xmlRootNode, NULL, "element", NULL); |
---|
43 | xmlNewChild (factorynode, NULL, "name", |
---|
44 | GST_PLUGIN_FEATURE_NAME(factory)); |
---|
45 | |
---|
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))); |
---|
52 | return 1; |
---|
53 | } |
---|
54 | |
---|
55 | /* write out the padtemplates */ |
---|
56 | padtemplates = factory->padtemplates; |
---|
57 | while (padtemplates) { |
---|
58 | padtemplate = (GstPadTemplate *)(padtemplates->data); |
---|
59 | padtemplates = g_list_next (padtemplates); |
---|
60 | |
---|
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); |
---|
65 | } |
---|
66 | |
---|
67 | pads = gst_element_get_pad_list (element); |
---|
68 | while (pads) { |
---|
69 | pad = (GstPad *)(pads->data); |
---|
70 | pads = g_list_next (pads); |
---|
71 | |
---|
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)); |
---|
76 | } |
---|
77 | |
---|
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) { |
---|
86 | GEnumValue *values; |
---|
87 | gint j; |
---|
88 | |
---|
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); |
---|
94 | g_free(value); |
---|
95 | } |
---|
96 | } |
---|
97 | } |
---|
98 | } |
---|
99 | } |
---|
100 | |
---|
101 | #ifdef HAVE_LIBXML2 |
---|
102 | xmlSaveFormatFile(GST_CACHE_DIR "/compreg.xml",doc,1); |
---|
103 | #else |
---|
104 | xmlSaveFile(GST_CACHE_DIR "/compreg.xml",doc); |
---|
105 | #endif |
---|
106 | |
---|
107 | return 0; |
---|
108 | } |
---|