aboutsummaryrefslogtreecommitdiff
path: root/voctocore/lib/pipeline.py
blob: f341491127280d6f56e5737fe1d954f3da83fac9 (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. from lib.streamblanker import StreamBlanker
  14. class Pipeline(object):
  15. """mixing, streaming and encoding pipeline constuction and control"""
  16. def __init__(self):
  17. self.log = logging.getLogger('Pipeline')
  18. self.log.info('Video-Caps configured to: %s', Config.get('mix', 'videocaps'))
  19. self.log.info('Audio-Caps configured to: %s', Config.get('mix', 'audiocaps'))
  20. names = Config.getlist('mix', 'sources')
  21. if len(names) < 1:
  22. raise RuntimeException("At least one AVSource must be configured!")
  23. self.sources = []
  24. self.mirrors = []
  25. self.previews = []
  26. self.sbsources = []
  27. self.log.info('Creating %u Creating AVSources: %s', len(names), names)
  28. for idx, name in enumerate(names):
  29. port = 10000 + idx
  30. self.log.info('Creating AVSource %s at tcp-port %u', name, port)
  31. source = AVSource(name, port)
  32. self.sources.append(source)
  33. port = 13000 + idx
  34. self.log.info('Creating Mirror-Output for AVSource %s at tcp-port %u', name, port)
  35. mirror = AVRawOutput('%s_mirror' % name, port)
  36. self.mirrors.append(mirror)
  37. if Config.getboolean('previews', 'enabled'):
  38. port = 14000 + idx
  39. self.log.info('Creating Preview-Output for AVSource %s at tcp-port %u', name, port)
  40. preview = AVPreviewOutput('%s_preview' % name, port)
  41. self.previews.append(preview)
  42. self.log.info('Creating Videmixer')
  43. self.vmix = VideoMix()
  44. self.log.info('Creating Audiomixer')
  45. self.amix = AudioMix()
  46. port = 16000
  47. self.log.info('Creating Mixer-Background VSource at tcp-port %u', port)
  48. self.bgsrc = VSource('background', port)
  49. port = 11000
  50. self.log.info('Creating Mixer-Output at tcp-port %u', port)
  51. self.mixout = AVRawOutput('mix_out', port)
  52. if Config.getboolean('previews', 'enabled'):
  53. port = 12000
  54. self.log.info('Creating Preview-Output for AVSource %s at tcp-port %u', name, port)
  55. self.mixpreview = AVPreviewOutput('mix_preview', port)
  56. if Config.getboolean('stream-blanker', 'enabled'):
  57. names = Config.getlist('stream-blanker', 'sources')
  58. if len(names) < 1:
  59. raise RuntimeException("At least one StreamBlanker-Source must be configured or the StreamBlanker disabled!")
  60. for idx, name in enumerate(names):
  61. port = 17000 + idx
  62. self.log.info('Creating StreamBlanker VSource %s at tcp-port %u', name, port)
  63. source = VSource('%s_streamblanker' % name, port)
  64. self.sbsources.append(source)
  65. port = 18000
  66. self.log.info('Creating StreamBlanker ASource at tcp-port %u', port)
  67. source = ASource('streamblanker', port)
  68. self.sbsources.append(source)
  69. self.log.info('Creating StreamBlanker')
  70. self.streamblanker = StreamBlanker()
  71. port = 15000
  72. self.log.info('Creating StreamBlanker-Output at tcp-port %u', port)
  73. self.streamout = AVRawOutput('streamblanker_out', port)