mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 16:26:39 +00:00
python: Remove some old examples
Remove some old examples that have been ported Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5187>
This commit is contained in:
parent
21bc5ebd7b
commit
9b35e0ad26
5 changed files with 0 additions and 358 deletions
|
@ -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 <dlehn@users.sourceforge.net>
|
||||
# 2004 Johan Dahlin <johan@gnome.org>
|
||||
#
|
||||
# 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))
|
||||
|
|
@ -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 <media file or uri>\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))
|
|
@ -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()
|
|
@ -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 <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.
|
||||
#
|
||||
# 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()
|
|
@ -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 <edward@fluendo.com>
|
||||
# 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()
|
Loading…
Reference in a new issue