one item list with structure

Original commit message from CVS:
one item list with structure
This commit is contained in:
Thomas Vander Stichele 2004-08-06 19:03:50 +00:00
parent 4b55e4eafe
commit f59e0690f6
4 changed files with 47 additions and 16 deletions

View file

@ -1,3 +1,9 @@
2004-08-06 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/gst.override:
* testsuite/caps.py:
one item list with structure is valid too
2004-08-06 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/gst.defs:

View file

@ -398,30 +398,35 @@ _wrap_gst_caps_new_empty(PyGBoxed *self, PyObject *args, PyObject *kwargs)
self->free_on_dealloc = FALSE;
if (len == 0) {
/* 0 length creates a new empty caps */
self->boxed = gst_caps_new_empty();
goto beach;
} else if (len == 1) {
/* 1 length is either a string or a structure */
item = PyTuple_GetItem(args, 0);
if (!PyString_Check(item)) {
PyErr_SetString(PyExc_TypeError, "argument must be a string");
if (PyString_Check(item)) {
self->boxed = gst_caps_from_string(PyString_AsString(item));
goto beach;
} else if (!pyg_boxed_check(item, GST_TYPE_STRUCTURE)) {
PyErr_SetString(PyExc_TypeError, "argument must be a string or a GstStructure");
return -1;
}
self->boxed = gst_caps_from_string(PyString_AsString(item));
} else {
self->boxed = gst_caps_new_empty();
for (i = 0; i < len; i++)
{
item = PyTuple_GetItem(args, i);
if (!pyg_boxed_check(item, GST_TYPE_STRUCTURE))
{
PyErr_SetString(PyExc_TypeError, "argument must be a GstStructure");
gst_caps_free(self->boxed);
return -1;
}
gst_caps_append_structure(self->boxed, pyg_boxed_get(item, GstStructure));
}
/* it's either one GstStructure or several whatevers */
self->boxed = gst_caps_new_empty();
for (i = 0; i < len; i++)
{
item = PyTuple_GetItem(args, i);
if (!pyg_boxed_check(item, GST_TYPE_STRUCTURE))
{
PyErr_SetString(PyExc_TypeError, "argument must be a GstStructure");
gst_caps_free(self->boxed);
return -1;
}
gst_caps_append_structure(self->boxed, pyg_boxed_get(item, GstStructure));
}
beach:
if (!self->boxed) {
PyErr_SetString(PyExc_RuntimeError, "could not create GstCaps object");
return -1;

View file

@ -32,6 +32,16 @@ class CapsTest(unittest.TestCase):
assert isinstance(caps[0]['width'], int)
assert caps[0]['width'] == 10
def testCapsConstructFromStructure(self):
struct = gst.structure_from_string('video/x-raw-yuv,width=10')
caps = gst.Caps(struct)
assert isinstance(caps, gst.Caps)
assert len(caps) == 1
assert isinstance(caps[0], gst.Structure)
assert caps[0].get_name() == 'video/x-raw-yuv'
assert isinstance(caps[0]['width'], int)
assert caps[0]['width'] == 10
def testCapsConstructFromStructures(self):
struct1 = gst.structure_from_string('video/x-raw-yuv,width=10')
struct2 = gst.structure_from_string('video/x-raw-rgb,height=20.0')

View file

@ -32,6 +32,16 @@ class CapsTest(unittest.TestCase):
assert isinstance(caps[0]['width'], int)
assert caps[0]['width'] == 10
def testCapsConstructFromStructure(self):
struct = gst.structure_from_string('video/x-raw-yuv,width=10')
caps = gst.Caps(struct)
assert isinstance(caps, gst.Caps)
assert len(caps) == 1
assert isinstance(caps[0], gst.Structure)
assert caps[0].get_name() == 'video/x-raw-yuv'
assert isinstance(caps[0]['width'], int)
assert caps[0]['width'] == 10
def testCapsConstructFromStructures(self):
struct1 = gst.structure_from_string('video/x-raw-yuv,width=10')
struct2 = gst.structure_from_string('video/x-raw-rgb,height=20.0')