summaryrefslogtreecommitdiff
path: root/voctocore/lib/pipeline.py
blob: 18b54dd1679e2612a759b116f1904f749ca49a8f (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.avsource import AVSource
  7. from lib.asource import ASource
  8. from lib.vsource import VSource
  9. from lib.avrawoutput import AVRawOutput
  10. from lib.avpreviewoutput import AVPreviewOutput
  11. from lib.videomix import VideoMix
  12. from lib.audiomix import AudioMix
  13. class Pipeline(object):
  14. """mixing, streaming and encoding pipeline constuction and control"""
  15. def __init__(self):
  16. self.log = logging.getLogger('Pipeline')
  17. self.log.info('Video-Caps configured to: %s', Config.get('mix', 'videocaps'))
  18. self.log.info('Audio-Caps configured to: %s', Config.get('mix', 'audiocaps'))
  19. names = Config.getlist('mix', 'sources')
  20. if len(names) < 1:
  21. raise RuntimeException("At least one AVSource must be configured!")
  22. self.sources = []
  23. self.mirrors = []
  24. self.previews = []
  25. self.log.info('Creating %u Creating AVSources: %s', len(names), names)
  26. for idx, name in enumerate(names):
  27. port = 10000 + idx
  28. self.log.info('Creating AVSource %s at tcp-port %u', name, port)
  29. source = AVSource(name, port)
  30. self.sources.append(source)
  31. port = 13000 + idx
  32. self.log.info('Creating Mirror-Output for AVSource %s at tcp-port %u', name, port)
  33. mirror = AVRawOutput('%s_mirror' % name, port)
  34. self.mirrors.append(mirror)
  35. if Config.getboolean('previews', 'enabled'):
  36. port = 14000 + idx
  37. self.log.info('Creating Preview-Output for AVSource %s at tcp-port %u', name, port)
  38. preview = AVPreviewOutput('%s_preview' % name, port)
  39. self.previews.append(preview)
  40. self.log.info('Creating Videmixer')
  41. self.vmix = VideoMix()
  42. self.log.info('Creating Videmixer')
  43. self.amix = AudioMix()
  44. port = 16000
  45. self.bgsrc = VSource('background', port)
  46. port = 11000
  47. self.log.info('Creating Mixer-Output at tcp-port %u', port)
  48. self.mixout = AVRawOutput('mix_out', port)
  49. if Config.getboolean('previews', 'enabled'):
  50. port = 12000
  51. self.log.info('Creating Preview-Output for AVSource %s at tcp-port %u', name, port)
  52. self.mixpreview = AVPreviewOutput('mix_preview', port)