# Description: Server and user space API to deal with multimedia pipelines
# URL: https://pipewire.org
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: alsa-lib dbus ffmpeg gst-plugins-base
# Optional: alsa-ucm-conf avahi bluez fdk-aac flatpak graphviz jack libcanberra libsndfile libuv lilv pulseaudio rtkit speexdsp v4l-utils vulkan-loader wireplumber

name=pipewire
version=0.3.77
release=1
source=(https://github.com/PipeWire/pipewire/archive/$version/$name-$version.tar.gz)

build() {
  prt-get isinst avahi || PKGMK_PW+=' -Davahi=disabled'
  prt-get isinst bluez || PKGMK_PW+=' -Dbluez5=disabled'
  prt-get isinst fdk-aac || PKGMK_PW+=' -Dbluez5-codec-aac=disabled'
  prt-get isinst flatpak || PKGMK_PW+=' -Dflatpak=disabled'
  prt-get isinst jack || PKGMK_PW+=' -Dpipewire-jack=disabled -Djack=disabled'
  prt-get isinst pulseaudio || PKGMK_PW+=' -Dlibpulse=disabled'
  prt-get isinst v4l-utils || PKGMK_PW+=' -Dv4l2=disabled'
  prt-get isinst vulkan-loader || PKGMK_PW+=' -Dvulkan=disabled -Dvulkan=disabled'

  meson setup $name-$version build $PKGMK_PW \
    -D prefix=/usr \
    --buildtype=plain \
    -D b_lto=false \
    -D b_pie=true \
    -D docs=disabled \
    -D tests=disabled \
    -D session-managers=""

  meson compile -C build
  DESTDIR=$PKG meson install -C build

  # enable alsa by default
  install -Dm644 /dev/null $PKG/usr/share/pipewire/media-session.d/with-alsa
  mkdir -p $PKG/etc/alsa/conf.d
  ln -st $PKG/etc/alsa/conf.d /usr/share/alsa/alsa.conf.d/99-pipewire-default.conf
  ln -st $PKG/etc/alsa/conf.d /usr/share/alsa/alsa.conf.d/50-pipewire.conf

  # remove leftovers
  rm -r $PKG/usr/share/locale
}
