pipewire: update to pw 0.3.30 and wp 0.4.0
[AGL/meta-agl.git] / meta-pipewire / recipes-multimedia / pipewire / pipewire_0.3.30.bb
1 # This recipe was written by Carlos Rafael Giani <crg7475@mailbox.org>
2 # for meta-oe
3 #
4 # The intention is to keep this synced with meta-oe and remove it when we
5 # can depend on meta-oe to provide this recipe for us
6 #
7 # AGL-specific overrides and configuration should go in the .bbappend file
8 #
9 SUMMARY = "Multimedia processing server for Linux"
10 DESCRIPTION = "Linux server for handling and routing audio and video streams between applications and multimedia I/O devices"
11 HOMEPAGE = "https://pipewire.org/"
12 BUGTRACKER  = "https://gitlab.freedesktop.org/pipewire/pipewire/issues"
13 LICENSE = "MIT"
14 LICENSE_${PN}-jack = "GPL-2.0-only"
15 LICENSE_${PN}-alsa-card-profile = "LGPL-2.1-or-later"
16 LICENSE_${PN}-spa-plugins-alsa = "LGPL-2.1-or-later"
17
18 LIC_FILES_CHKSUM = " \
19     file://LICENSE;md5=2158739e172e58dc9ab1bdd2d6ec9c72 \
20     file://COPYING;md5=97be96ca4fab23e9657ffa590b931c1a \
21 "
22 SECTION = "multimedia"
23
24 DEPENDS = "dbus"
25
26 SRCREV = "e857856be7b64d562cdcc01c43933218a68b225e"
27 SRC_URI = "git://gitlab.freedesktop.org/pipewire/pipewire.git;branch=master;protocol=https"
28
29 S = "${WORKDIR}/git"
30
31 inherit meson pkgconfig systemd manpages gettext useradd
32
33 USERADD_PACKAGES = "${PN}"
34
35 GROUPADD_PARAM_${PN} = "--system pipewire"
36
37 USERADD_PARAM_${PN} = "--system --home / --no-create-home \
38                        --comment 'PipeWire multimedia daemon' \
39                        --gid pipewire --groups audio,video \
40                        pipewire"
41
42 # For "EVL", look up https://evlproject.org/ . It involves
43 # a specially prepared kernel, and is currently unavailable
44 # in Yocto.
45 #
46 # FFmpeg and Vulkan aren't really supported - at the current
47 # stage (version 0.3.22), these are just experiments, not
48 # actual features.
49 #
50 # libcamera support currently does not build successfully.
51 #
52 # systemd user service files are disabled because per-user
53 # PipeWire instances aren't really something that makes
54 # much sense in an embedded environment. A system-wide
55 # instance does.
56 #
57 # manpage generation requires xmltoman, which is not available.
58 EXTRA_OEMESON += " \
59     -Daudiotestsrc=enabled \
60     -Devl=disabled \
61     -Dsystemd-user-service=disabled \
62     -Dtests=disabled \
63     -Dudevrulesdir=${nonarch_base_libdir}/udev/rules.d/ \
64     -Dvideotestsrc=enabled \
65     -Dffmpeg=disabled \
66     -Dvulkan=disabled \
67     -Dlibcamera=disabled \
68     -Dman=disabled \
69 "
70
71 PACKAGECONFIG ??= "\
72     ${@bb.utils.contains('DISTRO_FEATURES', 'bluetooth', 'bluez', '', d)} \
73     ${@bb.utils.filter('DISTRO_FEATURES', 'alsa systemd', d)} \
74     gstreamer jack v4l2 \
75 "
76
77 # "jack" and "pipewire-jack" packageconfigs cannot be both enabled,
78 # since "jack" imports libjack, and "pipewire-jack" generates
79 # libjack.so* files, thus colliding with the libpack package. This
80 # is why these two are marked in their respective packageconfigs
81 # as being in conflict.
82
83 PACKAGECONFIG[alsa] = "-Dalsa=enabled,-Dalsa=disabled,alsa-lib udev"
84 PACKAGECONFIG[bluez] = "-Dbluez5=enabled,-Dbluez5=disabled,bluez5 sbc"
85 PACKAGECONFIG[docs] = "-Ddocs=enabled,-Ddocs=disabled,doxygen-native"
86 PACKAGECONFIG[gstreamer] = "-Dgstreamer=enabled,-Dgstreamer=disabled,glib-2.0 gstreamer1.0 gstreamer1.0-plugins-base"
87 PACKAGECONFIG[jack] = "-Djack=enabled,-Djack=disabled,jack,,,pipewire-jack"
88 PACKAGECONFIG[sdl2] = "-Dsdl2=enabled,-Dsdl2=disabled,virtual/libsdl2"
89 PACKAGECONFIG[sndfile] = "-Dsndfile=enabled,-Dsndfile=disabled,libsndfile1"
90 PACKAGECONFIG[systemd] = "-Dsystemd=enabled -Dsystemd-system-service=enabled ,-Dsystemd=disabled -Dsystemd-system-service=disabled,systemd"
91 PACKAGECONFIG[v4l2] = "-Dv4l2=enabled,-Dv4l2=disabled,udev"
92 PACKAGECONFIG[pipewire-alsa] = "-Dpipewire-alsa=enabled,-Dpipewire-alsa=disabled,alsa-lib"
93 PACKAGECONFIG[pipewire-jack] = "-Dpipewire-jack=enabled -Dlibjack-path=${libdir}/${PW_MODULE_SUBDIR}/jack,-Dpipewire-jack=disabled,jack,,,jack"
94
95 PACKAGESPLITFUNCS_prepend = " split_dynamic_packages "
96 PACKAGESPLITFUNCS_append = " set_dynamic_metapkg_rdepends "
97
98 SPA_SUBDIR = "spa-0.2"
99 PW_MODULE_SUBDIR = "pipewire-0.3"
100
101 remove_unused_installed_files() {
102     # jack.conf is used by pipewire-jack (not the JACK SPA plugin).
103     # Remove it if pipewire-jack is not built to avoid creating the
104     # pipewire-jack package.
105     if ${@bb.utils.contains('PACKAGECONFIG', 'pipewire-jack', 'false', 'true', d)}; then
106         rm -f "${D}${datadir}/pipewire/jack.conf"
107     fi
108 }
109
110 do_install[postfuncs] += "remove_unused_installed_files"
111
112 python split_dynamic_packages () {
113     # Create packages for each SPA plugin. These plugins are located
114     # in individual subdirectories, so a recursive search is needed.
115     spa_libdir = d.expand('${libdir}/${SPA_SUBDIR}')
116     do_split_packages(d, spa_libdir, r'^libspa-(.*)\.so$', d.expand('${PN}-spa-plugins-%s'), 'PipeWire SPA plugin for %s', extra_depends='', recursive=True)
117
118     # Create packages for each PipeWire module.
119     pw_module_libdir = d.expand('${libdir}/${PW_MODULE_SUBDIR}')
120     do_split_packages(d, pw_module_libdir, r'^libpipewire-module-(.*)\.so$', d.expand('${PN}-modules-%s'), 'PipeWire %s module', extra_depends='', recursive=False)
121 }
122
123 python set_dynamic_metapkg_rdepends () {
124     import os
125     import oe.utils
126
127     # Go through all generated SPA plugin and PipeWire module packages
128     # (excluding the main package and the -meta package itself) and
129     # add them to the -meta package as RDEPENDS.
130
131     base_pn = d.getVar('PN')
132
133     spa_pn = base_pn + '-spa-plugins'
134     spa_metapkg =  spa_pn + '-meta'
135
136     pw_module_pn = base_pn + '-modules'
137     pw_module_metapkg =  pw_module_pn + '-meta'
138
139     d.setVar('ALLOW_EMPTY_' + spa_metapkg, "1")
140     d.setVar('FILES_' + spa_metapkg, "")
141
142     d.setVar('ALLOW_EMPTY_' + pw_module_metapkg, "1")
143     d.setVar('FILES_' + pw_module_metapkg, "")
144
145     blacklist = [ spa_pn, spa_metapkg, pw_module_pn, pw_module_metapkg ]
146     spa_metapkg_rdepends = []
147     pw_module_metapkg_rdepends = []
148     pkgdest = d.getVar('PKGDEST')
149
150     for pkg in oe.utils.packages_filter_out_system(d):
151         if pkg in blacklist:
152             continue
153
154         is_spa_pkg = pkg.startswith(spa_pn)
155         is_pw_module_pkg = pkg.startswith(pw_module_pn)
156         if not is_spa_pkg and not is_pw_module_pkg:
157             continue
158
159         if pkg in spa_metapkg_rdepends or pkg in pw_module_metapkg_rdepends:
160             continue
161
162         # See if the package is empty by looking at the contents of its
163         # PKGDEST subdirectory. If this subdirectory is empty, then then
164         # package is empty as well. Empty packages do not get added to
165         # the meta package's RDEPENDS.
166         pkgdir = os.path.join(pkgdest, pkg)
167         if os.path.exists(pkgdir):
168             dir_contents = os.listdir(pkgdir) or []
169         else:
170             dir_contents = []
171         is_empty = len(dir_contents) == 0
172         if not is_empty:
173             if is_spa_pkg:
174                 spa_metapkg_rdepends.append(pkg)
175             if is_pw_module_pkg:
176                 pw_module_metapkg_rdepends.append(pkg)
177
178     d.setVar('RDEPENDS_' + spa_metapkg, ' '.join(spa_metapkg_rdepends))
179     d.setVar('DESCRIPTION_' + spa_metapkg, spa_pn + ' meta package')
180
181     d.setVar('RDEPENDS_' + pw_module_metapkg, ' '.join(pw_module_metapkg_rdepends))
182     d.setVar('DESCRIPTION_' + pw_module_metapkg, pw_module_pn + ' meta package')
183 }
184
185 PACKAGES =+ "\
186     libpipewire \
187     ${PN}-tools \
188     ${PN}-pulse \
189     ${PN}-alsa \
190     ${PN}-jack \
191     ${PN}-media-session \
192     ${PN}-spa-plugins \
193     ${PN}-spa-plugins-meta \
194     ${PN}-spa-tools \
195     ${PN}-modules \
196     ${PN}-modules-meta \
197     ${PN}-alsa-card-profile \
198     gstreamer1.0-pipewire \
199 "
200
201 PACKAGES_DYNAMIC = "^${PN}-spa-plugins.* ^${PN}-modules.*"
202
203 SYSTEMD_SERVICE_${PN} = "pipewire.service"
204 CONFFILES_${PN} += "${datadir}/pipewire/pipewire.conf"
205 FILES_${PN} = " \
206     ${datadir}/pipewire/pipewire.conf \
207     ${datadir}/pipewire/filter-chain \
208     ${systemd_user_unitdir}/pipewire.* \
209     ${bindir}/pipewire \
210 "
211
212 FILES_${PN}-dev += " \
213     ${libdir}/${PW_MODULE_SUBDIR}/jack/libjack*.so \
214 "
215
216 CONFFILES_libpipewire += "${datadir}/pipewire/client.conf"
217 FILES_libpipewire = " \
218     ${datadir}/pipewire/client.conf \
219     ${libdir}/libpipewire-*.so.* \
220 "
221 # Add the bare minimum modules and plugins required to be able
222 # to use libpipewire. Without these, it is essentially unusable.
223 RDEPENDS_libpipewire += " \
224     ${PN}-modules-client-node \
225     ${PN}-modules-protocol-native \
226     ${PN}-spa-plugins-support \
227 "
228
229 FILES_${PN}-tools = " \
230     ${bindir}/pw-* \
231 "
232
233 # This is a shim daemon that is intended to be used as a
234 # drop-in PulseAudio replacement, providing a pulseaudio-compatible
235 # socket that can be used by applications that use libpulse.
236 CONFFILES_${PN}-pulse += "${datadir}/pipewire/pipewire-pulse.conf"
237
238 FILES_${PN}-pulse = " \
239     ${datadir}/pipewire/pipewire-pulse.conf \
240     ${systemd_user_unitdir}/pipewire-pulse.* \
241     ${bindir}/pipewire-pulse \
242 "
243 RDEPENDS_${PN}-pulse += " \
244     ${PN}-modules-protocol-pulse \
245 "
246
247 # alsa plugin to redirect audio to pipewire
248 FILES_${PN}-alsa = "\
249     ${libdir}/alsa-lib/* \
250     ${datadir}/alsa/alsa.conf.d/* \
251 "
252
253 # jack drop-in libraries to redirect audio to pipewire
254 CONFFILES_${PN}-jack = "${datadir}/pipewire/jack.conf"
255 FILES_${PN}-jack = "\
256     ${datadir}/pipewire/jack.conf \
257     ${libdir}/${PW_MODULE_SUBDIR}/jack/libjack*.so.* \
258 "
259
260 # Example session manager. Not intended for use in production.
261 CONFFILES_${PN}-media-session = "${datadir}/pipewire/media-session.d/*"
262 SYSTEMD_SERVICE_${PN}-media-session = "pipewire-media-session.service"
263 FILES_${PN}-media-session = " \
264     ${bindir}/pipewire-media-session \
265     ${datadir}/pipewire/media-session.d/* \
266     ${systemd_system_unitdir}/pipewire-media-session.service \
267 "
268 RPROVIDES_${PN}-media-session = "virtual/pipewire-sessionmanager"
269
270 # Dynamic packages (see set_dynamic_metapkg_rdepends).
271 FILES_${PN}-spa-plugins = ""
272 RRECOMMENDS_${PN}-spa-plugins += "${PN}-spa-plugins-meta"
273
274 FILES_${PN}-spa-tools = " \
275     ${bindir}/spa-* \
276 "
277
278 # Dynamic packages (see set_dynamic_metapkg_rdepends).
279 FILES_${PN}-modules = ""
280 RRECOMMENDS_${PN}-modules += "${PN}-modules-meta"
281
282 CONFFILES_${PN}-modules-rtkit = "${datadir}/pipewire/client-rt.conf"
283 FILES_${PN}-modules-rtkit += " \
284     ${datadir}/pipewire/client-rt.conf \
285     "
286
287 FILES_${PN}-alsa-card-profile = " \
288     ${datadir}/alsa-card-profile/* \
289     ${nonarch_base_libdir}/udev/rules.d/90-pipewire-alsa.rules \
290 "
291
292 FILES_gstreamer1.0-pipewire = " \
293     ${libdir}/gstreamer-1.0/* \
294 "