Commit graph

24 commits

Author SHA1 Message Date
Mathieu Duponchelle
e1f7c22d70 gstmodule: Fix reference counts of Py_True and Py_False
When returning those values, extensions must take a new reference.

Fixes #33
2020-02-26 13:53:17 +01:00
Thibault Saunier
efbce60285 Do not declare mix declaration and code 2019-12-30 16:53:32 +00:00
Thibault Saunier
d365954fc0 Subclass Exception for mapping and unmapping errors
And minor cleanup in the way errors are handled
2019-12-10 12:05:19 -03:00
Daniel Klamt
fecfe451a7 Changes the mapinfo so that the mapped data is writable
The Problem is, that in the current state it is not easily possible to
edit the buffer data in a gstreamer python element since you get a copy
of the real buffer.

This patch overrides the mapinfo and the function generating it in a way
so that mapinfo.data is now a memoryview pointing to the real buffer.
Depending on the flags given for this buffer the memoryview is r/w.
2019-12-09 09:23:55 +01:00
Thibault Saunier
91d05de9b9 python: Fix type type qualifiers issues 2019-11-28 10:47:07 -03:00
Thibault Saunier
95b2f64394 Remove python2 support
We have notified application developers this would happen a long time
ago and python2 is going to be deprecated very soon now, before 1.18
is going to be released.
2019-11-19 11:18:59 -03:00
Havard Graff
e9d615bf53 gstmodule: fix warning when building against python2
PyMapping_GetItemString’ discards ‘const’ qualifier from pointer target type

https://bugzilla.gnome.org/show_bug.cgi?id=796093
2018-05-14 07:51:43 -04:00
Thibault Saunier
cb0dd804f7 Add support for Gst.Bitmask 2017-07-26 15:27:21 -04:00
Thibault Saunier
31dfe42b37 Return a Gst.*Range instead of a python range converting from GValue to python
Otherwise we lose the information about what type of range it is, which
is mandatory, especially when dealing with Structure and Caps.
2017-07-26 15:27:21 -04:00
Nicolas Dufresne
d44975a1fe array/list: Make gvalue conversion symmetric
This is needed to support matrix. Otherwise, getting
a matrix would remove the rows envelopess, which would
make the "cast" fails, since it would not know if the
internal rows are ValueArray or ValueList. I think reading,
modifying and setting back the matrix is an important use
case.
2017-03-27 15:02:41 -04:00
Nicolas Dufresne
c6dee2c26b gstmodule: Factor out gst type creation
This reduces a lot the boiler plate all over. At the same
time, use N instead of O when passing PyObject to fix
the objects leaks.
2017-03-27 14:52:24 -04:00
Nicolas Dufresne
a4566ffbc8 overrides: Add more GstValue overrides
This patch adds overrides to support IntRange, Int64Range, DoubleRange,
FractionRange, Array and List. For integer ranges, it maps this
to python 'range'. Gst.IntRange() and Gst.Int64Range() are simple cast
to let the underlying code know which GType to use. To set such range in
python you will do:

  structure["range"] = Gst.IntRange(range(0,10,2)))

Same for the 64 bit variant. And when you do:

  r = structure.get_value("range")

A range will be returned directly, without the wrapper. For DoubleRange
and FractionRange, there is no native support in python. So the usage
will be:

  structure["range"] = Gst.DoubleRange(0,10.0)
  structure["range"] =
      Gst.FractionRange(Gst.Fraction(1/30), Gst.Fraction(1/5)

When getting this value, Gst.DoubleRange and Gst.FractionRange class are
returned. They both have start/stop members. The naming was taken from
range type.

For Array and List, both uses the native list type, though they can be
constructed from any python sequence. So again, the class is just like
a cast, to let it pick the right GType and python list are being
returned.

  structure["list"] = Gst.ValueList([1,2,3,4])
  structure["array"] = Gst.ValueArray([1,2,3,4)

Using string and tuple could also work. Since Gst.ValueList/Array are
sequence, you can convert one to the other with:

  list = Gst.ValueList([1,2,3,4])
  array = Gst.ValueArray (list)

https://bugzilla.gnome.org/show_bug.cgi?id=753754
2017-03-24 13:26:21 -04:00
Hanno Boeck
58c324e0cc NULL-terminate PyMethodDef array
PyMethodDef arrays are supposed to end with an entry full of NULL/0 values.
This is missing in gst-python in the file gstmodule.c.

This causes out of bounds memory reads which can be seen / tested by compiling
gst-python with address sanitizer (-fsanitize=address in CFLAGS/LDFLAGS).

https://bugzilla.gnome.org/show_bug.cgi?id=762766
2016-02-27 13:52:07 +02:00
Thibault Saunier
eb043251ee Fix bug when checking template object type 2016-02-20 21:47:09 +01:00
Thibault Saunier
7b627c499d gst: Fix a crash when passing wrong type as __templates__ 2016-02-15 23:28:47 +01:00
Mark Nauwelaerts
9352c54ced overrides: also provide wrapper for trace level debug logging 2015-11-08 11:56:41 +01:00
Simon Farnsworth
c889037e40 Fix zip code of new FSF address
I missed the zip code last time round - fix it. Thanks to Michael Schwendt
in https://bugzilla.redhat.com/show_bug.cgi?id=1034341#c11 for pointing this
out to me.

Signed-off-by: Simon Farnsworth <simon.farnsworth@onelan.co.uk>

https://bugzilla.gnome.org/show_bug.cgi?id=720317
2013-12-12 11:35:41 +00:00
Simon Farnsworth
2ad767a74c Update FSF address
The FSF has moved since these files were created. Update the address, in
order to keep packaging tools such as rpmlint quiet.

Signed-off-by: Simon Farnsworth <simon.farnsworth@onelan.co.uk>

https://bugzilla.gnome.org/show_bug.cgi?id=715182
2013-11-26 15:28:53 +00:00
Sebastian Dröge
46cab502ef Fix compilation with Python 3.0
Changes partially taken from pygobject.
2013-09-30 12:45:59 +02:00
Thibault Saunier
2ac104ea94 gstmodule: Check that we could retrieve the module before using it
And plug a small leak
2013-08-23 21:49:12 -04:00
Mark Nauwelaerts
93ab67c78b overrides: provide for gst-python style debug logging
Also provide a default debug category for the binding glue code.
2012-09-27 14:41:29 +02:00
René Stadler
acd4de381c overrides: Fix crash in add_template
templ vs. templates. Moved variable declarations to the inner scope to prevent
such a mistake.
2012-08-29 10:05:37 -07:00
Thibault Saunier
5adc55d50f overrides: Make it possible to add metadatas and PadTemplates to GstElementClass 2012-08-19 22:45:58 -04:00
Thibault Saunier
0f8f27e55c Implement the glue code so GstFraction works 2012-08-19 18:56:29 -04:00