2
# vi:si:et:sw=4:sts=4:ts=4
5
examine all plugins and elements and output xml documentation for them
6
used as part of the plugin documentation build
19
PAD_TEMPLATE = """<caps>
21
<direction>%(direction)s</direction>
22
<presence>%(presence)s</presence>
23
<details>%(details)s</details>
26
ELEMENT_TEMPLATE = """<element>
28
<longname>%(longname)s</longname>
29
<class>%(class)s</class>
30
<description>%(description)s</description>
31
<author>%(author)s</author>
37
PLUGIN_TEMPLATE = """<plugin>
39
<description>%(description)s</description>
40
<filename>%(filename)s</filename>
41
<basename>%(basename)s</basename>
42
<version>%(version)s</version>
43
<license>%(license)s</license>
44
<source>%(source)s</source>
45
<package>%(package)s</package>
46
<origin>%(origin)s</origin>
56
line = "&".join(line.split("&"))
57
line = "<".join(line.split("<"))
58
line = ">".join(line.split(">"))
61
def get_offset(indent):
62
return " " * INDENT_SIZE * indent
64
def output_pad_template(pt, indent=0):
65
print "PAD TEMPLATE", pt.name_template
66
paddir = ("unknown","source","sink")
67
padpres = ("always","sometimes","request")
70
'name': xmlencode(pt.name_template),
71
'direction': xmlencode(paddir[pt.direction]),
72
'presence': xmlencode(padpres[pt.presence]),
73
'details': xmlencode(pt.static_caps.string),
75
block = PAD_TEMPLATE % d
77
offset = get_offset(indent)
78
return offset + ("\n" + offset).join(block.split("\n"))
80
def output_element_factory(elf, indent=0):
81
print "ELEMENT", elf.get_name()
84
padtemplates = elf.get_static_pad_templates()
85
for padtemplate in padtemplates:
86
padsoutput.append(output_pad_template(padtemplate, indent))
89
'name': xmlencode(elf.get_name()),
90
'longname': xmlencode(elf.get_longname()),
91
'class': xmlencode(elf.get_klass()),
92
'description': xmlencode(elf.get_description()),
93
'author': xmlencode(elf.get_author()),
94
'pads': "\n".join(padsoutput),
96
block = ELEMENT_TEMPLATE % d
98
offset = get_offset(indent)
99
return offset + ("\n" + offset).join(block.split("\n"))
101
def output_plugin(plugin, indent=0):
102
print "PLUGIN", plugin.get_name()
103
version = plugin.get_version()
106
gst.debug('getting features for plugin %s' % plugin.get_name())
107
registry = gst.registry_get_default()
108
features = registry.get_feature_list_by_plugin(plugin.get_name())
109
gst.debug('plugin %s has %d features' % (plugin.get_name(), len(features)))
110
for feature in features:
111
if isinstance(feature, gst.ElementFactory):
112
elements[feature.get_name()] = feature
113
#gst.debug("got features")
116
keys = elements.keys()
119
feature = elements[name]
120
elementsoutput.append(output_element_factory(feature, indent + 2))
122
filename = plugin.get_filename()
125
basename = os.path.basename(basename)
127
'name': xmlencode(plugin.get_name()),
128
'description': xmlencode(plugin.get_description()),
129
'filename': filename,
130
'basename': basename,
132
'license': xmlencode(plugin.get_license()),
133
'source': xmlencode(plugin.get_source()),
134
'package': xmlencode(plugin.get_package()),
135
'origin': xmlencode(plugin.get_origin()),
136
'elements': "\n".join(elementsoutput),
138
block = PLUGIN_TEMPLATE % d
140
offset = get_offset(indent)
141
return offset + ("\n" + offset).join(block.split("\n"))
144
if len(sys.argv) == 1:
145
sys.stderr.write("Please specify a source module to inspect")
149
if len(sys.argv) > 2:
150
os.chdir(sys.argv[2])
152
registry = gst.registry_get_default()
153
all = registry.get_plugin_list()
155
gst.debug("inspecting plugin %s from source %s" % (
156
plugin.get_name(), plugin.get_source()))
157
# this skips gstcoreelements, with bin and pipeline
158
if plugin.get_filename() is None:
160
if plugin.get_source() != source:
163
filename = "plugin-%s.xml" % plugin.get_name()
164
handle = open(filename, "w")
165
handle.write(output_plugin(plugin))