From d584a00ccdb27b18ac96ed12ae03947a6594f8a8 Mon Sep 17 00:00:00 2001
From: David Trattnig <david.trattnig@o94.at>
Date: Wed, 27 May 2020 16:27:05 +0200
Subject: [PATCH] Activate and deactivate channel.

---
 .../communication/liquidsoap/playerclient.py  | 132 +++++++++++-------
 1 file changed, 80 insertions(+), 52 deletions(-)

diff --git a/modules/communication/liquidsoap/playerclient.py b/modules/communication/liquidsoap/playerclient.py
index 541c2eaa..caebb012 100644
--- a/modules/communication/liquidsoap/playerclient.py
+++ b/modules/communication/liquidsoap/playerclient.py
@@ -28,7 +28,10 @@ from modules.communication.liquidsoap.client import LiquidSoapClient
 
 class LiquidSoapPlayerClient(LiquidSoapClient):
 
-    # ------------------------------------------------------------------------------------------ #
+    #
+    # Mixer
+    #
+
     def mixer(self, command, *args):
         if command == "status":
             return self.mixerstatus(*args)
@@ -37,27 +40,83 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
             return self.mixerinputs()
 
         if command == "volume":
-            return self.mixervolume(*args)
+            return self.mixer_volume(*args)
 
         if command == "select":
             if len(args) == 2:
-                return self.mixerselect(args[0], args[1])
+                return self.mixer_select(args[0], args[1])
+
+        if command == "activate":
+            if len(args) == 2:
+                return self.mixer_activate(args[0], args[1])
 
         return "LiquidSoapPlayerClient does not understand mixer."+command+str(args)
 
+
     # ------------------------------------------------------------------------------------------ #
-    def recorder(self, num, command, *args):
-        if command == "status":
-            return self.recorderstatus(num)
+    def mixerinputs(self):
+        # send command
+        self.command("mixer", "inputs")
 
-        if command == "start":
-            return self.recorderstart(num)
+        # convert to list and return it
+        return self.message.strip().split(' ')
 
-        if command == "stop":
-            return self.recorderstop(num)
+    # ------------------------------------------------------------------------------------------ #
+    def mixerstatus(self, pos=""):
+        """
+        Get state of a source in the mixer
+        @type    pos:       string
+        @param   pos:       Mixerposition
+        @rtype:  string
+        @return: Response from LiquidSoap
+        """
+        self.command("mixer", "status", str(pos))
+        return self.message
 
-        return "LiquidSoapPlayerClient does not understand mixer." + command + str(args)
 
+    def mixer_volume(self, pos, volume):
+        """
+        Sets some mixer channel to the given volume
+
+        Args:
+            pos (Integer):  The channel number
+            volume (Integer): The volume
+
+        Returns:
+            (String):   Liquidsoap server response
+        """
+        self.command("mixer", "volume", str(pos) + " " + str(volume))
+        return self.message
+
+
+    def mixer_select(self, pos, select):
+        """
+        Selects some mixer channel or vice versa.
+
+        Args:
+            pos (Integer):  The channel number
+            select (Boolean): Select or deselect
+
+        Returns:
+            (String):   Liquidsoap server response
+        """
+        self.command("mixer", "select", str(pos) + " " + str(select).lower())
+        return self.message
+
+
+    def mixer_activate(self, pos, activate):
+        """
+        Selects some mixer channel and increases the volume to 100 or vice versa.
+
+        Args:
+            pos (Integer):  The channel number
+            activate (Boolean): Activate or deactivate
+
+        Returns:
+            (String):   Liquidsoap server response
+        """
+        self.command("mixer", "activate", str(pos) + " " + str(activate).lower())
+        return self.message
 
 
     #
@@ -66,10 +125,11 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
 
     def playlist_push(self, channel, uri):
         """
-        Pushs the passed file URI to the playlist channel.
+        Pushes the passed file URI to the playlist channel.
 
         Args:
             channel (String):   Liquidsoap Channel ID
+            uri (String):       Path to the file
         """
         self.command(channel, 'push', uri)
         return self.message
@@ -183,51 +243,19 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
         return self.message
 
 
-
     # ------------------------------------------------------------------------------------------ #
-    def mixerinputs(self):
-        # send command
-        self.command("mixer", "inputs")
+    def recorder(self, num, command, *args):
+        if command == "status":
+            return self.recorderstatus(num)
 
-        # convert to list and return it
-        return self.message.strip().split(' ')
+        if command == "start":
+            return self.recorderstart(num)
 
-    # ------------------------------------------------------------------------------------------ #
-    def mixerstatus(self, pos=""):
-        """
-        Get state of a source in the mixer
-        @type    pos:       string
-        @param   pos:       Mixerposition
-        @rtype:  string
-        @return: Response from LiquidSoap
-        """
-        self.command("mixer", "status", str(pos))
-        return self.message
+        if command == "stop":
+            return self.recorderstop(num)
 
-    # ------------------------------------------------------------------------------------------ #
-    def mixerselect(self, pos, activate):
-        """
-        Kanal/Source aktivieren
-        @type    pos:       string
-        @param   pos:       Die Position
-        @type    namespace: string
-        @param   namespace: Namespace der Source
-        @rtype:  string
-        @return: Die Antwort des Liquidsoap-Servers
-        """
-        self.command("mixer", "select", str(pos) + " " + str(activate).lower())
-        return self.message
+        return "LiquidSoapPlayerClient does not understand mixer." + command + str(args)
 
-    # ------------------------------------------------------------------------------------------ #
-    def mixervolume(self, pos, volume):
-        """
-        set channel volume
-        :param pos:
-        :param volume:
-        :return:
-        """
-        self.command("mixer", "volume", str(pos) + " " + str(volume))
-        return self.message
 
     # ------------------------------------------------------------------------------------------ #
     # def recorderstatus(self, num):
-- 
GitLab