summaryrefslogtreecommitdiff
path: root/roles/streaming/dolmetsch-raspi
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2021-07-30 21:54:12 +0200
committerChristian Pointner <equinox@spreadspace.org>2021-07-30 21:54:12 +0200
commite578f4538dad9aa7cd977094e58293e847990d30 (patch)
treee69f9edd2fe8d312e0ee4d0f7fb3adda35d88d7e /roles/streaming/dolmetsch-raspi
parentmove some legacy stuff to graveyard (diff)
move dolmetsch-raspi to generic folder
Diffstat (limited to 'roles/streaming/dolmetsch-raspi')
-rw-r--r--roles/streaming/dolmetsch-raspi/defaults/main.yml3
-rw-r--r--roles/streaming/dolmetsch-raspi/handlers/main.yml4
-rw-r--r--roles/streaming/dolmetsch-raspi/tasks/main.yml81
-rw-r--r--roles/streaming/dolmetsch-raspi/templates/dolmetschctl.service.j222
-rw-r--r--roles/streaming/dolmetsch-raspi/templates/dolmetschctld.service.j221
-rw-r--r--roles/streaming/dolmetsch-raspi/templates/rtp-recv.service.j222
-rw-r--r--roles/streaming/dolmetsch-raspi/templates/rtp-recv.sh.j214
-rw-r--r--roles/streaming/dolmetsch-raspi/templates/rtp-send.service.j222
-rw-r--r--roles/streaming/dolmetsch-raspi/templates/rtp-send.sh.j214
9 files changed, 203 insertions, 0 deletions
diff --git a/roles/streaming/dolmetsch-raspi/defaults/main.yml b/roles/streaming/dolmetsch-raspi/defaults/main.yml
new file mode 100644
index 00000000..987a0481
--- /dev/null
+++ b/roles/streaming/dolmetsch-raspi/defaults/main.yml
@@ -0,0 +1,3 @@
+---
+dolmetsch_raspi_golang_version: 1.11.5
+dolmetsch_raspi_golang_checksum: "sha256:b26b53c94923f78955236386fee0725ef4e76b6cb47e0df0ed0c0c4724e7b198"
diff --git a/roles/streaming/dolmetsch-raspi/handlers/main.yml b/roles/streaming/dolmetsch-raspi/handlers/main.yml
new file mode 100644
index 00000000..bb7fde2b
--- /dev/null
+++ b/roles/streaming/dolmetsch-raspi/handlers/main.yml
@@ -0,0 +1,4 @@
+---
+- name: reload systemd
+ systemd:
+ daemon_reload: yes
diff --git a/roles/streaming/dolmetsch-raspi/tasks/main.yml b/roles/streaming/dolmetsch-raspi/tasks/main.yml
new file mode 100644
index 00000000..10d55766
--- /dev/null
+++ b/roles/streaming/dolmetsch-raspi/tasks/main.yml
@@ -0,0 +1,81 @@
+---
+- name: install packages
+ apt:
+ name:
+ - gstreamer1.0-tools
+ - gstreamer1.0-plugins-base
+ - gstreamer1.0-plugins-good
+ - gstreamer1.0-plugins-bad
+ - gstreamer1.0-alsa
+ - git
+ - libasound2-dev
+ - telnet
+
+- name: download golang tarball
+ get_url:
+ url: "https://dl.google.com/go/go{{ dolmetsch_raspi_golang_version }}.linux-armv6l.tar.gz"
+ dest: "/usr/local/src/go{{ dolmetsch_raspi_golang_version }}.linux-armv6l.tar.gz"
+ checksum: "{{ dolmetsch_raspi_golang_checksum }}"
+
+- name: check current goloang version (if any)
+ command: /usr/local/go/bin/go version
+ ignore_errors: yes
+ check_mode: no
+ changed_when: false
+ register: golang_version
+
+- name: update golang installation
+ when: golang_version is failed or golang_version.stdout != ("go version go" + dolmetsch_raspi_golang_version + " linux/arm")
+ block:
+ - name: remove old golang installation
+ file:
+ path: /usr/local/go
+ state: absent
+
+ - name: extract the golang tarball
+ unarchive:
+ src: "/usr/local/src/go{{ dolmetsch_raspi_golang_version }}.linux-armv6l.tar.gz"
+ dest: /usr/local
+ copy: no
+
+- name: prepare dolmetschctl install path
+ file:
+ path: /opt/dolmetschctl
+ state: directory
+
+- name: build dolmetschctl (server and client)
+ loop:
+ - dolmetschctl
+ - dolmetschctld
+ command: "/usr/local/go/bin/go get spreadspace.org/dolmetschctl/cmd/{{ item }}"
+ args:
+ creates: "/opt/dolmetschctl/bin/{{ item }}"
+ environment:
+ GOPATH: /opt/dolmetschctl
+
+- name: install dolmetschctl systemd units
+ loop:
+ - dolmetschctl
+ - dolmetschctld
+ template:
+ src: "{{ item }}.service.j2"
+ dest: "/etc/systemd/system/{{ item }}.service"
+ notify: reload systemd
+
+- name: install rtp send/receive scripts
+ loop:
+ - rtp-recv
+ - rtp-send
+ template:
+ src: "{{ item }}.sh.j2"
+ dest: "/usr/local/bin/{{ item }}.sh"
+ mode: 0750
+
+- name: install rtp send/receive systemd units
+ loop:
+ - rtp-recv
+ - rtp-send
+ template:
+ src: "{{ item }}.service.j2"
+ dest: "/etc/systemd/system/{{ item }}.service"
+ notify: reload systemd
diff --git a/roles/streaming/dolmetsch-raspi/templates/dolmetschctl.service.j2 b/roles/streaming/dolmetsch-raspi/templates/dolmetschctl.service.j2
new file mode 100644
index 00000000..cd97cc3e
--- /dev/null
+++ b/roles/streaming/dolmetsch-raspi/templates/dolmetschctl.service.j2
@@ -0,0 +1,22 @@
+[Unit]
+Description=dolmetschctl Client
+
+[Service]
+{# TODO: remove hardcoded IP #}
+ExecStart=/opt/dolmetschctl/bin/dolmetschctl 192.168.48.102:8234
+Restart=always
+RestartSecs=1s
+StartLimitBurst=10
+StartLimitIntervalSec=5s
+CapabilityBoundingSet=CAP_NET_BIND_SERVICE
+NoNewPrivileges=yes
+PrivateTmp=yes
+ProtectSystem=strict
+ProtectHome=yes
+ProtectKernelTunables=yes
+ProtectControlGroups=yes
+RestrictRealtime=yes
+RestrictAddressFamilies=AF_INET AF_INET6
+
+[Install]
+WantedBy=multi-user.target
diff --git a/roles/streaming/dolmetsch-raspi/templates/dolmetschctld.service.j2 b/roles/streaming/dolmetsch-raspi/templates/dolmetschctld.service.j2
new file mode 100644
index 00000000..c8c9ca79
--- /dev/null
+++ b/roles/streaming/dolmetsch-raspi/templates/dolmetschctld.service.j2
@@ -0,0 +1,21 @@
+[Unit]
+Description=dolmetschctl Server
+
+[Service]
+ExecStart=/opt/dolmetschctl/bin/dolmetschctld
+Restart=always
+RestartSecs=1s
+StartLimitBurst=10
+StartLimitIntervalSec=5s
+CapabilityBoundingSet=CAP_NET_BIND_SERVICE
+NoNewPrivileges=yes
+PrivateTmp=yes
+ProtectSystem=strict
+ProtectHome=yes
+ProtectKernelTunables=yes
+ProtectControlGroups=yes
+RestrictRealtime=yes
+RestrictAddressFamilies=AF_INET AF_INET6
+
+[Install]
+WantedBy=multi-user.target
diff --git a/roles/streaming/dolmetsch-raspi/templates/rtp-recv.service.j2 b/roles/streaming/dolmetsch-raspi/templates/rtp-recv.service.j2
new file mode 100644
index 00000000..b338ff65
--- /dev/null
+++ b/roles/streaming/dolmetsch-raspi/templates/rtp-recv.service.j2
@@ -0,0 +1,22 @@
+[Unit]
+Description=RTP Receiver
+
+[Service]
+{# TODO: remove hardcoded IP #}
+ExecStart=/usr/local/bin/rtp-recv.sh 192.168.48.103
+Restart=always
+RestartSecs=1s
+StartLimitBurst=10
+StartLimitIntervalSec=5s
+CapabilityBoundingSet=CAP_NET_BIND_SERVICE
+NoNewPrivileges=yes
+PrivateTmp=yes
+ProtectSystem=strict
+ProtectHome=yes
+ProtectKernelTunables=yes
+ProtectControlGroups=yes
+RestrictRealtime=yes
+RestrictAddressFamilies=AF_INET AF_INET6
+
+[Install]
+WantedBy=multi-user.target
diff --git a/roles/streaming/dolmetsch-raspi/templates/rtp-recv.sh.j2 b/roles/streaming/dolmetsch-raspi/templates/rtp-recv.sh.j2
new file mode 100644
index 00000000..c9a89f95
--- /dev/null
+++ b/roles/streaming/dolmetsch-raspi/templates/rtp-recv.sh.j2
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+HOST="$1"
+if [ -z "$HOST" ]; then
+ echo "usage: $0 <remote-host>"
+ exit 1
+fi
+
+#export GST_DEBUG=3
+exec gst-launch-1.0 rtpbin name=rtpbin latency=50 \
+ udpsrc port=5000 caps="application/x-rtp,media=(string)audio,encoding-name=(string)OPUS,clock-rate=(int)48000" ! rtpbin.recv_rtp_sink_0 \
+ rtpbin. ! rtpopusdepay ! opusdec ! alsasink \
+ udpsrc port=5001 ! rtpbin.recv_rtcp_sink_0 \
+ rtpbin.send_rtcp_src_0 ! udpsink "host=$HOST" port=5001 sync=false async=false
diff --git a/roles/streaming/dolmetsch-raspi/templates/rtp-send.service.j2 b/roles/streaming/dolmetsch-raspi/templates/rtp-send.service.j2
new file mode 100644
index 00000000..40a029ab
--- /dev/null
+++ b/roles/streaming/dolmetsch-raspi/templates/rtp-send.service.j2
@@ -0,0 +1,22 @@
+[Unit]
+Description=RTP Sender
+
+[Service]
+{# TODO: remove hardcoded IP #}
+ExecStart=/usr/local/bin/rtp-send.sh 192.168.48.102
+Restart=always
+RestartSecs=1s
+StartLimitBurst=10
+StartLimitIntervalSec=5s
+CapabilityBoundingSet=CAP_NET_BIND_SERVICE
+NoNewPrivileges=yes
+PrivateTmp=yes
+ProtectSystem=strict
+ProtectHome=yes
+ProtectKernelTunables=yes
+ProtectControlGroups=yes
+RestrictRealtime=yes
+RestrictAddressFamilies=AF_INET AF_INET6
+
+[Install]
+WantedBy=multi-user.target
diff --git a/roles/streaming/dolmetsch-raspi/templates/rtp-send.sh.j2 b/roles/streaming/dolmetsch-raspi/templates/rtp-send.sh.j2
new file mode 100644
index 00000000..9754b620
--- /dev/null
+++ b/roles/streaming/dolmetsch-raspi/templates/rtp-send.sh.j2
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+HOST="$1"
+if [ -z "$HOST" ]; then
+ echo "usage: $0 <remote-host>"
+ exit 1
+fi
+
+#export GST_DEBUG=3
+exec gst-launch-1.0 rtpbin name=rtpbin \
+ alsasrc device=hw:CODEC ! 'audio/x-raw,rate=48000,channels=1' ! opusenc ! rtpopuspay ! rtpbin.send_rtp_sink_0 \
+ rtpbin.send_rtp_src_0 ! udpsink "host=$HOST" port=5000 \
+ rtpbin.send_rtcp_src_0 ! udpsink "host=$HOST" port=5001 sync=false async=false \
+ udpsrc port=5001 ! rtpbin.recv_rtcp_sink_0