From 02f72cd0284c348a89b54406f5d577a4e5f63027 Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Mon, 30 Aug 2004 10:42:36 +0000 Subject: [PATCH] gst/gst.override (_wrap_gst_structure_ass_subscript): Some more fixes, doesn't quite work as it should yet though.x Original commit message from CVS: * gst/gst.override (_wrap_gst_structure_ass_subscript): Some more fixes, doesn't quite work as it should yet though.x (_wrap_gst_caps_tp_str): Plug leak * gst/interfaces.defs (Mixer, MixerTrack): Add mixer fields here. * testsuite/element.py (QueueTest.testConstruct): Some basic test, one disabled for the moment --- ChangeLog | 11 +++++++++++ gst/gst.defs | 1 + gst/gst.override | 36 ++++++++++++++++++++++++++++-------- gst/interfaces.defs | 10 ++++++++++ testsuite/element.py | 10 ++++++++++ testsuite/struct.py | 7 +++++++ testsuite/test_element.py | 10 ++++++++++ testsuite/test_struct.py | 7 +++++++ 8 files changed, 84 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 803baed..adbbfed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-08-30 Johan Dahlin + + * gst/gst.override (_wrap_gst_structure_ass_subscript): Some more + fixes, doesn't quite work as it should yet though.x + (_wrap_gst_caps_tp_str): Plug leak + + * gst/interfaces.defs (Mixer, MixerTrack): Add mixer fields here. + + * testsuite/element.py (QueueTest.testConstruct): Some basic test, + one disabled for the moment + 2004-08-12 Johan Dahlin * gst/interfaces.defs (TunerNorm, TunerChannel): Add fields. diff --git a/gst/gst.defs b/gst/gst.defs index 21cc1df..e0c3e47 100644 --- a/gst/gst.defs +++ b/gst/gst.defs @@ -6082,3 +6082,4 @@ '("GstObject*" "parent") ) ) + diff --git a/gst/gst.override b/gst/gst.override index e5e6df9..a2346fb 100644 --- a/gst/gst.override +++ b/gst/gst.override @@ -1,5 +1,5 @@ /* -*- Mode: C; c-basic-offset: 4 -*- */ -so/* gst-python +/* gst-python * Copyright (C) 2002 David I. Lehn * Copyright (C) 2004 Johan Dahlin * @@ -73,7 +73,7 @@ include init PyGstPipeline_Type.tp_new = PyType_GenericNew; PyGstThread_Type.tp_new = PyType_GenericNew; -PyGstQueue_Type.tp_new = PyType_GenericNew; +//PyGstQueue_Type.tp_new = PyType_GenericNew; PyGstBin_Type.tp_new = PyType_GenericNew; // Shouldn't this be enough? %% modulename gst @@ -90,7 +90,6 @@ ignore-glob *_thyself *_valist gst_class_* - gst_debug_* gst_init* gst_interface_* gst_tag_list_get_* @@ -487,7 +486,14 @@ override-slot GstCaps.tp_str static PyObject * _wrap_gst_caps_tp_str(PyGObject *self) { - return PyString_FromString(gst_caps_to_string((GstCaps*)self->obj)); + gchar *tmp; + PyObject *retval; + + tmp = gst_caps_to_string((GstCaps*)self->obj); + retval = PyString_FromString(tmp); + g_free(tmp); + + return retval; } %% define GstTagList.keys noargs @@ -766,14 +772,28 @@ _wrap_gst_structure_ass_subscript(PyGObject *self, { const char *key; GstStructure* structure; - GValue value = { 0, }; structure = (GstStructure*)self->obj; key = PyString_AsString(py_key); if (py_value != NULL) { - if (PyString_Check(py_value)) - gst_structure_set(structure, key, G_TYPE_STRING, PyString_AsString(py_value), NULL); - else if (PyInt_Check(py_value)) + if (PyString_Check(py_value)) { +#if 0 + GValue *value = NULL; + gst_structure_field_from_string(PyString_AsString(py_value), value); + g_print ("gvalue: %s %s %s\n", + PyString_AsString(py_value), + gst_value_serialize(value), + G_VALUE_TYPE_NAME(value)); + gst_structure_set_value(structure, key, value); +#else + GValue value = { 0, }; + g_value_init (&value, G_TYPE_STRING); + gst_value_deserialize(&value, PyString_AsString(py_value)); + gst_structure_set_value(structure, key, &value); + g_value_unset(&value); +#endif + // gst_structure_set(structure, key, G_TYPE_STRING, PyString_AsString(py_value), NULL); + } else if (PyInt_Check(py_value)) gst_structure_set(structure, key, G_TYPE_INT, PyInt_AsLong(py_value), NULL); else if (PyFloat_Check(py_value)) gst_structure_set(structure, key, G_TYPE_DOUBLE, PyFloat_AsDouble(py_value), NULL); diff --git a/gst/interfaces.defs b/gst/interfaces.defs index 08c940e..c759440 100644 --- a/gst/interfaces.defs +++ b/gst/interfaces.defs @@ -484,6 +484,9 @@ (in-module "Gst") (c-name "GstMixer") (gtype-id "GST_TYPE_MIXER") + (fields + '("GstMixerType" "mixer_type") + ) ) (define-object MixerTrack @@ -491,6 +494,13 @@ (parent "GstObject") (c-name "GstMixerTrack") (gtype-id "GST_TYPE_MIXER_TRACK") + (fields + '("gchar*" "label") + '("GstMixerTrackFlags" "flags") + '("gint" "num_channels") + '("gint" "min_volume") + '("gint" "max_volume") + ) ) (define-interface Navigation diff --git a/testsuite/element.py b/testsuite/element.py index 47bd5e6..d71486a 100644 --- a/testsuite/element.py +++ b/testsuite/element.py @@ -158,5 +158,15 @@ class QueryTest(unittest.TestCase): assert self.element.query(gst.QUERY_POSITION, gst.FORMAT_BYTES) == 0 assert self.element.query(gst.QUERY_POSITION, gst.FORMAT_TIME) == 0 +class QueueTest(unittest.TestCase): + def testConstruct(self): + queue = gst.element_factory_make('queue') + assert isinstance(queue, gst.Queue) + assert queue.get_name() == 'queue0' + + #queue = gst.Element('queue') + #assert isinstance(queue, gst.Queue) + #assert queue.get_name() == 'queue0' + if __name__ == "__main__": unittest.main() diff --git a/testsuite/struct.py b/testsuite/struct.py index e51e2b3..f12cf44 100644 --- a/testsuite/struct.py +++ b/testsuite/struct.py @@ -37,6 +37,13 @@ class StructureTest(unittest.TestCase): assert isinstance(self.struct['integer'], int) assert self.struct['integer'] == 5, self.struct['integer'] + def testCreateFourCC(self): + self.struct['fourcc'] = "(fourcc)XVID" + #assert self.struct.has_key('fourcc') + #print self.struct.to_string() + #assert isinstance(self.struct['fourcc'], int) + #assert self.struct['integer'] == 5, self.struct['integer'] + def testStructureChange(self): #assert structure['pixel-aspect-ratio'].numerator == 1 #assert structure['pixel-aspect-ratio'].denominator == 2 diff --git a/testsuite/test_element.py b/testsuite/test_element.py index 47bd5e6..d71486a 100644 --- a/testsuite/test_element.py +++ b/testsuite/test_element.py @@ -158,5 +158,15 @@ class QueryTest(unittest.TestCase): assert self.element.query(gst.QUERY_POSITION, gst.FORMAT_BYTES) == 0 assert self.element.query(gst.QUERY_POSITION, gst.FORMAT_TIME) == 0 +class QueueTest(unittest.TestCase): + def testConstruct(self): + queue = gst.element_factory_make('queue') + assert isinstance(queue, gst.Queue) + assert queue.get_name() == 'queue0' + + #queue = gst.Element('queue') + #assert isinstance(queue, gst.Queue) + #assert queue.get_name() == 'queue0' + if __name__ == "__main__": unittest.main() diff --git a/testsuite/test_struct.py b/testsuite/test_struct.py index e51e2b3..f12cf44 100644 --- a/testsuite/test_struct.py +++ b/testsuite/test_struct.py @@ -37,6 +37,13 @@ class StructureTest(unittest.TestCase): assert isinstance(self.struct['integer'], int) assert self.struct['integer'] == 5, self.struct['integer'] + def testCreateFourCC(self): + self.struct['fourcc'] = "(fourcc)XVID" + #assert self.struct.has_key('fourcc') + #print self.struct.to_string() + #assert isinstance(self.struct['fourcc'], int) + #assert self.struct['integer'] == 5, self.struct['integer'] + def testStructureChange(self): #assert structure['pixel-aspect-ratio'].numerator == 1 #assert structure['pixel-aspect-ratio'].denominator == 2 -- 2.7.4