summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMarianna Smidth Buschle <msb@qtec.com>2016-10-17 09:37:30 +0200
committerThibault Saunier <thibault.saunier@osg.samsung.com>2016-10-17 10:03:13 +0200
commita9cc3ed6f2efc3986af765d8e054bb25bdadb7e8 (patch)
treea1a41661c6849b3ef868d69f03379e4f9382ea3c /examples
parentb7a78a37dc063d9533dc389df0887079ee8b25fa (diff)
examples: Added identity example
Created a simple BaseTransform element (identity) https://bugzilla.gnome.org/show_bug.cgi?id=772853
Diffstat (limited to 'examples')
-rw-r--r--examples/plugins/python/identity.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/examples/plugins/python/identity.py b/examples/plugins/python/identity.py
new file mode 100644
index 0000000..0f42efc
--- /dev/null
+++ b/examples/plugins/python/identity.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+# identity.py
+# 2016 Marianna S. Buschle <msb@qtec.com>
+#
+# Simple identity element in python
+#
+# 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 ! identity_py ! fakesink
+
+import gi
+gi.require_version('GstBase', '1.0')
+
+from gi.repository import Gst, GObject, GstBase
+Gst.init(None)
+
+#
+# Simple Identity element created entirely in python
+#
+class Identity(GstBase.BaseTransform):
+ __gstmetadata__ = ('Identity Python','Transform', \
+ 'Simple identity element written in python', 'Marianna S. Buschle')
+
+ __gsttemplates__ = (Gst.PadTemplate.new("src",
+ Gst.PadDirection.SRC,
+ Gst.PadPresence.ALWAYS,
+ Gst.Caps.new_any()),
+ Gst.PadTemplate.new("sink",
+ Gst.PadDirection.SINK,
+ Gst.PadPresence.ALWAYS,
+ Gst.Caps.new_any()))
+
+ def do_transform_ip(self, buffer):
+ Gst.info("timestamp(buffer):%s" % (Gst.TIME_ARGS(buffer.pts)))
+ return Gst.FlowReturn.OK
+
+GObject.type_register(Identity)
+__gstelementfactory__ = ("identity_py", Gst.Rank.NONE, Identity)