SUMMARY="An application that allow to convert media files while preserving HDR metadata"
DESCRIPTION="Cine Encoder is an application, uses the FFmpeg, MKVToolNix and MediaInfo utilities, \
that allows to convert media files while preserving HDR metadata. Supported hardware encoding \
NVENC for codecs H265, H264 and Intel QSV (for Windows and experimental for Linux) for codecs \
H264, MPEG-2. The following encoding modes are implemented: H265, H264, VP9, MPEG-2, XDCAM, \
DNxHR, ProRes."
HOMEPAGE="https://github.com/CineEncoder/cine-encoder/"
COPYRIGHT="Oleg Kozhukharenko"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/CineEncoder/cine-encoder/archive/refs/tags/$portVersion.tar.gz"
CHECKSUM_SHA256="ef34601896257bb2f1d5b019809ffc9959c20c019797a43bc871f9dd9bf84d8e"
SOURCE_DIR="cine-encoder-$portVersion"
PATCHES="cine_encoder-$portVersion.patchset"
ADDITIONAL_FILES="cine_encoder.rdef.in"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	cine_encoder$secondaryArchSuffix = $portVersion
	app:CineEncoder$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	cmd:ffmpeg
	cmd:mediainfo
	lib:libGL$secondaryArchSuffix
	lib:libmediainfo$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libzen$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libmediainfo$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libzen$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:qmake$secondaryArchSuffix >= 5
	"

BUILD()
{
	cd app
	qmake .
	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir/CineEncoder
	cp app/cine_encoder $appsDir/CineEncoder/CineEncoder
	cp share/cine-encoder.wav $appsDir/CineEncoder

	local APP_SIGNATURE="application/x-vnd.cine-encoder"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/cine_encoder.rdef.in > cine_encoder.rdef

	addResourcesToBinaries cine_encoder.rdef $appsDir/CineEncoder/CineEncoder
	addAppDeskbarSymlink $appsDir/CineEncoder/CineEncoder "Cine-Encoder"
}
