<commit_before>SUMMARY     = "Multimedia processing server for Linux"
DESCRIPTION = "Linux server for handling and routing audio and video streams between applications and multimedia I/O devices"
HOMEPAGE    = "https://pipewire.org/"
BUGTRACKER  = "https://gitlab.freedesktop.org/pipewire/pipewire/issues"
AUTHOR      = "<NAME> <<EMAIL>>"
SECTION     = "multimedia"

LICENSE = "MIT & LGPL-2.1-or-later & GPL-2.0-only"
LIC_FILES_CHKSUM = " \
    file://LICENSE;md5=2158739e172e58dc9ab1bdd2d6ec9c72 \
    file://COPYING;md5=97be96ca4fab23e9657ffa590b931c1a \
"

DEPENDS = "dbus ncurses"

SRCREV = "f274e53d25ee8f483ac6fce9e516bb1830abe88b"
SRC_URI = " \
	git://gitlab.freedesktop.org/pipewire/pipewire.git;branch=master;protocol=https \
	file://0001-avb-fix-compilation-on-big-endian.patch \
"

S = "${WORKDIR}/git"

inherit meson pkgconfig systemd gettext useradd

USERADD_PACKAGES = "${PN}"

GROUPADD_PARAM:${PN} = "--system pipewire"

USERADD_PARAM:${PN} = "--system --home / --no-create-home \
                       --comment 'PipeWire multimedia daemon' \
                       --gid pipewire --groups audio,video \
                       pipewire"

SYSTEMD_PACKAGES = "${PN}"

# For "EVL", look up https://evlproject.org/ . It involves
# a specially prepared kernel, and is currently unavailable
# in Yocto.
#
# Vulkan support is currently (as of version 0.3.44) not functional.
#
# manpage generation requires xmltoman, which is not available.
#
# The session-managers list specifies which session managers Meson
# shall download (via git clone) and build as subprojects. In OE,
# this is not how a session manager should be built. Instead, they
# should be integrated as separate OE recipes. To prevent PipeWire
# from using this Meson feature, set an empty list.
# This does not disable support or the need for session managers,
# it just prevents this subproject feature.
#
# AptX and LDAC are not available in OE. Currently, neither
# are lv2 and ROC.
#
# The RTKit module is deprecated in favor of the newer RT module.
# It still exists for legacy setups that still include it in
# their PipeWire configuration files.
EXTRA_OEMESON += " \
    -Devl=disabled \
    -Dtests=disabled \
    -Dudevrulesdir=${nonarch_base_libdir}/udev/rules.d/ \
    -Dsystemd-system-unit-dir=${systemd_system_unitdir} \
    -Dsystemd-user-unit-dir=${systemd_user_unitdir} \
    -Dman=disabled \
    -Dsession-managers='[]' \
    -Dlv2=disabled \
    -Droc=disabled \
    -Dbluez5-codec-aptx=disabled \
    -Dbluez5-codec-ldac=disabled \
    -Dlegacy-rtkit=false \
"

# spa alsa plugin code uses typedef redefinition, which is officially a C11 feature.
# Pipewire builds with 'c_std=gnu99' by default. Recent versions of gcc don't issue this warning in gnu99
# mode but it looks like clang still does
CFLAGS:append = " -Wno-typedef-redefinition"

# According to wireplumber documentation only one session manager should be installed at a time
# Possible options are media-session, which has fewer dependencies but is very simple,
# or wireplumber, which is more powerful.
PIPEWIRE_SESSION_MANAGER ??= "media-session"

FFMPEG_AVAILABLE = "${@bb.utils.contains('LICENSE_FLAGS_ACCEPTED', 'commercial', 'ffmpeg', '', d)}"
BLUETOOTH_AAC = "${@bb.utils.contains('LICENSE_FLAGS_ACCEPTED', 'commercial', 'bluez-aac', '', d)}"

PACKAGECONFIG:class-target ??= " \
    ${<EMAIL>('DISTRO_FEATURES', 'zeroconf', 'avahi', '', d)} \
    ${<EMAIL>('DISTRO_FEATURES', 'bluetooth', 'bluez ${BLUETOOTH_AAC}', '', d)} \
    ${<EMAIL>('DISTRO_FEATURES', 'systemd', 'systemd systemd-system-service systemd-user-service', '', d)} \
    ${<EMAIL>('DISTRO_FEATURES', 'alsa vulkan pulseaudio', d)} \
    ${PIPEWIRE_SESSION_MANAGER} \
    ${FFMPEG_AVAILABLE} gstreamer jack libusb pw-cat raop sndfile v4l2 udev volume \
"

# "jack" and "pipewire-jack" packageconfigs cannot be both enabled,
# since "jack" imports libjack, and "pipewire-jack" generates
# libjack.so* files, thus colliding with the libpack package. This
# is why these two are marked in their respective packageconfigs
# as being in conflict.
PACKAGECONFIG[alsa] = "-Dalsa=enabled,-Dalsa=disabled,alsa-lib udev,,pipewire-alsa pipewire-alsa-card-profile"
PACKAGECONFIG[avahi] = "-Davahi=enabled,-Davahi=disabled,avahi"
PACKAGECONFIG[bluez] = "-Dbluez5=enabled,-Dbluez5=disabled,bluez5 sbc"
PACKAGECONFIG[bluez-aac] = "-Dbluez5-codec-aac=enabled,-Dbluez5-codec-aac=disabled,fdk-aac"
PACKAGECONFIG[docs] = "-Ddocs=enabled,-Ddocs=disabled,doxygen-native graphviz-native"
PACKAGECONFIG[ffmpeg] = "-Dffmpeg=enabled,-Dffmpeg=disabled,ffmpeg"
PACKAGECONFIG[gstreamer] = "-Dgstreamer=enabled,-Dgstreamer=disabled,glib-2.0 gstreamer1.0 gstreamer1.0-plugins-base,,gstreamer1.0-pipewire"
PACKAGECONFIG[jack] = "-Djack=enabled,-Djack=disabled,jack,,,pipewire-jack"
PACKAGECONFIG[libcamera] = "-Dlibcamera=enabled,-Dlibcamera=disabled,libcamera libdrm"
PACKAGECONFIG[libcanberra] = "-Dlibcanberra=enabled,-Dlibcanberra=disabled,libcanberra"
PACKAGECONFIG[libusb] = "-Dlibusb=enabled,-Dlibusb=disabled,libusb"
PACKAGECONFIG[media-session] = ",,,pipewire-media-session"
PACKAGECONFIG[pulseaudio] = "-Dlibpulse=enabled,-Dlibpulse=disabled,pulseaudio,,pipewire-pulse"
PACKAGECONFIG[pipewire-alsa] = "-Dpipewire-alsa=enabled,-Dpipewire-alsa=disabled,alsa-lib"
PACKAGECONFIG[pipewire-jack] = "-Dpipewire-jack=enabled -Dlibjack-path=${libdir}/${PW_MODULE_SUBDIR}/jack,-Dpipewire-jack=disabled,jack,,,jack"
PACKAGECONFIG[pw-cat] = "-Dpw-cat=enabled,-Dpw-cat=disabled"
PACKAGECONFIG[raop] = "-Draop=enabled,-Draop=disabled,openssl"
PACKAGECONFIG[sdl2] = "-Dsdl2=enabled,-Dsdl2=disabled,libsdl2"
PACKAGECONFIG[sndfile] = "-Dsndfile=enabled,-Dsndfile=disabled,libsndfile1"
PACKAGECONFIG[systemd] = "-Dsystemd=enabled,-Dsystemd=disabled,systemd"
PACKAGECONFIG[systemd-system-service] = "-Dsystemd-system-service=enabled,-Dsystemd-system-service=disabled,systemd"
# "systemd-user-service" packageconfig will only install service
# files to rootfs but not enable them as systemd.bbclass
# currently lacks the feature of enabling user services.
PACKAGECONFIG[systemd-user-service] = "-Dsystemd-user-service=enabled,-Dsystemd-user-service=disabled,systemd"
# pw-cat needs sndfile packageconfig to be enabled
PACKAGECONFIG[udev] = "-Dudev=enabled,-Dudev=disabled,udev"
PACKAGECONFIG[v4l2] = "-Dv4l2=enabled,-Dv4l2=disabled,udev"
PACKAGECONFIG[volume] = "-Dvolume=enabled,-Dvolume=disabled"
PACKAGECONFIG[vulkan] = "-Dvulkan=enabled,-Dvulkan=disabled,vulkan-headers vulkan-loader"
PACKAGECONFIG[webrtc-echo-cancelling] = "-Decho-cancel-webrtc=enabled,-Decho-cancel-webrtc=disabled,webrtc-audio-processing"
PACKAGECONFIG[wireplumber] = ",,,wireplumber"

PACKAGESPLITFUNCS:prepend = " split_dynamic_packages "
PACKAGESPLITFUNCS:append = " set_dynamic_metapkg_rdepends "

SPA_SUBDIR = "spa-0.2"
PW_MODULE_SUBDIR = "pipewire-0.3"

remove_unused_installed_files() {
    # jack.conf is used by pipewire-jack (not the JACK SPA plugin).
    # Remove it if pipewire-jack is not built to avoid creating the
    # pipewire-jack package.
    if ${<EMAIL>.contains('PACKAGECONFIG', 'pipewire-jack', 'false', 'true', d)}; then
        rm -f "${D}${datadir}/pipewire/jack.conf"
    fi

    # minimal.conf is an example of how to minimally configure the
    # daemon and is not meant to be used for production.<commit_msg>pipewire: improve runtime dependency settings<commit_after>SUMMARY     = "Multimedia processing server for Linux"
DESCRIPTION = "Linux server for handling and routing audio and video streams between applications and multimedia I/O devices"
HOMEPAGE    = "https://pipewire.org/"
BUGTRACKER  = "https://gitlab.freedesktop.org/pipewire/pipewire/issues"
AUTHOR      = "<NAME> <<EMAIL>>"
SECTION     = "multimedia"

LICENSE = "MIT & LGPL-2.1-or-later & GPL-2.0-only"
LIC_FILES_CHKSUM = " \
    file://LICENSE;md5=2158739e172e58dc9ab1bdd2d6ec9c72 \
    file://COPYING;md5=97be96ca4fab23e9657ffa590b931c1a \
"

DEPENDS = "dbus ncurses"

SRCREV = "f274e53d25ee8f483ac6fce9e516bb1830abe88b"
SRC_URI = " \
	git://gitlab.freedesktop.org/pipewire/pipewire.git;branch=master;protocol=https \
	file://0001-avb-fix-compilation-on-big-endian.patch \
"

S = "${WORKDIR}/git"

inherit meson pkgconfig systemd gettext useradd

USERADD_PACKAGES = "${PN}"

GROUPADD_PARAM:${PN} = "--system pipewire"

USERADD_PARAM:${PN} = "--system --home / --no-create-home \
                       --comment 'PipeWire multimedia daemon' \
                       --gid pipewire --groups audio,video \
                       pipewire"

SYSTEMD_PACKAGES = "${PN}"

# For "EVL", look up https://evlproject.org/ . It involves
# a specially prepared kernel, and is currently unavailable
# in Yocto.
#
# Vulkan support is currently (as of version 0.3.44) not functional.
#
# manpage generation requires xmltoman, which is not available.
#
# The session-managers list specifies which session managers Meson
# shall download (via git clone) and build as subprojects. In OE,
# this is not how a session manager should be built. Instead, they
# should be integrated as separate OE recipes. To prevent PipeWire
# from using this Meson feature, set an empty list.
# This does not disable support or the need for session managers,
# it just prevents this subproject feature.
#
# AptX and LDAC are not available in OE. Currently, neither
# are lv2 and ROC.
#
# The RTKit module is deprecated in favor of the newer RT module.
# It still exists for legacy setups that still include it in
# their PipeWire configuration files.
EXTRA_OEMESON += " \
    -Devl=disabled \
    -Dtests=disabled \
    -Dudevrulesdir=${nonarch_base_libdir}/udev/rules.d/ \
    -Dsystemd-system-unit-dir=${systemd_system_unitdir} \
    -Dsystemd-user-unit-dir=${systemd_user_unitdir} \
    -Dman=disabled \
    -Dsession-managers='[]' \
    -Dlv2=disabled \
    -Droc=disabled \
    -Dbluez5-codec-aptx=disabled \
    -Dbluez5-codec-ldac=disabled \
    -Dlegacy-rtkit=false \
"

# spa alsa plugin code uses typedef redefinition, which is officially a C11 feature.
# Pipewire builds with 'c_std=gnu99' by default. Recent versions of gcc don't issue this warning in gnu99
# mode but it looks like clang still does
CFLAGS:append = " -Wno-typedef-redefinition"

# According to wireplumber documentation only one session manager should be installed at a time
# Possible options are media-session, which has fewer dependencies but is very simple,
# or wireplumber, which is more powerful.
PIPEWIRE_SESSION_MANAGER ??= "media-session"

FFMPEG_AVAILABLE = "${<EMAIL>('LICENSE_FLAGS_ACCEPTED', 'commercial', 'ffmpeg', '', d)}"
BLUETOOTH_AAC = "${@<EMAIL>('LICENSE_FLAGS_ACCEPTED', 'commercial', 'bluez-aac', '', d)}"

PACKAGECONFIG:class-target ??= " \
    ${<EMAIL>('DISTRO_FEATURES', 'zeroconf', 'avahi', '', d)} \
    ${<EMAIL>('DISTRO_FEATURES', 'bluetooth', 'bluez ${BLUETOOTH_AAC}', '', d)} \
    ${<EMAIL>('DISTRO_FEATURES', 'systemd', 'systemd systemd-system-service systemd-user-service', '', d)} \
    ${<EMAIL>('DISTRO_FEATURES', 'alsa vulkan pulseaudio', d)} \
    ${PIPEWIRE_SESSION_MANAGER} \
    ${FFMPEG_AVAILABLE} gstreamer jack libusb pw-cat raop sndfile v4l2 udev volume \
"

# "jack" and "pipewire-jack" packageconfigs cannot be both enabled,
# since "jack" imports libjack, and "pipewire-jack" generates
# libjack.so* files, thus colliding with the libpack package. This
# is why these two are marked in their respective packageconfigs
# as being in conflict.
PACKAGECONFIG[alsa] = "-Dalsa=enabled,-Dalsa=disabled,alsa-lib udev,,pipewire-alsa pipewire-alsa-card-profile"
PACKAGECONFIG[avahi] = "-Davahi=enabled,-Davahi=disabled,avahi"
PACKAGECONFIG[bluez] = "-Dbluez5=enabled,-Dbluez5=disabled,bluez5 sbc"
PACKAGECONFIG[bluez-aac] = "-Dbluez5-codec-aac=enabled,-Dbluez5-codec-aac=disabled,fdk-aac"
PACKAGECONFIG[docs] = "-Ddocs=enabled,-Ddocs=disabled,doxygen-native graphviz-native"
PACKAGECONFIG[ffmpeg] = "-Dffmpeg=enabled,-Dffmpeg=disabled,ffmpeg"
PACKAGECONFIG[gstreamer] = "-Dgstreamer=enabled,-Dgstreamer=disabled,glib-2.0 gstreamer1.0 gstreamer1.0-plugins-base,,gstreamer1.0-pipewire"
PACKAGECONFIG[jack] = "-Djack=enabled,-Djack=disabled,jack,,,pipewire-jack"
PACKAGECONFIG[libcamera] = "-Dlibcamera=enabled,-Dlibcamera=disabled,libcamera libdrm"
PACKAGECONFIG[libcanberra] = "-Dlibcanberra=enabled,-Dlibcanberra=disabled,libcanberra"
PACKAGECONFIG[libusb] = "-Dlibusb=enabled,-Dlibusb=disabled,libusb"
PACKAGECONFIG[media-session] = ",,,pipewire-media-session,,wireplumber"
PACKAGECONFIG[pulseaudio] = "-Dlibpulse=enabled,-Dlibpulse=disabled,pulseaudio,,pipewire-pulse"
PACKAGECONFIG[pipewire-alsa] = "-Dpipewire-alsa=enabled,-Dpipewire-alsa=disabled,alsa-lib"
PACKAGECONFIG[pipewire-jack] = "-Dpipewire-jack=enabled -Dlibjack-path=${libdir}/${PW_MODULE_SUBDIR}/jack,-Dpipewire-jack=disabled,jack,,pipewire-jack,jack"
PACKAGECONFIG[pw-cat] = "-Dpw-cat=enabled,-Dpw-cat=disabled"
PACKAGECONFIG[raop] = "-Draop=enabled,-Draop=disabled,openssl"
PACKAGECONFIG[sdl2] = "-Dsdl2=enabled,-Dsdl2=disabled,libsdl2"
PACKAGECONFIG[sndfile] = "-Dsndfile=enabled,-Dsndfile=disabled,libsndfile1"
PACKAGECONFIG[systemd] = "-Dsystemd=enabled,-Dsystemd=disabled,systemd"
PACKAGECONFIG[systemd-system-service] = "-Dsystemd-system-service=enabled,-Dsystemd-system-service=disabled,systemd"
# "systemd-user-service" packageconfig will only install service
# files to rootfs but not enable them as systemd.bbclass
# currently lacks the feature of enabling user services.
PACKAGECONFIG[systemd-user-service] = "-Dsystemd-user-service=enabled,-Dsystemd-user-service=disabled,systemd"
# pw-cat needs sndfile packageconfig to be enabled
PACKAGECONFIG[udev] = "-Dudev=enabled,-Dudev=disabled,udev"
PACKAGECONFIG[v4l2] = "-Dv4l2=enabled,-Dv4l2=disabled,udev"
PACKAGECONFIG[volume] = "-Dvolume=enabled,-Dvolume=disabled"
PACKAGECONFIG[vulkan] = "-Dvulkan=enabled,-Dvulkan=disabled,vulkan-headers vulkan-loader"
PACKAGECONFIG[webrtc-echo-cancelling] = "-Decho-cancel-webrtc=enabled,-Decho-cancel-webrtc=disabled,webrtc-audio-processing"
PACKAGECONFIG[wireplumber] = ",,,wireplumber,,media-session"

PACKAGESPLITFUNCS:prepend = " split_dynamic_packages "
PACKAGESPLITFUNCS:append = " set_dynamic_metapkg_rdepends "

SPA_SUBDIR = "spa-0.2"
PW_MODULE_SUBDIR = "pipewire-0.3"

remove_unused_installed_files() {
    # jack.conf is used by pipewire-jack (not the JACK SPA plugin).
    # Remove it if pipewire-jack is not built to avoid creating the
    # pipewire-jack package.
    if ${@<EMAIL>.contains('PACKAGECONFIG', 'pipewire-jack', 'false', 'true', d)}; then
        rm -f "${D}${datadir}/pipewire/jack.conf"
    fi

    # minimal.conf is an example of how to minimally configure the
    # daemon and is not meant to be used for production.
{'fraction_non_alphanumeric': 0.12954498942629103, 'fraction_numerical': 0.015417149873797668, 'mean_word_length': 5.0653702937525855, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5711286', 'n_tokens_mistral': 5224, 'n_tokens_neox': 5131, 'n_words': 1089}