From 9b35e0ad261049a04ff16407fbe0350729157fa7 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Tue, 15 Aug 2023 17:40:53 +1000 Subject: [PATCH] python: Remove some old examples Remove some old examples that have been ported Part-of: --- .../gst-python/old_examples/filesrc.py | 99 ------------------- .../gst-python/old_examples/helloworld.py | 54 ---------- .../gst-python/old_examples/pyidentity.py | 68 ------------- .../old_examples/sinkelement-registry.py | 69 ------------- .../gst-python/old_examples/sinkelement.py | 68 ------------- 5 files changed, 358 deletions(-) delete mode 100755 subprojects/gst-python/old_examples/filesrc.py delete mode 100644 subprojects/gst-python/old_examples/helloworld.py delete mode 100644 subprojects/gst-python/old_examples/pyidentity.py delete mode 100644 subprojects/gst-python/old_examples/sinkelement-registry.py delete mode 100644 subprojects/gst-python/old_examples/sinkelement.py diff --git a/subprojects/gst-python/old_examples/filesrc.py b/subprojects/gst-python/old_examples/filesrc.py deleted file mode 100755 index 519d9bc54a..0000000000 --- a/subprojects/gst-python/old_examples/filesrc.py +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env python -# -*- Mode: Python -*- -# vi:si:et:sw=4:sts=4:ts=4 - -# GStreamer python bindings -# Copyright (C) 2002 David I. Lehn -# 2004 Johan Dahlin -# -# filesrc.py: implements a file source element completely in python -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Library General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public -# License along with this library; if not, write to the -# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301, USA. - -import sys -import gobject; gobject.threads_init() -import pygst -pygst.require('0.10') -import gst - -class FileSource(gst.BaseSrc): - __gsttemplates__ = ( - gst.PadTemplate("src", - gst.PAD_SRC, - gst.PAD_ALWAYS, - gst.caps_new_any()), - ) - - blocksize = 4096 - fd = None - - def __init__(self, name): - self.__gobject_init__() - self.curoffset = 0 - self.set_name(name) - - def set_property(self, name, value): - if name == 'location': - self.fd = open(value, 'r') - - def do_create(self, offset, size): - if offset != self.curoffset: - self.fd.seek(offset, 0) - data = self.fd.read(self.blocksize) - if data: - self.curoffset += len(data) - return gst.FLOW_OK, gst.Buffer(data) - else: - return gst.FLOW_UNEXPECTED, None -gobject.type_register(FileSource) - -def main(args): - if len(args) != 3: - print 'Usage: %s input output' % (args[0]) - return -1 - - bin = gst.Pipeline('pipeline') - - filesrc = FileSource('filesource') - assert filesrc - filesrc.set_property('location', args[1]) - - filesink = gst.element_factory_make('filesink', 'sink') - filesink.set_property('location', args[2]) - - bin.add(filesrc, filesink) - gst.element_link_many(filesrc, filesink) - - bin.set_state(gst.STATE_PLAYING); - mainloop = gobject.MainLoop() - - def bus_event(bus, message): - t = message.type - if t == gst.MESSAGE_EOS: - mainloop.quit() - elif t == gst.MESSAGE_ERROR: - err, debug = message.parse_error() - print "Error: %s" % err, debug - mainloop.quit() - return True - bin.get_bus().add_watch(bus_event) - - mainloop.run() - bin.set_state(gst.STATE_NULL) - -if __name__ == '__main__': - sys.exit(main(sys.argv)) - diff --git a/subprojects/gst-python/old_examples/helloworld.py b/subprojects/gst-python/old_examples/helloworld.py deleted file mode 100644 index 0ef0205bf1..0000000000 --- a/subprojects/gst-python/old_examples/helloworld.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python - -import sys - -import gobject -gobject.threads_init() - -import pygst -pygst.require('0.10') -import gst - -def bus_call(bus, message, loop): - t = message.type - if t == gst.MESSAGE_EOS: - sys.stout.write("End-of-stream\n") - loop.quit() - elif t == gst.MESSAGE_ERROR: - err, debug = message.parse_error() - sys.stderr.write("Error: %s: %s\n" % err, debug) - loop.quit() - return True - -def main(args): - if len(args) != 2: - sys.stderr.write("usage: %s \n" % args[0]) - sys.exit(1) - - playbin = gst.element_factory_make("playbin2", None) - if not playbin: - sys.stderr.write("'playbin2' gstreamer plugin missing\n") - sys.exit(1) - - # take the commandline argument and ensure that it is a uri - if gst.uri_is_valid(args[1]): - uri = args[1] - else: - uri = gst.filename_to_uri(args[1]) - playbin.set_property('uri', uri) - - # create and event loop and feed gstreamer bus mesages to it - loop = gobject.MainLoop() - - bus = playbin.get_bus() - bus.add_watch(bus_call, loop) - - # start play back and listed to events - playbin.set_state(gst.STATE_PLAYING) - loop.run() - - # cleanup - playbin.set_state(gst.STATE_NULL) - -if __name__ == '__main__': - sys.exit(main(sys.argv)) diff --git a/subprojects/gst-python/old_examples/pyidentity.py b/subprojects/gst-python/old_examples/pyidentity.py deleted file mode 100644 index 184c8c5c70..0000000000 --- a/subprojects/gst-python/old_examples/pyidentity.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/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_query_function(self.srcqueryfunc) - 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 srcqueryfunc (self, pad, query): - return self.sinkpad.query (query) - 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() diff --git a/subprojects/gst-python/old_examples/sinkelement-registry.py b/subprojects/gst-python/old_examples/sinkelement-registry.py deleted file mode 100644 index 8131acd68f..0000000000 --- a/subprojects/gst-python/old_examples/sinkelement-registry.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python -# -*- Mode: Python -*- -# vi:si:et:sw=4:sts=4:ts=4 - -# sinkelement.py -# (c) 2005 Edward Hervey -# (c) 2007 Jan Schmidt -# 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. -# -# Run this script with GST_DEBUG=python:5 to see the debug -# messages - -import pygst -pygst.require('0.10') -import gst -import gobject -gobject.threads_init () - -# -# Simple Sink element created entirely in python -# - -class MySink(gst.Element): - __gstdetails__ = ('CustomSink','Sink', \ - 'Custom test sink element', 'Edward Hervey') - - _sinkpadtemplate = gst.PadTemplate ("sinkpadtemplate", - gst.PAD_SINK, - gst.PAD_ALWAYS, - gst.caps_new_any()) - - def __init__(self): - gst.Element.__init__(self) - gst.info('creating sinkpad') - self.sinkpad = gst.Pad(self._sinkpadtemplate, "sink") - gst.info('adding sinkpad to self') - self.add_pad(self.sinkpad) - - gst.info('setting chain/event functions') - self.sinkpad.set_chain_function(self.chainfunc) - self.sinkpad.set_event_function(self.eventfunc) - - def chainfunc(self, pad, buffer): - self.info("%s timestamp(buffer):%d" % (pad, buffer.timestamp)) - return gst.FLOW_OK - - def eventfunc(self, pad, event): - self.info("%s event:%r" % (pad, event.type)) - return True - -gobject.type_register(MySink) - -# Register the element into this process' registry. -gst.element_register (MySink, 'mysink', gst.RANK_MARGINAL) - -print "Use --gst-debug=python:3 to see output from this example" - -# -# Code to test the MySink class -# -gst.info('About to create MySink') -pipeline = gst.parse_launch ("fakesrc ! mysink") -pipeline.set_state(gst.STATE_PLAYING) - -gobject.MainLoop().run() diff --git a/subprojects/gst-python/old_examples/sinkelement.py b/subprojects/gst-python/old_examples/sinkelement.py deleted file mode 100644 index a5966017b2..0000000000 --- a/subprojects/gst-python/old_examples/sinkelement.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env python -# -*- Mode: Python -*- -# vi:si:et:sw=4:sts=4:ts=4 - -# sinkelement.py -# (c) 2005 Edward Hervey -# Licensed under LGPL -# -# Small test application to show how to write a sink element -# in 20 lines in python -# -# Run this script with GST_DEBUG=python:5 to see the debug -# messages - -import pygst -pygst.require('0.10') -import gst -import gobject -gobject.threads_init () - -# -# Simple Sink element created entirely in python -# - -class MySink(gst.Element): - - _sinkpadtemplate = gst.PadTemplate ("sinkpadtemplate", - gst.PAD_SINK, - gst.PAD_ALWAYS, - gst.caps_new_any()) - - def __init__(self): - gst.Element.__init__(self) - gst.info('creating sinkpad') - self.sinkpad = gst.Pad(self._sinkpadtemplate, "sink") - gst.info('adding sinkpad to self') - self.add_pad(self.sinkpad) - - gst.info('setting chain/event functions') - self.sinkpad.set_chain_function(self.chainfunc) - self.sinkpad.set_event_function(self.eventfunc) - - def chainfunc(self, pad, buffer): - self.info("%s timestamp(buffer):%d" % (pad, buffer.timestamp)) - return gst.FLOW_OK - - def eventfunc(self, pad, event): - self.info("%s event:%r" % (pad, event.type)) - return True - -gobject.type_register(MySink) - -# -# Code to test the MySink class -# - -src = gst.element_factory_make('fakesrc') -gst.info('About to create MySink') -sink = MySink() - -pipeline = gst.Pipeline() -pipeline.add(src, sink) - -src.link(sink) - -pipeline.set_state(gst.STATE_PLAYING) - -gobject.MainLoop().run()