mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-01 00:02:24 +00:00
c802a40a96
We used to always call the `->set_child_property` virtual method of the object that `ges_timeline_element_set_child_property` was called from, but that means that, in the case of referencing GESContainer children properties from its children, the children wouldn't know what child property have been set, and the children override wouldn't be takent into account, in turns, it means that the behaviour could be different in the setter depending on parent the method was called, which is totally unexpected. We now make sure that the vmethod from the element that introduced the child property is called whatever parent method is called, making the behaviour more uniform. Fix the python override to make sure that new behaviour is respected.
105 lines
3.4 KiB
Python
105 lines
3.4 KiB
Python
# -*- Mode: Python; py-indent-offset: 4 -*-
|
|
# vim: tabstop=4 shiftwidth=4 expandtab
|
|
#
|
|
# GES.py
|
|
#
|
|
# Copyright (C) 2012 Thibault Saunier <thibault.saunier@collabora.com>
|
|
#
|
|
# This program is free software; you can redistribute it and/or
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
# License as published by the Free Software Foundation; either
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
# Lesser General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
# License along with this program; if not, write to the
|
|
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
# Boston, MA 02111-1307, USA.
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3, or (at your option)
|
|
# any later version.
|
|
|
|
import sys
|
|
from ..overrides import override
|
|
from ..importer import modules
|
|
from gi.repository import GObject
|
|
|
|
|
|
if sys.version_info >= (3, 0):
|
|
_basestring = str
|
|
_callable = lambda c: hasattr(c, '__call__')
|
|
else:
|
|
_basestring = basestring
|
|
_callable = callable
|
|
|
|
GES = modules['GES']._introspection_module
|
|
__all__ = []
|
|
|
|
if GES._version == '0.10':
|
|
import warnings
|
|
warn_msg = "You have imported the GES 0.10 module. Because GES 0.10 \
|
|
was not designed for use with introspection some of the \
|
|
interfaces and API will fail. As such this is not supported \
|
|
by the GStreamer development team and we encourage you to \
|
|
port your app to GES 1 or greater. static python bindings is the recomended \
|
|
python module to use with GES 0.10"
|
|
|
|
warnings.warn(warn_msg, RuntimeWarning)
|
|
|
|
class TimelineElement(GES.TimelineElement):
|
|
def __repr__(self):
|
|
return "%s [%s (%s) %s]" % (
|
|
self.props.name,
|
|
Gst.TIME_ARGS(self.props.start),
|
|
Gst.TIME_ARGS(self.props.in_point),
|
|
Gst.TIME_ARGS(self.props.duration),
|
|
)
|
|
|
|
def set_child_property(self, prop_name, prop_value):
|
|
res, _, pspec = GES.TimelineElement.lookup_child(self, prop_name)
|
|
if not res:
|
|
return res
|
|
|
|
v = GObject.Value()
|
|
v.init(pspec.value_type)
|
|
v.set_value(prop_value)
|
|
|
|
return GES.TimelineElement.set_child_property(self, prop_name, v)
|
|
|
|
|
|
TimelineElement = override(TimelineElement)
|
|
__all__.append('TimelineElement')
|
|
|
|
class TrackElement(GES.TrackElement):
|
|
def set_child_property(self, prop_name, prop_value):
|
|
return TimelineElement.set_child_property(self, prop_name, prop_value)
|
|
|
|
TrackElement = override(TrackElement)
|
|
__all__.append('TrackElement')
|
|
|
|
|
|
class Container(GES.Container):
|
|
def edit(self, layers, new_layer_priority, mode, edge, position):
|
|
return GES.TimelineElement.edit(self, layers, new_layer_priority, mode, edge, position)
|
|
|
|
Container = override(Container)
|
|
__all__.append('Container')
|
|
|
|
class Asset(GES.Asset):
|
|
def __repr__(self):
|
|
return "%s(%s)" % (super().__repr__(), self.props.id)
|
|
|
|
|
|
Asset = override(Asset)
|
|
__all__.append('Asset')
|
|
|
|
try:
|
|
from gi.repository import Gst
|
|
Gst
|
|
except:
|
|
raise RuntimeError("GSt couldn't be imported, make sure you have gst-python installed")
|