mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
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.
This commit is contained in:
parent
605a8acde5
commit
4ecf760ec1
4 changed files with 78 additions and 1 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2007-04-10 Jan Schmidt <thaytan@mad.scientist.com>
|
||||
|
||||
* 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 <edward@fluendo.com>
|
||||
|
||||
* codegen/codegen.py:
|
||||
|
|
2
common
2
common
|
@ -1 +1 @@
|
|||
Subproject commit 57d4a1587556bd42c850601773c662211694c5a6
|
||||
Subproject commit 9097e252e477e18182f08a032d8860bdee9a0416
|
65
examples/pyidentity.py
Normal file
65
examples/pyidentity.py
Normal file
|
@ -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()
|
|
@ -16,6 +16,7 @@ import pygst
|
|||
pygst.require('0.10')
|
||||
import gst
|
||||
import gobject
|
||||
gobject.threads_init ()
|
||||
|
||||
#
|
||||
# Simple Sink element created entirely in python
|
||||
|
|
Loading…
Reference in a new issue