SUMMARY="A media editor exclusively built for Haiku"
DESCRIPTION="Medo is a modern video editor with customisable OpenGL GLSL \
plugin based effects.

There are many bundled media effects, including:
- Colour grading effects (saturation, exposure, temperature etc.)
- Colour correction curves and white balance
- Support for Adobe LUT (Look Up Tables)
- Create masks and keyframes
- Several transitions
- Several special effects (blur, night vision, Chroma Key etc.)
- Spatial tools to transform media (scale, rotate, position, crop)
- Multiple text effects, including 3D extruded fonts
- Audio effects (20 band equaliser, fade, IIR Filter)

Medo can edit UHD 4K videos, export to any Haiku supported codec, is optimised \
for many CPU-core systems, and has low system resource requirements.

An SDK allows 3rd party developers to create addons and plugins.

Changelog for Beta1-4.2
- preview of media source
- tag media sources
- show clip trim/not visible markers
- Srgb/Linear/Gamma plugin (video)
- IIR Filter (audio)
- Multi chroma key (video)
- fixed multiple ffmpeg related crashes
- fixed audio resampler issues when seeking
- fixed zoom issues (use Z key for quick zoom)
- miscellanous bug fixes"
HOMEPAGE="https://github.com/smallstepforman/Medo"
COPYRIGHT="2019-2021 Zen Yes Pty Ltd"
LICENSE="MIT"
REVISION="2"
SOURCE_URI="https://github.com/smallstepforman/Medo/archive/R1.0.0-Beta1-4.2.tar.gz"
CHECKSUM_SHA256="e209714fe963e49c6011b9001376a172d34983f464d825bec5a0c5ee8438ed72"
SOURCE_DIR="Medo-R1.0.0-Beta1-4.2"
PATCHES="medo-1.0.0~beta1.2.patchset"

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

PROVIDES="
	medo$secondaryArchSuffix = $portVersion
	app:Medo
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libavcodec$secondaryArchSuffix
	lib:libavformat$secondaryArchSuffix
	lib:libavutil$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libswresample$secondaryArchSuffix
	lib:libswscale$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libavformat$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:jam
	"

BUILD()
{
	cd AddOns
	for d in */; do
		cd "$d"
		chmod +x clean_all
	cd ..
	done
	cd ..

	release=true jam -q $jobArgs
	sh build_addons
	sh setup_attributes
}

INSTALL()
{
	mkdir -p $appsDir/Medo
	cp Medo $appsDir/Medo

	mkdir $appsDir/Medo/AddOns
	pushd AddOns
	for d in */; do
		pushd ${d%/}
		mkdir $appsDir/Medo/AddOns/${d%/}
		cp *".so" "$appsDir/Medo/AddOns/$d"
		cp *".png" "$appsDir/Medo/AddOns/$d"
		cp *".json" "$appsDir/Medo/AddOns/$d"
		popd
	done
	popd

	#Plugins
	mkdir $appsDir/Medo/Plugins
	pushd Plugins
	for f in */; do
		pushd ${f%/}
		mkdir $appsDir/Medo/Plugins/${f%/}
		cp *.* "$appsDir/Medo/Plugins/$f"
		popd
	done
	popd

	#Languages
	mkdir $appsDir/Medo/Languages
	pushd Languages
	cp *.lang "$appsDir/Medo/Languages/"
	popd

	#Resources
	mkdir $appsDir/Medo/Resources
	mkdir $appsDir/Medo/Resources/Icon
	pushd Resources
	cp *".png" "$appsDir/Medo/Resources/"
	cp "Icon/Medo_Logo.png" "$appsDir/Medo/Resources/Icon"
	popd

	addResourcesToBinaries Resources/Icon/Medo_icon.rdef \
		$appsDir/Medo/Medo
	addAppDeskbarSymlink $appsDir/Medo/Medo
}
