gstreamer/docs/libs/document-children-props.py
Thibault Saunier 4a9e2c8984 ges: Update documentation
And start generating TrackElement children property with a stupid
simple script
2020-04-09 10:10:09 -04:00

82 lines
2.7 KiB
Python
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
Simple script to update the children properties information for
GESTrackElement-s that add children properties all the time
"""
import gi
import os
import sys
import textwrap
gi.require_version("Gst", "1.0")
gi.require_version("GObject", "2.0")
gi.require_version("GES", "1.0")
from gi.repository import Gst, GES, GObject
overrides = {
"GstFramePositioner": False,
"GstBaseTextOverlay": "timeoverlay",
"GstVideoDirection": "videoflip",
"GESVideoTestSource": "GESVideoTestSource",
"GESVideoTransition": "GESVideoTransition",
}
if __name__ == "__main__":
Gst.init(None)
GES.init()
os.chdir(os.path.realpath(os.path.dirname(__file__)))
tl = GES.Timeline.new_audio_video()
layer = tl.append_layer()
elements = []
def add_clip(c, add=True):
c.props.duration = Gst.SECOND
c.props.start = layer.get_duration()
layer.add_clip(c)
if add:
elements.extend(c.children)
add_clip(GES.UriClipAsset.request_sync(Gst.filename_to_uri(os.path.join("../../", "tests/check/assets/audio_video.ogg"))).extract())
add_clip(GES.TestClip.new())
add_clip(GES.TitleClip.new())
transition = GES.TransitionClip.new_for_nick("crossfade")
add_clip(transition, False)
elements.append(transition)
for element in elements:
gtype = element.__gtype__
print(gtype)
with open(gtype.name + '-children-props.md', 'w') as f:
for prop in GES.TimelineElement.list_children_properties(element):
prefix = '#### `%s`\n\n' % (prop.name)
prefix_len = len(prefix)
lines = textwrap.wrap(prop.blurb, width=80)
doc = prefix + lines[0]
if GObject.type_is_a(prop, GObject.ParamSpecEnum.__gtype__):
lines += ["", "Valid values:"]
for value in prop.enum_class.__enum_values__.values():
lines.append(" - **%s** (%d) %s" % (value.value_name,
int(value), value.value_nick))
else:
lines += ["", "Value type: #" + prop.value_type.name]
typename = overrides.get(prop.owner_type.name, None)
if typename is not False:
if typename is None:
if GObject.type_is_a(prop.owner_type, Gst.Element):
typename = GObject.new(prop.owner_type).get_factory().get_name()
lines += ["", "See #%s:%s" % (typename, prop.name)]
if len(lines) > 1:
doc += '\n'
doc += '\n'.join(lines[1:])
print(doc + "\n", file=f)