summaryrefslogtreecommitdiff
path: root/voctocore/lib/video/mix.py
diff options
context:
space:
mode:
authorMaZderMind <github@mazdermind.de>2015-05-10 23:07:11 +0200
committerMaZderMind <github@mazdermind.de>2015-05-10 23:07:11 +0200
commita93c71be7f309265658cd0cbc8bd63f22d7ce04f (patch)
tree0870006a765e15f4fe22f8db7b69d9b92700895b /voctocore/lib/video/mix.py
parent80d57d8006a5af2854efa195c49c6f5edd5f93b1 (diff)
Add controll-server and control mixer
Diffstat (limited to 'voctocore/lib/video/mix.py')
-rw-r--r--voctocore/lib/video/mix.py63
1 files changed, 47 insertions, 16 deletions
diff --git a/voctocore/lib/video/mix.py b/voctocore/lib/video/mix.py
index 8bb7036..a9e1513 100644
--- a/voctocore/lib/video/mix.py
+++ b/voctocore/lib/video/mix.py
@@ -1,19 +1,30 @@
#!/usr/bin/python3
import logging
from gi.repository import Gst
+from enum import Enum
from lib.config import Config
+class ComposteModes(Enum):
+ fullscreen = 0
+
class VideoMix(object):
log = logging.getLogger('VideoMix')
mixingPipeline = None
+ caps = None
+ names = []
+
+ compositeMode = ComposteModes.fullscreen
+ sourceA = 0
+ sourceB = 1
+
def __init__(self):
- caps = Config.get('mix', 'videocaps')
+ self.caps = Config.get('mix', 'videocaps')
- names = Config.getlist('sources', 'video')
- self.log.info('Configuring Mixer for %u Sources', len(names))
+ self.names = Config.getlist('sources', 'video')
+ self.log.info('Configuring Mixer for %u Sources', len(self.names))
pipeline = """
videomixer name=mix !
@@ -21,10 +32,10 @@ class VideoMix(object):
textoverlay text=mixer halignment=left valignment=top ypad=175 !
intervideosink channel=video_mix
""".format(
- caps=caps
+ caps=self.caps
)
- for idx, name in enumerate(names):
+ for idx, name in enumerate(self.names):
pipeline += """
intervideosrc channel=video_{name}_mixer !
{caps} !
@@ -33,22 +44,42 @@ class VideoMix(object):
mix.
""".format(
name=name,
- caps=caps,
+ caps=self.caps,
idx=idx
)
- self.log.debug('Launching Mixing-Pipeline:\n%s', pipeline)
+ self.log.debug('Creating Mixing-Pipeline:\n%s', pipeline)
self.mixingPipeline = Gst.parse_launch(pipeline)
+
+ self.log.debug('Initializing Mixer-State')
+ self.updateMixerState()
+
+ self.log.debug('Launching Mixing-Pipeline:\n%s', pipeline)
self.mixingPipeline.set_state(Gst.State.PLAYING)
- mixerpad = self.mixingPipeline.get_by_name('mix').get_static_pad('sink_0')
- mixerpad.set_property('alpha', 0.5)
- mixerpad.set_property('xpos', 64)
- mixerpad.set_property('ypos', 64)
+ def updateMixerState(self):
+ if self.compositeMode == ComposteModes.fullscreen:
+ self.updateMixerStateFullscreen()
+
+ def updateMixerStateFullscreen(self):
+ self.log.info('Updating Mixer-State for Fullscreen-Composition')
+ for idx, name in enumerate(self.names):
+ alpha = int(idx == self.sourceA)
+
+ self.log.debug('Setting Mixerpad %u to x/y=0 and alpha=%u', idx, alpha)
+ mixerpad = self.mixingPipeline.get_by_name('mix').get_static_pad('sink_%u' % idx)
+ mixerpad.set_property('alpha', alpha )
+ mixerpad.set_property('xpos', 0)
+ mixerpad.set_property('ypos', 0)
+
+ self.log.debug('Resetting Scaler %u to non-scaling', idx)
+ capsfilter = self.mixingPipeline.get_by_name('caps_%u' % idx)
+ capsfilter.set_property('caps', Gst.Caps.from_string(self.caps))
- mixerpad = self.mixingPipeline.get_by_name('mix').get_static_pad('sink_1')
- mixerpad.set_property('alpha', 0.2)
+ def setVideoA(self, source):
+ self.sourceA = source
+ self.updateMixerState()
- capsilter = self.mixingPipeline.get_by_name('caps_1')
- capsilter.set_property('caps', Gst.Caps.from_string(
- 'video/x-raw,width=320,height=180'))
+ def setVideoB(self, source):
+ self.sourceN = source
+ self.updateMixerState()