From: Jan Schmidt Date: Tue, 10 Apr 2007 12:44:44 +0000 (+0000) Subject: examples/pyidentity.py: Add a simple example that implements an identity-like element... X-Git-Tag: 1.19.3~485^2~688 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4ecf760ec1e993d6337cd97fe0169970ccacbe8b;p=platform%2Fupstream%2Fgstreamer.git examples/pyidentity.py: Add a simple example that implements an identity-like element in python and passes buffers th... Original commit message from CVS: * examples/pyidentity.py: Add a simple example that implements an identity-like element in python and passes buffers through. It lacks buffer-alloc & query handling at the moment, because the required gstreamer funcs aren't wrapped. * examples/sinkelement.py: Make sure to call gobject.threads_init() in the example. --- diff --git a/ChangeLog b/ChangeLog index 80a169d..5543d72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-04-10 Jan Schmidt + + * examples/pyidentity.py: + Add a simple example that implements an identity-like element in + python and passes buffers through. It lacks buffer-alloc & query + handling at the moment, because the required gstreamer funcs aren't + wrapped. + + * examples/sinkelement.py: + Make sure to call gobject.threads_init() in the example. + 2007-04-04 Edward Hervey * codegen/codegen.py: diff --git a/common b/common index 57d4a15..9097e25 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 57d4a1587556bd42c850601773c662211694c5a6 +Subproject commit 9097e252e477e18182f08a032d8860bdee9a0416 diff --git a/examples/pyidentity.py b/examples/pyidentity.py new file mode 100644 index 0000000..e864892 --- /dev/null +++ b/examples/pyidentity.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +import pygtk +pygtk.require ("2.0") +import gobject +gobject.threads_init() + +import pygst +pygst.require('0.10') +import gst + +class PyIdentity(gst.Element): + _sinkpadtemplate = gst.PadTemplate ("sink", + gst.PAD_SINK, + gst.PAD_ALWAYS, + gst.caps_new_any()) + _srcpadtemplate = gst.PadTemplate ("src", + gst.PAD_SRC, + gst.PAD_ALWAYS, + gst.caps_new_any()) + + def __init__(self): + gst.Element.__init__(self) + + self.sinkpad = gst.Pad(self._sinkpadtemplate, "sink") + self.sinkpad.set_chain_function(self.chainfunc) + self.sinkpad.set_event_function(self.eventfunc) + self.sinkpad.set_getcaps_function(gst.Pad.proxy_getcaps) + self.sinkpad.set_setcaps_function(gst.Pad.proxy_setcaps) + self.add_pad (self.sinkpad) + + self.srcpad = gst.Pad(self._srcpadtemplate, "src") + + self.srcpad.set_event_function(self.srceventfunc) + self.srcpad.set_getcaps_function(gst.Pad.proxy_getcaps) + self.srcpad.set_setcaps_function(gst.Pad.proxy_setcaps) + self.add_pad (self.srcpad) + + def chainfunc(self, pad, buffer): + gst.log ("Passing buffer with ts %d" % (buffer.timestamp)) + return self.srcpad.push (buffer) + + def eventfunc(self, pad, event): + return self.srcpad.push_event (event) + + def srceventfunc (self, pad, event): + return self.sinkpad.push_event (event) + +gobject.type_register(PyIdentity) + +pipe = gst.Pipeline() +vt = gst.element_factory_make ("videotestsrc") +i1 = PyIdentity() +color = gst.element_factory_make ("ffmpegcolorspace") +scale = gst.element_factory_make ("videoscale") +q1 = gst.element_factory_make ("queue") +i2 = PyIdentity() +sink = gst.element_factory_make ("autovideosink") + +pipe.add (vt, i1, q1, i2, color, scale, sink) +gst.element_link_many (vt, i1, q1, i2, color, scale, sink) + +pipe.set_state (gst.STATE_PLAYING) + +gobject.MainLoop().run() diff --git a/examples/sinkelement.py b/examples/sinkelement.py index 40e1c6e..a596601 100644 --- a/examples/sinkelement.py +++ b/examples/sinkelement.py @@ -16,6 +16,7 @@ import pygst pygst.require('0.10') import gst import gobject +gobject.threads_init () # # Simple Sink element created entirely in python