summaryrefslogtreecommitdiff
path: root/voctocore/lib/pipeline.py
blob: a7058712f29b80ee37552d1df07ccf395c630054 (plain)
  1. import logging
  2. from gi.repository import Gst
  3. # import library components
  4. from lib.config import Config
  5. from lib.avsource import AVSource
  6. from lib.avrawoutput import AVRawOutput
  7. from lib.avpreviewoutput import AVPreviewOutput
  8. from lib.videomix import VideoMix
  9. from lib.audiomix import AudioMix
  10. from lib.streamblanker import StreamBlanker
  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. self.log.info('Default composit a source configured to: %s', Config.get('mix', 'defcompa'))
  18. names = Config.getlist('mix', 'sources')
  19. if len(names) < 1:
  20. raise RuntimeError("At least one AVSource must be configured!")
  21. self.sources = []
  22. self.mirrors = []
  23. self.previews = []
  24. self.sbsources = []
  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. outputs = [name+'_mixer', name+'_mirror']
  30. if Config.getboolean('previews', 'enabled'):
  31. outputs.append(name+'_preview')
  32. source = AVSource(name, port, outputs=outputs)
  33. self.sources.append(source)
  34. port = 13000 + idx
  35. self.log.info('Creating Mirror-Output for AVSource %s at tcp-port %u', name, port)
  36. mirror = AVRawOutput('%s_mirror' % name, port)
  37. self.mirrors.append(mirror)
  38. if Config.getboolean('previews', 'enabled'):
  39. port = 14000 + idx
  40. self.log.info('Creating Preview-Output for AVSource %s at tcp-port %u', name, port)
  41. preview = AVPreviewOutput('%s_preview' % name, port)
  42. self.previews.append(preview)
  43. self.log.info('Creating Videmixer')
  44. self.vmix = VideoMix()
  45. self.log.info('Creating Audiomixer')
  46. self.amix = AudioMix()
  47. port = 16000
  48. self.log.info('Creating Mixer-Background VSource at tcp-port %u', port)
  49. self.bgsrc = AVSource('background', port, has_audio=False)
  50. port = 11000
  51. self.log.info('Creating Mixer-Output at tcp-port %u', port)
  52. self.mixout = AVRawOutput('mix_out', port)
  53. if Config.getboolean('previews', 'enabled'):
  54. port = 12000
  55. self.log.info('Creating Preview-Output for AVSource %s at tcp-port %u', name, port)
  56. self.mixpreview = AVPreviewOutput('mix_preview', port)
  57. if Config.getboolean('stream-blanker', 'enabled'):
  58. names = Config.getlist('stream-blanker', 'sources')
  59. if len(names) < 1:
  60. raise RuntimeError("At least one StreamBlanker-Source must be configured or the StreamBlanker disabled!")
  61. for idx, name in enumerate(names):
  62. port = 17000 + idx
  63. self.log.info('Creating StreamBlanker VSource %s at tcp-port %u', name, port)
  64. source = AVSource('%s_streamblanker' % name, port, has_audio=False)
  65. self.sbsources.append(source)
  66. port = 18000
  67. self.log.info('Creating StreamBlanker ASource at tcp-port %u', port)
  68. source = AVSource('streamblanker', port, has_video=False)
  69. self.sbsources.append(source)
  70. self.log.info('Creating StreamBlanker')
  71. self.streamblanker = StreamBlanker()
  72. port = 15000
  73. self.log.info('Creating StreamBlanker-Output at tcp-port %u', port)
  74. self.streamout = AVRawOutput('streamblanker_out', port)