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