mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-14 13:21:28 +00:00
7dffdb6864
Also we now need to explicitly call Gst.init() from python bindings.
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
#!/usr/bin/env python
|
|
# -*- Mode: Python -*-
|
|
# vi:si:et:sw=4:sts=4:ts=4
|
|
|
|
# sinkelement.py
|
|
# (c) 2005 Edward Hervey <edward@fluendo.com>
|
|
# (c) 2007 Jan Schmidt <jan@fluendo.com>
|
|
# Licensed under LGPL
|
|
#
|
|
# Small test application to show how to write a sink element
|
|
# in 20 lines in python and place into the gstreamer registry
|
|
# so it can be autoplugged or used from parse_launch.
|
|
#
|
|
# You can run the example from the source doing from gst-python/:
|
|
#
|
|
# $ export GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$PWD/plugin:$PWD/examples/plugins
|
|
# $ GST_DEBUG=python:4 gst-launch-1.0 fakesrc num-buffers=10 ! mysink
|
|
|
|
from gi.repository import Gst, GObject, GstBase
|
|
Gst.init(None)
|
|
|
|
#
|
|
# Simple Sink element created entirely in python
|
|
#
|
|
class MySink(GstBase.BaseSink):
|
|
__gstmetadata__ = ('CustomSink','Sink', \
|
|
'Custom test sink element', 'Edward Hervey')
|
|
|
|
__gsttemplates__ = Gst.PadTemplate.new("sink",
|
|
Gst.PadDirection.SINK,
|
|
Gst.PadPresence.ALWAYS,
|
|
Gst.Caps.new_any())
|
|
|
|
def do_render(self, buffer):
|
|
Gst.info("timestamp(buffer):%s" % (Gst.TIME_ARGS(buffer.pts)))
|
|
return Gst.FlowReturn.OK
|
|
|
|
GObject.type_register(MySink)
|
|
__gstelementfactory__ = ("mysink", Gst.Rank.NONE, MySink)
|