aboutsummaryrefslogtreecommitdiff
path: root/voctocore/lib/pipeline.py
blob: a13f1d20a7a9810a9028fb0e4edad6a6e97d0b7c (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. names = Config.getlist('mix', 'sources')
  18. if len(names) < 1:
  19. raise RuntimeError("At least one AVSource must be configured!")
  20. self.sources = []
  21. self.mirrors = []
  22. self.previews = []
  23. self.sbsources = []
  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. outputs = [name+'_mixer', name+'_mirror']
  29. if Config.getboolean('previews', 'enabled'):
  30. outputs.append(name+'_preview')
  31. source = AVSource(name, port, outputs=outputs)
  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 = AVSource('background', port, has_audio=False)
  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 RuntimeError("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 = AVSource('%s_streamblanker' % name, port, has_audio=False)
  64. self.sbsources.append(source)
  65. port = 18000
  66. self.log.info('Creating StreamBlanker ASource at tcp-port %u', port)
  67. source = AVSource('streamblanker', port, has_video=False)
  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)