gst/gstpad.override: Use proper GValue <-> MiniObject conversion function
authorEdward Hervey <bilboed@bilboed.com>
Fri, 4 Nov 2005 13:14:59 +0000 (13:14 +0000)
committerEdward Hervey <bilboed@bilboed.com>
Fri, 4 Nov 2005 13:14:59 +0000 (13:14 +0000)
Original commit message from CVS:
* gst/gstpad.override:
Use proper GValue <-> MiniObject conversion function
* examples/Makefile.am:
* examples/sinkelement.py:
New example showing how to create a sink element in python.

ChangeLog
examples/Makefile.am
examples/sinkelement.py [new file with mode: 0644]
gst/gstpad.override

index fb66239..6f4ec15 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2005-11-04  Edward Hervey  <edward@fluendo.com>
 
+       * gst/gstpad.override:
+       Use proper GValue <-> MiniObject conversion function
+       * examples/Makefile.am:
+       * examples/sinkelement.py:
+       New example showing how to create a sink element in python.
+
+2005-11-04  Edward Hervey  <edward@fluendo.com>
+
        * examples/play.py:
        Fixed the play example to work with 0.9.4 API
 
index 454c578..f7d0ca8 100644 (file)
@@ -13,6 +13,7 @@ examples_DATA =       \
        audioconcat.py  \
        pipeline-tester \
        vumeter.py      \
-       fvumeter.py
+       fvumeter.py     \
+       sinkelement.py
 
 EXTRA_DIST = $(examples_DATA)
diff --git a/examples/sinkelement.py b/examples/sinkelement.py
new file mode 100644 (file)
index 0000000..acfa8d0
--- /dev/null
@@ -0,0 +1,63 @@
+# sinkelement.py
+# (c) 2005 Edward Hervey <edward@fluendo.com>
+# Licensed under LGPL
+#
+# Small test application to show how to write a sink element
+# in 20 lines in python
+#
+# Run this script with GST_DEBUG=python:5 to see the debug
+# messages
+
+import pygst
+pygst.require('0.9')
+import gst
+import gobject
+
+#
+# Simple Sink element created entirely in python
+#
+
+class MySink(gst.Element):
+
+    _sinkpadtemplate = gst.PadTemplate ("sinkpadtemplate",
+                                        gst.PAD_SINK,
+                                        gst.PAD_ALWAYS,
+                                        gst.caps_new_any())
+
+    def __init__(self):
+        gst.Element.__init__(self)
+        gst.info('creating sinkpad')
+        self.sinkpad = gst.Pad(self._sinkpadtemplate, "sink")
+        gst.info('adding sinkpad to self')
+        self.add_pad(self.sinkpad)
+
+        gst.info('setting chain/event functions')
+        self.sinkpad.set_chain_function(self.chainfunc)
+        self.sinkpad.set_event_function(self.eventfunc)
+        
+    def chainfunc(self, pad, buffer):
+        self.info("%s timestamp(buffer):%d" % (pad, buffer.timestamp))
+        return gst.FLOW_OK
+
+    def eventfunc(self, pad, event):
+        self.info("%s event:%r" % (pad, event.type))
+        return True
+
+gobject.type_register(MySink)
+
+#
+# Code to test the MySink class
+#
+
+src = gst.element_factory_make('fakesrc')
+gst.info('About to create MySink')
+sink = MySink()
+
+pipeline = gst.Pipeline()
+pipeline.add(src, sink)
+
+src.link(sink)
+
+pipeline.set_state(gst.STATE_PLAYING)
+
+gobject.MainLoop().run()
index ff89a08..6de6220 100644 (file)
@@ -322,7 +322,7 @@ call_event_function (GstPad *pad, GstEvent *event)
     g_value_init (&args[0], GST_TYPE_PAD);
     g_value_init (&args[1], GST_TYPE_EVENT);
     g_value_set_object (&args[0], pad);
-    g_value_set_boxed (&args[1], event);
+    gst_value_set_mini_object (&args[1], GST_MINI_OBJECT (event));
     closure = pad_private(pad)->event_function;
     
     g_closure_invoke (closure, &ret, 2, args, NULL);