Commit 31dfe42b authored by Thibault Saunier's avatar Thibault Saunier

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.
parent 02ddaf29
......@@ -248,6 +248,7 @@ class Structure(Gst.Structure):
def __getitem__(self, key):
return self.get_value(key)
def __setitem__(self, key, value):
return self.set_value(key, value)
......@@ -369,6 +370,13 @@ class IntRange(Gst.IntRange):
return '[%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
if sys.version_info >= (3, 0):
IntRange = override(IntRange)
__all__.append('IntRange')
......@@ -401,6 +409,12 @@ 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
if sys.version_info >= (3, 0):
Int64Range = override(Int64Range)
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment