aboutsummaryrefslogtreecommitdiff
path: root/voctocore/lib/pipeline.py
blob: a4ada0447ee9be3862d9445b48535b4eb689e9ad (plain)
  1. #!/usr/bin/python3
  2. import logging
  3. from gi.repository import Gst
  4. # import library components
  5. from lib.config import Config
  6. from lib.video.src import VideoSrc
  7. from lib.video.rawoutput import VideoRawOutput
  8. from lib.video.mix import VideoMix
  9. class Pipeline(object):
  10. """mixing, streaming and encoding pipeline constuction and control"""
  11. log = logging.getLogger('Pipeline')
  12. vsources = []
  13. vmirrors = []
  14. vpreviews = []
  15. vmixer = None
  16. vmixerout = None
  17. def __init__(self):
  18. self.log.debug('creating Video-Pipeline')
  19. self.initVideo()
  20. self.log.debug('creating Control-Server')
  21. def initVideo(self):
  22. caps = Config.get('mix', 'videocaps')
  23. self.log.info('Video-Caps configured to: %s', caps)
  24. names = Config.getlist('sources', 'video')
  25. if len(names) < 1:
  26. raise RuntimeException("At least one Video-Source must be configured!")
  27. for idx, name in enumerate(names):
  28. port = 10000 + idx
  29. self.log.info('Creating Video-Source %s at tcp-port %u', name, port)
  30. source = VideoSrc(name, port, caps)
  31. self.vsources.append(source)
  32. port = 13000 + idx
  33. self.log.info('Creating Mirror-Output for Video-Source %s at tcp-port %u', name, port)
  34. mirror = VideoRawOutput('video_%s_mirror' % name, port, caps)
  35. self.vmirrors.append(mirror)
  36. self.log.debug('Creating Video-Mixer')
  37. self.vmixer = VideoMix()
  38. port = 11000
  39. self.log.debug('Creating Video-Mixer-Output at tcp-port %u', port)
  40. self.vmixerout = VideoRawOutput('video_mix', port, caps)