summaryrefslogtreecommitdiff
path: root/voctocore
diff options
context:
space:
mode:
authorMaZderMind <github@mazdermind.de>2014-07-28 23:13:45 +0200
committerMaZderMind <github@mazdermind.de>2014-07-28 23:13:45 +0200
commitf3245358a983f2e97076cac3bbeaafc42eac148a (patch)
tree3f6a4e3651d7831be5496f25807186bd67cd5f4f /voctocore
parent150db06d4dccb52b1b219dad4f5bb189c9d29d95 (diff)
rename from octocat to core
Diffstat (limited to 'voctocore')
-rw-r--r--voctocore/README.md0
-rw-r--r--voctocore/controlserver.py4
-rw-r--r--voctocore/videomix.py69
-rwxr-xr-xvoctocore/voctocat.py27
4 files changed, 100 insertions, 0 deletions
diff --git a/voctocore/README.md b/voctocore/README.md
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/voctocore/README.md
diff --git a/voctocore/controlserver.py b/voctocore/controlserver.py
new file mode 100644
index 0000000..8397705
--- /dev/null
+++ b/voctocore/controlserver.py
@@ -0,0 +1,4 @@
+class ControlServer:
+
+ def __init__(self, videomix):
+ self.videomix = videomix
diff --git a/voctocore/videomix.py b/voctocore/videomix.py
new file mode 100644
index 0000000..895a25f
--- /dev/null
+++ b/voctocore/videomix.py
@@ -0,0 +1,69 @@
+import sys, inspect
+from pprint import pprint
+from gi.repository import GLib, Gst
+
+class Videomix:
+ decoder = []
+ mixerpads = []
+
+ def __init__(self):
+ self.pipeline = Gst.Pipeline()
+
+ self.videomixer = Gst.ElementFactory.make('videomixer', 'videomixer')
+ self.pipeline.add(self.videomixer)
+
+ for uri in ("http://video.blendertestbuilds.de/download.blender.org/ED/ED_1280.avi", "http://download.blender.org/durian/trailer/sintel_trailer-720p.mp4",):
+ decoder = Gst.ElementFactory.make('uridecodebin', 'uridecoder('+uri+')')
+ decoder.set_property("uri", uri)
+ decoder.connect("pad-added", self.OnDynamicPad)
+ self.pipeline.add(decoder)
+ self.decoder.append(decoder)
+
+ self.monitorvideosink = Gst.ElementFactory.make('autovideosink', 'monitorvideosink')
+ self.pipeline.add(self.monitorvideosink)
+ self.videomixer.link(self.monitorvideosink)
+
+ self.monitoraudiosink = Gst.ElementFactory.make('autoaudiosink', 'monitoraudiosink')
+ self.pipeline.add(self.monitoraudiosink)
+
+ self.pipeline.set_state(Gst.State.PLAYING)
+
+ GLib.io_add_watch(sys.stdin, GLib.IO_IN, self.Input)
+
+ def Input(self, fd, condition):
+ if condition == GLib.IO_IN:
+ char = fd.readline()
+ try:
+ i = int(char.rstrip())
+ print("settinh pad {0} to alpha=1".format(i))
+ self.mixerpads[i].set_property('alpha', 1)
+ for idx, pad in enumerate(self.mixerpads):
+ if idx != i:
+ print("settinh pad {0} to alpha=0".format(idx))
+ pad.set_property('alpha', 0)
+ except:
+ pass
+
+ return True
+ else:
+ return False
+
+ def OnDynamicPad(self, uridecodebin, src_pad):
+ caps = src_pad.query_caps(None).to_string()
+ srcname = uridecodebin.get_name()
+ print("{0}-source of {1} online".format(caps.split(',')[0], srcname))
+
+ if caps.startswith('audio/'):
+ sinkpad = self.monitoraudiosink.get_static_pad("sink")
+
+ # link the first audio-stream and be done
+ if not sinkpad.is_linked():
+ src_pad.link(sinkpad)
+
+ else:
+ sinkpad = Gst.Element.get_request_pad(self.videomixer, "sink_%u")
+ src_pad.link(sinkpad)
+ self.mixerpads.append(sinkpad)
+ print('add', sinkpad)
+ sinkpad.set_property('alpha', 0.7)
+
diff --git a/voctocore/voctocat.py b/voctocore/voctocat.py
new file mode 100755
index 0000000..dcab83d
--- /dev/null
+++ b/voctocore/voctocat.py
@@ -0,0 +1,27 @@
+#!/usr/bin/python3
+import gi
+import signal
+
+gi.require_version('Gst', '1.0')
+from gi.repository import GLib, Gst, Gtk, GObject
+
+from videomix import Videomix
+from controlserver import ControlServer
+
+
+
+class Main:
+ def __init__(self):
+ self.videomix = Videomix()
+ self.controlserver = ControlServer(self.videomix)
+
+def runmain():
+ GObject.threads_init()
+ Gst.init(None)
+
+ signal.signal(signal.SIGINT, signal.SIG_DFL)
+ start=Main()
+ Gtk.main()
+
+if __name__ == '__main__':
+ runmain()