{% set version = "1.21.3" %}
{% set posix = 'm2-' if win else '' %}

package:
  name: gstreamer_and_plugins
  version: {{ version }}

source:
  - url: https://gstreamer.freedesktop.org/src/gstreamer/gstreamer-{{ version }}.tar.xz
    sha256: 27a75236bce2b10b188fe0c0087c6ceb9ee13c18fe9bf7437e0234a0e4afa226
  - url: https://gstreamer.freedesktop.org/src/gst-plugins-base/gst-plugins-base-{{ version }}.tar.xz
    sha256: 953d507db08d74ab0b4531eed7545a1756c45966237049c06bd7e4e5d5265c6c
    folder: plugins_base
  - url: https://gstreamer.freedesktop.org/src/gst-plugins-good/gst-plugins-good-{{ version }}.tar.xz
    sha256: d17dca7a9ddb6b389f8d419834b5bac2ec0c5a5207c25773b1f5a57246282e84
    folder: plugins_good
    patches:
      - jpeg-win.patch  # [win]

build:
  number: 1

outputs:
  - name: gstreamer
    script: install_gstreamer.sh  # [unix]
    script: install_gstreamer.bat  # [win]
    build:
      activate_in_script: true
      ignore_run_exports:
        # we need cross-python to build, but this isn't a python package
        - python      # [build_platform != target_platform]
        - python_abi  # [build_platform != target_platform]
      run_exports:
        # remove symbols at .90 patch releases just before minor versions?
        #    https://abi-laboratory.pro/tracker/timeline/gstreamer/
        - {{ pin_subpackage('gstreamer', max_pin='x.x') }}

    requirements:
      build:
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - pkg-config
        - {{ posix }}bison
        - {{ posix }}flex
        - meson
        - ninja
        - gobject-introspection
        # 20221027 - hmaarrfk
        # 3.11 doesn't have distutils which mesons needs???
        - cross-python_{{ target_platform }} 3.10  # [build_platform != target_platform]
      host:
        - python 3.10  # [build_platform != target_platform]
        - gettext
        - glib
      run:
        - {{ pin_compatible("glib") }}  # required for anything that builds against GStreamer, e.g. Qt
    test:
      commands:
        - gst-inspect-1.0 --version
        - gst-launch-1.0  --version
        - gst-stats-1.0 --version
        - gst-typefind-1.0 --version
        - test -f $PREFIX/lib/girepository-1.0/Gst-1.0.typelib  # [unix]
        - if not exist %LIBRARY_LIB%\\girepository-1.0\\Gst-1.0.typelib exit 1  # [win]
    about:
      summary: Library for constructing graphs of media-handling components
      description:
      doc_source_url: https://cgit.freedesktop.org/gstreamer/gstreamer/tree/docs
      license: LGPL-2.0-or-later
      license_file: COPYING

  - name: gst-plugins-base
    script: install_base_plugins.sh  # [unix]
    script: install_base_plugins.bat  # [win]
    build:
      activate_in_script: true
      ignore_run_exports:
        # we need cross-python to build, but this isn't a python package
        - python      # [build_platform != target_platform]
        - python_abi  # [build_platform != target_platform]
      run_exports:
        # remove symbols at .90 patch releases just before minor versions?
        #    https://abi-laboratory.pro/tracker/timeline/gstreamer/
        - {{ pin_subpackage('gst-plugins-base', max_pin='x.x') }}

    requirements:
      build:
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - {{ cdt('libxau-devel') }}          # [linux]
        - {{ cdt('libxext-devel') }}         # [linux]
        - {{ cdt('libx11-devel') }}          # [linux]
        - {{ cdt('libxrender-devel') }}      # [linux]
        - {{ cdt('xorg-x11-proto-devel') }}  # [linux]
        - {{ cdt('mesa-libgl-devel') }}      # [linux]
        - {{ cdt('libdrm-devel') }}          # [linux]
        - {{ cdt('libxdamage-devel') }}      # [linux]
        - {{ cdt('libxfixes-devel') }}       # [linux]
        - {{ cdt('libxxf86vm-devel') }}      # [linux]
        - {{ cdt('mesa-dri-drivers') }}      # [linux]
        # These dependencies are only for cos7 platforms
        - {{ cdt('libglvnd-glx') }}          # [linux & (ppc64le | aarch64)]
        - {{ cdt('libglvnd') }}              # [linux & (ppc64le | aarch64)]
        - {{ cdt('libxshmfence-devel') }}    # [linux & (ppc64le | aarch64)]
        - {{ cdt('mesa-khr-devel') }}        # [linux & (ppc64le | aarch64)]
        # expat here is _only_ required for mesa-dri-drivers
        - {{ cdt('expat') }}                 # [linux]
        - {{ cdt('libselinux-devel') }}      # [linux]
        - pkg-config
        - meson
        - ninja
        - gobject-introspection
        - cross-python_{{ target_platform }} 3.10    # [build_platform != target_platform]
      host:
        - python 3.10  # [build_platform != target_platform]
        - {{ pin_subpackage('gstreamer', exact=True) }}
        - glib
        - zlib
        - gettext
        - libxcb                             # [linux]
        - libpng                             # [unix]
        - alsa-lib                           # [linux]
        - libopus                            # [unix]
        - libvorbis
      run:
        - {{ pin_subpackage('gstreamer', exact=True) }}
        - libpng                             # [unix]

    test:
      commands:
        - test -f $PREFIX/lib/libgstallocators-1.0${SHLIB_EXT}  # [unix]
        - test -f $PREFIX/lib/libgstapp-1.0${SHLIB_EXT}  # [unix]
        - test -f $PREFIX/lib/libgstaudio-1.0${SHLIB_EXT}  # [unix]
        - test -f $PREFIX/lib/libgstfft-1.0${SHLIB_EXT}  # [unix]
        - test -f $PREFIX/lib/libgstpbutils-1.0${SHLIB_EXT}  # [unix]
        - test -f $PREFIX/lib/libgstriff-1.0${SHLIB_EXT}  # [unix]
        - test -f $PREFIX/lib/libgstrtp-1.0${SHLIB_EXT}  # [unix]
        - test -f $PREFIX/lib/libgstrtsp-1.0${SHLIB_EXT}  # [unix]
        - test -f $PREFIX/lib/libgstsdp-1.0${SHLIB_EXT}  # [unix]
        - test -f $PREFIX/lib/libgsttag-1.0${SHLIB_EXT}  # [unix]
        - test -f $PREFIX/lib/libgstvideo-1.0${SHLIB_EXT}  # [unix]
        - test -f $PREFIX/lib/girepository-1.0/GstVideo-1.0.typelib  # [unix]
        - if not exist %LIBRARY_BIN%\\gstallocators-1.0-0.dll exit 1  # [win]
        - if not exist %LIBRARY_LIB%\\girepository-1.0\\GstVideo-1.0.typelib exit 1  # [win]
        - gst-inspect-1.0 --plugin volume

    about:
      summary: GStreamer Base Plug-ins
      description: |
        GStreamer Base Plug-ins is a well-groomed and well-maintained collection of
        GStreamer plug-ins and elements, spanning the range of possible types of
        elements one would want to write for GStreamer.
      doc_source_url: https://github.com/GStreamer/gst-plugins-base/tree/master/docs
      license: LGPL-2.0-or-later
      license_file: COPYING

  - name: gst-plugins-good
    script: install_good_plugins.sh  # [unix]
    script: install_good_plugins.bat  # [win]
    build:
      activate_in_script: true
      ignore_run_exports:
        # we need cross-python to build, but this isn't a python package
        - python      # [build_platform != target_platform]
        - python_abi  # [build_platform != target_platform]
      run_exports:
        - {{ pin_subpackage('gst-plugins-good', max_pin='x.x') }}
    requirements:
      build:
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - {{ cdt('libxau-devel') }}          # [linux]
        - {{ cdt('libxext-devel') }}         # [linux]
        - {{ cdt('libx11-devel') }}          # [linux]
        - {{ cdt('libxrender-devel') }}      # [linux]
        - {{ cdt('xorg-x11-proto-devel') }}  # [linux]
        - {{ cdt('mesa-libgl-devel') }}      # [linux]
        - {{ cdt('libdrm-devel') }}          # [linux]
        - {{ cdt('libxdamage-devel') }}      # [linux]
        - {{ cdt('libxfixes-devel') }}       # [linux]
        - {{ cdt('libxxf86vm-devel') }}      # [linux]
        - {{ cdt('mesa-dri-drivers') }}      # [linux]
        # These dependencies are only for cos7 platforms
        - {{ cdt('libglvnd-glx') }}          # [linux & (ppc64le | aarch64)]
        - {{ cdt('libglvnd') }}              # [linux & (ppc64le | aarch64)]
        - {{ cdt('libxshmfence-devel') }}    # [linux & (ppc64le | aarch64)]
        - {{ cdt('mesa-khr-devel') }}        # [linux & (ppc64le | aarch64)]
        # expat here is _only_ required for mesa-dri-drivers
        - {{ cdt('expat') }}                 # [linux]
        - {{ cdt('libselinux-devel') }}      # [linux]
        # 20221027 - hmaarrfk - needs distutils, which was removed from 3.11
        - cross-python_{{ target_platform }} 3.10    # [build_platform != target_platform]
        - pkg-config
        - meson
        - ninja
      host:
        - python 3.10  # [build_platform != target_platform]
        - {{ pin_subpackage('gstreamer', exact=True) }}
        - {{ pin_subpackage('gst-plugins-base', exact=True) }}
        - glib
        - libxcb                             # [linux]
        - jack >=1.9.7                       # [linux64]
        - lame                               # [unix]
        - mpg123                             # [linux64 or osx]
        - zlib
        - libsoup                            # [not ppc64le]
        - jpeg
      run:
        - {{ pin_subpackage('gstreamer', exact=True) }}
        - {{ pin_subpackage('gst-plugins-base', exact=True) }}
        - libsoup                            # [not ppc64le]
        - glib-networking                    # [not ppc64le]
    test:
      commands:
        - test -f $PREFIX/lib/gstreamer-1.0/libgstalpha${SHLIB_EXT}  # [unix]
        - test -f $PREFIX/lib/gstreamer-1.0/libgstdebug${SHLIB_EXT}  # [unix]
        - test -f $PREFIX/lib/gstreamer-1.0/libgstjack${SHLIB_EXT}  # [linux64]
        - test -f $PREFIX/lib/gstreamer-1.0/libgstjpeg${SHLIB_EXT}  # [unix]
        - test -f $PREFIX/lib/gstreamer-1.0/libgstlame${SHLIB_EXT}  # [unix]
        - test -f $PREFIX/lib/gstreamer-1.0/libgstmpg123${SHLIB_EXT}  # [linux64 or osx]
        - test -f $PREFIX/lib/gstreamer-1.0/libgstspectrum${SHLIB_EXT}  # [unix]
        - if not exist %LIBRARY_LIB%\\gstreamer-1.0\\gstalpha.dll exit 1  # [win]
        - if not exist %LIBRARY_LIB%\\gstreamer-1.0\\gstdebug.dll exit 1  # [win]
        - if not exist %LIBRARY_LIB%\\gstreamer-1.0\\gstjpeg.dll exit 1  # [win]
        - if not exist %LIBRARY_LIB%\\gstreamer-1.0\\gstspectrum.dll exit 1  # [win]
        - gst-inspect-1.0 --plugin alpha
    about:
      summary: GStreamer Good Plug-ins
      description: |
        GStreamer Good Plug-ins is A collection of plug-ins you'd
        want to have right next to you on the battlefield.
        Shooting sharp and making no mistakes, these plug-ins have it
        all: good looks, good code, and good licensing.  Documented and
        dressed up in tests.  If you're looking for a role model to
        base your own plug-in on here it is.
      doc_source_url: https://github.com/GStreamer/gst-plugins-good/tree/master/docs
      license: LGPL-2.0-or-later
      license_file: COPYING

about:
  home: https://gstreamer.freedesktop.org/
  summary: Library for constructing graphs of media-handling components
  license: LGPL-2.0-or-later
  license_file: COPYING
  doc_url: https://gstreamer.freedesktop.org/documentation/
  dev_url: https://cgit.freedesktop.org/gstreamer/gstreamer/tree/

extra:
  recipe-maintainers:
    - andfoy
    - ccordoba12
    - mingwandroid
    - msarahan
    - tschoonj
    - scopatz
