mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-29 23:32:33 +00:00
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.
This commit is contained in:
parent
02ddaf29f9
commit
31dfe42b37
2 changed files with 32 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue