# mkfifo pipe_a && mkfifo pipe_v && mkfifo pipe_s
# ln -s /var/www/html/Driver hls
# ln -s /mnt/Driver spool
# sudo docker compose up --detach
## sudo docker logs -f --tail 100 alarm-service-alarm-proxy-1
## sudo docker logs -f --tail 100 alarm-service-alarm-player-ks-1

version: '2'

services:

  ctl-video:
    restart: always
    image: expertmusic-streamer-raws/v2
    environment:
      TZ: Europe/Kiev
      SPOOL: /spool
      SPOOL_EXT: .h264
      PORT: 18001
      NEXT_ITEM_URL: /api/playlist/CHANNEL1/next/video
    command: node /app/ctl_static.js
    volumes:
      - ./spool:/spool
    logging:
      driver: "json-file"
      options:
        max-file: "5"   # number of files or file count
        max-size: "10m" # file size
        compress: "false"

  ctl-audio:
    restart: always
    image: expertmusic-streamer-raws/v2
    environment:
      TZ: Europe/Kiev
      SPOOL: /spool
      SPOOL_EXT: .aac
      PORT: 18002
      NEXT_ITEM_URL: /api/playlist/CHANNEL1/next/audio
    command: node /app/ctl_static.js
    volumes:
      - ./spool:/spool
    logging:
      driver: "json-file"
      options:
        max-file: "5"   # number of files or file count
        max-size: "10m" # file size
        compress: "false"

  feeder-video:
    restart: always
    image: expertmusic-streamer-raws/v2
    environment:
      TZ: Europe/Kiev
      SPOOL: /spool
      PIPE: /video
      FAILOVER: black
      NEXT_ITEM_URL: http://ctl-video:18001/api/playlist/CHANNEL1/next/video
    command: node /app/feeder.js
    volumes:
      - ./spool:/spool
      - ./pipe_v:/video
    logging:
      driver: "json-file"
      options:
        max-file: "5"   # number of files or file count
        max-size: "10m" # file size
        compress: "false"

  feeder-audio:
    restart: always
    image: expertmusic-streamer-raws/v2
    environment:
      TZ: Europe/Kiev
      SPOOL: /spool
      PIPE: /audio
      FAILOVER: silence
      NEXT_ITEM_URL: http://ctl-audio:18002/api/playlist/CHANNEL1/next/audio
    command: node /app/feeder.js
    volumes:
      - ./spool:/spool
      - ./pipe_a:/audio
    logging:
      driver: "json-file"
      options:
        max-file: "5"   # number of files or file count
        max-size: "10m" # file size
        compress: "false"

  raws2mux:
    restart: always
    image: expertmusic-streamer-raws/v2
    command: /app/raws2mux /video /audio /stream mpegts
    volumes:
      - ./pipe_v:/video
      - ./pipe_a:/audio
      - ./pipe_s:/stream
    logging:
      driver: "json-file"
      options:
        max-file: "5"   # number of files or file count
        max-size: "10m" # file size
        compress: "false"

  muxer:
    restart: always
    image: expertmusic-streamer-ts/v1
    command: /app/ffmpeg -i /stream -c copy -f hls -hls_list_size 30 -hls_segment_filename /hls/%s.ts -hls_time 2 -strftime 1 -hls_flags delete_segments -y /hls/stream.m3u8
    volumes:
      - ./pipe_s:/stream
      - ./hls:/hls
    logging:
      driver: "json-file"
      options:
        max-file: "5"   # number of files or file count
        max-size: "10m" # file size
        compress: "false"

