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