# Description: An essential exemplary set of plugins for gstreamer
# URL: https://gstreamer.freedesktop.org/modules/gst-plugins-base.html
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: gl-headers graphene gstreamer libgudev libjpeg-turbo libtheora libvisual-plugins opus orc pango
# Optional: cdparanoia libglvnd wayland-protocols

name=gst-plugins-base
version=1.24.2
release=1
source=(https://gstreamer.freedesktop.org/src/$name/$name-$version.tar.xz)

build() {
  # decide accordingly to what mesa builds with
  [ -e /usr/lib/pkgconfig/egl.pc ] || prt-get isinst wayland-protocols && \
    PKGMK_GST_PLATFORM+='egl' \
    PKGMK_GST_GLAPI+='gles2' \
    PKGMK_GST_WINDOW+='egl'
  prt-get isinst xorg-libxdamage xorg-libxrandr xorg-libxshmfence xorg-libxvmc xorg-libxxf86vm && \
    PKGMK_GST_PLATFORM+=',glx' \
    PKGMK_GST_GLAPI+=',opengl' \
    PKGMK_GST_WINDOW+=',x11'

  meson setup build $name-$version \
    --prefix=/usr \
    --libexecdir=/usr/lib \
    --wrap-mode=nodownload \
    -D buildtype=plain \
    -D gl=enabled \
    -D gl-graphene=enabled \
    -D gl_platform=${PKGMK_GST_PLATFORM#,} \
    -D gl_api=${PKGMK_GST_GLAPI#,} \
    -D gl_winsys=${PKGMK_GST_WINDOW#,} \
    -D nls=disabled \
    -D package-name="GStreamer (CRUX Linux)" \
    -D package-origin="https://crux.nu/"

  meson compile -C build -j ${JOBS:-1}
  DESTDIR=$PKG meson install -C build
}
