aboutsummaryrefslogtreecommitdiff
path: root/voctocore/lib/pipeline.py
blob: 9c6a7f84d8d8d9bea7913ac6f2218fa9049008fe (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. from lib.streamblanker import StreamBlanker
  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 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)