# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           active_variants 1.1
PortGroup           meson 1.0
PortGroup           gobject_introspection 1.0

# https://bugzilla.gnome.org/show_bug.cgi?id=636134
PortGroup           muniversal 1.0

name                gstreamer1-gst-plugins-bad
set my_name         gst-plugins-bad
# please only commit stable updates (even numbered releases)
version             1.28.2
revision            1
description         A set of plug-ins for GStreamer that need more quality.
long_description    GStreamer Bad Plug-ins is a set of plug-ins that aren't up to par compared \
                    to the rest. They might be close to being good quality, but they're missing \
                    something - be it a good code review, some documentation, a set of tests, \
                    a real live maintainer, or some actual wide use.
license             GPL LGPL
maintainers         nomaintainer
categories          gnome
homepage            https://gstreamer.freedesktop.org/modules/${my_name}.html
master_sites        https://gstreamer.freedesktop.org/src/${my_name}/
distname            ${my_name}-${version}
use_xz              yes

checksums           rmd160  a0a4d24b3c7b502bb6ccc8690f93bba03a0c20dc \
                    sha256  6467e3964828f4d7d08bfe1fbb4d76287a1c8fa76674e59e101a149c020fefd7 \
                    size    7988892

set py_ver          3.14
set py_ver_nodot    [string map {. {}} ${py_ver}]
set python.bin      ${prefix}/bin/python${py_ver}

depends_build-append \
                    port:gettext \
                    path:bin/pkg-config:pkgconfig \
                    port:python${py_ver_nodot}

depends_lib-append  port:aom \
                    port:bzip2 \
                    port:curl \
                    port:flite \
                    port:fluidsynth \
                    port:gettext-runtime \
                    path:lib/pkgconfig/cairo.pc:cairo \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    port:gstreamer1 \
                    port:gstreamer1-gst-plugins-base \
                    port:imath \
                    port:json-glib \
                    port:lcms2 \
                    path:lib/pkgconfig/libass.pc:libass \
                    port:libbs2b \
                    port:libde265 \
                    port:libgsm \
                    port:libmodplug \
                    port:libnice \
                    port:libopenmpt \
                    port:libxml2 \
                    path:lib/pkgconfig/librsvg-2.0.pc:librsvg \
                    path:lib/pkgconfig/pango.pc:pango \
                    path:lib/libssl.dylib:openssl \
                    port:libsndfile \
                    port:libvmaf \
                    port:libopus \
                    port:openh264 \
                    port:neon \
                    port:nettle \
                    port:openal-soft \
                    port:openexr \
                    port:openjpeg \
                    port:orc \
                    port:rtmpdump \
                    port:soundtouch \
                    port:spandsp-devel \
                    port:webp \
                    port:zvbi

patchfiles          modplug.patch \
                    libressl.patch \
                    no_pqueue_size.patch \
                    gstdecklink.patch

post-patch {
    reinplace "s|/usr/bin/env python3|${python.bin}|" \
        ${worksrcpath}/scripts/extract-release-date-from-doap-file.py \
        ${worksrcpath}/scripts/dist-translations.py \
        ${worksrcpath}/scripts/update-orc-dist-files.py \
        ${worksrcpath}/tests/check/media/download-media \
        ${worksrcpath}/gst-libs/gst/vulkan/vulkan_mkenum.py \
        ${worksrcpath}/ext/vulkan/shaders/bin2array.py
}

gobject_introspection   yes

# fatal error: 'stdatomic.h' file not found
compiler.blacklist-append {clang < 700}
# requires support for C11 (redefinition of typedef ‘GstTestHTTPSrc’ at elements/test_http_src.c:101)
compiler.c_standard         2011
# OpenExr requires C++11
compiler.cxx_standard       2011

configure.args-append \
                    -Dapplemedia=disabled \
                    -Dexamples=disabled \
                    -Dfaac=disabled \
                    -Dfdkaac=disabled \
                    -Dopencv=disabled \
                    -Dsctp=disabled \
                    -Dsrtp=disabled \
                    -Dsvtav1=disabled \
                    -Dx11=disabled \
                    -Dvulkan=disabled

configure.cflags-append     -std=c11
configure.cxxflags-append   -std=gnu++11

variant faac description {Enable faac AAC plugin} {
    depends_lib-append      port:faac
    configure.args-replace  -Dfaac=disabled \
                            -Dfaac=enabled
    notes-append "Use of the +faac variant may affect licensing due to the restrictive license of port faac itself."
}

variant fdkaac description {Enable fdkaac AAC plugin} {
    depends_lib-append      port:libfdk-aac
    configure.args-replace  -Dfdkaac=disabled \
                            -Dfdkaac=enabled
    notes-append "Use of the +fdkaac variant may affect licensing due to the restrictive license of port libfdk-aac itself."
}

variant gpl description {Enable glp-licenced plugins} {
    configure.args-append   -Dgpl=enabled
    depends_lib-append      port:faad2 \
                            port:libdca \
                            port:libdvdread \
                            port:libdvdnav \
                            port:x265
}

# Window system is provided by gstreamer1-gst-plugins-base, so sync up.
variant x11 conflicts quartz {
    require_active_variants port:gstreamer1-gst-plugins-base x11
    configure.args-replace  -Dx11=disabled -Dx11=enabled
    depends_lib-append      port:xorg-libX11 \
                            port:mesa
}

variant quartz conflicts x11 {
    # plugin applemedia (Apple video) now only builds on darwin 18 and later
    platform macosx {
        if {${os.major} >= 18} {
            # Apple_Media requires CGL, which can only be provided on newer platforms and without X11 enabled.
            require_active_variants port:gstreamer1-gst-plugins-base {} x11
            configure.args-replace  -Dapplemedia=disabled \
                                    -Dapplemedia=enabled
        }
    }
}

if {![variant_isset quartz]} {
    default_variants +x11
}

if {![variant_isset x11]} {
    default_variants +quartz
}

livecheck.type      regex
livecheck.url       ${master_sites}
livecheck.regex     "${my_name}-(\\d+\\\.\\d*\[02468\](?:\\.\\d+)*)${extract.suffix}"
