Commit graph

35 commits

Author SHA1 Message Date
Xavier Claessens
06851d2e4c python: Fix pulling events from appsink
appsink.pull_object() is introspectable, but it needs a way to convert
the GstMiniObject to its GstEvent/GstSample subclass.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9148>
2025-06-04 20:49:53 +00:00
Xavier Claessens
bbf60305ed python: Fix API break by not forcing usage of context manager
caps.get_structure(0).get_name() used to work, but the usage of
StructureWrapper broke it but forcing to wrap it in a "with" statement.

We already have a Structure subclass, simply make it reference its
parent Gst.Caps object.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9148>
2025-06-04 20:49:52 +00:00
Xavier Claessens
f7c52a22a0 python: Fix unit tests running against system libgstreamer
Unit tests for which `i.get(2, [])` is empty were not adding
testsenv_ld_library_path to LD_LIBRARY_PATH.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9148>
2025-06-04 20:49:52 +00:00
Thibault Saunier
e2f54cc405 python: Convert buffer metadata API to use @property decorators
Convert buffer metadata getter/setter methods to Python properties for
more intuitive access. This makes the API more Pythonic by allowing
direct property assignment (buf.pts = 42) instead of method calls
(buf.set_pts(42)).

Updated properties: flags, pts, dts, duration, offset, offset_end

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9134>
2025-05-29 16:18:11 +00:00
Thibault Saunier
515bf888a9 python: Make use of the new structure.is_writable method
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9027>
2025-05-25 15:16:37 +02:00
Thibault Saunier
f0e1591111 python: Add overrides for Buffer/Query/Event/Context to handle writability
And make them look more like proper MiniObject

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9027>
2025-05-25 15:16:37 +02:00
Thibault Saunier
0201423142 python: Factor out a MiniObject class that all mini object will be based on
Making the API closer to what it should be as Caps are MiniObject

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9027>
2025-05-25 15:16:37 +02:00
Thibault Saunier
da9365176b python: Add a Caps.get_value variant that does not copy the structures
Keeping the __getitem__ implementation the same way

This also now make structure.set_value() raise an exception if the structure
was not writable

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9027>
2025-05-25 15:16:37 +02:00
Thibault Saunier
c3d2209c1f python: Add overrides to be able to write into the GstStructure inside GstCaps
Add Python bindings for allowing to modify GstCaps structures with proper
writability checks.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9027>
2025-05-25 15:16:37 +02:00
Xavier Claessens
0172e47a79 python: Add Gst.Float wrapper
When the float python type is used inside a GstValueArray, it is
converted to a G_TYPE_DOUBLE GValue. Sometimes it is important to be
able to force G_TYPE_FLOAT GValue, for instance to set the the
"mix-matrix" property on audioconvert.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8957>
2025-05-10 23:23:14 +00:00
Xavier Claessens
c2a4c3a53a python: override Gst.ValueArray.append_value()
This ensures that self.array is kept up to date.

Add append() method that is more natural than the static method.

Allow creating empty ValueArray by omitting the constructor parameter.

Fixes: #3114
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8952>
2025-05-10 21:38:05 +00:00
Xavier Claessens
20904a1b92 python: Fix coding style errors in unit tests
Otherwise pre-commit does not pass.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8952>
2025-05-10 21:38:05 +00:00
Santosh Mahto
7c7832fee1 python analytics: Add api iter_on_type to iterate over specific Mtd types
This adds new Python api `iter_on_type()` to GstAnalyticsRelationMeta
to iterate over mtd type specified by argument.
usage:
```
for i in rmeta.iter_on_type(GstAnalytics.ODMtd):
```

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8459>
2025-04-22 18:54:08 -04:00
Santosh Mahto
e68eb7bb23 analytics: Add python api to get relation path
A new api `Mtd.relation_path()` is added to get relation chain
between two Mtd in RelationMeta.

Usage:
```
for i in mtd1.relation_path(mtd2, max_span=4, relation_type=...):
  pass
```

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8556>
2025-04-22 20:41:19 +00:00
Santosh Mahto
4c4e80d286 gstanalytics: Add api iter_direct_related python to GstAnalyticsMeta
The API `iter_direct_related` allows to iterate over directly related
Mtd objects.
Usage:
```
for i in mtd.iter_direct_related(GstAnalytics.RELATE_TO,
                      GstAnalytics.ODMtd)
```

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8461>
2025-04-14 19:11:29 +00:00
Olivier Crête
86bac82c8e python: Add __eq__ to Mtd classes
Also programatically iterate all of the base classes to register them.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8237>
2025-01-20 21:16:32 +00:00
Daniel Morin
ad4fa052e5 gst-python: Test for GstAnalyticsRelationMeta iterator
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8237>
2025-01-20 21:16:32 +00:00
Olivier Crête
33259e7ea4 analytics: Tensor dimensions are always row-major or col-major
Simplify by removing the extra fields, as this is what all
frameworks give us.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8250>
2025-01-08 21:47:52 +00:00
Daniel Morin
e272e229e8 python tests: Adapt analytics unit test
- Adapt test to batch size moved into dims field

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8191>
2025-01-03 23:14:39 +00:00
Thibault Saunier
2c9a642b66 meson: Give the same name for api_version in all modules
There were 2 version of it, apiversion and api_version, I chose the one
with most occurencies: `api_version`

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8178>
2024-12-20 20:19:28 +00:00
Oskar Fiedot
a3a7acdd0a analytics: add rotation to object detection mtd
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7938>
2024-12-11 11:54:15 +01:00
Olivier Crête
65549da07e tensormeta: Add Python unit tests for the tensor meta APIs
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6000>
2024-11-08 14:58:49 +00:00
Olivier Crête
b87d5e080d python tests: Add test for analytics segmentation
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6026>
2024-10-17 18:13:03 +00:00
Olivier Crête
cf6660e3d7 python tests: Add analytics lib runtime path
This way, it will run it against the just compiled version when doing full build.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6026>
2024-10-17 18:13:03 +00:00
Xavier Claessens
ecb685e2ca meson: do not invoke pkgconfig directly in gst-python
That bypass env setup by Meson and is dead code anyway because
pluginsdirs is later overriden by the proper gst_dep.get_variable()
solution.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7445>
2024-09-05 03:00:28 +00:00
Olivier Crête
07205d036a python: Add unit test for analytics API
This is a way to validate that the GObject Annotations are correct

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7297>
2024-08-06 14:28:18 +00:00
Edward Hervey
900a9c47be gst-python: Fix unit test for python >= 3.12
unittest.TestCase.assertEquals was marked deprecated since 3.0 and was finally
removed in 3.12

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5633>
2024-02-02 14:15:49 +01:00
Edward Hervey
7c68ef354b gst-python: Fix override loading in python >= 3.12
The `imp` module got removed in python 3.12 and the `importlib` module should be
used instead.

This is also a good excuse to switch to the new finder module from PEP 451 :
https://www.python.org/dev/peps/pep-0451/

This only requires implement the `find_spec()` method in our custom loaders

Co-authored-by: Stefan <107316-stefan6419846@users.noreply.gitlab.freedesktop.org>
Co-authored-by: Jordan Petrids <jordan@centricular.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5633>
2024-02-02 13:30:38 +01:00
Stefan
3321851786 gst-python: Drop obselete python2 code path
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6007>
2024-01-29 22:33:58 +00:00
Thibault Saunier
761f26080a python: Add a suppression file for a leak in PyGObject
And ensure that the CI runs GES valgrind test when we change the
overrides as many GES tests are implemented in python

Proper fix is at: https://gitlab.gnome.org/GNOME/pygobject/-/merge_requests/204

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2060>
2022-03-29 19:16:58 +02:00
Nirbheek Chauhan
1be6d6ccf5 meson: Add explicit check: kwarg to all run_command() calls
This is required since Meson 0.61.0, and causes a warning to be
emitted otherwise:

2c079d855e
https://github.com/mesonbuild/meson/issues/9300

This exposed a bunch of places where we had broken run_command()
calls, unnecessary run_command() calls, and places where check: true
should be used.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1507>
2022-01-09 18:12:47 +05:30
Thibault Saunier
3729704132 gst: Fix license headers and add SPDX
Fixes https://gitlab.freedesktop.org/gstreamer/gst-python/-/issues/57

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1351>
2021-11-15 22:12:09 -03:00
Tim-Philipp Müller
8dfab0b08c meson: update for meson.build_root() and .build_source() deprecation
-> use meson.project_build_root() or .global_build_root() instead.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1183>
2021-10-20 11:20:44 +00:00
Tim-Philipp Müller
f1bb2c76c6 meson: update for dep.get_pkgconfig_variable() deprecation
... in favour of dep.get_variable('foo', ..) which in some
cases allows for further cleanups in future since we can
extract variables from pkg-config dependencies as well as
internal dependencies using this mechanism.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1183>
2021-10-20 11:20:44 +00:00
Thibault Saunier
24c6e49874 Move files from gst-python into the "subprojects/gst-python//" subdir 2021-09-24 16:16:05 -03:00