diff options
author | MaZderMind <peter@mazdermind.de> | 2014-08-25 15:17:52 +0200 |
---|---|---|
committer | MaZderMind <peter@mazdermind.de> | 2014-08-25 15:17:52 +0200 |
commit | 91665267433095988dd926b43e845adca32486f0 (patch) | |
tree | 7632de486ec254e9e631620d0f7de10236eb7c4e /voctocore | |
parent | 2219fbe4bda924019080316b5718cbb6539f93d4 (diff) |
minimal example of linking problem
Diffstat (limited to 'voctocore')
-rwxr-xr-x | voctocore/experiments/binlinktest.py | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/voctocore/experiments/binlinktest.py b/voctocore/experiments/binlinktest.py new file mode 100755 index 0000000..92d02ca --- /dev/null +++ b/voctocore/experiments/binlinktest.py @@ -0,0 +1,73 @@ +#!/usr/bin/python3 +import gi, time + +gi.require_version('Gst', '1.0') +from gi.repository import GLib, Gst, GObject + +GObject.threads_init() +Gst.init(None) + +class SrcBin(Gst.Bin): + def __init__(self): + super().__init__() + self.src = Gst.ElementFactory.make('videotestsrc', 'src') + self.add(self.src) + + self.add_pad( + Gst.GhostPad.new('src', self.src.get_static_pad('src')) + ) + +class SinkBin(Gst.Bin): + def __init__(self): + super().__init__() + self.sink = Gst.ElementFactory.make('autovideosink', 'sink') + self.add(self.sink) + + self.add_pad( + Gst.GhostPad.new('sink', self.sink.get_static_pad('sink')) + ) + +class MixBin(Gst.Bin): + def __init__(self): + super().__init__() + self.mix = Gst.ElementFactory.make('videomixer', 'src') + self.add(self.mix) + + self.add_pad( + Gst.GhostPad.new('src', self.mix.get_static_pad('src')) + ) + + def add_src(self, src): + sinkpad = self.mix.get_request_pad('sink_%u') + sinkpad.set_property('alpha', 0.75) + src = src.get_static_pad('src') + + print(src.link(sinkpad)) # Error => GST_PAD_LINK_WRONG_HIERARCHY + +class Example: + def __init__(self): + self.mainloop = GObject.MainLoop() + self.pipeline = Gst.Pipeline() + + self.src = SrcBin() + self.sink = SinkBin() + self.mix = MixBin() + + # Add elements to pipeline + self.pipeline.add(self.src) + self.pipeline.add(self.sink) + self.pipeline.add(self.mix) + + self.mix.add_src(self.src) + self.mix.link(self.sink) + + def run(self): + self.pipeline.set_state(Gst.State.PLAYING) + self.mainloop.run() + + def kill(self): + self.pipeline.set_state(Gst.State.NULL) + self.mainloop.quit() + +example = Example() +example.run() |