...
 
Commits (18)
=== release 1.12.5 ===
2018-03-28 14:33:57 +0100 Tim-Philipp Müller <tim@centricular.com>
* ChangeLog:
* NEWS:
* RELEASE:
* configure.ac:
* gst-python.doap:
* meson.build:
Release 1.12.5
2018-02-22 08:05:24 -0300 Thibault Saunier <tsaunier@igalia.com>
* gi/overrides/Gst.py:
* testsuite/test_types.py:
bitmask: Do not use long() directly with python3
It doesn't exist anymore there
2018-02-18 10:00:48 -0500 Nicolas Dufresne <nicolas.dufresne@collabora.com>
* Makefile.am:
* gi/Makefile.am:
* gi/overrides/Makefile.am:
* testsuite/Makefile.am:
makefiles: Add missing dist files
https://bugzilla.gnome.org/show_bug.cgi?id=793560
2018-02-23 14:40:37 +0100 Edward Hervey <edward@centricular.com>
* configure.ac:
configure.ac: Don't use runtime location of overrides by default
If someone wants to put the overrides in a non-standard location,
they can use the --with-pygi-overrides-dir option.
The default is to put them in ${pyexecdir}/gi/overrides
Fixes make distcheck
https://bugzilla.gnome.org/show_bug.cgi?id=793756
2018-02-22 10:58:48 +0100 Sebastian Dröge <sebastian@centricular.com>
* gi/overrides/Gst.py:
* testsuite/test_types.py:
Allow Bitmask to be created from ints and longs but always store as long
We need a 64 bit integer, and previously the test failed because it was
already created from longs in various cases (e.g. when reading from a
GstStructure).
2018-01-23 19:32:18 +0200 Sebastian Dröge <sebastian@centricular.com>
* Makefile.am:
* gi/Makefile.am:
* gi/overrides/Makefile.am:
* plugin/Makefile.am:
* testsuite/Makefile.am:
Ship meson build system in autotools generated tarballs
=== release 1.12.4 ===
2017-12-07 20:23:15 +0200 Sebastian Dröge <sebastian@centricular.com>
* ChangeLog:
* NEWS:
* RELEASE:
* configure.ac:
* gst-python.doap:
* meson.build:
Release 1.12.4
=== release 1.12.3 ===
2017-09-18 17:48:49 +0300 Sebastian Dröge <sebastian@centricular.com>
* ChangeLog:
* NEWS:
* RELEASE:
* configure.ac:
* gst-python.doap:
* meson.build:
Release 1.12.3
2017-07-29 23:05:22 -0400 Thibault Saunier <thibault.saunier@osg.samsung.com>
* plugin/gstpythonplugin.c:
plugin: Always initialize GIL state
gcc warns about possibly unintialized use of it
(even if it can't actually happen)
2017-07-25 16:17:54 -0400 Thibault Saunier <thibault.saunier@osg.samsung.com>
* gi/overrides/Gst.py:
* gi/overrides/gstmodule.c:
* testsuite/test_types.py:
Add support for Gst.Bitmask
2017-07-25 14:35:01 -0400 Thibault Saunier <thibault.saunier@osg.samsung.com>
* testsuite/test_types.py:
tests: Stop using deprecated assertion methods
2017-07-25 14:29:19 -0400 Thibault Saunier <thibault.saunier@osg.samsung.com>
* testsuite/Makefile.am:
* testsuite/meson.build:
* testsuite/test_doublerange.py:
* testsuite/test_fraction.py:
* testsuite/test_fractionrange.py:
* testsuite/test_int64range.py:
* testsuite/test_intrange.py:
* testsuite/test_types.py:
* testsuite/test_valuearray.py:
* testsuite/test_valuelist.py:
tests: Move all Fundamental types tests in a file
No reason to have one file per type and it makes it more complicated
to handle.
2017-07-25 13:00:08 -0400 Thibault Saunier <thibault.saunier@osg.samsung.com>
* gi/overrides/Gst.py:
structure: Add a .keys() method and implement __str__
We are making it behave like a dict, so we should provide the
same kind of utilities.
2017-07-24 17:06:06 -0400 Thibault Saunier <thibault.saunier@osg.samsung.com>
* gi/overrides/Gst.py:
* gi/overrides/gstmodule.c:
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-24 12:13:13 -0400 Thibault Saunier <thibault.saunier@osg.samsung.com>
* gi/overrides/Gst.py:
* testsuite/test_gst.py:
structures: Override __new__ to make it more pythonic
2017-05-21 18:06:25 +0200 Olivier Crête <olivier.crete@collabora.com>
* gi/overrides/Gst.py:
* testsuite/test_int64range.py:
* testsuite/test_intrange.py:
overrides: Remove IntRange And Int64Range on Python2
They use the range() built-in type which is a Python 3 change.
https://bugzilla.gnome.org/show_bug.cgi?id=782927
=== release 1.12.2 ===
2017-07-14 14:04:07 +0300 Sebastian Dröge <sebastian@centricular.com>
* ChangeLog:
* NEWS:
* RELEASE:
* configure.ac:
* gst-python.doap:
* meson.build:
Release 1.12.2
=== release 1.12.1 ===
2017-06-20 12:07:49 +0300 Sebastian Dröge <sebastian@centricular.com>
* ChangeLog:
* NEWS:
* RELEASE:
* configure.ac:
* gst-python.doap:
* meson.build:
Release 1.12.1
=== release 1.12.0 ===
2017-05-04 Sebastian Dröge <slomo@coaxion.net>
2017-05-04 15:40:29 +0300 Sebastian Dröge <sebastian@centricular.com>
* ChangeLog:
* NEWS:
* RELEASE:
* configure.ac:
releasing 1.12.0
* gst-python.doap:
* meson.build:
Release 1.12.0
=== release 1.11.91 ===
......
......@@ -28,3 +28,13 @@ CRUFT_FILES = \
include $(top_srcdir)/common/cruft.mak
all-local: check-cruft
EXTRA_DIST = \
meson.build \
meson_options.txt \
config.h.meson \
pygst.py.in \
scripts/pythondetector \
examples/plugins/python/sinkelement.py \
examples/plugins/python/identity.py \
examples/helloworld.py
This diff is collapsed.
This is GStreamer gst-python 1.12.5.
Release notes for GStreamer Python bindings 1.12.0
The GStreamer team is pleased to announce the fifth bugfix release in the stable
1.12 release series of your favourite cross-platform multimedia framework!
The GStreamer team is pleased to announce the first release in the stable 1.12
release series. The 1.12 release series is adding new features on top of the
1.0, 1.2, 1.4, 1.6, 1.8 and 1.10 series and is part of the API and ABI-stable
1.x release series of the GStreamer multimedia framework.
This release only contains bugfixes and it is safe to update from 1.12.x. For a
full list of bugfixes see Bugzilla and the release notes.
The 1.12 stable series is now superseded by the 1.14 stable series, and 1.12.5
will likely be the last bugfix release in the 1.12 series.
Full release notes can be found here
Full release notes can be found at:
https://gstreamer.freedesktop.org/releases/1.12/#1.12.5
Binaries for Android, iOS, Mac OS X and Windows will be provided in the next days.
Binaries for Android, iOS, Mac OS X and Windows will be provided shortly
after the release.
This module will not be very useful by itself and should be used in conjunction
with other GStreamer modules for a complete multimedia experience.
- gstreamer: provides the core GStreamer libraries and some generic plugins
- gst-plugins-base: a basic set of well-supported plugins and additional
media-specific GStreamer helper libraries for audio,
video, rtsp, rtp, tags, OpenGL, etc.
- gst-plugins-good: a set of well-supported plugins under our preferred
license
- gst-plugins-ugly: a set of well-supported plugins which might pose
problems for distributors
- gst-plugins-bad: a set of plugins of varying quality that have not made
their way into one of core/base/good/ugly yet, for one
reason or another. Many of these are are production quality
elements, but may still be missing documentation or unit
tests; others haven't passed the rigorous quality testing
we expect yet.
- gst-libav: a set of codecs plugins based on the ffmpeg library. This is
where you can find audio and video decoders and encoders
for a wide variety of formats including H.264, AAC, etc.
- gstreamer-vaapi: hardware-accelerated video decoding and encoding using
VA-API on Linux. Primarily for Intel graphics hardware.
- gst-omx: hardware-accelerated video decoding and encoding, primarily for
embedded Linux systems that provide an OpenMax
implementation layer such as the Raspberry Pi.
- gst-rtsp-server: library to serve files or streaming pipelines via RTSP
- gst-editing-services: library an plugins for non-linear editing
==== Download ====
You can find source releases of gst-python in the download
directory: https://gstreamer.freedesktop.org/src/gst-python/
You can find source releases of gstreamer in the download
directory: https://gstreamer.freedesktop.org/src/gstreamer/
The git repository and details how to clone it can be found at
http://cgit.freedesktop.org/gstreamer/gst-python/
https://cgit.freedesktop.org/gstreamer/gstreamer/
==== Homepage ====
......@@ -29,7 +68,7 @@ The project's website is https://gstreamer.freedesktop.org/
==== Support and Bugs ====
We use GNOME's bugzilla for bug reports and feature requests:
http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer
https://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer
Please submit patches via bugzilla as well.
......@@ -45,9 +84,3 @@ from there (see link above).
Interested developers of the core library, plugins, and applications should
subscribe to the gstreamer-devel list.
Contributors to this release
* Sebastian Dröge
 
\ No newline at end of file
......@@ -3,7 +3,7 @@ AC_PREREQ([2.68])
dnl initialize autoconf
dnl when going to/from release please set the nano (fourth number) right !
dnl releases only do Wall, cvs and prerelease does Werror too
AC_INIT(GStreamer GObject Introspection overrides for Python , 1.12.0,
AC_INIT(GStreamer GObject Introspection overrides for Python , 1.12.5,
http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer,
gst-python)
......@@ -101,11 +101,7 @@ AC_ARG_WITH([pygi_overrides_dir],
AC_MSG_CHECKING(for pygobject overrides directory)
if test "x$with_pygi_overrides_dir" = "x" ; then
overrides_dir="`$PYTHON -c 'import gi; print(gi._overridesdir)' 2>/dev/null`"
# fallback if the previous failed
if test "x$overrides_dir" = "x" ; then
overrides_dir="${pyexecdir}/gi/overrides"
fi
else
overrides_dir="$with_pygi_overrides_dir"
fi
......
SUBDIRS = overrides
EXTRA_DIST = \
__init__.py \
meson.build
......@@ -29,10 +29,13 @@ import inspect
from ..overrides import override
from ..importer import modules
from gi.repository import GLib
if sys.version_info >= (3, 0):
_basestring = str
_callable = lambda c: hasattr(c, '__call__')
long = int
else:
_basestring = basestring
_callable = callable
......@@ -224,12 +227,48 @@ Pipeline = override(Pipeline)
__all__.append('Pipeline')
class Structure(Gst.Structure):
def __new__(cls, *args, **kwargs):
if not args:
if kwargs:
raise TypeError("wrong arguments when creating GstStructure, first argument"
" must be the structure name.")
return Structure.new_empty()
elif len(args) > 1:
raise TypeError("wrong arguments when creating GstStructure object")
elif isinstance(args[0], str):
if not kwargs:
return Structure.from_string(args[0])[0]
struct = Structure.new_empty(args[0])
for k, v in kwargs.items():
struct[k] = v
return struct
elif isinstance(args[0], Structure):
return args[0].copy()
raise TypeError("wrong arguments when creating GstStructure object")
def __init__(self, *args, **kwargs):
pass
def __getitem__(self, key):
return self.get_value(key)
def keys(self):
keys = set()
def foreach(fid, value, unused1, udata):
keys.add(GLib.quark_to_string(fid))
return True
self.foreach(foreach, None, None)
return keys
def __setitem__(self, key, value):
return self.set_value(key, value)
def __str__(self):
return self.to_string()
Structure = override(Structure)
__all__.append('Structure')
......@@ -348,8 +387,16 @@ class IntRange(Gst.IntRange):
return '[%d,%d,%d]' % (self.range.start, self.range.stop,
self.range.step)
IntRange = override(IntRange)
__all__.append('IntRange')
def __eq__(self, other):
if isinstance(other, range):
return self.range == other
elif isinstance(other, IntRange):
return self.range == other.range
return False
if sys.version_info >= (3, 0):
IntRange = override(IntRange)
__all__.append('IntRange')
class Int64Range(Gst.Int64Range):
......@@ -379,9 +426,34 @@ class Int64Range(Gst.Int64Range):
return '(int64)[%d,%d,%d]' % (self.range.start, self.range.stop,
self.range.step)
def __eq__(self, other):
if isinstance(other, range):
return self.range == other
elif isinstance(other, IntRange):
return self.range == other.range
return False
class Bitmask(Gst.Bitmask):
def __init__(self, v):
if not isinstance(v, long) and not isinstance(v, int):
raise TypeError("%s is not an int or long." % (type(v)))
self.v = long(v)
def __str__(self):
return hex(self.v)
Int64Range = override(Int64Range)
__all__.append('Int64Range')
def __eq__(self, other):
return self.v == other
Bitmask = override(Bitmask)
__all__.append('Bitmask')
if sys.version_info >= (3, 0):
Int64Range = override(Int64Range)
__all__.append('Int64Range')
class DoubleRange(Gst.DoubleRange):
......
......@@ -8,7 +8,11 @@ pygioverrides_PYTHON = Gst.py GstPbutils.py
pygioverridesexecdir = $(PYGI_OVERRIDES_DIR)
EXTRA_DIST = Gst.py
EXTRA_DIST = \
__init__.py \
meson.build \
Gst.py \
GstPbutils.py
AM_CPPFLAGS = $(PYTHON_INCLUDES)
......
......@@ -137,13 +137,21 @@ static PyObject *
gi_gst_int_range_from_value (const GValue * value)
{
gint min, max, step;
PyObject *int_range_type, *int_range, *range;
min = gst_value_get_int_range_min (value);
max = gst_value_get_int_range_max (value);
step = gst_value_get_int_range_step (value);
return PyObject_CallFunction ((PyObject *) & PyRange_Type, "iii",
int_range_type = gi_gst_get_type ("IntRange");
range = PyObject_CallFunction ((PyObject *) & PyRange_Type, "iii",
min, max, step);
int_range = PyObject_CallFunction (int_range_type, "O", range);
Py_DECREF (int_range_type);
Py_DECREF (range);
return int_range;
}
static int
......@@ -182,13 +190,21 @@ static PyObject *
gi_gst_int64_range_from_value (const GValue * value)
{
gint64 min, max, step;
PyObject *int64_range_type, *int64_range, *range;
min = gst_value_get_int64_range_min (value);
max = gst_value_get_int64_range_max (value);
step = gst_value_get_int64_range_step (value);
return PyObject_CallFunction ((PyObject *) & PyRange_Type, "LLL",
range = PyObject_CallFunction ((PyObject *) & PyRange_Type, "LLL",
min, max, step);
int64_range_type = gi_gst_get_type ("Int64Range");
int64_range = PyObject_CallFunction (int64_range_type, "O", range);
Py_DECREF (int64_range_type);
Py_DECREF (range);
return int64_range;
}
static int
......@@ -384,6 +400,35 @@ fail:
return -1;
}
static PyObject *
gi_gst_bitmask_from_value (const GValue * value)
{
PyObject *val, *bitmask_type;
bitmask_type = gi_gst_get_type ("Bitmask");
val = PyObject_CallFunction (bitmask_type, "L",
gst_value_get_bitmask (value));
Py_DECREF (bitmask_type);
return val;
}
static int
gi_gst_bitmask_to_value (GValue * value, PyObject * object)
{
PyObject *v = PyObject_GetAttrString (object, "v");
if (v == NULL)
goto fail;
gst_value_set_bitmask (value, PyLong_AsLong (v));
return 0;
fail:
PyErr_SetString (PyExc_KeyError, "Object is not compatible with Gst.Bitmask");
return -1;
}
static PyObject *
gi_gst_list_from_value (const GValue * value)
{
......@@ -471,9 +516,9 @@ gi_gst_register_types (PyObject * d)
gi_gst_date_time_from_value, gi_gst_date_time_to_value);
pyg_register_gtype_custom (GST_TYPE_FLAG_SET,
gi_gst_flag_set_from_value, gi_gst_flag_set_to_value);
#endif
pyg_register_gtype_custom (GST_TYPE_BITMASK,
gi_gst_bitmask_from_value, gi_gst_bitmask_to_value);
#endif
}
static int
......
......@@ -28,7 +28,57 @@ GStreamer Python Bindings is a set of overrides and Gst fundamental types handli
<location rdf:resource="git://anongit.freedesktop.org/gstreamer/gst-python"/>
<browse rdf:resource="http://cgit.freedesktop.org/gstreamer/gst-python"/>
</GitRepository>
</repository>
</repository>
<release>
<Version>
<revision>1.12.5</revision>
<branch>1.12</branch>
<name></name>
<created>2018-03-28</created>
<file-release rdf:resource="https://gstreamer.freedesktop.org/src/gst-python/gst-python-1.12.5.tar.xz" />
</Version>
</release>
<release>
<Version>
<revision>1.12.4</revision>
<branch>1.12</branch>
<name></name>
<created>2017-12-07</created>
<file-release rdf:resource="http://gstreamer.freedesktop.org/src/gst-python/gst-python-1.12.4.tar.xz" />
</Version>
</release>
<release>
<Version>
<revision>1.12.3</revision>
<branch>1.12</branch>
<name></name>
<created>2017-09-18</created>
<file-release rdf:resource="http://gstreamer.freedesktop.org/src/gst-python/gst-python-1.12.3.tar.xz" />
</Version>
</release>
<release>
<Version>
<revision>1.12.2</revision>
<branch>1.12</branch>
<name></name>
<created>2017-07-14</created>
<file-release rdf:resource="http://gstreamer.freedesktop.org/src/gst-python/gst-python-1.12.2.tar.xz" />
</Version>
</release>
<release>
<Version>
<revision>1.12.1</revision>
<branch>1.12</branch>
<name></name>
<created>2017-06-20</created>
<file-release rdf:resource="http://gstreamer.freedesktop.org/src/gst-python/gst-python-1.12.1.tar.xz" />
</Version>
</release>
<release>
<Version>
......
project('gst-python', 'c', 'cpp',
version : '1.12.0',
version : '1.12.5',
meson_version : '>= 0.36.0',
default_options : [ 'warning_level=1',
'c_std=gnu99',
......
......@@ -11,3 +11,6 @@ libgstpythonplugin_la_SOURCES = gstpythonplugin.c
libgstpythonplugin_la_LDFLAGS = -avoid-version -shrext $(PYTHON_SO)
libgstpythonplugin_la_LIBADD = $(PYTHON_LIBS) $(PYGOBJECT_LIBS) $(GST_LIBS)
libgstpythonplugin_la_CFLAGS = $(GST_CFLAGS) $(PYGOBJECT_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(PYTHON_INCLUDES)
EXTRA_DIST = \
meson.build
......@@ -208,7 +208,7 @@ gst_python_plugin_load (GstPlugin * plugin)
static gboolean
plugin_init (GstPlugin * plugin)
{
PyGILState_STATE state;
PyGILState_STATE state = 0;
PyObject *gi, *require_version, *args, *gst, *dict, *pyplugin;
gboolean we_initialized = FALSE;
GModule *libpython;
......
......@@ -3,19 +3,17 @@
# Keep this list sorted!
tests = \
test_gst.py \
test_fraction.py \
test_intrange.py \
test_int64range.py \
test_doublerange.py \
test_fractionrange.py \
test_valuearray.py \
test_valuelist.py
test_types.py
EXTRA_DIST = \
__init__.py \
cleanup.py \
common.py \
runtests.py \
gstpython.supp \
meson.build \
overrides_hack.py \
python.supp \
runtests.py \
$(tests)
clean-local:
......
......@@ -2,13 +2,7 @@ runtests = find_program('runtests.py')
tests = [
['Test gst', 'test_gst.py'],
['Test fractions', 'test_fraction.py'],
['Test integer ranges', 'test_intrange.py'],
['Test 64bit integer ranges', 'test_int64range.py'],
['Test double ranges', 'test_doublerange.py'],
['Test fraction ranges', 'test_fractionrange.py'],
['Test value arrays', 'test_valuearray.py'],
['Test value lists', 'test_valuelist.py']
['Test fundamentals', 'test_types.py'],
]
pluginsdirs = []
......
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
#
# gst-python - Python bindings for GStreamer
# Copyright (C) 2007 Johan Dahlin
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import overrides_hack
overrides_hack
from common import TestCase
import gi
gi.require_version("Gst", "1.0")
from gi.repository import Gst
Gst.init(None)
R = Gst.DoubleRange
class TestDoubleRange(TestCase):
def testConstructor(self):
Gst.init(None)
r = R(1.2, 3.4)
self.assertEquals(r.start, 1.2)
self.assertEquals(r.stop, 3.4)
self.assertRaises(TypeError, R, {}, 2)
self.assertRaises(TypeError, R, 2, ())
self.assertRaises(TypeError, R, 2, 1)
self.assertRaises(TypeError, R)
def testRepr(self):
Gst.init(None)
self.assertEquals(repr(R(1,2)), '<Gst.DoubleRange [1.0,2.0]>')
def testGetValue(self):
Gst.init(None)
st = Gst.Structure.new_empty("video/x-raw")
st["range"] = R(1,2)
value = st["range"]
self.failUnlessEqual(value.start, 1.0)
self.failUnlessEqual(value.stop, 2.0)
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
#
# gst-python - Python bindings for GStreamer
# Copyright (C) 2007 Johan Dahlin
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import overrides_hack
overrides_hack
from common import TestCase
from gi.repository import Gst
Gst.init(None)
F = Gst.Fraction
class TestFraction(TestCase):
def testConstructor(self):
Gst.init(None)
frac = F(1, 2)
self.assertEquals(frac.num, 1)
self.assertEquals(frac.denom, 2)
frac = F(1)
self.assertEquals(frac.num, 1)
self.assertEquals(frac.denom, 1)
self.assertRaises(TypeError, F)
def testRepr(self):
Gst.init(None)
self.assertEquals(repr(F(1, 2)), '<Gst.Fraction 1/2>')
def testEqNe(self):
Gst.init(None)
frac = F(1, 2)
self.assertEquals(frac, frac)
self.assertEquals(F(1, 2), F(1, 2))
self.assertEquals(F(2, 4), F(1, 2))
self.assertNotEquals(F(1, 3), F(1, 2))
self.assertNotEquals(F(2, 1), F(1, 2))
def testMul(self):
Gst.init(None)
self.assertEquals(F(1, 2) * F(1, 2), F(1, 4))
self.assertEquals(F(2, 3) * F(4, 5), F(8, 15))
self.assertEquals(F(1, 3) * F(4), F(4, 3))
self.assertEquals(F(1, 3) * 4, F(4, 3))
def testRMul(self):
Gst.init(None)
self.assertEquals(2 * F(1, 2), F(1))
self.assertEquals(4 * F(1, 2), F(2))
self.assertEquals(-10 * F(1, 2), F(-5))
def testDiv(self):
Gst.init(None)
self.assertEquals(F(1, 3) / F(1, 4), F(4, 3))
self.assertEquals(F(2, 3) / F(4, 5), F(10, 12))
self.assertEquals(F(1, 3) / F(4), F(1, 12))
self.assertEquals(F(1, 3) / 4, F(1, 12))
self.assertEquals(F(1, 3) / 2, F(1, 6))
self.assertEquals(F(1, 5) / -4, F(1, -20))
def testRDiv(self):
Gst.init(None)
self.assertEquals(2 / F(1, 3), F(6, 1))
self.assertEquals(-4 / F(1, 5), F(-20, 1))
def testFloat(self):
Gst.init(None)
self.assertEquals(float(F(1, 2)), 0.5)
def testPropertyMarshalling(self):
Gst.init(None)
obj = Gst.ElementFactory.make("rawvideoparse")
if not obj:
obj = Gst.ElementFactory.make("rawvideoparse")
if not obj:
# no (raw)videoparse and I don't know of any elements in core or -base using
# fraction properties. Skip this test.
return
value = obj.props.framerate
self.failUnlessEqual(value.num, 25)
self.failUnlessEqual(value.denom, 1)
obj.props.framerate = Gst.Fraction(2, 1)
value = obj.props.framerate
self.failUnlessEqual(value.num, 2)
self.failUnlessEqual(value.denom, 1)
def bad():
obj.props.framerate = 1
self.failUnlessRaises(TypeError, bad)
value = obj.props.framerate
self.failUnlessEqual(value.num, 2)
self.failUnlessEqual(value.denom, 1)
def testGetFractionValue(self):
Gst.init(None)
st = Gst.Structure.from_string("video/x-raw,framerate=10/1")[0]
value = st["framerate"]
self.failUnlessEqual(value.num, 10)
self.failUnlessEqual(value.denom, 1)
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
#
# gst-python - Python bindings for GStreamer
# Copyright (C) 2007 Johan Dahlin
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import overrides_hack
overrides_hack
from common import TestCase
import gi
gi.require_version("Gst", "1.0")
from gi.repository import Gst
Gst.init(None)
R = Gst.FractionRange
class TestFractionRange(TestCase):
def testConstructor(self):
Gst.init(None)
r = R(Gst.Fraction(1, 30), Gst.Fraction(1, 2))
self.assertEquals(r.start, Gst.Fraction(1, 30))
self.assertEquals(r.stop, Gst.Fraction(1, 2))
self.assertRaises(TypeError, R, Gst.Fraction(1, 2), Gst.Fraction(1, 30))
self.assertRaises(TypeError, R, 2, Gst.Fraction(1, 2))
self.assertRaises(TypeError, R, Gst.Fraction(1, 2), 2)
self.assertRaises(TypeError, R)
def testRepr(self):
Gst.init(None)
self.assertEquals(repr(R(Gst.Fraction(1,30), Gst.Fraction(1,2))),
'<Gst.FractionRange [1/30,1/2]>')
def testGetValue(self):
Gst.init(None)
st = Gst.Structure.new_empty("video/x-raw")
st["range"] = R(Gst.Fraction(1, 30), Gst.Fraction(1, 2))
value = st["range"]
self.failUnlessEqual(value.start, Gst.Fraction(1, 30))
self.failUnlessEqual(value.stop, Gst.Fraction(1, 2))
......@@ -76,5 +76,15 @@ class TestNotInitialized(TestCase):
Gst.ElementFactory.make("identity", None)
class TestStructure(TestCase):
def test_new(self):
Gst.init(None)
test = Gst.Structure('test', test=1)
self.assertEqual(test['test'], 1)
test = Gst.Structure('test,test=1')
self.assertEqual(test['test'], 1)
if __name__ == "__main__":
unittest.main()
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
#
# gst-python - Python bindings for GStreamer
# Copyright (C) 2007 Johan Dahlin
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import overrides_hack
overrides_hack
from common import TestCase
import gi
gi.require_version("Gst", "1.0")
from gi.repository import Gst
Gst.init(None)
R = Gst.Int64Range
class TestInt64Range(TestCase):
def testConstructor(self):
Gst.init(None)
r = R(range(0, 10, 2))
self.assertEquals(r.range, range(0, 10, 2))
self.assertRaises(TypeError, R, range(1, 10, 2))
self.assertRaises(TypeError, R, range(0, 9, 2))
self.assertRaises(TypeError, R, range(10, 0))
self.assertRaises(TypeError, R, 1)
self.assertRaises(TypeError, R)
def testRepr(self):
Gst.init(None)
self.assertEquals(repr(R(range(0, 10, 2))), '<Gst.Int64Range [0,10,2]>')
def testGetValue(self):
Gst.init(None)
st = Gst.Structure.new_empty("video/x-raw")
st["range"] = R(range(0, 10, 2))
value = st["range"]
self.failUnlessEqual(value, range(0, 10, 2))
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
#
# gst-python - Python bindings for GStreamer
# Copyright (C) 2007 Johan Dahlin
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import overrides_hack
overrides_hack
from common import TestCase
import gi
gi.require_version("Gst", "1.0")
from gi.repository import Gst
Gst.init(None)
R = Gst.IntRange
class TestIntRange(TestCase):
def testConstructor(self):
Gst.init(None)
r = R(range(0, 10, 2))
self.assertEquals(r.range, range(0, 10, 2))
self.assertRaises(TypeError, R, range(1, 10, 2))
self.assertRaises(TypeError, R, range(0, 9, 2))
self.assertRaises(TypeError, R, range(10, 0))
self.assertRaises(TypeError, R, 1)
self.assertRaises(TypeError, R)
def testRepr(self):
Gst.init(None)
self.assertEquals(repr(R(range(0, 10, 2))), '<Gst.IntRange [0,10,2]>')
def testGetValue(self):
Gst.init(None)
st = Gst.Structure.new_empty("video/x-raw")
st["range"] = R(range(0, 10, 2))
value = st["range"]
self.failUnlessEqual(value, range(0, 10, 2))
This diff is collapsed.
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
#
# gst-python - Python bindings for GStreamer
# Copyright (C) 2007 Johan Dahlin
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import overrides_hack
overrides_hack
from common import TestCase
import gi
gi.require_version("Gst", "1.0")
from gi.repository import Gst
Gst.init(None)
A = Gst.ValueArray
class TestFraction(TestCase):
def testConstructor(self):
Gst.init(None)
a = A((1,2,3))
self.assertEquals(a.array, [1,2,3])
self.assertRaises(TypeError, A, 1)
self.assertRaises(TypeError, A)
def testRepr(self):
Gst.init(None)
self.assertEquals(repr(A([1,2,3])), '<Gst.ValueArray <1,2,3>>')
def testPropertyMarshalling(self):
Gst.init(None)
obj = Gst.ElementFactory.make("rawvideoparse")
if not obj:
# no rawvideoparse and I don't know of any elements in core or -base using
# fraction properties. Skip this test.
return
value = obj.props.plane_strides
self.failUnlessEqual(value[0], 320)
self.failUnlessEqual(value[1], 160)
self.failUnlessEqual(value[2], 160)
obj.props.plane_strides = A([640,320,320])
value = obj.props.plane_strides
self.failUnlessEqual(value[0], 640)
self.failUnlessEqual(value[1], 320)
self.failUnlessEqual(value[2], 320)
def bad():
obj.props.plane_strides = 1
self.failUnlessRaises(TypeError, bad)
value = obj.props.plane_strides
self.failUnlessEqual(value[0], 640)
self.failUnlessEqual(value[1], 320)
self.failUnlessEqual(value[2], 320)
def testGetValue(self):
Gst.init(None)
st = Gst.Structure.new_empty("video/x-raw")
st["array"] = A([Gst.Fraction(1, 30), Gst.Fraction(1, 2)])
value = st["array"]
st["array"] = A(value)
self.failUnlessEqual(value[0], Gst.Fraction(1, 30))
self.failUnlessEqual(value[1], Gst.Fraction(1, 2))
st["matrix"] = A([A([0, 1]), A([-1, 0])])
value = st["matrix"]
self.failUnlessEqual(value[0][0], 0)
self.failUnlessEqual(value[0][1], 1)
self.failUnlessEqual(value[1][0], -1)
self.failUnlessEqual(value[1][1], 0)
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
#
# gst-python - Python bindings for GStreamer
# Copyright (C) 2007 Johan Dahlin
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import overrides_hack
overrides_hack
from common import TestCase
import gi
gi.require_version("Gst", "1.0")
from gi.repository import Gst
Gst.init(None)
L = Gst.ValueList
class TestFraction(TestCase):
def testConstructor(self):
Gst.init(None)
a = L((1,2,3))
self.assertEquals(a.array, [1,2,3])
self.assertRaises(TypeError, L, 1)
self.assertRaises(TypeError, L)
def testRepr(self):
Gst.init(None)
self.assertEquals(repr(L([1,2,3])), '<Gst.ValueList {1,2,3}>')
def testGetValue(self):
Gst.init(None)
st = Gst.Structure.new_empty("video/x-raw")
st["framerate"] = L([Gst.Fraction(1, 30), Gst.Fraction(1, 2)])
value = st["framerate"]
self.failUnlessEqual(value[0], Gst.Fraction(1, 30))
self.failUnlessEqual(value[1], Gst.Fraction(1, 2))
st["matrix"] = L([L([0, 1]), L([-1 ,0])])
value = st["matrix"]
self.failUnlessEqual(value[0][0], 0)
self.failUnlessEqual(value[0][1], 1)
self.failUnlessEqual(value[1][0], -1)
self.failUnlessEqual(value[1][1], 0)