summaryrefslogtreecommitdiff
path: root/voctocore/lib/videomix.py
diff options
context:
space:
mode:
Diffstat (limited to 'voctocore/lib/videomix.py')
-rw-r--r--voctocore/lib/videomix.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/voctocore/lib/videomix.py b/voctocore/lib/videomix.py
new file mode 100644
index 0000000..d32dd90
--- /dev/null
+++ b/voctocore/lib/videomix.py
@@ -0,0 +1,44 @@
+#!/usr/bin/python3
+import time, logging
+from gi.repository import GLib, Gst
+
+from lib.config import Config
+
+class VideoMix(Gst.Bin):
+ log = logging.getLogger('VideoMix')
+ sinkpads = []
+
+ def __init__(self):
+ super().__init__()
+
+ self.mixer = Gst.ElementFactory.make('videomixer', 'mixer')
+ self.scale = Gst.ElementFactory.make('videoscale', 'scale')
+ self.conv = Gst.ElementFactory.make('videoconvert', 'conv')
+
+ self.add(self.mixer)
+ self.add(self.scale)
+ self.add(self.conv)
+
+ caps = Gst.Caps.from_string(Config.get('mix', 'outputcaps'))
+ self.mixer.link_filtered(self.scale, caps)
+ self.scale.link(self.conv)
+
+ self.add_pad(
+ Gst.GhostPad.new('src', self.conv.get_static_pad('src'))
+ )
+
+ # I don't know how to create a on-request ghost-pad
+ def add_source(self, src):
+ self.log.info('adding source %s', src.get_name())
+ sinkpad = self.mixer.get_request_pad('sink_%u')
+ sinkpad.set_property('alpha', 1)
+ self.sinkpads.append(sinkpad)
+
+ #srcpad = src.get_compatible_pad(sinkpad, None)
+ #srcpad.link(sinkpad)
+ src.link(self.mixer) # linking ghost pads
+
+ def set_active(self, target):
+ self.log.info('setting source #%u active', target)
+ for idx, sinkpad in enumerate(self.sinkpads):
+ sinkpad.set_property('alpha', int(target == idx))