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