summaryrefslogtreecommitdiff
path: root/voctocore/lib/commands.py
blob: f3243f36af2c3ed114f6e6812945cc7382b283f2 (plain)
  1. #!/usr/bin/python3
  2. import logging
  3. from lib.config import Config
  4. class ControlServerCommands():
  5. log = logging.getLogger('ControlServerCommands')
  6. pipeline = None
  7. vnames = []
  8. def __init__(self, pipeline):
  9. self.pipeline = pipeline
  10. self.vnames = Config.getlist('sources', 'video')
  11. def decodeVideoSrcName(self, src_name_or_id):
  12. if isinstance(src_name_or_id, str):
  13. try:
  14. return self.vnames.index(src_name_or_id)
  15. except Exception as e:
  16. raise IndexError("video-source %s unknown" % src_name_or_id)
  17. if src_name_or_id < 0 or src_name_or_id >= len(self.vnames):
  18. raise IndexError("video-source %s unknown" % src_name_or_id)
  19. def set_video_a(self, src_name_or_id):
  20. src_id = self.decodeVideoSrcName(src_name_or_id)
  21. self.pipeline.vmixer.setVideoA(src_id)
  22. return True
  23. def set_video_b(self, src_name_or_id):
  24. src_id = self.decodeVideoSrcName(src_name_or_id)
  25. self.pipeline.vmixer.setVideoB(src_id)
  26. return True
  27. def set_composite_mode(self, composite_mode):
  28. self.pipeline.vmixer.set_composite_mode(src_name_or_id)
  29. return True