gst/pygstvalue.c: Make buffers-in-gvalues more generic: handle all miniobjects
authorMichael Smith <msmith@xiph.org>
Sun, 25 Feb 2007 12:11:34 +0000 (12:11 +0000)
committerMichael Smith <msmith@xiph.org>
Sun, 25 Feb 2007 12:11:34 +0000 (12:11 +0000)
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.

ChangeLog
gst/pygstvalue.c
testsuite/test_caps.py

index 6b2a651..b5937d3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * testsuite/test_caps.py:
index 625f77d..59e2e1d 100644 (file)
@@ -32,8 +32,6 @@ static PyObject *gstdoublerange_class = NULL;
 static PyObject *gstfraction_class = NULL;
 static PyObject *gstfractionrange_class = NULL;
 
-extern PyTypeObject PyGstBuffer_Type;
-
 /**
  * pygst_value_as_pyobject:
  * @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");
         return FALSE;
       }
-    } else if (PyObject_IsInstance (obj, (PyObject *)&PyGstBuffer_Type)) {
+    } else if (PyObject_IsInstance (obj, (PyObject *)&PyGstMiniObject_Type)) {
       PyErr_Clear ();
-      t = GST_TYPE_BUFFER;
+      t = GST_TYPE_MINI_OBJECT;
     } else if (PyTuple_Check (obj)) {
       PyErr_Clear ();
       t = GST_TYPE_ARRAY;
@@ -266,9 +264,9 @@ pygst_value_from_pyobject (GValue *value, PyObject *obj)
       return -1;
     }
     return 0;
-  } else if (PyObject_IsInstance (obj, (PyObject *)&PyGstBuffer_Type)) {
-    VALUE_TYPE_CHECK (value, GST_TYPE_BUFFER);
-    gst_value_set_buffer (value, pygstminiobject_get(obj));
+  } else if (PyObject_IsInstance (obj, (PyObject *)&PyGstMiniObject_Type)) {
+    VALUE_TYPE_CHECK (value, GST_TYPE_MINI_OBJECT);
+    gst_value_set_mini_object (value, pygstminiobject_get(obj));
     return 0;
   } else if (PyTuple_Check (obj)) {
     gint i, len;
index 2eb33d0..60360c5 100644 (file)
@@ -50,14 +50,15 @@ class CapsTest(TestCase):
     def testCapsContainingMiniObjects(self):
         # buffer contains hex encoding of ascii 'abcd'
         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")
         caps[0]['buf2'] = buf
         buf2 = caps[0]['buf2']
         assert buf2 == buf
 
-
     def testCapsConstructEmpty(self):
         caps = gst.Caps()
         assert isinstance(caps, gst.Caps)