diff options
Diffstat (limited to 'voctocore')
-rw-r--r-- | voctocore/lib/failvideosrc.py | 34 | ||||
-rw-r--r-- | voctocore/lib/pipeline.py | 5 | ||||
-rw-r--r-- | voctocore/lib/shmsrc.py | 4 |
3 files changed, 39 insertions, 4 deletions
diff --git a/voctocore/lib/failvideosrc.py b/voctocore/lib/failvideosrc.py new file mode 100644 index 0000000..500603a --- /dev/null +++ b/voctocore/lib/failvideosrc.py @@ -0,0 +1,34 @@ +#!/usr/bin/python3 +import time, logging +from gi.repository import GLib, Gst + +from lib.config import Config + +class FailVideoSrc(Gst.Bin): + log = logging.getLogger('FailVideoSrc') + colors = [ + 0xffff0000, # red + 0xff00ff00, # green + 0xff0000ff, # blue + 0xffffff00, # yellow + 0xff00ffff, # cyan + 0xffff00ff, # magenta + 0xffffffff, # white + ] + + def __init__(self, idx, name): + super().__init__() + + # Create elements + self.failsrc = Gst.ElementFactory.make('videotestsrc', None) + + # Add elements to Bin + self.add(self.failsrc) + + # Set properties + self.failsrc.set_property('foreground-color', self.colors[idx % len(self.colors)]) + + # Add Ghost Pads + self.add_pad( + Gst.GhostPad.new('src', self.failsrc.get_static_pad('src')) + ) diff --git a/voctocore/lib/pipeline.py b/voctocore/lib/pipeline.py index 35ecf2a..529aeca 100644 --- a/voctocore/lib/pipeline.py +++ b/voctocore/lib/pipeline.py @@ -12,6 +12,7 @@ from lib.videomix import VideoMix # from lib.audiomix import AudioMix from lib.distributor import TimesTwoDistributor from lib.shmsrc import FailsafeShmSrc +from lib.failvideosrc import FailVideoSrc class Pipeline(Gst.Pipeline): """mixing, streaming and encoding pipeline constuction and control""" @@ -45,11 +46,11 @@ class Pipeline(Gst.Pipeline): self.videonames = Config.getlist('sources', 'video') self.audionames = Config.getlist('sources', 'video') - for name in self.videonames: + for idx, name in enumerate(self.videonames): socket = os.path.join(socketpath, 'v-'+name) self.log.info('Creating video-source "%s" at socket-path %s', name, socket) - sourcebin = FailsafeShmSrc(socket) + sourcebin = FailsafeShmSrc(socket, FailVideoSrc(idx, name)) self.add(sourcebin) distributor = TimesTwoDistributor() diff --git a/voctocore/lib/shmsrc.py b/voctocore/lib/shmsrc.py index 64e3555..1158887 100644 --- a/voctocore/lib/shmsrc.py +++ b/voctocore/lib/shmsrc.py @@ -10,7 +10,7 @@ class FailsafeShmSrc(Gst.Bin): last_restart_retry = 0 is_in_failstate = True - def __init__(self, socket): + def __init__(self, socket, failsrc): super().__init__() caps = Gst.Caps.from_string(Config.get('sources', 'videocaps')) @@ -21,7 +21,7 @@ class FailsafeShmSrc(Gst.Bin): self.capsfilter = Gst.ElementFactory.make('capsfilter', None) self.failsrcsyncer = Gst.ElementFactory.make('identity', None) self.switch = Gst.ElementFactory.make('input-selector', None) - self.failsrc = Gst.ElementFactory.make('videotestsrc', None) + self.failsrc = failsrc; if not self.shmsrc or not self.capsfilter or not self.failsrcsyncer or not self.switch or not self.failsrc: self.log.error('could not create elements') |