Cloud Containerization

From SOUND4wiki
Revision as of 16:14, 7 February 2024 by Camille (talk | contribs) (Created)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The SOUND4 .CL processing can be containerized.

General information

To provide the audio to the container, the easier is to use RTP to send and retrieve audio.

You can use the sound4.xxx-proc program contained in the archive to create the process using the dynamic library.

For X1.CL and IMPACT.CL, you can add extensions (Kantar.CL and Stream.CL) in the container to have them available.

The libraries for Linux have very little dependencies :

  • kernel >= 3.13
  • GlibC >= 2.19

So, using Debian>=8 or Ubuntu>=14.04 will work.

Special care

The distribution should have recent ca-certificates to be able to access HTTPS on the Internet, for licenses or metadata pulling.

The configuration storage should be in a volume to keep presets and configuration upon upgrades.

You need to pass license information when starting the container. This can be done with environment variables or process parameters.

You can check all available options by running the sound4.xxx-proc with -h to get help.

Example for X1.CL

Files used in image should be extracted from the matching process library archives.

Dockerfile

FROM debian:bookworm-slim
# install ca-certificates to access HTTPS for licenses
RUN apt update \
    && apt install -yq --no-install-recommends \
		ca-certificates \
    && rm -rf /var/lib/apt/lists/*
RUN mkdir -p /usr/share/sound4proc
WORKDIR /
# copy processing library
COPY lib/libsound4.x1.cloud.so /usr/local/lib
# copy processing helper executable
COPY bin/sound4.x1.cloud-proc /usr/local/bin

# OPTIONAL: Kantar.CL
COPY lib/libsound4.kantar.so /usr/local/lib
COPY lib/libsnapliveaudioembedder.so /usr/local/lib

# OPTIONAL: Stream.CL
COPY lib/libsound4.stream.so /usr/local/lib
# OPTIONAL: Stream.CL scripts in share/sound4/SOUND4\ Stream.CL\ Metaparsers/
COPY share/ /usr/local/share/

# force libs locate
RUN ldconfig
# rtp needs a logname
ENV LOGNAME=sound4
CMD /usr/local/bin/sound4.x1.cloud-proc

Docker-compose File

version: '3.4'
services:
  process:
    build: .
    restart: unless-stopped
    ports:
     - "${RTP_SRC_PORT:-5004}:${RTP_SRC_PORT:-5004}/udp"
     - "${HTTP_PORT:-80}:${HTTP_PORT:-80}"
    volumes:
     - process_storage:/usr/share/sound4proc
    command: [
        "/usr/local/bin/sound4.x1.cloud-proc"
        # You can get the full command line options by running the program with -h

        # For Kantar, disable usage of offline licenses in cloud solutions
        , "-a", "KANTAR_OfflineLicense=0"
        # , "-a", "KANTAR_LicPath=/usr/share/sound4lic"
        # For Kantar, you may force KANTAR_Login, KANTAR_Password, KANTAR_LicenseName and KANTAR_ChannelName
        # For stream, known metadata parsers
        , "-a", "Metadata_provided_path=/usr/local/share/sound4/SOUND4 Stream.CL Metaparsers"
        # For stream, if you want no metadata management in UI, set to 1
        , "-a", "Metadata_no_ui=0"
    ]
    environment:
      # where to save, internally
      - STATE_DIR=/usr/share/sound4proc
      # RTP/UDP listening specific IP (use for broadcast) or Livewire channel in
      # use 0 to receive directly RTP (no Livewire)
      - RTP_SRC_IP=${RTP_SRC_IP:-0}
      - RTP_SRC_PORT=${RTP_SRC_PORT:-5004}
      # Send back to this IP or Livewire channel
      - RTP_DEST_IP=${RTP_DEST_IP:-x.x.x.x}
      - RTP_DEST_PORT=${RTP_DEST_PORT:-5004}
      - PROC_VERB=${PROC_VERB:-}
      # Choose sample format in S16_LE, S16_BE, S24_LE, S24_BE, S32_LE, S32_BE, F32_LE, F32_BE
      - RTP_SAMPLE_FORMAT=${RTP_SAMPLE_FORMAT:-S16_BE}
      # receive/send RTP payload. NOTE: payload 97 allows to receive payload 96 or 97, to ease compatibility.
      - RTP_PAYLOAD=${RTP_PAYLOAD:-97}
      # Audio frames Per Output Packet
      - RTP_FRAMES=${RTP_FRAMES:-64}
      # Port for HTTP
      - HTTP_PORT=${HTTP_PORT:-80}
      # Setup/Admin user: see doc
      - SETUP_USER=${SETUP_USER:-}
      - SETUP_SECRET=${SETUP_SECRET:-}
      - ADMIN_USER=${ADMIN_USER:-}
      - ADMIN_SECRET=${ADMIN_SECRET:-}
      # IDs for the licence SOUND4 gave you
      - S4LOGINKEY=${S4LOGINKEY:-xxxxxxxx}
      - RADIO_NAME=${RADIO_NAME:-}
      - S4_AWS_ACCESS_KEY_ID=${S4_AWS_ACCESS_KEY_ID:-}
      - S4_AWS_SECRET_ACCESS_KEY=${S4_AWS_SECRET_ACCESS_KEY:-}
volumes:
  process_storage: