GNOME Bugzilla – Bug 789055
Gst.Bin __init__ changed behavior between 1.10 and 1.12 GStreamer version
Last modified: 2018-11-03 15:37:13 UTC
In version 1.10 Gst.Bin component behaved like a regular GObject class used in python. I mean, you could define a new component using Gst.Bin as parent, define properties as GObject.ParamFlags.CONSTRUCT_ONLY and pass values to __init__ method in order to set them. class MyBin(Gst.Bin): foo = GObject.Property(type=str, flags=GObject.ParamFlags.CONSTRUCT_ONLY | GObject.ParamFlags.READWRITE) def __init__(self, *args, **kwargs): Gst.Bin.__init__(self, *args, **kwargs) # your stuff my_bin = MyBin(foo='bar') But currently in Gst version 1.12 it raise an error because it does not pass properties to GObject.Object.__init__. TypeError: __init__() got an unexpected keyword argument 'foo'
I can't see any change between 1.10.0 and latest 1.12 that looks like it would be the cause. Can you "git bisect" to find the offending commit?
I've already reviewed changes between 1.10.x and 1.12.x. And you are right, there are no (obvious) changes about that. And yet it happens. In fact, I can't explain why it worked with 1.10.x. Behaviour in 1.12.x looks like regular one looking at code. I'm using a dirty workaround in 1.12.x: class MyBin(Gst.Bin): foo = GObject.Property(type=str, flags=GObject.ParamFlags.CONSTRUCT_ONLY | GObject.ParamFlags.READWRITE) def __init__(self, *args, **kwargs): Gst.Element.__init__(self, **kwargs) Gst.Bin.__init__(self) # your stuff Perhaps I'm reserving more memory than I should, and I'm not sure if it will be freed.
More info: In my remote machine (CentOS 7.2): $ python3.4 Python 3.4.5 (default, May 29 2017, 15:17:55) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import gi >>> gi.require_version('Gst', '1.0') >>> from gi.repository import Gst >>> Gst.version_string() 'GStreamer 1.10.2' >>> import inspect >>> inspect.signature(Gst.Bin.__init__).parameters mappingproxy(OrderedDict([('self', <Parameter at 0x7f637cea4a68 'self'>), ('args', <Parameter at 0x7f637ce97e10 'args'>), ('kwargs', <Parameter at 0x7f637cc176c0 'kwargs'>)])) >>> Gst.Bin.__mro__ (<class 'gi.repository.Gst.Bin'>, <class 'gi.repository.Gst.Element'>, <class 'gi.repository.Gst.Object'>, <class 'gi.repository.GObject.InitiallyUnowned'>, <class 'gi.overrides.GObject.Object'>, <class 'gi.repository.GObject.Object'>, <class 'gi._gobject.GObject'>, <class 'gi.repository.Gst.ChildProxy'>, <class 'gobject.GInterface'>, <class 'object'>) It looks like Gst.Bin is not overridden. It's weird because it is overridden since commit 02ca5d3ad25 (5 years ago). On the other hand, I don't understand why __init__ method must be overridden. In my labtop (Fedora 26): $ python3 Python 3.6.2 (default, Oct 2 2017, 16:51:32) [GCC 7.2.1 20170915 (Red Hat 7.2.1-2)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import gi >>> gi.require_version('Gst', '1.0') >>> from gi.repository import Gst >>> Gst.init([]) [] >>> Gst.version_string() 'GStreamer 1.12.3' >>> import inspect >>> inspect.signature(Gst.Bin.__init__).parameters mappingproxy(OrderedDict([('self', <Parameter "self">), ('name', <Parameter "name=None">)])) >>> Gst.Bin.__mro__ (<class 'gi.overrides.Gst.Bin'>, <class 'gi.repository.Gst.Bin'>, <class 'gi.repository.Gst.Element'>, <class 'gi.repository.Gst.Object'>, <class 'gi.repository.GObject.InitiallyUnowned'>, <class 'gi.overrides.GObject.Object'>, <class 'gi.repository.GObject.Object'>, <class 'gi._gobject.GObject'>, <class 'gi.repository.Gst.ChildProxy'>, <class 'gobject.GInterface'>, <class 'object'>)
Could this be caused by different versions of g-i/pygi or the presence/absence of gst-python? On my debian sid: $ python3 Python 3.6.4 (default, Jan 5 2018, 02:13:53) >>> inspect.signature(Gst.Bin.__init__).parameters mappingproxy(OrderedDict([('self', <Parameter "self">), ('args', <Parameter "*args">), ('kwargs', <Parameter "**kwargs">)])) >>> Gst.Bin.__mro__ (<class 'gi.repository.Gst.Bin'>, <class 'gi.repository.Gst.Element'>, <class 'gi.repository.Gst.Object'>, <class 'gi.repository.GObject.InitiallyUnowned'>, <class 'gi.overrides.GObject.Object'>, <class 'gi.repository.GObject.Object'>, <class 'gi._gi.GObject'>, <class 'gi.repository.Gst.ChildProxy'>, <class 'gobject.GInterface'>, <class 'object'>) >>> Gst.version_string() 'GStreamer 1.12.4' python-gi is 3.26.1-2 python-gst-1.0 is not installed
Neither on my labtop or remote machine, python-gst is installed. Curiously, you are getting same bug on version 1.12 than me on version 1.10. The problem is in class <class 'gi.overrides.Gst.Bin'>. Looking at code it looks python-gi is overriding Bin base class (I don't know why it is needed). https://cgit.freedesktop.org/gstreamer/gst-python/tree/gi/overrides/Gst.py#n65 I guess there was a problem with function `override` from python-gi. But it was solved in with a refactor (https://gitlab.gnome.org/GNOME/pygobject/commit/149c31beced944c72fba6ca6e096c81c1100ea2b). So, in brief, gst-python (gi) was using function override from pygobject but it wasn't worked properly. Now it works but gst-python implementation prevents to set construct-only properties in custom Bin classes. From my point of view, it should be solved on gst-python doing something like: ``` File: gi/overrides/Gst.py Line: 56 class Bin(Gst.Bin): def __init__(self, name=None, **kwargs): Gst.Bin.__init__(self, name=name, **kwargs) def add(self, *args): for arg in args: if not Gst.Bin.add(self, arg): raise AddError(arg) ```
Further info: My labtop (it is using override function properly): >>> import gi >>> gi.version_info (3, 26, 1) My remote machine: >>> import gi >>> gi.version_info (3, 18, 2)
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-python/issues/9.