#
# Application configuration file
#

# for the compatibility purposes
version: 3

coordinator:
  # debugging switch
  #   - shows debug logs
  #   - allows selecting worker instances
  debug: false
  # selects free workers:
  #   - any (default, any free)
  #   - ping (with the lowest ping)
  selector: any
  # games library
  library:
    # root folder for the library (where games are stored)
    basePath: assets/games
    # an explicit list of supported file extensions
    # which overrides Libretro emulator ROMs configs
    supported:
    # a list of ignored words in the ROM filenames
    ignored:
      - neogeo
      - pgm
    # print some additional info
    verbose: true
    # enable library directory live reload
    # (experimental)
    watchMode: false
  monitoring:
    port: 6601
    # enable Go profiler HTTP server
    profilingEnabled: false
    metricEnabled: false
    urlPrefix: /coordinator
  # a custom Origins for incoming Websocket connections:
  # "" -- checks same origin policy
  # "*" -- allows all
  # "your address" -- checks for that address
  origin:
    userWs:
    workerWs:
  # HTTP(S) server config
  server:
    address: :8000
    https: false
    # Letsencrypt or self cert config
    tls:
      address: :443
      # allowed host name
      domain:
      # if both are set then will use certs
      # and Letsencryt instead
      httpsCert:
      httpsKey:
  analytics:
    inject: false
    gtag:

worker:
  # show more logs
  debug: false
  network:
    # a coordinator address to connect to
    coordinatorAddress: localhost:8000
    # where to connect
    endpoint: /wso
    # ping endpoint
    pingEndpoint: /echo
    # set public ping address (IP or hostname)
    publicAddress:
    # make coordinator connection secure (wss)
    secure: false
    # ISO Alpha-2 country code to group workers by zones
    zone:
  monitoring:
    # monitoring server port
    port: 6602
    profilingEnabled: false
    # monitoring server URL prefix
    metricEnabled: false
    urlPrefix: /worker
  server:
    address: :9000
    https: false
    tls:
      address: :444
      # LetsEncrypt config
      # allowed host name
      domain:
      # Own certs config
      httpsCert:
      httpsKey:
  # optional server tag
  tag:

emulator:
  # set output viewport scale factor
  scale: 1

  # set the total number of threads for the image processing
  # (experimental)
  threads: 4

  aspectRatio:
    # enable aspect ratio changing
    # (experimental)
    keep: false
    # recalculate emulator game frame size to the given WxH
    width: 320
    height: 240

  # enable autosave for emulator states if set to a non-zero value of seconds
  autosaveSec: 0

  # save directory for emulator states
  # special tag {user} will be replaced with current user's home dir
  storage: "{user}/.cr/save"

  # path for storing emulator generated files
  localPath: "./libretro"

  libretro:
    # use zip compression for emulator save states
    saveCompression: true
    # Libretro cores logging level: DEBUG = 0, INFO, WARN, ERROR, DUMMY = INT_MAX
    logLevel: 1
    cores:
      paths:
        libs: assets/cores
        configs: assets/cores
      # Config params for Libretro cores repository,
      # available types are:
      #   - buildbot (the default Libretro nightly repository)
      #   - github (GitHub raw repository with a similar structure to buildbot)
      #   - raw (just a link to a zip file extracted as is)
      repo:
        # enable auto-download for the list of cores (list->lib)
        sync: true
        # external cross-process mutex lock
        extLock: "{user}/.cr/cloud-game.lock"
        main:
          type: buildbot
          url: https://buildbot.libretro.com/nightly
          # if repo has file compression
          compression: zip
        # a secondary repo to use i.e. for not found in the main cores
        secondary:
          type: github
          url: https://github.com/sergystepanov/libretro-spiegel/blob/main
          compression: zip
      # Libretro core configuration
      #
      # The emulator selection will happen in this order:
      #   - based on the folder name in the folder param
      #   - based on the folder name (core name) in the list (i.e. nes, snes)
      #   - based on the rom names in the roms param
      #
      # Available config params:
      #   - altRepo (bool) prioritize secondary repo as the download source
      #   - lib (string)
      #   - config (string)
      #   - roms ([]string)
      #   - folder (string)
      #       By default emulator selection is based on the folder named as cores
      #       in the list (i.e. nes, snes) but if you specify folder param,
      #       then it will try to load the ROM file from that folder first.
      #   - width (int) -- broken
      #   - height (int) -- broken
      #   - ratio (float)
      #   - isGlAllowed (bool)
      #   - usesLibCo (bool)
      #   - hasMultitap (bool)
      list:
        gba:
          lib: mgba_libretro
          roms: [ "gba", "gbc" ]
        pcsx:
          lib: pcsx_rearmed_libretro
          roms: [ "cue" ]
          # example of folder override
          folder: psx
        # MAME core requires additional manual setup, please read:
        # https://docs.libretro.com/library/fbneo/
        mame:
          lib: fbneo_libretro
          roms: [ "zip" ]
        nes:
          lib: nestopia_libretro
          config: nestopia_libretro.cfg
          roms: [ "nes" ]
        snes:
          lib: snes9x_libretro
          roms: [ "smc", "sfc", "swc", "fig", "bs" ]
          hasMultitap: true
        n64:
          lib: mupen64plus_next_libretro
          altRepo: true
          config: mupen64plus_next_libretro.cfg
          roms: [ "n64", "v64", "z64" ]
          isGlAllowed: true
          usesLibCo: true

encoder:
  audio:
    # audio frame duration needed for WebRTC (Opus)
    # most of the emulators have ~1400 samples per a video frame,
    # so we keep the frame buffer roughly half of that size or 2 RTC packets per frame
    frame: 10
  video:
    # h264, vpx (VP8)
    codec: h264
    # concurrent execution units (0 - disabled)
    concurrency: 0
    # see: https://trac.ffmpeg.org/wiki/Encode/H.264
    h264:
      # Constant Rate Factor (CRF) 0-51 (default: 23)
      crf: 23
      # ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo
      preset: superfast
      # baseline, main, high, high10, high422, high444
      profile: baseline
      # film, animation, grain, stillimage, psnr, ssim, fastdecode, zerolatency
      tune: zerolatency
      # 0-3
      logLevel: 0
    # see: https://www.webmproject.org/docs/encoder-parameters
    vpx:
      # target bitrate (KBit/s)
      bitrate: 1200
      # force keyframe interval
      keyframeInterval: 5

# game recording
# (experimental)
# recording allows export RAW a/v streams of games
# by default, it will export audio as WAV files,
# video as a list of PNG-encoded images, and
# one additional FFMPEG concat demux file
recording:
  enabled: false
  # image compression level:
  #   0 - default compression
  #	 -1 - no compression
  #	 -2 - best speed
  #	 -3 - best compression
  compressLevel: 0
  # name contains the name of the recording dir (or zip)
  # format:
  # %date:go_time_format% -- refer: https://go.dev/src/time/format.go
  # %user% -- user name who started the recording
  # %game% -- game name (game ROM name)
  # %rand:len% -- a random string of given length
  # as example: 20210101101010_yeE_user1_badApple
  name: "%date:20060102150405%_%rand:3%_%user%_%game%"
  # zip and remove recording dir on completion
  zip: true
  # save directory
  folder: ./recording

storage:
  # cloud storage provider:
  #   - empty (No op storage stub)
  #   - oracle [Oracle Object Storage](https://www.oracle.com/cloud/storage/object-storage.html)
  provider:
  # this value contains arbitrary key attribute:
  #   - oracle: pre-authenticated URL (see: https://docs.oracle.com/en-us/iaas/Content/Object/Tasks/usingpreauthenticatedrequests.htm)
  key:

webrtc:
  # turn off default Pion interceptors (see: https://github.com/pion/interceptor)
  # (performance)
  disableDefaultInterceptors: true
  # indicates the role of the DTLS transport (see: https://github.com/pion/webrtc/blob/master/dtlsrole.go)
  # (debug)
  #  - (default)
  #  - 1 (auto)
  #  - 2 (client)
  #  - 3 (server)
  dtlsRole:
  # a list of STUN/TURN servers to use
  iceServers:
    - urls: stun:stun.l.google.com:19302
  # configures whether the ice agent should be a lite agent (true/false)
  # (performance)
  # don't use iceServers when enabled
  iceLite: false
  # ICE configuration
  # by default, ICE ports are random and unlimited
  # alternatives:
  #   1. instead of random unlimited port range for
  #   WebRTC connections, these params limit port range of ICE connections
  icePorts:
    min:
    max:
  #  2. select a single port to forward all ICE connections there
  singlePort:
  # override ICE candidate IP, see: https://github.com/pion/webrtc/issues/835,
  # can be used for Docker bridged network internal IP override
  iceIpMap:
  # set additional log level for WebRTC separately
  # -1 - trace, 6 - nothing, ..., debug - 0
  logLevel: 6
