# Specifies the Docker Compose file version.
version: '3.9'  
# Defines the services to be run.
services:  
  # Stream Capture Container
  stream_capture:  # Service name for the Stream Capture Container.
    # # Docker image name and tag
    # image: stream-capture:latest  
    # # Container name  
    # container_name: StreamCaptureContainer  
    # Specifies the build configuration.
    build:  
      # Sets the build context to the current directory.
      context: .  
      # Specifies the Dockerfile to use for building the image.     
      dockerfile: docker/capture/Dockerfile  
    # 
    environment:    
      - HLS_URL=${HLS_URL}
      - CHANNEL_NAME=${CHANNEL_NAME}
      - LOG_FILE_NAME=${LOG_FILE}
      - DRM_CONFIG=${DRM_CONFIG}
      - ORIGIN_TTL=${ORIGIN_TTL} 
      - SEGMENT_DURATION=${SEGMENT_DURATION}
      - MAX_CAPTURE_RETRIES=${MAX_CAPTURE_RETRIES}
      - EXIT_ON_FAILURE=${EXIT_ON_FAILURE}
      - CAPTURE_RETRY_INTERVAL=${RETRY_INTERVAL}
      - MAX_TS_FILE_NUMBER=${MAX_TS_FILE_NUMBER}
      - ASPECT_RATIO=${ASPECT_RATIO}
      - FPS=${ASPECT_RATIO} 
      - RESOLUTION=${RESOLUTION}
      - MIN_BITRATE=${MIN_BITRATE}
      - MAX_BITRATE=${MAX_BITRATE}
      - AUDIO_BITRATE=${AUDIO_BITRATE}
      - AUDIO_SAMPLE_RATE=${AUDIO_SAMPLE_RATE}
      - AUDIO_CHANNELS=${AUDIO_CHANNELS}
    # Specifies volume mounts for the service. 
    volumes:  
      # Mount the host machine's ./streams directory to /app/streams in the container. 
      - ./streams:/app/streams 
    # Defines the command to run in the container.
    command: ["sh", "/app/stream_capture.sh"]  
    # Network 
    networks:
      - PlutoTV_network

  # Stream Listener Container
  stream_listener:  # Service name for the Stream Listener Container.
    # # Docker image name and tag
    # image: stream-listener:latest  
    # # Container name  
    # container_name: StreamListenerContainer  
    # Specifies the build configuration.
    build:  
      # Sets the build context to the current directory.
      context: .  
      # Specifies the Dockerfile to use for building the image.
      dockerfile: docker/listner/Dockerfile    
    # 
    environment:     
      - CHANNEL_NAME=${CHANNEL_NAME}
      - SEGMENT_DURATION=${SEGMENT_DURATION}
      - MAX_TS_FILE_NUMBER=${MAX_TS_FILE_NUMBER}
    # Specifies volume mounts for the service. 
    volumes:  
      # Mount the host machine's ./streams directory to /app/streams in the container. 
      - ./streams:/app/streams  
    # 
    depends_on:
      # Ensure StreamCaptureContainer is started first
      - stream_capture  
    # Network 
    networks:
      - PlutoTV_network

networks:
  PlutoTV_network:
    driver: bridge  