# Maintainer: Benjamin Klettbach <b dot klettbach at gmail dot com >
# Contributor: Jonathan Steel <jsteel at archlinux.org>
# Contributor: ArcticVanguard <LideEmily at gmail dot com>
# Contributor: ledti <antergist at gmail dot com>

pkgname=obs-studio-git
_pkgname=${pkgname%-git}
pkgver=32.2.1.r6.g220a163
pkgrel=1
epoch=5
pkgdesc="Free, open source software for live streaming and recording (with websocket support)"
arch=("i686" "x86_64")
url="https://obsproject.com/"
license=("GPL-2.0-or-later")
depends=('ffmpeg' 'jansson' 'libxinerama' 'libxkbcommon-x11' 'mbedtls' 'rnnoise' 'pciutils'
	'qt6-svg' 'curl' 'jack' 'gtk-update-icon-cache' 'pipewire' 'libxcomposite'
	'libdatachannel')
makedepends=('git' 'cmake' 'extra-cmake-modules' 'libfdk-aac' 'x264' 'swig' 'python' 'luajit' 'sndio' 'ffnvcodec-headers' 'uthash' 'nlohmann-json' 'ffnvcodec-headers' 'asio' 'websocketpp' 'qrcodegencpp-cmake' 'simde')
optdepends=('libfdk-aac: FDK AAC codec support'
	'libva-intel-driver: hardware encoding'
	'libva-mesa-driver: hardware encoding'
	'luajit: scripting support'
	'python: scripting support'
	'sndio: Sndio input client'
	'v4l2loopback-dkms: virtual camera support')
provides=("${_pkgname}")
conflicts=("${_pkgname}")
source=("git+https://github.com/obsproject/${_pkgname}.git"
	"git+https://github.com/obsproject/obs-websocket.git")
sha256sums=('SKIP'
            'SKIP')

pkgver() {
	cd "${_pkgname}/"
	git describe --long --tags --abbrev=7 | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/.rc/rc/;s/.beta/beta/'
}

prepare() {
	cd "${_pkgname}/"

	git submodule init
	git config submodule.plugins/obs-websocket.url "${srcdir}/obs-websocket/"
	git -c protocol.file.allow=always submodule update

	git cherry-pick -n 26dfacbd4f5217258a2f1c5472a544c65a182d10 # Fix Qt 6.10 build
}

build() {
	cmake -B build \
		-S "${_pkgname}/" \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=None \
		-DENABLE_BROWSER=OFF \
		-DENABLE_WEBSOCKET=ON \
		-DENABLE_VST=ON \
		-DENABLE_VLC=OFF \
		-DENABLE_NEW_MPEGTS_OUTPUT=OFF \
		-DENABLE_AJA=OFF \
		-DENABLE_JACK=ON \
		-DENABLE_LIBFDK=ON \
		-DENABLE_WEBRTC=ON \
		-DCALM_DEPRECATION=ON \
		-DOBS_COMPILE_DEPRECATION_AS_WARNING=ON \
		-Wno-dev

	cmake --build build
}

package() {
	DESTDIR="${pkgdir}" cmake --install build
}
