Debian Codegraph @

bindings/python/gi/overrides/GES.py

raw
1 # -*- Mode: Python; py-indent-offset: 4 -*-
2 # vim: tabstop=4 shiftwidth=4 expandtab
3 #
4 # GES.py
5 #
6 # Copyright (C) 2012 Thibault Saunier <[email protected]>
7 #
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Library General Public
10 # License as published by the Free Software Foundation; either
11 # version 2 of the License, or (at your option) any later version.
12 #
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Library General Public License for more details.
17 #
18 # You should have received a copy of the GNU Library General Public
19 # License along with this library; if not, write to the
20 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 # Boston, MA 02110-1301, USA.
22
23 import sys
24 from ..overrides import override
25 from ..importer import modules
26 from gi.repository import GObject
27
28
29 if sys.version_info >= (3, 0):
30 _basestring = str
31 _callable = lambda c: hasattr(c, '__call__')
32 else:
33 _basestring = basestring
34 _callable = callable
35
36 GES = modules['GES']._introspection_module
37 __all__ = []
38
39 if GES._version == '0.10':
40 import warnings
41 warn_msg = "You have imported the GES 0.10 module. Because GES 0.10 \
42 was not designed for use with introspection some of the \
43 interfaces and API will fail. As such this is not supported \
44 by the GStreamer development team and we encourage you to \
45 port your app to GES 1 or greater. static python bindings is the recomended \
46 python module to use with GES 0.10"
47
48 warnings.warn(warn_msg, RuntimeWarning)
49
50 def __timeline_element__repr__(self):
51 return "%s [%s (%s) %s]" % (
52 self.props.name,
53 Gst.TIME_ARGS(self.props.start),
54 Gst.TIME_ARGS(self.props.in_point),
55 Gst.TIME_ARGS(self.props.duration),
56 )
57
58 __prev_set_child_property = GES.TimelineElement.set_child_property
59 def __timeline_element_set_child_property(self, prop_name, prop_value):
60 res, _, pspec = GES.TimelineElement.lookup_child(self, prop_name)
61 if not res:
62 return res
63
64 v = GObject.Value()
65 v.init(pspec.value_type)
66 v.set_value(prop_value)
67
68 return __prev_set_child_property(self, prop_name, v)
69
70
71 GES.TimelineElement.__repr__ = __timeline_element__repr__
72 GES.TimelineElement.set_child_property = __timeline_element_set_child_property
73 GES.TrackElement.set_child_property = GES.TimelineElement.set_child_property
74 GES.Container.edit = GES.TimelineElement.edit
75
76 __prev_asset_repr = GES.Asset.__repr__
77 def __asset__repr__(self):
78 return "%s(%s)" % (__prev_asset_repr(self), self.props.id)
79
80 GES.Asset.__repr__ = __asset__repr__
81
82 def __timeline_iter_clips(self):
83 """Iterate all clips in a timeline"""
84 for layer in self.get_layers():
85 for clip in layer.get_clips():
86 yield clip
87
88 GES.Timeline.iter_clips = __timeline_iter_clips
89
90 try:
91 from gi.repository import Gst
92 Gst
93 except:
94 raise RuntimeError("GSt couldn't be imported, make sure you have gst-python installed")