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