mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-01 17:31:10 +00:00
Fully implement GstPropertyProbe interface, with unit test.
Original commit message from CVS: reviewed by: Edward Hervey <edward@fluendo.com> * gst/interfaces.defs: * gst/interfaces.override: * testsuite/test_interface.py: Fully implement GstPropertyProbe interface, with unit test. Fixes #376996
This commit is contained in:
parent
4c9d89a324
commit
04a182516c
4 changed files with 113 additions and 3 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2007-02-04 Johan Dahlin <johan@gnome.org>
|
||||||
|
|
||||||
|
reviewed by: Edward Hervey <edward@fluendo.com>
|
||||||
|
|
||||||
|
* gst/interfaces.defs:
|
||||||
|
* gst/interfaces.override:
|
||||||
|
* testsuite/test_interface.py:
|
||||||
|
Fully implement GstPropertyProbe interface, with unit test.
|
||||||
|
Fixes #376996
|
||||||
|
|
||||||
2007-01-31 Edward Hervey <edward@fluendo.com>
|
2007-01-31 Edward Hervey <edward@fluendo.com>
|
||||||
|
|
||||||
* configure.ac:
|
* configure.ac:
|
||||||
|
|
|
@ -438,13 +438,13 @@
|
||||||
(return-type "GType")
|
(return-type "GType")
|
||||||
)
|
)
|
||||||
|
|
||||||
(define-method get_properties
|
(define-method probe_get_properties
|
||||||
(of-object "GstPropertyProbe")
|
(of-object "GstPropertyProbe")
|
||||||
(c-name "gst_property_probe_get_properties")
|
(c-name "gst_property_probe_get_properties")
|
||||||
(return-type "const-GList*")
|
(return-type "const-GList*")
|
||||||
)
|
)
|
||||||
|
|
||||||
(define-method get_property
|
(define-method probe_get_property
|
||||||
(of-object "GstPropertyProbe")
|
(of-object "GstPropertyProbe")
|
||||||
(c-name "gst_property_probe_get_property")
|
(c-name "gst_property_probe_get_property")
|
||||||
(return-type "const-GParamSpec*")
|
(return-type "const-GParamSpec*")
|
||||||
|
@ -498,7 +498,7 @@
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
(define-method get_values_name
|
(define-method probe_get_values_name
|
||||||
(of-object "GstPropertyProbe")
|
(of-object "GstPropertyProbe")
|
||||||
(c-name "gst_property_probe_get_values_name")
|
(c-name "gst_property_probe_get_values_name")
|
||||||
(return-type "GValueArray*")
|
(return-type "GValueArray*")
|
||||||
|
|
|
@ -245,3 +245,76 @@ _wrap_gst_mixer_get_volume (PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||||
|
|
||||||
return py_tuple;
|
return py_tuple;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%%
|
||||||
|
override gst_property_probe_get_property args
|
||||||
|
static PyObject *
|
||||||
|
_wrap_gst_property_probe_get_property (PyGObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
const GParamSpec *spec;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, "s:ProbeProperty.get_property", &name))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
spec = gst_property_probe_get_property (GST_PROPERTY_PROBE (self->obj),
|
||||||
|
name);
|
||||||
|
if (!spec) {
|
||||||
|
PyErr_Format(PyExc_ValueError, "unknown property: %s", name);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pyg_param_spec_new((GParamSpec*)spec);
|
||||||
|
}
|
||||||
|
%%
|
||||||
|
override gst_property_probe_get_properties noargs
|
||||||
|
static PyObject *
|
||||||
|
_wrap_gst_property_probe_get_properties (PyGObject *self)
|
||||||
|
{
|
||||||
|
const GList *l, *list;
|
||||||
|
PyObject *py_list;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_PROPERTY_PROBE (self->obj), PyList_New(0));
|
||||||
|
|
||||||
|
list = gst_property_probe_get_properties (GST_PROPERTY_PROBE (self->obj));
|
||||||
|
|
||||||
|
py_list = PyList_New(0);
|
||||||
|
for (l = list; l; l = l->next) {
|
||||||
|
GParamSpec *spec = (GParamSpec*)l->data;
|
||||||
|
PyObject *py_gspec = pyg_param_spec_new((GParamSpec*)spec);
|
||||||
|
PyList_Append(py_list, py_gspec);
|
||||||
|
Py_DECREF(py_gspec);
|
||||||
|
}
|
||||||
|
|
||||||
|
return py_list;
|
||||||
|
}
|
||||||
|
%%
|
||||||
|
override gst_property_probe_get_values_name args
|
||||||
|
static PyObject *
|
||||||
|
_wrap_gst_property_probe_get_values_name (PyGObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
GValueArray *array;
|
||||||
|
PyObject *py_list;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_PROPERTY_PROBE (self->obj), PyList_New(0));
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, "s:ProbeProperty.get_values_name", &name))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
array = gst_property_probe_get_values_name (GST_PROPERTY_PROBE (self->obj),
|
||||||
|
name);
|
||||||
|
py_list = PyList_New(0);
|
||||||
|
|
||||||
|
for (i = 0; i < array->n_values; i++) {
|
||||||
|
GValue *value = g_value_array_get_nth(array, i);
|
||||||
|
PyObject *py_value = pyg_value_as_pyobject(value, TRUE);
|
||||||
|
PyList_Append(py_list, py_value);
|
||||||
|
Py_DECREF(py_value);
|
||||||
|
|
||||||
|
}
|
||||||
|
g_value_array_free(array);
|
||||||
|
|
||||||
|
return py_list;
|
||||||
|
}
|
||||||
|
|
|
@ -43,5 +43,32 @@ class FunctionCall(TestCase):
|
||||||
assert isinstance(element, gst.interfaces.XOverlay)
|
assert isinstance(element, gst.interfaces.XOverlay)
|
||||||
element.set_xwindow_id(0L)
|
element.set_xwindow_id(0L)
|
||||||
|
|
||||||
|
class MixerTest(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
TestCase.setUp(self)
|
||||||
|
self.mixer = gst.element_factory_make('alsasrc', '')
|
||||||
|
assert self.mixer
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
del self.mixer
|
||||||
|
TestCase.tearDown(self)
|
||||||
|
|
||||||
|
def testGetProperty(self):
|
||||||
|
self.failUnless(self.mixer.probe_get_property('device'))
|
||||||
|
self.assertRaises(ValueError,
|
||||||
|
self.mixer.probe_get_property, 'non-existent')
|
||||||
|
|
||||||
|
def testGetProperties(self):
|
||||||
|
properties = self.mixer.probe_get_properties()
|
||||||
|
self.failUnless(properties)
|
||||||
|
self.assertEqual(type(properties), list)
|
||||||
|
prop = properties[0]
|
||||||
|
self.assertEqual(prop.name, 'device')
|
||||||
|
self.assertEqual(prop.value_type, gobject.TYPE_STRING)
|
||||||
|
|
||||||
|
def testGetValuesName(self):
|
||||||
|
values = self.mixer.probe_get_values_name('device')
|
||||||
|
self.assertEqual(type(values), list)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in a new issue