]> git.parisson.com Git - telecaster-server.git/commitdiff
one deefuzzer instance for all
authorGuillaume Pellerin <guillaume.pellerin@free.fr>
Tue, 6 Feb 2024 20:59:07 +0000 (21:59 +0100)
committerGuillaume Pellerin <guillaume.pellerin@free.fr>
Tue, 6 Feb 2024 20:59:07 +0000 (21:59 +0100)
bin/streaming/telecaster.py
etc/telecaster/telecaster.yml

index 0a1a852330348e1fbf2de3dc4b4b0ef724888cd5..bf672abe9a70603de01b0a8ed9b1d68434d77ec0 100755 (executable)
@@ -36,7 +36,7 @@ AUDIO_PIPELINE_BASE="""jackaudiosrc connect=2 ! audio/x-raw, format=F32LE, chann
     ! queue ! audiodynamic characteristics=hard-knee mode=compressor threshold=0.95 ratio=0.001 \
     ! queue ! audioconvert \
     ! queue ! lamemp3enc quality={mp3_quality} \
-    ! queue ! shout2send ip={ip} port={port} password={password} mount=telecaster_live.mp3
+    ! queue ! shout2send ip={ip} port={port} password={password} mount=telecaster_live_{id}.mp3
 """
 
 V4L2_LOGITECH_PARAMS = {
@@ -85,10 +85,11 @@ class TeleCaster(Thread):
         Thread.__init__(self)
         conf_file = open(conf_file_path, 'r')
         self.conf = yaml.safe_load(conf_file)["telecaster"]
-        self.stream_types = ["audio", "video"]
-        self.deefuzzer_video_conf_file = "/tmp/telecaster_deefuzzer_video_monitor.yml"
-        self.deefuzzer_audio_conf_file = "/tmp/telecaster_deefuzzer_audio_monitor.yml"
-        # print(self.conf)
+        self.streams = [
+            {"type": "video", "format": "webm", "pipeline": VIDEO_PIPELINE_BASE},
+            {"type": "audio", "format": "mp3", "pipeline": AUDIO_PIPELINE_BASE}
+            ]
+        self.deefuzzer_conf_file = "/tmp/telecaster_deefuzzer_monitor.yml"
 
     def write_conf(self, conf_dict, path):
         filename, ext = os.path.splitext(path)
@@ -107,19 +108,58 @@ class TeleCaster(Thread):
             # print(args)
             subprocess.call(command, shell=True)
 
-    def deefuzzer_start(self, conf, conf_file):
+    def deefuzzer_start(self, conf):
         # print(self.conf)
-        self.write_conf(conf, conf_file)
-        deefuzzer = TeleCasterDeeFuzzer(conf_file)
+        self.write_conf(conf, self.deefuzzer_conf_file)
+        deefuzzer = TeleCasterDeeFuzzer(self.deefuzzer_conf_file)
         deefuzzer.start()
 
+    def stream_start(self):
+        deefuzzer_default_conf = deepcopy(self.conf["deefuzzer"])
+        deefuzzer_global_conf = {"deefuzzer": deepcopy(deefuzzer_default_conf)}
+        deefuzzer_global_conf["deefuzzer"]["station"] = []
+        deefuzzer_station_conf = deepcopy(deefuzzer_default_conf["station"])
+
+        for stream in self.streams:
+            for gstream in self.conf["gstreamer"][stream["type"]]:
+                # print(gstream)
+                if "logitech" in gstream:
+                    self.logitech_c92x_setup(gstream)
+
+                if stream["type"] =="video":
+                    audio_conf = deepcopy(self.conf["gstreamer"]["audio"][0])
+                    audio_conf.pop("id") if 'id' in audio_conf else None
+                    pipeline = stream["pipeline"].format(**gstream,
+                        **audio_conf,
+                        **self.conf["server"])
+                elif stream["type"] =="audio":
+                    pipeline = stream["pipeline"].format(**gstream,
+                        **self.conf["server"])
+
+
+                # print(pipeline)
+                tc_gstream = TeleCasterGStream(pipeline)
+                tc_gstream.start()
+
+                deefuzzer_local_conf = deepcopy(deefuzzer_station_conf)
+                deefuzzer_local_conf["media"]["format"] = stream["format"]
+                deefuzzer_local_conf["media"]["dir"] = deefuzzer_local_conf["media"]["dir"] + os.sep + stream["format"]
+                relay_url = "http://{ip}:{port}/telecaster_live_{id}.{format}".format(id=gstream["id"], **self.conf["server"], format=stream["format"])
+                deefuzzer_local_conf["relay"]["url"] = relay_url
+                deefuzzer_local_conf["record"]["dir"] = deefuzzer_local_conf["record"]["dir"] + os.sep + stream["format"] + os.sep + str(gstream["id"])
+                deefuzzer_local_conf["server"]["mountpoint"] = "monitor_" + str(gstream["id"]) + "." + stream["format"]
+                deefuzzer_global_conf["deefuzzer"]["station"].append(deefuzzer_local_conf)
+                print(deefuzzer_global_conf)
+
+        print(deefuzzer_global_conf)
+        self.deefuzzer_start(deefuzzer_global_conf)
+
     def video_start(self):
         deefuzzer_default_conf = deepcopy(self.conf["video"]["deefuzzer"])
         deefuzzer_station_conf = deepcopy(deefuzzer_default_conf["station"])
 
         deefuzzer_global_conf = {"deefuzzer": deepcopy(deefuzzer_default_conf)}
         deefuzzer_global_conf["deefuzzer"]["station"] = []
-#
 
         for video in self.conf["video"]["gstreamer"]:
             if "logitech" in video:
@@ -141,6 +181,7 @@ class TeleCaster(Thread):
 
         self.deefuzzer_start(deefuzzer_global_conf, self.deefuzzer_video_conf_file)
 
+
     def audio_start(self):
         deefuzzer_default_conf = deepcopy(self.conf["audio"]["deefuzzer"])
         deefuzzer_station_conf = deepcopy(deefuzzer_default_conf["station"])
@@ -166,9 +207,9 @@ class TeleCaster(Thread):
         self.deefuzzer_start(deefuzzer_global_conf, self.deefuzzer_audio_conf_file)
 
     def run(self):
-        self.video_start()
-        self.audio_start()
-
+        self.video_start()
+        self.audio_start()
+        self.stream_start()
 
 def main():
     if len(sys.argv) >= 2:
index 0409d1279566c8186b8ce589df4f8b40a2d38932..45066ab28df3e6be0453fa5d113539a846d7c30d 100644 (file)
@@ -4,9 +4,8 @@ telecaster:
     port: 8000
     password: hackme
     type: icecast
-  record_dir: /home/telecaster/monitor/
-  video:
-    gstreamer:
+  gstreamer:
+    video:
       - id: 0
         width: 848
         height: 480
@@ -27,113 +26,65 @@ telecaster:
         format: image/jpeg
         decoder: jpegdec
         logitech: true
-    deefuzzer:
-        log: /var/log/telecaster/telecaster_webm_monitor.log
-        m3u: /tmp/telecaster_webm_monitor.m3u
-        station:
-          control:
-            mode: 0
-            port: 16002
-          infos:
-            description: TeleCaster WebM monitor stream
-            genre: Vocal
-            name: monitor_1.webm
-            short_name: monitor_1.webm
-            url: https://www.parisson.com
-          jingles:
-            dir: /path/to/jingles
-            mode: '0'
-            shuffle: '0'
-          media:
-            bitrate: '512'
-            dir: /home/telecaster/media/webm
-            format: webm
-            ogg_quality: '4'
-            samplerate: '48000'
-            shuffle: '0'
-            voices: '1'
-          record:
-            dir: /home/telecaster/trash/webm/1
-            mode: 1
-          relay:
-            author: TeleCaster
-            mode: '1'
-            url: http://127.0.0.1:8000/telecaster_live_0.webm
-          rss:
-            dir: /var/www/rss
-            enclosure: '0'
-            media_url: http://localhost/rss/
-          server:
-            host: 127.0.0.1
-            mountpoint: monitor_0.webm
-            port: '8000'
-            public: '0'
-            sourcepassword: hackme
-            type: icecast
-          twitter:
-            key: 76728330-OjKgbHtn4II86Ad7pNUGEzfNAkGTW5Wvw38qUmLE
-            mode: '0'
-            secret: 4egZs1dSM37XVY8zXa016Yueku2fleXF2bx8k25V4
-            tags: bla bla
-
-  audio:
-    gstreamer:
-      channels: 2
-      opus_bitrate: 96000
-      mp3_quality: 4.0
-      gain_pre: 2.5
-      gain_post: 1.5
-      jack:
-        driver: alsa
-        samplerate: 48000
-        ring_buffers: 3
-        phw: 3
-        chw: 3
-    deefuzzer:
-      log: /var/log/telecaster/telecaster_mp3_monitor.log
-      m3u: /tmp/telecaster_mp3_monitor.m3u
-      station:
-        control:
-          mode: 0
-          port: 16001
-        infos:
-          description: TeleCaster MP3 monitor
-          genre: Vocal
-          name: monitor.mp3
-          short_name: monitor.mp3
-          url: https://www.parisson.com
-        jingles:
-          dir: /path/to/jingles
-          mode: 0
-          shuffle: 1
-        media:
-          bitrate: 96
-          dir: /home/telecaster/media/mp3
-          format: mp3
-          ogg_quality: 4
+    audio:
+      - id: 0
+        channels: 2
+        opus_bitrate: 96000
+        mp3_quality: 4.0
+        gain_pre: 2.5
+        gain_post: 1.5
+        jack:
+          driver: alsa
           samplerate: 48000
-          shuffle: 0
-          voices: '2'
-        record:
-          dir: /home/telecaster/trash/mp3
-          mode: 1
-        relay:
-          author: Inconnu
-          mode: 1
-          url: http://127.0.0.1:8000/telecaster_live.mp3
-        rss:
-          dir: /var/www/rss
-          enclosure: 0
-          media_url: http://localhost/rss/
-        server:
-          host: 127.0.0.1
-          mountpoint: monitor.mp3
-          port: 8000
-          public: 0
-          sourcepassword: hackme
-          type: icecast
-        twitter:
-          key: 76728330-OjKgbHtn4II86Ad7pNUGEzfNAkGTW5Wvw38qUmLE
-          mode: 0
-          secret: 4egZs1dSM37XVY8zXa016Yueku2fleXF2bx8k25V4
-          tags: bla bla
+          ring_buffers: 3
+          phw: 3
+          chw: 3
+  deefuzzer:
+    log: /var/log/telecaster/telecaster_monitor.log
+    m3u: /tmp/telecaster_monitor.m3u
+    station:
+      control:
+        mode: 0
+        port: 16002
+      infos:
+        description: TeleCaster monitor stream
+        genre: Vocal
+        name: monitor_1.webm
+        short_name: monitor_1.webm
+        url: https://www.parisson.com
+      jingles:
+        dir: /path/to/jingles
+        mode: '0'
+        shuffle: '0'
+      media:
+        bitrate: '512'
+        dir: /home/telecaster/media/
+        format: webm
+        ogg_quality: '4'
+        samplerate: '48000'
+        shuffle: '0'
+        voices: '1'
+      record:
+        dir: /home/telecaster/monitor/
+        mode: 1
+      relay:
+        author: TeleCaster
+        mode: '1'
+        url: http://127.0.0.1:8000/telecaster_live_0.webm
+      rss:
+        dir: /var/www/rss
+        enclosure: '0'
+        media_url: http://localhost/rss/
+      server:
+        host: 127.0.0.1
+        mountpoint: monitor_0.webm
+        port: '8000'
+        public: '0'
+        sourcepassword: hackme
+        type: icecast
+      twitter:
+        key: 76728330-OjKgbHtn4II86Ad7pNUGEzfNAkGTW5Wvw38qUmLE
+        mode: '0'
+        secret: 4egZs1dSM37XVY8zXa016Yueku2fleXF2bx8k25V4
+        tags: bla bla
+