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