pythongstreamergobjectpython-gstreamergobject-introspection

Using pygi, how can I override a virtual method from a GObject class that has the same name as a virtual method in its base class?


Using GObject Introspection in Python, I am trying to create a custom PushSrc element, which requires override create or fill virtual methods, without success.

The issue seems to be that both PushSrc and its base class, BaseSrc, has these virtual methods.

In other words, this code:

import gi
gi.require_version('Gst', '1.0')
gi.require_version('GstBase', '1.0')
from gi.repository import GstBase, Gst, GObject
Gst.init(None)


class MyPushSrc(GstBase.PushSrc):
    def __init__(self):
        self.add_pad_template(Gst.PadTemplate.new("src",
                                                  Gst.PadDirection.SRC,
                                                  Gst.PadPresence.ALWAYS,
                                                  Gst.Caps.new_any()))
        GstBase.PushSrc.__init__(self)

    def do_fill(self, buf):
        return Gst.FlowReturn.OK


GObject.type_register(MyPushSrc)

results in this output:

Traceback (most recent call last):
  File "mypushsrc.py", line 8, in <module>
    class MyPushSrc(GstBase.PushSrc):
  File "/usr/lib/python3/dist-packages/gi/types.py", line 223, in __init__
    cls._setup_vfuncs()
  File "/usr/lib/python3/dist-packages/gi/types.py", line 120, in _setup_vfuncs
    ambiguous_base.__info__.get_name()
TypeError: Method do_fill() on class GstBase.PushSrc is ambiguous with methods in base classes GstBase.PushSrc and GstBase.BaseSrc

Unfortunately, the fact that do_fill in PushSrc has just one argument agains three in BaseSrc is not enough to the introspection differ these virtual methods. So, what can I do to override this method?


Solution

  • I think this is a bug in the GStreamer Python bindings which can’t currently be worked around. See the upstream bug report. Solutions might become available there if anybody works on the problem.