summaryrefslogtreecommitdiff
path: root/voctocore/lib/pipeline.py
blob: 4e4a71453bb82f162a65a05d6cca50a2eb491bda (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.video.src import VideoSrc
  7. from lib.video.rawoutput import VideoRawOutput
  8. from lib.video.mix import VideoMix
  9. from lib.audio.src import AudioSrc
  10. from lib.audio.rawoutput import AudioRawOutput
  11. from lib.audio.mix import AudioMix
  12. class Pipeline(object):
  13. """mixing, streaming and encoding pipeline constuction and control"""
  14. log = logging.getLogger('Pipeline')
  15. vsources = []
  16. vmirrors = []
  17. vpreviews = []
  18. vmixer = None
  19. vmixerout = None
  20. asources = []
  21. amirrors = []
  22. apreviews = []
  23. amixer = None
  24. amixerout = None
  25. def __init__(self):
  26. self.log.debug('creating Video-Pipeline')
  27. self.initVideo()
  28. self.log.debug('creating Audio-Pipeline')
  29. self.initAudio()
  30. def initVideo(self):
  31. caps = Config.get('mix', 'videocaps')
  32. self.log.info('Video-Caps configured to: %s', caps)
  33. names = Config.getlist('sources', 'video')
  34. if len(names) < 1:
  35. raise RuntimeException("At least one Video-Source must be configured!")
  36. for idx, name in enumerate(names):
  37. port = 10000 + idx
  38. self.log.info('Creating Video-Source %s at tcp-port %u', name, port)
  39. source = VideoSrc(name, port, caps)
  40. self.vsources.append(source)
  41. port = 13000 + idx
  42. self.log.info('Creating Mirror-Output for Video-Source %s at tcp-port %u', name, port)
  43. mirror = VideoRawOutput('video_%s_mirror' % name, port, caps)
  44. self.vmirrors.append(mirror)
  45. self.log.debug('Creating Video-Mixer')
  46. self.vmixer = VideoMix()
  47. port = 11000
  48. self.log.debug('Creating Video-Mixer-Output at tcp-port %u', port)
  49. self.vmixerout = VideoRawOutput('video_mix', port, caps)
  50. def initAudio(self):
  51. caps = Config.get('mix', 'audiocaps')
  52. self.log.info('Audio-Caps configured to: %s', caps)
  53. names = Config.getlist('sources', 'audio')
  54. if len(names) < 1:
  55. raise RuntimeException("At least one Audio-Source must be configured!")
  56. for idx, name in enumerate(names):
  57. port = 20000 + idx
  58. self.log.info('Creating Audio-Source %s at tcp-port %u', name, port)
  59. source = AudioSrc(name, port, caps)
  60. self.asources.append(source)
  61. port = 23000 + idx
  62. self.log.info('Creating Mirror-Output for Audio-Source %s at tcp-port %u', name, port)
  63. mirror = AudioRawOutput('audio_%s_mirror' % name, port, caps)
  64. self.amirrors.append(mirror)