Move files from gst-python into the "subprojects/gst-python//" subdir
[platform/upstream/gstreamer.git] / subprojects / gst-python / testsuite / python / identity.py
1 #!/usr/bin/env python
2 # -*- Mode: Python -*-
3 # vi:si:et:sw=4:sts=4:ts=4
4
5 # identity.py
6 # 2016 Marianna S. Buschle <msb@qtec.com>
7 #
8 # Simple identity element in python
9 #
10 # You can run the example from the source doing from gst-python/:
11 #
12 #  $ export GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$PWD/plugin:$PWD/examples/plugins
13 #  $ GST_DEBUG=python:4 gst-launch-1.0 fakesrc num-buffers=10 ! identity_py ! fakesink
14
15 import gi
16 gi.require_version('Gst', '1.0')
17 gi.require_version('GstBase', '1.0')
18
19 from gi.repository import Gst, GObject, GstBase
20 Gst.init(None)
21
22 #
23 # Simple Identity element created entirely in python
24 #
25 class Identity(GstBase.BaseTransform):
26     __gstmetadata__ = ('Identity Python','Transform', \
27                       'Simple identity element written in python', 'Marianna S. Buschle')
28
29     __gsttemplates__ = (Gst.PadTemplate.new("src",
30                                            Gst.PadDirection.SRC,
31                                            Gst.PadPresence.ALWAYS,
32                                            Gst.Caps.new_any()),
33                        Gst.PadTemplate.new("sink",
34                                            Gst.PadDirection.SINK,
35                                            Gst.PadPresence.ALWAYS,
36                                            Gst.Caps.new_any()))
37
38     def __init__(self):
39         self.transformed = False
40
41     def do_transform_ip(self, buffer):
42         self.transformed = True
43         return Gst.FlowReturn.OK
44
45 GObject.type_register(Identity)
46 __gstelementfactory__ = ("test_identity_py", Gst.Rank.NONE, Identity)