Unable to set properties for elements of type GArray with numpy arrays on PyGObject 3.36+
It appears that the behavior for being able to set properties that leverage GArrays (e.g. audiofirfilter's kernel property which expects Array of GValues of type "gdouble") changed at some point. Some examples below that illustrate this behavior:
Example: Debian Buster
$ python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import gi
>>> gi.require_version('Gst', '1.0')
>>> from gi.repository import Gst
>>> Gst.init(None)
[]
>>> elem = Gst.ElementFactory.make("audiofirfilter", None)
>>> elem.set_property("kernel", numpy.array([1.3, 2.6, 3.9]))
>>> elem.get_property("kernel")
[1.3, 2.6, 3.9]
Can reproduce via:
$ podman run -it --rm docker://debian:buster
$ apt update && apt-get install -y gstreamer1.0-plugins-good python3-gst-1.0 python3-numpy
$ python3
Relevant versions:
python3/oldstable,now 3.7.3-1 amd64
python3-gi/oldstable,now 3.30.4-1 amd64
python3-gst-1.0/oldstable,now 1.14.4-1+b1 amd64
libgstreamer1.0-0/oldstable,now 1.14.4-1 amd64
libglib2.0-0/oldstable,now 2.58.3-2+deb10u3 amd64
Example: Debian Bullseye
$ python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import gi
>>> gi.require_version('Gst', '1.0')
>>> from gi.repository import Gst
>>> Gst.init(None)
[]
>>> elem = Gst.ElementFactory.make("audiofirfilter", None)
>>> elem.set_property("kernel", numpy.array([1.3, 2.6, 3.9]))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: could not convert array([1.3, 2.6, 3.9]) to type 'GValueArray' when setting property 'GstAudioFIRFilter.kernel'
Can reproduce via:
$ podman run -it --rm docker://debian:bullseye
$ apt update && apt-get install -y gstreamer1.0-plugins-good python3-gst-1.0 python3-numpy
$ python3
Relevant versions:
python3/stable,now 3.9.2-3 amd64
python3-gi/stable,now 3.38.0-2 amd64
python3-gst-1.0/stable,now 1.18.3-1 amd64
libgstreamer1.0-0/stable,now 1.18.4-2.1 amd64
libglib2.0-0/stable,now 2.66.8-1 amd64
It appears that this isn't related to gstreamer/gst-python/glib, but rather some interaction with pygobject/gi. I have also attempted by using conda to choose between different versions of gstreamer/gst-python/pygobject, and using a 1.18.x version of gstreamer is fine as long as the version of pygobject is old enough. 3.30.x works fine, 3.36.x doesn't.
With all that said, it's unclear to me whether any of this was intended, but it was a really nice feature that's now no longer available. If passing in a numpy array no longer works and this is not an intended feature, what's the right way to do this?