3 # vi:si:et:sw=4:sts=4:ts=4
6 # (c) 2005 Edward Hervey <edward@fluendo.com>
7 # (c) 2007 Jan Schmidt <jan@fluendo.com>
10 # Small test application to show how to write a sink element
11 # in 20 lines in python and place into the gstreamer registry
12 # so it can be autoplugged or used from parse_launch.
14 # You can run the example from the source doing from gst-python/:
16 # $ export GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$PWD/plugin:$PWD/examples/plugins
17 # $ GST_DEBUG=python:4 gst-launch-1.0 fakesrc num-buffers=10 ! mysink
19 # Since this implements the `mypysink://` protocol you can also do:
21 # $ gst-launch-1.0 videotestsrc ! pymysink://
23 from gi.repository import Gst, GObject, GstBase
27 # Simple Sink element created entirely in python
29 class MySink(GstBase.BaseSink, Gst.URIHandler):
30 __gstmetadata__ = ('CustomSink','Sink', \
31 'Custom test sink element', 'Edward Hervey')
33 __gsttemplates__ = Gst.PadTemplate.new("sink",
34 Gst.PadDirection.SINK,
35 Gst.PadPresence.ALWAYS,
38 __protocols__ = ("pymysink",)
39 __uritype__ = Gst.URIType.SINK
43 # Working around https://gitlab.gnome.org/GNOME/pygobject/-/merge_requests/129
44 self.__dontkillme = self
46 def do_render(self, buffer):
47 Gst.info("timestamp(buffer):%s" % (Gst.TIME_ARGS(buffer.pts)))
48 return Gst.FlowReturn.OK
50 def do_get_uri(self, uri):
53 def do_set_uri(self, uri):
56 GObject.type_register(MySink)
57 __gstelementfactory__ = ("mysink", Gst.Rank.NONE, MySink)