gst/pygstvalue.c: Make buffers-in-gvalues more generic: handle all miniobjects

Original commit message from CVS:
* gst/pygstvalue.c: (pygst_value_init_for_pyobject),
(pygst_value_from_pyobject):
Make buffers-in-gvalues more generic: handle all miniobjects
* testsuite/test_caps.py:
Add a bit to one the test for buffers in caps.
This commit is contained in:
Michael Smith 2007-02-25 12:11:34 +00:00
parent e4bd9d306c
commit 4d9d385f44
3 changed files with 16 additions and 9 deletions

View file

@ -1,3 +1,11 @@
2007-02-25 Michael Smith <msmith@fluendo.com>
* gst/pygstvalue.c: (pygst_value_init_for_pyobject),
(pygst_value_from_pyobject):
Make buffers-in-gvalues more generic: handle all miniobjects
* testsuite/test_caps.py:
Add a bit to one the test for buffers in caps.
2007-02-24 Michael Smith <msmith@fluendo.com> 2007-02-24 Michael Smith <msmith@fluendo.com>
* testsuite/test_caps.py: * testsuite/test_caps.py:

View file

@ -32,8 +32,6 @@ static PyObject *gstdoublerange_class = NULL;
static PyObject *gstfraction_class = NULL; static PyObject *gstfraction_class = NULL;
static PyObject *gstfractionrange_class = NULL; static PyObject *gstfractionrange_class = NULL;
extern PyTypeObject PyGstBuffer_Type;
/** /**
* pygst_value_as_pyobject: * pygst_value_as_pyobject:
* @value: the GValue object. * @value: the GValue object.
@ -147,9 +145,9 @@ pygst_value_init_for_pyobject (GValue *value, PyObject *obj)
PyErr_SetString(PyExc_TypeError, "Unexpected gst.Value instance"); PyErr_SetString(PyExc_TypeError, "Unexpected gst.Value instance");
return FALSE; return FALSE;
} }
} else if (PyObject_IsInstance (obj, (PyObject *)&PyGstBuffer_Type)) { } else if (PyObject_IsInstance (obj, (PyObject *)&PyGstMiniObject_Type)) {
PyErr_Clear (); PyErr_Clear ();
t = GST_TYPE_BUFFER; t = GST_TYPE_MINI_OBJECT;
} else if (PyTuple_Check (obj)) { } else if (PyTuple_Check (obj)) {
PyErr_Clear (); PyErr_Clear ();
t = GST_TYPE_ARRAY; t = GST_TYPE_ARRAY;
@ -266,9 +264,9 @@ pygst_value_from_pyobject (GValue *value, PyObject *obj)
return -1; return -1;
} }
return 0; return 0;
} else if (PyObject_IsInstance (obj, (PyObject *)&PyGstBuffer_Type)) { } else if (PyObject_IsInstance (obj, (PyObject *)&PyGstMiniObject_Type)) {
VALUE_TYPE_CHECK (value, GST_TYPE_BUFFER); VALUE_TYPE_CHECK (value, GST_TYPE_MINI_OBJECT);
gst_value_set_buffer (value, pygstminiobject_get(obj)); gst_value_set_mini_object (value, pygstminiobject_get(obj));
return 0; return 0;
} else if (PyTuple_Check (obj)) { } else if (PyTuple_Check (obj)) {
gint i, len; gint i, len;

View file

@ -50,14 +50,15 @@ class CapsTest(TestCase):
def testCapsContainingMiniObjects(self): def testCapsContainingMiniObjects(self):
# buffer contains hex encoding of ascii 'abcd' # buffer contains hex encoding of ascii 'abcd'
caps = gst.Caps("video/x-raw-yuv, buf=(buffer)61626364") caps = gst.Caps("video/x-raw-yuv, buf=(buffer)61626364")
assert isinstance(caps[0]['buf'], gst.Buffer) buf = caps[0]['buf']
assert isinstance(buf, gst.Buffer)
assert buf.data == "abcd"
buf = gst.Buffer("1234") buf = gst.Buffer("1234")
caps[0]['buf2'] = buf caps[0]['buf2'] = buf
buf2 = caps[0]['buf2'] buf2 = caps[0]['buf2']
assert buf2 == buf assert buf2 == buf
def testCapsConstructEmpty(self): def testCapsConstructEmpty(self):
caps = gst.Caps() caps = gst.Caps()
assert isinstance(caps, gst.Caps) assert isinstance(caps, gst.Caps)