diff --git a/build/gn_processor.py b/build/gn_processor.py index 00d96b743c45..44c48eb64a0a 100644 --- a/build/gn_processor.py +++ b/build/gn_processor.py @@ -584,6 +584,16 @@ def write_mozbuild( ) except KeyError: pass + try: + if ( + relsrcdir + in write_mozbuild_variables["INCLUDE_SYSTEM_PIPEWIRE_HANDLING"] + ): + mb.write('CXXFLAGS += CONFIG["MOZ_PIPEWIRE_CFLAGS"]\n') + mb.write('if not CONFIG["MOZ_SYSTEM_PIPEWIRE"]:\n') + mb.write(' LOCAL_INCLUDES += [ "/third_party/pipewire/" ]\n') + except KeyError: + pass try: if ( relsrcdir diff --git a/config/make-system-wrappers.py b/config/make-system-wrappers.py index a4b3d51af1e8..47822da56776 100644 --- a/config/make-system-wrappers.py +++ b/config/make-system-wrappers.py @@ -20,11 +20,12 @@ def gen_wrappers(unused, outdir, *header_list): for header in header_list: with FileAvoidWrite(os.path.join(outdir, header)) as f: includes = include_next_template.format(header=header) - if header == "wayland-util.h": - # wayland-util.h in Wayland < 1.12 includes math.h inside an - # extern "C" block, which breaks including the header from C++. - # This was fixed in Wayland 1.12, but for versions earlier than - # that, we work around that by force-including math.h first. + if header == "wayland-util.h" or header == "pipewire/pipewire.h": + # wayland-util.h in Wayland < 1.12 and pipewire.h > 1.4 include + # math.h inside an extern "C" block, which breaks including the + # header from C++. This was fixed in Wayland 1.12, but for versions + # earlier than that, we work around that by force-including math.h + # first. includes = "#include \n" + includes elif header == "wayland-client.h": # The system wayland-client.h uses quote includes for diff --git a/config/system-headers.mozbuild b/config/system-headers.mozbuild index 4d4f4c414ac9..9aeb8ee169c1 100644 --- a/config/system-headers.mozbuild +++ b/config/system-headers.mozbuild @@ -1267,6 +1267,11 @@ if CONFIG["MOZ_SYSTEM_LIBDRM"]: "xf86drm.h", ] +if CONFIG["MOZ_SYSTEM_PIPEWIRE"]: + system_headers += [ + "pipewire/pipewire.h", + ] + if CONFIG["MOZ_JACK"]: system_headers += [ "jack/jack.h", diff --git a/dom/media/webrtc/third_party_build/gn-configs/webrtc.json b/dom/media/webrtc/third_party_build/gn-configs/webrtc.json index faf0d971ad1e..34d2aec4ecfc 100644 --- a/dom/media/webrtc/third_party_build/gn-configs/webrtc.json +++ b/dom/media/webrtc/third_party_build/gn-configs/webrtc.json @@ -25,6 +25,11 @@ "third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn", "third_party/libwebrtc/modules/portal/portal_gn" ], + "INCLUDE_SYSTEM_PIPEWIRE_HANDLING": [ + "third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn", + "third_party/libwebrtc/modules/portal/portal_gn", + "third_party/libwebrtc/modules/video_capture/video_capture_internal_impl_gn" + ], "INCLUDE_SYSTEM_DAV1D_HANDLING": [ "third_party/libwebrtc/modules/video_coding/codecs/av1/dav1d_decoder_gn", "third_party/libwebrtc/modules/video_coding/codecs/av1/libaom_av1_encoder_gn" diff --git a/third_party/pipewire/libpipewire/moz.build b/third_party/pipewire/libpipewire/moz.build index 3102b3cb69b7..b487b816643c 100644 --- a/third_party/pipewire/libpipewire/moz.build +++ b/third_party/pipewire/libpipewire/moz.build @@ -4,13 +4,13 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -SOURCES += [ - 'mozpipewire.cpp', -] - if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": CXXFLAGS += CONFIG['MOZ_GTK3_CFLAGS'] -LOCAL_INCLUDES += ['/third_party/pipewire'] +if CONFIG["MOZ_SYSTEM_PIPEWIRE"]: + OS_LIBS += CONFIG["MOZ_PIPEWIRE_LIBS"] +else: + SOURCES += ['mozpipewire.cpp'] + LOCAL_INCLUDES += ['/third_party/pipewire'] FINAL_LIBRARY = 'xul' diff --git a/toolkit/moz.configure b/toolkit/moz.configure index ccf496454191..c58ab24a6f85 100644 --- a/toolkit/moz.configure +++ b/toolkit/moz.configure @@ -678,6 +678,24 @@ def v4l2(target, toolkit_gtk): set_config("MOZ_ENABLE_V4L2", True, when=v4l2) set_define("MOZ_ENABLE_V4L2", True, when=v4l2) +# System PipeWire support +# ============================================================= +with only_when(compile_environment): + system_lib_option( + "--with-system-pipewire", + nargs="?", + help="Use system PipeWire", + when=use_pkg_config, + ) + + pipewire_headers = pkg_check_modules( + "MOZ_PIPEWIRE", + "libpipewire-0.3 libspa-0.2", + when="--with-system-pipewire", + ) + + set_config("MOZ_SYSTEM_PIPEWIRE", True, when="--with-system-pipewire") + # System gbm support (for screencast support using PipeWire) # ============================================================= with only_when(compile_environment):