[gst-devel] Dynamic pipeline problem
Stefan Kost
ensonic at hora-obscura.de
Fri Sep 28 22:05:20 CEST 2007
hi,
I belive this needs some work in gnonlin too. Here is a documenta that explains:
http://webcvs.freedesktop.org/gstreamer/gstreamer/docs/design/part-block.txt?view=markup
Stefan
Dominique Würtz wrote:
> Hi,
>
> in my GStreamer/GNonlin-based project (some multi-track audio application), I
> need to add/remove elements to/from the main pipeline while in PLAYING or PAUSED
> state. Until now this works quite unreliably and results in occasional
> freezes/crashes.
>
> To give you an idea of how my pipeline works, I attached a Python script which
> runs a pipeline and constantly adds and removes "tracks" (which here correspond
> to gnonlin compositions). For me this works only for a few seconds. I guess
> there are some additional checks missing at various places in my code, but I
> have no clue where to find documentation about this. Can anybody help me to get
> my test script working flawlessly?
>
> I'm using the latest Gstreamer/gst-plugins-base/gnonline releases.
>
> Regards,
>
> Dominique
>
>
> ------------------------------------------------------------------------
>
> import pygst
> pygst.require("0.10")
> import gst
> import gobject
>
> class Track:
>
> def __init__(self, pipeline):
> self.comp = gst.element_factory_make("gnlcomposition")
> self.comp.connect("pad-added", self.on_composition_pad_added)
> pipeline.add(self.comp)
> self.comp.set_state(gst.STATE_PLAYING)
>
> def on_composition_pad_added(self, comp, pad):
> caps = pad.get_caps()
> self.srcpad = pad
> if not comp.get_parent() or not convert.get_parent():
> return
> gst.Element.link(comp, adder)
>
> def go():
> global num_tracks, tracks, action
>
> if action == ACTION_ADD_TRACK:
> print "Add Track"
> tracks.append(Track(pipeline))
> action = ACTION_ADD_EVENT
> elif action == ACTION_ADD_EVENT:
> print "Add Event"
>
> track = tracks[-1]
> silence = gst.element_factory_make("audiotestsrc")
> silence.set_property("wave", "silence")
> src = gst.element_factory_make("gnlsource")
> src.add(silence)
> src.set_property("start", 0 * gst.SECOND)
> src.set_property("duration", 1000 * gst.SECOND)
> track.comp.add(src)
>
> if len(tracks) < 3:
> action = ACTION_ADD_TRACK
> else:
> action = ACTION_REMOVE_TRACK
> else:
> print "Remove Track"
> track = tracks.pop()
> try:
> sink = track.srcpad.get_peer()
> gst.Element.unlink(track.comp, adder)
> adder.release_request_pad(sink)
> except:
> pass
> track.comp.set_state(gst.STATE_NULL)
> pipeline.remove(track.comp)
> if not tracks:
> action = ACTION_ADD_TRACK
> return True
>
> adder = gst.element_factory_make("adder")
> convert = gst.element_factory_make("audioconvert")
> sink = gst.element_factory_make("alsasink")
> pipeline = gst.element_factory_make("pipeline")
> pipeline.add(adder, convert, sink)
> gst.Element.link(adder, convert)
> gst.Element.link(convert, sink)
>
> ACTION_ADD_TRACK = 0
> ACTION_ADD_EVENT = 1
> ACTION_REMOVE_TRACK = 2
> action = ACTION_ADD_TRACK
>
> tracks = []
>
> gobject.threads_init()
> gobject.idle_add(go)
> pipeline.set_state(gst.STATE_PLAYING)
> gobject.MainLoop().run()
> pipeline.set_state(gst.STATE_NULL)
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
More information about the gstreamer-devel
mailing list