summaryrefslogtreecommitdiff
path: root/voctocore/lib/commands.py
diff options
context:
space:
mode:
authorMarkus Otto <otto@fs.tum.de>2015-08-14 19:01:05 +0200
committerMarkus Otto <otto@fs.tum.de>2015-08-15 12:56:22 +0200
commit079c0cc1aa089c865768b232003570fa73fc52fa (patch)
tree682266b73e2544c6c8d1b3cde17ece5b636951c1 /voctocore/lib/commands.py
parent2aa635013174a8c73839d52d678e503eabed2900 (diff)
add protocol features and minor fixes
Diffstat (limited to 'voctocore/lib/commands.py')
-rw-r--r--voctocore/lib/commands.py64
1 files changed, 57 insertions, 7 deletions
diff --git a/voctocore/lib/commands.py b/voctocore/lib/commands.py
index f0b8011..664a6ca 100644
--- a/voctocore/lib/commands.py
+++ b/voctocore/lib/commands.py
@@ -1,5 +1,7 @@
#!/usr/bin/python3
import logging
+import json
+
from lib.config import Config
from lib.videomix import CompositeModes
@@ -22,6 +24,12 @@ class ControlServerCommands():
if src_name_or_id < 0 or src_name_or_id >= len(self.sources):
raise IndexError("source %s unknown" % src_name_or_id)
+ def encodeSourceName(self, src_id):
+ try:
+ return self.sources[src_id]
+ except Exception as e:
+ raise IndexError("source %s unknown" % src_id)
+
def decodeBlankerSourceName(self, src_name_or_id):
if isinstance(src_name_or_id, str):
try:
@@ -32,6 +40,12 @@ class ControlServerCommands():
if src_name_or_id < 0 or src_name_or_id >= len(self.blankersources):
raise IndexError("source %s unknown" % src_name_or_id)
+ def encodeBlankerSourceName(self, src_id):
+ try:
+ return self.blankersources[src_id]
+ except Exception as e:
+ raise IndexError("source %s unknown" % src_id)
+
def message(self, *args):
return True
@@ -41,16 +55,28 @@ class ControlServerCommands():
self.pipeline.vmix.setVideoSourceA(src_id)
return True
+ def get_video_a(self):
+ src_id = self.pipeline.vmix.getVideoSourceA()
+ return (True, self.encodeSourceName(src_id))
+
def set_video_b(self, src_name_or_id):
src_id = self.decodeSourceName(src_name_or_id)
self.pipeline.vmix.setVideoSourceB(src_id)
return True
+ def get_video_b(self):
+ src_id = self.pipeline.vmix.getVideoSourceB()
+ return (True, self.encodeSourceName(src_id))
+
def set_audio(self, src_name_or_id):
src_id = self.decodeSourceName(src_name_or_id)
self.pipeline.amix.setAudioSource(src_id)
return True
+ def get_audio(self):
+ src_id = self.pipeline.amix.getAudioSource()
+ return (True, self.encodeSourceName(src_id))
+
def set_composite_mode(self, composite_mode):
try:
mode = CompositeModes[composite_mode]
@@ -60,11 +86,35 @@ class ControlServerCommands():
self.pipeline.vmix.setCompositeMode(mode)
return True
- def set_stream_blank(self, src_name_or_id):
- src_id = self.decodeBlankerSourceName(src_name_or_id)
- self.pipeline.streamblanker.setBlankSource(src_id)
- return True
+ def get_composite_mode(self):
+ try:
+ mode = self.pipeline.vmix.getCompositeMode()
+ return (True, mode.name)
+ except Exception as e:
+ raise KeyError("composite-mode %s unknown" % mode)
+
+ def set_stream_status(self, *args):
+ try:
+ if args[0] == "live":
+ self.pipeline.streamblanker.setBlankSource(None)
+ return True
+ elif args [0] == "blank":
+ src_id = self.decodeBlankerSourceName(args[1])
+ self.pipeline.streamblanker.setBlankSource(src_id)
+ return True
+ else:
+ return (False, "invocation: set_stream_status (live | blank <mode>)")
+ except IndexError as e:
+ return (False, "invocation: set_stream_status (live | blank <mode>)")
+
+ def get_stream_status(self):
+ if self.pipeline.streamblanker.blankSource is None:
+ return (True, "live")
+
+ name = self.encodeBlankerSourceName(self.pipeline.streamblanker.blankSource)
+ return (True, "blank " + name)
+
+ def get_config(self):
+ confdict = {k: dict(v) for k, v in dict(Config).items()}
+ return (True, json.dumps(confdict))
- def set_stream_live(self):
- self.pipeline.streamblanker.setBlankSource(None)
- return True