bilboed gst-python: gst-python/ gst-python/codegen/ gst-python/gst/ gst-python/testsuite/

[email protected] Sat, 6 Dec 2008 07:41:55 -0800 (PST)
Newsgroups gmane.comp.video.gstreamer.cvs
Message-ID <[email protected]>
CVS Root:       /cvs/gstreamer
Module:         gst-python
Changes by:     bilboed
Date:           Sat Dec 06 2008  15:41:55 UTC

Log message:
* codegen/argtypes.py:
Add handling of 'keep-refcount' for GBoxed arguments.
* gst/gst.defs:
Mark the appropriate 'gst_message_new_*' arguments when the method
takes the ownership of the passed gst.Structure/gst.TagList
* testsuite/test_message.py:
Test for creating messages that take a gst.Structure/gst.TagList as
argument and make sure they're properly created.
Fixes #556054

Modified files:
    .               : ChangeLog
    codegen         : argtypes.py
    gst             : gst.defs
    testsuite       : test_message.py

Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/ChangeLog.diff?r1=1.697&r2=1.698
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/codegen/argtypes.py.diff?r1=1.17&r2=1.18
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/gst/gst.defs.diff?r1=1.141&r2=1.142
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/testsuite/test_message.py.diff?r1=1.6&r2=1.7

====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-python/ChangeLog,v
retrieving revision 1.697
retrieving revision 1.698
diff -u -d -r1.697 -r1.698
--- ChangeLog	6 Dec 2008 15:39:01 -0000	1.697
+++ ChangeLog	6 Dec 2008 15:41:39 -0000	1.698
@@ -1,5 +1,17 @@
 2008-12-06  Edward Hervey  <[email protected]>
 
+	* codegen/argtypes.py:
+	Add handling of 'keep-refcount' for GBoxed arguments.
+	* gst/gst.defs:
+	Mark the appropriate 'gst_message_new_*' arguments when the method
+	takes the ownership of the passed gst.Structure/gst.TagList
+	* testsuite/test_message.py:
+	Test for creating messages that take a gst.Structure/gst.TagList as
+	argument and make sure they're properly created.
+	Fixes #556054
+
+2008-12-06  Edward Hervey  <[email protected]>
 	* testsuite/Makefile.am:
 	Add a way to run individual tests.
 	'make test_bin.py.check' for example.
Index: argtypes.py
RCS file: /cvs/gstreamer/gst-python/codegen/argtypes.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- argtypes.py	16 Dec 2006 14:41:21 -0000	1.17
+++ argtypes.py	6 Dec 2008 15:41:40 -0000	1.18
@@ -613,6 +613,7 @@
             '        PyErr_SetString(PyExc_TypeError, "%(name)s should be a %(typename)s or None");\n'
             '        return NULL;\n'
             '    }\n')
+    acopy = ('   %(name)s = g_boxed_copy(%(typecode)s, %(name)s);\n')
     def __init__(self, ptype, typecode):
         self.typename = ptype
         self.typecode = typecode
@@ -629,6 +630,10 @@
             info.codebefore.append(self.check % {'name':  pname,
                                                  'typename': self.typename,
                                                  'typecode': self.typecode})
+        if keeprefcount:
+            # We need to grab a copy of the GBoxed
+            info.codebefore.append(self.acopy % {'name': pname,
+                                                 'typecode': self.typecode})
         if ptype[-1] == '*':
             typename = ptype[:-1]
             if typename[:6] == 'const-': typename = typename[6:]
Index: gst.defs
RCS file: /cvs/gstreamer/gst-python/gst/gst.defs,v
retrieving revision 1.141
retrieving revision 1.142
diff -u -d -r1.141 -r1.142
--- gst.defs	9 Sep 2008 10:41:27 -0000	1.141
+++ gst.defs	6 Dec 2008 15:41:40 -0000	1.142
@@ -3038,7 +3038,7 @@
   (caller-owns-return #t)
   (parameters
     '("GstObject*" "src")
-    '("GstTagList*" "tag_list")
+    '("GstTagList*" "tag_list" (keep-refcount))
   )
 )
@@ -3131,7 +3131,7 @@
-    '("GstStructure*" "structure")
+    '("GstStructure*" "structure" (keep-refcount))
@@ -3141,7 +3141,7 @@
@@ -3191,7 +3191,7 @@
     '("GstMessageType" "type")
Index: test_message.py
RCS file: /cvs/gstreamer/gst-python/testsuite/test_message.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- test_message.py	5 Apr 2006 17:05:43 -0000	1.6
+++ test_message.py	6 Dec 2008 15:41:41 -0000	1.7
@@ -55,5 +55,56 @@
         self.failUnless(self.got_message == True)
         self.gccollect()
+class TestCreateMessages(TestCase):
+    def setUp(self):
+        TestCase.setUp(self)
+        self.element = gst.Bin()
+    def tearDown(self):
+        del self.element
+    def testCustomMessage(self):
+        # create two custom messages using the same structure
+        s = gst.Structure("something")
+        assert s != None
+        e1 = gst.message_new_custom(gst.MESSAGE_APPLICATION, self.element, s)
+        assert e1
+        e2 = gst.message_new_custom(gst.MESSAGE_APPLICATION, self.element, s)
+        assert e2
+        # make sure the two structures are equal
+        self.assertEquals(e1.structure.to_string(),
+                          e2.structure.to_string())
+    def testTagMessage(self):
+        # Create a taglist
+        t = gst.TagList()
+        t['something'] = "else"
+        t['another'] = 42
+        # Create two messages using that same taglist
+        m1 = gst.message_new_tag(self.element, t)
+        assert m1
+        m2 = gst.message_new_tag(self.element, t)
+        assert m2
+        # make sure the two messages have the same taglist
+        t1 = m1.parse_tag()
+        assert t1
+        keys = t1.keys()
+        keys.sort()
+        self.assertEquals(keys, ['another', 'something'])
+        self.assertEquals(t1['something'], "else")
+        self.assertEquals(t1['another'], 42)
+        t2 = m2.parse_tag()
+        assert t2
+        keys = t2.keys()
+        self.assertEquals(t2['something'], "else")
+        self.assertEquals(t2['another'], 42)
 if __name__ == "__main__":
     unittest.main()

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/