From 112f72dabc869b30c6eaa3ded77f265cd7d737c4 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Sun, 8 Jan 2006 12:26:35 +0000 Subject: [PATCH] gst/gststructure.override: Properly check for gstvalue data types. This makes it possible to set fields with fractions. Original commit message from CVS: * gst/gststructure.override: (_wrap_gst_structure_set_value): Properly check for gstvalue data types. This makes it possible to set fields with fractions. * testsuite/test_caps.py: * testsuite/test_struct.py: Test for above modifications --- ChangeLog | 9 +++++++++ common | 2 +- gst/gststructure.override | 12 +++++++----- testsuite/test_caps.py | 3 ++- testsuite/test_struct.py | 6 ++++++ 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8145fbb..3a40272 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-01-08 Martin Soto + + * gst/gststructure.override: (_wrap_gst_structure_set_value): + Properly check for gstvalue data types. This makes it possible to + set fields with fractions. + * testsuite/test_caps.py: + * testsuite/test_struct.py: + Test for above modifications + 2006-01-05 Edward Hervey * gst/base.defs: diff --git a/common b/common index 5f10c87..e0b1213 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 5f10c872cafb3eb8058d63e438cae029ed9e8d73 +Subproject commit e0b121388ece524c0b7035a72bddd191d122d8bf diff --git a/gst/gststructure.override b/gst/gststructure.override index 7aefc59..4df4e82 100644 --- a/gst/gststructure.override +++ b/gst/gststructure.override @@ -113,14 +113,16 @@ _wrap_gst_structure_set_value(PyObject *self, PyObject *args, PyObject *kwargs) } else { /* Let PyGTK guess a GType for the object. */ type = pyg_type_from_object((PyObject *) py_value->ob_type); - if (type == 0) { - return NULL; - } } - g_value_init(&value, type); + if (type != G_TYPE_INVALID) { + g_value_init(&value, type); + } else if (!pygst_value_init_for_pyobject(&value, py_value)) { + return NULL; + } + if (pygst_value_from_pyobject(&value, py_value) != 0) { - return NULL; + return NULL; } gst_structure_set_value(pyg_boxed_get(self, GstStructure), field, &value); diff --git a/testsuite/test_caps.py b/testsuite/test_caps.py index ebdf503..016d61d 100644 --- a/testsuite/test_caps.py +++ b/testsuite/test_caps.py @@ -61,7 +61,7 @@ class CapsTest(TestCase): assert caps[0]['width'] == 10 def testCapsConstructFromStructure(self): - struct = gst.structure_from_string('video/x-raw-yuv,width=10') + struct = gst.structure_from_string('video/x-raw-yuv,width=10,framerate=[0/1, 25/3]') caps = gst.Caps(struct) assert isinstance(caps, gst.Caps) assert len(caps) == 1 @@ -69,6 +69,7 @@ class CapsTest(TestCase): assert caps[0].get_name() == 'video/x-raw-yuv' assert isinstance(caps[0]['width'], int) assert caps[0]['width'] == 10 + assert isinstance(caps[0]['framerate'], gst.FractionRange) def testCapsConstructFromStructures(self): struct1 = gst.structure_from_string('video/x-raw-yuv,width=10') diff --git a/testsuite/test_struct.py b/testsuite/test_struct.py index 36b7612..1b45988 100644 --- a/testsuite/test_struct.py +++ b/testsuite/test_struct.py @@ -73,6 +73,12 @@ class StructureTest(TestCase): s['frac'] = gst.Fraction(3,4) assert s['frac'].num == 3 assert s['frac'].denom == 4 + s['fracrange'] = gst.FractionRange(gst.Fraction(0,1), + gst.Fraction(25,3)) + assert s['fracrange'].low.num == 0 + assert s['fracrange'].low.denom == 1 + assert s['fracrange'].high.num == 25 + assert s['fracrange'].high.denom == 3 s['intrange'] = gst.IntRange(5,21) assert s['intrange'].low == 5 assert s['intrange'].high == 21 -- 2.7.4