Github messages for voidlinux
 help / color / Atom feed
* Re: pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
@ 2020-03-28 10:26 ` Duncaen
  2020-03-28 10:27 ` Duncaen
                   ` (50 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: Duncaen @ 2020-03-28 10:26 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 229 bytes --]

New comment by Duncaen on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-605427802

Comment:
Those xdg-desktop-portal updates are pre releases and conditional patches are big no go.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
  2020-03-28 10:26 ` pipewire: update to 0.3.2 Duncaen
@ 2020-03-28 10:27 ` Duncaen
  2020-03-28 10:34 ` sirn
                   ` (49 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: Duncaen @ 2020-03-28 10:27 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 227 bytes --]

New comment by Duncaen on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-605427802

Comment:
The xdg-desktop-portal update is a pre releases and conditional patches are big no go.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
  2020-03-28 10:26 ` pipewire: update to 0.3.2 Duncaen
  2020-03-28 10:27 ` Duncaen
@ 2020-03-28 10:34 ` sirn
  2020-03-30  8:02 ` Piraty
                   ` (48 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-03-28 10:34 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 376 bytes --]

New comment by sirn on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-605428568

Comment:
Oh, I didn't realized it was a pre-release. I'll try to upstream the patch (given that glibc has `O_SYNC` aliased to `O_FSYNC`). Should I close this for the time being? (e.g. until xdg-desktop-portal has a pipewire-0.3 compatible release)

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (2 preceding siblings ...)
  2020-03-28 10:34 ` sirn
@ 2020-03-30  8:02 ` Piraty
  2020-04-05 11:28 ` [PR PATCH] [Updated] WIP: " sirn
                   ` (47 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: Piraty @ 2020-03-30  8:02 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 234 bytes --]

New comment by Piraty on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-605845530

Comment:
@sirn you can prefix the PR's title with `WIP: ` (preferred), or `NOMERGE` or mark it as draft

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PR PATCH] [Updated] WIP: pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (3 preceding siblings ...)
  2020-03-30  8:02 ` Piraty
@ 2020-04-05 11:28 ` sirn
  2020-04-05 11:30 ` sirn
                   ` (46 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-04-05 11:28 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 1073 bytes --]

There is an updated pull request by sirn against master on the void-packages repository

https://github.com/sirn/void-packages pipewire-update
https://github.com/void-linux/void-packages/pull/20413

WIP: pipewire: update to 0.3.2
This PR updates pipewire to 0.3.2 as well as update packages that depends on it (xdg-desktop-portal to 1.7.1 and bump revision of xdg-desktop-portal-kde to force rebuild with pipewire-0.3)

xdg-desktop-portal 1.7.1 has few changes to xdg-document-portal and requires a patch to build on musl (`O_FSYNC` being undefined, see [musl's FFSYNC patch](https://git.musl-libc.org/cgit/musl/commit/?id=c1f4ed150137d793c9d07356305a89e8785e7e02)). 

Edit: on a second thought, I'm now providing `alsa-pipewire` (installs `libasound_module_pcm_pipewire.so`, so not much to configure) as well as `libjack-pipewire` and `libpulseaudio-pipewire` but still not sure what would be the best way to provide an option to replace `libpulse.so`/`libjack.so` with them. 

A patch file from https://github.com/void-linux/void-packages/pull/20413.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pipewire-update-20413.patch --]
[-- Type: text/x-diff, Size: 7443 bytes --]

From f6047ffd5ac99bf809fe5a71771b54749d552ae7 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:23:52 +0900
Subject: [PATCH 1/3] pipewire: update to 0.3.2

---
 common/shlibs                  |  2 +-
 srcpkgs/alsa-pipewire          |  1 +
 srcpkgs/libjack-pipewire       |  1 +
 srcpkgs/libpulseaudio-pipewire |  1 +
 srcpkgs/pipewire/template      | 71 ++++++++++++++++++++++++++--------
 5 files changed, 59 insertions(+), 17 deletions(-)
 create mode 120000 srcpkgs/alsa-pipewire
 create mode 120000 srcpkgs/libjack-pipewire
 create mode 120000 srcpkgs/libpulseaudio-pipewire

diff --git a/common/shlibs b/common/shlibs
index 14e6c812fe2..8272c7e11f2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3204,7 +3204,7 @@ libarcan_shmif_ext.so.0.11 arcan-0.5.4.3_1
 libarcan_shmif_server.so.0.11 arcan-0.5.4.3_1
 libarcan_tui.so.0.11 arcan-0.5.4.3_1
 liblwipv6.so.2 lwipv6-1.5a_1
-libpipewire-0.2.so.1 libpipewire-0.2.2_1
+libpipewire-0.3.so.0 libpipewire-0.3.2_1
 libvolk.so.2.2.1 volk-2.2.1_1
 libgnuradio-runtime.so.3.8.0 gnuradio-3.8.0.0_1
 libgnuradio-pmt.so.3.8.0 gnuradio-3.8.0.0_1
diff --git a/srcpkgs/alsa-pipewire b/srcpkgs/alsa-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/alsa-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libjack-pipewire b/srcpkgs/libjack-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libjack-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libpulseaudio-pipewire b/srcpkgs/libpulseaudio-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libpulseaudio-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/pipewire/template b/srcpkgs/pipewire/template
index 7f646dad11d..697c20c0347 100644
--- a/srcpkgs/pipewire/template
+++ b/srcpkgs/pipewire/template
@@ -1,26 +1,39 @@
 # Template file for 'pipewire'
 pkgname=pipewire
-version=0.2.7
+version=0.3.2
 revision=1
 build_style=meson
-configure_args="-Dman=true -Dgstreamer=enabled -Ddocs=true -Dsystemd=false"
+configure_args="-Dman=true -Dgstreamer=true -Ddocs=true -Dsystemd=false
+ -Dbluez5=true -Dffmpeg=true -Dpipewire-alsa=true -Dpipewire-jack=true
+ -Dpipewire-pulseaudio=true"
 hostmakedepends="doxygen graphviz pkg-config xmltoman"
 makedepends="SDL2-devel ffmpeg-devel gst-plugins-base1-devel jack-devel
- sbc-devel v4l-utils-devel libva-devel"
+ sbc-devel v4l-utils-devel libva-devel libbluetooth-devel"
 short_desc="Server and user space API to deal with multimedia pipelines"
 maintainer="Orphaned <orphan@voidlinux.org>"
-#Next release will probably change to MIT, currently listed in master
-license="LGPL-2.1-only, GPL-2.0-only "
+license="MIT"
 homepage="https://pipewire.org/"
-changelog="https://raw.githubusercontent.com/PipeWire/pipewire/master/NEWS"
-distfiles="https://github.com/PipeWire/pipewire/archive/${version}.tar.gz"
-checksum=bfaa0f6ae6c0791e2e0b59234d399753bf24f1b33dbf587682363a8463dd8df1
+changelog="https://gitlab.freedesktop.org/pipewire/pipewire/-/raw/master/NEWS"
+distfiles="https://gitlab.freedesktop.org/pipewire/pipewire/-/archive/${version}/pipewire-${version}.tar.gz"
+checksum=fd1bb2ae65997d921d6c18e1828f23251dac3145bbe5031c324afeb39f9b26fb
 conf_files="/etc/pipewire/pipewire.conf"
 
+CFLAGS+="-Wformat"
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+	LDFLAGS+=" -latomic"
+fi
+
+post_install() {
+	vlicense LICENSE
+}
+
 libpipewire_package() {
 	short_desc+=" - pipewire library"
 	pkg_install() {
-		vmove "usr/lib/libpipewire-0.2.so.*"
+		vmove "usr/lib/libpipewire-0.3.so.*"
+		vmove usr/lib/pipewire-0.3
 	}
 }
 
@@ -28,25 +41,25 @@ pipewire-devel_package() {
 	depends="libpipewire-${version}_${revision}"
 	short_desc+=" - pipewire and libspa development files"
 	pkg_install() {
-		vmove usr/include/pipewire
-		vmove usr/include/spa
-		vmove usr/lib/pkgconfig/libpipewire-0.2.pc
-		vmove usr/lib/pkgconfig/libspa-0.1.pc
-		vmove usr/lib/libpipewire-0.2.so
+		vmove usr/include/pipewire-0.3
+		vmove usr/include/spa-0.2
+		vmove usr/lib/pkgconfig/libpipewire-0.3.pc
+		vmove usr/lib/pkgconfig/libspa-0.2.pc
+		vmove usr/lib/libpipewire-0.3.so
 	}
 }
 
 libspa-ffmpeg_package() {
 	short_desc+=" - ffmpeg plugins"
 	pkg_install() {
-		vmove usr/lib/spa/ffmpeg
+		vmove usr/lib/spa-0.2/ffmpeg
 	}
 }
 
 libspa-bluetooth_package() {
 	short_desc+=" - bluetooth plugins"
 	pkg_install() {
-		vmove usr/lib/spa/bluez5
+		vmove usr/lib/spa-0.2/bluez5
 	}
 }
 
@@ -57,6 +70,32 @@ gstreamer1-pipewire_package() {
 	}
 }
 
+libpulseaudio-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - PulseAudio client library"
+	pkg_install() {
+		vmove "usr/lib/libpulse-mainloop-glib-pw.so*"
+		vmove "usr/lib/libpulse-pw.so*"
+		vmove "usr/lib/libpulse-simple-pw.so*"
+	}
+}
+
+alsa-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - ALSA client library"
+	pkg_install() {
+		vmove "usr/lib/alsa-lib"
+	}
+}
+
+libjack-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - JACK client library"
+	pkg_install() {
+		vmove "usr/lib/libjack-pw.so*"
+	}
+}
+
 pipewire-doc_package() {
 	archs=noarch
 	short_desc+=" - documentation"

From b705425c5e4e628dabc3371dd33b1bfa3172f17d Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:26 +0900
Subject: [PATCH 2/3] xdg-desktop-portal: update to 1.7.2

---
 srcpkgs/xdg-desktop-portal/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/xdg-desktop-portal/template b/srcpkgs/xdg-desktop-portal/template
index eb8a4602f5d..25b821f0b69 100644
--- a/srcpkgs/xdg-desktop-portal/template
+++ b/srcpkgs/xdg-desktop-portal/template
@@ -1,6 +1,6 @@
 # Template file for 'xdg-desktop-portal'
 pkgname=xdg-desktop-portal
-version=1.6.0
+version=1.7.2
 revision=1
 build_style=gnu-configure
 configure_args="--enable-pipewire --enable-geoclue --disable-libportal"
@@ -11,7 +11,7 @@ maintainer="Duncaen <duncaen@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://github.com/flatpak/xdg-desktop-portal"
 distfiles="https://github.com/flatpak/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.xz"
-checksum=883c9c9a925e48af54812b5347f546dd776ec2e27076a83d5a8126af6bafb9da
+checksum=2f2bffa93107d905b9939b844eb6c46f37267c37dc27146ab13ae429f03e629f
 
 post_install() {
 	rm -rf "${DESTDIR}/usr/lib/systemd"

From 6f95e5c599aa9ac1b0e93f6370abeb3d1086c8e5 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:46 +0900
Subject: [PATCH 3/3] xdg-desktop-portal-kde: rebuild for pipewire-0.3

---
 srcpkgs/xdg-desktop-portal-kde/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xdg-desktop-portal-kde/template b/srcpkgs/xdg-desktop-portal-kde/template
index f26057d323a..9519abc19f6 100644
--- a/srcpkgs/xdg-desktop-portal-kde/template
+++ b/srcpkgs/xdg-desktop-portal-kde/template
@@ -1,7 +1,7 @@
 # Template file for 'xdg-desktop-portal-kde'
 pkgname=xdg-desktop-portal-kde
 version=5.18.4.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules qt5-qmake qt5-host-tools kcoreaddons gettext"
 makedepends="glib-devel kio-devel kwayland-devel libepoxy-devel pipewire-devel

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: WIP: pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (4 preceding siblings ...)
  2020-04-05 11:28 ` [PR PATCH] [Updated] WIP: " sirn
@ 2020-04-05 11:30 ` sirn
  2020-04-18  7:53 ` [PR PATCH] [Updated] " sirn
                   ` (45 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-04-05 11:30 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 367 bytes --]

New comment by sirn on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-609401673

Comment:
I've bumped `xdg-desktop-portal` to 1.7.2 which include a fix for building under musl so conditional patch is no longer needed. It's still prerelease though, but I'll keep this PR updated until 1.8.0(?) is released. :bowing_man: 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PR PATCH] [Updated] WIP: pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (5 preceding siblings ...)
  2020-04-05 11:30 ` sirn
@ 2020-04-18  7:53 ` sirn
  2020-04-29 19:44 ` mnabid
                   ` (44 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-04-18  7:53 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 1073 bytes --]

There is an updated pull request by sirn against master on the void-packages repository

https://github.com/sirn/void-packages pipewire-update
https://github.com/void-linux/void-packages/pull/20413

WIP: pipewire: update to 0.3.2
This PR updates pipewire to 0.3.2 as well as update packages that depends on it (xdg-desktop-portal to 1.7.1 and bump revision of xdg-desktop-portal-kde to force rebuild with pipewire-0.3)

xdg-desktop-portal 1.7.1 has few changes to xdg-document-portal and requires a patch to build on musl (`O_FSYNC` being undefined, see [musl's FFSYNC patch](https://git.musl-libc.org/cgit/musl/commit/?id=c1f4ed150137d793c9d07356305a89e8785e7e02)). 

Edit: on a second thought, I'm now providing `alsa-pipewire` (installs `libasound_module_pcm_pipewire.so`, so not much to configure) as well as `libjack-pipewire` and `libpulseaudio-pipewire` but still not sure what would be the best way to provide an option to replace `libpulse.so`/`libjack.so` with them. 

A patch file from https://github.com/void-linux/void-packages/pull/20413.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pipewire-update-20413.patch --]
[-- Type: text/x-diff, Size: 7443 bytes --]

From 6285fbb16f13bb54fea82aeef15c9616db27634d Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:23:52 +0900
Subject: [PATCH 1/3] pipewire: update to 0.3.2

---
 common/shlibs                  |  2 +-
 srcpkgs/alsa-pipewire          |  1 +
 srcpkgs/libjack-pipewire       |  1 +
 srcpkgs/libpulseaudio-pipewire |  1 +
 srcpkgs/pipewire/template      | 71 ++++++++++++++++++++++++++--------
 5 files changed, 59 insertions(+), 17 deletions(-)
 create mode 120000 srcpkgs/alsa-pipewire
 create mode 120000 srcpkgs/libjack-pipewire
 create mode 120000 srcpkgs/libpulseaudio-pipewire

diff --git a/common/shlibs b/common/shlibs
index 53a59b7303b..7f23af47ca9 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3201,7 +3201,7 @@ libarcan_shmif_ext.so.0.11 arcan-0.5.4.3_1
 libarcan_shmif_server.so.0.11 arcan-0.5.4.3_1
 libarcan_tui.so.0.11 arcan-0.5.4.3_1
 liblwipv6.so.2 lwipv6-1.5a_1
-libpipewire-0.2.so.1 libpipewire-0.2.2_1
+libpipewire-0.3.so.0 libpipewire-0.3.2_1
 libvolk.so.2.2.1 volk-2.2.1_1
 libgnuradio-runtime.so.3.8.0 gnuradio-3.8.0.0_1
 libgnuradio-pmt.so.3.8.0 gnuradio-3.8.0.0_1
diff --git a/srcpkgs/alsa-pipewire b/srcpkgs/alsa-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/alsa-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libjack-pipewire b/srcpkgs/libjack-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libjack-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libpulseaudio-pipewire b/srcpkgs/libpulseaudio-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libpulseaudio-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/pipewire/template b/srcpkgs/pipewire/template
index 7f646dad11d..697c20c0347 100644
--- a/srcpkgs/pipewire/template
+++ b/srcpkgs/pipewire/template
@@ -1,26 +1,39 @@
 # Template file for 'pipewire'
 pkgname=pipewire
-version=0.2.7
+version=0.3.2
 revision=1
 build_style=meson
-configure_args="-Dman=true -Dgstreamer=enabled -Ddocs=true -Dsystemd=false"
+configure_args="-Dman=true -Dgstreamer=true -Ddocs=true -Dsystemd=false
+ -Dbluez5=true -Dffmpeg=true -Dpipewire-alsa=true -Dpipewire-jack=true
+ -Dpipewire-pulseaudio=true"
 hostmakedepends="doxygen graphviz pkg-config xmltoman"
 makedepends="SDL2-devel ffmpeg-devel gst-plugins-base1-devel jack-devel
- sbc-devel v4l-utils-devel libva-devel"
+ sbc-devel v4l-utils-devel libva-devel libbluetooth-devel"
 short_desc="Server and user space API to deal with multimedia pipelines"
 maintainer="Orphaned <orphan@voidlinux.org>"
-#Next release will probably change to MIT, currently listed in master
-license="LGPL-2.1-only, GPL-2.0-only "
+license="MIT"
 homepage="https://pipewire.org/"
-changelog="https://raw.githubusercontent.com/PipeWire/pipewire/master/NEWS"
-distfiles="https://github.com/PipeWire/pipewire/archive/${version}.tar.gz"
-checksum=bfaa0f6ae6c0791e2e0b59234d399753bf24f1b33dbf587682363a8463dd8df1
+changelog="https://gitlab.freedesktop.org/pipewire/pipewire/-/raw/master/NEWS"
+distfiles="https://gitlab.freedesktop.org/pipewire/pipewire/-/archive/${version}/pipewire-${version}.tar.gz"
+checksum=fd1bb2ae65997d921d6c18e1828f23251dac3145bbe5031c324afeb39f9b26fb
 conf_files="/etc/pipewire/pipewire.conf"
 
+CFLAGS+="-Wformat"
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+	LDFLAGS+=" -latomic"
+fi
+
+post_install() {
+	vlicense LICENSE
+}
+
 libpipewire_package() {
 	short_desc+=" - pipewire library"
 	pkg_install() {
-		vmove "usr/lib/libpipewire-0.2.so.*"
+		vmove "usr/lib/libpipewire-0.3.so.*"
+		vmove usr/lib/pipewire-0.3
 	}
 }
 
@@ -28,25 +41,25 @@ pipewire-devel_package() {
 	depends="libpipewire-${version}_${revision}"
 	short_desc+=" - pipewire and libspa development files"
 	pkg_install() {
-		vmove usr/include/pipewire
-		vmove usr/include/spa
-		vmove usr/lib/pkgconfig/libpipewire-0.2.pc
-		vmove usr/lib/pkgconfig/libspa-0.1.pc
-		vmove usr/lib/libpipewire-0.2.so
+		vmove usr/include/pipewire-0.3
+		vmove usr/include/spa-0.2
+		vmove usr/lib/pkgconfig/libpipewire-0.3.pc
+		vmove usr/lib/pkgconfig/libspa-0.2.pc
+		vmove usr/lib/libpipewire-0.3.so
 	}
 }
 
 libspa-ffmpeg_package() {
 	short_desc+=" - ffmpeg plugins"
 	pkg_install() {
-		vmove usr/lib/spa/ffmpeg
+		vmove usr/lib/spa-0.2/ffmpeg
 	}
 }
 
 libspa-bluetooth_package() {
 	short_desc+=" - bluetooth plugins"
 	pkg_install() {
-		vmove usr/lib/spa/bluez5
+		vmove usr/lib/spa-0.2/bluez5
 	}
 }
 
@@ -57,6 +70,32 @@ gstreamer1-pipewire_package() {
 	}
 }
 
+libpulseaudio-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - PulseAudio client library"
+	pkg_install() {
+		vmove "usr/lib/libpulse-mainloop-glib-pw.so*"
+		vmove "usr/lib/libpulse-pw.so*"
+		vmove "usr/lib/libpulse-simple-pw.so*"
+	}
+}
+
+alsa-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - ALSA client library"
+	pkg_install() {
+		vmove "usr/lib/alsa-lib"
+	}
+}
+
+libjack-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - JACK client library"
+	pkg_install() {
+		vmove "usr/lib/libjack-pw.so*"
+	}
+}
+
 pipewire-doc_package() {
 	archs=noarch
 	short_desc+=" - documentation"

From 40e6e8398cdb1034a339189d09e82889210e27b2 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:26 +0900
Subject: [PATCH 2/3] xdg-desktop-portal: update to 1.7.2

---
 srcpkgs/xdg-desktop-portal/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/xdg-desktop-portal/template b/srcpkgs/xdg-desktop-portal/template
index eb8a4602f5d..25b821f0b69 100644
--- a/srcpkgs/xdg-desktop-portal/template
+++ b/srcpkgs/xdg-desktop-portal/template
@@ -1,6 +1,6 @@
 # Template file for 'xdg-desktop-portal'
 pkgname=xdg-desktop-portal
-version=1.6.0
+version=1.7.2
 revision=1
 build_style=gnu-configure
 configure_args="--enable-pipewire --enable-geoclue --disable-libportal"
@@ -11,7 +11,7 @@ maintainer="Duncaen <duncaen@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://github.com/flatpak/xdg-desktop-portal"
 distfiles="https://github.com/flatpak/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.xz"
-checksum=883c9c9a925e48af54812b5347f546dd776ec2e27076a83d5a8126af6bafb9da
+checksum=2f2bffa93107d905b9939b844eb6c46f37267c37dc27146ab13ae429f03e629f
 
 post_install() {
 	rm -rf "${DESTDIR}/usr/lib/systemd"

From 770d6085921e1eb046e35d0f1454a1c1c35f2989 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:46 +0900
Subject: [PATCH 3/3] xdg-desktop-portal-kde: rebuild for pipewire-0.3

---
 srcpkgs/xdg-desktop-portal-kde/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xdg-desktop-portal-kde/template b/srcpkgs/xdg-desktop-portal-kde/template
index f26057d323a..9519abc19f6 100644
--- a/srcpkgs/xdg-desktop-portal-kde/template
+++ b/srcpkgs/xdg-desktop-portal-kde/template
@@ -1,7 +1,7 @@
 # Template file for 'xdg-desktop-portal-kde'
 pkgname=xdg-desktop-portal-kde
 version=5.18.4.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules qt5-qmake qt5-host-tools kcoreaddons gettext"
 makedepends="glib-devel kio-devel kwayland-devel libepoxy-devel pipewire-devel

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: WIP: pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (6 preceding siblings ...)
  2020-04-18  7:53 ` [PR PATCH] [Updated] " sirn
@ 2020-04-29 19:44 ` mnabid
  2020-04-29 19:46 ` mnabid
                   ` (43 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: mnabid @ 2020-04-29 19:44 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 668 bytes --]

New comment by mnabid on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-621423386

Comment:
@sirn
I rebuilt `xdg-desktop-portal` 1.6.0 with [this patch](https://github.com/flatpak/xdg-desktop-portal/commit/a38901e5e7f835efe7b7a06c55790c8c20bc91a2) and that seems to be built fine. 

God knows when **1.8.0** will be released ! `mutter-3.36` needs `libpipewire-0.3.x `, so all **gnome 3.36** updates will be stuck if pipewire can't be updated. Could you just revbump `xdg-desktop-portal` for now? I've modified [template](https://github.com/mnabid/void-packages/commit/a91e2a2a8177ad231f1f49f168b44279f5f18ec0) a bit. 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: WIP: pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (7 preceding siblings ...)
  2020-04-29 19:44 ` mnabid
@ 2020-04-29 19:46 ` mnabid
  2020-04-29 19:47 ` mnabid
                   ` (42 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: mnabid @ 2020-04-29 19:46 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 672 bytes --]

New comment by mnabid on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-621423386

Comment:
@sirn
I rebuilt `xdg-desktop-portal` 1.6.0 with [this patch](https://github.com/flatpak/xdg-desktop-portal/commit/a38901e5e7f835efe7b7a06c55790c8c20bc91a2) and that seems to be built fine. 

God knows when **1.8.0** will be released ! `mutter-3.36` needs `libpipewire-0.3.x `, so all **gnome 3.36** updates will be stuck if pipewire can't be updated. Could you just revbump `xdg-desktop-portal` for now? I've modified the [template](https://github.com/mnabid/void-packages/commit/a91e2a2a8177ad231f1f49f168b44279f5f18ec0) a bit. 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: WIP: pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (8 preceding siblings ...)
  2020-04-29 19:46 ` mnabid
@ 2020-04-29 19:47 ` mnabid
  2020-04-29 20:02 ` [PR PATCH] [Updated] " sirn
                   ` (41 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: mnabid @ 2020-04-29 19:47 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 669 bytes --]

New comment by mnabid on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-621423386

Comment:
@sirn
I rebuilt `xdg-desktop-portal` 1.6.0 with [this patch](https://github.com/flatpak/xdg-desktop-portal/commit/a38901e5e7f835efe7b7a06c55790c8c20bc91a2) and that seems to be built fine. 

God knows when **1.8.0** will be released ! `mutter-3.36` needs `libpipewire-0.3`, so all **gnome 3.36** updates will be stuck if pipewire can't be updated. Could you just revbump `xdg-desktop-portal` for now? I've modified the [template](https://github.com/mnabid/void-packages/commit/a91e2a2a8177ad231f1f49f168b44279f5f18ec0) a bit. 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PR PATCH] [Updated] WIP: pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (9 preceding siblings ...)
  2020-04-29 19:47 ` mnabid
@ 2020-04-29 20:02 ` sirn
  2020-04-29 20:04 ` sirn
                   ` (40 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-04-29 20:02 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 1073 bytes --]

There is an updated pull request by sirn against master on the void-packages repository

https://github.com/sirn/void-packages pipewire-update
https://github.com/void-linux/void-packages/pull/20413

WIP: pipewire: update to 0.3.2
This PR updates pipewire to 0.3.2 as well as update packages that depends on it (xdg-desktop-portal to 1.7.1 and bump revision of xdg-desktop-portal-kde to force rebuild with pipewire-0.3)

xdg-desktop-portal 1.7.1 has few changes to xdg-document-portal and requires a patch to build on musl (`O_FSYNC` being undefined, see [musl's FFSYNC patch](https://git.musl-libc.org/cgit/musl/commit/?id=c1f4ed150137d793c9d07356305a89e8785e7e02)). 

Edit: on a second thought, I'm now providing `alsa-pipewire` (installs `libasound_module_pcm_pipewire.so`, so not much to configure) as well as `libjack-pipewire` and `libpulseaudio-pipewire` but still not sure what would be the best way to provide an option to replace `libpulse.so`/`libjack.so` with them. 

A patch file from https://github.com/void-linux/void-packages/pull/20413.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pipewire-update-20413.patch --]
[-- Type: text/x-diff, Size: 7443 bytes --]

From 6285fbb16f13bb54fea82aeef15c9616db27634d Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:23:52 +0900
Subject: [PATCH 1/3] pipewire: update to 0.3.2

---
 common/shlibs                  |  2 +-
 srcpkgs/alsa-pipewire          |  1 +
 srcpkgs/libjack-pipewire       |  1 +
 srcpkgs/libpulseaudio-pipewire |  1 +
 srcpkgs/pipewire/template      | 71 ++++++++++++++++++++++++++--------
 5 files changed, 59 insertions(+), 17 deletions(-)
 create mode 120000 srcpkgs/alsa-pipewire
 create mode 120000 srcpkgs/libjack-pipewire
 create mode 120000 srcpkgs/libpulseaudio-pipewire

diff --git a/common/shlibs b/common/shlibs
index 53a59b7303b..7f23af47ca9 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3201,7 +3201,7 @@ libarcan_shmif_ext.so.0.11 arcan-0.5.4.3_1
 libarcan_shmif_server.so.0.11 arcan-0.5.4.3_1
 libarcan_tui.so.0.11 arcan-0.5.4.3_1
 liblwipv6.so.2 lwipv6-1.5a_1
-libpipewire-0.2.so.1 libpipewire-0.2.2_1
+libpipewire-0.3.so.0 libpipewire-0.3.2_1
 libvolk.so.2.2.1 volk-2.2.1_1
 libgnuradio-runtime.so.3.8.0 gnuradio-3.8.0.0_1
 libgnuradio-pmt.so.3.8.0 gnuradio-3.8.0.0_1
diff --git a/srcpkgs/alsa-pipewire b/srcpkgs/alsa-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/alsa-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libjack-pipewire b/srcpkgs/libjack-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libjack-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libpulseaudio-pipewire b/srcpkgs/libpulseaudio-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libpulseaudio-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/pipewire/template b/srcpkgs/pipewire/template
index 7f646dad11d..697c20c0347 100644
--- a/srcpkgs/pipewire/template
+++ b/srcpkgs/pipewire/template
@@ -1,26 +1,39 @@
 # Template file for 'pipewire'
 pkgname=pipewire
-version=0.2.7
+version=0.3.2
 revision=1
 build_style=meson
-configure_args="-Dman=true -Dgstreamer=enabled -Ddocs=true -Dsystemd=false"
+configure_args="-Dman=true -Dgstreamer=true -Ddocs=true -Dsystemd=false
+ -Dbluez5=true -Dffmpeg=true -Dpipewire-alsa=true -Dpipewire-jack=true
+ -Dpipewire-pulseaudio=true"
 hostmakedepends="doxygen graphviz pkg-config xmltoman"
 makedepends="SDL2-devel ffmpeg-devel gst-plugins-base1-devel jack-devel
- sbc-devel v4l-utils-devel libva-devel"
+ sbc-devel v4l-utils-devel libva-devel libbluetooth-devel"
 short_desc="Server and user space API to deal with multimedia pipelines"
 maintainer="Orphaned <orphan@voidlinux.org>"
-#Next release will probably change to MIT, currently listed in master
-license="LGPL-2.1-only, GPL-2.0-only "
+license="MIT"
 homepage="https://pipewire.org/"
-changelog="https://raw.githubusercontent.com/PipeWire/pipewire/master/NEWS"
-distfiles="https://github.com/PipeWire/pipewire/archive/${version}.tar.gz"
-checksum=bfaa0f6ae6c0791e2e0b59234d399753bf24f1b33dbf587682363a8463dd8df1
+changelog="https://gitlab.freedesktop.org/pipewire/pipewire/-/raw/master/NEWS"
+distfiles="https://gitlab.freedesktop.org/pipewire/pipewire/-/archive/${version}/pipewire-${version}.tar.gz"
+checksum=fd1bb2ae65997d921d6c18e1828f23251dac3145bbe5031c324afeb39f9b26fb
 conf_files="/etc/pipewire/pipewire.conf"
 
+CFLAGS+="-Wformat"
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+	LDFLAGS+=" -latomic"
+fi
+
+post_install() {
+	vlicense LICENSE
+}
+
 libpipewire_package() {
 	short_desc+=" - pipewire library"
 	pkg_install() {
-		vmove "usr/lib/libpipewire-0.2.so.*"
+		vmove "usr/lib/libpipewire-0.3.so.*"
+		vmove usr/lib/pipewire-0.3
 	}
 }
 
@@ -28,25 +41,25 @@ pipewire-devel_package() {
 	depends="libpipewire-${version}_${revision}"
 	short_desc+=" - pipewire and libspa development files"
 	pkg_install() {
-		vmove usr/include/pipewire
-		vmove usr/include/spa
-		vmove usr/lib/pkgconfig/libpipewire-0.2.pc
-		vmove usr/lib/pkgconfig/libspa-0.1.pc
-		vmove usr/lib/libpipewire-0.2.so
+		vmove usr/include/pipewire-0.3
+		vmove usr/include/spa-0.2
+		vmove usr/lib/pkgconfig/libpipewire-0.3.pc
+		vmove usr/lib/pkgconfig/libspa-0.2.pc
+		vmove usr/lib/libpipewire-0.3.so
 	}
 }
 
 libspa-ffmpeg_package() {
 	short_desc+=" - ffmpeg plugins"
 	pkg_install() {
-		vmove usr/lib/spa/ffmpeg
+		vmove usr/lib/spa-0.2/ffmpeg
 	}
 }
 
 libspa-bluetooth_package() {
 	short_desc+=" - bluetooth plugins"
 	pkg_install() {
-		vmove usr/lib/spa/bluez5
+		vmove usr/lib/spa-0.2/bluez5
 	}
 }
 
@@ -57,6 +70,32 @@ gstreamer1-pipewire_package() {
 	}
 }
 
+libpulseaudio-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - PulseAudio client library"
+	pkg_install() {
+		vmove "usr/lib/libpulse-mainloop-glib-pw.so*"
+		vmove "usr/lib/libpulse-pw.so*"
+		vmove "usr/lib/libpulse-simple-pw.so*"
+	}
+}
+
+alsa-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - ALSA client library"
+	pkg_install() {
+		vmove "usr/lib/alsa-lib"
+	}
+}
+
+libjack-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - JACK client library"
+	pkg_install() {
+		vmove "usr/lib/libjack-pw.so*"
+	}
+}
+
 pipewire-doc_package() {
 	archs=noarch
 	short_desc+=" - documentation"

From 40e6e8398cdb1034a339189d09e82889210e27b2 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:26 +0900
Subject: [PATCH 2/3] xdg-desktop-portal: update to 1.7.2

---
 srcpkgs/xdg-desktop-portal/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/xdg-desktop-portal/template b/srcpkgs/xdg-desktop-portal/template
index eb8a4602f5d..25b821f0b69 100644
--- a/srcpkgs/xdg-desktop-portal/template
+++ b/srcpkgs/xdg-desktop-portal/template
@@ -1,6 +1,6 @@
 # Template file for 'xdg-desktop-portal'
 pkgname=xdg-desktop-portal
-version=1.6.0
+version=1.7.2
 revision=1
 build_style=gnu-configure
 configure_args="--enable-pipewire --enable-geoclue --disable-libportal"
@@ -11,7 +11,7 @@ maintainer="Duncaen <duncaen@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://github.com/flatpak/xdg-desktop-portal"
 distfiles="https://github.com/flatpak/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.xz"
-checksum=883c9c9a925e48af54812b5347f546dd776ec2e27076a83d5a8126af6bafb9da
+checksum=2f2bffa93107d905b9939b844eb6c46f37267c37dc27146ab13ae429f03e629f
 
 post_install() {
 	rm -rf "${DESTDIR}/usr/lib/systemd"

From 770d6085921e1eb046e35d0f1454a1c1c35f2989 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:46 +0900
Subject: [PATCH 3/3] xdg-desktop-portal-kde: rebuild for pipewire-0.3

---
 srcpkgs/xdg-desktop-portal-kde/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xdg-desktop-portal-kde/template b/srcpkgs/xdg-desktop-portal-kde/template
index f26057d323a..9519abc19f6 100644
--- a/srcpkgs/xdg-desktop-portal-kde/template
+++ b/srcpkgs/xdg-desktop-portal-kde/template
@@ -1,7 +1,7 @@
 # Template file for 'xdg-desktop-portal-kde'
 pkgname=xdg-desktop-portal-kde
 version=5.18.4.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules qt5-qmake qt5-host-tools kcoreaddons gettext"
 makedepends="glib-devel kio-devel kwayland-devel libepoxy-devel pipewire-devel

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: WIP: pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (10 preceding siblings ...)
  2020-04-29 20:02 ` [PR PATCH] [Updated] " sirn
@ 2020-04-29 20:04 ` sirn
  2020-04-29 20:09 ` sirn
                   ` (39 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-04-29 20:04 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 201 bytes --]

New comment by sirn on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-621433367

Comment:
@mnabid I've cherry-pick pipewire from your branch. Thank you! 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: WIP: pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (11 preceding siblings ...)
  2020-04-29 20:04 ` sirn
@ 2020-04-29 20:09 ` sirn
  2020-04-29 20:23 ` sirn
                   ` (38 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-04-29 20:09 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 222 bytes --]

New comment by sirn on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-621433367

Comment:
@mnabid I've cherry-pick ~pipewire~ xdg-desktop-portal from your branch. Thank you! 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (12 preceding siblings ...)
  2020-04-29 20:09 ` sirn
@ 2020-04-29 20:23 ` sirn
  2020-04-29 20:32 ` mnabid
                   ` (37 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-04-29 20:23 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 363 bytes --]

New comment by sirn on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-621442760

Comment:
@Duncaen since this PR is now building `xdg-desktop-portal` 1.6.0 with pipewire 0.3 patch, and it seems to build in all systems (& also confirmed working locally on x86_64-musl), is it possible to re-review? Thank you! :bow: 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (13 preceding siblings ...)
  2020-04-29 20:23 ` sirn
@ 2020-04-29 20:32 ` mnabid
  2020-04-29 20:37 ` sirn
                   ` (36 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: mnabid @ 2020-04-29 20:32 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 325 bytes --]

New comment by mnabid on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-621447056

Comment:
Now that I think about it...
`mutter-3.34` is still in the repo and needs `libpipewire-0.2`, so that'll create **unresolvable shlib** issue. I'm working on gnome 3.36 updates (#21382).

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (14 preceding siblings ...)
  2020-04-29 20:32 ` mnabid
@ 2020-04-29 20:37 ` sirn
  2020-04-29 20:38 ` mnabid
                   ` (35 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-04-29 20:37 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 590 bytes --]

New comment by sirn on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-621450118

Comment:
Looks like so far only mutter hasn't been updated:

```
$ xbps-query -RX libpipewire
gstreamer1-pipewire-0.2.7_1
mutter-3.34.1_2
pipewire-0.2.7_1
pipewire-devel-0.2.7_1
xdg-desktop-portal-1.6.0_1
xdg-desktop-portal-kde-5.18.4.1_1
```

Is it possible to version bump just Mutter, or that requires the rest of GNOME 3.36 as well? In the latter case I guess it makes more sense that I'll close this PR and let #21382 incorporate pipewire-0.3? 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (15 preceding siblings ...)
  2020-04-29 20:37 ` sirn
@ 2020-04-29 20:38 ` mnabid
  2020-04-29 20:40 ` mnabid
                   ` (34 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: mnabid @ 2020-04-29 20:38 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 640 bytes --]

New comment by mnabid on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-621450613

Comment:
> Looks like so far only mutter hasn't been updated:
> 
> ```
> $ xbps-query -RX libpipewire
> gstreamer1-pipewire-0.2.7_1
> mutter-3.34.1_2
> pipewire-0.2.7_1
> pipewire-devel-0.2.7_1
> xdg-desktop-portal-1.6.0_1
> xdg-desktop-portal-kde-5.18.4.1_1
> ```
> 
> Is it possible to version bump just Mutter, or that requires the rest of GNOME 3.36 as well? In the latter case I guess it makes more sense that I'll close this PR and let #21382 incorporate pipewire-0.3?

Yeah, rest of 3.36.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (16 preceding siblings ...)
  2020-04-29 20:38 ` mnabid
@ 2020-04-29 20:40 ` mnabid
  2020-04-29 21:18 ` [PR PATCH] [Updated] " sirn
                   ` (33 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: mnabid @ 2020-04-29 20:40 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 681 bytes --]

New comment by mnabid on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-621450613

Comment:
> Looks like so far only mutter hasn't been updated:
> 
> ```
> $ xbps-query -RX libpipewire
> gstreamer1-pipewire-0.2.7_1
> mutter-3.34.1_2
> pipewire-0.2.7_1
> pipewire-devel-0.2.7_1
> xdg-desktop-portal-1.6.0_1
> xdg-desktop-portal-kde-5.18.4.1_1
> ```
> 
> Is it possible to version bump just Mutter, or that requires the rest of GNOME 3.36 as well? In the latter case I guess it makes more sense that I'll close this PR and let #21382 incorporate pipewire-0.3?

Yeah, rest of 3.36.
I tried to revbump mutter, didn't work.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PR PATCH] [Updated] pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (17 preceding siblings ...)
  2020-04-29 20:40 ` mnabid
@ 2020-04-29 21:18 ` sirn
  2020-04-29 21:20 ` sirn
                   ` (32 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-04-29 21:18 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 1068 bytes --]

There is an updated pull request by sirn against master on the void-packages repository

https://github.com/sirn/void-packages pipewire-update
https://github.com/void-linux/void-packages/pull/20413

pipewire: update to 0.3.2
This PR updates pipewire to 0.3.2 as well as update packages that depends on it (xdg-desktop-portal to 1.7.1 and bump revision of xdg-desktop-portal-kde to force rebuild with pipewire-0.3)

xdg-desktop-portal 1.7.1 has few changes to xdg-document-portal and requires a patch to build on musl (`O_FSYNC` being undefined, see [musl's FFSYNC patch](https://git.musl-libc.org/cgit/musl/commit/?id=c1f4ed150137d793c9d07356305a89e8785e7e02)). 

Edit: on a second thought, I'm now providing `alsa-pipewire` (installs `libasound_module_pcm_pipewire.so`, so not much to configure) as well as `libjack-pipewire` and `libpulseaudio-pipewire` but still not sure what would be the best way to provide an option to replace `libpulse.so`/`libjack.so` with them. 

A patch file from https://github.com/void-linux/void-packages/pull/20413.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pipewire-update-20413.patch --]
[-- Type: text/x-diff, Size: 50842 bytes --]

From bcffa68d6816ccfcd1cb5b9418fa7ecf9ddf30ed Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:23:52 +0900
Subject: [PATCH 1/4] pipewire: update to 0.3.2

---
 common/shlibs                  |  2 +-
 srcpkgs/alsa-pipewire          |  1 +
 srcpkgs/libjack-pipewire       |  1 +
 srcpkgs/libpulseaudio-pipewire |  1 +
 srcpkgs/pipewire/template      | 71 ++++++++++++++++++++++++++--------
 5 files changed, 59 insertions(+), 17 deletions(-)
 create mode 120000 srcpkgs/alsa-pipewire
 create mode 120000 srcpkgs/libjack-pipewire
 create mode 120000 srcpkgs/libpulseaudio-pipewire

diff --git a/common/shlibs b/common/shlibs
index a208407b359..0b58777db72 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3199,7 +3199,7 @@ libarcan_shmif_ext.so.0.11 arcan-0.5.4.3_1
 libarcan_shmif_server.so.0.11 arcan-0.5.4.3_1
 libarcan_tui.so.0.11 arcan-0.5.4.3_1
 liblwipv6.so.2 lwipv6-1.5a_1
-libpipewire-0.2.so.1 libpipewire-0.2.2_1
+libpipewire-0.3.so.0 libpipewire-0.3.2_1
 libvolk.so.2.2.1 volk-2.2.1_1
 libgnuradio-runtime.so.3.8.0 gnuradio-3.8.0.0_1
 libgnuradio-pmt.so.3.8.0 gnuradio-3.8.0.0_1
diff --git a/srcpkgs/alsa-pipewire b/srcpkgs/alsa-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/alsa-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libjack-pipewire b/srcpkgs/libjack-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libjack-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libpulseaudio-pipewire b/srcpkgs/libpulseaudio-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libpulseaudio-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/pipewire/template b/srcpkgs/pipewire/template
index 7f646dad11d..697c20c0347 100644
--- a/srcpkgs/pipewire/template
+++ b/srcpkgs/pipewire/template
@@ -1,26 +1,39 @@
 # Template file for 'pipewire'
 pkgname=pipewire
-version=0.2.7
+version=0.3.2
 revision=1
 build_style=meson
-configure_args="-Dman=true -Dgstreamer=enabled -Ddocs=true -Dsystemd=false"
+configure_args="-Dman=true -Dgstreamer=true -Ddocs=true -Dsystemd=false
+ -Dbluez5=true -Dffmpeg=true -Dpipewire-alsa=true -Dpipewire-jack=true
+ -Dpipewire-pulseaudio=true"
 hostmakedepends="doxygen graphviz pkg-config xmltoman"
 makedepends="SDL2-devel ffmpeg-devel gst-plugins-base1-devel jack-devel
- sbc-devel v4l-utils-devel libva-devel"
+ sbc-devel v4l-utils-devel libva-devel libbluetooth-devel"
 short_desc="Server and user space API to deal with multimedia pipelines"
 maintainer="Orphaned <orphan@voidlinux.org>"
-#Next release will probably change to MIT, currently listed in master
-license="LGPL-2.1-only, GPL-2.0-only "
+license="MIT"
 homepage="https://pipewire.org/"
-changelog="https://raw.githubusercontent.com/PipeWire/pipewire/master/NEWS"
-distfiles="https://github.com/PipeWire/pipewire/archive/${version}.tar.gz"
-checksum=bfaa0f6ae6c0791e2e0b59234d399753bf24f1b33dbf587682363a8463dd8df1
+changelog="https://gitlab.freedesktop.org/pipewire/pipewire/-/raw/master/NEWS"
+distfiles="https://gitlab.freedesktop.org/pipewire/pipewire/-/archive/${version}/pipewire-${version}.tar.gz"
+checksum=fd1bb2ae65997d921d6c18e1828f23251dac3145bbe5031c324afeb39f9b26fb
 conf_files="/etc/pipewire/pipewire.conf"
 
+CFLAGS+="-Wformat"
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+	LDFLAGS+=" -latomic"
+fi
+
+post_install() {
+	vlicense LICENSE
+}
+
 libpipewire_package() {
 	short_desc+=" - pipewire library"
 	pkg_install() {
-		vmove "usr/lib/libpipewire-0.2.so.*"
+		vmove "usr/lib/libpipewire-0.3.so.*"
+		vmove usr/lib/pipewire-0.3
 	}
 }
 
@@ -28,25 +41,25 @@ pipewire-devel_package() {
 	depends="libpipewire-${version}_${revision}"
 	short_desc+=" - pipewire and libspa development files"
 	pkg_install() {
-		vmove usr/include/pipewire
-		vmove usr/include/spa
-		vmove usr/lib/pkgconfig/libpipewire-0.2.pc
-		vmove usr/lib/pkgconfig/libspa-0.1.pc
-		vmove usr/lib/libpipewire-0.2.so
+		vmove usr/include/pipewire-0.3
+		vmove usr/include/spa-0.2
+		vmove usr/lib/pkgconfig/libpipewire-0.3.pc
+		vmove usr/lib/pkgconfig/libspa-0.2.pc
+		vmove usr/lib/libpipewire-0.3.so
 	}
 }
 
 libspa-ffmpeg_package() {
 	short_desc+=" - ffmpeg plugins"
 	pkg_install() {
-		vmove usr/lib/spa/ffmpeg
+		vmove usr/lib/spa-0.2/ffmpeg
 	}
 }
 
 libspa-bluetooth_package() {
 	short_desc+=" - bluetooth plugins"
 	pkg_install() {
-		vmove usr/lib/spa/bluez5
+		vmove usr/lib/spa-0.2/bluez5
 	}
 }
 
@@ -57,6 +70,32 @@ gstreamer1-pipewire_package() {
 	}
 }
 
+libpulseaudio-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - PulseAudio client library"
+	pkg_install() {
+		vmove "usr/lib/libpulse-mainloop-glib-pw.so*"
+		vmove "usr/lib/libpulse-pw.so*"
+		vmove "usr/lib/libpulse-simple-pw.so*"
+	}
+}
+
+alsa-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - ALSA client library"
+	pkg_install() {
+		vmove "usr/lib/alsa-lib"
+	}
+}
+
+libjack-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - JACK client library"
+	pkg_install() {
+		vmove "usr/lib/libjack-pw.so*"
+	}
+}
+
 pipewire-doc_package() {
 	archs=noarch
 	short_desc+=" - documentation"

From 6007b0cf7c3b3c59f1c787474c966ba59457c925 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:46 +0900
Subject: [PATCH 2/4] xdg-desktop-portal-kde: rebuild for pipewire-0.3

---
 srcpkgs/xdg-desktop-portal-kde/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xdg-desktop-portal-kde/template b/srcpkgs/xdg-desktop-portal-kde/template
index f26057d323a..9519abc19f6 100644
--- a/srcpkgs/xdg-desktop-portal-kde/template
+++ b/srcpkgs/xdg-desktop-portal-kde/template
@@ -1,7 +1,7 @@
 # Template file for 'xdg-desktop-portal-kde'
 pkgname=xdg-desktop-portal-kde
 version=5.18.4.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules qt5-qmake qt5-host-tools kcoreaddons gettext"
 makedepends="glib-devel kio-devel kwayland-devel libepoxy-devel pipewire-devel

From 3eea0de9b0c08e078717b0ecbc9e3ba33a69daf5 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:26 +0900
Subject: [PATCH 3/4] xdg-desktop-portal: rebuild for pipewire-0.3

---
 .../patches/pipewire-0.3.patch                | 551 ++++++++++++++++++
 srcpkgs/xdg-desktop-portal/template           |   8 +-
 2 files changed, 557 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch

diff --git a/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..94ebe083598
--- /dev/null
+++ b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
@@ -0,0 +1,551 @@
+From a38901e5e7f835efe7b7a06c55790c8c20bc91a2 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Tue, 14 Jan 2020 09:37:09 +0100
+Subject: [PATCH] PipeWire: update to 0.3 API
+
+---
+ configure.ac      |   2 +-
+ src/camera.c      |  24 ++++----
+ src/pipewire.c    | 141 +++++++++++++---------------------------------
+ src/pipewire.h    |  10 ++--
+ src/screen-cast.c |  98 ++++++--------------------------
+ 5 files changed, 72 insertions(+), 203 deletions(-)
+
+diff --git configure.ac configure.ac
+index 89902fa..62d7960 100644
+--- configure.ac
++++ configure.ac
+@@ -97,7 +97,7 @@ AC_ARG_ENABLE(pipewire,
+ 	      [AS_HELP_STRING([--enable-pipewire],[Enable PipeWire support. Needed for screen cast portal])],
+ 	      enable_pipewire=$enableval, enable_pipewire=yes)
+ if test x$enable_pipewire = xyes ; then
+-	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.2 >= 0.2.6])
++	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.3 >= 0.2.90])
+ 	AC_DEFINE([HAVE_PIPEWIRE],[1], [Define to enable PipeWire support])
+ fi
+ AM_CONDITIONAL([HAVE_PIPEWIRE],[test "$enable_pipewire" = "yes"])
+diff --git src/camera.c src/camera.c
+index c2b392c..20fe3aa 100644
+--- src/camera.c
++++ src/camera.c
+@@ -141,7 +141,7 @@ open_pipewire_camera_remote (const char *app_id,
+                              GError **error)
+ {
+   PipeWireRemote *remote;
+-  struct spa_dict_item permission_items[1];
++  struct pw_permission permission_items[2];
+   struct pw_properties *pipewire_properties;
+ 
+   pipewire_properties =
+@@ -158,12 +158,12 @@ open_pipewire_camera_remote (const char *app_id,
+    * Hide all existing and future nodes by default. PipeWire will use the
+    * permission store to set up permissions.
+    */
+-  permission_items[0].key = PW_CORE_PROXY_PERMISSIONS_DEFAULT;
+-  permission_items[0].value = "---";
++  permission_items[0] = PW_PERMISSION_INIT (PW_ID_CORE, PW_PERM_RWX);
++  permission_items[1] = PW_PERMISSION_INIT (PW_ID_ANY, 0);
+ 
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             &SPA_DICT_INIT (permission_items,
+-                                             G_N_ELEMENTS (permission_items)));
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                G_N_ELEMENTS (permission_items),
++                                permission_items);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -219,7 +219,7 @@ handle_open_pipewire_remote (XdpCamera *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
+@@ -250,29 +250,28 @@ camera_iface_init (XdpCameraIface *iface)
+ static void
+ global_added_cb (PipeWireRemote *remote,
+                  uint32_t id,
+-                 uint32_t type,
++                 const char *type,
+                  const struct spa_dict *props,
+                  gpointer user_data)
+ {
+   Camera *camera = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *media_class;
+   const struct spa_dict_item *media_role;
+ 
+-  if (type != core_type->node)
++  if (strcmp(type, PW_TYPE_INTERFACE_Node) != 0)
+     return;
+ 
+   if (!props)
+     return;
+ 
+-  media_class = spa_dict_lookup_item (props, "media.class");
++  media_class = spa_dict_lookup_item (props, PW_KEY_MEDIA_CLASS);
+   if (!media_class)
+     return;
+ 
+   if (g_strcmp0 (media_class->value, "Video/Source") != 0)
+     return;
+ 
+-  media_role = spa_dict_lookup_item (props, "media.role");
++  media_role = spa_dict_lookup_item (props, PW_KEY_MEDIA_ROLE);
+   if (!media_role)
+     return;
+ 
+@@ -342,6 +341,7 @@ create_pipewire_remote (Camera *camera,
+     }
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.is_portal", "true",
++                                           "portal.monitor", "Camera",
+                                            NULL);
+   camera->pipewire_remote = pipewire_remote_new_sync (pipewire_properties,
+                                                       global_added_cb,
+diff --git src/pipewire.c src/pipewire.c
+index 793a378..162cd55 100644
+--- src/pipewire.c
++++ src/pipewire.c
+@@ -21,6 +21,7 @@
+ #include <errno.h>
+ #include <glib.h>
+ #include <pipewire/pipewire.h>
++#include <spa/utils/result.h>
+ 
+ #include "pipewire.h"
+ 
+@@ -36,27 +37,25 @@ static gboolean is_pipewire_initialized = FALSE;
+ static void
+ registry_event_global (void *user_data,
+                        uint32_t id,
+-                       uint32_t parent_id,
+                        uint32_t permissions,
+-                       uint32_t type,
++                       const char *type,
+                        uint32_t version,
+                        const struct spa_dict *props)
+ {
+   PipeWireRemote *remote = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *factory_object_type;
+   PipeWireGlobal *global;
+ 
+   global = g_new0 (PipeWireGlobal, 1);
+   *global = (PipeWireGlobal) {
+-    .parent_id = parent_id,
++    .parent_id = id,
+   };
+ 
+   g_hash_table_insert (remote->globals, GINT_TO_POINTER (id), global);
+   if (remote->global_added_cb)
+     remote->global_added_cb (remote, id, type, props, remote->user_data);
+ 
+-  if (type != core_type->factory)
++  if (strcmp(type, PW_TYPE_INTERFACE_Factory) != 0)
+     return;
+ 
+   factory_object_type = spa_dict_lookup_item (props, "factory.type.name");
+@@ -81,8 +80,8 @@ registry_event_global_remove (void *user_data,
+   g_hash_table_remove (remote->globals, GINT_TO_POINTER (id));
+ }
+ 
+-static const struct pw_registry_proxy_events registry_events = {
+-  PW_VERSION_REGISTRY_PROXY_EVENTS,
++static const struct pw_registry_events registry_events = {
++  PW_VERSION_REGISTRY_EVENTS,
+   .global = registry_event_global,
+   .global_remove = registry_event_global_remove,
+ };
+@@ -90,7 +89,7 @@ static const struct pw_registry_proxy_events registry_events = {
+ void
+ pipewire_remote_roundtrip (PipeWireRemote *remote)
+ {
+-  pw_core_proxy_sync (remote->core_proxy, ++remote->sync_seq);
++  remote->sync_seq = pw_core_sync (remote->core, PW_ID_CORE, remote->sync_seq);
+   pw_main_loop_run (remote->loop);
+ }
+ 
+@@ -98,16 +97,13 @@ static gboolean
+ discover_node_factory_sync (PipeWireRemote *remote,
+                             GError **error)
+ {
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+-  struct pw_registry_proxy *registry_proxy;
++  struct pw_registry *registry;
+ 
+-  registry_proxy = pw_core_proxy_get_registry (remote->core_proxy,
+-                                               core_type->registry,
+-                                               PW_VERSION_REGISTRY, 0);
+-  pw_registry_proxy_add_listener (registry_proxy,
+-                                  &remote->registry_listener,
+-                                  &registry_events,
+-                                  remote);
++  registry = pw_core_get_registry (remote->core, PW_VERSION_REGISTRY, 0);
++  pw_registry_add_listener (registry,
++                            &remote->registry_listener,
++                            &registry_events,
++                            remote);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -122,59 +118,35 @@ discover_node_factory_sync (PipeWireRemote *remote,
+ }
+ 
+ static void
+-on_state_changed (void *user_data,
+-                  enum pw_remote_state old,
+-                  enum pw_remote_state state,
+-                  const char *error)
++core_event_error (void       *user_data,
++                  uint32_t    id,
++		  int         seq,
++		  int         res,
++		  const char *message)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  switch (state)
++  if (id == PW_ID_CORE)
+     {
+-    case PW_REMOTE_STATE_ERROR:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "%s", error);
+-        }
++      g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
++                 "%s", message);
+       pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "Disconnected");
+-        }
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    default:
+-      g_warning ("Unknown PipeWire state");
+-      break;
+     }
+ }
+ 
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
+-};
+-
+ static void
+ core_event_done (void *user_data,
+-                 uint32_t seq)
++                 uint32_t id, int seq)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  if (remote->sync_seq == seq)
++  if (id == PW_ID_CORE && remote->sync_seq == seq)
+     pw_main_loop_quit (remote->loop);
+ }
+ 
+-static const struct pw_core_proxy_events core_events = {
+-  PW_VERSION_CORE_PROXY_EVENTS,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = core_event_error,
+   .done = core_event_done,
+ };
+ 
+@@ -237,8 +209,8 @@ void
+ pipewire_remote_destroy (PipeWireRemote *remote)
+ {
+   g_clear_pointer (&remote->globals, g_hash_table_destroy);
+-  g_clear_pointer (&remote->remote, pw_remote_destroy);
+-  g_clear_pointer (&remote->core, pw_core_destroy);
++  g_clear_pointer (&remote->core, pw_core_disconnect);
++  g_clear_pointer (&remote->context, pw_context_destroy);
+   g_clear_pointer (&remote->loop, pw_main_loop_destroy);
+   g_clear_error (&remote->error);
+ 
+@@ -307,68 +279,31 @@ pipewire_remote_new_sync (struct pw_properties *pipewire_properties,
+       return NULL;
+     }
+ 
+-  remote->core = pw_core_new (pw_main_loop_get_loop (remote->loop), NULL);
+-  if (!remote->core)
++  remote->context = pw_context_new (pw_main_loop_get_loop (remote->loop), NULL, 0);
++  if (!remote->context)
+     {
+       pipewire_remote_destroy (remote);
+       pw_properties_free (pipewire_properties);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire core");
++                   "Couldn't create PipeWire context");
+       return NULL;
+     }
+ 
+-  remote->remote = pw_remote_new (remote->core, pipewire_properties, 0);
+-  if (!remote->remote)
++  remote->core = pw_context_connect (remote->context, pipewire_properties, 0);
++  if (!remote->core)
+     {
+       pipewire_remote_destroy (remote);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire remote");
++                   "Couldn't connect to PipeWire");
+       return NULL;
+     }
+ 
+   remote->globals = g_hash_table_new_full (NULL, NULL, NULL, g_free);
+ 
+-  pw_remote_add_listener (remote->remote,
+-                          &remote->remote_listener,
+-                          &remote_events,
+-                          remote);
+-
+-  if (pw_remote_connect (remote->remote) != 0)
+-    {
+-      pipewire_remote_destroy (remote);
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect PipeWire remote");
+-      return NULL;
+-    }
+-
+-  pw_main_loop_run (remote->loop);
+-
+-  switch (pw_remote_get_state (remote->remote, NULL))
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      *error = g_steal_pointer (&remote->error);
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "PipeWire loop stopped unexpectedly");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      break;
+-    default:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Unexpected PipeWire state");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    }
+-
+-  remote->core_proxy = pw_remote_get_core_proxy (remote->remote);
+-  pw_core_proxy_add_listener (remote->core_proxy,
+-                              &remote->core_listener,
+-                              &core_events,
+-                              remote);
++  pw_core_add_listener (remote->core,
++                        &remote->core_listener,
++                        &core_events,
++                        remote);
+ 
+   if (!discover_node_factory_sync (remote, error))
+     {
+diff --git src/pipewire.h src/pipewire.h
+index 0f1bf54..bf48d5e 100644
+--- src/pipewire.h
++++ src/pipewire.h
+@@ -32,7 +32,7 @@ typedef struct _PipeWireGlobal
+ 
+ typedef void (* PipeWireGlobalAddedCallback) (PipeWireRemote *remote,
+                                               uint32_t id,
+-                                              uint32_t type,
++                                              const char *type,
+                                               const struct spa_dict *props,
+                                               gpointer user_data);
+ 
+@@ -43,13 +43,11 @@ typedef void (* PipeWireGlobalRemovedCallback) (PipeWireRemote *remote,
+ struct _PipeWireRemote
+ {
+   struct pw_main_loop *loop;
++  struct pw_context *context;
+   struct pw_core *core;
+-  struct pw_remote *remote;
+-  struct spa_hook remote_listener;
+-
+-  struct pw_core_proxy *core_proxy;
+   struct spa_hook core_listener;
+-  uint32_t sync_seq;
++
++  int sync_seq;
+ 
+   struct spa_hook registry_listener;
+ 
+diff --git src/screen-cast.c src/screen-cast.c
+index 7881ddc..1677050 100644
+--- src/screen-cast.c
++++ src/screen-cast.c
+@@ -31,10 +31,10 @@
+ #include "xdp-impl-dbus.h"
+ #include "xdp-utils.h"
+ 
+-#define PERMISSION_ITEM(item_key, item_value) \
+-  ((struct spa_dict_item) { \
+-    .key = item_key, \
+-    .value = item_value \
++#define PERMISSION_ITEM(item_id, item_permissions) \
++  ((struct pw_permission) { \
++    .id = item_id, \
++    .permissions = item_permissions \
+   })
+ 
+ typedef struct _ScreenCast ScreenCast;
+@@ -517,42 +517,9 @@ screen_cast_stream_get_pipewire_node_id (ScreenCastStream *stream)
+   return stream->id;
+ }
+ 
+-static void
+-append_parent_permissions (PipeWireRemote *remote,
+-                           GArray *permission_items,
+-                           GList **string_stash,
+-                           PipeWireGlobal *global,
+-                           const char *permission)
+-{
+-  PipeWireGlobal *parent;
+-  char *parent_permission_value;
+-
+-  if (global->parent_id == 0)
+-    return;
+-
+-  parent = g_hash_table_lookup (remote->globals, GINT_TO_POINTER (global->parent_id));
+-
+-  if (parent->permission_set)
+-    return;
+-  parent->permission_set = TRUE;
+-
+-  append_parent_permissions (remote, permission_items, string_stash,
+-                             parent, permission);
+-
+-  parent_permission_value = g_strdup_printf ("%u:%s",
+-                                             global->parent_id,
+-                                             permission);
+-  *string_stash = g_list_prepend (*string_stash, parent_permission_value);
+-
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       parent_permission_value));
+-}
+-
+ static void
+ append_stream_permissions (PipeWireRemote *remote,
+                            GArray *permission_items,
+-                           GList **string_stash,
+                            GList *streams)
+ {
+   GList *l;
+@@ -561,21 +528,10 @@ append_stream_permissions (PipeWireRemote *remote,
+     {
+       ScreenCastStream *stream = l->data;
+       uint32_t stream_id;
+-      PipeWireGlobal *stream_global;
+-      char *stream_permission_value;
+ 
+       stream_id = screen_cast_stream_get_pipewire_node_id (stream);
+-      stream_global = g_hash_table_lookup (remote->globals,
+-                                           GINT_TO_POINTER (stream_id));
+-
+-      append_parent_permissions (remote, permission_items, string_stash,
+-                                 stream_global, "r--");
+-
+-      stream_permission_value = g_strdup_printf ("%u:rwx", stream_id);
+-      *string_stash = g_list_prepend (*string_stash, stream_permission_value);
+       g_array_append_val (permission_items,
+-                          PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                           stream_permission_value));
++                          PERMISSION_ITEM (stream_id, PW_PERM_RWX));
+     }
+ }
+ 
+@@ -587,9 +543,6 @@ open_pipewire_screen_cast_remote (const char *app_id,
+   struct pw_properties *pipewire_properties;
+   PipeWireRemote *remote;
+   g_autoptr(GArray) permission_items = NULL;
+-  char *node_factory_permission_string;
+-  GList *string_stash = NULL;
+-  struct spa_dict *permission_dict;
+   PipeWireGlobal *node_global;
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.app_id", app_id,
+@@ -603,48 +556,31 @@ open_pipewire_screen_cast_remote (const char *app_id,
+ 
+   permission_items = g_array_new (FALSE, TRUE, sizeof (struct spa_dict_item));
+ 
+-  /*
+-   * Hide all existing and future nodes (except the ones we explicitly list below.
+-   */
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_EXISTING,
+-                                       "---"));
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_DEFAULT,
+-                                       "---"));
+-
+   /*
+    * PipeWire:Interface:Core
+    * Needs rwx to be able create the sink node using the create-object method
+    */
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       "0:rwx"));
++                      PERMISSION_ITEM (PW_ID_CORE, PW_PERM_RWX));
+ 
+   /*
+    * PipeWire:Interface:NodeFactory
+    * Needs r-- so it can be passed to create-object when creating the sink node.
+    */
+-  node_factory_permission_string = g_strdup_printf ("%d:r--",
+-                                                    remote->node_factory_id);
+-  string_stash = g_list_prepend (string_stash, node_factory_permission_string);
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       node_factory_permission_string));
+-  node_global = g_hash_table_lookup (remote->globals,
+-                                     GINT_TO_POINTER (remote->node_factory_id));
+-  append_parent_permissions (remote, permission_items, &string_stash,
+-                             node_global, "r--");
++                      PERMISSION_ITEM (remote->node_factory_id, PW_PERM_R));
+ 
+-  append_stream_permissions (remote, permission_items, &string_stash, streams);
++  append_stream_permissions (remote, permission_items, streams);
+ 
+-  permission_dict =
+-    &SPA_DICT_INIT ((struct spa_dict_item *) permission_items->data,
+-                    permission_items->len);
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             permission_dict);
++  /*
++   * Hide all existing and future nodes (except the ones we explicitly list above).
++   */
++  g_array_append_val (permission_items,
++                      PERMISSION_ITEM (PW_ID_ANY, 0));
+ 
+-  g_list_free_full (string_stash, g_free);
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                permission_items->len,
++                                (const struct pw_permission *)permission_items->data);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -943,7 +879,7 @@ handle_open_pipewire_remote (XdpScreenCast *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
diff --git a/srcpkgs/xdg-desktop-portal/template b/srcpkgs/xdg-desktop-portal/template
index eb8a4602f5d..1136b6a6e0e 100644
--- a/srcpkgs/xdg-desktop-portal/template
+++ b/srcpkgs/xdg-desktop-portal/template
@@ -1,10 +1,10 @@
 # Template file for 'xdg-desktop-portal'
 pkgname=xdg-desktop-portal
 version=1.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-pipewire --enable-geoclue --disable-libportal"
-hostmakedepends="pkg-config glib-devel"
+hostmakedepends="automake libtool gettext-devel pkg-config glib-devel"
 makedepends="flatpak-devel fuse-devel pipewire-devel geoclue2-devel"
 short_desc="Portal frontend service for Flatpak"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -13,6 +13,10 @@ homepage="https://github.com/flatpak/xdg-desktop-portal"
 distfiles="https://github.com/flatpak/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.xz"
 checksum=883c9c9a925e48af54812b5347f546dd776ec2e27076a83d5a8126af6bafb9da
 
+pre_configure() {
+	autoreconf -vfi
+}
+
 post_install() {
 	rm -rf "${DESTDIR}/usr/lib/systemd"
 }

From 708fa62cf95351f1b48507b14458a7c0f8af6c1f Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Thu, 30 Apr 2020 06:17:17 +0900
Subject: [PATCH 4/4] mutter: rebuild for pipewire-0.3

---
 srcpkgs/mutter/patches/pipewire-0.3.patch | 521 ++++++++++++++++++++++
 srcpkgs/mutter/template                   |   2 +-
 2 files changed, 522 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/mutter/patches/pipewire-0.3.patch

diff --git a/srcpkgs/mutter/patches/pipewire-0.3.patch b/srcpkgs/mutter/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..ebff65fba85
--- /dev/null
+++ b/srcpkgs/mutter/patches/pipewire-0.3.patch
@@ -0,0 +1,521 @@
+Build mutter against pipewire-0.3, based on a patch at:
+https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1062
+--- meson.build
++++ meson.build
+@@ -50,7 +50,7 @@ libinput_req = '>= 1.7'
+ gbm_req = '>= 10.3'
+
+ # screen cast version requirements
+-libpipewire_req = '>= 0.2.5'
++libpipewire_req = '>= 0.3.0'
+
+ gnome = import('gnome')
+ pkg = import('pkgconfig')
+@@ -241,7 +241,7 @@ endif
+
+ have_remote_desktop = get_option('remote_desktop')
+ if have_remote_desktop
+-  libpipewire_dep = dependency('libpipewire-0.2', version: libpipewire_req)
++  libpipewire_dep = dependency('libpipewire-0.3', version: libpipewire_req)
+ endif
+
+ have_introspection = get_option('introspection')
+diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
+index 82c5cba436..ba1ce94a7e 100644
+--- src/backends/meta-screen-cast-stream-src.c
++++ src/backends/meta-screen-cast-stream-src.c
+@@ -29,6 +29,7 @@
+ #include <spa/param/props.h>
+ #include <spa/param/format-utils.h>
+ #include <spa/param/video/format-utils.h>
++#include <spa/utils/result.h>
+ #include <stdint.h>
+ #include <sys/mman.h>
+
+@@ -62,15 +63,6 @@ enum
+
+ static guint signals[N_SIGNALS];
+
+-typedef struct _MetaSpaType
+-{
+-  struct spa_type_media_type media_type;
+-  struct spa_type_media_subtype media_subtype;
+-  struct spa_type_format_video format_video;
+-  struct spa_type_video_format video_format;
+-  uint32_t meta_cursor;
+-} MetaSpaType;
+-
+ typedef struct _MetaPipeWireSource
+ {
+   GSource base;
+@@ -82,19 +74,19 @@ typedef struct _MetaScreenCastStreamSrcPrivate
+ {
+   MetaScreenCastStream *stream;
+
++  struct pw_context *pipewire_context;
+   struct pw_core *pipewire_core;
+-  struct pw_remote *pipewire_remote;
+-  struct pw_type *pipewire_type;
+   MetaPipeWireSource *pipewire_source;
+-  struct spa_hook pipewire_remote_listener;
++  struct spa_hook pipewire_core_listener;
+
+   gboolean is_enabled;
+
+   struct pw_stream *pipewire_stream;
+   struct spa_hook pipewire_stream_listener;
++  uint32_t node_id;
+
+-  MetaSpaType spa_type;
+   struct spa_video_info_raw video_format;
++  int video_stride;
+
+   uint64_t last_frame_timestamp_us;
+
+@@ -112,8 +104,6 @@ G_DEFINE_TYPE_WITH_CODE (MetaScreenCastStreamSrc,
+                                                 meta_screen_cast_stream_src_init_initable_iface)
+                          G_ADD_PRIVATE (MetaScreenCastStreamSrc))
+
+-#define PROP_RANGE(min, max) 2, (min), (max)
+-
+ static void
+ meta_screen_cast_stream_src_get_specs (MetaScreenCastStreamSrc *src,
+                                        int                     *width,
+@@ -286,9 +276,6 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+                                                               int                      x,
+                                                               int                      y)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+
+   spa_meta_cursor->id = 1;
+@@ -300,7 +287,7 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   spa_meta_cursor->hotspot.x = 0;
+@@ -317,9 +304,6 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+                                                         int                      y,
+                                                         float                    scale)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   CoglTexture *cursor_texture;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+   int hotspot_x, hotspot_y;
+@@ -346,7 +330,7 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
+@@ -382,12 +366,10 @@ static void
+ add_cursor_metadata (MetaScreenCastStreamSrc *src,
+                      struct spa_buffer       *spa_buffer)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_cursor *spa_meta_cursor;
+
+-  spa_meta_cursor = spa_buffer_find_meta (spa_buffer, spa_type->meta_cursor);
++  spa_meta_cursor = spa_buffer_find_meta_data (spa_buffer, SPA_META_Cursor,
++                                               sizeof (*spa_meta_cursor));
+   if (spa_meta_cursor)
+     meta_screen_cast_stream_src_set_cursor_metadata (src, spa_meta_cursor);
+ }
+@@ -447,14 +429,14 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+     {
+       data = spa_buffer->datas[0].data;
+     }
+-  else if (spa_buffer->datas[0].type == priv->pipewire_type->data.MemFd)
++  else if (spa_buffer->datas[0].type == SPA_DATA_MemFd)
+     {
+       map = mmap (NULL, spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset,
+                   PROT_READ | PROT_WRITE, MAP_SHARED,
+                   spa_buffer->datas[0].fd, 0);
+       if (map == MAP_FAILED)
+         {
+-          g_warning ("Failed to mmap pipewire stream buffer: %s\n",
++          g_warning ("Failed to mmap pipewire stream buffer: %s",
+                      strerror (errno));
+           return;
+         }
+@@ -469,28 +451,30 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+
+   if (meta_screen_cast_stream_src_record_frame (src, data))
+     {
+-      struct spa_meta_video_crop *spa_meta_video_crop;
++      struct spa_meta_region *spa_meta_video_crop;
+
+       spa_buffer->datas[0].chunk->size = spa_buffer->datas[0].maxsize;
++      spa_buffer->datas[0].chunk->stride = priv->video_stride;
+
+       /* Update VideoCrop if needed */
+       spa_meta_video_crop =
+-        spa_buffer_find_meta (spa_buffer, priv->pipewire_type->meta.VideoCrop);
++        spa_buffer_find_meta_data (spa_buffer, SPA_META_VideoCrop,
++                                   sizeof (*spa_meta_video_crop));
+       if (spa_meta_video_crop)
+         {
+           if (meta_screen_cast_stream_src_get_videocrop (src, &crop_rect))
+             {
+-              spa_meta_video_crop->x = crop_rect.x;
+-              spa_meta_video_crop->y = crop_rect.y;
+-              spa_meta_video_crop->width = crop_rect.width;
+-              spa_meta_video_crop->height = crop_rect.height;
++              spa_meta_video_crop->region.position.x = crop_rect.x;
++              spa_meta_video_crop->region.position.y = crop_rect.y;
++              spa_meta_video_crop->region.size.width = crop_rect.width;
++              spa_meta_video_crop->region.size.height = crop_rect.height;
+             }
+           else
+             {
+-              spa_meta_video_crop->x = 0;
+-              spa_meta_video_crop->y = 0;
+-              spa_meta_video_crop->width = priv->stream_width;
+-              spa_meta_video_crop->height = priv->stream_height;
++              spa_meta_video_crop->region.position.x = 0;
++              spa_meta_video_crop->region.position.y = 0;
++              spa_meta_video_crop->region.size.width = priv->stream_width;
++              spa_meta_video_crop->region.size.height = priv->stream_height;
+             }
+         }
+     }
+@@ -555,7 +539,6 @@ on_stream_state_changed (void                 *data,
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  uint32_t node_id;
+
+   switch (state)
+     {
+@@ -563,14 +546,12 @@ on_stream_state_changed (void                 *data,
+       g_warning ("pipewire stream error: %s", error_message);
+       meta_screen_cast_stream_src_notify_closed (src);
+       break;
+-    case PW_STREAM_STATE_CONFIGURE:
+-      node_id = pw_stream_get_node_id (priv->pipewire_stream);
+-      g_signal_emit (src, signals[READY], 0, (unsigned int) node_id);
+-      break;
+-    case PW_STREAM_STATE_UNCONNECTED:
+-    case PW_STREAM_STATE_CONNECTING:
+-    case PW_STREAM_STATE_READY:
+     case PW_STREAM_STATE_PAUSED:
++      if (priv->node_id == SPA_ID_INVALID && priv->pipewire_stream)
++        {
++          priv->node_id = pw_stream_get_node_id (priv->pipewire_stream);
++          g_signal_emit (src, signals[READY], 0, (unsigned int) priv->node_id);
++        }
+       if (meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_disable (src);
+       break;
+@@ -578,68 +559,69 @@ on_stream_state_changed (void                 *data,
+       if (!meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_enable (src);
+       break;
++    case PW_STREAM_STATE_UNCONNECTED:
++    case PW_STREAM_STATE_CONNECTING:
++      break;
+     }
+ }
+
+ static void
+-on_stream_format_changed (void                 *data,
+-                          const struct spa_pod *format)
++on_stream_param_changed (void                 *data,
++                         uint32_t              id,
++                         const struct spa_pod *format)
+ {
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   uint8_t params_buffer[1024];
+   int32_t width, height, stride, size;
+   struct spa_pod_builder pod_builder;
+   const struct spa_pod *params[3];
+   const int bpp = 4;
+
+-  if (!format)
+-    {
+-      pw_stream_finish_format (priv->pipewire_stream, 0, NULL, 0);
+-      return;
+-    }
++  if (!format || id != SPA_PARAM_Format)
++    return;
+
+   spa_format_video_raw_parse (format,
+-                              &priv->video_format,
+-                              &priv->spa_type.format_video);
++                              &priv->video_format);
+
+   width = priv->video_format.size.width;
+   height = priv->video_format.size.height;
+   stride = SPA_ROUND_UP_N (width * bpp, 4);
+   size = height * stride;
+
++  priv->video_stride = stride;
++
+   pod_builder = SPA_POD_BUILDER_INIT (params_buffer, sizeof (params_buffer));
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idBuffers, pipewire_type->param_buffers.Buffers,
+-    ":", pipewire_type->param_buffers.size, "i", size,
+-    ":", pipewire_type->param_buffers.stride, "i", stride,
+-    ":", pipewire_type->param_buffers.buffers, "iru", 16, PROP_RANGE (2, 16),
+-    ":", pipewire_type->param_buffers.align, "i", 16);
+-
+-  params[1] = spa_pod_builder_object (
++    SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
++    SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int (16, 2, 16),
++    SPA_PARAM_BUFFERS_blocks, SPA_POD_Int (1),
++    SPA_PARAM_BUFFERS_size, SPA_POD_Int (size),
++    SPA_PARAM_BUFFERS_stride, SPA_POD_Int (stride),
++    SPA_PARAM_BUFFERS_align, SPA_POD_Int (16));
++
++  params[1] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", pipewire_type->meta.VideoCrop,
+-    ":", pipewire_type->param_meta.size, "i", sizeof (struct spa_meta_video_crop));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_VideoCrop),
++    SPA_PARAM_META_size, SPA_POD_Int (sizeof (struct spa_meta_region)));
+
+-  params[2] = spa_pod_builder_object (
++  params[2] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", priv->spa_type.meta_cursor,
+-    ":", pipewire_type->param_meta.size, "i", CURSOR_META_SIZE (64, 64));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_Cursor),
++    SPA_PARAM_META_size, SPA_POD_Int (CURSOR_META_SIZE (64, 64)));
+
+-  pw_stream_finish_format (priv->pipewire_stream, 0,
+-                           params, G_N_ELEMENTS (params));
++  pw_stream_update_params (priv->pipewire_stream, params, G_N_ELEMENTS (params));
+ }
+
+ static const struct pw_stream_events stream_events = {
+   PW_VERSION_STREAM_EVENTS,
+   .state_changed = on_stream_state_changed,
+-  .format_changed = on_stream_format_changed,
++  .param_changed = on_stream_param_changed,
+ };
+
+ static struct pw_stream *
+@@ -652,8 +634,6 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   uint8_t buffer[1024];
+   struct spa_pod_builder pod_builder =
+     SPA_POD_BUILDER_INIT (buffer, sizeof (buffer));
+-  MetaSpaType *spa_type = &priv->spa_type;
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   float frame_rate;
+   MetaFraction frame_rate_fraction;
+   struct spa_fraction max_framerate;
+@@ -661,7 +641,9 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   const struct spa_pod *params[1];
+   int result;
+
+-  pipewire_stream = pw_stream_new (priv->pipewire_remote,
++  priv->node_id = SPA_ID_INVALID;
++
++  pipewire_stream = pw_stream_new (priv->pipewire_core,
+                                    "meta-screen-cast-src",
+                                    NULL);
+   if (!pipewire_stream)
+@@ -682,17 +664,17 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   max_framerate = SPA_FRACTION (frame_rate_fraction.num,
+                                 frame_rate_fraction.denom);
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idEnumFormat, pipewire_type->spa_format,
+-    "I", spa_type->media_type.video,
+-    "I", spa_type->media_subtype.raw,
+-    ":", spa_type->format_video.format, "I", spa_type->video_format.BGRx,
+-    ":", spa_type->format_video.size, "R", &SPA_RECTANGLE (priv->stream_width,
+-                                                           priv->stream_height),
+-    ":", spa_type->format_video.framerate, "F", &SPA_FRACTION (0, 1),
+-    ":", spa_type->format_video.max_framerate, "Fru", &max_framerate,
+-                                                      PROP_RANGE (&min_framerate,
++    SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
++    SPA_FORMAT_mediaType, SPA_POD_Id (SPA_MEDIA_TYPE_video),
++    SPA_FORMAT_mediaSubtype, SPA_POD_Id (SPA_MEDIA_SUBTYPE_raw),
++    SPA_FORMAT_VIDEO_format, SPA_POD_Id (SPA_VIDEO_FORMAT_BGRx),
++    SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle (&SPA_RECTANGLE (priv->stream_width,
++                                                              priv->stream_height)),
++    SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction (&SPA_FRACTION (0, 1)),
++    SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction (&max_framerate,
++                                                                  &min_framerate,
+                                                                   &max_framerate));
+
+   pw_stream_add_listener (pipewire_stream,
+@@ -702,7 +684,7 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+
+   result = pw_stream_connect (pipewire_stream,
+                               PW_DIRECTION_OUTPUT,
+-                              NULL,
++                              SPA_ID_INVALID,
+                               (PW_STREAM_FLAG_DRIVER |
+                                PW_STREAM_FLAG_MAP_BUFFERS),
+                               params, G_N_ELEMENTS (params));
+@@ -717,40 +699,18 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+ }
+
+ static void
+-on_state_changed (void                 *data,
+-                  enum pw_remote_state  old,
+-                  enum pw_remote_state  state,
+-                  const char           *error_message)
++on_core_error (void       *data,
++               uint32_t    id,
++	       int         seq,
++	       int         res,
++	       const char *message)
+ {
+   MetaScreenCastStreamSrc *src = data;
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_stream *pipewire_stream;
+-  GError *error = NULL;
+
+-  switch (state)
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-      g_warning ("pipewire remote error: %s\n", error_message);
+-      meta_screen_cast_stream_src_notify_closed (src);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pipewire_stream = create_pipewire_stream (src, &error);
+-      if (!pipewire_stream)
+-        {
+-          g_warning ("Could not create pipewire stream: %s", error->message);
+-          g_error_free (error);
+-          meta_screen_cast_stream_src_notify_closed (src);
+-        }
+-      else
+-        {
+-          priv->pipewire_stream = pipewire_stream;
+-        }
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    }
++  g_warning ("pipewire remote error: id:%u %s", id, message);
++
++  if (id == PW_ID_CORE && res == -EPIPE)
++    meta_screen_cast_stream_src_notify_closed (src);
+ }
+
+ static gboolean
+@@ -793,17 +753,6 @@ static GSourceFuncs pipewire_source_funcs =
+   pipewire_loop_source_finalize
+ };
+
+-static void
+-init_spa_type (MetaSpaType         *type,
+-               struct spa_type_map *map)
+-{
+-  spa_type_media_type_map (map, &type->media_type);
+-  spa_type_media_subtype_map (map, &type->media_subtype);
+-  spa_type_format_video_map (map, &type->format_video);
+-  spa_type_video_format_map (map, &type->video_format);
+-  type->meta_cursor = spa_type_map_get_id(map, SPA_TYPE_META__Cursor);
+-}
+-
+ static MetaPipeWireSource *
+ create_pipewire_source (void)
+ {
+@@ -829,9 +778,9 @@ create_pipewire_source (void)
+   return pipewire_source;
+ }
+
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = on_core_error,
+ };
+
+ static gboolean
+@@ -851,37 +800,31 @@ meta_screen_cast_stream_src_initable_init (GInitable     *initable,
+       return FALSE;
+     }
+
+-  priv->pipewire_core = pw_core_new (priv->pipewire_source->pipewire_loop,
+-                                     NULL);
+-  if (!priv->pipewire_core)
++  priv->pipewire_context = pw_context_new (priv->pipewire_source->pipewire_loop,
++                                           NULL, 0);
++  if (!priv->pipewire_context)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Failed to create pipewire core");
++                   "Failed to create pipewire context");
+       return FALSE;
+     }
+
+-  priv->pipewire_remote = pw_remote_new (priv->pipewire_core, NULL, 0);
+-  if (!priv->pipewire_remote)
++  priv->pipewire_core = pw_context_connect (priv->pipewire_context, NULL, 0);
++  if (!priv->pipewire_core)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't creat pipewire remote");
++                   "Couldn't connect pipewire context");
+       return FALSE;
+     }
+
+-  pw_remote_add_listener (priv->pipewire_remote,
+-                          &priv->pipewire_remote_listener,
+-                          &remote_events,
+-                          src);
++  pw_core_add_listener (priv->pipewire_core,
++                        &priv->pipewire_core_listener,
++                        &core_events,
++                        src);
+
+-  priv->pipewire_type = pw_core_get_type (priv->pipewire_core);
+-  init_spa_type (&priv->spa_type, priv->pipewire_type->map);
+-
+-  if (pw_remote_connect (priv->pipewire_remote) != 0)
+-    {
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect pipewire remote");
+-      return FALSE;
+-    }
++  priv->pipewire_stream = create_pipewire_stream (src, error);
++  if (!priv->pipewire_stream)
++    return FALSE;
+
+   return TRUE;
+ }
+@@ -912,8 +855,8 @@ meta_screen_cast_stream_src_finalize (GObject *object)
+     meta_screen_cast_stream_src_disable (src);
+
+   g_clear_pointer (&priv->pipewire_stream, pw_stream_destroy);
+-  g_clear_pointer (&priv->pipewire_remote, pw_remote_destroy);
+-  g_clear_pointer (&priv->pipewire_core, pw_core_destroy);
++  g_clear_pointer (&priv->pipewire_core, pw_core_disconnect);
++  g_clear_pointer (&priv->pipewire_context, pw_context_destroy);
+   g_source_destroy (&priv->pipewire_source->base);
+
+   G_OBJECT_CLASS (meta_screen_cast_stream_src_parent_class)->finalize (object);
diff --git a/srcpkgs/mutter/template b/srcpkgs/mutter/template
index 4e0bd32b67d..806a3bef9f0 100644
--- a/srcpkgs/mutter/template
+++ b/srcpkgs/mutter/template
@@ -1,7 +1,7 @@
 # Template file for 'mutter'
 pkgname=mutter
 version=3.34.1
-revision=2
+revision=3
 build_helper="gir"
 build_style=meson
 configure_args="-Degl_device=true -Dudev=true -Dnative_backend=true

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (18 preceding siblings ...)
  2020-04-29 21:18 ` [PR PATCH] [Updated] " sirn
@ 2020-04-29 21:20 ` sirn
  2020-04-29 21:21 ` [WIP] " sirn
                   ` (31 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-04-29 21:20 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 394 bytes --]

New comment by sirn on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-621470496

Comment:
A patch at https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1062 does seems to get mutter to built against pipewire 0.3. I'm not sure if I need to revbump something else. @mnabid do you mind testing if screencast under this patched mutter-3.34 works?

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [WIP] pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (19 preceding siblings ...)
  2020-04-29 21:20 ` sirn
@ 2020-04-29 21:21 ` sirn
  2020-04-30  3:29 ` mnabid
                   ` (30 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-04-29 21:21 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 427 bytes --]

New comment by sirn on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-621442760

Comment:
> ~@Duncaen since this PR is now building `xdg-desktop-portal` 1.6.0 with pipewire 0.3 patch, and it seems to build in all systems (& also confirmed working locally on x86_64-musl), is it possible to re-review? Thank you! :bow:~

Sorry for the noise. Back to WIP again because of Mutter.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [WIP] pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (20 preceding siblings ...)
  2020-04-29 21:21 ` [WIP] " sirn
@ 2020-04-30  3:29 ` mnabid
  2020-04-30  3:29 ` mnabid
                   ` (29 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: mnabid @ 2020-04-30  3:29 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 167 bytes --]

New comment by mnabid on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-621591500

Comment:
Yeah, works fine. Thanks ! 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [WIP] pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (21 preceding siblings ...)
  2020-04-30  3:29 ` mnabid
@ 2020-04-30  3:29 ` mnabid
  2020-04-30  4:10 ` mnabid
                   ` (28 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: mnabid @ 2020-04-30  3:29 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 173 bytes --]

New comment by mnabid on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-621591500

Comment:
@sirn Yeah, works fine. Thanks ! 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [WIP] pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (22 preceding siblings ...)
  2020-04-30  3:29 ` mnabid
@ 2020-04-30  4:10 ` mnabid
  2020-04-30 20:51 ` [PR PATCH] [Updated] " sirn
                   ` (27 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: mnabid @ 2020-04-30  4:10 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 246 bytes --]

New comment by mnabid on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-621591500

Comment:
@sirn Yeah, works fine. Thanks ! 

Maybe edit the PR description to match the current state of this PR. 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PR PATCH] [Updated] pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (23 preceding siblings ...)
  2020-04-30  4:10 ` mnabid
@ 2020-04-30 20:51 ` sirn
  2020-04-30 20:52 ` sirn
                   ` (26 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-04-30 20:51 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 785 bytes --]

There is an updated pull request by sirn against master on the void-packages repository

https://github.com/sirn/void-packages pipewire-update
https://github.com/void-linux/void-packages/pull/20413

pipewire: update to 0.3.2
This PR updates `pipewire` to 0.3.2 and also updating/patching all packages that depends on it. 

* `xdg-desktop-portal` includes a patch backported from 1.7.0 to allow 1.6.0 to build against pipewire-0.3 (1.7.x is prerelease)
* `xdg-desktop-portal-kde` already includes Pipewire 0.3 support and only requires revbump.
* `mutter` includes a patch backported from 3.35 to allow 3.34 to build against pipewire-0.3 (upgrading to >=3.35 also requires upgrading GNOME).

A patch file from https://github.com/void-linux/void-packages/pull/20413.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pipewire-update-20413.patch --]
[-- Type: text/x-diff, Size: 50987 bytes --]

From e61689ba95dc79ac203ac55d5d3c5dd7f2b93b62 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:23:52 +0900
Subject: [PATCH 1/4] pipewire: update to 0.3.4

---
 common/shlibs                  |  2 +-
 srcpkgs/alsa-pipewire          |  1 +
 srcpkgs/libjack-pipewire       |  1 +
 srcpkgs/libpulseaudio-pipewire |  1 +
 srcpkgs/pipewire/template      | 75 ++++++++++++++++++++++++++--------
 5 files changed, 62 insertions(+), 18 deletions(-)
 create mode 120000 srcpkgs/alsa-pipewire
 create mode 120000 srcpkgs/libjack-pipewire
 create mode 120000 srcpkgs/libpulseaudio-pipewire

diff --git a/common/shlibs b/common/shlibs
index a208407b359..0b58777db72 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3199,7 +3199,7 @@ libarcan_shmif_ext.so.0.11 arcan-0.5.4.3_1
 libarcan_shmif_server.so.0.11 arcan-0.5.4.3_1
 libarcan_tui.so.0.11 arcan-0.5.4.3_1
 liblwipv6.so.2 lwipv6-1.5a_1
-libpipewire-0.2.so.1 libpipewire-0.2.2_1
+libpipewire-0.3.so.0 libpipewire-0.3.2_1
 libvolk.so.2.2.1 volk-2.2.1_1
 libgnuradio-runtime.so.3.8.0 gnuradio-3.8.0.0_1
 libgnuradio-pmt.so.3.8.0 gnuradio-3.8.0.0_1
diff --git a/srcpkgs/alsa-pipewire b/srcpkgs/alsa-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/alsa-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libjack-pipewire b/srcpkgs/libjack-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libjack-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libpulseaudio-pipewire b/srcpkgs/libpulseaudio-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libpulseaudio-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/pipewire/template b/srcpkgs/pipewire/template
index 7f646dad11d..5f14a189e6f 100644
--- a/srcpkgs/pipewire/template
+++ b/srcpkgs/pipewire/template
@@ -1,26 +1,42 @@
 # Template file for 'pipewire'
 pkgname=pipewire
-version=0.2.7
+version=0.3.4
 revision=1
 build_style=meson
-configure_args="-Dman=true -Dgstreamer=enabled -Ddocs=true -Dsystemd=false"
+configure_args="-Dman=true -Dgstreamer=true -Ddocs=true -Dsystemd=false
+ -Dbluez5=true -Dffmpeg=true -Dpipewire-alsa=true -Dpipewire-jack=true
+ -Dpipewire-pulseaudio=true"
 hostmakedepends="doxygen graphviz pkg-config xmltoman"
 makedepends="SDL2-devel ffmpeg-devel gst-plugins-base1-devel jack-devel
- sbc-devel v4l-utils-devel libva-devel"
+ sbc-devel v4l-utils-devel libva-devel libbluetooth-devel"
 short_desc="Server and user space API to deal with multimedia pipelines"
 maintainer="Orphaned <orphan@voidlinux.org>"
-#Next release will probably change to MIT, currently listed in master
-license="LGPL-2.1-only, GPL-2.0-only "
+license="MIT"
 homepage="https://pipewire.org/"
-changelog="https://raw.githubusercontent.com/PipeWire/pipewire/master/NEWS"
-distfiles="https://github.com/PipeWire/pipewire/archive/${version}.tar.gz"
-checksum=bfaa0f6ae6c0791e2e0b59234d399753bf24f1b33dbf587682363a8463dd8df1
+changelog="https://gitlab.freedesktop.org/pipewire/pipewire/-/raw/master/NEWS"
+distfiles="https://gitlab.freedesktop.org/pipewire/pipewire/-/archive/${version}/pipewire-${version}.tar.gz"
+checksum=6a1c9c671514c84b38ce96d51823354702bc4d5dbaba12d501faa0448f892515
 conf_files="/etc/pipewire/pipewire.conf"
 
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+	LDFLAGS+=" -latomic"
+fi
+
+post_install() {
+	vlicense LICENSE
+}
+
+post_patch() {
+	# https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/233
+	vsed -i meson.build -e 's|.*-Werror=suggest-attribute=format.*||g'
+}
+
 libpipewire_package() {
 	short_desc+=" - pipewire library"
 	pkg_install() {
-		vmove "usr/lib/libpipewire-0.2.so.*"
+		vmove "usr/lib/libpipewire-0.3.so.*"
+		vmove "usr/lib/pipewire-0.3/*.so"
 	}
 }
 
@@ -28,25 +44,24 @@ pipewire-devel_package() {
 	depends="libpipewire-${version}_${revision}"
 	short_desc+=" - pipewire and libspa development files"
 	pkg_install() {
-		vmove usr/include/pipewire
-		vmove usr/include/spa
-		vmove usr/lib/pkgconfig/libpipewire-0.2.pc
-		vmove usr/lib/pkgconfig/libspa-0.1.pc
-		vmove usr/lib/libpipewire-0.2.so
+		vmove usr/include/pipewire-0.3
+		vmove usr/include/spa-0.2
+		vmove usr/lib/pkgconfig/libpipewire-0.3.pc
+		vmove usr/lib/pkgconfig/libspa-0.2.pc
 	}
 }
 
 libspa-ffmpeg_package() {
 	short_desc+=" - ffmpeg plugins"
 	pkg_install() {
-		vmove usr/lib/spa/ffmpeg
+		vmove usr/lib/spa-0.2/ffmpeg
 	}
 }
 
 libspa-bluetooth_package() {
 	short_desc+=" - bluetooth plugins"
 	pkg_install() {
-		vmove usr/lib/spa/bluez5
+		vmove usr/lib/spa-0.2/bluez5
 	}
 }
 
@@ -57,10 +72,36 @@ gstreamer1-pipewire_package() {
 	}
 }
 
+libpulseaudio-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - PulseAudio client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/pulse
+		vmove usr/bin/pw-pulse
+	}
+}
+
+alsa-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - ALSA client library"
+	pkg_install() {
+		vmove usr/lib/alsa-lib
+	}
+}
+
+libjack-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - JACK client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/jack
+		vmove usr/bin/pw-jack
+	}
+}
+
 pipewire-doc_package() {
 	archs=noarch
 	short_desc+=" - documentation"
 	pkg_install() {
 		vmove usr/share/doc
 	}
-}
+}
\ No newline at end of file

From fb045f236438ac4dc05427d09187c2e59c030de9 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:46 +0900
Subject: [PATCH 2/4] xdg-desktop-portal-kde: rebuild for pipewire-0.3

---
 srcpkgs/xdg-desktop-portal-kde/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xdg-desktop-portal-kde/template b/srcpkgs/xdg-desktop-portal-kde/template
index f26057d323a..9519abc19f6 100644
--- a/srcpkgs/xdg-desktop-portal-kde/template
+++ b/srcpkgs/xdg-desktop-portal-kde/template
@@ -1,7 +1,7 @@
 # Template file for 'xdg-desktop-portal-kde'
 pkgname=xdg-desktop-portal-kde
 version=5.18.4.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules qt5-qmake qt5-host-tools kcoreaddons gettext"
 makedepends="glib-devel kio-devel kwayland-devel libepoxy-devel pipewire-devel

From 8749796a1cd9a8a88a6bba94f6c42e5e05f61362 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:26 +0900
Subject: [PATCH 3/4] xdg-desktop-portal: rebuild for pipewire-0.3

---
 .../patches/pipewire-0.3.patch                | 551 ++++++++++++++++++
 srcpkgs/xdg-desktop-portal/template           |   8 +-
 2 files changed, 557 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch

diff --git a/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..94ebe083598
--- /dev/null
+++ b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
@@ -0,0 +1,551 @@
+From a38901e5e7f835efe7b7a06c55790c8c20bc91a2 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Tue, 14 Jan 2020 09:37:09 +0100
+Subject: [PATCH] PipeWire: update to 0.3 API
+
+---
+ configure.ac      |   2 +-
+ src/camera.c      |  24 ++++----
+ src/pipewire.c    | 141 +++++++++++++---------------------------------
+ src/pipewire.h    |  10 ++--
+ src/screen-cast.c |  98 ++++++--------------------------
+ 5 files changed, 72 insertions(+), 203 deletions(-)
+
+diff --git configure.ac configure.ac
+index 89902fa..62d7960 100644
+--- configure.ac
++++ configure.ac
+@@ -97,7 +97,7 @@ AC_ARG_ENABLE(pipewire,
+ 	      [AS_HELP_STRING([--enable-pipewire],[Enable PipeWire support. Needed for screen cast portal])],
+ 	      enable_pipewire=$enableval, enable_pipewire=yes)
+ if test x$enable_pipewire = xyes ; then
+-	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.2 >= 0.2.6])
++	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.3 >= 0.2.90])
+ 	AC_DEFINE([HAVE_PIPEWIRE],[1], [Define to enable PipeWire support])
+ fi
+ AM_CONDITIONAL([HAVE_PIPEWIRE],[test "$enable_pipewire" = "yes"])
+diff --git src/camera.c src/camera.c
+index c2b392c..20fe3aa 100644
+--- src/camera.c
++++ src/camera.c
+@@ -141,7 +141,7 @@ open_pipewire_camera_remote (const char *app_id,
+                              GError **error)
+ {
+   PipeWireRemote *remote;
+-  struct spa_dict_item permission_items[1];
++  struct pw_permission permission_items[2];
+   struct pw_properties *pipewire_properties;
+ 
+   pipewire_properties =
+@@ -158,12 +158,12 @@ open_pipewire_camera_remote (const char *app_id,
+    * Hide all existing and future nodes by default. PipeWire will use the
+    * permission store to set up permissions.
+    */
+-  permission_items[0].key = PW_CORE_PROXY_PERMISSIONS_DEFAULT;
+-  permission_items[0].value = "---";
++  permission_items[0] = PW_PERMISSION_INIT (PW_ID_CORE, PW_PERM_RWX);
++  permission_items[1] = PW_PERMISSION_INIT (PW_ID_ANY, 0);
+ 
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             &SPA_DICT_INIT (permission_items,
+-                                             G_N_ELEMENTS (permission_items)));
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                G_N_ELEMENTS (permission_items),
++                                permission_items);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -219,7 +219,7 @@ handle_open_pipewire_remote (XdpCamera *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
+@@ -250,29 +250,28 @@ camera_iface_init (XdpCameraIface *iface)
+ static void
+ global_added_cb (PipeWireRemote *remote,
+                  uint32_t id,
+-                 uint32_t type,
++                 const char *type,
+                  const struct spa_dict *props,
+                  gpointer user_data)
+ {
+   Camera *camera = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *media_class;
+   const struct spa_dict_item *media_role;
+ 
+-  if (type != core_type->node)
++  if (strcmp(type, PW_TYPE_INTERFACE_Node) != 0)
+     return;
+ 
+   if (!props)
+     return;
+ 
+-  media_class = spa_dict_lookup_item (props, "media.class");
++  media_class = spa_dict_lookup_item (props, PW_KEY_MEDIA_CLASS);
+   if (!media_class)
+     return;
+ 
+   if (g_strcmp0 (media_class->value, "Video/Source") != 0)
+     return;
+ 
+-  media_role = spa_dict_lookup_item (props, "media.role");
++  media_role = spa_dict_lookup_item (props, PW_KEY_MEDIA_ROLE);
+   if (!media_role)
+     return;
+ 
+@@ -342,6 +341,7 @@ create_pipewire_remote (Camera *camera,
+     }
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.is_portal", "true",
++                                           "portal.monitor", "Camera",
+                                            NULL);
+   camera->pipewire_remote = pipewire_remote_new_sync (pipewire_properties,
+                                                       global_added_cb,
+diff --git src/pipewire.c src/pipewire.c
+index 793a378..162cd55 100644
+--- src/pipewire.c
++++ src/pipewire.c
+@@ -21,6 +21,7 @@
+ #include <errno.h>
+ #include <glib.h>
+ #include <pipewire/pipewire.h>
++#include <spa/utils/result.h>
+ 
+ #include "pipewire.h"
+ 
+@@ -36,27 +37,25 @@ static gboolean is_pipewire_initialized = FALSE;
+ static void
+ registry_event_global (void *user_data,
+                        uint32_t id,
+-                       uint32_t parent_id,
+                        uint32_t permissions,
+-                       uint32_t type,
++                       const char *type,
+                        uint32_t version,
+                        const struct spa_dict *props)
+ {
+   PipeWireRemote *remote = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *factory_object_type;
+   PipeWireGlobal *global;
+ 
+   global = g_new0 (PipeWireGlobal, 1);
+   *global = (PipeWireGlobal) {
+-    .parent_id = parent_id,
++    .parent_id = id,
+   };
+ 
+   g_hash_table_insert (remote->globals, GINT_TO_POINTER (id), global);
+   if (remote->global_added_cb)
+     remote->global_added_cb (remote, id, type, props, remote->user_data);
+ 
+-  if (type != core_type->factory)
++  if (strcmp(type, PW_TYPE_INTERFACE_Factory) != 0)
+     return;
+ 
+   factory_object_type = spa_dict_lookup_item (props, "factory.type.name");
+@@ -81,8 +80,8 @@ registry_event_global_remove (void *user_data,
+   g_hash_table_remove (remote->globals, GINT_TO_POINTER (id));
+ }
+ 
+-static const struct pw_registry_proxy_events registry_events = {
+-  PW_VERSION_REGISTRY_PROXY_EVENTS,
++static const struct pw_registry_events registry_events = {
++  PW_VERSION_REGISTRY_EVENTS,
+   .global = registry_event_global,
+   .global_remove = registry_event_global_remove,
+ };
+@@ -90,7 +89,7 @@ static const struct pw_registry_proxy_events registry_events = {
+ void
+ pipewire_remote_roundtrip (PipeWireRemote *remote)
+ {
+-  pw_core_proxy_sync (remote->core_proxy, ++remote->sync_seq);
++  remote->sync_seq = pw_core_sync (remote->core, PW_ID_CORE, remote->sync_seq);
+   pw_main_loop_run (remote->loop);
+ }
+ 
+@@ -98,16 +97,13 @@ static gboolean
+ discover_node_factory_sync (PipeWireRemote *remote,
+                             GError **error)
+ {
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+-  struct pw_registry_proxy *registry_proxy;
++  struct pw_registry *registry;
+ 
+-  registry_proxy = pw_core_proxy_get_registry (remote->core_proxy,
+-                                               core_type->registry,
+-                                               PW_VERSION_REGISTRY, 0);
+-  pw_registry_proxy_add_listener (registry_proxy,
+-                                  &remote->registry_listener,
+-                                  &registry_events,
+-                                  remote);
++  registry = pw_core_get_registry (remote->core, PW_VERSION_REGISTRY, 0);
++  pw_registry_add_listener (registry,
++                            &remote->registry_listener,
++                            &registry_events,
++                            remote);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -122,59 +118,35 @@ discover_node_factory_sync (PipeWireRemote *remote,
+ }
+ 
+ static void
+-on_state_changed (void *user_data,
+-                  enum pw_remote_state old,
+-                  enum pw_remote_state state,
+-                  const char *error)
++core_event_error (void       *user_data,
++                  uint32_t    id,
++		  int         seq,
++		  int         res,
++		  const char *message)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  switch (state)
++  if (id == PW_ID_CORE)
+     {
+-    case PW_REMOTE_STATE_ERROR:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "%s", error);
+-        }
++      g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
++                 "%s", message);
+       pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "Disconnected");
+-        }
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    default:
+-      g_warning ("Unknown PipeWire state");
+-      break;
+     }
+ }
+ 
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
+-};
+-
+ static void
+ core_event_done (void *user_data,
+-                 uint32_t seq)
++                 uint32_t id, int seq)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  if (remote->sync_seq == seq)
++  if (id == PW_ID_CORE && remote->sync_seq == seq)
+     pw_main_loop_quit (remote->loop);
+ }
+ 
+-static const struct pw_core_proxy_events core_events = {
+-  PW_VERSION_CORE_PROXY_EVENTS,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = core_event_error,
+   .done = core_event_done,
+ };
+ 
+@@ -237,8 +209,8 @@ void
+ pipewire_remote_destroy (PipeWireRemote *remote)
+ {
+   g_clear_pointer (&remote->globals, g_hash_table_destroy);
+-  g_clear_pointer (&remote->remote, pw_remote_destroy);
+-  g_clear_pointer (&remote->core, pw_core_destroy);
++  g_clear_pointer (&remote->core, pw_core_disconnect);
++  g_clear_pointer (&remote->context, pw_context_destroy);
+   g_clear_pointer (&remote->loop, pw_main_loop_destroy);
+   g_clear_error (&remote->error);
+ 
+@@ -307,68 +279,31 @@ pipewire_remote_new_sync (struct pw_properties *pipewire_properties,
+       return NULL;
+     }
+ 
+-  remote->core = pw_core_new (pw_main_loop_get_loop (remote->loop), NULL);
+-  if (!remote->core)
++  remote->context = pw_context_new (pw_main_loop_get_loop (remote->loop), NULL, 0);
++  if (!remote->context)
+     {
+       pipewire_remote_destroy (remote);
+       pw_properties_free (pipewire_properties);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire core");
++                   "Couldn't create PipeWire context");
+       return NULL;
+     }
+ 
+-  remote->remote = pw_remote_new (remote->core, pipewire_properties, 0);
+-  if (!remote->remote)
++  remote->core = pw_context_connect (remote->context, pipewire_properties, 0);
++  if (!remote->core)
+     {
+       pipewire_remote_destroy (remote);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire remote");
++                   "Couldn't connect to PipeWire");
+       return NULL;
+     }
+ 
+   remote->globals = g_hash_table_new_full (NULL, NULL, NULL, g_free);
+ 
+-  pw_remote_add_listener (remote->remote,
+-                          &remote->remote_listener,
+-                          &remote_events,
+-                          remote);
+-
+-  if (pw_remote_connect (remote->remote) != 0)
+-    {
+-      pipewire_remote_destroy (remote);
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect PipeWire remote");
+-      return NULL;
+-    }
+-
+-  pw_main_loop_run (remote->loop);
+-
+-  switch (pw_remote_get_state (remote->remote, NULL))
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      *error = g_steal_pointer (&remote->error);
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "PipeWire loop stopped unexpectedly");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      break;
+-    default:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Unexpected PipeWire state");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    }
+-
+-  remote->core_proxy = pw_remote_get_core_proxy (remote->remote);
+-  pw_core_proxy_add_listener (remote->core_proxy,
+-                              &remote->core_listener,
+-                              &core_events,
+-                              remote);
++  pw_core_add_listener (remote->core,
++                        &remote->core_listener,
++                        &core_events,
++                        remote);
+ 
+   if (!discover_node_factory_sync (remote, error))
+     {
+diff --git src/pipewire.h src/pipewire.h
+index 0f1bf54..bf48d5e 100644
+--- src/pipewire.h
++++ src/pipewire.h
+@@ -32,7 +32,7 @@ typedef struct _PipeWireGlobal
+ 
+ typedef void (* PipeWireGlobalAddedCallback) (PipeWireRemote *remote,
+                                               uint32_t id,
+-                                              uint32_t type,
++                                              const char *type,
+                                               const struct spa_dict *props,
+                                               gpointer user_data);
+ 
+@@ -43,13 +43,11 @@ typedef void (* PipeWireGlobalRemovedCallback) (PipeWireRemote *remote,
+ struct _PipeWireRemote
+ {
+   struct pw_main_loop *loop;
++  struct pw_context *context;
+   struct pw_core *core;
+-  struct pw_remote *remote;
+-  struct spa_hook remote_listener;
+-
+-  struct pw_core_proxy *core_proxy;
+   struct spa_hook core_listener;
+-  uint32_t sync_seq;
++
++  int sync_seq;
+ 
+   struct spa_hook registry_listener;
+ 
+diff --git src/screen-cast.c src/screen-cast.c
+index 7881ddc..1677050 100644
+--- src/screen-cast.c
++++ src/screen-cast.c
+@@ -31,10 +31,10 @@
+ #include "xdp-impl-dbus.h"
+ #include "xdp-utils.h"
+ 
+-#define PERMISSION_ITEM(item_key, item_value) \
+-  ((struct spa_dict_item) { \
+-    .key = item_key, \
+-    .value = item_value \
++#define PERMISSION_ITEM(item_id, item_permissions) \
++  ((struct pw_permission) { \
++    .id = item_id, \
++    .permissions = item_permissions \
+   })
+ 
+ typedef struct _ScreenCast ScreenCast;
+@@ -517,42 +517,9 @@ screen_cast_stream_get_pipewire_node_id (ScreenCastStream *stream)
+   return stream->id;
+ }
+ 
+-static void
+-append_parent_permissions (PipeWireRemote *remote,
+-                           GArray *permission_items,
+-                           GList **string_stash,
+-                           PipeWireGlobal *global,
+-                           const char *permission)
+-{
+-  PipeWireGlobal *parent;
+-  char *parent_permission_value;
+-
+-  if (global->parent_id == 0)
+-    return;
+-
+-  parent = g_hash_table_lookup (remote->globals, GINT_TO_POINTER (global->parent_id));
+-
+-  if (parent->permission_set)
+-    return;
+-  parent->permission_set = TRUE;
+-
+-  append_parent_permissions (remote, permission_items, string_stash,
+-                             parent, permission);
+-
+-  parent_permission_value = g_strdup_printf ("%u:%s",
+-                                             global->parent_id,
+-                                             permission);
+-  *string_stash = g_list_prepend (*string_stash, parent_permission_value);
+-
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       parent_permission_value));
+-}
+-
+ static void
+ append_stream_permissions (PipeWireRemote *remote,
+                            GArray *permission_items,
+-                           GList **string_stash,
+                            GList *streams)
+ {
+   GList *l;
+@@ -561,21 +528,10 @@ append_stream_permissions (PipeWireRemote *remote,
+     {
+       ScreenCastStream *stream = l->data;
+       uint32_t stream_id;
+-      PipeWireGlobal *stream_global;
+-      char *stream_permission_value;
+ 
+       stream_id = screen_cast_stream_get_pipewire_node_id (stream);
+-      stream_global = g_hash_table_lookup (remote->globals,
+-                                           GINT_TO_POINTER (stream_id));
+-
+-      append_parent_permissions (remote, permission_items, string_stash,
+-                                 stream_global, "r--");
+-
+-      stream_permission_value = g_strdup_printf ("%u:rwx", stream_id);
+-      *string_stash = g_list_prepend (*string_stash, stream_permission_value);
+       g_array_append_val (permission_items,
+-                          PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                           stream_permission_value));
++                          PERMISSION_ITEM (stream_id, PW_PERM_RWX));
+     }
+ }
+ 
+@@ -587,9 +543,6 @@ open_pipewire_screen_cast_remote (const char *app_id,
+   struct pw_properties *pipewire_properties;
+   PipeWireRemote *remote;
+   g_autoptr(GArray) permission_items = NULL;
+-  char *node_factory_permission_string;
+-  GList *string_stash = NULL;
+-  struct spa_dict *permission_dict;
+   PipeWireGlobal *node_global;
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.app_id", app_id,
+@@ -603,48 +556,31 @@ open_pipewire_screen_cast_remote (const char *app_id,
+ 
+   permission_items = g_array_new (FALSE, TRUE, sizeof (struct spa_dict_item));
+ 
+-  /*
+-   * Hide all existing and future nodes (except the ones we explicitly list below.
+-   */
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_EXISTING,
+-                                       "---"));
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_DEFAULT,
+-                                       "---"));
+-
+   /*
+    * PipeWire:Interface:Core
+    * Needs rwx to be able create the sink node using the create-object method
+    */
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       "0:rwx"));
++                      PERMISSION_ITEM (PW_ID_CORE, PW_PERM_RWX));
+ 
+   /*
+    * PipeWire:Interface:NodeFactory
+    * Needs r-- so it can be passed to create-object when creating the sink node.
+    */
+-  node_factory_permission_string = g_strdup_printf ("%d:r--",
+-                                                    remote->node_factory_id);
+-  string_stash = g_list_prepend (string_stash, node_factory_permission_string);
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       node_factory_permission_string));
+-  node_global = g_hash_table_lookup (remote->globals,
+-                                     GINT_TO_POINTER (remote->node_factory_id));
+-  append_parent_permissions (remote, permission_items, &string_stash,
+-                             node_global, "r--");
++                      PERMISSION_ITEM (remote->node_factory_id, PW_PERM_R));
+ 
+-  append_stream_permissions (remote, permission_items, &string_stash, streams);
++  append_stream_permissions (remote, permission_items, streams);
+ 
+-  permission_dict =
+-    &SPA_DICT_INIT ((struct spa_dict_item *) permission_items->data,
+-                    permission_items->len);
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             permission_dict);
++  /*
++   * Hide all existing and future nodes (except the ones we explicitly list above).
++   */
++  g_array_append_val (permission_items,
++                      PERMISSION_ITEM (PW_ID_ANY, 0));
+ 
+-  g_list_free_full (string_stash, g_free);
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                permission_items->len,
++                                (const struct pw_permission *)permission_items->data);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -943,7 +879,7 @@ handle_open_pipewire_remote (XdpScreenCast *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
diff --git a/srcpkgs/xdg-desktop-portal/template b/srcpkgs/xdg-desktop-portal/template
index eb8a4602f5d..1136b6a6e0e 100644
--- a/srcpkgs/xdg-desktop-portal/template
+++ b/srcpkgs/xdg-desktop-portal/template
@@ -1,10 +1,10 @@
 # Template file for 'xdg-desktop-portal'
 pkgname=xdg-desktop-portal
 version=1.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-pipewire --enable-geoclue --disable-libportal"
-hostmakedepends="pkg-config glib-devel"
+hostmakedepends="automake libtool gettext-devel pkg-config glib-devel"
 makedepends="flatpak-devel fuse-devel pipewire-devel geoclue2-devel"
 short_desc="Portal frontend service for Flatpak"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -13,6 +13,10 @@ homepage="https://github.com/flatpak/xdg-desktop-portal"
 distfiles="https://github.com/flatpak/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.xz"
 checksum=883c9c9a925e48af54812b5347f546dd776ec2e27076a83d5a8126af6bafb9da
 
+pre_configure() {
+	autoreconf -vfi
+}
+
 post_install() {
 	rm -rf "${DESTDIR}/usr/lib/systemd"
 }

From e7495d196ca454d35bd552f3f7c1771e983a41d2 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Thu, 30 Apr 2020 06:17:17 +0900
Subject: [PATCH 4/4] mutter: rebuild for pipewire-0.3

---
 srcpkgs/mutter/patches/pipewire-0.3.patch | 521 ++++++++++++++++++++++
 srcpkgs/mutter/template                   |   2 +-
 2 files changed, 522 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/mutter/patches/pipewire-0.3.patch

diff --git a/srcpkgs/mutter/patches/pipewire-0.3.patch b/srcpkgs/mutter/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..ebff65fba85
--- /dev/null
+++ b/srcpkgs/mutter/patches/pipewire-0.3.patch
@@ -0,0 +1,521 @@
+Build mutter against pipewire-0.3, based on a patch at:
+https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1062
+--- meson.build
++++ meson.build
+@@ -50,7 +50,7 @@ libinput_req = '>= 1.7'
+ gbm_req = '>= 10.3'
+
+ # screen cast version requirements
+-libpipewire_req = '>= 0.2.5'
++libpipewire_req = '>= 0.3.0'
+
+ gnome = import('gnome')
+ pkg = import('pkgconfig')
+@@ -241,7 +241,7 @@ endif
+
+ have_remote_desktop = get_option('remote_desktop')
+ if have_remote_desktop
+-  libpipewire_dep = dependency('libpipewire-0.2', version: libpipewire_req)
++  libpipewire_dep = dependency('libpipewire-0.3', version: libpipewire_req)
+ endif
+
+ have_introspection = get_option('introspection')
+diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
+index 82c5cba436..ba1ce94a7e 100644
+--- src/backends/meta-screen-cast-stream-src.c
++++ src/backends/meta-screen-cast-stream-src.c
+@@ -29,6 +29,7 @@
+ #include <spa/param/props.h>
+ #include <spa/param/format-utils.h>
+ #include <spa/param/video/format-utils.h>
++#include <spa/utils/result.h>
+ #include <stdint.h>
+ #include <sys/mman.h>
+
+@@ -62,15 +63,6 @@ enum
+
+ static guint signals[N_SIGNALS];
+
+-typedef struct _MetaSpaType
+-{
+-  struct spa_type_media_type media_type;
+-  struct spa_type_media_subtype media_subtype;
+-  struct spa_type_format_video format_video;
+-  struct spa_type_video_format video_format;
+-  uint32_t meta_cursor;
+-} MetaSpaType;
+-
+ typedef struct _MetaPipeWireSource
+ {
+   GSource base;
+@@ -82,19 +74,19 @@ typedef struct _MetaScreenCastStreamSrcPrivate
+ {
+   MetaScreenCastStream *stream;
+
++  struct pw_context *pipewire_context;
+   struct pw_core *pipewire_core;
+-  struct pw_remote *pipewire_remote;
+-  struct pw_type *pipewire_type;
+   MetaPipeWireSource *pipewire_source;
+-  struct spa_hook pipewire_remote_listener;
++  struct spa_hook pipewire_core_listener;
+
+   gboolean is_enabled;
+
+   struct pw_stream *pipewire_stream;
+   struct spa_hook pipewire_stream_listener;
++  uint32_t node_id;
+
+-  MetaSpaType spa_type;
+   struct spa_video_info_raw video_format;
++  int video_stride;
+
+   uint64_t last_frame_timestamp_us;
+
+@@ -112,8 +104,6 @@ G_DEFINE_TYPE_WITH_CODE (MetaScreenCastStreamSrc,
+                                                 meta_screen_cast_stream_src_init_initable_iface)
+                          G_ADD_PRIVATE (MetaScreenCastStreamSrc))
+
+-#define PROP_RANGE(min, max) 2, (min), (max)
+-
+ static void
+ meta_screen_cast_stream_src_get_specs (MetaScreenCastStreamSrc *src,
+                                        int                     *width,
+@@ -286,9 +276,6 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+                                                               int                      x,
+                                                               int                      y)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+
+   spa_meta_cursor->id = 1;
+@@ -300,7 +287,7 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   spa_meta_cursor->hotspot.x = 0;
+@@ -317,9 +304,6 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+                                                         int                      y,
+                                                         float                    scale)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   CoglTexture *cursor_texture;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+   int hotspot_x, hotspot_y;
+@@ -346,7 +330,7 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
+@@ -382,12 +366,10 @@ static void
+ add_cursor_metadata (MetaScreenCastStreamSrc *src,
+                      struct spa_buffer       *spa_buffer)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_cursor *spa_meta_cursor;
+
+-  spa_meta_cursor = spa_buffer_find_meta (spa_buffer, spa_type->meta_cursor);
++  spa_meta_cursor = spa_buffer_find_meta_data (spa_buffer, SPA_META_Cursor,
++                                               sizeof (*spa_meta_cursor));
+   if (spa_meta_cursor)
+     meta_screen_cast_stream_src_set_cursor_metadata (src, spa_meta_cursor);
+ }
+@@ -447,14 +429,14 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+     {
+       data = spa_buffer->datas[0].data;
+     }
+-  else if (spa_buffer->datas[0].type == priv->pipewire_type->data.MemFd)
++  else if (spa_buffer->datas[0].type == SPA_DATA_MemFd)
+     {
+       map = mmap (NULL, spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset,
+                   PROT_READ | PROT_WRITE, MAP_SHARED,
+                   spa_buffer->datas[0].fd, 0);
+       if (map == MAP_FAILED)
+         {
+-          g_warning ("Failed to mmap pipewire stream buffer: %s\n",
++          g_warning ("Failed to mmap pipewire stream buffer: %s",
+                      strerror (errno));
+           return;
+         }
+@@ -469,28 +451,30 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+
+   if (meta_screen_cast_stream_src_record_frame (src, data))
+     {
+-      struct spa_meta_video_crop *spa_meta_video_crop;
++      struct spa_meta_region *spa_meta_video_crop;
+
+       spa_buffer->datas[0].chunk->size = spa_buffer->datas[0].maxsize;
++      spa_buffer->datas[0].chunk->stride = priv->video_stride;
+
+       /* Update VideoCrop if needed */
+       spa_meta_video_crop =
+-        spa_buffer_find_meta (spa_buffer, priv->pipewire_type->meta.VideoCrop);
++        spa_buffer_find_meta_data (spa_buffer, SPA_META_VideoCrop,
++                                   sizeof (*spa_meta_video_crop));
+       if (spa_meta_video_crop)
+         {
+           if (meta_screen_cast_stream_src_get_videocrop (src, &crop_rect))
+             {
+-              spa_meta_video_crop->x = crop_rect.x;
+-              spa_meta_video_crop->y = crop_rect.y;
+-              spa_meta_video_crop->width = crop_rect.width;
+-              spa_meta_video_crop->height = crop_rect.height;
++              spa_meta_video_crop->region.position.x = crop_rect.x;
++              spa_meta_video_crop->region.position.y = crop_rect.y;
++              spa_meta_video_crop->region.size.width = crop_rect.width;
++              spa_meta_video_crop->region.size.height = crop_rect.height;
+             }
+           else
+             {
+-              spa_meta_video_crop->x = 0;
+-              spa_meta_video_crop->y = 0;
+-              spa_meta_video_crop->width = priv->stream_width;
+-              spa_meta_video_crop->height = priv->stream_height;
++              spa_meta_video_crop->region.position.x = 0;
++              spa_meta_video_crop->region.position.y = 0;
++              spa_meta_video_crop->region.size.width = priv->stream_width;
++              spa_meta_video_crop->region.size.height = priv->stream_height;
+             }
+         }
+     }
+@@ -555,7 +539,6 @@ on_stream_state_changed (void                 *data,
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  uint32_t node_id;
+
+   switch (state)
+     {
+@@ -563,14 +546,12 @@ on_stream_state_changed (void                 *data,
+       g_warning ("pipewire stream error: %s", error_message);
+       meta_screen_cast_stream_src_notify_closed (src);
+       break;
+-    case PW_STREAM_STATE_CONFIGURE:
+-      node_id = pw_stream_get_node_id (priv->pipewire_stream);
+-      g_signal_emit (src, signals[READY], 0, (unsigned int) node_id);
+-      break;
+-    case PW_STREAM_STATE_UNCONNECTED:
+-    case PW_STREAM_STATE_CONNECTING:
+-    case PW_STREAM_STATE_READY:
+     case PW_STREAM_STATE_PAUSED:
++      if (priv->node_id == SPA_ID_INVALID && priv->pipewire_stream)
++        {
++          priv->node_id = pw_stream_get_node_id (priv->pipewire_stream);
++          g_signal_emit (src, signals[READY], 0, (unsigned int) priv->node_id);
++        }
+       if (meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_disable (src);
+       break;
+@@ -578,68 +559,69 @@ on_stream_state_changed (void                 *data,
+       if (!meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_enable (src);
+       break;
++    case PW_STREAM_STATE_UNCONNECTED:
++    case PW_STREAM_STATE_CONNECTING:
++      break;
+     }
+ }
+
+ static void
+-on_stream_format_changed (void                 *data,
+-                          const struct spa_pod *format)
++on_stream_param_changed (void                 *data,
++                         uint32_t              id,
++                         const struct spa_pod *format)
+ {
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   uint8_t params_buffer[1024];
+   int32_t width, height, stride, size;
+   struct spa_pod_builder pod_builder;
+   const struct spa_pod *params[3];
+   const int bpp = 4;
+
+-  if (!format)
+-    {
+-      pw_stream_finish_format (priv->pipewire_stream, 0, NULL, 0);
+-      return;
+-    }
++  if (!format || id != SPA_PARAM_Format)
++    return;
+
+   spa_format_video_raw_parse (format,
+-                              &priv->video_format,
+-                              &priv->spa_type.format_video);
++                              &priv->video_format);
+
+   width = priv->video_format.size.width;
+   height = priv->video_format.size.height;
+   stride = SPA_ROUND_UP_N (width * bpp, 4);
+   size = height * stride;
+
++  priv->video_stride = stride;
++
+   pod_builder = SPA_POD_BUILDER_INIT (params_buffer, sizeof (params_buffer));
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idBuffers, pipewire_type->param_buffers.Buffers,
+-    ":", pipewire_type->param_buffers.size, "i", size,
+-    ":", pipewire_type->param_buffers.stride, "i", stride,
+-    ":", pipewire_type->param_buffers.buffers, "iru", 16, PROP_RANGE (2, 16),
+-    ":", pipewire_type->param_buffers.align, "i", 16);
+-
+-  params[1] = spa_pod_builder_object (
++    SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
++    SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int (16, 2, 16),
++    SPA_PARAM_BUFFERS_blocks, SPA_POD_Int (1),
++    SPA_PARAM_BUFFERS_size, SPA_POD_Int (size),
++    SPA_PARAM_BUFFERS_stride, SPA_POD_Int (stride),
++    SPA_PARAM_BUFFERS_align, SPA_POD_Int (16));
++
++  params[1] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", pipewire_type->meta.VideoCrop,
+-    ":", pipewire_type->param_meta.size, "i", sizeof (struct spa_meta_video_crop));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_VideoCrop),
++    SPA_PARAM_META_size, SPA_POD_Int (sizeof (struct spa_meta_region)));
+
+-  params[2] = spa_pod_builder_object (
++  params[2] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", priv->spa_type.meta_cursor,
+-    ":", pipewire_type->param_meta.size, "i", CURSOR_META_SIZE (64, 64));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_Cursor),
++    SPA_PARAM_META_size, SPA_POD_Int (CURSOR_META_SIZE (64, 64)));
+
+-  pw_stream_finish_format (priv->pipewire_stream, 0,
+-                           params, G_N_ELEMENTS (params));
++  pw_stream_update_params (priv->pipewire_stream, params, G_N_ELEMENTS (params));
+ }
+
+ static const struct pw_stream_events stream_events = {
+   PW_VERSION_STREAM_EVENTS,
+   .state_changed = on_stream_state_changed,
+-  .format_changed = on_stream_format_changed,
++  .param_changed = on_stream_param_changed,
+ };
+
+ static struct pw_stream *
+@@ -652,8 +634,6 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   uint8_t buffer[1024];
+   struct spa_pod_builder pod_builder =
+     SPA_POD_BUILDER_INIT (buffer, sizeof (buffer));
+-  MetaSpaType *spa_type = &priv->spa_type;
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   float frame_rate;
+   MetaFraction frame_rate_fraction;
+   struct spa_fraction max_framerate;
+@@ -661,7 +641,9 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   const struct spa_pod *params[1];
+   int result;
+
+-  pipewire_stream = pw_stream_new (priv->pipewire_remote,
++  priv->node_id = SPA_ID_INVALID;
++
++  pipewire_stream = pw_stream_new (priv->pipewire_core,
+                                    "meta-screen-cast-src",
+                                    NULL);
+   if (!pipewire_stream)
+@@ -682,17 +664,17 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   max_framerate = SPA_FRACTION (frame_rate_fraction.num,
+                                 frame_rate_fraction.denom);
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idEnumFormat, pipewire_type->spa_format,
+-    "I", spa_type->media_type.video,
+-    "I", spa_type->media_subtype.raw,
+-    ":", spa_type->format_video.format, "I", spa_type->video_format.BGRx,
+-    ":", spa_type->format_video.size, "R", &SPA_RECTANGLE (priv->stream_width,
+-                                                           priv->stream_height),
+-    ":", spa_type->format_video.framerate, "F", &SPA_FRACTION (0, 1),
+-    ":", spa_type->format_video.max_framerate, "Fru", &max_framerate,
+-                                                      PROP_RANGE (&min_framerate,
++    SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
++    SPA_FORMAT_mediaType, SPA_POD_Id (SPA_MEDIA_TYPE_video),
++    SPA_FORMAT_mediaSubtype, SPA_POD_Id (SPA_MEDIA_SUBTYPE_raw),
++    SPA_FORMAT_VIDEO_format, SPA_POD_Id (SPA_VIDEO_FORMAT_BGRx),
++    SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle (&SPA_RECTANGLE (priv->stream_width,
++                                                              priv->stream_height)),
++    SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction (&SPA_FRACTION (0, 1)),
++    SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction (&max_framerate,
++                                                                  &min_framerate,
+                                                                   &max_framerate));
+
+   pw_stream_add_listener (pipewire_stream,
+@@ -702,7 +684,7 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+
+   result = pw_stream_connect (pipewire_stream,
+                               PW_DIRECTION_OUTPUT,
+-                              NULL,
++                              SPA_ID_INVALID,
+                               (PW_STREAM_FLAG_DRIVER |
+                                PW_STREAM_FLAG_MAP_BUFFERS),
+                               params, G_N_ELEMENTS (params));
+@@ -717,40 +699,18 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+ }
+
+ static void
+-on_state_changed (void                 *data,
+-                  enum pw_remote_state  old,
+-                  enum pw_remote_state  state,
+-                  const char           *error_message)
++on_core_error (void       *data,
++               uint32_t    id,
++	       int         seq,
++	       int         res,
++	       const char *message)
+ {
+   MetaScreenCastStreamSrc *src = data;
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_stream *pipewire_stream;
+-  GError *error = NULL;
+
+-  switch (state)
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-      g_warning ("pipewire remote error: %s\n", error_message);
+-      meta_screen_cast_stream_src_notify_closed (src);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pipewire_stream = create_pipewire_stream (src, &error);
+-      if (!pipewire_stream)
+-        {
+-          g_warning ("Could not create pipewire stream: %s", error->message);
+-          g_error_free (error);
+-          meta_screen_cast_stream_src_notify_closed (src);
+-        }
+-      else
+-        {
+-          priv->pipewire_stream = pipewire_stream;
+-        }
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    }
++  g_warning ("pipewire remote error: id:%u %s", id, message);
++
++  if (id == PW_ID_CORE && res == -EPIPE)
++    meta_screen_cast_stream_src_notify_closed (src);
+ }
+
+ static gboolean
+@@ -793,17 +753,6 @@ static GSourceFuncs pipewire_source_funcs =
+   pipewire_loop_source_finalize
+ };
+
+-static void
+-init_spa_type (MetaSpaType         *type,
+-               struct spa_type_map *map)
+-{
+-  spa_type_media_type_map (map, &type->media_type);
+-  spa_type_media_subtype_map (map, &type->media_subtype);
+-  spa_type_format_video_map (map, &type->format_video);
+-  spa_type_video_format_map (map, &type->video_format);
+-  type->meta_cursor = spa_type_map_get_id(map, SPA_TYPE_META__Cursor);
+-}
+-
+ static MetaPipeWireSource *
+ create_pipewire_source (void)
+ {
+@@ -829,9 +778,9 @@ create_pipewire_source (void)
+   return pipewire_source;
+ }
+
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = on_core_error,
+ };
+
+ static gboolean
+@@ -851,37 +800,31 @@ meta_screen_cast_stream_src_initable_init (GInitable     *initable,
+       return FALSE;
+     }
+
+-  priv->pipewire_core = pw_core_new (priv->pipewire_source->pipewire_loop,
+-                                     NULL);
+-  if (!priv->pipewire_core)
++  priv->pipewire_context = pw_context_new (priv->pipewire_source->pipewire_loop,
++                                           NULL, 0);
++  if (!priv->pipewire_context)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Failed to create pipewire core");
++                   "Failed to create pipewire context");
+       return FALSE;
+     }
+
+-  priv->pipewire_remote = pw_remote_new (priv->pipewire_core, NULL, 0);
+-  if (!priv->pipewire_remote)
++  priv->pipewire_core = pw_context_connect (priv->pipewire_context, NULL, 0);
++  if (!priv->pipewire_core)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't creat pipewire remote");
++                   "Couldn't connect pipewire context");
+       return FALSE;
+     }
+
+-  pw_remote_add_listener (priv->pipewire_remote,
+-                          &priv->pipewire_remote_listener,
+-                          &remote_events,
+-                          src);
++  pw_core_add_listener (priv->pipewire_core,
++                        &priv->pipewire_core_listener,
++                        &core_events,
++                        src);
+
+-  priv->pipewire_type = pw_core_get_type (priv->pipewire_core);
+-  init_spa_type (&priv->spa_type, priv->pipewire_type->map);
+-
+-  if (pw_remote_connect (priv->pipewire_remote) != 0)
+-    {
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect pipewire remote");
+-      return FALSE;
+-    }
++  priv->pipewire_stream = create_pipewire_stream (src, error);
++  if (!priv->pipewire_stream)
++    return FALSE;
+
+   return TRUE;
+ }
+@@ -912,8 +855,8 @@ meta_screen_cast_stream_src_finalize (GObject *object)
+     meta_screen_cast_stream_src_disable (src);
+
+   g_clear_pointer (&priv->pipewire_stream, pw_stream_destroy);
+-  g_clear_pointer (&priv->pipewire_remote, pw_remote_destroy);
+-  g_clear_pointer (&priv->pipewire_core, pw_core_destroy);
++  g_clear_pointer (&priv->pipewire_core, pw_core_disconnect);
++  g_clear_pointer (&priv->pipewire_context, pw_context_destroy);
+   g_source_destroy (&priv->pipewire_source->base);
+
+   G_OBJECT_CLASS (meta_screen_cast_stream_src_parent_class)->finalize (object);
diff --git a/srcpkgs/mutter/template b/srcpkgs/mutter/template
index 4e0bd32b67d..806a3bef9f0 100644
--- a/srcpkgs/mutter/template
+++ b/srcpkgs/mutter/template
@@ -1,7 +1,7 @@
 # Template file for 'mutter'
 pkgname=mutter
 version=3.34.1
-revision=2
+revision=3
 build_helper="gir"
 build_style=meson
 configure_args="-Degl_device=true -Dudev=true -Dnative_backend=true

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PR PATCH] [Updated] pipewire: update to 0.3.2
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (24 preceding siblings ...)
  2020-04-30 20:51 ` [PR PATCH] [Updated] " sirn
@ 2020-04-30 20:52 ` sirn
  2020-04-30 21:02 ` [PR PATCH] [Updated] pipewire: update to 0.3.4 sirn
                   ` (25 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-04-30 20:52 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 785 bytes --]

There is an updated pull request by sirn against master on the void-packages repository

https://github.com/sirn/void-packages pipewire-update
https://github.com/void-linux/void-packages/pull/20413

pipewire: update to 0.3.2
This PR updates `pipewire` to 0.3.2 and also updating/patching all packages that depends on it. 

* `xdg-desktop-portal` includes a patch backported from 1.7.0 to allow 1.6.0 to build against pipewire-0.3 (1.7.x is prerelease)
* `xdg-desktop-portal-kde` already includes Pipewire 0.3 support and only requires revbump.
* `mutter` includes a patch backported from 3.35 to allow 3.34 to build against pipewire-0.3 (upgrading to >=3.35 also requires upgrading GNOME).

A patch file from https://github.com/void-linux/void-packages/pull/20413.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pipewire-update-20413.patch --]
[-- Type: text/x-diff, Size: 50987 bytes --]

From 1c12b0c869252455e8d4fd37b14cce45b45c4421 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:23:52 +0900
Subject: [PATCH 1/4] pipewire: update to 0.3.4

---
 common/shlibs                  |  2 +-
 srcpkgs/alsa-pipewire          |  1 +
 srcpkgs/libjack-pipewire       |  1 +
 srcpkgs/libpulseaudio-pipewire |  1 +
 srcpkgs/pipewire/template      | 75 ++++++++++++++++++++++++++--------
 5 files changed, 62 insertions(+), 18 deletions(-)
 create mode 120000 srcpkgs/alsa-pipewire
 create mode 120000 srcpkgs/libjack-pipewire
 create mode 120000 srcpkgs/libpulseaudio-pipewire

diff --git a/common/shlibs b/common/shlibs
index a208407b359..07279a7bc72 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3199,7 +3199,7 @@ libarcan_shmif_ext.so.0.11 arcan-0.5.4.3_1
 libarcan_shmif_server.so.0.11 arcan-0.5.4.3_1
 libarcan_tui.so.0.11 arcan-0.5.4.3_1
 liblwipv6.so.2 lwipv6-1.5a_1
-libpipewire-0.2.so.1 libpipewire-0.2.2_1
+libpipewire-0.3.so.0 libpipewire-0.3.4_1
 libvolk.so.2.2.1 volk-2.2.1_1
 libgnuradio-runtime.so.3.8.0 gnuradio-3.8.0.0_1
 libgnuradio-pmt.so.3.8.0 gnuradio-3.8.0.0_1
diff --git a/srcpkgs/alsa-pipewire b/srcpkgs/alsa-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/alsa-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libjack-pipewire b/srcpkgs/libjack-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libjack-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libpulseaudio-pipewire b/srcpkgs/libpulseaudio-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libpulseaudio-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/pipewire/template b/srcpkgs/pipewire/template
index 7f646dad11d..5f14a189e6f 100644
--- a/srcpkgs/pipewire/template
+++ b/srcpkgs/pipewire/template
@@ -1,26 +1,42 @@
 # Template file for 'pipewire'
 pkgname=pipewire
-version=0.2.7
+version=0.3.4
 revision=1
 build_style=meson
-configure_args="-Dman=true -Dgstreamer=enabled -Ddocs=true -Dsystemd=false"
+configure_args="-Dman=true -Dgstreamer=true -Ddocs=true -Dsystemd=false
+ -Dbluez5=true -Dffmpeg=true -Dpipewire-alsa=true -Dpipewire-jack=true
+ -Dpipewire-pulseaudio=true"
 hostmakedepends="doxygen graphviz pkg-config xmltoman"
 makedepends="SDL2-devel ffmpeg-devel gst-plugins-base1-devel jack-devel
- sbc-devel v4l-utils-devel libva-devel"
+ sbc-devel v4l-utils-devel libva-devel libbluetooth-devel"
 short_desc="Server and user space API to deal with multimedia pipelines"
 maintainer="Orphaned <orphan@voidlinux.org>"
-#Next release will probably change to MIT, currently listed in master
-license="LGPL-2.1-only, GPL-2.0-only "
+license="MIT"
 homepage="https://pipewire.org/"
-changelog="https://raw.githubusercontent.com/PipeWire/pipewire/master/NEWS"
-distfiles="https://github.com/PipeWire/pipewire/archive/${version}.tar.gz"
-checksum=bfaa0f6ae6c0791e2e0b59234d399753bf24f1b33dbf587682363a8463dd8df1
+changelog="https://gitlab.freedesktop.org/pipewire/pipewire/-/raw/master/NEWS"
+distfiles="https://gitlab.freedesktop.org/pipewire/pipewire/-/archive/${version}/pipewire-${version}.tar.gz"
+checksum=6a1c9c671514c84b38ce96d51823354702bc4d5dbaba12d501faa0448f892515
 conf_files="/etc/pipewire/pipewire.conf"
 
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+	LDFLAGS+=" -latomic"
+fi
+
+post_install() {
+	vlicense LICENSE
+}
+
+post_patch() {
+	# https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/233
+	vsed -i meson.build -e 's|.*-Werror=suggest-attribute=format.*||g'
+}
+
 libpipewire_package() {
 	short_desc+=" - pipewire library"
 	pkg_install() {
-		vmove "usr/lib/libpipewire-0.2.so.*"
+		vmove "usr/lib/libpipewire-0.3.so.*"
+		vmove "usr/lib/pipewire-0.3/*.so"
 	}
 }
 
@@ -28,25 +44,24 @@ pipewire-devel_package() {
 	depends="libpipewire-${version}_${revision}"
 	short_desc+=" - pipewire and libspa development files"
 	pkg_install() {
-		vmove usr/include/pipewire
-		vmove usr/include/spa
-		vmove usr/lib/pkgconfig/libpipewire-0.2.pc
-		vmove usr/lib/pkgconfig/libspa-0.1.pc
-		vmove usr/lib/libpipewire-0.2.so
+		vmove usr/include/pipewire-0.3
+		vmove usr/include/spa-0.2
+		vmove usr/lib/pkgconfig/libpipewire-0.3.pc
+		vmove usr/lib/pkgconfig/libspa-0.2.pc
 	}
 }
 
 libspa-ffmpeg_package() {
 	short_desc+=" - ffmpeg plugins"
 	pkg_install() {
-		vmove usr/lib/spa/ffmpeg
+		vmove usr/lib/spa-0.2/ffmpeg
 	}
 }
 
 libspa-bluetooth_package() {
 	short_desc+=" - bluetooth plugins"
 	pkg_install() {
-		vmove usr/lib/spa/bluez5
+		vmove usr/lib/spa-0.2/bluez5
 	}
 }
 
@@ -57,10 +72,36 @@ gstreamer1-pipewire_package() {
 	}
 }
 
+libpulseaudio-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - PulseAudio client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/pulse
+		vmove usr/bin/pw-pulse
+	}
+}
+
+alsa-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - ALSA client library"
+	pkg_install() {
+		vmove usr/lib/alsa-lib
+	}
+}
+
+libjack-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - JACK client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/jack
+		vmove usr/bin/pw-jack
+	}
+}
+
 pipewire-doc_package() {
 	archs=noarch
 	short_desc+=" - documentation"
 	pkg_install() {
 		vmove usr/share/doc
 	}
-}
+}
\ No newline at end of file

From 98e645034ab200ac8ed372a8b4fea479a355781c Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:46 +0900
Subject: [PATCH 2/4] xdg-desktop-portal-kde: rebuild for pipewire-0.3

---
 srcpkgs/xdg-desktop-portal-kde/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xdg-desktop-portal-kde/template b/srcpkgs/xdg-desktop-portal-kde/template
index f26057d323a..9519abc19f6 100644
--- a/srcpkgs/xdg-desktop-portal-kde/template
+++ b/srcpkgs/xdg-desktop-portal-kde/template
@@ -1,7 +1,7 @@
 # Template file for 'xdg-desktop-portal-kde'
 pkgname=xdg-desktop-portal-kde
 version=5.18.4.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules qt5-qmake qt5-host-tools kcoreaddons gettext"
 makedepends="glib-devel kio-devel kwayland-devel libepoxy-devel pipewire-devel

From 22b52438bebe94609e24ae933ee09ae2c33e1f32 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:26 +0900
Subject: [PATCH 3/4] xdg-desktop-portal: rebuild for pipewire-0.3

---
 .../patches/pipewire-0.3.patch                | 551 ++++++++++++++++++
 srcpkgs/xdg-desktop-portal/template           |   8 +-
 2 files changed, 557 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch

diff --git a/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..94ebe083598
--- /dev/null
+++ b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
@@ -0,0 +1,551 @@
+From a38901e5e7f835efe7b7a06c55790c8c20bc91a2 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Tue, 14 Jan 2020 09:37:09 +0100
+Subject: [PATCH] PipeWire: update to 0.3 API
+
+---
+ configure.ac      |   2 +-
+ src/camera.c      |  24 ++++----
+ src/pipewire.c    | 141 +++++++++++++---------------------------------
+ src/pipewire.h    |  10 ++--
+ src/screen-cast.c |  98 ++++++--------------------------
+ 5 files changed, 72 insertions(+), 203 deletions(-)
+
+diff --git configure.ac configure.ac
+index 89902fa..62d7960 100644
+--- configure.ac
++++ configure.ac
+@@ -97,7 +97,7 @@ AC_ARG_ENABLE(pipewire,
+ 	      [AS_HELP_STRING([--enable-pipewire],[Enable PipeWire support. Needed for screen cast portal])],
+ 	      enable_pipewire=$enableval, enable_pipewire=yes)
+ if test x$enable_pipewire = xyes ; then
+-	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.2 >= 0.2.6])
++	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.3 >= 0.2.90])
+ 	AC_DEFINE([HAVE_PIPEWIRE],[1], [Define to enable PipeWire support])
+ fi
+ AM_CONDITIONAL([HAVE_PIPEWIRE],[test "$enable_pipewire" = "yes"])
+diff --git src/camera.c src/camera.c
+index c2b392c..20fe3aa 100644
+--- src/camera.c
++++ src/camera.c
+@@ -141,7 +141,7 @@ open_pipewire_camera_remote (const char *app_id,
+                              GError **error)
+ {
+   PipeWireRemote *remote;
+-  struct spa_dict_item permission_items[1];
++  struct pw_permission permission_items[2];
+   struct pw_properties *pipewire_properties;
+ 
+   pipewire_properties =
+@@ -158,12 +158,12 @@ open_pipewire_camera_remote (const char *app_id,
+    * Hide all existing and future nodes by default. PipeWire will use the
+    * permission store to set up permissions.
+    */
+-  permission_items[0].key = PW_CORE_PROXY_PERMISSIONS_DEFAULT;
+-  permission_items[0].value = "---";
++  permission_items[0] = PW_PERMISSION_INIT (PW_ID_CORE, PW_PERM_RWX);
++  permission_items[1] = PW_PERMISSION_INIT (PW_ID_ANY, 0);
+ 
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             &SPA_DICT_INIT (permission_items,
+-                                             G_N_ELEMENTS (permission_items)));
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                G_N_ELEMENTS (permission_items),
++                                permission_items);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -219,7 +219,7 @@ handle_open_pipewire_remote (XdpCamera *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
+@@ -250,29 +250,28 @@ camera_iface_init (XdpCameraIface *iface)
+ static void
+ global_added_cb (PipeWireRemote *remote,
+                  uint32_t id,
+-                 uint32_t type,
++                 const char *type,
+                  const struct spa_dict *props,
+                  gpointer user_data)
+ {
+   Camera *camera = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *media_class;
+   const struct spa_dict_item *media_role;
+ 
+-  if (type != core_type->node)
++  if (strcmp(type, PW_TYPE_INTERFACE_Node) != 0)
+     return;
+ 
+   if (!props)
+     return;
+ 
+-  media_class = spa_dict_lookup_item (props, "media.class");
++  media_class = spa_dict_lookup_item (props, PW_KEY_MEDIA_CLASS);
+   if (!media_class)
+     return;
+ 
+   if (g_strcmp0 (media_class->value, "Video/Source") != 0)
+     return;
+ 
+-  media_role = spa_dict_lookup_item (props, "media.role");
++  media_role = spa_dict_lookup_item (props, PW_KEY_MEDIA_ROLE);
+   if (!media_role)
+     return;
+ 
+@@ -342,6 +341,7 @@ create_pipewire_remote (Camera *camera,
+     }
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.is_portal", "true",
++                                           "portal.monitor", "Camera",
+                                            NULL);
+   camera->pipewire_remote = pipewire_remote_new_sync (pipewire_properties,
+                                                       global_added_cb,
+diff --git src/pipewire.c src/pipewire.c
+index 793a378..162cd55 100644
+--- src/pipewire.c
++++ src/pipewire.c
+@@ -21,6 +21,7 @@
+ #include <errno.h>
+ #include <glib.h>
+ #include <pipewire/pipewire.h>
++#include <spa/utils/result.h>
+ 
+ #include "pipewire.h"
+ 
+@@ -36,27 +37,25 @@ static gboolean is_pipewire_initialized = FALSE;
+ static void
+ registry_event_global (void *user_data,
+                        uint32_t id,
+-                       uint32_t parent_id,
+                        uint32_t permissions,
+-                       uint32_t type,
++                       const char *type,
+                        uint32_t version,
+                        const struct spa_dict *props)
+ {
+   PipeWireRemote *remote = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *factory_object_type;
+   PipeWireGlobal *global;
+ 
+   global = g_new0 (PipeWireGlobal, 1);
+   *global = (PipeWireGlobal) {
+-    .parent_id = parent_id,
++    .parent_id = id,
+   };
+ 
+   g_hash_table_insert (remote->globals, GINT_TO_POINTER (id), global);
+   if (remote->global_added_cb)
+     remote->global_added_cb (remote, id, type, props, remote->user_data);
+ 
+-  if (type != core_type->factory)
++  if (strcmp(type, PW_TYPE_INTERFACE_Factory) != 0)
+     return;
+ 
+   factory_object_type = spa_dict_lookup_item (props, "factory.type.name");
+@@ -81,8 +80,8 @@ registry_event_global_remove (void *user_data,
+   g_hash_table_remove (remote->globals, GINT_TO_POINTER (id));
+ }
+ 
+-static const struct pw_registry_proxy_events registry_events = {
+-  PW_VERSION_REGISTRY_PROXY_EVENTS,
++static const struct pw_registry_events registry_events = {
++  PW_VERSION_REGISTRY_EVENTS,
+   .global = registry_event_global,
+   .global_remove = registry_event_global_remove,
+ };
+@@ -90,7 +89,7 @@ static const struct pw_registry_proxy_events registry_events = {
+ void
+ pipewire_remote_roundtrip (PipeWireRemote *remote)
+ {
+-  pw_core_proxy_sync (remote->core_proxy, ++remote->sync_seq);
++  remote->sync_seq = pw_core_sync (remote->core, PW_ID_CORE, remote->sync_seq);
+   pw_main_loop_run (remote->loop);
+ }
+ 
+@@ -98,16 +97,13 @@ static gboolean
+ discover_node_factory_sync (PipeWireRemote *remote,
+                             GError **error)
+ {
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+-  struct pw_registry_proxy *registry_proxy;
++  struct pw_registry *registry;
+ 
+-  registry_proxy = pw_core_proxy_get_registry (remote->core_proxy,
+-                                               core_type->registry,
+-                                               PW_VERSION_REGISTRY, 0);
+-  pw_registry_proxy_add_listener (registry_proxy,
+-                                  &remote->registry_listener,
+-                                  &registry_events,
+-                                  remote);
++  registry = pw_core_get_registry (remote->core, PW_VERSION_REGISTRY, 0);
++  pw_registry_add_listener (registry,
++                            &remote->registry_listener,
++                            &registry_events,
++                            remote);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -122,59 +118,35 @@ discover_node_factory_sync (PipeWireRemote *remote,
+ }
+ 
+ static void
+-on_state_changed (void *user_data,
+-                  enum pw_remote_state old,
+-                  enum pw_remote_state state,
+-                  const char *error)
++core_event_error (void       *user_data,
++                  uint32_t    id,
++		  int         seq,
++		  int         res,
++		  const char *message)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  switch (state)
++  if (id == PW_ID_CORE)
+     {
+-    case PW_REMOTE_STATE_ERROR:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "%s", error);
+-        }
++      g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
++                 "%s", message);
+       pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "Disconnected");
+-        }
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    default:
+-      g_warning ("Unknown PipeWire state");
+-      break;
+     }
+ }
+ 
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
+-};
+-
+ static void
+ core_event_done (void *user_data,
+-                 uint32_t seq)
++                 uint32_t id, int seq)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  if (remote->sync_seq == seq)
++  if (id == PW_ID_CORE && remote->sync_seq == seq)
+     pw_main_loop_quit (remote->loop);
+ }
+ 
+-static const struct pw_core_proxy_events core_events = {
+-  PW_VERSION_CORE_PROXY_EVENTS,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = core_event_error,
+   .done = core_event_done,
+ };
+ 
+@@ -237,8 +209,8 @@ void
+ pipewire_remote_destroy (PipeWireRemote *remote)
+ {
+   g_clear_pointer (&remote->globals, g_hash_table_destroy);
+-  g_clear_pointer (&remote->remote, pw_remote_destroy);
+-  g_clear_pointer (&remote->core, pw_core_destroy);
++  g_clear_pointer (&remote->core, pw_core_disconnect);
++  g_clear_pointer (&remote->context, pw_context_destroy);
+   g_clear_pointer (&remote->loop, pw_main_loop_destroy);
+   g_clear_error (&remote->error);
+ 
+@@ -307,68 +279,31 @@ pipewire_remote_new_sync (struct pw_properties *pipewire_properties,
+       return NULL;
+     }
+ 
+-  remote->core = pw_core_new (pw_main_loop_get_loop (remote->loop), NULL);
+-  if (!remote->core)
++  remote->context = pw_context_new (pw_main_loop_get_loop (remote->loop), NULL, 0);
++  if (!remote->context)
+     {
+       pipewire_remote_destroy (remote);
+       pw_properties_free (pipewire_properties);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire core");
++                   "Couldn't create PipeWire context");
+       return NULL;
+     }
+ 
+-  remote->remote = pw_remote_new (remote->core, pipewire_properties, 0);
+-  if (!remote->remote)
++  remote->core = pw_context_connect (remote->context, pipewire_properties, 0);
++  if (!remote->core)
+     {
+       pipewire_remote_destroy (remote);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire remote");
++                   "Couldn't connect to PipeWire");
+       return NULL;
+     }
+ 
+   remote->globals = g_hash_table_new_full (NULL, NULL, NULL, g_free);
+ 
+-  pw_remote_add_listener (remote->remote,
+-                          &remote->remote_listener,
+-                          &remote_events,
+-                          remote);
+-
+-  if (pw_remote_connect (remote->remote) != 0)
+-    {
+-      pipewire_remote_destroy (remote);
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect PipeWire remote");
+-      return NULL;
+-    }
+-
+-  pw_main_loop_run (remote->loop);
+-
+-  switch (pw_remote_get_state (remote->remote, NULL))
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      *error = g_steal_pointer (&remote->error);
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "PipeWire loop stopped unexpectedly");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      break;
+-    default:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Unexpected PipeWire state");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    }
+-
+-  remote->core_proxy = pw_remote_get_core_proxy (remote->remote);
+-  pw_core_proxy_add_listener (remote->core_proxy,
+-                              &remote->core_listener,
+-                              &core_events,
+-                              remote);
++  pw_core_add_listener (remote->core,
++                        &remote->core_listener,
++                        &core_events,
++                        remote);
+ 
+   if (!discover_node_factory_sync (remote, error))
+     {
+diff --git src/pipewire.h src/pipewire.h
+index 0f1bf54..bf48d5e 100644
+--- src/pipewire.h
++++ src/pipewire.h
+@@ -32,7 +32,7 @@ typedef struct _PipeWireGlobal
+ 
+ typedef void (* PipeWireGlobalAddedCallback) (PipeWireRemote *remote,
+                                               uint32_t id,
+-                                              uint32_t type,
++                                              const char *type,
+                                               const struct spa_dict *props,
+                                               gpointer user_data);
+ 
+@@ -43,13 +43,11 @@ typedef void (* PipeWireGlobalRemovedCallback) (PipeWireRemote *remote,
+ struct _PipeWireRemote
+ {
+   struct pw_main_loop *loop;
++  struct pw_context *context;
+   struct pw_core *core;
+-  struct pw_remote *remote;
+-  struct spa_hook remote_listener;
+-
+-  struct pw_core_proxy *core_proxy;
+   struct spa_hook core_listener;
+-  uint32_t sync_seq;
++
++  int sync_seq;
+ 
+   struct spa_hook registry_listener;
+ 
+diff --git src/screen-cast.c src/screen-cast.c
+index 7881ddc..1677050 100644
+--- src/screen-cast.c
++++ src/screen-cast.c
+@@ -31,10 +31,10 @@
+ #include "xdp-impl-dbus.h"
+ #include "xdp-utils.h"
+ 
+-#define PERMISSION_ITEM(item_key, item_value) \
+-  ((struct spa_dict_item) { \
+-    .key = item_key, \
+-    .value = item_value \
++#define PERMISSION_ITEM(item_id, item_permissions) \
++  ((struct pw_permission) { \
++    .id = item_id, \
++    .permissions = item_permissions \
+   })
+ 
+ typedef struct _ScreenCast ScreenCast;
+@@ -517,42 +517,9 @@ screen_cast_stream_get_pipewire_node_id (ScreenCastStream *stream)
+   return stream->id;
+ }
+ 
+-static void
+-append_parent_permissions (PipeWireRemote *remote,
+-                           GArray *permission_items,
+-                           GList **string_stash,
+-                           PipeWireGlobal *global,
+-                           const char *permission)
+-{
+-  PipeWireGlobal *parent;
+-  char *parent_permission_value;
+-
+-  if (global->parent_id == 0)
+-    return;
+-
+-  parent = g_hash_table_lookup (remote->globals, GINT_TO_POINTER (global->parent_id));
+-
+-  if (parent->permission_set)
+-    return;
+-  parent->permission_set = TRUE;
+-
+-  append_parent_permissions (remote, permission_items, string_stash,
+-                             parent, permission);
+-
+-  parent_permission_value = g_strdup_printf ("%u:%s",
+-                                             global->parent_id,
+-                                             permission);
+-  *string_stash = g_list_prepend (*string_stash, parent_permission_value);
+-
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       parent_permission_value));
+-}
+-
+ static void
+ append_stream_permissions (PipeWireRemote *remote,
+                            GArray *permission_items,
+-                           GList **string_stash,
+                            GList *streams)
+ {
+   GList *l;
+@@ -561,21 +528,10 @@ append_stream_permissions (PipeWireRemote *remote,
+     {
+       ScreenCastStream *stream = l->data;
+       uint32_t stream_id;
+-      PipeWireGlobal *stream_global;
+-      char *stream_permission_value;
+ 
+       stream_id = screen_cast_stream_get_pipewire_node_id (stream);
+-      stream_global = g_hash_table_lookup (remote->globals,
+-                                           GINT_TO_POINTER (stream_id));
+-
+-      append_parent_permissions (remote, permission_items, string_stash,
+-                                 stream_global, "r--");
+-
+-      stream_permission_value = g_strdup_printf ("%u:rwx", stream_id);
+-      *string_stash = g_list_prepend (*string_stash, stream_permission_value);
+       g_array_append_val (permission_items,
+-                          PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                           stream_permission_value));
++                          PERMISSION_ITEM (stream_id, PW_PERM_RWX));
+     }
+ }
+ 
+@@ -587,9 +543,6 @@ open_pipewire_screen_cast_remote (const char *app_id,
+   struct pw_properties *pipewire_properties;
+   PipeWireRemote *remote;
+   g_autoptr(GArray) permission_items = NULL;
+-  char *node_factory_permission_string;
+-  GList *string_stash = NULL;
+-  struct spa_dict *permission_dict;
+   PipeWireGlobal *node_global;
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.app_id", app_id,
+@@ -603,48 +556,31 @@ open_pipewire_screen_cast_remote (const char *app_id,
+ 
+   permission_items = g_array_new (FALSE, TRUE, sizeof (struct spa_dict_item));
+ 
+-  /*
+-   * Hide all existing and future nodes (except the ones we explicitly list below.
+-   */
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_EXISTING,
+-                                       "---"));
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_DEFAULT,
+-                                       "---"));
+-
+   /*
+    * PipeWire:Interface:Core
+    * Needs rwx to be able create the sink node using the create-object method
+    */
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       "0:rwx"));
++                      PERMISSION_ITEM (PW_ID_CORE, PW_PERM_RWX));
+ 
+   /*
+    * PipeWire:Interface:NodeFactory
+    * Needs r-- so it can be passed to create-object when creating the sink node.
+    */
+-  node_factory_permission_string = g_strdup_printf ("%d:r--",
+-                                                    remote->node_factory_id);
+-  string_stash = g_list_prepend (string_stash, node_factory_permission_string);
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       node_factory_permission_string));
+-  node_global = g_hash_table_lookup (remote->globals,
+-                                     GINT_TO_POINTER (remote->node_factory_id));
+-  append_parent_permissions (remote, permission_items, &string_stash,
+-                             node_global, "r--");
++                      PERMISSION_ITEM (remote->node_factory_id, PW_PERM_R));
+ 
+-  append_stream_permissions (remote, permission_items, &string_stash, streams);
++  append_stream_permissions (remote, permission_items, streams);
+ 
+-  permission_dict =
+-    &SPA_DICT_INIT ((struct spa_dict_item *) permission_items->data,
+-                    permission_items->len);
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             permission_dict);
++  /*
++   * Hide all existing and future nodes (except the ones we explicitly list above).
++   */
++  g_array_append_val (permission_items,
++                      PERMISSION_ITEM (PW_ID_ANY, 0));
+ 
+-  g_list_free_full (string_stash, g_free);
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                permission_items->len,
++                                (const struct pw_permission *)permission_items->data);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -943,7 +879,7 @@ handle_open_pipewire_remote (XdpScreenCast *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
diff --git a/srcpkgs/xdg-desktop-portal/template b/srcpkgs/xdg-desktop-portal/template
index eb8a4602f5d..1136b6a6e0e 100644
--- a/srcpkgs/xdg-desktop-portal/template
+++ b/srcpkgs/xdg-desktop-portal/template
@@ -1,10 +1,10 @@
 # Template file for 'xdg-desktop-portal'
 pkgname=xdg-desktop-portal
 version=1.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-pipewire --enable-geoclue --disable-libportal"
-hostmakedepends="pkg-config glib-devel"
+hostmakedepends="automake libtool gettext-devel pkg-config glib-devel"
 makedepends="flatpak-devel fuse-devel pipewire-devel geoclue2-devel"
 short_desc="Portal frontend service for Flatpak"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -13,6 +13,10 @@ homepage="https://github.com/flatpak/xdg-desktop-portal"
 distfiles="https://github.com/flatpak/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.xz"
 checksum=883c9c9a925e48af54812b5347f546dd776ec2e27076a83d5a8126af6bafb9da
 
+pre_configure() {
+	autoreconf -vfi
+}
+
 post_install() {
 	rm -rf "${DESTDIR}/usr/lib/systemd"
 }

From 57525f5c7c5bb1b7b7ed4e6ab2a9af1593435fad Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Thu, 30 Apr 2020 06:17:17 +0900
Subject: [PATCH 4/4] mutter: rebuild for pipewire-0.3

---
 srcpkgs/mutter/patches/pipewire-0.3.patch | 521 ++++++++++++++++++++++
 srcpkgs/mutter/template                   |   2 +-
 2 files changed, 522 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/mutter/patches/pipewire-0.3.patch

diff --git a/srcpkgs/mutter/patches/pipewire-0.3.patch b/srcpkgs/mutter/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..ebff65fba85
--- /dev/null
+++ b/srcpkgs/mutter/patches/pipewire-0.3.patch
@@ -0,0 +1,521 @@
+Build mutter against pipewire-0.3, based on a patch at:
+https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1062
+--- meson.build
++++ meson.build
+@@ -50,7 +50,7 @@ libinput_req = '>= 1.7'
+ gbm_req = '>= 10.3'
+
+ # screen cast version requirements
+-libpipewire_req = '>= 0.2.5'
++libpipewire_req = '>= 0.3.0'
+
+ gnome = import('gnome')
+ pkg = import('pkgconfig')
+@@ -241,7 +241,7 @@ endif
+
+ have_remote_desktop = get_option('remote_desktop')
+ if have_remote_desktop
+-  libpipewire_dep = dependency('libpipewire-0.2', version: libpipewire_req)
++  libpipewire_dep = dependency('libpipewire-0.3', version: libpipewire_req)
+ endif
+
+ have_introspection = get_option('introspection')
+diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
+index 82c5cba436..ba1ce94a7e 100644
+--- src/backends/meta-screen-cast-stream-src.c
++++ src/backends/meta-screen-cast-stream-src.c
+@@ -29,6 +29,7 @@
+ #include <spa/param/props.h>
+ #include <spa/param/format-utils.h>
+ #include <spa/param/video/format-utils.h>
++#include <spa/utils/result.h>
+ #include <stdint.h>
+ #include <sys/mman.h>
+
+@@ -62,15 +63,6 @@ enum
+
+ static guint signals[N_SIGNALS];
+
+-typedef struct _MetaSpaType
+-{
+-  struct spa_type_media_type media_type;
+-  struct spa_type_media_subtype media_subtype;
+-  struct spa_type_format_video format_video;
+-  struct spa_type_video_format video_format;
+-  uint32_t meta_cursor;
+-} MetaSpaType;
+-
+ typedef struct _MetaPipeWireSource
+ {
+   GSource base;
+@@ -82,19 +74,19 @@ typedef struct _MetaScreenCastStreamSrcPrivate
+ {
+   MetaScreenCastStream *stream;
+
++  struct pw_context *pipewire_context;
+   struct pw_core *pipewire_core;
+-  struct pw_remote *pipewire_remote;
+-  struct pw_type *pipewire_type;
+   MetaPipeWireSource *pipewire_source;
+-  struct spa_hook pipewire_remote_listener;
++  struct spa_hook pipewire_core_listener;
+
+   gboolean is_enabled;
+
+   struct pw_stream *pipewire_stream;
+   struct spa_hook pipewire_stream_listener;
++  uint32_t node_id;
+
+-  MetaSpaType spa_type;
+   struct spa_video_info_raw video_format;
++  int video_stride;
+
+   uint64_t last_frame_timestamp_us;
+
+@@ -112,8 +104,6 @@ G_DEFINE_TYPE_WITH_CODE (MetaScreenCastStreamSrc,
+                                                 meta_screen_cast_stream_src_init_initable_iface)
+                          G_ADD_PRIVATE (MetaScreenCastStreamSrc))
+
+-#define PROP_RANGE(min, max) 2, (min), (max)
+-
+ static void
+ meta_screen_cast_stream_src_get_specs (MetaScreenCastStreamSrc *src,
+                                        int                     *width,
+@@ -286,9 +276,6 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+                                                               int                      x,
+                                                               int                      y)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+
+   spa_meta_cursor->id = 1;
+@@ -300,7 +287,7 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   spa_meta_cursor->hotspot.x = 0;
+@@ -317,9 +304,6 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+                                                         int                      y,
+                                                         float                    scale)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   CoglTexture *cursor_texture;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+   int hotspot_x, hotspot_y;
+@@ -346,7 +330,7 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
+@@ -382,12 +366,10 @@ static void
+ add_cursor_metadata (MetaScreenCastStreamSrc *src,
+                      struct spa_buffer       *spa_buffer)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_cursor *spa_meta_cursor;
+
+-  spa_meta_cursor = spa_buffer_find_meta (spa_buffer, spa_type->meta_cursor);
++  spa_meta_cursor = spa_buffer_find_meta_data (spa_buffer, SPA_META_Cursor,
++                                               sizeof (*spa_meta_cursor));
+   if (spa_meta_cursor)
+     meta_screen_cast_stream_src_set_cursor_metadata (src, spa_meta_cursor);
+ }
+@@ -447,14 +429,14 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+     {
+       data = spa_buffer->datas[0].data;
+     }
+-  else if (spa_buffer->datas[0].type == priv->pipewire_type->data.MemFd)
++  else if (spa_buffer->datas[0].type == SPA_DATA_MemFd)
+     {
+       map = mmap (NULL, spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset,
+                   PROT_READ | PROT_WRITE, MAP_SHARED,
+                   spa_buffer->datas[0].fd, 0);
+       if (map == MAP_FAILED)
+         {
+-          g_warning ("Failed to mmap pipewire stream buffer: %s\n",
++          g_warning ("Failed to mmap pipewire stream buffer: %s",
+                      strerror (errno));
+           return;
+         }
+@@ -469,28 +451,30 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+
+   if (meta_screen_cast_stream_src_record_frame (src, data))
+     {
+-      struct spa_meta_video_crop *spa_meta_video_crop;
++      struct spa_meta_region *spa_meta_video_crop;
+
+       spa_buffer->datas[0].chunk->size = spa_buffer->datas[0].maxsize;
++      spa_buffer->datas[0].chunk->stride = priv->video_stride;
+
+       /* Update VideoCrop if needed */
+       spa_meta_video_crop =
+-        spa_buffer_find_meta (spa_buffer, priv->pipewire_type->meta.VideoCrop);
++        spa_buffer_find_meta_data (spa_buffer, SPA_META_VideoCrop,
++                                   sizeof (*spa_meta_video_crop));
+       if (spa_meta_video_crop)
+         {
+           if (meta_screen_cast_stream_src_get_videocrop (src, &crop_rect))
+             {
+-              spa_meta_video_crop->x = crop_rect.x;
+-              spa_meta_video_crop->y = crop_rect.y;
+-              spa_meta_video_crop->width = crop_rect.width;
+-              spa_meta_video_crop->height = crop_rect.height;
++              spa_meta_video_crop->region.position.x = crop_rect.x;
++              spa_meta_video_crop->region.position.y = crop_rect.y;
++              spa_meta_video_crop->region.size.width = crop_rect.width;
++              spa_meta_video_crop->region.size.height = crop_rect.height;
+             }
+           else
+             {
+-              spa_meta_video_crop->x = 0;
+-              spa_meta_video_crop->y = 0;
+-              spa_meta_video_crop->width = priv->stream_width;
+-              spa_meta_video_crop->height = priv->stream_height;
++              spa_meta_video_crop->region.position.x = 0;
++              spa_meta_video_crop->region.position.y = 0;
++              spa_meta_video_crop->region.size.width = priv->stream_width;
++              spa_meta_video_crop->region.size.height = priv->stream_height;
+             }
+         }
+     }
+@@ -555,7 +539,6 @@ on_stream_state_changed (void                 *data,
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  uint32_t node_id;
+
+   switch (state)
+     {
+@@ -563,14 +546,12 @@ on_stream_state_changed (void                 *data,
+       g_warning ("pipewire stream error: %s", error_message);
+       meta_screen_cast_stream_src_notify_closed (src);
+       break;
+-    case PW_STREAM_STATE_CONFIGURE:
+-      node_id = pw_stream_get_node_id (priv->pipewire_stream);
+-      g_signal_emit (src, signals[READY], 0, (unsigned int) node_id);
+-      break;
+-    case PW_STREAM_STATE_UNCONNECTED:
+-    case PW_STREAM_STATE_CONNECTING:
+-    case PW_STREAM_STATE_READY:
+     case PW_STREAM_STATE_PAUSED:
++      if (priv->node_id == SPA_ID_INVALID && priv->pipewire_stream)
++        {
++          priv->node_id = pw_stream_get_node_id (priv->pipewire_stream);
++          g_signal_emit (src, signals[READY], 0, (unsigned int) priv->node_id);
++        }
+       if (meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_disable (src);
+       break;
+@@ -578,68 +559,69 @@ on_stream_state_changed (void                 *data,
+       if (!meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_enable (src);
+       break;
++    case PW_STREAM_STATE_UNCONNECTED:
++    case PW_STREAM_STATE_CONNECTING:
++      break;
+     }
+ }
+
+ static void
+-on_stream_format_changed (void                 *data,
+-                          const struct spa_pod *format)
++on_stream_param_changed (void                 *data,
++                         uint32_t              id,
++                         const struct spa_pod *format)
+ {
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   uint8_t params_buffer[1024];
+   int32_t width, height, stride, size;
+   struct spa_pod_builder pod_builder;
+   const struct spa_pod *params[3];
+   const int bpp = 4;
+
+-  if (!format)
+-    {
+-      pw_stream_finish_format (priv->pipewire_stream, 0, NULL, 0);
+-      return;
+-    }
++  if (!format || id != SPA_PARAM_Format)
++    return;
+
+   spa_format_video_raw_parse (format,
+-                              &priv->video_format,
+-                              &priv->spa_type.format_video);
++                              &priv->video_format);
+
+   width = priv->video_format.size.width;
+   height = priv->video_format.size.height;
+   stride = SPA_ROUND_UP_N (width * bpp, 4);
+   size = height * stride;
+
++  priv->video_stride = stride;
++
+   pod_builder = SPA_POD_BUILDER_INIT (params_buffer, sizeof (params_buffer));
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idBuffers, pipewire_type->param_buffers.Buffers,
+-    ":", pipewire_type->param_buffers.size, "i", size,
+-    ":", pipewire_type->param_buffers.stride, "i", stride,
+-    ":", pipewire_type->param_buffers.buffers, "iru", 16, PROP_RANGE (2, 16),
+-    ":", pipewire_type->param_buffers.align, "i", 16);
+-
+-  params[1] = spa_pod_builder_object (
++    SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
++    SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int (16, 2, 16),
++    SPA_PARAM_BUFFERS_blocks, SPA_POD_Int (1),
++    SPA_PARAM_BUFFERS_size, SPA_POD_Int (size),
++    SPA_PARAM_BUFFERS_stride, SPA_POD_Int (stride),
++    SPA_PARAM_BUFFERS_align, SPA_POD_Int (16));
++
++  params[1] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", pipewire_type->meta.VideoCrop,
+-    ":", pipewire_type->param_meta.size, "i", sizeof (struct spa_meta_video_crop));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_VideoCrop),
++    SPA_PARAM_META_size, SPA_POD_Int (sizeof (struct spa_meta_region)));
+
+-  params[2] = spa_pod_builder_object (
++  params[2] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", priv->spa_type.meta_cursor,
+-    ":", pipewire_type->param_meta.size, "i", CURSOR_META_SIZE (64, 64));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_Cursor),
++    SPA_PARAM_META_size, SPA_POD_Int (CURSOR_META_SIZE (64, 64)));
+
+-  pw_stream_finish_format (priv->pipewire_stream, 0,
+-                           params, G_N_ELEMENTS (params));
++  pw_stream_update_params (priv->pipewire_stream, params, G_N_ELEMENTS (params));
+ }
+
+ static const struct pw_stream_events stream_events = {
+   PW_VERSION_STREAM_EVENTS,
+   .state_changed = on_stream_state_changed,
+-  .format_changed = on_stream_format_changed,
++  .param_changed = on_stream_param_changed,
+ };
+
+ static struct pw_stream *
+@@ -652,8 +634,6 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   uint8_t buffer[1024];
+   struct spa_pod_builder pod_builder =
+     SPA_POD_BUILDER_INIT (buffer, sizeof (buffer));
+-  MetaSpaType *spa_type = &priv->spa_type;
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   float frame_rate;
+   MetaFraction frame_rate_fraction;
+   struct spa_fraction max_framerate;
+@@ -661,7 +641,9 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   const struct spa_pod *params[1];
+   int result;
+
+-  pipewire_stream = pw_stream_new (priv->pipewire_remote,
++  priv->node_id = SPA_ID_INVALID;
++
++  pipewire_stream = pw_stream_new (priv->pipewire_core,
+                                    "meta-screen-cast-src",
+                                    NULL);
+   if (!pipewire_stream)
+@@ -682,17 +664,17 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   max_framerate = SPA_FRACTION (frame_rate_fraction.num,
+                                 frame_rate_fraction.denom);
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idEnumFormat, pipewire_type->spa_format,
+-    "I", spa_type->media_type.video,
+-    "I", spa_type->media_subtype.raw,
+-    ":", spa_type->format_video.format, "I", spa_type->video_format.BGRx,
+-    ":", spa_type->format_video.size, "R", &SPA_RECTANGLE (priv->stream_width,
+-                                                           priv->stream_height),
+-    ":", spa_type->format_video.framerate, "F", &SPA_FRACTION (0, 1),
+-    ":", spa_type->format_video.max_framerate, "Fru", &max_framerate,
+-                                                      PROP_RANGE (&min_framerate,
++    SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
++    SPA_FORMAT_mediaType, SPA_POD_Id (SPA_MEDIA_TYPE_video),
++    SPA_FORMAT_mediaSubtype, SPA_POD_Id (SPA_MEDIA_SUBTYPE_raw),
++    SPA_FORMAT_VIDEO_format, SPA_POD_Id (SPA_VIDEO_FORMAT_BGRx),
++    SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle (&SPA_RECTANGLE (priv->stream_width,
++                                                              priv->stream_height)),
++    SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction (&SPA_FRACTION (0, 1)),
++    SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction (&max_framerate,
++                                                                  &min_framerate,
+                                                                   &max_framerate));
+
+   pw_stream_add_listener (pipewire_stream,
+@@ -702,7 +684,7 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+
+   result = pw_stream_connect (pipewire_stream,
+                               PW_DIRECTION_OUTPUT,
+-                              NULL,
++                              SPA_ID_INVALID,
+                               (PW_STREAM_FLAG_DRIVER |
+                                PW_STREAM_FLAG_MAP_BUFFERS),
+                               params, G_N_ELEMENTS (params));
+@@ -717,40 +699,18 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+ }
+
+ static void
+-on_state_changed (void                 *data,
+-                  enum pw_remote_state  old,
+-                  enum pw_remote_state  state,
+-                  const char           *error_message)
++on_core_error (void       *data,
++               uint32_t    id,
++	       int         seq,
++	       int         res,
++	       const char *message)
+ {
+   MetaScreenCastStreamSrc *src = data;
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_stream *pipewire_stream;
+-  GError *error = NULL;
+
+-  switch (state)
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-      g_warning ("pipewire remote error: %s\n", error_message);
+-      meta_screen_cast_stream_src_notify_closed (src);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pipewire_stream = create_pipewire_stream (src, &error);
+-      if (!pipewire_stream)
+-        {
+-          g_warning ("Could not create pipewire stream: %s", error->message);
+-          g_error_free (error);
+-          meta_screen_cast_stream_src_notify_closed (src);
+-        }
+-      else
+-        {
+-          priv->pipewire_stream = pipewire_stream;
+-        }
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    }
++  g_warning ("pipewire remote error: id:%u %s", id, message);
++
++  if (id == PW_ID_CORE && res == -EPIPE)
++    meta_screen_cast_stream_src_notify_closed (src);
+ }
+
+ static gboolean
+@@ -793,17 +753,6 @@ static GSourceFuncs pipewire_source_funcs =
+   pipewire_loop_source_finalize
+ };
+
+-static void
+-init_spa_type (MetaSpaType         *type,
+-               struct spa_type_map *map)
+-{
+-  spa_type_media_type_map (map, &type->media_type);
+-  spa_type_media_subtype_map (map, &type->media_subtype);
+-  spa_type_format_video_map (map, &type->format_video);
+-  spa_type_video_format_map (map, &type->video_format);
+-  type->meta_cursor = spa_type_map_get_id(map, SPA_TYPE_META__Cursor);
+-}
+-
+ static MetaPipeWireSource *
+ create_pipewire_source (void)
+ {
+@@ -829,9 +778,9 @@ create_pipewire_source (void)
+   return pipewire_source;
+ }
+
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = on_core_error,
+ };
+
+ static gboolean
+@@ -851,37 +800,31 @@ meta_screen_cast_stream_src_initable_init (GInitable     *initable,
+       return FALSE;
+     }
+
+-  priv->pipewire_core = pw_core_new (priv->pipewire_source->pipewire_loop,
+-                                     NULL);
+-  if (!priv->pipewire_core)
++  priv->pipewire_context = pw_context_new (priv->pipewire_source->pipewire_loop,
++                                           NULL, 0);
++  if (!priv->pipewire_context)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Failed to create pipewire core");
++                   "Failed to create pipewire context");
+       return FALSE;
+     }
+
+-  priv->pipewire_remote = pw_remote_new (priv->pipewire_core, NULL, 0);
+-  if (!priv->pipewire_remote)
++  priv->pipewire_core = pw_context_connect (priv->pipewire_context, NULL, 0);
++  if (!priv->pipewire_core)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't creat pipewire remote");
++                   "Couldn't connect pipewire context");
+       return FALSE;
+     }
+
+-  pw_remote_add_listener (priv->pipewire_remote,
+-                          &priv->pipewire_remote_listener,
+-                          &remote_events,
+-                          src);
++  pw_core_add_listener (priv->pipewire_core,
++                        &priv->pipewire_core_listener,
++                        &core_events,
++                        src);
+
+-  priv->pipewire_type = pw_core_get_type (priv->pipewire_core);
+-  init_spa_type (&priv->spa_type, priv->pipewire_type->map);
+-
+-  if (pw_remote_connect (priv->pipewire_remote) != 0)
+-    {
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect pipewire remote");
+-      return FALSE;
+-    }
++  priv->pipewire_stream = create_pipewire_stream (src, error);
++  if (!priv->pipewire_stream)
++    return FALSE;
+
+   return TRUE;
+ }
+@@ -912,8 +855,8 @@ meta_screen_cast_stream_src_finalize (GObject *object)
+     meta_screen_cast_stream_src_disable (src);
+
+   g_clear_pointer (&priv->pipewire_stream, pw_stream_destroy);
+-  g_clear_pointer (&priv->pipewire_remote, pw_remote_destroy);
+-  g_clear_pointer (&priv->pipewire_core, pw_core_destroy);
++  g_clear_pointer (&priv->pipewire_core, pw_core_disconnect);
++  g_clear_pointer (&priv->pipewire_context, pw_context_destroy);
+   g_source_destroy (&priv->pipewire_source->base);
+
+   G_OBJECT_CLASS (meta_screen_cast_stream_src_parent_class)->finalize (object);
diff --git a/srcpkgs/mutter/template b/srcpkgs/mutter/template
index 4e0bd32b67d..806a3bef9f0 100644
--- a/srcpkgs/mutter/template
+++ b/srcpkgs/mutter/template
@@ -1,7 +1,7 @@
 # Template file for 'mutter'
 pkgname=mutter
 version=3.34.1
-revision=2
+revision=3
 build_helper="gir"
 build_style=meson
 configure_args="-Degl_device=true -Dudev=true -Dnative_backend=true

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PR PATCH] [Updated] pipewire: update to 0.3.4
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (25 preceding siblings ...)
  2020-04-30 20:52 ` sirn
@ 2020-04-30 21:02 ` sirn
  2020-04-30 21:07 ` sirn
                   ` (24 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-04-30 21:02 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 785 bytes --]

There is an updated pull request by sirn against master on the void-packages repository

https://github.com/sirn/void-packages pipewire-update
https://github.com/void-linux/void-packages/pull/20413

pipewire: update to 0.3.4
This PR updates `pipewire` to 0.3.4 and also updating/patching all packages that depends on it. 

* `xdg-desktop-portal` includes a patch backported from 1.7.0 to allow 1.6.0 to build against pipewire-0.3 (1.7.x is prerelease)
* `xdg-desktop-portal-kde` already includes Pipewire 0.3 support and only requires revbump.
* `mutter` includes a patch backported from 3.35 to allow 3.34 to build against pipewire-0.3 (upgrading to >=3.35 also requires upgrading GNOME).

A patch file from https://github.com/void-linux/void-packages/pull/20413.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pipewire-update-20413.patch --]
[-- Type: text/x-diff, Size: 51037 bytes --]

From a1048b9de261a2c421a781b7178e598e67918f85 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:23:52 +0900
Subject: [PATCH 1/4] pipewire: update to 0.3.4

---
 common/shlibs                  |  2 +-
 srcpkgs/alsa-pipewire          |  1 +
 srcpkgs/libjack-pipewire       |  1 +
 srcpkgs/libpulseaudio-pipewire |  1 +
 srcpkgs/pipewire/template      | 76 ++++++++++++++++++++++++++--------
 5 files changed, 63 insertions(+), 18 deletions(-)
 create mode 120000 srcpkgs/alsa-pipewire
 create mode 120000 srcpkgs/libjack-pipewire
 create mode 120000 srcpkgs/libpulseaudio-pipewire

diff --git a/common/shlibs b/common/shlibs
index a208407b359..07279a7bc72 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3199,7 +3199,7 @@ libarcan_shmif_ext.so.0.11 arcan-0.5.4.3_1
 libarcan_shmif_server.so.0.11 arcan-0.5.4.3_1
 libarcan_tui.so.0.11 arcan-0.5.4.3_1
 liblwipv6.so.2 lwipv6-1.5a_1
-libpipewire-0.2.so.1 libpipewire-0.2.2_1
+libpipewire-0.3.so.0 libpipewire-0.3.4_1
 libvolk.so.2.2.1 volk-2.2.1_1
 libgnuradio-runtime.so.3.8.0 gnuradio-3.8.0.0_1
 libgnuradio-pmt.so.3.8.0 gnuradio-3.8.0.0_1
diff --git a/srcpkgs/alsa-pipewire b/srcpkgs/alsa-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/alsa-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libjack-pipewire b/srcpkgs/libjack-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libjack-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libpulseaudio-pipewire b/srcpkgs/libpulseaudio-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libpulseaudio-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/pipewire/template b/srcpkgs/pipewire/template
index 7f646dad11d..d975c40d81d 100644
--- a/srcpkgs/pipewire/template
+++ b/srcpkgs/pipewire/template
@@ -1,26 +1,42 @@
 # Template file for 'pipewire'
 pkgname=pipewire
-version=0.2.7
+version=0.3.4
 revision=1
 build_style=meson
-configure_args="-Dman=true -Dgstreamer=enabled -Ddocs=true -Dsystemd=false"
+configure_args="-Dman=true -Dgstreamer=true -Ddocs=true -Dsystemd=false
+ -Dbluez5=true -Dffmpeg=true -Dpipewire-alsa=true -Dpipewire-jack=true
+ -Dpipewire-pulseaudio=true"
 hostmakedepends="doxygen graphviz pkg-config xmltoman"
 makedepends="SDL2-devel ffmpeg-devel gst-plugins-base1-devel jack-devel
- sbc-devel v4l-utils-devel libva-devel"
+ sbc-devel v4l-utils-devel libva-devel libbluetooth-devel"
 short_desc="Server and user space API to deal with multimedia pipelines"
 maintainer="Orphaned <orphan@voidlinux.org>"
-#Next release will probably change to MIT, currently listed in master
-license="LGPL-2.1-only, GPL-2.0-only "
+license="MIT"
 homepage="https://pipewire.org/"
-changelog="https://raw.githubusercontent.com/PipeWire/pipewire/master/NEWS"
-distfiles="https://github.com/PipeWire/pipewire/archive/${version}.tar.gz"
-checksum=bfaa0f6ae6c0791e2e0b59234d399753bf24f1b33dbf587682363a8463dd8df1
+changelog="https://gitlab.freedesktop.org/pipewire/pipewire/-/raw/master/NEWS"
+distfiles="https://gitlab.freedesktop.org/pipewire/pipewire/-/archive/${version}/pipewire-${version}.tar.gz"
+checksum=6a1c9c671514c84b38ce96d51823354702bc4d5dbaba12d501faa0448f892515
 conf_files="/etc/pipewire/pipewire.conf"
 
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+	LDFLAGS+=" -latomic"
+fi
+
+post_install() {
+	vlicense LICENSE
+}
+
+post_patch() {
+	# https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/233
+	vsed -i meson.build -e 's|.*-Werror=suggest-attribute=format.*||g'
+}
+
 libpipewire_package() {
 	short_desc+=" - pipewire library"
 	pkg_install() {
-		vmove "usr/lib/libpipewire-0.2.so.*"
+		vmove "usr/lib/libpipewire-0.3.so.*"
+		vmove "usr/lib/pipewire-0.3/*.so"
 	}
 }
 
@@ -28,25 +44,25 @@ pipewire-devel_package() {
 	depends="libpipewire-${version}_${revision}"
 	short_desc+=" - pipewire and libspa development files"
 	pkg_install() {
-		vmove usr/include/pipewire
-		vmove usr/include/spa
-		vmove usr/lib/pkgconfig/libpipewire-0.2.pc
-		vmove usr/lib/pkgconfig/libspa-0.1.pc
-		vmove usr/lib/libpipewire-0.2.so
+		vmove usr/include/pipewire-0.3
+		vmove usr/include/spa-0.2
+		vmove usr/lib/pkgconfig/libpipewire-0.3.pc
+		vmove usr/lib/pkgconfig/libspa-0.2.pc
+                vmove usr/lib/libpipewire-0.3.so
 	}
 }
 
 libspa-ffmpeg_package() {
 	short_desc+=" - ffmpeg plugins"
 	pkg_install() {
-		vmove usr/lib/spa/ffmpeg
+		vmove usr/lib/spa-0.2/ffmpeg
 	}
 }
 
 libspa-bluetooth_package() {
 	short_desc+=" - bluetooth plugins"
 	pkg_install() {
-		vmove usr/lib/spa/bluez5
+		vmove usr/lib/spa-0.2/bluez5
 	}
 }
 
@@ -57,10 +73,36 @@ gstreamer1-pipewire_package() {
 	}
 }
 
+libpulseaudio-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - PulseAudio client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/pulse
+		vmove usr/bin/pw-pulse
+	}
+}
+
+alsa-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - ALSA client library"
+	pkg_install() {
+		vmove usr/lib/alsa-lib
+	}
+}
+
+libjack-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - JACK client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/jack
+		vmove usr/bin/pw-jack
+	}
+}
+
 pipewire-doc_package() {
 	archs=noarch
 	short_desc+=" - documentation"
 	pkg_install() {
 		vmove usr/share/doc
 	}
-}
+}
\ No newline at end of file

From 0e5566fcec7ac6eababcceba689b66a5b8341ff9 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:46 +0900
Subject: [PATCH 2/4] xdg-desktop-portal-kde: rebuild for pipewire-0.3

---
 srcpkgs/xdg-desktop-portal-kde/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xdg-desktop-portal-kde/template b/srcpkgs/xdg-desktop-portal-kde/template
index f26057d323a..9519abc19f6 100644
--- a/srcpkgs/xdg-desktop-portal-kde/template
+++ b/srcpkgs/xdg-desktop-portal-kde/template
@@ -1,7 +1,7 @@
 # Template file for 'xdg-desktop-portal-kde'
 pkgname=xdg-desktop-portal-kde
 version=5.18.4.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules qt5-qmake qt5-host-tools kcoreaddons gettext"
 makedepends="glib-devel kio-devel kwayland-devel libepoxy-devel pipewire-devel

From 765c1fc4dd64865b7b01a9ec782ca682863ce82f Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:26 +0900
Subject: [PATCH 3/4] xdg-desktop-portal: rebuild for pipewire-0.3

---
 .../patches/pipewire-0.3.patch                | 551 ++++++++++++++++++
 srcpkgs/xdg-desktop-portal/template           |   8 +-
 2 files changed, 557 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch

diff --git a/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..94ebe083598
--- /dev/null
+++ b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
@@ -0,0 +1,551 @@
+From a38901e5e7f835efe7b7a06c55790c8c20bc91a2 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Tue, 14 Jan 2020 09:37:09 +0100
+Subject: [PATCH] PipeWire: update to 0.3 API
+
+---
+ configure.ac      |   2 +-
+ src/camera.c      |  24 ++++----
+ src/pipewire.c    | 141 +++++++++++++---------------------------------
+ src/pipewire.h    |  10 ++--
+ src/screen-cast.c |  98 ++++++--------------------------
+ 5 files changed, 72 insertions(+), 203 deletions(-)
+
+diff --git configure.ac configure.ac
+index 89902fa..62d7960 100644
+--- configure.ac
++++ configure.ac
+@@ -97,7 +97,7 @@ AC_ARG_ENABLE(pipewire,
+ 	      [AS_HELP_STRING([--enable-pipewire],[Enable PipeWire support. Needed for screen cast portal])],
+ 	      enable_pipewire=$enableval, enable_pipewire=yes)
+ if test x$enable_pipewire = xyes ; then
+-	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.2 >= 0.2.6])
++	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.3 >= 0.2.90])
+ 	AC_DEFINE([HAVE_PIPEWIRE],[1], [Define to enable PipeWire support])
+ fi
+ AM_CONDITIONAL([HAVE_PIPEWIRE],[test "$enable_pipewire" = "yes"])
+diff --git src/camera.c src/camera.c
+index c2b392c..20fe3aa 100644
+--- src/camera.c
++++ src/camera.c
+@@ -141,7 +141,7 @@ open_pipewire_camera_remote (const char *app_id,
+                              GError **error)
+ {
+   PipeWireRemote *remote;
+-  struct spa_dict_item permission_items[1];
++  struct pw_permission permission_items[2];
+   struct pw_properties *pipewire_properties;
+ 
+   pipewire_properties =
+@@ -158,12 +158,12 @@ open_pipewire_camera_remote (const char *app_id,
+    * Hide all existing and future nodes by default. PipeWire will use the
+    * permission store to set up permissions.
+    */
+-  permission_items[0].key = PW_CORE_PROXY_PERMISSIONS_DEFAULT;
+-  permission_items[0].value = "---";
++  permission_items[0] = PW_PERMISSION_INIT (PW_ID_CORE, PW_PERM_RWX);
++  permission_items[1] = PW_PERMISSION_INIT (PW_ID_ANY, 0);
+ 
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             &SPA_DICT_INIT (permission_items,
+-                                             G_N_ELEMENTS (permission_items)));
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                G_N_ELEMENTS (permission_items),
++                                permission_items);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -219,7 +219,7 @@ handle_open_pipewire_remote (XdpCamera *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
+@@ -250,29 +250,28 @@ camera_iface_init (XdpCameraIface *iface)
+ static void
+ global_added_cb (PipeWireRemote *remote,
+                  uint32_t id,
+-                 uint32_t type,
++                 const char *type,
+                  const struct spa_dict *props,
+                  gpointer user_data)
+ {
+   Camera *camera = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *media_class;
+   const struct spa_dict_item *media_role;
+ 
+-  if (type != core_type->node)
++  if (strcmp(type, PW_TYPE_INTERFACE_Node) != 0)
+     return;
+ 
+   if (!props)
+     return;
+ 
+-  media_class = spa_dict_lookup_item (props, "media.class");
++  media_class = spa_dict_lookup_item (props, PW_KEY_MEDIA_CLASS);
+   if (!media_class)
+     return;
+ 
+   if (g_strcmp0 (media_class->value, "Video/Source") != 0)
+     return;
+ 
+-  media_role = spa_dict_lookup_item (props, "media.role");
++  media_role = spa_dict_lookup_item (props, PW_KEY_MEDIA_ROLE);
+   if (!media_role)
+     return;
+ 
+@@ -342,6 +341,7 @@ create_pipewire_remote (Camera *camera,
+     }
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.is_portal", "true",
++                                           "portal.monitor", "Camera",
+                                            NULL);
+   camera->pipewire_remote = pipewire_remote_new_sync (pipewire_properties,
+                                                       global_added_cb,
+diff --git src/pipewire.c src/pipewire.c
+index 793a378..162cd55 100644
+--- src/pipewire.c
++++ src/pipewire.c
+@@ -21,6 +21,7 @@
+ #include <errno.h>
+ #include <glib.h>
+ #include <pipewire/pipewire.h>
++#include <spa/utils/result.h>
+ 
+ #include "pipewire.h"
+ 
+@@ -36,27 +37,25 @@ static gboolean is_pipewire_initialized = FALSE;
+ static void
+ registry_event_global (void *user_data,
+                        uint32_t id,
+-                       uint32_t parent_id,
+                        uint32_t permissions,
+-                       uint32_t type,
++                       const char *type,
+                        uint32_t version,
+                        const struct spa_dict *props)
+ {
+   PipeWireRemote *remote = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *factory_object_type;
+   PipeWireGlobal *global;
+ 
+   global = g_new0 (PipeWireGlobal, 1);
+   *global = (PipeWireGlobal) {
+-    .parent_id = parent_id,
++    .parent_id = id,
+   };
+ 
+   g_hash_table_insert (remote->globals, GINT_TO_POINTER (id), global);
+   if (remote->global_added_cb)
+     remote->global_added_cb (remote, id, type, props, remote->user_data);
+ 
+-  if (type != core_type->factory)
++  if (strcmp(type, PW_TYPE_INTERFACE_Factory) != 0)
+     return;
+ 
+   factory_object_type = spa_dict_lookup_item (props, "factory.type.name");
+@@ -81,8 +80,8 @@ registry_event_global_remove (void *user_data,
+   g_hash_table_remove (remote->globals, GINT_TO_POINTER (id));
+ }
+ 
+-static const struct pw_registry_proxy_events registry_events = {
+-  PW_VERSION_REGISTRY_PROXY_EVENTS,
++static const struct pw_registry_events registry_events = {
++  PW_VERSION_REGISTRY_EVENTS,
+   .global = registry_event_global,
+   .global_remove = registry_event_global_remove,
+ };
+@@ -90,7 +89,7 @@ static const struct pw_registry_proxy_events registry_events = {
+ void
+ pipewire_remote_roundtrip (PipeWireRemote *remote)
+ {
+-  pw_core_proxy_sync (remote->core_proxy, ++remote->sync_seq);
++  remote->sync_seq = pw_core_sync (remote->core, PW_ID_CORE, remote->sync_seq);
+   pw_main_loop_run (remote->loop);
+ }
+ 
+@@ -98,16 +97,13 @@ static gboolean
+ discover_node_factory_sync (PipeWireRemote *remote,
+                             GError **error)
+ {
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+-  struct pw_registry_proxy *registry_proxy;
++  struct pw_registry *registry;
+ 
+-  registry_proxy = pw_core_proxy_get_registry (remote->core_proxy,
+-                                               core_type->registry,
+-                                               PW_VERSION_REGISTRY, 0);
+-  pw_registry_proxy_add_listener (registry_proxy,
+-                                  &remote->registry_listener,
+-                                  &registry_events,
+-                                  remote);
++  registry = pw_core_get_registry (remote->core, PW_VERSION_REGISTRY, 0);
++  pw_registry_add_listener (registry,
++                            &remote->registry_listener,
++                            &registry_events,
++                            remote);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -122,59 +118,35 @@ discover_node_factory_sync (PipeWireRemote *remote,
+ }
+ 
+ static void
+-on_state_changed (void *user_data,
+-                  enum pw_remote_state old,
+-                  enum pw_remote_state state,
+-                  const char *error)
++core_event_error (void       *user_data,
++                  uint32_t    id,
++		  int         seq,
++		  int         res,
++		  const char *message)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  switch (state)
++  if (id == PW_ID_CORE)
+     {
+-    case PW_REMOTE_STATE_ERROR:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "%s", error);
+-        }
++      g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
++                 "%s", message);
+       pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "Disconnected");
+-        }
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    default:
+-      g_warning ("Unknown PipeWire state");
+-      break;
+     }
+ }
+ 
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
+-};
+-
+ static void
+ core_event_done (void *user_data,
+-                 uint32_t seq)
++                 uint32_t id, int seq)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  if (remote->sync_seq == seq)
++  if (id == PW_ID_CORE && remote->sync_seq == seq)
+     pw_main_loop_quit (remote->loop);
+ }
+ 
+-static const struct pw_core_proxy_events core_events = {
+-  PW_VERSION_CORE_PROXY_EVENTS,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = core_event_error,
+   .done = core_event_done,
+ };
+ 
+@@ -237,8 +209,8 @@ void
+ pipewire_remote_destroy (PipeWireRemote *remote)
+ {
+   g_clear_pointer (&remote->globals, g_hash_table_destroy);
+-  g_clear_pointer (&remote->remote, pw_remote_destroy);
+-  g_clear_pointer (&remote->core, pw_core_destroy);
++  g_clear_pointer (&remote->core, pw_core_disconnect);
++  g_clear_pointer (&remote->context, pw_context_destroy);
+   g_clear_pointer (&remote->loop, pw_main_loop_destroy);
+   g_clear_error (&remote->error);
+ 
+@@ -307,68 +279,31 @@ pipewire_remote_new_sync (struct pw_properties *pipewire_properties,
+       return NULL;
+     }
+ 
+-  remote->core = pw_core_new (pw_main_loop_get_loop (remote->loop), NULL);
+-  if (!remote->core)
++  remote->context = pw_context_new (pw_main_loop_get_loop (remote->loop), NULL, 0);
++  if (!remote->context)
+     {
+       pipewire_remote_destroy (remote);
+       pw_properties_free (pipewire_properties);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire core");
++                   "Couldn't create PipeWire context");
+       return NULL;
+     }
+ 
+-  remote->remote = pw_remote_new (remote->core, pipewire_properties, 0);
+-  if (!remote->remote)
++  remote->core = pw_context_connect (remote->context, pipewire_properties, 0);
++  if (!remote->core)
+     {
+       pipewire_remote_destroy (remote);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire remote");
++                   "Couldn't connect to PipeWire");
+       return NULL;
+     }
+ 
+   remote->globals = g_hash_table_new_full (NULL, NULL, NULL, g_free);
+ 
+-  pw_remote_add_listener (remote->remote,
+-                          &remote->remote_listener,
+-                          &remote_events,
+-                          remote);
+-
+-  if (pw_remote_connect (remote->remote) != 0)
+-    {
+-      pipewire_remote_destroy (remote);
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect PipeWire remote");
+-      return NULL;
+-    }
+-
+-  pw_main_loop_run (remote->loop);
+-
+-  switch (pw_remote_get_state (remote->remote, NULL))
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      *error = g_steal_pointer (&remote->error);
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "PipeWire loop stopped unexpectedly");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      break;
+-    default:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Unexpected PipeWire state");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    }
+-
+-  remote->core_proxy = pw_remote_get_core_proxy (remote->remote);
+-  pw_core_proxy_add_listener (remote->core_proxy,
+-                              &remote->core_listener,
+-                              &core_events,
+-                              remote);
++  pw_core_add_listener (remote->core,
++                        &remote->core_listener,
++                        &core_events,
++                        remote);
+ 
+   if (!discover_node_factory_sync (remote, error))
+     {
+diff --git src/pipewire.h src/pipewire.h
+index 0f1bf54..bf48d5e 100644
+--- src/pipewire.h
++++ src/pipewire.h
+@@ -32,7 +32,7 @@ typedef struct _PipeWireGlobal
+ 
+ typedef void (* PipeWireGlobalAddedCallback) (PipeWireRemote *remote,
+                                               uint32_t id,
+-                                              uint32_t type,
++                                              const char *type,
+                                               const struct spa_dict *props,
+                                               gpointer user_data);
+ 
+@@ -43,13 +43,11 @@ typedef void (* PipeWireGlobalRemovedCallback) (PipeWireRemote *remote,
+ struct _PipeWireRemote
+ {
+   struct pw_main_loop *loop;
++  struct pw_context *context;
+   struct pw_core *core;
+-  struct pw_remote *remote;
+-  struct spa_hook remote_listener;
+-
+-  struct pw_core_proxy *core_proxy;
+   struct spa_hook core_listener;
+-  uint32_t sync_seq;
++
++  int sync_seq;
+ 
+   struct spa_hook registry_listener;
+ 
+diff --git src/screen-cast.c src/screen-cast.c
+index 7881ddc..1677050 100644
+--- src/screen-cast.c
++++ src/screen-cast.c
+@@ -31,10 +31,10 @@
+ #include "xdp-impl-dbus.h"
+ #include "xdp-utils.h"
+ 
+-#define PERMISSION_ITEM(item_key, item_value) \
+-  ((struct spa_dict_item) { \
+-    .key = item_key, \
+-    .value = item_value \
++#define PERMISSION_ITEM(item_id, item_permissions) \
++  ((struct pw_permission) { \
++    .id = item_id, \
++    .permissions = item_permissions \
+   })
+ 
+ typedef struct _ScreenCast ScreenCast;
+@@ -517,42 +517,9 @@ screen_cast_stream_get_pipewire_node_id (ScreenCastStream *stream)
+   return stream->id;
+ }
+ 
+-static void
+-append_parent_permissions (PipeWireRemote *remote,
+-                           GArray *permission_items,
+-                           GList **string_stash,
+-                           PipeWireGlobal *global,
+-                           const char *permission)
+-{
+-  PipeWireGlobal *parent;
+-  char *parent_permission_value;
+-
+-  if (global->parent_id == 0)
+-    return;
+-
+-  parent = g_hash_table_lookup (remote->globals, GINT_TO_POINTER (global->parent_id));
+-
+-  if (parent->permission_set)
+-    return;
+-  parent->permission_set = TRUE;
+-
+-  append_parent_permissions (remote, permission_items, string_stash,
+-                             parent, permission);
+-
+-  parent_permission_value = g_strdup_printf ("%u:%s",
+-                                             global->parent_id,
+-                                             permission);
+-  *string_stash = g_list_prepend (*string_stash, parent_permission_value);
+-
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       parent_permission_value));
+-}
+-
+ static void
+ append_stream_permissions (PipeWireRemote *remote,
+                            GArray *permission_items,
+-                           GList **string_stash,
+                            GList *streams)
+ {
+   GList *l;
+@@ -561,21 +528,10 @@ append_stream_permissions (PipeWireRemote *remote,
+     {
+       ScreenCastStream *stream = l->data;
+       uint32_t stream_id;
+-      PipeWireGlobal *stream_global;
+-      char *stream_permission_value;
+ 
+       stream_id = screen_cast_stream_get_pipewire_node_id (stream);
+-      stream_global = g_hash_table_lookup (remote->globals,
+-                                           GINT_TO_POINTER (stream_id));
+-
+-      append_parent_permissions (remote, permission_items, string_stash,
+-                                 stream_global, "r--");
+-
+-      stream_permission_value = g_strdup_printf ("%u:rwx", stream_id);
+-      *string_stash = g_list_prepend (*string_stash, stream_permission_value);
+       g_array_append_val (permission_items,
+-                          PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                           stream_permission_value));
++                          PERMISSION_ITEM (stream_id, PW_PERM_RWX));
+     }
+ }
+ 
+@@ -587,9 +543,6 @@ open_pipewire_screen_cast_remote (const char *app_id,
+   struct pw_properties *pipewire_properties;
+   PipeWireRemote *remote;
+   g_autoptr(GArray) permission_items = NULL;
+-  char *node_factory_permission_string;
+-  GList *string_stash = NULL;
+-  struct spa_dict *permission_dict;
+   PipeWireGlobal *node_global;
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.app_id", app_id,
+@@ -603,48 +556,31 @@ open_pipewire_screen_cast_remote (const char *app_id,
+ 
+   permission_items = g_array_new (FALSE, TRUE, sizeof (struct spa_dict_item));
+ 
+-  /*
+-   * Hide all existing and future nodes (except the ones we explicitly list below.
+-   */
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_EXISTING,
+-                                       "---"));
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_DEFAULT,
+-                                       "---"));
+-
+   /*
+    * PipeWire:Interface:Core
+    * Needs rwx to be able create the sink node using the create-object method
+    */
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       "0:rwx"));
++                      PERMISSION_ITEM (PW_ID_CORE, PW_PERM_RWX));
+ 
+   /*
+    * PipeWire:Interface:NodeFactory
+    * Needs r-- so it can be passed to create-object when creating the sink node.
+    */
+-  node_factory_permission_string = g_strdup_printf ("%d:r--",
+-                                                    remote->node_factory_id);
+-  string_stash = g_list_prepend (string_stash, node_factory_permission_string);
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       node_factory_permission_string));
+-  node_global = g_hash_table_lookup (remote->globals,
+-                                     GINT_TO_POINTER (remote->node_factory_id));
+-  append_parent_permissions (remote, permission_items, &string_stash,
+-                             node_global, "r--");
++                      PERMISSION_ITEM (remote->node_factory_id, PW_PERM_R));
+ 
+-  append_stream_permissions (remote, permission_items, &string_stash, streams);
++  append_stream_permissions (remote, permission_items, streams);
+ 
+-  permission_dict =
+-    &SPA_DICT_INIT ((struct spa_dict_item *) permission_items->data,
+-                    permission_items->len);
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             permission_dict);
++  /*
++   * Hide all existing and future nodes (except the ones we explicitly list above).
++   */
++  g_array_append_val (permission_items,
++                      PERMISSION_ITEM (PW_ID_ANY, 0));
+ 
+-  g_list_free_full (string_stash, g_free);
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                permission_items->len,
++                                (const struct pw_permission *)permission_items->data);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -943,7 +879,7 @@ handle_open_pipewire_remote (XdpScreenCast *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
diff --git a/srcpkgs/xdg-desktop-portal/template b/srcpkgs/xdg-desktop-portal/template
index eb8a4602f5d..1136b6a6e0e 100644
--- a/srcpkgs/xdg-desktop-portal/template
+++ b/srcpkgs/xdg-desktop-portal/template
@@ -1,10 +1,10 @@
 # Template file for 'xdg-desktop-portal'
 pkgname=xdg-desktop-portal
 version=1.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-pipewire --enable-geoclue --disable-libportal"
-hostmakedepends="pkg-config glib-devel"
+hostmakedepends="automake libtool gettext-devel pkg-config glib-devel"
 makedepends="flatpak-devel fuse-devel pipewire-devel geoclue2-devel"
 short_desc="Portal frontend service for Flatpak"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -13,6 +13,10 @@ homepage="https://github.com/flatpak/xdg-desktop-portal"
 distfiles="https://github.com/flatpak/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.xz"
 checksum=883c9c9a925e48af54812b5347f546dd776ec2e27076a83d5a8126af6bafb9da
 
+pre_configure() {
+	autoreconf -vfi
+}
+
 post_install() {
 	rm -rf "${DESTDIR}/usr/lib/systemd"
 }

From e9ffc3b878df2ad44ea79fa364ba215f18b3f576 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Thu, 30 Apr 2020 06:17:17 +0900
Subject: [PATCH 4/4] mutter: rebuild for pipewire-0.3

---
 srcpkgs/mutter/patches/pipewire-0.3.patch | 521 ++++++++++++++++++++++
 srcpkgs/mutter/template                   |   2 +-
 2 files changed, 522 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/mutter/patches/pipewire-0.3.patch

diff --git a/srcpkgs/mutter/patches/pipewire-0.3.patch b/srcpkgs/mutter/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..ebff65fba85
--- /dev/null
+++ b/srcpkgs/mutter/patches/pipewire-0.3.patch
@@ -0,0 +1,521 @@
+Build mutter against pipewire-0.3, based on a patch at:
+https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1062
+--- meson.build
++++ meson.build
+@@ -50,7 +50,7 @@ libinput_req = '>= 1.7'
+ gbm_req = '>= 10.3'
+
+ # screen cast version requirements
+-libpipewire_req = '>= 0.2.5'
++libpipewire_req = '>= 0.3.0'
+
+ gnome = import('gnome')
+ pkg = import('pkgconfig')
+@@ -241,7 +241,7 @@ endif
+
+ have_remote_desktop = get_option('remote_desktop')
+ if have_remote_desktop
+-  libpipewire_dep = dependency('libpipewire-0.2', version: libpipewire_req)
++  libpipewire_dep = dependency('libpipewire-0.3', version: libpipewire_req)
+ endif
+
+ have_introspection = get_option('introspection')
+diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
+index 82c5cba436..ba1ce94a7e 100644
+--- src/backends/meta-screen-cast-stream-src.c
++++ src/backends/meta-screen-cast-stream-src.c
+@@ -29,6 +29,7 @@
+ #include <spa/param/props.h>
+ #include <spa/param/format-utils.h>
+ #include <spa/param/video/format-utils.h>
++#include <spa/utils/result.h>
+ #include <stdint.h>
+ #include <sys/mman.h>
+
+@@ -62,15 +63,6 @@ enum
+
+ static guint signals[N_SIGNALS];
+
+-typedef struct _MetaSpaType
+-{
+-  struct spa_type_media_type media_type;
+-  struct spa_type_media_subtype media_subtype;
+-  struct spa_type_format_video format_video;
+-  struct spa_type_video_format video_format;
+-  uint32_t meta_cursor;
+-} MetaSpaType;
+-
+ typedef struct _MetaPipeWireSource
+ {
+   GSource base;
+@@ -82,19 +74,19 @@ typedef struct _MetaScreenCastStreamSrcPrivate
+ {
+   MetaScreenCastStream *stream;
+
++  struct pw_context *pipewire_context;
+   struct pw_core *pipewire_core;
+-  struct pw_remote *pipewire_remote;
+-  struct pw_type *pipewire_type;
+   MetaPipeWireSource *pipewire_source;
+-  struct spa_hook pipewire_remote_listener;
++  struct spa_hook pipewire_core_listener;
+
+   gboolean is_enabled;
+
+   struct pw_stream *pipewire_stream;
+   struct spa_hook pipewire_stream_listener;
++  uint32_t node_id;
+
+-  MetaSpaType spa_type;
+   struct spa_video_info_raw video_format;
++  int video_stride;
+
+   uint64_t last_frame_timestamp_us;
+
+@@ -112,8 +104,6 @@ G_DEFINE_TYPE_WITH_CODE (MetaScreenCastStreamSrc,
+                                                 meta_screen_cast_stream_src_init_initable_iface)
+                          G_ADD_PRIVATE (MetaScreenCastStreamSrc))
+
+-#define PROP_RANGE(min, max) 2, (min), (max)
+-
+ static void
+ meta_screen_cast_stream_src_get_specs (MetaScreenCastStreamSrc *src,
+                                        int                     *width,
+@@ -286,9 +276,6 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+                                                               int                      x,
+                                                               int                      y)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+
+   spa_meta_cursor->id = 1;
+@@ -300,7 +287,7 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   spa_meta_cursor->hotspot.x = 0;
+@@ -317,9 +304,6 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+                                                         int                      y,
+                                                         float                    scale)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   CoglTexture *cursor_texture;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+   int hotspot_x, hotspot_y;
+@@ -346,7 +330,7 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
+@@ -382,12 +366,10 @@ static void
+ add_cursor_metadata (MetaScreenCastStreamSrc *src,
+                      struct spa_buffer       *spa_buffer)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_cursor *spa_meta_cursor;
+
+-  spa_meta_cursor = spa_buffer_find_meta (spa_buffer, spa_type->meta_cursor);
++  spa_meta_cursor = spa_buffer_find_meta_data (spa_buffer, SPA_META_Cursor,
++                                               sizeof (*spa_meta_cursor));
+   if (spa_meta_cursor)
+     meta_screen_cast_stream_src_set_cursor_metadata (src, spa_meta_cursor);
+ }
+@@ -447,14 +429,14 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+     {
+       data = spa_buffer->datas[0].data;
+     }
+-  else if (spa_buffer->datas[0].type == priv->pipewire_type->data.MemFd)
++  else if (spa_buffer->datas[0].type == SPA_DATA_MemFd)
+     {
+       map = mmap (NULL, spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset,
+                   PROT_READ | PROT_WRITE, MAP_SHARED,
+                   spa_buffer->datas[0].fd, 0);
+       if (map == MAP_FAILED)
+         {
+-          g_warning ("Failed to mmap pipewire stream buffer: %s\n",
++          g_warning ("Failed to mmap pipewire stream buffer: %s",
+                      strerror (errno));
+           return;
+         }
+@@ -469,28 +451,30 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+
+   if (meta_screen_cast_stream_src_record_frame (src, data))
+     {
+-      struct spa_meta_video_crop *spa_meta_video_crop;
++      struct spa_meta_region *spa_meta_video_crop;
+
+       spa_buffer->datas[0].chunk->size = spa_buffer->datas[0].maxsize;
++      spa_buffer->datas[0].chunk->stride = priv->video_stride;
+
+       /* Update VideoCrop if needed */
+       spa_meta_video_crop =
+-        spa_buffer_find_meta (spa_buffer, priv->pipewire_type->meta.VideoCrop);
++        spa_buffer_find_meta_data (spa_buffer, SPA_META_VideoCrop,
++                                   sizeof (*spa_meta_video_crop));
+       if (spa_meta_video_crop)
+         {
+           if (meta_screen_cast_stream_src_get_videocrop (src, &crop_rect))
+             {
+-              spa_meta_video_crop->x = crop_rect.x;
+-              spa_meta_video_crop->y = crop_rect.y;
+-              spa_meta_video_crop->width = crop_rect.width;
+-              spa_meta_video_crop->height = crop_rect.height;
++              spa_meta_video_crop->region.position.x = crop_rect.x;
++              spa_meta_video_crop->region.position.y = crop_rect.y;
++              spa_meta_video_crop->region.size.width = crop_rect.width;
++              spa_meta_video_crop->region.size.height = crop_rect.height;
+             }
+           else
+             {
+-              spa_meta_video_crop->x = 0;
+-              spa_meta_video_crop->y = 0;
+-              spa_meta_video_crop->width = priv->stream_width;
+-              spa_meta_video_crop->height = priv->stream_height;
++              spa_meta_video_crop->region.position.x = 0;
++              spa_meta_video_crop->region.position.y = 0;
++              spa_meta_video_crop->region.size.width = priv->stream_width;
++              spa_meta_video_crop->region.size.height = priv->stream_height;
+             }
+         }
+     }
+@@ -555,7 +539,6 @@ on_stream_state_changed (void                 *data,
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  uint32_t node_id;
+
+   switch (state)
+     {
+@@ -563,14 +546,12 @@ on_stream_state_changed (void                 *data,
+       g_warning ("pipewire stream error: %s", error_message);
+       meta_screen_cast_stream_src_notify_closed (src);
+       break;
+-    case PW_STREAM_STATE_CONFIGURE:
+-      node_id = pw_stream_get_node_id (priv->pipewire_stream);
+-      g_signal_emit (src, signals[READY], 0, (unsigned int) node_id);
+-      break;
+-    case PW_STREAM_STATE_UNCONNECTED:
+-    case PW_STREAM_STATE_CONNECTING:
+-    case PW_STREAM_STATE_READY:
+     case PW_STREAM_STATE_PAUSED:
++      if (priv->node_id == SPA_ID_INVALID && priv->pipewire_stream)
++        {
++          priv->node_id = pw_stream_get_node_id (priv->pipewire_stream);
++          g_signal_emit (src, signals[READY], 0, (unsigned int) priv->node_id);
++        }
+       if (meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_disable (src);
+       break;
+@@ -578,68 +559,69 @@ on_stream_state_changed (void                 *data,
+       if (!meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_enable (src);
+       break;
++    case PW_STREAM_STATE_UNCONNECTED:
++    case PW_STREAM_STATE_CONNECTING:
++      break;
+     }
+ }
+
+ static void
+-on_stream_format_changed (void                 *data,
+-                          const struct spa_pod *format)
++on_stream_param_changed (void                 *data,
++                         uint32_t              id,
++                         const struct spa_pod *format)
+ {
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   uint8_t params_buffer[1024];
+   int32_t width, height, stride, size;
+   struct spa_pod_builder pod_builder;
+   const struct spa_pod *params[3];
+   const int bpp = 4;
+
+-  if (!format)
+-    {
+-      pw_stream_finish_format (priv->pipewire_stream, 0, NULL, 0);
+-      return;
+-    }
++  if (!format || id != SPA_PARAM_Format)
++    return;
+
+   spa_format_video_raw_parse (format,
+-                              &priv->video_format,
+-                              &priv->spa_type.format_video);
++                              &priv->video_format);
+
+   width = priv->video_format.size.width;
+   height = priv->video_format.size.height;
+   stride = SPA_ROUND_UP_N (width * bpp, 4);
+   size = height * stride;
+
++  priv->video_stride = stride;
++
+   pod_builder = SPA_POD_BUILDER_INIT (params_buffer, sizeof (params_buffer));
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idBuffers, pipewire_type->param_buffers.Buffers,
+-    ":", pipewire_type->param_buffers.size, "i", size,
+-    ":", pipewire_type->param_buffers.stride, "i", stride,
+-    ":", pipewire_type->param_buffers.buffers, "iru", 16, PROP_RANGE (2, 16),
+-    ":", pipewire_type->param_buffers.align, "i", 16);
+-
+-  params[1] = spa_pod_builder_object (
++    SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
++    SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int (16, 2, 16),
++    SPA_PARAM_BUFFERS_blocks, SPA_POD_Int (1),
++    SPA_PARAM_BUFFERS_size, SPA_POD_Int (size),
++    SPA_PARAM_BUFFERS_stride, SPA_POD_Int (stride),
++    SPA_PARAM_BUFFERS_align, SPA_POD_Int (16));
++
++  params[1] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", pipewire_type->meta.VideoCrop,
+-    ":", pipewire_type->param_meta.size, "i", sizeof (struct spa_meta_video_crop));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_VideoCrop),
++    SPA_PARAM_META_size, SPA_POD_Int (sizeof (struct spa_meta_region)));
+
+-  params[2] = spa_pod_builder_object (
++  params[2] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", priv->spa_type.meta_cursor,
+-    ":", pipewire_type->param_meta.size, "i", CURSOR_META_SIZE (64, 64));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_Cursor),
++    SPA_PARAM_META_size, SPA_POD_Int (CURSOR_META_SIZE (64, 64)));
+
+-  pw_stream_finish_format (priv->pipewire_stream, 0,
+-                           params, G_N_ELEMENTS (params));
++  pw_stream_update_params (priv->pipewire_stream, params, G_N_ELEMENTS (params));
+ }
+
+ static const struct pw_stream_events stream_events = {
+   PW_VERSION_STREAM_EVENTS,
+   .state_changed = on_stream_state_changed,
+-  .format_changed = on_stream_format_changed,
++  .param_changed = on_stream_param_changed,
+ };
+
+ static struct pw_stream *
+@@ -652,8 +634,6 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   uint8_t buffer[1024];
+   struct spa_pod_builder pod_builder =
+     SPA_POD_BUILDER_INIT (buffer, sizeof (buffer));
+-  MetaSpaType *spa_type = &priv->spa_type;
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   float frame_rate;
+   MetaFraction frame_rate_fraction;
+   struct spa_fraction max_framerate;
+@@ -661,7 +641,9 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   const struct spa_pod *params[1];
+   int result;
+
+-  pipewire_stream = pw_stream_new (priv->pipewire_remote,
++  priv->node_id = SPA_ID_INVALID;
++
++  pipewire_stream = pw_stream_new (priv->pipewire_core,
+                                    "meta-screen-cast-src",
+                                    NULL);
+   if (!pipewire_stream)
+@@ -682,17 +664,17 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   max_framerate = SPA_FRACTION (frame_rate_fraction.num,
+                                 frame_rate_fraction.denom);
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idEnumFormat, pipewire_type->spa_format,
+-    "I", spa_type->media_type.video,
+-    "I", spa_type->media_subtype.raw,
+-    ":", spa_type->format_video.format, "I", spa_type->video_format.BGRx,
+-    ":", spa_type->format_video.size, "R", &SPA_RECTANGLE (priv->stream_width,
+-                                                           priv->stream_height),
+-    ":", spa_type->format_video.framerate, "F", &SPA_FRACTION (0, 1),
+-    ":", spa_type->format_video.max_framerate, "Fru", &max_framerate,
+-                                                      PROP_RANGE (&min_framerate,
++    SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
++    SPA_FORMAT_mediaType, SPA_POD_Id (SPA_MEDIA_TYPE_video),
++    SPA_FORMAT_mediaSubtype, SPA_POD_Id (SPA_MEDIA_SUBTYPE_raw),
++    SPA_FORMAT_VIDEO_format, SPA_POD_Id (SPA_VIDEO_FORMAT_BGRx),
++    SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle (&SPA_RECTANGLE (priv->stream_width,
++                                                              priv->stream_height)),
++    SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction (&SPA_FRACTION (0, 1)),
++    SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction (&max_framerate,
++                                                                  &min_framerate,
+                                                                   &max_framerate));
+
+   pw_stream_add_listener (pipewire_stream,
+@@ -702,7 +684,7 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+
+   result = pw_stream_connect (pipewire_stream,
+                               PW_DIRECTION_OUTPUT,
+-                              NULL,
++                              SPA_ID_INVALID,
+                               (PW_STREAM_FLAG_DRIVER |
+                                PW_STREAM_FLAG_MAP_BUFFERS),
+                               params, G_N_ELEMENTS (params));
+@@ -717,40 +699,18 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+ }
+
+ static void
+-on_state_changed (void                 *data,
+-                  enum pw_remote_state  old,
+-                  enum pw_remote_state  state,
+-                  const char           *error_message)
++on_core_error (void       *data,
++               uint32_t    id,
++	       int         seq,
++	       int         res,
++	       const char *message)
+ {
+   MetaScreenCastStreamSrc *src = data;
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_stream *pipewire_stream;
+-  GError *error = NULL;
+
+-  switch (state)
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-      g_warning ("pipewire remote error: %s\n", error_message);
+-      meta_screen_cast_stream_src_notify_closed (src);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pipewire_stream = create_pipewire_stream (src, &error);
+-      if (!pipewire_stream)
+-        {
+-          g_warning ("Could not create pipewire stream: %s", error->message);
+-          g_error_free (error);
+-          meta_screen_cast_stream_src_notify_closed (src);
+-        }
+-      else
+-        {
+-          priv->pipewire_stream = pipewire_stream;
+-        }
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    }
++  g_warning ("pipewire remote error: id:%u %s", id, message);
++
++  if (id == PW_ID_CORE && res == -EPIPE)
++    meta_screen_cast_stream_src_notify_closed (src);
+ }
+
+ static gboolean
+@@ -793,17 +753,6 @@ static GSourceFuncs pipewire_source_funcs =
+   pipewire_loop_source_finalize
+ };
+
+-static void
+-init_spa_type (MetaSpaType         *type,
+-               struct spa_type_map *map)
+-{
+-  spa_type_media_type_map (map, &type->media_type);
+-  spa_type_media_subtype_map (map, &type->media_subtype);
+-  spa_type_format_video_map (map, &type->format_video);
+-  spa_type_video_format_map (map, &type->video_format);
+-  type->meta_cursor = spa_type_map_get_id(map, SPA_TYPE_META__Cursor);
+-}
+-
+ static MetaPipeWireSource *
+ create_pipewire_source (void)
+ {
+@@ -829,9 +778,9 @@ create_pipewire_source (void)
+   return pipewire_source;
+ }
+
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = on_core_error,
+ };
+
+ static gboolean
+@@ -851,37 +800,31 @@ meta_screen_cast_stream_src_initable_init (GInitable     *initable,
+       return FALSE;
+     }
+
+-  priv->pipewire_core = pw_core_new (priv->pipewire_source->pipewire_loop,
+-                                     NULL);
+-  if (!priv->pipewire_core)
++  priv->pipewire_context = pw_context_new (priv->pipewire_source->pipewire_loop,
++                                           NULL, 0);
++  if (!priv->pipewire_context)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Failed to create pipewire core");
++                   "Failed to create pipewire context");
+       return FALSE;
+     }
+
+-  priv->pipewire_remote = pw_remote_new (priv->pipewire_core, NULL, 0);
+-  if (!priv->pipewire_remote)
++  priv->pipewire_core = pw_context_connect (priv->pipewire_context, NULL, 0);
++  if (!priv->pipewire_core)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't creat pipewire remote");
++                   "Couldn't connect pipewire context");
+       return FALSE;
+     }
+
+-  pw_remote_add_listener (priv->pipewire_remote,
+-                          &priv->pipewire_remote_listener,
+-                          &remote_events,
+-                          src);
++  pw_core_add_listener (priv->pipewire_core,
++                        &priv->pipewire_core_listener,
++                        &core_events,
++                        src);
+
+-  priv->pipewire_type = pw_core_get_type (priv->pipewire_core);
+-  init_spa_type (&priv->spa_type, priv->pipewire_type->map);
+-
+-  if (pw_remote_connect (priv->pipewire_remote) != 0)
+-    {
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect pipewire remote");
+-      return FALSE;
+-    }
++  priv->pipewire_stream = create_pipewire_stream (src, error);
++  if (!priv->pipewire_stream)
++    return FALSE;
+
+   return TRUE;
+ }
+@@ -912,8 +855,8 @@ meta_screen_cast_stream_src_finalize (GObject *object)
+     meta_screen_cast_stream_src_disable (src);
+
+   g_clear_pointer (&priv->pipewire_stream, pw_stream_destroy);
+-  g_clear_pointer (&priv->pipewire_remote, pw_remote_destroy);
+-  g_clear_pointer (&priv->pipewire_core, pw_core_destroy);
++  g_clear_pointer (&priv->pipewire_core, pw_core_disconnect);
++  g_clear_pointer (&priv->pipewire_context, pw_context_destroy);
+   g_source_destroy (&priv->pipewire_source->base);
+
+   G_OBJECT_CLASS (meta_screen_cast_stream_src_parent_class)->finalize (object);
diff --git a/srcpkgs/mutter/template b/srcpkgs/mutter/template
index 4e0bd32b67d..806a3bef9f0 100644
--- a/srcpkgs/mutter/template
+++ b/srcpkgs/mutter/template
@@ -1,7 +1,7 @@
 # Template file for 'mutter'
 pkgname=mutter
 version=3.34.1
-revision=2
+revision=3
 build_helper="gir"
 build_style=meson
 configure_args="-Degl_device=true -Dudev=true -Dnative_backend=true

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.4
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (26 preceding siblings ...)
  2020-04-30 21:02 ` [PR PATCH] [Updated] pipewire: update to 0.3.4 sirn
@ 2020-04-30 21:07 ` sirn
  2020-04-30 21:42 ` [PR PATCH] [Updated] " sirn
                   ` (23 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-04-30 21:07 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 687 bytes --]

New comment by sirn on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-622112769

Comment:
Updated to pipewire-0.3.4 which needs removing `-Werror=suggest-attribute=format` from `meson.build` (enabled since 0.3.3). See also: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/233

pipewire-0.3.4 also now provides `pw-pulse` and `pw-jack` which is a wrapper for setting `LD_LIBRARY_PATH` to pipewire's pulseaudio/JACK implementation for anyone to try out without replacing their system library. This is part of `pipewire-{pulseaudio,jack}` subtree so I install them in `libpulseaudio-pipewire` and `libjack-pipewire` respectively. 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PR PATCH] [Updated] pipewire: update to 0.3.4
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (27 preceding siblings ...)
  2020-04-30 21:07 ` sirn
@ 2020-04-30 21:42 ` sirn
  2020-05-01 10:35 ` sirn
                   ` (22 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-04-30 21:42 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 785 bytes --]

There is an updated pull request by sirn against master on the void-packages repository

https://github.com/sirn/void-packages pipewire-update
https://github.com/void-linux/void-packages/pull/20413

pipewire: update to 0.3.4
This PR updates `pipewire` to 0.3.4 and also updating/patching all packages that depends on it. 

* `xdg-desktop-portal` includes a patch backported from 1.7.0 to allow 1.6.0 to build against pipewire-0.3 (1.7.x is prerelease)
* `xdg-desktop-portal-kde` already includes Pipewire 0.3 support and only requires revbump.
* `mutter` includes a patch backported from 3.35 to allow 3.34 to build against pipewire-0.3 (upgrading to >=3.35 also requires upgrading GNOME).

A patch file from https://github.com/void-linux/void-packages/pull/20413.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pipewire-update-20413.patch --]
[-- Type: text/x-diff, Size: 50943 bytes --]

From 79ba1a1a1cdbac1c15bfc5ba46833febb88c8a04 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:23:52 +0900
Subject: [PATCH 1/4] pipewire: update to 0.3.4

---
 common/shlibs                  |  2 +-
 srcpkgs/alsa-pipewire          |  1 +
 srcpkgs/libjack-pipewire       |  1 +
 srcpkgs/libpulseaudio-pipewire |  1 +
 srcpkgs/pipewire/template      | 74 ++++++++++++++++++++++++++--------
 5 files changed, 62 insertions(+), 17 deletions(-)
 create mode 120000 srcpkgs/alsa-pipewire
 create mode 120000 srcpkgs/libjack-pipewire
 create mode 120000 srcpkgs/libpulseaudio-pipewire

diff --git a/common/shlibs b/common/shlibs
index a208407b359..07279a7bc72 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3199,7 +3199,7 @@ libarcan_shmif_ext.so.0.11 arcan-0.5.4.3_1
 libarcan_shmif_server.so.0.11 arcan-0.5.4.3_1
 libarcan_tui.so.0.11 arcan-0.5.4.3_1
 liblwipv6.so.2 lwipv6-1.5a_1
-libpipewire-0.2.so.1 libpipewire-0.2.2_1
+libpipewire-0.3.so.0 libpipewire-0.3.4_1
 libvolk.so.2.2.1 volk-2.2.1_1
 libgnuradio-runtime.so.3.8.0 gnuradio-3.8.0.0_1
 libgnuradio-pmt.so.3.8.0 gnuradio-3.8.0.0_1
diff --git a/srcpkgs/alsa-pipewire b/srcpkgs/alsa-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/alsa-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libjack-pipewire b/srcpkgs/libjack-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libjack-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libpulseaudio-pipewire b/srcpkgs/libpulseaudio-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libpulseaudio-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/pipewire/template b/srcpkgs/pipewire/template
index 7f646dad11d..1c1931b1a6d 100644
--- a/srcpkgs/pipewire/template
+++ b/srcpkgs/pipewire/template
@@ -1,26 +1,42 @@
 # Template file for 'pipewire'
 pkgname=pipewire
-version=0.2.7
+version=0.3.4
 revision=1
 build_style=meson
-configure_args="-Dman=true -Dgstreamer=enabled -Ddocs=true -Dsystemd=false"
+configure_args="-Dman=true -Dgstreamer=true -Ddocs=true -Dsystemd=false
+ -Dbluez5=true -Dffmpeg=true -Dpipewire-alsa=true -Dpipewire-jack=true
+ -Dpipewire-pulseaudio=true"
 hostmakedepends="doxygen graphviz pkg-config xmltoman"
 makedepends="SDL2-devel ffmpeg-devel gst-plugins-base1-devel jack-devel
- sbc-devel v4l-utils-devel libva-devel"
+ sbc-devel v4l-utils-devel libva-devel libbluetooth-devel"
 short_desc="Server and user space API to deal with multimedia pipelines"
 maintainer="Orphaned <orphan@voidlinux.org>"
-#Next release will probably change to MIT, currently listed in master
-license="LGPL-2.1-only, GPL-2.0-only "
+license="MIT"
 homepage="https://pipewire.org/"
-changelog="https://raw.githubusercontent.com/PipeWire/pipewire/master/NEWS"
-distfiles="https://github.com/PipeWire/pipewire/archive/${version}.tar.gz"
-checksum=bfaa0f6ae6c0791e2e0b59234d399753bf24f1b33dbf587682363a8463dd8df1
+changelog="https://gitlab.freedesktop.org/pipewire/pipewire/-/raw/master/NEWS"
+distfiles="https://gitlab.freedesktop.org/pipewire/pipewire/-/archive/${version}/pipewire-${version}.tar.gz"
+checksum=6a1c9c671514c84b38ce96d51823354702bc4d5dbaba12d501faa0448f892515
 conf_files="/etc/pipewire/pipewire.conf"
 
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+	LDFLAGS+=" -latomic"
+fi
+
+post_install() {
+	vlicense LICENSE
+}
+
+post_patch() {
+	# https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/233
+	vsed -i meson.build -e 's|.*-Werror=suggest-attribute=format.*||g'
+}
+
 libpipewire_package() {
 	short_desc+=" - pipewire library"
 	pkg_install() {
-		vmove "usr/lib/libpipewire-0.2.so.*"
+		vmove "usr/lib/libpipewire-0.3.so.*"
+		vmove "usr/lib/pipewire-0.3/*.so"
 	}
 }
 
@@ -28,25 +44,25 @@ pipewire-devel_package() {
 	depends="libpipewire-${version}_${revision}"
 	short_desc+=" - pipewire and libspa development files"
 	pkg_install() {
-		vmove usr/include/pipewire
-		vmove usr/include/spa
-		vmove usr/lib/pkgconfig/libpipewire-0.2.pc
-		vmove usr/lib/pkgconfig/libspa-0.1.pc
-		vmove usr/lib/libpipewire-0.2.so
+		vmove usr/include/pipewire-0.3
+		vmove usr/include/spa-0.2
+		vmove usr/lib/pkgconfig/libpipewire-0.3.pc
+		vmove usr/lib/pkgconfig/libspa-0.2.pc
+		vmove usr/lib/libpipewire-0.3.so
 	}
 }
 
 libspa-ffmpeg_package() {
 	short_desc+=" - ffmpeg plugins"
 	pkg_install() {
-		vmove usr/lib/spa/ffmpeg
+		vmove usr/lib/spa-0.2/ffmpeg
 	}
 }
 
 libspa-bluetooth_package() {
 	short_desc+=" - bluetooth plugins"
 	pkg_install() {
-		vmove usr/lib/spa/bluez5
+		vmove usr/lib/spa-0.2/bluez5
 	}
 }
 
@@ -57,6 +73,32 @@ gstreamer1-pipewire_package() {
 	}
 }
 
+libpulseaudio-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - PulseAudio client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/pulse
+		vmove usr/bin/pw-pulse
+	}
+}
+
+alsa-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - ALSA client library"
+	pkg_install() {
+		vmove usr/lib/alsa-lib
+	}
+}
+
+libjack-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - JACK client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/jack
+		vmove usr/bin/pw-jack
+	}
+}
+
 pipewire-doc_package() {
 	archs=noarch
 	short_desc+=" - documentation"

From 868ae7f7272c6b30abd425dbdcf512c122085809 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:46 +0900
Subject: [PATCH 2/4] xdg-desktop-portal-kde: rebuild for pipewire-0.3

---
 srcpkgs/xdg-desktop-portal-kde/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xdg-desktop-portal-kde/template b/srcpkgs/xdg-desktop-portal-kde/template
index f26057d323a..9519abc19f6 100644
--- a/srcpkgs/xdg-desktop-portal-kde/template
+++ b/srcpkgs/xdg-desktop-portal-kde/template
@@ -1,7 +1,7 @@
 # Template file for 'xdg-desktop-portal-kde'
 pkgname=xdg-desktop-portal-kde
 version=5.18.4.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules qt5-qmake qt5-host-tools kcoreaddons gettext"
 makedepends="glib-devel kio-devel kwayland-devel libepoxy-devel pipewire-devel

From ca2692712b496fd85fb783532b6e197e4808030d Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:26 +0900
Subject: [PATCH 3/4] xdg-desktop-portal: rebuild for pipewire-0.3

---
 .../patches/pipewire-0.3.patch                | 551 ++++++++++++++++++
 srcpkgs/xdg-desktop-portal/template           |   8 +-
 2 files changed, 557 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch

diff --git a/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..94ebe083598
--- /dev/null
+++ b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
@@ -0,0 +1,551 @@
+From a38901e5e7f835efe7b7a06c55790c8c20bc91a2 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Tue, 14 Jan 2020 09:37:09 +0100
+Subject: [PATCH] PipeWire: update to 0.3 API
+
+---
+ configure.ac      |   2 +-
+ src/camera.c      |  24 ++++----
+ src/pipewire.c    | 141 +++++++++++++---------------------------------
+ src/pipewire.h    |  10 ++--
+ src/screen-cast.c |  98 ++++++--------------------------
+ 5 files changed, 72 insertions(+), 203 deletions(-)
+
+diff --git configure.ac configure.ac
+index 89902fa..62d7960 100644
+--- configure.ac
++++ configure.ac
+@@ -97,7 +97,7 @@ AC_ARG_ENABLE(pipewire,
+ 	      [AS_HELP_STRING([--enable-pipewire],[Enable PipeWire support. Needed for screen cast portal])],
+ 	      enable_pipewire=$enableval, enable_pipewire=yes)
+ if test x$enable_pipewire = xyes ; then
+-	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.2 >= 0.2.6])
++	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.3 >= 0.2.90])
+ 	AC_DEFINE([HAVE_PIPEWIRE],[1], [Define to enable PipeWire support])
+ fi
+ AM_CONDITIONAL([HAVE_PIPEWIRE],[test "$enable_pipewire" = "yes"])
+diff --git src/camera.c src/camera.c
+index c2b392c..20fe3aa 100644
+--- src/camera.c
++++ src/camera.c
+@@ -141,7 +141,7 @@ open_pipewire_camera_remote (const char *app_id,
+                              GError **error)
+ {
+   PipeWireRemote *remote;
+-  struct spa_dict_item permission_items[1];
++  struct pw_permission permission_items[2];
+   struct pw_properties *pipewire_properties;
+ 
+   pipewire_properties =
+@@ -158,12 +158,12 @@ open_pipewire_camera_remote (const char *app_id,
+    * Hide all existing and future nodes by default. PipeWire will use the
+    * permission store to set up permissions.
+    */
+-  permission_items[0].key = PW_CORE_PROXY_PERMISSIONS_DEFAULT;
+-  permission_items[0].value = "---";
++  permission_items[0] = PW_PERMISSION_INIT (PW_ID_CORE, PW_PERM_RWX);
++  permission_items[1] = PW_PERMISSION_INIT (PW_ID_ANY, 0);
+ 
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             &SPA_DICT_INIT (permission_items,
+-                                             G_N_ELEMENTS (permission_items)));
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                G_N_ELEMENTS (permission_items),
++                                permission_items);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -219,7 +219,7 @@ handle_open_pipewire_remote (XdpCamera *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
+@@ -250,29 +250,28 @@ camera_iface_init (XdpCameraIface *iface)
+ static void
+ global_added_cb (PipeWireRemote *remote,
+                  uint32_t id,
+-                 uint32_t type,
++                 const char *type,
+                  const struct spa_dict *props,
+                  gpointer user_data)
+ {
+   Camera *camera = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *media_class;
+   const struct spa_dict_item *media_role;
+ 
+-  if (type != core_type->node)
++  if (strcmp(type, PW_TYPE_INTERFACE_Node) != 0)
+     return;
+ 
+   if (!props)
+     return;
+ 
+-  media_class = spa_dict_lookup_item (props, "media.class");
++  media_class = spa_dict_lookup_item (props, PW_KEY_MEDIA_CLASS);
+   if (!media_class)
+     return;
+ 
+   if (g_strcmp0 (media_class->value, "Video/Source") != 0)
+     return;
+ 
+-  media_role = spa_dict_lookup_item (props, "media.role");
++  media_role = spa_dict_lookup_item (props, PW_KEY_MEDIA_ROLE);
+   if (!media_role)
+     return;
+ 
+@@ -342,6 +341,7 @@ create_pipewire_remote (Camera *camera,
+     }
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.is_portal", "true",
++                                           "portal.monitor", "Camera",
+                                            NULL);
+   camera->pipewire_remote = pipewire_remote_new_sync (pipewire_properties,
+                                                       global_added_cb,
+diff --git src/pipewire.c src/pipewire.c
+index 793a378..162cd55 100644
+--- src/pipewire.c
++++ src/pipewire.c
+@@ -21,6 +21,7 @@
+ #include <errno.h>
+ #include <glib.h>
+ #include <pipewire/pipewire.h>
++#include <spa/utils/result.h>
+ 
+ #include "pipewire.h"
+ 
+@@ -36,27 +37,25 @@ static gboolean is_pipewire_initialized = FALSE;
+ static void
+ registry_event_global (void *user_data,
+                        uint32_t id,
+-                       uint32_t parent_id,
+                        uint32_t permissions,
+-                       uint32_t type,
++                       const char *type,
+                        uint32_t version,
+                        const struct spa_dict *props)
+ {
+   PipeWireRemote *remote = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *factory_object_type;
+   PipeWireGlobal *global;
+ 
+   global = g_new0 (PipeWireGlobal, 1);
+   *global = (PipeWireGlobal) {
+-    .parent_id = parent_id,
++    .parent_id = id,
+   };
+ 
+   g_hash_table_insert (remote->globals, GINT_TO_POINTER (id), global);
+   if (remote->global_added_cb)
+     remote->global_added_cb (remote, id, type, props, remote->user_data);
+ 
+-  if (type != core_type->factory)
++  if (strcmp(type, PW_TYPE_INTERFACE_Factory) != 0)
+     return;
+ 
+   factory_object_type = spa_dict_lookup_item (props, "factory.type.name");
+@@ -81,8 +80,8 @@ registry_event_global_remove (void *user_data,
+   g_hash_table_remove (remote->globals, GINT_TO_POINTER (id));
+ }
+ 
+-static const struct pw_registry_proxy_events registry_events = {
+-  PW_VERSION_REGISTRY_PROXY_EVENTS,
++static const struct pw_registry_events registry_events = {
++  PW_VERSION_REGISTRY_EVENTS,
+   .global = registry_event_global,
+   .global_remove = registry_event_global_remove,
+ };
+@@ -90,7 +89,7 @@ static const struct pw_registry_proxy_events registry_events = {
+ void
+ pipewire_remote_roundtrip (PipeWireRemote *remote)
+ {
+-  pw_core_proxy_sync (remote->core_proxy, ++remote->sync_seq);
++  remote->sync_seq = pw_core_sync (remote->core, PW_ID_CORE, remote->sync_seq);
+   pw_main_loop_run (remote->loop);
+ }
+ 
+@@ -98,16 +97,13 @@ static gboolean
+ discover_node_factory_sync (PipeWireRemote *remote,
+                             GError **error)
+ {
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+-  struct pw_registry_proxy *registry_proxy;
++  struct pw_registry *registry;
+ 
+-  registry_proxy = pw_core_proxy_get_registry (remote->core_proxy,
+-                                               core_type->registry,
+-                                               PW_VERSION_REGISTRY, 0);
+-  pw_registry_proxy_add_listener (registry_proxy,
+-                                  &remote->registry_listener,
+-                                  &registry_events,
+-                                  remote);
++  registry = pw_core_get_registry (remote->core, PW_VERSION_REGISTRY, 0);
++  pw_registry_add_listener (registry,
++                            &remote->registry_listener,
++                            &registry_events,
++                            remote);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -122,59 +118,35 @@ discover_node_factory_sync (PipeWireRemote *remote,
+ }
+ 
+ static void
+-on_state_changed (void *user_data,
+-                  enum pw_remote_state old,
+-                  enum pw_remote_state state,
+-                  const char *error)
++core_event_error (void       *user_data,
++                  uint32_t    id,
++		  int         seq,
++		  int         res,
++		  const char *message)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  switch (state)
++  if (id == PW_ID_CORE)
+     {
+-    case PW_REMOTE_STATE_ERROR:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "%s", error);
+-        }
++      g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
++                 "%s", message);
+       pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "Disconnected");
+-        }
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    default:
+-      g_warning ("Unknown PipeWire state");
+-      break;
+     }
+ }
+ 
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
+-};
+-
+ static void
+ core_event_done (void *user_data,
+-                 uint32_t seq)
++                 uint32_t id, int seq)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  if (remote->sync_seq == seq)
++  if (id == PW_ID_CORE && remote->sync_seq == seq)
+     pw_main_loop_quit (remote->loop);
+ }
+ 
+-static const struct pw_core_proxy_events core_events = {
+-  PW_VERSION_CORE_PROXY_EVENTS,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = core_event_error,
+   .done = core_event_done,
+ };
+ 
+@@ -237,8 +209,8 @@ void
+ pipewire_remote_destroy (PipeWireRemote *remote)
+ {
+   g_clear_pointer (&remote->globals, g_hash_table_destroy);
+-  g_clear_pointer (&remote->remote, pw_remote_destroy);
+-  g_clear_pointer (&remote->core, pw_core_destroy);
++  g_clear_pointer (&remote->core, pw_core_disconnect);
++  g_clear_pointer (&remote->context, pw_context_destroy);
+   g_clear_pointer (&remote->loop, pw_main_loop_destroy);
+   g_clear_error (&remote->error);
+ 
+@@ -307,68 +279,31 @@ pipewire_remote_new_sync (struct pw_properties *pipewire_properties,
+       return NULL;
+     }
+ 
+-  remote->core = pw_core_new (pw_main_loop_get_loop (remote->loop), NULL);
+-  if (!remote->core)
++  remote->context = pw_context_new (pw_main_loop_get_loop (remote->loop), NULL, 0);
++  if (!remote->context)
+     {
+       pipewire_remote_destroy (remote);
+       pw_properties_free (pipewire_properties);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire core");
++                   "Couldn't create PipeWire context");
+       return NULL;
+     }
+ 
+-  remote->remote = pw_remote_new (remote->core, pipewire_properties, 0);
+-  if (!remote->remote)
++  remote->core = pw_context_connect (remote->context, pipewire_properties, 0);
++  if (!remote->core)
+     {
+       pipewire_remote_destroy (remote);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire remote");
++                   "Couldn't connect to PipeWire");
+       return NULL;
+     }
+ 
+   remote->globals = g_hash_table_new_full (NULL, NULL, NULL, g_free);
+ 
+-  pw_remote_add_listener (remote->remote,
+-                          &remote->remote_listener,
+-                          &remote_events,
+-                          remote);
+-
+-  if (pw_remote_connect (remote->remote) != 0)
+-    {
+-      pipewire_remote_destroy (remote);
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect PipeWire remote");
+-      return NULL;
+-    }
+-
+-  pw_main_loop_run (remote->loop);
+-
+-  switch (pw_remote_get_state (remote->remote, NULL))
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      *error = g_steal_pointer (&remote->error);
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "PipeWire loop stopped unexpectedly");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      break;
+-    default:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Unexpected PipeWire state");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    }
+-
+-  remote->core_proxy = pw_remote_get_core_proxy (remote->remote);
+-  pw_core_proxy_add_listener (remote->core_proxy,
+-                              &remote->core_listener,
+-                              &core_events,
+-                              remote);
++  pw_core_add_listener (remote->core,
++                        &remote->core_listener,
++                        &core_events,
++                        remote);
+ 
+   if (!discover_node_factory_sync (remote, error))
+     {
+diff --git src/pipewire.h src/pipewire.h
+index 0f1bf54..bf48d5e 100644
+--- src/pipewire.h
++++ src/pipewire.h
+@@ -32,7 +32,7 @@ typedef struct _PipeWireGlobal
+ 
+ typedef void (* PipeWireGlobalAddedCallback) (PipeWireRemote *remote,
+                                               uint32_t id,
+-                                              uint32_t type,
++                                              const char *type,
+                                               const struct spa_dict *props,
+                                               gpointer user_data);
+ 
+@@ -43,13 +43,11 @@ typedef void (* PipeWireGlobalRemovedCallback) (PipeWireRemote *remote,
+ struct _PipeWireRemote
+ {
+   struct pw_main_loop *loop;
++  struct pw_context *context;
+   struct pw_core *core;
+-  struct pw_remote *remote;
+-  struct spa_hook remote_listener;
+-
+-  struct pw_core_proxy *core_proxy;
+   struct spa_hook core_listener;
+-  uint32_t sync_seq;
++
++  int sync_seq;
+ 
+   struct spa_hook registry_listener;
+ 
+diff --git src/screen-cast.c src/screen-cast.c
+index 7881ddc..1677050 100644
+--- src/screen-cast.c
++++ src/screen-cast.c
+@@ -31,10 +31,10 @@
+ #include "xdp-impl-dbus.h"
+ #include "xdp-utils.h"
+ 
+-#define PERMISSION_ITEM(item_key, item_value) \
+-  ((struct spa_dict_item) { \
+-    .key = item_key, \
+-    .value = item_value \
++#define PERMISSION_ITEM(item_id, item_permissions) \
++  ((struct pw_permission) { \
++    .id = item_id, \
++    .permissions = item_permissions \
+   })
+ 
+ typedef struct _ScreenCast ScreenCast;
+@@ -517,42 +517,9 @@ screen_cast_stream_get_pipewire_node_id (ScreenCastStream *stream)
+   return stream->id;
+ }
+ 
+-static void
+-append_parent_permissions (PipeWireRemote *remote,
+-                           GArray *permission_items,
+-                           GList **string_stash,
+-                           PipeWireGlobal *global,
+-                           const char *permission)
+-{
+-  PipeWireGlobal *parent;
+-  char *parent_permission_value;
+-
+-  if (global->parent_id == 0)
+-    return;
+-
+-  parent = g_hash_table_lookup (remote->globals, GINT_TO_POINTER (global->parent_id));
+-
+-  if (parent->permission_set)
+-    return;
+-  parent->permission_set = TRUE;
+-
+-  append_parent_permissions (remote, permission_items, string_stash,
+-                             parent, permission);
+-
+-  parent_permission_value = g_strdup_printf ("%u:%s",
+-                                             global->parent_id,
+-                                             permission);
+-  *string_stash = g_list_prepend (*string_stash, parent_permission_value);
+-
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       parent_permission_value));
+-}
+-
+ static void
+ append_stream_permissions (PipeWireRemote *remote,
+                            GArray *permission_items,
+-                           GList **string_stash,
+                            GList *streams)
+ {
+   GList *l;
+@@ -561,21 +528,10 @@ append_stream_permissions (PipeWireRemote *remote,
+     {
+       ScreenCastStream *stream = l->data;
+       uint32_t stream_id;
+-      PipeWireGlobal *stream_global;
+-      char *stream_permission_value;
+ 
+       stream_id = screen_cast_stream_get_pipewire_node_id (stream);
+-      stream_global = g_hash_table_lookup (remote->globals,
+-                                           GINT_TO_POINTER (stream_id));
+-
+-      append_parent_permissions (remote, permission_items, string_stash,
+-                                 stream_global, "r--");
+-
+-      stream_permission_value = g_strdup_printf ("%u:rwx", stream_id);
+-      *string_stash = g_list_prepend (*string_stash, stream_permission_value);
+       g_array_append_val (permission_items,
+-                          PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                           stream_permission_value));
++                          PERMISSION_ITEM (stream_id, PW_PERM_RWX));
+     }
+ }
+ 
+@@ -587,9 +543,6 @@ open_pipewire_screen_cast_remote (const char *app_id,
+   struct pw_properties *pipewire_properties;
+   PipeWireRemote *remote;
+   g_autoptr(GArray) permission_items = NULL;
+-  char *node_factory_permission_string;
+-  GList *string_stash = NULL;
+-  struct spa_dict *permission_dict;
+   PipeWireGlobal *node_global;
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.app_id", app_id,
+@@ -603,48 +556,31 @@ open_pipewire_screen_cast_remote (const char *app_id,
+ 
+   permission_items = g_array_new (FALSE, TRUE, sizeof (struct spa_dict_item));
+ 
+-  /*
+-   * Hide all existing and future nodes (except the ones we explicitly list below.
+-   */
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_EXISTING,
+-                                       "---"));
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_DEFAULT,
+-                                       "---"));
+-
+   /*
+    * PipeWire:Interface:Core
+    * Needs rwx to be able create the sink node using the create-object method
+    */
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       "0:rwx"));
++                      PERMISSION_ITEM (PW_ID_CORE, PW_PERM_RWX));
+ 
+   /*
+    * PipeWire:Interface:NodeFactory
+    * Needs r-- so it can be passed to create-object when creating the sink node.
+    */
+-  node_factory_permission_string = g_strdup_printf ("%d:r--",
+-                                                    remote->node_factory_id);
+-  string_stash = g_list_prepend (string_stash, node_factory_permission_string);
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       node_factory_permission_string));
+-  node_global = g_hash_table_lookup (remote->globals,
+-                                     GINT_TO_POINTER (remote->node_factory_id));
+-  append_parent_permissions (remote, permission_items, &string_stash,
+-                             node_global, "r--");
++                      PERMISSION_ITEM (remote->node_factory_id, PW_PERM_R));
+ 
+-  append_stream_permissions (remote, permission_items, &string_stash, streams);
++  append_stream_permissions (remote, permission_items, streams);
+ 
+-  permission_dict =
+-    &SPA_DICT_INIT ((struct spa_dict_item *) permission_items->data,
+-                    permission_items->len);
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             permission_dict);
++  /*
++   * Hide all existing and future nodes (except the ones we explicitly list above).
++   */
++  g_array_append_val (permission_items,
++                      PERMISSION_ITEM (PW_ID_ANY, 0));
+ 
+-  g_list_free_full (string_stash, g_free);
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                permission_items->len,
++                                (const struct pw_permission *)permission_items->data);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -943,7 +879,7 @@ handle_open_pipewire_remote (XdpScreenCast *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
diff --git a/srcpkgs/xdg-desktop-portal/template b/srcpkgs/xdg-desktop-portal/template
index eb8a4602f5d..1136b6a6e0e 100644
--- a/srcpkgs/xdg-desktop-portal/template
+++ b/srcpkgs/xdg-desktop-portal/template
@@ -1,10 +1,10 @@
 # Template file for 'xdg-desktop-portal'
 pkgname=xdg-desktop-portal
 version=1.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-pipewire --enable-geoclue --disable-libportal"
-hostmakedepends="pkg-config glib-devel"
+hostmakedepends="automake libtool gettext-devel pkg-config glib-devel"
 makedepends="flatpak-devel fuse-devel pipewire-devel geoclue2-devel"
 short_desc="Portal frontend service for Flatpak"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -13,6 +13,10 @@ homepage="https://github.com/flatpak/xdg-desktop-portal"
 distfiles="https://github.com/flatpak/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.xz"
 checksum=883c9c9a925e48af54812b5347f546dd776ec2e27076a83d5a8126af6bafb9da
 
+pre_configure() {
+	autoreconf -vfi
+}
+
 post_install() {
 	rm -rf "${DESTDIR}/usr/lib/systemd"
 }

From dc0c1053e3b0a73a33b8286b94dd02d53340e0fa Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Thu, 30 Apr 2020 06:17:17 +0900
Subject: [PATCH 4/4] mutter: rebuild for pipewire-0.3

---
 srcpkgs/mutter/patches/pipewire-0.3.patch | 521 ++++++++++++++++++++++
 srcpkgs/mutter/template                   |   2 +-
 2 files changed, 522 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/mutter/patches/pipewire-0.3.patch

diff --git a/srcpkgs/mutter/patches/pipewire-0.3.patch b/srcpkgs/mutter/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..ebff65fba85
--- /dev/null
+++ b/srcpkgs/mutter/patches/pipewire-0.3.patch
@@ -0,0 +1,521 @@
+Build mutter against pipewire-0.3, based on a patch at:
+https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1062
+--- meson.build
++++ meson.build
+@@ -50,7 +50,7 @@ libinput_req = '>= 1.7'
+ gbm_req = '>= 10.3'
+
+ # screen cast version requirements
+-libpipewire_req = '>= 0.2.5'
++libpipewire_req = '>= 0.3.0'
+
+ gnome = import('gnome')
+ pkg = import('pkgconfig')
+@@ -241,7 +241,7 @@ endif
+
+ have_remote_desktop = get_option('remote_desktop')
+ if have_remote_desktop
+-  libpipewire_dep = dependency('libpipewire-0.2', version: libpipewire_req)
++  libpipewire_dep = dependency('libpipewire-0.3', version: libpipewire_req)
+ endif
+
+ have_introspection = get_option('introspection')
+diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
+index 82c5cba436..ba1ce94a7e 100644
+--- src/backends/meta-screen-cast-stream-src.c
++++ src/backends/meta-screen-cast-stream-src.c
+@@ -29,6 +29,7 @@
+ #include <spa/param/props.h>
+ #include <spa/param/format-utils.h>
+ #include <spa/param/video/format-utils.h>
++#include <spa/utils/result.h>
+ #include <stdint.h>
+ #include <sys/mman.h>
+
+@@ -62,15 +63,6 @@ enum
+
+ static guint signals[N_SIGNALS];
+
+-typedef struct _MetaSpaType
+-{
+-  struct spa_type_media_type media_type;
+-  struct spa_type_media_subtype media_subtype;
+-  struct spa_type_format_video format_video;
+-  struct spa_type_video_format video_format;
+-  uint32_t meta_cursor;
+-} MetaSpaType;
+-
+ typedef struct _MetaPipeWireSource
+ {
+   GSource base;
+@@ -82,19 +74,19 @@ typedef struct _MetaScreenCastStreamSrcPrivate
+ {
+   MetaScreenCastStream *stream;
+
++  struct pw_context *pipewire_context;
+   struct pw_core *pipewire_core;
+-  struct pw_remote *pipewire_remote;
+-  struct pw_type *pipewire_type;
+   MetaPipeWireSource *pipewire_source;
+-  struct spa_hook pipewire_remote_listener;
++  struct spa_hook pipewire_core_listener;
+
+   gboolean is_enabled;
+
+   struct pw_stream *pipewire_stream;
+   struct spa_hook pipewire_stream_listener;
++  uint32_t node_id;
+
+-  MetaSpaType spa_type;
+   struct spa_video_info_raw video_format;
++  int video_stride;
+
+   uint64_t last_frame_timestamp_us;
+
+@@ -112,8 +104,6 @@ G_DEFINE_TYPE_WITH_CODE (MetaScreenCastStreamSrc,
+                                                 meta_screen_cast_stream_src_init_initable_iface)
+                          G_ADD_PRIVATE (MetaScreenCastStreamSrc))
+
+-#define PROP_RANGE(min, max) 2, (min), (max)
+-
+ static void
+ meta_screen_cast_stream_src_get_specs (MetaScreenCastStreamSrc *src,
+                                        int                     *width,
+@@ -286,9 +276,6 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+                                                               int                      x,
+                                                               int                      y)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+
+   spa_meta_cursor->id = 1;
+@@ -300,7 +287,7 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   spa_meta_cursor->hotspot.x = 0;
+@@ -317,9 +304,6 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+                                                         int                      y,
+                                                         float                    scale)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   CoglTexture *cursor_texture;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+   int hotspot_x, hotspot_y;
+@@ -346,7 +330,7 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
+@@ -382,12 +366,10 @@ static void
+ add_cursor_metadata (MetaScreenCastStreamSrc *src,
+                      struct spa_buffer       *spa_buffer)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_cursor *spa_meta_cursor;
+
+-  spa_meta_cursor = spa_buffer_find_meta (spa_buffer, spa_type->meta_cursor);
++  spa_meta_cursor = spa_buffer_find_meta_data (spa_buffer, SPA_META_Cursor,
++                                               sizeof (*spa_meta_cursor));
+   if (spa_meta_cursor)
+     meta_screen_cast_stream_src_set_cursor_metadata (src, spa_meta_cursor);
+ }
+@@ -447,14 +429,14 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+     {
+       data = spa_buffer->datas[0].data;
+     }
+-  else if (spa_buffer->datas[0].type == priv->pipewire_type->data.MemFd)
++  else if (spa_buffer->datas[0].type == SPA_DATA_MemFd)
+     {
+       map = mmap (NULL, spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset,
+                   PROT_READ | PROT_WRITE, MAP_SHARED,
+                   spa_buffer->datas[0].fd, 0);
+       if (map == MAP_FAILED)
+         {
+-          g_warning ("Failed to mmap pipewire stream buffer: %s\n",
++          g_warning ("Failed to mmap pipewire stream buffer: %s",
+                      strerror (errno));
+           return;
+         }
+@@ -469,28 +451,30 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+
+   if (meta_screen_cast_stream_src_record_frame (src, data))
+     {
+-      struct spa_meta_video_crop *spa_meta_video_crop;
++      struct spa_meta_region *spa_meta_video_crop;
+
+       spa_buffer->datas[0].chunk->size = spa_buffer->datas[0].maxsize;
++      spa_buffer->datas[0].chunk->stride = priv->video_stride;
+
+       /* Update VideoCrop if needed */
+       spa_meta_video_crop =
+-        spa_buffer_find_meta (spa_buffer, priv->pipewire_type->meta.VideoCrop);
++        spa_buffer_find_meta_data (spa_buffer, SPA_META_VideoCrop,
++                                   sizeof (*spa_meta_video_crop));
+       if (spa_meta_video_crop)
+         {
+           if (meta_screen_cast_stream_src_get_videocrop (src, &crop_rect))
+             {
+-              spa_meta_video_crop->x = crop_rect.x;
+-              spa_meta_video_crop->y = crop_rect.y;
+-              spa_meta_video_crop->width = crop_rect.width;
+-              spa_meta_video_crop->height = crop_rect.height;
++              spa_meta_video_crop->region.position.x = crop_rect.x;
++              spa_meta_video_crop->region.position.y = crop_rect.y;
++              spa_meta_video_crop->region.size.width = crop_rect.width;
++              spa_meta_video_crop->region.size.height = crop_rect.height;
+             }
+           else
+             {
+-              spa_meta_video_crop->x = 0;
+-              spa_meta_video_crop->y = 0;
+-              spa_meta_video_crop->width = priv->stream_width;
+-              spa_meta_video_crop->height = priv->stream_height;
++              spa_meta_video_crop->region.position.x = 0;
++              spa_meta_video_crop->region.position.y = 0;
++              spa_meta_video_crop->region.size.width = priv->stream_width;
++              spa_meta_video_crop->region.size.height = priv->stream_height;
+             }
+         }
+     }
+@@ -555,7 +539,6 @@ on_stream_state_changed (void                 *data,
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  uint32_t node_id;
+
+   switch (state)
+     {
+@@ -563,14 +546,12 @@ on_stream_state_changed (void                 *data,
+       g_warning ("pipewire stream error: %s", error_message);
+       meta_screen_cast_stream_src_notify_closed (src);
+       break;
+-    case PW_STREAM_STATE_CONFIGURE:
+-      node_id = pw_stream_get_node_id (priv->pipewire_stream);
+-      g_signal_emit (src, signals[READY], 0, (unsigned int) node_id);
+-      break;
+-    case PW_STREAM_STATE_UNCONNECTED:
+-    case PW_STREAM_STATE_CONNECTING:
+-    case PW_STREAM_STATE_READY:
+     case PW_STREAM_STATE_PAUSED:
++      if (priv->node_id == SPA_ID_INVALID && priv->pipewire_stream)
++        {
++          priv->node_id = pw_stream_get_node_id (priv->pipewire_stream);
++          g_signal_emit (src, signals[READY], 0, (unsigned int) priv->node_id);
++        }
+       if (meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_disable (src);
+       break;
+@@ -578,68 +559,69 @@ on_stream_state_changed (void                 *data,
+       if (!meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_enable (src);
+       break;
++    case PW_STREAM_STATE_UNCONNECTED:
++    case PW_STREAM_STATE_CONNECTING:
++      break;
+     }
+ }
+
+ static void
+-on_stream_format_changed (void                 *data,
+-                          const struct spa_pod *format)
++on_stream_param_changed (void                 *data,
++                         uint32_t              id,
++                         const struct spa_pod *format)
+ {
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   uint8_t params_buffer[1024];
+   int32_t width, height, stride, size;
+   struct spa_pod_builder pod_builder;
+   const struct spa_pod *params[3];
+   const int bpp = 4;
+
+-  if (!format)
+-    {
+-      pw_stream_finish_format (priv->pipewire_stream, 0, NULL, 0);
+-      return;
+-    }
++  if (!format || id != SPA_PARAM_Format)
++    return;
+
+   spa_format_video_raw_parse (format,
+-                              &priv->video_format,
+-                              &priv->spa_type.format_video);
++                              &priv->video_format);
+
+   width = priv->video_format.size.width;
+   height = priv->video_format.size.height;
+   stride = SPA_ROUND_UP_N (width * bpp, 4);
+   size = height * stride;
+
++  priv->video_stride = stride;
++
+   pod_builder = SPA_POD_BUILDER_INIT (params_buffer, sizeof (params_buffer));
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idBuffers, pipewire_type->param_buffers.Buffers,
+-    ":", pipewire_type->param_buffers.size, "i", size,
+-    ":", pipewire_type->param_buffers.stride, "i", stride,
+-    ":", pipewire_type->param_buffers.buffers, "iru", 16, PROP_RANGE (2, 16),
+-    ":", pipewire_type->param_buffers.align, "i", 16);
+-
+-  params[1] = spa_pod_builder_object (
++    SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
++    SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int (16, 2, 16),
++    SPA_PARAM_BUFFERS_blocks, SPA_POD_Int (1),
++    SPA_PARAM_BUFFERS_size, SPA_POD_Int (size),
++    SPA_PARAM_BUFFERS_stride, SPA_POD_Int (stride),
++    SPA_PARAM_BUFFERS_align, SPA_POD_Int (16));
++
++  params[1] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", pipewire_type->meta.VideoCrop,
+-    ":", pipewire_type->param_meta.size, "i", sizeof (struct spa_meta_video_crop));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_VideoCrop),
++    SPA_PARAM_META_size, SPA_POD_Int (sizeof (struct spa_meta_region)));
+
+-  params[2] = spa_pod_builder_object (
++  params[2] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", priv->spa_type.meta_cursor,
+-    ":", pipewire_type->param_meta.size, "i", CURSOR_META_SIZE (64, 64));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_Cursor),
++    SPA_PARAM_META_size, SPA_POD_Int (CURSOR_META_SIZE (64, 64)));
+
+-  pw_stream_finish_format (priv->pipewire_stream, 0,
+-                           params, G_N_ELEMENTS (params));
++  pw_stream_update_params (priv->pipewire_stream, params, G_N_ELEMENTS (params));
+ }
+
+ static const struct pw_stream_events stream_events = {
+   PW_VERSION_STREAM_EVENTS,
+   .state_changed = on_stream_state_changed,
+-  .format_changed = on_stream_format_changed,
++  .param_changed = on_stream_param_changed,
+ };
+
+ static struct pw_stream *
+@@ -652,8 +634,6 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   uint8_t buffer[1024];
+   struct spa_pod_builder pod_builder =
+     SPA_POD_BUILDER_INIT (buffer, sizeof (buffer));
+-  MetaSpaType *spa_type = &priv->spa_type;
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   float frame_rate;
+   MetaFraction frame_rate_fraction;
+   struct spa_fraction max_framerate;
+@@ -661,7 +641,9 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   const struct spa_pod *params[1];
+   int result;
+
+-  pipewire_stream = pw_stream_new (priv->pipewire_remote,
++  priv->node_id = SPA_ID_INVALID;
++
++  pipewire_stream = pw_stream_new (priv->pipewire_core,
+                                    "meta-screen-cast-src",
+                                    NULL);
+   if (!pipewire_stream)
+@@ -682,17 +664,17 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   max_framerate = SPA_FRACTION (frame_rate_fraction.num,
+                                 frame_rate_fraction.denom);
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idEnumFormat, pipewire_type->spa_format,
+-    "I", spa_type->media_type.video,
+-    "I", spa_type->media_subtype.raw,
+-    ":", spa_type->format_video.format, "I", spa_type->video_format.BGRx,
+-    ":", spa_type->format_video.size, "R", &SPA_RECTANGLE (priv->stream_width,
+-                                                           priv->stream_height),
+-    ":", spa_type->format_video.framerate, "F", &SPA_FRACTION (0, 1),
+-    ":", spa_type->format_video.max_framerate, "Fru", &max_framerate,
+-                                                      PROP_RANGE (&min_framerate,
++    SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
++    SPA_FORMAT_mediaType, SPA_POD_Id (SPA_MEDIA_TYPE_video),
++    SPA_FORMAT_mediaSubtype, SPA_POD_Id (SPA_MEDIA_SUBTYPE_raw),
++    SPA_FORMAT_VIDEO_format, SPA_POD_Id (SPA_VIDEO_FORMAT_BGRx),
++    SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle (&SPA_RECTANGLE (priv->stream_width,
++                                                              priv->stream_height)),
++    SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction (&SPA_FRACTION (0, 1)),
++    SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction (&max_framerate,
++                                                                  &min_framerate,
+                                                                   &max_framerate));
+
+   pw_stream_add_listener (pipewire_stream,
+@@ -702,7 +684,7 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+
+   result = pw_stream_connect (pipewire_stream,
+                               PW_DIRECTION_OUTPUT,
+-                              NULL,
++                              SPA_ID_INVALID,
+                               (PW_STREAM_FLAG_DRIVER |
+                                PW_STREAM_FLAG_MAP_BUFFERS),
+                               params, G_N_ELEMENTS (params));
+@@ -717,40 +699,18 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+ }
+
+ static void
+-on_state_changed (void                 *data,
+-                  enum pw_remote_state  old,
+-                  enum pw_remote_state  state,
+-                  const char           *error_message)
++on_core_error (void       *data,
++               uint32_t    id,
++	       int         seq,
++	       int         res,
++	       const char *message)
+ {
+   MetaScreenCastStreamSrc *src = data;
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_stream *pipewire_stream;
+-  GError *error = NULL;
+
+-  switch (state)
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-      g_warning ("pipewire remote error: %s\n", error_message);
+-      meta_screen_cast_stream_src_notify_closed (src);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pipewire_stream = create_pipewire_stream (src, &error);
+-      if (!pipewire_stream)
+-        {
+-          g_warning ("Could not create pipewire stream: %s", error->message);
+-          g_error_free (error);
+-          meta_screen_cast_stream_src_notify_closed (src);
+-        }
+-      else
+-        {
+-          priv->pipewire_stream = pipewire_stream;
+-        }
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    }
++  g_warning ("pipewire remote error: id:%u %s", id, message);
++
++  if (id == PW_ID_CORE && res == -EPIPE)
++    meta_screen_cast_stream_src_notify_closed (src);
+ }
+
+ static gboolean
+@@ -793,17 +753,6 @@ static GSourceFuncs pipewire_source_funcs =
+   pipewire_loop_source_finalize
+ };
+
+-static void
+-init_spa_type (MetaSpaType         *type,
+-               struct spa_type_map *map)
+-{
+-  spa_type_media_type_map (map, &type->media_type);
+-  spa_type_media_subtype_map (map, &type->media_subtype);
+-  spa_type_format_video_map (map, &type->format_video);
+-  spa_type_video_format_map (map, &type->video_format);
+-  type->meta_cursor = spa_type_map_get_id(map, SPA_TYPE_META__Cursor);
+-}
+-
+ static MetaPipeWireSource *
+ create_pipewire_source (void)
+ {
+@@ -829,9 +778,9 @@ create_pipewire_source (void)
+   return pipewire_source;
+ }
+
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = on_core_error,
+ };
+
+ static gboolean
+@@ -851,37 +800,31 @@ meta_screen_cast_stream_src_initable_init (GInitable     *initable,
+       return FALSE;
+     }
+
+-  priv->pipewire_core = pw_core_new (priv->pipewire_source->pipewire_loop,
+-                                     NULL);
+-  if (!priv->pipewire_core)
++  priv->pipewire_context = pw_context_new (priv->pipewire_source->pipewire_loop,
++                                           NULL, 0);
++  if (!priv->pipewire_context)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Failed to create pipewire core");
++                   "Failed to create pipewire context");
+       return FALSE;
+     }
+
+-  priv->pipewire_remote = pw_remote_new (priv->pipewire_core, NULL, 0);
+-  if (!priv->pipewire_remote)
++  priv->pipewire_core = pw_context_connect (priv->pipewire_context, NULL, 0);
++  if (!priv->pipewire_core)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't creat pipewire remote");
++                   "Couldn't connect pipewire context");
+       return FALSE;
+     }
+
+-  pw_remote_add_listener (priv->pipewire_remote,
+-                          &priv->pipewire_remote_listener,
+-                          &remote_events,
+-                          src);
++  pw_core_add_listener (priv->pipewire_core,
++                        &priv->pipewire_core_listener,
++                        &core_events,
++                        src);
+
+-  priv->pipewire_type = pw_core_get_type (priv->pipewire_core);
+-  init_spa_type (&priv->spa_type, priv->pipewire_type->map);
+-
+-  if (pw_remote_connect (priv->pipewire_remote) != 0)
+-    {
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect pipewire remote");
+-      return FALSE;
+-    }
++  priv->pipewire_stream = create_pipewire_stream (src, error);
++  if (!priv->pipewire_stream)
++    return FALSE;
+
+   return TRUE;
+ }
+@@ -912,8 +855,8 @@ meta_screen_cast_stream_src_finalize (GObject *object)
+     meta_screen_cast_stream_src_disable (src);
+
+   g_clear_pointer (&priv->pipewire_stream, pw_stream_destroy);
+-  g_clear_pointer (&priv->pipewire_remote, pw_remote_destroy);
+-  g_clear_pointer (&priv->pipewire_core, pw_core_destroy);
++  g_clear_pointer (&priv->pipewire_core, pw_core_disconnect);
++  g_clear_pointer (&priv->pipewire_context, pw_context_destroy);
+   g_source_destroy (&priv->pipewire_source->base);
+
+   G_OBJECT_CLASS (meta_screen_cast_stream_src_parent_class)->finalize (object);
diff --git a/srcpkgs/mutter/template b/srcpkgs/mutter/template
index 4e0bd32b67d..806a3bef9f0 100644
--- a/srcpkgs/mutter/template
+++ b/srcpkgs/mutter/template
@@ -1,7 +1,7 @@
 # Template file for 'mutter'
 pkgname=mutter
 version=3.34.1
-revision=2
+revision=3
 build_helper="gir"
 build_style=meson
 configure_args="-Degl_device=true -Dudev=true -Dnative_backend=true

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PR PATCH] [Updated] pipewire: update to 0.3.4
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (28 preceding siblings ...)
  2020-04-30 21:42 ` [PR PATCH] [Updated] " sirn
@ 2020-05-01 10:35 ` sirn
  2020-05-01 10:36 ` sirn
                   ` (21 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-05-01 10:35 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 785 bytes --]

There is an updated pull request by sirn against master on the void-packages repository

https://github.com/sirn/void-packages pipewire-update
https://github.com/void-linux/void-packages/pull/20413

pipewire: update to 0.3.4
This PR updates `pipewire` to 0.3.4 and also updating/patching all packages that depends on it. 

* `xdg-desktop-portal` includes a patch backported from 1.7.0 to allow 1.6.0 to build against pipewire-0.3 (1.7.x is prerelease)
* `xdg-desktop-portal-kde` already includes Pipewire 0.3 support and only requires revbump.
* `mutter` includes a patch backported from 3.35 to allow 3.34 to build against pipewire-0.3 (upgrading to >=3.35 also requires upgrading GNOME).

A patch file from https://github.com/void-linux/void-packages/pull/20413.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pipewire-update-20413.patch --]
[-- Type: text/x-diff, Size: 54847 bytes --]

From 19c49156336625e3dd5244fd5d22c11407bd5d98 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:23:52 +0900
Subject: [PATCH 1/4] pipewire: update to 0.3.4

---
 common/shlibs                                 |   2 +-
 srcpkgs/alsa-pipewire                         |   1 +
 srcpkgs/libjack-pipewire                      |   1 +
 srcpkgs/libpulseaudio-pipewire                |   1 +
 .../patches/01-fix-format-warning.patch       |  37 ++++++
 .../patches/02-fix-spa_log_func-musl.patch    |  25 ++++
 srcpkgs/pipewire/template                     | 120 ++++++++++++------
 7 files changed, 147 insertions(+), 40 deletions(-)
 create mode 120000 srcpkgs/alsa-pipewire
 create mode 120000 srcpkgs/libjack-pipewire
 create mode 120000 srcpkgs/libpulseaudio-pipewire
 create mode 100644 srcpkgs/pipewire/patches/01-fix-format-warning.patch
 create mode 100644 srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch

diff --git a/common/shlibs b/common/shlibs
index a208407b359..07279a7bc72 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3199,7 +3199,7 @@ libarcan_shmif_ext.so.0.11 arcan-0.5.4.3_1
 libarcan_shmif_server.so.0.11 arcan-0.5.4.3_1
 libarcan_tui.so.0.11 arcan-0.5.4.3_1
 liblwipv6.so.2 lwipv6-1.5a_1
-libpipewire-0.2.so.1 libpipewire-0.2.2_1
+libpipewire-0.3.so.0 libpipewire-0.3.4_1
 libvolk.so.2.2.1 volk-2.2.1_1
 libgnuradio-runtime.so.3.8.0 gnuradio-3.8.0.0_1
 libgnuradio-pmt.so.3.8.0 gnuradio-3.8.0.0_1
diff --git a/srcpkgs/alsa-pipewire b/srcpkgs/alsa-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/alsa-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libjack-pipewire b/srcpkgs/libjack-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libjack-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libpulseaudio-pipewire b/srcpkgs/libpulseaudio-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libpulseaudio-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/pipewire/patches/01-fix-format-warning.patch b/srcpkgs/pipewire/patches/01-fix-format-warning.patch
new file mode 100644
index 00000000000..b4e8748390e
--- /dev/null
+++ b/srcpkgs/pipewire/patches/01-fix-format-warning.patch
@@ -0,0 +1,37 @@
+From 979a81a70d468d6482773521b89aaf67ce79b921 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Fri, 1 May 2020 11:05:38 +0200
+Subject: [PATCH] meson: add -Wformat
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+cc1: warning: ‘-Wformat-security’ ignored without ‘-Wformat’ [-Wformat-security]
+
+Fixes #234
+---
+ meson.build | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/meson.build b/meson.build
+index 74142587..1631e763 100644
+--- meson.build
++++ meson.build
+@@ -51,6 +51,7 @@ if cc.get_id() == 'gcc'
+ 			'-Wsign-compare',
+ 			'-Wimplicit-fallthrough',
+ 			'-Wpointer-arith',
++			'-Wformat',
+ 			'-Wformat-security',
+ 			'-Werror=suggest-attribute=format',
+ 			'-Wmissing-braces',
+@@ -68,6 +69,7 @@ if cc.get_id() == 'gcc'
+ 			'-Wsign-compare',
+ 			'-Wimplicit-fallthrough',
+ 			'-Wpointer-arith',
++			'-Wformat',
+ 			'-Wformat-security',
+ 			'-Werror=suggest-attribute=format',
+ 			'-Wmissing-braces',
+--
+2.26.2
diff --git a/srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch b/srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch
new file mode 100644
index 00000000000..b816975a6eb
--- /dev/null
+++ b/srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch
@@ -0,0 +1,25 @@
+From e83bf8a33f720050c7f1ec5f00530fafd5af5698 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Fri, 1 May 2020 11:18:28 +0200
+Subject: [PATCH] log: use printf attribute for log fallback
+
+Fixes #233
+---
+ spa/include/spa/support/log.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/spa/include/spa/support/log.h b/spa/include/spa/support/log.h
+index c97cc8e5..51b3e741 100644
+--- spa/include/spa/support/log.h
++++ spa/include/spa/support/log.h
+@@ -139,7 +139,7 @@ struct spa_log_methods {
+ #else
+
+ #define SPA_LOG_FUNC(name,lev)							\
+-static inline void spa_log_##name (struct spa_log *l, const char *format, ...)  \
++static inline SPA_PRINTF_FUNC(2,3) void spa_log_##name (struct spa_log *l, const char *format, ...)  \
+ {										\
+ 	if (SPA_UNLIKELY(spa_log_level_enabled(l, lev))) {			\
+ 		va_list varargs;						\
+--
+2.26.2
diff --git a/srcpkgs/pipewire/template b/srcpkgs/pipewire/template
index 7f646dad11d..2d1fc3d006c 100644
--- a/srcpkgs/pipewire/template
+++ b/srcpkgs/pipewire/template
@@ -1,66 +1,108 @@
 # Template file for 'pipewire'
 pkgname=pipewire
-version=0.2.7
+version=0.3.4
 revision=1
 build_style=meson
-configure_args="-Dman=true -Dgstreamer=enabled -Ddocs=true -Dsystemd=false"
+configure_args="-Dman=true -Dgstreamer=true -Ddocs=true -Dsystemd=false
+ -Dbluez5=true -Dffmpeg=true -Dpipewire-alsa=true -Dpipewire-jack=true
+ -Dpipewire-pulseaudio=true"
 hostmakedepends="doxygen graphviz pkg-config xmltoman"
 makedepends="SDL2-devel ffmpeg-devel gst-plugins-base1-devel jack-devel
- sbc-devel v4l-utils-devel libva-devel"
+ sbc-devel v4l-utils-devel libva-devel libbluetooth-devel"
 short_desc="Server and user space API to deal with multimedia pipelines"
-maintainer="Orphaned <orphan@voidlinux.org>"
-#Next release will probably change to MIT, currently listed in master
-license="LGPL-2.1-only, GPL-2.0-only "
+maintainer="Kridsada Thanabulpong <sirn@ogsite.net>"
+license="MIT"
 homepage="https://pipewire.org/"
-changelog="https://raw.githubusercontent.com/PipeWire/pipewire/master/NEWS"
-distfiles="https://github.com/PipeWire/pipewire/archive/${version}.tar.gz"
-checksum=bfaa0f6ae6c0791e2e0b59234d399753bf24f1b33dbf587682363a8463dd8df1
+changelog="https://gitlab.freedesktop.org/pipewire/pipewire/-/raw/master/NEWS"
+distfiles="https://gitlab.freedesktop.org/pipewire/pipewire/-/archive/${version}/pipewire-${version}.tar.gz"
+checksum=6a1c9c671514c84b38ce96d51823354702bc4d5dbaba12d501faa0448f892515
 conf_files="/etc/pipewire/pipewire.conf"
 
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+        makedepends+=" libatomic-devel"
+        LDFLAGS+=" -latomic"
+fi
+
+post_install() {
+        vlicense LICENSE
+}
+
+post_patch() {
+        # https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/233
+        vsed -i meson.build -e 's|have_neon = .*|have_neon = false|g'
+}
+
 libpipewire_package() {
-	short_desc+=" - pipewire library"
-	pkg_install() {
-		vmove "usr/lib/libpipewire-0.2.so.*"
-	}
+        short_desc+=" - pipewire library"
+        pkg_install() {
+                vmove "usr/lib/libpipewire-0.3.so.*"
+                vmove "usr/lib/pipewire-0.3/*.so"
+        }
 }
 
 pipewire-devel_package() {
-	depends="libpipewire-${version}_${revision}"
-	short_desc+=" - pipewire and libspa development files"
-	pkg_install() {
-		vmove usr/include/pipewire
-		vmove usr/include/spa
-		vmove usr/lib/pkgconfig/libpipewire-0.2.pc
-		vmove usr/lib/pkgconfig/libspa-0.1.pc
-		vmove usr/lib/libpipewire-0.2.so
-	}
+        depends="libpipewire-${version}_${revision}"
+        short_desc+=" - pipewire and libspa development files"
+        pkg_install() {
+                vmove usr/include/pipewire-0.3
+                vmove usr/include/spa-0.2
+                vmove usr/lib/pkgconfig/libpipewire-0.3.pc
+                vmove usr/lib/pkgconfig/libspa-0.2.pc
+                vmove usr/lib/libpipewire-0.3.so
+        }
 }
 
 libspa-ffmpeg_package() {
-	short_desc+=" - ffmpeg plugins"
-	pkg_install() {
-		vmove usr/lib/spa/ffmpeg
-	}
+        short_desc+=" - ffmpeg plugins"
+        pkg_install() {
+                vmove usr/lib/spa-0.2/ffmpeg
+        }
 }
 
 libspa-bluetooth_package() {
-	short_desc+=" - bluetooth plugins"
-	pkg_install() {
-		vmove usr/lib/spa/bluez5
-	}
+        short_desc+=" - bluetooth plugins"
+        pkg_install() {
+                vmove usr/lib/spa-0.2/bluez5
+        }
 }
 
 gstreamer1-pipewire_package() {
-	short_desc+=" - gstreamer plugin"
-	pkg_install() {
-		vmove usr/lib/gstreamer-1.0
-	}
+        short_desc+=" - gstreamer plugin"
+        pkg_install() {
+                vmove usr/lib/gstreamer-1.0
+        }
+}
+
+libpulseaudio-pipewire_package() {
+        depends="libpipewire-${version}_${revision}"
+        short_desc+=" - PulseAudio client library"
+        pkg_install() {
+                vmove usr/lib/pipewire-0.3/pulse
+                vmove usr/bin/pw-pulse
+        }
+}
+
+alsa-pipewire_package() {
+        depends="libpipewire-${version}_${revision}"
+        short_desc+=" - ALSA client library"
+        pkg_install() {
+                vmove usr/lib/alsa-lib
+        }
+}
+
+libjack-pipewire_package() {
+        depends="libpipewire-${version}_${revision}"
+        short_desc+=" - JACK client library"
+        pkg_install() {
+                vmove usr/lib/pipewire-0.3/jack
+                vmove usr/bin/pw-jack
+        }
 }
 
 pipewire-doc_package() {
-	archs=noarch
-	short_desc+=" - documentation"
-	pkg_install() {
-		vmove usr/share/doc
-	}
+        archs=noarch
+        short_desc+=" - documentation"
+        pkg_install() {
+                vmove usr/share/doc
+        }
 }

From 3eb77d83e0a1edd2e0bd2ebc48a0a40828be4962 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:46 +0900
Subject: [PATCH 2/4] xdg-desktop-portal-kde: rebuild for pipewire-0.3

---
 srcpkgs/xdg-desktop-portal-kde/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xdg-desktop-portal-kde/template b/srcpkgs/xdg-desktop-portal-kde/template
index f26057d323a..9519abc19f6 100644
--- a/srcpkgs/xdg-desktop-portal-kde/template
+++ b/srcpkgs/xdg-desktop-portal-kde/template
@@ -1,7 +1,7 @@
 # Template file for 'xdg-desktop-portal-kde'
 pkgname=xdg-desktop-portal-kde
 version=5.18.4.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules qt5-qmake qt5-host-tools kcoreaddons gettext"
 makedepends="glib-devel kio-devel kwayland-devel libepoxy-devel pipewire-devel

From f6e60ceb7cd1a87d7f8797b8642f58226b4e83b9 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:26 +0900
Subject: [PATCH 3/4] xdg-desktop-portal: rebuild for pipewire-0.3

---
 .../patches/pipewire-0.3.patch                | 551 ++++++++++++++++++
 srcpkgs/xdg-desktop-portal/template           |   8 +-
 2 files changed, 557 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch

diff --git a/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..94ebe083598
--- /dev/null
+++ b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
@@ -0,0 +1,551 @@
+From a38901e5e7f835efe7b7a06c55790c8c20bc91a2 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Tue, 14 Jan 2020 09:37:09 +0100
+Subject: [PATCH] PipeWire: update to 0.3 API
+
+---
+ configure.ac      |   2 +-
+ src/camera.c      |  24 ++++----
+ src/pipewire.c    | 141 +++++++++++++---------------------------------
+ src/pipewire.h    |  10 ++--
+ src/screen-cast.c |  98 ++++++--------------------------
+ 5 files changed, 72 insertions(+), 203 deletions(-)
+
+diff --git configure.ac configure.ac
+index 89902fa..62d7960 100644
+--- configure.ac
++++ configure.ac
+@@ -97,7 +97,7 @@ AC_ARG_ENABLE(pipewire,
+ 	      [AS_HELP_STRING([--enable-pipewire],[Enable PipeWire support. Needed for screen cast portal])],
+ 	      enable_pipewire=$enableval, enable_pipewire=yes)
+ if test x$enable_pipewire = xyes ; then
+-	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.2 >= 0.2.6])
++	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.3 >= 0.2.90])
+ 	AC_DEFINE([HAVE_PIPEWIRE],[1], [Define to enable PipeWire support])
+ fi
+ AM_CONDITIONAL([HAVE_PIPEWIRE],[test "$enable_pipewire" = "yes"])
+diff --git src/camera.c src/camera.c
+index c2b392c..20fe3aa 100644
+--- src/camera.c
++++ src/camera.c
+@@ -141,7 +141,7 @@ open_pipewire_camera_remote (const char *app_id,
+                              GError **error)
+ {
+   PipeWireRemote *remote;
+-  struct spa_dict_item permission_items[1];
++  struct pw_permission permission_items[2];
+   struct pw_properties *pipewire_properties;
+ 
+   pipewire_properties =
+@@ -158,12 +158,12 @@ open_pipewire_camera_remote (const char *app_id,
+    * Hide all existing and future nodes by default. PipeWire will use the
+    * permission store to set up permissions.
+    */
+-  permission_items[0].key = PW_CORE_PROXY_PERMISSIONS_DEFAULT;
+-  permission_items[0].value = "---";
++  permission_items[0] = PW_PERMISSION_INIT (PW_ID_CORE, PW_PERM_RWX);
++  permission_items[1] = PW_PERMISSION_INIT (PW_ID_ANY, 0);
+ 
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             &SPA_DICT_INIT (permission_items,
+-                                             G_N_ELEMENTS (permission_items)));
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                G_N_ELEMENTS (permission_items),
++                                permission_items);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -219,7 +219,7 @@ handle_open_pipewire_remote (XdpCamera *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
+@@ -250,29 +250,28 @@ camera_iface_init (XdpCameraIface *iface)
+ static void
+ global_added_cb (PipeWireRemote *remote,
+                  uint32_t id,
+-                 uint32_t type,
++                 const char *type,
+                  const struct spa_dict *props,
+                  gpointer user_data)
+ {
+   Camera *camera = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *media_class;
+   const struct spa_dict_item *media_role;
+ 
+-  if (type != core_type->node)
++  if (strcmp(type, PW_TYPE_INTERFACE_Node) != 0)
+     return;
+ 
+   if (!props)
+     return;
+ 
+-  media_class = spa_dict_lookup_item (props, "media.class");
++  media_class = spa_dict_lookup_item (props, PW_KEY_MEDIA_CLASS);
+   if (!media_class)
+     return;
+ 
+   if (g_strcmp0 (media_class->value, "Video/Source") != 0)
+     return;
+ 
+-  media_role = spa_dict_lookup_item (props, "media.role");
++  media_role = spa_dict_lookup_item (props, PW_KEY_MEDIA_ROLE);
+   if (!media_role)
+     return;
+ 
+@@ -342,6 +341,7 @@ create_pipewire_remote (Camera *camera,
+     }
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.is_portal", "true",
++                                           "portal.monitor", "Camera",
+                                            NULL);
+   camera->pipewire_remote = pipewire_remote_new_sync (pipewire_properties,
+                                                       global_added_cb,
+diff --git src/pipewire.c src/pipewire.c
+index 793a378..162cd55 100644
+--- src/pipewire.c
++++ src/pipewire.c
+@@ -21,6 +21,7 @@
+ #include <errno.h>
+ #include <glib.h>
+ #include <pipewire/pipewire.h>
++#include <spa/utils/result.h>
+ 
+ #include "pipewire.h"
+ 
+@@ -36,27 +37,25 @@ static gboolean is_pipewire_initialized = FALSE;
+ static void
+ registry_event_global (void *user_data,
+                        uint32_t id,
+-                       uint32_t parent_id,
+                        uint32_t permissions,
+-                       uint32_t type,
++                       const char *type,
+                        uint32_t version,
+                        const struct spa_dict *props)
+ {
+   PipeWireRemote *remote = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *factory_object_type;
+   PipeWireGlobal *global;
+ 
+   global = g_new0 (PipeWireGlobal, 1);
+   *global = (PipeWireGlobal) {
+-    .parent_id = parent_id,
++    .parent_id = id,
+   };
+ 
+   g_hash_table_insert (remote->globals, GINT_TO_POINTER (id), global);
+   if (remote->global_added_cb)
+     remote->global_added_cb (remote, id, type, props, remote->user_data);
+ 
+-  if (type != core_type->factory)
++  if (strcmp(type, PW_TYPE_INTERFACE_Factory) != 0)
+     return;
+ 
+   factory_object_type = spa_dict_lookup_item (props, "factory.type.name");
+@@ -81,8 +80,8 @@ registry_event_global_remove (void *user_data,
+   g_hash_table_remove (remote->globals, GINT_TO_POINTER (id));
+ }
+ 
+-static const struct pw_registry_proxy_events registry_events = {
+-  PW_VERSION_REGISTRY_PROXY_EVENTS,
++static const struct pw_registry_events registry_events = {
++  PW_VERSION_REGISTRY_EVENTS,
+   .global = registry_event_global,
+   .global_remove = registry_event_global_remove,
+ };
+@@ -90,7 +89,7 @@ static const struct pw_registry_proxy_events registry_events = {
+ void
+ pipewire_remote_roundtrip (PipeWireRemote *remote)
+ {
+-  pw_core_proxy_sync (remote->core_proxy, ++remote->sync_seq);
++  remote->sync_seq = pw_core_sync (remote->core, PW_ID_CORE, remote->sync_seq);
+   pw_main_loop_run (remote->loop);
+ }
+ 
+@@ -98,16 +97,13 @@ static gboolean
+ discover_node_factory_sync (PipeWireRemote *remote,
+                             GError **error)
+ {
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+-  struct pw_registry_proxy *registry_proxy;
++  struct pw_registry *registry;
+ 
+-  registry_proxy = pw_core_proxy_get_registry (remote->core_proxy,
+-                                               core_type->registry,
+-                                               PW_VERSION_REGISTRY, 0);
+-  pw_registry_proxy_add_listener (registry_proxy,
+-                                  &remote->registry_listener,
+-                                  &registry_events,
+-                                  remote);
++  registry = pw_core_get_registry (remote->core, PW_VERSION_REGISTRY, 0);
++  pw_registry_add_listener (registry,
++                            &remote->registry_listener,
++                            &registry_events,
++                            remote);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -122,59 +118,35 @@ discover_node_factory_sync (PipeWireRemote *remote,
+ }
+ 
+ static void
+-on_state_changed (void *user_data,
+-                  enum pw_remote_state old,
+-                  enum pw_remote_state state,
+-                  const char *error)
++core_event_error (void       *user_data,
++                  uint32_t    id,
++		  int         seq,
++		  int         res,
++		  const char *message)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  switch (state)
++  if (id == PW_ID_CORE)
+     {
+-    case PW_REMOTE_STATE_ERROR:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "%s", error);
+-        }
++      g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
++                 "%s", message);
+       pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "Disconnected");
+-        }
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    default:
+-      g_warning ("Unknown PipeWire state");
+-      break;
+     }
+ }
+ 
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
+-};
+-
+ static void
+ core_event_done (void *user_data,
+-                 uint32_t seq)
++                 uint32_t id, int seq)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  if (remote->sync_seq == seq)
++  if (id == PW_ID_CORE && remote->sync_seq == seq)
+     pw_main_loop_quit (remote->loop);
+ }
+ 
+-static const struct pw_core_proxy_events core_events = {
+-  PW_VERSION_CORE_PROXY_EVENTS,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = core_event_error,
+   .done = core_event_done,
+ };
+ 
+@@ -237,8 +209,8 @@ void
+ pipewire_remote_destroy (PipeWireRemote *remote)
+ {
+   g_clear_pointer (&remote->globals, g_hash_table_destroy);
+-  g_clear_pointer (&remote->remote, pw_remote_destroy);
+-  g_clear_pointer (&remote->core, pw_core_destroy);
++  g_clear_pointer (&remote->core, pw_core_disconnect);
++  g_clear_pointer (&remote->context, pw_context_destroy);
+   g_clear_pointer (&remote->loop, pw_main_loop_destroy);
+   g_clear_error (&remote->error);
+ 
+@@ -307,68 +279,31 @@ pipewire_remote_new_sync (struct pw_properties *pipewire_properties,
+       return NULL;
+     }
+ 
+-  remote->core = pw_core_new (pw_main_loop_get_loop (remote->loop), NULL);
+-  if (!remote->core)
++  remote->context = pw_context_new (pw_main_loop_get_loop (remote->loop), NULL, 0);
++  if (!remote->context)
+     {
+       pipewire_remote_destroy (remote);
+       pw_properties_free (pipewire_properties);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire core");
++                   "Couldn't create PipeWire context");
+       return NULL;
+     }
+ 
+-  remote->remote = pw_remote_new (remote->core, pipewire_properties, 0);
+-  if (!remote->remote)
++  remote->core = pw_context_connect (remote->context, pipewire_properties, 0);
++  if (!remote->core)
+     {
+       pipewire_remote_destroy (remote);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire remote");
++                   "Couldn't connect to PipeWire");
+       return NULL;
+     }
+ 
+   remote->globals = g_hash_table_new_full (NULL, NULL, NULL, g_free);
+ 
+-  pw_remote_add_listener (remote->remote,
+-                          &remote->remote_listener,
+-                          &remote_events,
+-                          remote);
+-
+-  if (pw_remote_connect (remote->remote) != 0)
+-    {
+-      pipewire_remote_destroy (remote);
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect PipeWire remote");
+-      return NULL;
+-    }
+-
+-  pw_main_loop_run (remote->loop);
+-
+-  switch (pw_remote_get_state (remote->remote, NULL))
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      *error = g_steal_pointer (&remote->error);
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "PipeWire loop stopped unexpectedly");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      break;
+-    default:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Unexpected PipeWire state");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    }
+-
+-  remote->core_proxy = pw_remote_get_core_proxy (remote->remote);
+-  pw_core_proxy_add_listener (remote->core_proxy,
+-                              &remote->core_listener,
+-                              &core_events,
+-                              remote);
++  pw_core_add_listener (remote->core,
++                        &remote->core_listener,
++                        &core_events,
++                        remote);
+ 
+   if (!discover_node_factory_sync (remote, error))
+     {
+diff --git src/pipewire.h src/pipewire.h
+index 0f1bf54..bf48d5e 100644
+--- src/pipewire.h
++++ src/pipewire.h
+@@ -32,7 +32,7 @@ typedef struct _PipeWireGlobal
+ 
+ typedef void (* PipeWireGlobalAddedCallback) (PipeWireRemote *remote,
+                                               uint32_t id,
+-                                              uint32_t type,
++                                              const char *type,
+                                               const struct spa_dict *props,
+                                               gpointer user_data);
+ 
+@@ -43,13 +43,11 @@ typedef void (* PipeWireGlobalRemovedCallback) (PipeWireRemote *remote,
+ struct _PipeWireRemote
+ {
+   struct pw_main_loop *loop;
++  struct pw_context *context;
+   struct pw_core *core;
+-  struct pw_remote *remote;
+-  struct spa_hook remote_listener;
+-
+-  struct pw_core_proxy *core_proxy;
+   struct spa_hook core_listener;
+-  uint32_t sync_seq;
++
++  int sync_seq;
+ 
+   struct spa_hook registry_listener;
+ 
+diff --git src/screen-cast.c src/screen-cast.c
+index 7881ddc..1677050 100644
+--- src/screen-cast.c
++++ src/screen-cast.c
+@@ -31,10 +31,10 @@
+ #include "xdp-impl-dbus.h"
+ #include "xdp-utils.h"
+ 
+-#define PERMISSION_ITEM(item_key, item_value) \
+-  ((struct spa_dict_item) { \
+-    .key = item_key, \
+-    .value = item_value \
++#define PERMISSION_ITEM(item_id, item_permissions) \
++  ((struct pw_permission) { \
++    .id = item_id, \
++    .permissions = item_permissions \
+   })
+ 
+ typedef struct _ScreenCast ScreenCast;
+@@ -517,42 +517,9 @@ screen_cast_stream_get_pipewire_node_id (ScreenCastStream *stream)
+   return stream->id;
+ }
+ 
+-static void
+-append_parent_permissions (PipeWireRemote *remote,
+-                           GArray *permission_items,
+-                           GList **string_stash,
+-                           PipeWireGlobal *global,
+-                           const char *permission)
+-{
+-  PipeWireGlobal *parent;
+-  char *parent_permission_value;
+-
+-  if (global->parent_id == 0)
+-    return;
+-
+-  parent = g_hash_table_lookup (remote->globals, GINT_TO_POINTER (global->parent_id));
+-
+-  if (parent->permission_set)
+-    return;
+-  parent->permission_set = TRUE;
+-
+-  append_parent_permissions (remote, permission_items, string_stash,
+-                             parent, permission);
+-
+-  parent_permission_value = g_strdup_printf ("%u:%s",
+-                                             global->parent_id,
+-                                             permission);
+-  *string_stash = g_list_prepend (*string_stash, parent_permission_value);
+-
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       parent_permission_value));
+-}
+-
+ static void
+ append_stream_permissions (PipeWireRemote *remote,
+                            GArray *permission_items,
+-                           GList **string_stash,
+                            GList *streams)
+ {
+   GList *l;
+@@ -561,21 +528,10 @@ append_stream_permissions (PipeWireRemote *remote,
+     {
+       ScreenCastStream *stream = l->data;
+       uint32_t stream_id;
+-      PipeWireGlobal *stream_global;
+-      char *stream_permission_value;
+ 
+       stream_id = screen_cast_stream_get_pipewire_node_id (stream);
+-      stream_global = g_hash_table_lookup (remote->globals,
+-                                           GINT_TO_POINTER (stream_id));
+-
+-      append_parent_permissions (remote, permission_items, string_stash,
+-                                 stream_global, "r--");
+-
+-      stream_permission_value = g_strdup_printf ("%u:rwx", stream_id);
+-      *string_stash = g_list_prepend (*string_stash, stream_permission_value);
+       g_array_append_val (permission_items,
+-                          PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                           stream_permission_value));
++                          PERMISSION_ITEM (stream_id, PW_PERM_RWX));
+     }
+ }
+ 
+@@ -587,9 +543,6 @@ open_pipewire_screen_cast_remote (const char *app_id,
+   struct pw_properties *pipewire_properties;
+   PipeWireRemote *remote;
+   g_autoptr(GArray) permission_items = NULL;
+-  char *node_factory_permission_string;
+-  GList *string_stash = NULL;
+-  struct spa_dict *permission_dict;
+   PipeWireGlobal *node_global;
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.app_id", app_id,
+@@ -603,48 +556,31 @@ open_pipewire_screen_cast_remote (const char *app_id,
+ 
+   permission_items = g_array_new (FALSE, TRUE, sizeof (struct spa_dict_item));
+ 
+-  /*
+-   * Hide all existing and future nodes (except the ones we explicitly list below.
+-   */
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_EXISTING,
+-                                       "---"));
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_DEFAULT,
+-                                       "---"));
+-
+   /*
+    * PipeWire:Interface:Core
+    * Needs rwx to be able create the sink node using the create-object method
+    */
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       "0:rwx"));
++                      PERMISSION_ITEM (PW_ID_CORE, PW_PERM_RWX));
+ 
+   /*
+    * PipeWire:Interface:NodeFactory
+    * Needs r-- so it can be passed to create-object when creating the sink node.
+    */
+-  node_factory_permission_string = g_strdup_printf ("%d:r--",
+-                                                    remote->node_factory_id);
+-  string_stash = g_list_prepend (string_stash, node_factory_permission_string);
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       node_factory_permission_string));
+-  node_global = g_hash_table_lookup (remote->globals,
+-                                     GINT_TO_POINTER (remote->node_factory_id));
+-  append_parent_permissions (remote, permission_items, &string_stash,
+-                             node_global, "r--");
++                      PERMISSION_ITEM (remote->node_factory_id, PW_PERM_R));
+ 
+-  append_stream_permissions (remote, permission_items, &string_stash, streams);
++  append_stream_permissions (remote, permission_items, streams);
+ 
+-  permission_dict =
+-    &SPA_DICT_INIT ((struct spa_dict_item *) permission_items->data,
+-                    permission_items->len);
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             permission_dict);
++  /*
++   * Hide all existing and future nodes (except the ones we explicitly list above).
++   */
++  g_array_append_val (permission_items,
++                      PERMISSION_ITEM (PW_ID_ANY, 0));
+ 
+-  g_list_free_full (string_stash, g_free);
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                permission_items->len,
++                                (const struct pw_permission *)permission_items->data);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -943,7 +879,7 @@ handle_open_pipewire_remote (XdpScreenCast *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
diff --git a/srcpkgs/xdg-desktop-portal/template b/srcpkgs/xdg-desktop-portal/template
index eb8a4602f5d..1136b6a6e0e 100644
--- a/srcpkgs/xdg-desktop-portal/template
+++ b/srcpkgs/xdg-desktop-portal/template
@@ -1,10 +1,10 @@
 # Template file for 'xdg-desktop-portal'
 pkgname=xdg-desktop-portal
 version=1.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-pipewire --enable-geoclue --disable-libportal"
-hostmakedepends="pkg-config glib-devel"
+hostmakedepends="automake libtool gettext-devel pkg-config glib-devel"
 makedepends="flatpak-devel fuse-devel pipewire-devel geoclue2-devel"
 short_desc="Portal frontend service for Flatpak"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -13,6 +13,10 @@ homepage="https://github.com/flatpak/xdg-desktop-portal"
 distfiles="https://github.com/flatpak/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.xz"
 checksum=883c9c9a925e48af54812b5347f546dd776ec2e27076a83d5a8126af6bafb9da
 
+pre_configure() {
+	autoreconf -vfi
+}
+
 post_install() {
 	rm -rf "${DESTDIR}/usr/lib/systemd"
 }

From 97b3f09ded23a98e0f5d0ff2bd97f63d409c124e Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Thu, 30 Apr 2020 06:17:17 +0900
Subject: [PATCH 4/4] mutter: rebuild for pipewire-0.3

---
 srcpkgs/mutter/patches/pipewire-0.3.patch | 521 ++++++++++++++++++++++
 srcpkgs/mutter/template                   |   2 +-
 2 files changed, 522 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/mutter/patches/pipewire-0.3.patch

diff --git a/srcpkgs/mutter/patches/pipewire-0.3.patch b/srcpkgs/mutter/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..ebff65fba85
--- /dev/null
+++ b/srcpkgs/mutter/patches/pipewire-0.3.patch
@@ -0,0 +1,521 @@
+Build mutter against pipewire-0.3, based on a patch at:
+https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1062
+--- meson.build
++++ meson.build
+@@ -50,7 +50,7 @@ libinput_req = '>= 1.7'
+ gbm_req = '>= 10.3'
+
+ # screen cast version requirements
+-libpipewire_req = '>= 0.2.5'
++libpipewire_req = '>= 0.3.0'
+
+ gnome = import('gnome')
+ pkg = import('pkgconfig')
+@@ -241,7 +241,7 @@ endif
+
+ have_remote_desktop = get_option('remote_desktop')
+ if have_remote_desktop
+-  libpipewire_dep = dependency('libpipewire-0.2', version: libpipewire_req)
++  libpipewire_dep = dependency('libpipewire-0.3', version: libpipewire_req)
+ endif
+
+ have_introspection = get_option('introspection')
+diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
+index 82c5cba436..ba1ce94a7e 100644
+--- src/backends/meta-screen-cast-stream-src.c
++++ src/backends/meta-screen-cast-stream-src.c
+@@ -29,6 +29,7 @@
+ #include <spa/param/props.h>
+ #include <spa/param/format-utils.h>
+ #include <spa/param/video/format-utils.h>
++#include <spa/utils/result.h>
+ #include <stdint.h>
+ #include <sys/mman.h>
+
+@@ -62,15 +63,6 @@ enum
+
+ static guint signals[N_SIGNALS];
+
+-typedef struct _MetaSpaType
+-{
+-  struct spa_type_media_type media_type;
+-  struct spa_type_media_subtype media_subtype;
+-  struct spa_type_format_video format_video;
+-  struct spa_type_video_format video_format;
+-  uint32_t meta_cursor;
+-} MetaSpaType;
+-
+ typedef struct _MetaPipeWireSource
+ {
+   GSource base;
+@@ -82,19 +74,19 @@ typedef struct _MetaScreenCastStreamSrcPrivate
+ {
+   MetaScreenCastStream *stream;
+
++  struct pw_context *pipewire_context;
+   struct pw_core *pipewire_core;
+-  struct pw_remote *pipewire_remote;
+-  struct pw_type *pipewire_type;
+   MetaPipeWireSource *pipewire_source;
+-  struct spa_hook pipewire_remote_listener;
++  struct spa_hook pipewire_core_listener;
+
+   gboolean is_enabled;
+
+   struct pw_stream *pipewire_stream;
+   struct spa_hook pipewire_stream_listener;
++  uint32_t node_id;
+
+-  MetaSpaType spa_type;
+   struct spa_video_info_raw video_format;
++  int video_stride;
+
+   uint64_t last_frame_timestamp_us;
+
+@@ -112,8 +104,6 @@ G_DEFINE_TYPE_WITH_CODE (MetaScreenCastStreamSrc,
+                                                 meta_screen_cast_stream_src_init_initable_iface)
+                          G_ADD_PRIVATE (MetaScreenCastStreamSrc))
+
+-#define PROP_RANGE(min, max) 2, (min), (max)
+-
+ static void
+ meta_screen_cast_stream_src_get_specs (MetaScreenCastStreamSrc *src,
+                                        int                     *width,
+@@ -286,9 +276,6 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+                                                               int                      x,
+                                                               int                      y)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+
+   spa_meta_cursor->id = 1;
+@@ -300,7 +287,7 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   spa_meta_cursor->hotspot.x = 0;
+@@ -317,9 +304,6 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+                                                         int                      y,
+                                                         float                    scale)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   CoglTexture *cursor_texture;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+   int hotspot_x, hotspot_y;
+@@ -346,7 +330,7 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
+@@ -382,12 +366,10 @@ static void
+ add_cursor_metadata (MetaScreenCastStreamSrc *src,
+                      struct spa_buffer       *spa_buffer)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_cursor *spa_meta_cursor;
+
+-  spa_meta_cursor = spa_buffer_find_meta (spa_buffer, spa_type->meta_cursor);
++  spa_meta_cursor = spa_buffer_find_meta_data (spa_buffer, SPA_META_Cursor,
++                                               sizeof (*spa_meta_cursor));
+   if (spa_meta_cursor)
+     meta_screen_cast_stream_src_set_cursor_metadata (src, spa_meta_cursor);
+ }
+@@ -447,14 +429,14 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+     {
+       data = spa_buffer->datas[0].data;
+     }
+-  else if (spa_buffer->datas[0].type == priv->pipewire_type->data.MemFd)
++  else if (spa_buffer->datas[0].type == SPA_DATA_MemFd)
+     {
+       map = mmap (NULL, spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset,
+                   PROT_READ | PROT_WRITE, MAP_SHARED,
+                   spa_buffer->datas[0].fd, 0);
+       if (map == MAP_FAILED)
+         {
+-          g_warning ("Failed to mmap pipewire stream buffer: %s\n",
++          g_warning ("Failed to mmap pipewire stream buffer: %s",
+                      strerror (errno));
+           return;
+         }
+@@ -469,28 +451,30 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+
+   if (meta_screen_cast_stream_src_record_frame (src, data))
+     {
+-      struct spa_meta_video_crop *spa_meta_video_crop;
++      struct spa_meta_region *spa_meta_video_crop;
+
+       spa_buffer->datas[0].chunk->size = spa_buffer->datas[0].maxsize;
++      spa_buffer->datas[0].chunk->stride = priv->video_stride;
+
+       /* Update VideoCrop if needed */
+       spa_meta_video_crop =
+-        spa_buffer_find_meta (spa_buffer, priv->pipewire_type->meta.VideoCrop);
++        spa_buffer_find_meta_data (spa_buffer, SPA_META_VideoCrop,
++                                   sizeof (*spa_meta_video_crop));
+       if (spa_meta_video_crop)
+         {
+           if (meta_screen_cast_stream_src_get_videocrop (src, &crop_rect))
+             {
+-              spa_meta_video_crop->x = crop_rect.x;
+-              spa_meta_video_crop->y = crop_rect.y;
+-              spa_meta_video_crop->width = crop_rect.width;
+-              spa_meta_video_crop->height = crop_rect.height;
++              spa_meta_video_crop->region.position.x = crop_rect.x;
++              spa_meta_video_crop->region.position.y = crop_rect.y;
++              spa_meta_video_crop->region.size.width = crop_rect.width;
++              spa_meta_video_crop->region.size.height = crop_rect.height;
+             }
+           else
+             {
+-              spa_meta_video_crop->x = 0;
+-              spa_meta_video_crop->y = 0;
+-              spa_meta_video_crop->width = priv->stream_width;
+-              spa_meta_video_crop->height = priv->stream_height;
++              spa_meta_video_crop->region.position.x = 0;
++              spa_meta_video_crop->region.position.y = 0;
++              spa_meta_video_crop->region.size.width = priv->stream_width;
++              spa_meta_video_crop->region.size.height = priv->stream_height;
+             }
+         }
+     }
+@@ -555,7 +539,6 @@ on_stream_state_changed (void                 *data,
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  uint32_t node_id;
+
+   switch (state)
+     {
+@@ -563,14 +546,12 @@ on_stream_state_changed (void                 *data,
+       g_warning ("pipewire stream error: %s", error_message);
+       meta_screen_cast_stream_src_notify_closed (src);
+       break;
+-    case PW_STREAM_STATE_CONFIGURE:
+-      node_id = pw_stream_get_node_id (priv->pipewire_stream);
+-      g_signal_emit (src, signals[READY], 0, (unsigned int) node_id);
+-      break;
+-    case PW_STREAM_STATE_UNCONNECTED:
+-    case PW_STREAM_STATE_CONNECTING:
+-    case PW_STREAM_STATE_READY:
+     case PW_STREAM_STATE_PAUSED:
++      if (priv->node_id == SPA_ID_INVALID && priv->pipewire_stream)
++        {
++          priv->node_id = pw_stream_get_node_id (priv->pipewire_stream);
++          g_signal_emit (src, signals[READY], 0, (unsigned int) priv->node_id);
++        }
+       if (meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_disable (src);
+       break;
+@@ -578,68 +559,69 @@ on_stream_state_changed (void                 *data,
+       if (!meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_enable (src);
+       break;
++    case PW_STREAM_STATE_UNCONNECTED:
++    case PW_STREAM_STATE_CONNECTING:
++      break;
+     }
+ }
+
+ static void
+-on_stream_format_changed (void                 *data,
+-                          const struct spa_pod *format)
++on_stream_param_changed (void                 *data,
++                         uint32_t              id,
++                         const struct spa_pod *format)
+ {
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   uint8_t params_buffer[1024];
+   int32_t width, height, stride, size;
+   struct spa_pod_builder pod_builder;
+   const struct spa_pod *params[3];
+   const int bpp = 4;
+
+-  if (!format)
+-    {
+-      pw_stream_finish_format (priv->pipewire_stream, 0, NULL, 0);
+-      return;
+-    }
++  if (!format || id != SPA_PARAM_Format)
++    return;
+
+   spa_format_video_raw_parse (format,
+-                              &priv->video_format,
+-                              &priv->spa_type.format_video);
++                              &priv->video_format);
+
+   width = priv->video_format.size.width;
+   height = priv->video_format.size.height;
+   stride = SPA_ROUND_UP_N (width * bpp, 4);
+   size = height * stride;
+
++  priv->video_stride = stride;
++
+   pod_builder = SPA_POD_BUILDER_INIT (params_buffer, sizeof (params_buffer));
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idBuffers, pipewire_type->param_buffers.Buffers,
+-    ":", pipewire_type->param_buffers.size, "i", size,
+-    ":", pipewire_type->param_buffers.stride, "i", stride,
+-    ":", pipewire_type->param_buffers.buffers, "iru", 16, PROP_RANGE (2, 16),
+-    ":", pipewire_type->param_buffers.align, "i", 16);
+-
+-  params[1] = spa_pod_builder_object (
++    SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
++    SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int (16, 2, 16),
++    SPA_PARAM_BUFFERS_blocks, SPA_POD_Int (1),
++    SPA_PARAM_BUFFERS_size, SPA_POD_Int (size),
++    SPA_PARAM_BUFFERS_stride, SPA_POD_Int (stride),
++    SPA_PARAM_BUFFERS_align, SPA_POD_Int (16));
++
++  params[1] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", pipewire_type->meta.VideoCrop,
+-    ":", pipewire_type->param_meta.size, "i", sizeof (struct spa_meta_video_crop));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_VideoCrop),
++    SPA_PARAM_META_size, SPA_POD_Int (sizeof (struct spa_meta_region)));
+
+-  params[2] = spa_pod_builder_object (
++  params[2] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", priv->spa_type.meta_cursor,
+-    ":", pipewire_type->param_meta.size, "i", CURSOR_META_SIZE (64, 64));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_Cursor),
++    SPA_PARAM_META_size, SPA_POD_Int (CURSOR_META_SIZE (64, 64)));
+
+-  pw_stream_finish_format (priv->pipewire_stream, 0,
+-                           params, G_N_ELEMENTS (params));
++  pw_stream_update_params (priv->pipewire_stream, params, G_N_ELEMENTS (params));
+ }
+
+ static const struct pw_stream_events stream_events = {
+   PW_VERSION_STREAM_EVENTS,
+   .state_changed = on_stream_state_changed,
+-  .format_changed = on_stream_format_changed,
++  .param_changed = on_stream_param_changed,
+ };
+
+ static struct pw_stream *
+@@ -652,8 +634,6 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   uint8_t buffer[1024];
+   struct spa_pod_builder pod_builder =
+     SPA_POD_BUILDER_INIT (buffer, sizeof (buffer));
+-  MetaSpaType *spa_type = &priv->spa_type;
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   float frame_rate;
+   MetaFraction frame_rate_fraction;
+   struct spa_fraction max_framerate;
+@@ -661,7 +641,9 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   const struct spa_pod *params[1];
+   int result;
+
+-  pipewire_stream = pw_stream_new (priv->pipewire_remote,
++  priv->node_id = SPA_ID_INVALID;
++
++  pipewire_stream = pw_stream_new (priv->pipewire_core,
+                                    "meta-screen-cast-src",
+                                    NULL);
+   if (!pipewire_stream)
+@@ -682,17 +664,17 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   max_framerate = SPA_FRACTION (frame_rate_fraction.num,
+                                 frame_rate_fraction.denom);
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idEnumFormat, pipewire_type->spa_format,
+-    "I", spa_type->media_type.video,
+-    "I", spa_type->media_subtype.raw,
+-    ":", spa_type->format_video.format, "I", spa_type->video_format.BGRx,
+-    ":", spa_type->format_video.size, "R", &SPA_RECTANGLE (priv->stream_width,
+-                                                           priv->stream_height),
+-    ":", spa_type->format_video.framerate, "F", &SPA_FRACTION (0, 1),
+-    ":", spa_type->format_video.max_framerate, "Fru", &max_framerate,
+-                                                      PROP_RANGE (&min_framerate,
++    SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
++    SPA_FORMAT_mediaType, SPA_POD_Id (SPA_MEDIA_TYPE_video),
++    SPA_FORMAT_mediaSubtype, SPA_POD_Id (SPA_MEDIA_SUBTYPE_raw),
++    SPA_FORMAT_VIDEO_format, SPA_POD_Id (SPA_VIDEO_FORMAT_BGRx),
++    SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle (&SPA_RECTANGLE (priv->stream_width,
++                                                              priv->stream_height)),
++    SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction (&SPA_FRACTION (0, 1)),
++    SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction (&max_framerate,
++                                                                  &min_framerate,
+                                                                   &max_framerate));
+
+   pw_stream_add_listener (pipewire_stream,
+@@ -702,7 +684,7 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+
+   result = pw_stream_connect (pipewire_stream,
+                               PW_DIRECTION_OUTPUT,
+-                              NULL,
++                              SPA_ID_INVALID,
+                               (PW_STREAM_FLAG_DRIVER |
+                                PW_STREAM_FLAG_MAP_BUFFERS),
+                               params, G_N_ELEMENTS (params));
+@@ -717,40 +699,18 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+ }
+
+ static void
+-on_state_changed (void                 *data,
+-                  enum pw_remote_state  old,
+-                  enum pw_remote_state  state,
+-                  const char           *error_message)
++on_core_error (void       *data,
++               uint32_t    id,
++	       int         seq,
++	       int         res,
++	       const char *message)
+ {
+   MetaScreenCastStreamSrc *src = data;
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_stream *pipewire_stream;
+-  GError *error = NULL;
+
+-  switch (state)
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-      g_warning ("pipewire remote error: %s\n", error_message);
+-      meta_screen_cast_stream_src_notify_closed (src);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pipewire_stream = create_pipewire_stream (src, &error);
+-      if (!pipewire_stream)
+-        {
+-          g_warning ("Could not create pipewire stream: %s", error->message);
+-          g_error_free (error);
+-          meta_screen_cast_stream_src_notify_closed (src);
+-        }
+-      else
+-        {
+-          priv->pipewire_stream = pipewire_stream;
+-        }
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    }
++  g_warning ("pipewire remote error: id:%u %s", id, message);
++
++  if (id == PW_ID_CORE && res == -EPIPE)
++    meta_screen_cast_stream_src_notify_closed (src);
+ }
+
+ static gboolean
+@@ -793,17 +753,6 @@ static GSourceFuncs pipewire_source_funcs =
+   pipewire_loop_source_finalize
+ };
+
+-static void
+-init_spa_type (MetaSpaType         *type,
+-               struct spa_type_map *map)
+-{
+-  spa_type_media_type_map (map, &type->media_type);
+-  spa_type_media_subtype_map (map, &type->media_subtype);
+-  spa_type_format_video_map (map, &type->format_video);
+-  spa_type_video_format_map (map, &type->video_format);
+-  type->meta_cursor = spa_type_map_get_id(map, SPA_TYPE_META__Cursor);
+-}
+-
+ static MetaPipeWireSource *
+ create_pipewire_source (void)
+ {
+@@ -829,9 +778,9 @@ create_pipewire_source (void)
+   return pipewire_source;
+ }
+
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = on_core_error,
+ };
+
+ static gboolean
+@@ -851,37 +800,31 @@ meta_screen_cast_stream_src_initable_init (GInitable     *initable,
+       return FALSE;
+     }
+
+-  priv->pipewire_core = pw_core_new (priv->pipewire_source->pipewire_loop,
+-                                     NULL);
+-  if (!priv->pipewire_core)
++  priv->pipewire_context = pw_context_new (priv->pipewire_source->pipewire_loop,
++                                           NULL, 0);
++  if (!priv->pipewire_context)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Failed to create pipewire core");
++                   "Failed to create pipewire context");
+       return FALSE;
+     }
+
+-  priv->pipewire_remote = pw_remote_new (priv->pipewire_core, NULL, 0);
+-  if (!priv->pipewire_remote)
++  priv->pipewire_core = pw_context_connect (priv->pipewire_context, NULL, 0);
++  if (!priv->pipewire_core)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't creat pipewire remote");
++                   "Couldn't connect pipewire context");
+       return FALSE;
+     }
+
+-  pw_remote_add_listener (priv->pipewire_remote,
+-                          &priv->pipewire_remote_listener,
+-                          &remote_events,
+-                          src);
++  pw_core_add_listener (priv->pipewire_core,
++                        &priv->pipewire_core_listener,
++                        &core_events,
++                        src);
+
+-  priv->pipewire_type = pw_core_get_type (priv->pipewire_core);
+-  init_spa_type (&priv->spa_type, priv->pipewire_type->map);
+-
+-  if (pw_remote_connect (priv->pipewire_remote) != 0)
+-    {
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect pipewire remote");
+-      return FALSE;
+-    }
++  priv->pipewire_stream = create_pipewire_stream (src, error);
++  if (!priv->pipewire_stream)
++    return FALSE;
+
+   return TRUE;
+ }
+@@ -912,8 +855,8 @@ meta_screen_cast_stream_src_finalize (GObject *object)
+     meta_screen_cast_stream_src_disable (src);
+
+   g_clear_pointer (&priv->pipewire_stream, pw_stream_destroy);
+-  g_clear_pointer (&priv->pipewire_remote, pw_remote_destroy);
+-  g_clear_pointer (&priv->pipewire_core, pw_core_destroy);
++  g_clear_pointer (&priv->pipewire_core, pw_core_disconnect);
++  g_clear_pointer (&priv->pipewire_context, pw_context_destroy);
+   g_source_destroy (&priv->pipewire_source->base);
+
+   G_OBJECT_CLASS (meta_screen_cast_stream_src_parent_class)->finalize (object);
diff --git a/srcpkgs/mutter/template b/srcpkgs/mutter/template
index 4e0bd32b67d..806a3bef9f0 100644
--- a/srcpkgs/mutter/template
+++ b/srcpkgs/mutter/template
@@ -1,7 +1,7 @@
 # Template file for 'mutter'
 pkgname=mutter
 version=3.34.1
-revision=2
+revision=3
 build_helper="gir"
 build_style=meson
 configure_args="-Degl_device=true -Dudev=true -Dnative_backend=true

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PR PATCH] [Updated] pipewire: update to 0.3.4
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (29 preceding siblings ...)
  2020-05-01 10:35 ` sirn
@ 2020-05-01 10:36 ` sirn
  2020-05-01 10:37 ` sirn
                   ` (20 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-05-01 10:36 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 785 bytes --]

There is an updated pull request by sirn against master on the void-packages repository

https://github.com/sirn/void-packages pipewire-update
https://github.com/void-linux/void-packages/pull/20413

pipewire: update to 0.3.4
This PR updates `pipewire` to 0.3.4 and also updating/patching all packages that depends on it. 

* `xdg-desktop-portal` includes a patch backported from 1.7.0 to allow 1.6.0 to build against pipewire-0.3 (1.7.x is prerelease)
* `xdg-desktop-portal-kde` already includes Pipewire 0.3 support and only requires revbump.
* `mutter` includes a patch backported from 3.35 to allow 3.34 to build against pipewire-0.3 (upgrading to >=3.35 also requires upgrading GNOME).

A patch file from https://github.com/void-linux/void-packages/pull/20413.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pipewire-update-20413.patch --]
[-- Type: text/x-diff, Size: 54682 bytes --]

From fa6113de01d92cedd8421de67496cbe7c5d9deb6 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:23:52 +0900
Subject: [PATCH 1/4] pipewire: update to 0.3.4

---
 common/shlibs                                 |   2 +-
 srcpkgs/alsa-pipewire                         |   1 +
 srcpkgs/libjack-pipewire                      |   1 +
 srcpkgs/libpulseaudio-pipewire                |   1 +
 .../patches/01-fix-format-warning.patch       |  37 ++++++
 .../patches/02-fix-spa_log_func-musl.patch    |  25 ++++
 srcpkgs/pipewire/template                     | 115 ++++++++++++------
 7 files changed, 142 insertions(+), 40 deletions(-)
 create mode 120000 srcpkgs/alsa-pipewire
 create mode 120000 srcpkgs/libjack-pipewire
 create mode 120000 srcpkgs/libpulseaudio-pipewire
 create mode 100644 srcpkgs/pipewire/patches/01-fix-format-warning.patch
 create mode 100644 srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch

diff --git a/common/shlibs b/common/shlibs
index a208407b359..07279a7bc72 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3199,7 +3199,7 @@ libarcan_shmif_ext.so.0.11 arcan-0.5.4.3_1
 libarcan_shmif_server.so.0.11 arcan-0.5.4.3_1
 libarcan_tui.so.0.11 arcan-0.5.4.3_1
 liblwipv6.so.2 lwipv6-1.5a_1
-libpipewire-0.2.so.1 libpipewire-0.2.2_1
+libpipewire-0.3.so.0 libpipewire-0.3.4_1
 libvolk.so.2.2.1 volk-2.2.1_1
 libgnuradio-runtime.so.3.8.0 gnuradio-3.8.0.0_1
 libgnuradio-pmt.so.3.8.0 gnuradio-3.8.0.0_1
diff --git a/srcpkgs/alsa-pipewire b/srcpkgs/alsa-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/alsa-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libjack-pipewire b/srcpkgs/libjack-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libjack-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libpulseaudio-pipewire b/srcpkgs/libpulseaudio-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libpulseaudio-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/pipewire/patches/01-fix-format-warning.patch b/srcpkgs/pipewire/patches/01-fix-format-warning.patch
new file mode 100644
index 00000000000..b4e8748390e
--- /dev/null
+++ b/srcpkgs/pipewire/patches/01-fix-format-warning.patch
@@ -0,0 +1,37 @@
+From 979a81a70d468d6482773521b89aaf67ce79b921 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Fri, 1 May 2020 11:05:38 +0200
+Subject: [PATCH] meson: add -Wformat
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+cc1: warning: ‘-Wformat-security’ ignored without ‘-Wformat’ [-Wformat-security]
+
+Fixes #234
+---
+ meson.build | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/meson.build b/meson.build
+index 74142587..1631e763 100644
+--- meson.build
++++ meson.build
+@@ -51,6 +51,7 @@ if cc.get_id() == 'gcc'
+ 			'-Wsign-compare',
+ 			'-Wimplicit-fallthrough',
+ 			'-Wpointer-arith',
++			'-Wformat',
+ 			'-Wformat-security',
+ 			'-Werror=suggest-attribute=format',
+ 			'-Wmissing-braces',
+@@ -68,6 +69,7 @@ if cc.get_id() == 'gcc'
+ 			'-Wsign-compare',
+ 			'-Wimplicit-fallthrough',
+ 			'-Wpointer-arith',
++			'-Wformat',
+ 			'-Wformat-security',
+ 			'-Werror=suggest-attribute=format',
+ 			'-Wmissing-braces',
+--
+2.26.2
diff --git a/srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch b/srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch
new file mode 100644
index 00000000000..b816975a6eb
--- /dev/null
+++ b/srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch
@@ -0,0 +1,25 @@
+From e83bf8a33f720050c7f1ec5f00530fafd5af5698 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Fri, 1 May 2020 11:18:28 +0200
+Subject: [PATCH] log: use printf attribute for log fallback
+
+Fixes #233
+---
+ spa/include/spa/support/log.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/spa/include/spa/support/log.h b/spa/include/spa/support/log.h
+index c97cc8e5..51b3e741 100644
+--- spa/include/spa/support/log.h
++++ spa/include/spa/support/log.h
+@@ -139,7 +139,7 @@ struct spa_log_methods {
+ #else
+
+ #define SPA_LOG_FUNC(name,lev)							\
+-static inline void spa_log_##name (struct spa_log *l, const char *format, ...)  \
++static inline SPA_PRINTF_FUNC(2,3) void spa_log_##name (struct spa_log *l, const char *format, ...)  \
+ {										\
+ 	if (SPA_UNLIKELY(spa_log_level_enabled(l, lev))) {			\
+ 		va_list varargs;						\
+--
+2.26.2
diff --git a/srcpkgs/pipewire/template b/srcpkgs/pipewire/template
index 7f646dad11d..31061aa4639 100644
--- a/srcpkgs/pipewire/template
+++ b/srcpkgs/pipewire/template
@@ -1,66 +1,103 @@
 # Template file for 'pipewire'
 pkgname=pipewire
-version=0.2.7
+version=0.3.4
 revision=1
 build_style=meson
-configure_args="-Dman=true -Dgstreamer=enabled -Ddocs=true -Dsystemd=false"
+configure_args="-Dman=true -Dgstreamer=true -Ddocs=true -Dsystemd=false
+ -Dbluez5=true -Dffmpeg=true -Dpipewire-alsa=true -Dpipewire-jack=true
+ -Dpipewire-pulseaudio=true"
 hostmakedepends="doxygen graphviz pkg-config xmltoman"
 makedepends="SDL2-devel ffmpeg-devel gst-plugins-base1-devel jack-devel
- sbc-devel v4l-utils-devel libva-devel"
+ sbc-devel v4l-utils-devel libva-devel libbluetooth-devel"
 short_desc="Server and user space API to deal with multimedia pipelines"
-maintainer="Orphaned <orphan@voidlinux.org>"
-#Next release will probably change to MIT, currently listed in master
-license="LGPL-2.1-only, GPL-2.0-only "
+maintainer="Kridsada Thanabulpong <sirn@ogsite.net>"
+license="MIT"
 homepage="https://pipewire.org/"
-changelog="https://raw.githubusercontent.com/PipeWire/pipewire/master/NEWS"
-distfiles="https://github.com/PipeWire/pipewire/archive/${version}.tar.gz"
-checksum=bfaa0f6ae6c0791e2e0b59234d399753bf24f1b33dbf587682363a8463dd8df1
+changelog="https://gitlab.freedesktop.org/pipewire/pipewire/-/raw/master/NEWS"
+distfiles="https://gitlab.freedesktop.org/pipewire/pipewire/-/archive/${version}/pipewire-${version}.tar.gz"
+checksum=6a1c9c671514c84b38ce96d51823354702bc4d5dbaba12d501faa0448f892515
 conf_files="/etc/pipewire/pipewire.conf"
 
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+        makedepends+=" libatomic-devel"
+        LDFLAGS+=" -latomic"
+fi
+
+post_install() {
+        vlicense LICENSE
+}
+
 libpipewire_package() {
-	short_desc+=" - pipewire library"
-	pkg_install() {
-		vmove "usr/lib/libpipewire-0.2.so.*"
-	}
+        short_desc+=" - pipewire library"
+        pkg_install() {
+                vmove "usr/lib/libpipewire-0.3.so.*"
+                vmove "usr/lib/pipewire-0.3/*.so"
+        }
 }
 
 pipewire-devel_package() {
-	depends="libpipewire-${version}_${revision}"
-	short_desc+=" - pipewire and libspa development files"
-	pkg_install() {
-		vmove usr/include/pipewire
-		vmove usr/include/spa
-		vmove usr/lib/pkgconfig/libpipewire-0.2.pc
-		vmove usr/lib/pkgconfig/libspa-0.1.pc
-		vmove usr/lib/libpipewire-0.2.so
-	}
+        depends="libpipewire-${version}_${revision}"
+        short_desc+=" - pipewire and libspa development files"
+        pkg_install() {
+                vmove usr/include/pipewire-0.3
+                vmove usr/include/spa-0.2
+                vmove usr/lib/pkgconfig/libpipewire-0.3.pc
+                vmove usr/lib/pkgconfig/libspa-0.2.pc
+                vmove usr/lib/libpipewire-0.3.so
+        }
 }
 
 libspa-ffmpeg_package() {
-	short_desc+=" - ffmpeg plugins"
-	pkg_install() {
-		vmove usr/lib/spa/ffmpeg
-	}
+        short_desc+=" - ffmpeg plugins"
+        pkg_install() {
+                vmove usr/lib/spa-0.2/ffmpeg
+        }
 }
 
 libspa-bluetooth_package() {
-	short_desc+=" - bluetooth plugins"
-	pkg_install() {
-		vmove usr/lib/spa/bluez5
-	}
+        short_desc+=" - bluetooth plugins"
+        pkg_install() {
+                vmove usr/lib/spa-0.2/bluez5
+        }
 }
 
 gstreamer1-pipewire_package() {
-	short_desc+=" - gstreamer plugin"
-	pkg_install() {
-		vmove usr/lib/gstreamer-1.0
-	}
+        short_desc+=" - gstreamer plugin"
+        pkg_install() {
+                vmove usr/lib/gstreamer-1.0
+        }
+}
+
+libpulseaudio-pipewire_package() {
+        depends="libpipewire-${version}_${revision}"
+        short_desc+=" - PulseAudio client library"
+        pkg_install() {
+                vmove usr/lib/pipewire-0.3/pulse
+                vmove usr/bin/pw-pulse
+        }
+}
+
+alsa-pipewire_package() {
+        depends="libpipewire-${version}_${revision}"
+        short_desc+=" - ALSA client library"
+        pkg_install() {
+                vmove usr/lib/alsa-lib
+        }
+}
+
+libjack-pipewire_package() {
+        depends="libpipewire-${version}_${revision}"
+        short_desc+=" - JACK client library"
+        pkg_install() {
+                vmove usr/lib/pipewire-0.3/jack
+                vmove usr/bin/pw-jack
+        }
 }
 
 pipewire-doc_package() {
-	archs=noarch
-	short_desc+=" - documentation"
-	pkg_install() {
-		vmove usr/share/doc
-	}
+        archs=noarch
+        short_desc+=" - documentation"
+        pkg_install() {
+                vmove usr/share/doc
+        }
 }

From b2a5929a8f20b5ffd0b3045b74a0d0c68446424a Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:46 +0900
Subject: [PATCH 2/4] xdg-desktop-portal-kde: rebuild for pipewire-0.3

---
 srcpkgs/xdg-desktop-portal-kde/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xdg-desktop-portal-kde/template b/srcpkgs/xdg-desktop-portal-kde/template
index f26057d323a..9519abc19f6 100644
--- a/srcpkgs/xdg-desktop-portal-kde/template
+++ b/srcpkgs/xdg-desktop-portal-kde/template
@@ -1,7 +1,7 @@
 # Template file for 'xdg-desktop-portal-kde'
 pkgname=xdg-desktop-portal-kde
 version=5.18.4.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules qt5-qmake qt5-host-tools kcoreaddons gettext"
 makedepends="glib-devel kio-devel kwayland-devel libepoxy-devel pipewire-devel

From d51b970c68f4d3f3e8b465ac36964ef423a559fd Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:26 +0900
Subject: [PATCH 3/4] xdg-desktop-portal: rebuild for pipewire-0.3

---
 .../patches/pipewire-0.3.patch                | 551 ++++++++++++++++++
 srcpkgs/xdg-desktop-portal/template           |   8 +-
 2 files changed, 557 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch

diff --git a/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..94ebe083598
--- /dev/null
+++ b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
@@ -0,0 +1,551 @@
+From a38901e5e7f835efe7b7a06c55790c8c20bc91a2 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Tue, 14 Jan 2020 09:37:09 +0100
+Subject: [PATCH] PipeWire: update to 0.3 API
+
+---
+ configure.ac      |   2 +-
+ src/camera.c      |  24 ++++----
+ src/pipewire.c    | 141 +++++++++++++---------------------------------
+ src/pipewire.h    |  10 ++--
+ src/screen-cast.c |  98 ++++++--------------------------
+ 5 files changed, 72 insertions(+), 203 deletions(-)
+
+diff --git configure.ac configure.ac
+index 89902fa..62d7960 100644
+--- configure.ac
++++ configure.ac
+@@ -97,7 +97,7 @@ AC_ARG_ENABLE(pipewire,
+ 	      [AS_HELP_STRING([--enable-pipewire],[Enable PipeWire support. Needed for screen cast portal])],
+ 	      enable_pipewire=$enableval, enable_pipewire=yes)
+ if test x$enable_pipewire = xyes ; then
+-	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.2 >= 0.2.6])
++	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.3 >= 0.2.90])
+ 	AC_DEFINE([HAVE_PIPEWIRE],[1], [Define to enable PipeWire support])
+ fi
+ AM_CONDITIONAL([HAVE_PIPEWIRE],[test "$enable_pipewire" = "yes"])
+diff --git src/camera.c src/camera.c
+index c2b392c..20fe3aa 100644
+--- src/camera.c
++++ src/camera.c
+@@ -141,7 +141,7 @@ open_pipewire_camera_remote (const char *app_id,
+                              GError **error)
+ {
+   PipeWireRemote *remote;
+-  struct spa_dict_item permission_items[1];
++  struct pw_permission permission_items[2];
+   struct pw_properties *pipewire_properties;
+ 
+   pipewire_properties =
+@@ -158,12 +158,12 @@ open_pipewire_camera_remote (const char *app_id,
+    * Hide all existing and future nodes by default. PipeWire will use the
+    * permission store to set up permissions.
+    */
+-  permission_items[0].key = PW_CORE_PROXY_PERMISSIONS_DEFAULT;
+-  permission_items[0].value = "---";
++  permission_items[0] = PW_PERMISSION_INIT (PW_ID_CORE, PW_PERM_RWX);
++  permission_items[1] = PW_PERMISSION_INIT (PW_ID_ANY, 0);
+ 
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             &SPA_DICT_INIT (permission_items,
+-                                             G_N_ELEMENTS (permission_items)));
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                G_N_ELEMENTS (permission_items),
++                                permission_items);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -219,7 +219,7 @@ handle_open_pipewire_remote (XdpCamera *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
+@@ -250,29 +250,28 @@ camera_iface_init (XdpCameraIface *iface)
+ static void
+ global_added_cb (PipeWireRemote *remote,
+                  uint32_t id,
+-                 uint32_t type,
++                 const char *type,
+                  const struct spa_dict *props,
+                  gpointer user_data)
+ {
+   Camera *camera = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *media_class;
+   const struct spa_dict_item *media_role;
+ 
+-  if (type != core_type->node)
++  if (strcmp(type, PW_TYPE_INTERFACE_Node) != 0)
+     return;
+ 
+   if (!props)
+     return;
+ 
+-  media_class = spa_dict_lookup_item (props, "media.class");
++  media_class = spa_dict_lookup_item (props, PW_KEY_MEDIA_CLASS);
+   if (!media_class)
+     return;
+ 
+   if (g_strcmp0 (media_class->value, "Video/Source") != 0)
+     return;
+ 
+-  media_role = spa_dict_lookup_item (props, "media.role");
++  media_role = spa_dict_lookup_item (props, PW_KEY_MEDIA_ROLE);
+   if (!media_role)
+     return;
+ 
+@@ -342,6 +341,7 @@ create_pipewire_remote (Camera *camera,
+     }
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.is_portal", "true",
++                                           "portal.monitor", "Camera",
+                                            NULL);
+   camera->pipewire_remote = pipewire_remote_new_sync (pipewire_properties,
+                                                       global_added_cb,
+diff --git src/pipewire.c src/pipewire.c
+index 793a378..162cd55 100644
+--- src/pipewire.c
++++ src/pipewire.c
+@@ -21,6 +21,7 @@
+ #include <errno.h>
+ #include <glib.h>
+ #include <pipewire/pipewire.h>
++#include <spa/utils/result.h>
+ 
+ #include "pipewire.h"
+ 
+@@ -36,27 +37,25 @@ static gboolean is_pipewire_initialized = FALSE;
+ static void
+ registry_event_global (void *user_data,
+                        uint32_t id,
+-                       uint32_t parent_id,
+                        uint32_t permissions,
+-                       uint32_t type,
++                       const char *type,
+                        uint32_t version,
+                        const struct spa_dict *props)
+ {
+   PipeWireRemote *remote = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *factory_object_type;
+   PipeWireGlobal *global;
+ 
+   global = g_new0 (PipeWireGlobal, 1);
+   *global = (PipeWireGlobal) {
+-    .parent_id = parent_id,
++    .parent_id = id,
+   };
+ 
+   g_hash_table_insert (remote->globals, GINT_TO_POINTER (id), global);
+   if (remote->global_added_cb)
+     remote->global_added_cb (remote, id, type, props, remote->user_data);
+ 
+-  if (type != core_type->factory)
++  if (strcmp(type, PW_TYPE_INTERFACE_Factory) != 0)
+     return;
+ 
+   factory_object_type = spa_dict_lookup_item (props, "factory.type.name");
+@@ -81,8 +80,8 @@ registry_event_global_remove (void *user_data,
+   g_hash_table_remove (remote->globals, GINT_TO_POINTER (id));
+ }
+ 
+-static const struct pw_registry_proxy_events registry_events = {
+-  PW_VERSION_REGISTRY_PROXY_EVENTS,
++static const struct pw_registry_events registry_events = {
++  PW_VERSION_REGISTRY_EVENTS,
+   .global = registry_event_global,
+   .global_remove = registry_event_global_remove,
+ };
+@@ -90,7 +89,7 @@ static const struct pw_registry_proxy_events registry_events = {
+ void
+ pipewire_remote_roundtrip (PipeWireRemote *remote)
+ {
+-  pw_core_proxy_sync (remote->core_proxy, ++remote->sync_seq);
++  remote->sync_seq = pw_core_sync (remote->core, PW_ID_CORE, remote->sync_seq);
+   pw_main_loop_run (remote->loop);
+ }
+ 
+@@ -98,16 +97,13 @@ static gboolean
+ discover_node_factory_sync (PipeWireRemote *remote,
+                             GError **error)
+ {
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+-  struct pw_registry_proxy *registry_proxy;
++  struct pw_registry *registry;
+ 
+-  registry_proxy = pw_core_proxy_get_registry (remote->core_proxy,
+-                                               core_type->registry,
+-                                               PW_VERSION_REGISTRY, 0);
+-  pw_registry_proxy_add_listener (registry_proxy,
+-                                  &remote->registry_listener,
+-                                  &registry_events,
+-                                  remote);
++  registry = pw_core_get_registry (remote->core, PW_VERSION_REGISTRY, 0);
++  pw_registry_add_listener (registry,
++                            &remote->registry_listener,
++                            &registry_events,
++                            remote);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -122,59 +118,35 @@ discover_node_factory_sync (PipeWireRemote *remote,
+ }
+ 
+ static void
+-on_state_changed (void *user_data,
+-                  enum pw_remote_state old,
+-                  enum pw_remote_state state,
+-                  const char *error)
++core_event_error (void       *user_data,
++                  uint32_t    id,
++		  int         seq,
++		  int         res,
++		  const char *message)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  switch (state)
++  if (id == PW_ID_CORE)
+     {
+-    case PW_REMOTE_STATE_ERROR:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "%s", error);
+-        }
++      g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
++                 "%s", message);
+       pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "Disconnected");
+-        }
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    default:
+-      g_warning ("Unknown PipeWire state");
+-      break;
+     }
+ }
+ 
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
+-};
+-
+ static void
+ core_event_done (void *user_data,
+-                 uint32_t seq)
++                 uint32_t id, int seq)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  if (remote->sync_seq == seq)
++  if (id == PW_ID_CORE && remote->sync_seq == seq)
+     pw_main_loop_quit (remote->loop);
+ }
+ 
+-static const struct pw_core_proxy_events core_events = {
+-  PW_VERSION_CORE_PROXY_EVENTS,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = core_event_error,
+   .done = core_event_done,
+ };
+ 
+@@ -237,8 +209,8 @@ void
+ pipewire_remote_destroy (PipeWireRemote *remote)
+ {
+   g_clear_pointer (&remote->globals, g_hash_table_destroy);
+-  g_clear_pointer (&remote->remote, pw_remote_destroy);
+-  g_clear_pointer (&remote->core, pw_core_destroy);
++  g_clear_pointer (&remote->core, pw_core_disconnect);
++  g_clear_pointer (&remote->context, pw_context_destroy);
+   g_clear_pointer (&remote->loop, pw_main_loop_destroy);
+   g_clear_error (&remote->error);
+ 
+@@ -307,68 +279,31 @@ pipewire_remote_new_sync (struct pw_properties *pipewire_properties,
+       return NULL;
+     }
+ 
+-  remote->core = pw_core_new (pw_main_loop_get_loop (remote->loop), NULL);
+-  if (!remote->core)
++  remote->context = pw_context_new (pw_main_loop_get_loop (remote->loop), NULL, 0);
++  if (!remote->context)
+     {
+       pipewire_remote_destroy (remote);
+       pw_properties_free (pipewire_properties);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire core");
++                   "Couldn't create PipeWire context");
+       return NULL;
+     }
+ 
+-  remote->remote = pw_remote_new (remote->core, pipewire_properties, 0);
+-  if (!remote->remote)
++  remote->core = pw_context_connect (remote->context, pipewire_properties, 0);
++  if (!remote->core)
+     {
+       pipewire_remote_destroy (remote);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire remote");
++                   "Couldn't connect to PipeWire");
+       return NULL;
+     }
+ 
+   remote->globals = g_hash_table_new_full (NULL, NULL, NULL, g_free);
+ 
+-  pw_remote_add_listener (remote->remote,
+-                          &remote->remote_listener,
+-                          &remote_events,
+-                          remote);
+-
+-  if (pw_remote_connect (remote->remote) != 0)
+-    {
+-      pipewire_remote_destroy (remote);
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect PipeWire remote");
+-      return NULL;
+-    }
+-
+-  pw_main_loop_run (remote->loop);
+-
+-  switch (pw_remote_get_state (remote->remote, NULL))
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      *error = g_steal_pointer (&remote->error);
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "PipeWire loop stopped unexpectedly");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      break;
+-    default:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Unexpected PipeWire state");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    }
+-
+-  remote->core_proxy = pw_remote_get_core_proxy (remote->remote);
+-  pw_core_proxy_add_listener (remote->core_proxy,
+-                              &remote->core_listener,
+-                              &core_events,
+-                              remote);
++  pw_core_add_listener (remote->core,
++                        &remote->core_listener,
++                        &core_events,
++                        remote);
+ 
+   if (!discover_node_factory_sync (remote, error))
+     {
+diff --git src/pipewire.h src/pipewire.h
+index 0f1bf54..bf48d5e 100644
+--- src/pipewire.h
++++ src/pipewire.h
+@@ -32,7 +32,7 @@ typedef struct _PipeWireGlobal
+ 
+ typedef void (* PipeWireGlobalAddedCallback) (PipeWireRemote *remote,
+                                               uint32_t id,
+-                                              uint32_t type,
++                                              const char *type,
+                                               const struct spa_dict *props,
+                                               gpointer user_data);
+ 
+@@ -43,13 +43,11 @@ typedef void (* PipeWireGlobalRemovedCallback) (PipeWireRemote *remote,
+ struct _PipeWireRemote
+ {
+   struct pw_main_loop *loop;
++  struct pw_context *context;
+   struct pw_core *core;
+-  struct pw_remote *remote;
+-  struct spa_hook remote_listener;
+-
+-  struct pw_core_proxy *core_proxy;
+   struct spa_hook core_listener;
+-  uint32_t sync_seq;
++
++  int sync_seq;
+ 
+   struct spa_hook registry_listener;
+ 
+diff --git src/screen-cast.c src/screen-cast.c
+index 7881ddc..1677050 100644
+--- src/screen-cast.c
++++ src/screen-cast.c
+@@ -31,10 +31,10 @@
+ #include "xdp-impl-dbus.h"
+ #include "xdp-utils.h"
+ 
+-#define PERMISSION_ITEM(item_key, item_value) \
+-  ((struct spa_dict_item) { \
+-    .key = item_key, \
+-    .value = item_value \
++#define PERMISSION_ITEM(item_id, item_permissions) \
++  ((struct pw_permission) { \
++    .id = item_id, \
++    .permissions = item_permissions \
+   })
+ 
+ typedef struct _ScreenCast ScreenCast;
+@@ -517,42 +517,9 @@ screen_cast_stream_get_pipewire_node_id (ScreenCastStream *stream)
+   return stream->id;
+ }
+ 
+-static void
+-append_parent_permissions (PipeWireRemote *remote,
+-                           GArray *permission_items,
+-                           GList **string_stash,
+-                           PipeWireGlobal *global,
+-                           const char *permission)
+-{
+-  PipeWireGlobal *parent;
+-  char *parent_permission_value;
+-
+-  if (global->parent_id == 0)
+-    return;
+-
+-  parent = g_hash_table_lookup (remote->globals, GINT_TO_POINTER (global->parent_id));
+-
+-  if (parent->permission_set)
+-    return;
+-  parent->permission_set = TRUE;
+-
+-  append_parent_permissions (remote, permission_items, string_stash,
+-                             parent, permission);
+-
+-  parent_permission_value = g_strdup_printf ("%u:%s",
+-                                             global->parent_id,
+-                                             permission);
+-  *string_stash = g_list_prepend (*string_stash, parent_permission_value);
+-
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       parent_permission_value));
+-}
+-
+ static void
+ append_stream_permissions (PipeWireRemote *remote,
+                            GArray *permission_items,
+-                           GList **string_stash,
+                            GList *streams)
+ {
+   GList *l;
+@@ -561,21 +528,10 @@ append_stream_permissions (PipeWireRemote *remote,
+     {
+       ScreenCastStream *stream = l->data;
+       uint32_t stream_id;
+-      PipeWireGlobal *stream_global;
+-      char *stream_permission_value;
+ 
+       stream_id = screen_cast_stream_get_pipewire_node_id (stream);
+-      stream_global = g_hash_table_lookup (remote->globals,
+-                                           GINT_TO_POINTER (stream_id));
+-
+-      append_parent_permissions (remote, permission_items, string_stash,
+-                                 stream_global, "r--");
+-
+-      stream_permission_value = g_strdup_printf ("%u:rwx", stream_id);
+-      *string_stash = g_list_prepend (*string_stash, stream_permission_value);
+       g_array_append_val (permission_items,
+-                          PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                           stream_permission_value));
++                          PERMISSION_ITEM (stream_id, PW_PERM_RWX));
+     }
+ }
+ 
+@@ -587,9 +543,6 @@ open_pipewire_screen_cast_remote (const char *app_id,
+   struct pw_properties *pipewire_properties;
+   PipeWireRemote *remote;
+   g_autoptr(GArray) permission_items = NULL;
+-  char *node_factory_permission_string;
+-  GList *string_stash = NULL;
+-  struct spa_dict *permission_dict;
+   PipeWireGlobal *node_global;
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.app_id", app_id,
+@@ -603,48 +556,31 @@ open_pipewire_screen_cast_remote (const char *app_id,
+ 
+   permission_items = g_array_new (FALSE, TRUE, sizeof (struct spa_dict_item));
+ 
+-  /*
+-   * Hide all existing and future nodes (except the ones we explicitly list below.
+-   */
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_EXISTING,
+-                                       "---"));
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_DEFAULT,
+-                                       "---"));
+-
+   /*
+    * PipeWire:Interface:Core
+    * Needs rwx to be able create the sink node using the create-object method
+    */
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       "0:rwx"));
++                      PERMISSION_ITEM (PW_ID_CORE, PW_PERM_RWX));
+ 
+   /*
+    * PipeWire:Interface:NodeFactory
+    * Needs r-- so it can be passed to create-object when creating the sink node.
+    */
+-  node_factory_permission_string = g_strdup_printf ("%d:r--",
+-                                                    remote->node_factory_id);
+-  string_stash = g_list_prepend (string_stash, node_factory_permission_string);
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       node_factory_permission_string));
+-  node_global = g_hash_table_lookup (remote->globals,
+-                                     GINT_TO_POINTER (remote->node_factory_id));
+-  append_parent_permissions (remote, permission_items, &string_stash,
+-                             node_global, "r--");
++                      PERMISSION_ITEM (remote->node_factory_id, PW_PERM_R));
+ 
+-  append_stream_permissions (remote, permission_items, &string_stash, streams);
++  append_stream_permissions (remote, permission_items, streams);
+ 
+-  permission_dict =
+-    &SPA_DICT_INIT ((struct spa_dict_item *) permission_items->data,
+-                    permission_items->len);
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             permission_dict);
++  /*
++   * Hide all existing and future nodes (except the ones we explicitly list above).
++   */
++  g_array_append_val (permission_items,
++                      PERMISSION_ITEM (PW_ID_ANY, 0));
+ 
+-  g_list_free_full (string_stash, g_free);
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                permission_items->len,
++                                (const struct pw_permission *)permission_items->data);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -943,7 +879,7 @@ handle_open_pipewire_remote (XdpScreenCast *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
diff --git a/srcpkgs/xdg-desktop-portal/template b/srcpkgs/xdg-desktop-portal/template
index eb8a4602f5d..1136b6a6e0e 100644
--- a/srcpkgs/xdg-desktop-portal/template
+++ b/srcpkgs/xdg-desktop-portal/template
@@ -1,10 +1,10 @@
 # Template file for 'xdg-desktop-portal'
 pkgname=xdg-desktop-portal
 version=1.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-pipewire --enable-geoclue --disable-libportal"
-hostmakedepends="pkg-config glib-devel"
+hostmakedepends="automake libtool gettext-devel pkg-config glib-devel"
 makedepends="flatpak-devel fuse-devel pipewire-devel geoclue2-devel"
 short_desc="Portal frontend service for Flatpak"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -13,6 +13,10 @@ homepage="https://github.com/flatpak/xdg-desktop-portal"
 distfiles="https://github.com/flatpak/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.xz"
 checksum=883c9c9a925e48af54812b5347f546dd776ec2e27076a83d5a8126af6bafb9da
 
+pre_configure() {
+	autoreconf -vfi
+}
+
 post_install() {
 	rm -rf "${DESTDIR}/usr/lib/systemd"
 }

From 331e28c2ace5f8bda452873dcec31bd820af8d13 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Thu, 30 Apr 2020 06:17:17 +0900
Subject: [PATCH 4/4] mutter: rebuild for pipewire-0.3

---
 srcpkgs/mutter/patches/pipewire-0.3.patch | 521 ++++++++++++++++++++++
 srcpkgs/mutter/template                   |   2 +-
 2 files changed, 522 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/mutter/patches/pipewire-0.3.patch

diff --git a/srcpkgs/mutter/patches/pipewire-0.3.patch b/srcpkgs/mutter/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..ebff65fba85
--- /dev/null
+++ b/srcpkgs/mutter/patches/pipewire-0.3.patch
@@ -0,0 +1,521 @@
+Build mutter against pipewire-0.3, based on a patch at:
+https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1062
+--- meson.build
++++ meson.build
+@@ -50,7 +50,7 @@ libinput_req = '>= 1.7'
+ gbm_req = '>= 10.3'
+
+ # screen cast version requirements
+-libpipewire_req = '>= 0.2.5'
++libpipewire_req = '>= 0.3.0'
+
+ gnome = import('gnome')
+ pkg = import('pkgconfig')
+@@ -241,7 +241,7 @@ endif
+
+ have_remote_desktop = get_option('remote_desktop')
+ if have_remote_desktop
+-  libpipewire_dep = dependency('libpipewire-0.2', version: libpipewire_req)
++  libpipewire_dep = dependency('libpipewire-0.3', version: libpipewire_req)
+ endif
+
+ have_introspection = get_option('introspection')
+diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
+index 82c5cba436..ba1ce94a7e 100644
+--- src/backends/meta-screen-cast-stream-src.c
++++ src/backends/meta-screen-cast-stream-src.c
+@@ -29,6 +29,7 @@
+ #include <spa/param/props.h>
+ #include <spa/param/format-utils.h>
+ #include <spa/param/video/format-utils.h>
++#include <spa/utils/result.h>
+ #include <stdint.h>
+ #include <sys/mman.h>
+
+@@ -62,15 +63,6 @@ enum
+
+ static guint signals[N_SIGNALS];
+
+-typedef struct _MetaSpaType
+-{
+-  struct spa_type_media_type media_type;
+-  struct spa_type_media_subtype media_subtype;
+-  struct spa_type_format_video format_video;
+-  struct spa_type_video_format video_format;
+-  uint32_t meta_cursor;
+-} MetaSpaType;
+-
+ typedef struct _MetaPipeWireSource
+ {
+   GSource base;
+@@ -82,19 +74,19 @@ typedef struct _MetaScreenCastStreamSrcPrivate
+ {
+   MetaScreenCastStream *stream;
+
++  struct pw_context *pipewire_context;
+   struct pw_core *pipewire_core;
+-  struct pw_remote *pipewire_remote;
+-  struct pw_type *pipewire_type;
+   MetaPipeWireSource *pipewire_source;
+-  struct spa_hook pipewire_remote_listener;
++  struct spa_hook pipewire_core_listener;
+
+   gboolean is_enabled;
+
+   struct pw_stream *pipewire_stream;
+   struct spa_hook pipewire_stream_listener;
++  uint32_t node_id;
+
+-  MetaSpaType spa_type;
+   struct spa_video_info_raw video_format;
++  int video_stride;
+
+   uint64_t last_frame_timestamp_us;
+
+@@ -112,8 +104,6 @@ G_DEFINE_TYPE_WITH_CODE (MetaScreenCastStreamSrc,
+                                                 meta_screen_cast_stream_src_init_initable_iface)
+                          G_ADD_PRIVATE (MetaScreenCastStreamSrc))
+
+-#define PROP_RANGE(min, max) 2, (min), (max)
+-
+ static void
+ meta_screen_cast_stream_src_get_specs (MetaScreenCastStreamSrc *src,
+                                        int                     *width,
+@@ -286,9 +276,6 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+                                                               int                      x,
+                                                               int                      y)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+
+   spa_meta_cursor->id = 1;
+@@ -300,7 +287,7 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   spa_meta_cursor->hotspot.x = 0;
+@@ -317,9 +304,6 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+                                                         int                      y,
+                                                         float                    scale)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   CoglTexture *cursor_texture;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+   int hotspot_x, hotspot_y;
+@@ -346,7 +330,7 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
+@@ -382,12 +366,10 @@ static void
+ add_cursor_metadata (MetaScreenCastStreamSrc *src,
+                      struct spa_buffer       *spa_buffer)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_cursor *spa_meta_cursor;
+
+-  spa_meta_cursor = spa_buffer_find_meta (spa_buffer, spa_type->meta_cursor);
++  spa_meta_cursor = spa_buffer_find_meta_data (spa_buffer, SPA_META_Cursor,
++                                               sizeof (*spa_meta_cursor));
+   if (spa_meta_cursor)
+     meta_screen_cast_stream_src_set_cursor_metadata (src, spa_meta_cursor);
+ }
+@@ -447,14 +429,14 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+     {
+       data = spa_buffer->datas[0].data;
+     }
+-  else if (spa_buffer->datas[0].type == priv->pipewire_type->data.MemFd)
++  else if (spa_buffer->datas[0].type == SPA_DATA_MemFd)
+     {
+       map = mmap (NULL, spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset,
+                   PROT_READ | PROT_WRITE, MAP_SHARED,
+                   spa_buffer->datas[0].fd, 0);
+       if (map == MAP_FAILED)
+         {
+-          g_warning ("Failed to mmap pipewire stream buffer: %s\n",
++          g_warning ("Failed to mmap pipewire stream buffer: %s",
+                      strerror (errno));
+           return;
+         }
+@@ -469,28 +451,30 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+
+   if (meta_screen_cast_stream_src_record_frame (src, data))
+     {
+-      struct spa_meta_video_crop *spa_meta_video_crop;
++      struct spa_meta_region *spa_meta_video_crop;
+
+       spa_buffer->datas[0].chunk->size = spa_buffer->datas[0].maxsize;
++      spa_buffer->datas[0].chunk->stride = priv->video_stride;
+
+       /* Update VideoCrop if needed */
+       spa_meta_video_crop =
+-        spa_buffer_find_meta (spa_buffer, priv->pipewire_type->meta.VideoCrop);
++        spa_buffer_find_meta_data (spa_buffer, SPA_META_VideoCrop,
++                                   sizeof (*spa_meta_video_crop));
+       if (spa_meta_video_crop)
+         {
+           if (meta_screen_cast_stream_src_get_videocrop (src, &crop_rect))
+             {
+-              spa_meta_video_crop->x = crop_rect.x;
+-              spa_meta_video_crop->y = crop_rect.y;
+-              spa_meta_video_crop->width = crop_rect.width;
+-              spa_meta_video_crop->height = crop_rect.height;
++              spa_meta_video_crop->region.position.x = crop_rect.x;
++              spa_meta_video_crop->region.position.y = crop_rect.y;
++              spa_meta_video_crop->region.size.width = crop_rect.width;
++              spa_meta_video_crop->region.size.height = crop_rect.height;
+             }
+           else
+             {
+-              spa_meta_video_crop->x = 0;
+-              spa_meta_video_crop->y = 0;
+-              spa_meta_video_crop->width = priv->stream_width;
+-              spa_meta_video_crop->height = priv->stream_height;
++              spa_meta_video_crop->region.position.x = 0;
++              spa_meta_video_crop->region.position.y = 0;
++              spa_meta_video_crop->region.size.width = priv->stream_width;
++              spa_meta_video_crop->region.size.height = priv->stream_height;
+             }
+         }
+     }
+@@ -555,7 +539,6 @@ on_stream_state_changed (void                 *data,
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  uint32_t node_id;
+
+   switch (state)
+     {
+@@ -563,14 +546,12 @@ on_stream_state_changed (void                 *data,
+       g_warning ("pipewire stream error: %s", error_message);
+       meta_screen_cast_stream_src_notify_closed (src);
+       break;
+-    case PW_STREAM_STATE_CONFIGURE:
+-      node_id = pw_stream_get_node_id (priv->pipewire_stream);
+-      g_signal_emit (src, signals[READY], 0, (unsigned int) node_id);
+-      break;
+-    case PW_STREAM_STATE_UNCONNECTED:
+-    case PW_STREAM_STATE_CONNECTING:
+-    case PW_STREAM_STATE_READY:
+     case PW_STREAM_STATE_PAUSED:
++      if (priv->node_id == SPA_ID_INVALID && priv->pipewire_stream)
++        {
++          priv->node_id = pw_stream_get_node_id (priv->pipewire_stream);
++          g_signal_emit (src, signals[READY], 0, (unsigned int) priv->node_id);
++        }
+       if (meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_disable (src);
+       break;
+@@ -578,68 +559,69 @@ on_stream_state_changed (void                 *data,
+       if (!meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_enable (src);
+       break;
++    case PW_STREAM_STATE_UNCONNECTED:
++    case PW_STREAM_STATE_CONNECTING:
++      break;
+     }
+ }
+
+ static void
+-on_stream_format_changed (void                 *data,
+-                          const struct spa_pod *format)
++on_stream_param_changed (void                 *data,
++                         uint32_t              id,
++                         const struct spa_pod *format)
+ {
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   uint8_t params_buffer[1024];
+   int32_t width, height, stride, size;
+   struct spa_pod_builder pod_builder;
+   const struct spa_pod *params[3];
+   const int bpp = 4;
+
+-  if (!format)
+-    {
+-      pw_stream_finish_format (priv->pipewire_stream, 0, NULL, 0);
+-      return;
+-    }
++  if (!format || id != SPA_PARAM_Format)
++    return;
+
+   spa_format_video_raw_parse (format,
+-                              &priv->video_format,
+-                              &priv->spa_type.format_video);
++                              &priv->video_format);
+
+   width = priv->video_format.size.width;
+   height = priv->video_format.size.height;
+   stride = SPA_ROUND_UP_N (width * bpp, 4);
+   size = height * stride;
+
++  priv->video_stride = stride;
++
+   pod_builder = SPA_POD_BUILDER_INIT (params_buffer, sizeof (params_buffer));
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idBuffers, pipewire_type->param_buffers.Buffers,
+-    ":", pipewire_type->param_buffers.size, "i", size,
+-    ":", pipewire_type->param_buffers.stride, "i", stride,
+-    ":", pipewire_type->param_buffers.buffers, "iru", 16, PROP_RANGE (2, 16),
+-    ":", pipewire_type->param_buffers.align, "i", 16);
+-
+-  params[1] = spa_pod_builder_object (
++    SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
++    SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int (16, 2, 16),
++    SPA_PARAM_BUFFERS_blocks, SPA_POD_Int (1),
++    SPA_PARAM_BUFFERS_size, SPA_POD_Int (size),
++    SPA_PARAM_BUFFERS_stride, SPA_POD_Int (stride),
++    SPA_PARAM_BUFFERS_align, SPA_POD_Int (16));
++
++  params[1] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", pipewire_type->meta.VideoCrop,
+-    ":", pipewire_type->param_meta.size, "i", sizeof (struct spa_meta_video_crop));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_VideoCrop),
++    SPA_PARAM_META_size, SPA_POD_Int (sizeof (struct spa_meta_region)));
+
+-  params[2] = spa_pod_builder_object (
++  params[2] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", priv->spa_type.meta_cursor,
+-    ":", pipewire_type->param_meta.size, "i", CURSOR_META_SIZE (64, 64));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_Cursor),
++    SPA_PARAM_META_size, SPA_POD_Int (CURSOR_META_SIZE (64, 64)));
+
+-  pw_stream_finish_format (priv->pipewire_stream, 0,
+-                           params, G_N_ELEMENTS (params));
++  pw_stream_update_params (priv->pipewire_stream, params, G_N_ELEMENTS (params));
+ }
+
+ static const struct pw_stream_events stream_events = {
+   PW_VERSION_STREAM_EVENTS,
+   .state_changed = on_stream_state_changed,
+-  .format_changed = on_stream_format_changed,
++  .param_changed = on_stream_param_changed,
+ };
+
+ static struct pw_stream *
+@@ -652,8 +634,6 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   uint8_t buffer[1024];
+   struct spa_pod_builder pod_builder =
+     SPA_POD_BUILDER_INIT (buffer, sizeof (buffer));
+-  MetaSpaType *spa_type = &priv->spa_type;
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   float frame_rate;
+   MetaFraction frame_rate_fraction;
+   struct spa_fraction max_framerate;
+@@ -661,7 +641,9 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   const struct spa_pod *params[1];
+   int result;
+
+-  pipewire_stream = pw_stream_new (priv->pipewire_remote,
++  priv->node_id = SPA_ID_INVALID;
++
++  pipewire_stream = pw_stream_new (priv->pipewire_core,
+                                    "meta-screen-cast-src",
+                                    NULL);
+   if (!pipewire_stream)
+@@ -682,17 +664,17 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   max_framerate = SPA_FRACTION (frame_rate_fraction.num,
+                                 frame_rate_fraction.denom);
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idEnumFormat, pipewire_type->spa_format,
+-    "I", spa_type->media_type.video,
+-    "I", spa_type->media_subtype.raw,
+-    ":", spa_type->format_video.format, "I", spa_type->video_format.BGRx,
+-    ":", spa_type->format_video.size, "R", &SPA_RECTANGLE (priv->stream_width,
+-                                                           priv->stream_height),
+-    ":", spa_type->format_video.framerate, "F", &SPA_FRACTION (0, 1),
+-    ":", spa_type->format_video.max_framerate, "Fru", &max_framerate,
+-                                                      PROP_RANGE (&min_framerate,
++    SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
++    SPA_FORMAT_mediaType, SPA_POD_Id (SPA_MEDIA_TYPE_video),
++    SPA_FORMAT_mediaSubtype, SPA_POD_Id (SPA_MEDIA_SUBTYPE_raw),
++    SPA_FORMAT_VIDEO_format, SPA_POD_Id (SPA_VIDEO_FORMAT_BGRx),
++    SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle (&SPA_RECTANGLE (priv->stream_width,
++                                                              priv->stream_height)),
++    SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction (&SPA_FRACTION (0, 1)),
++    SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction (&max_framerate,
++                                                                  &min_framerate,
+                                                                   &max_framerate));
+
+   pw_stream_add_listener (pipewire_stream,
+@@ -702,7 +684,7 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+
+   result = pw_stream_connect (pipewire_stream,
+                               PW_DIRECTION_OUTPUT,
+-                              NULL,
++                              SPA_ID_INVALID,
+                               (PW_STREAM_FLAG_DRIVER |
+                                PW_STREAM_FLAG_MAP_BUFFERS),
+                               params, G_N_ELEMENTS (params));
+@@ -717,40 +699,18 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+ }
+
+ static void
+-on_state_changed (void                 *data,
+-                  enum pw_remote_state  old,
+-                  enum pw_remote_state  state,
+-                  const char           *error_message)
++on_core_error (void       *data,
++               uint32_t    id,
++	       int         seq,
++	       int         res,
++	       const char *message)
+ {
+   MetaScreenCastStreamSrc *src = data;
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_stream *pipewire_stream;
+-  GError *error = NULL;
+
+-  switch (state)
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-      g_warning ("pipewire remote error: %s\n", error_message);
+-      meta_screen_cast_stream_src_notify_closed (src);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pipewire_stream = create_pipewire_stream (src, &error);
+-      if (!pipewire_stream)
+-        {
+-          g_warning ("Could not create pipewire stream: %s", error->message);
+-          g_error_free (error);
+-          meta_screen_cast_stream_src_notify_closed (src);
+-        }
+-      else
+-        {
+-          priv->pipewire_stream = pipewire_stream;
+-        }
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    }
++  g_warning ("pipewire remote error: id:%u %s", id, message);
++
++  if (id == PW_ID_CORE && res == -EPIPE)
++    meta_screen_cast_stream_src_notify_closed (src);
+ }
+
+ static gboolean
+@@ -793,17 +753,6 @@ static GSourceFuncs pipewire_source_funcs =
+   pipewire_loop_source_finalize
+ };
+
+-static void
+-init_spa_type (MetaSpaType         *type,
+-               struct spa_type_map *map)
+-{
+-  spa_type_media_type_map (map, &type->media_type);
+-  spa_type_media_subtype_map (map, &type->media_subtype);
+-  spa_type_format_video_map (map, &type->format_video);
+-  spa_type_video_format_map (map, &type->video_format);
+-  type->meta_cursor = spa_type_map_get_id(map, SPA_TYPE_META__Cursor);
+-}
+-
+ static MetaPipeWireSource *
+ create_pipewire_source (void)
+ {
+@@ -829,9 +778,9 @@ create_pipewire_source (void)
+   return pipewire_source;
+ }
+
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = on_core_error,
+ };
+
+ static gboolean
+@@ -851,37 +800,31 @@ meta_screen_cast_stream_src_initable_init (GInitable     *initable,
+       return FALSE;
+     }
+
+-  priv->pipewire_core = pw_core_new (priv->pipewire_source->pipewire_loop,
+-                                     NULL);
+-  if (!priv->pipewire_core)
++  priv->pipewire_context = pw_context_new (priv->pipewire_source->pipewire_loop,
++                                           NULL, 0);
++  if (!priv->pipewire_context)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Failed to create pipewire core");
++                   "Failed to create pipewire context");
+       return FALSE;
+     }
+
+-  priv->pipewire_remote = pw_remote_new (priv->pipewire_core, NULL, 0);
+-  if (!priv->pipewire_remote)
++  priv->pipewire_core = pw_context_connect (priv->pipewire_context, NULL, 0);
++  if (!priv->pipewire_core)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't creat pipewire remote");
++                   "Couldn't connect pipewire context");
+       return FALSE;
+     }
+
+-  pw_remote_add_listener (priv->pipewire_remote,
+-                          &priv->pipewire_remote_listener,
+-                          &remote_events,
+-                          src);
++  pw_core_add_listener (priv->pipewire_core,
++                        &priv->pipewire_core_listener,
++                        &core_events,
++                        src);
+
+-  priv->pipewire_type = pw_core_get_type (priv->pipewire_core);
+-  init_spa_type (&priv->spa_type, priv->pipewire_type->map);
+-
+-  if (pw_remote_connect (priv->pipewire_remote) != 0)
+-    {
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect pipewire remote");
+-      return FALSE;
+-    }
++  priv->pipewire_stream = create_pipewire_stream (src, error);
++  if (!priv->pipewire_stream)
++    return FALSE;
+
+   return TRUE;
+ }
+@@ -912,8 +855,8 @@ meta_screen_cast_stream_src_finalize (GObject *object)
+     meta_screen_cast_stream_src_disable (src);
+
+   g_clear_pointer (&priv->pipewire_stream, pw_stream_destroy);
+-  g_clear_pointer (&priv->pipewire_remote, pw_remote_destroy);
+-  g_clear_pointer (&priv->pipewire_core, pw_core_destroy);
++  g_clear_pointer (&priv->pipewire_core, pw_core_disconnect);
++  g_clear_pointer (&priv->pipewire_context, pw_context_destroy);
+   g_source_destroy (&priv->pipewire_source->base);
+
+   G_OBJECT_CLASS (meta_screen_cast_stream_src_parent_class)->finalize (object);
diff --git a/srcpkgs/mutter/template b/srcpkgs/mutter/template
index 4e0bd32b67d..806a3bef9f0 100644
--- a/srcpkgs/mutter/template
+++ b/srcpkgs/mutter/template
@@ -1,7 +1,7 @@
 # Template file for 'mutter'
 pkgname=mutter
 version=3.34.1
-revision=2
+revision=3
 build_helper="gir"
 build_style=meson
 configure_args="-Degl_device=true -Dudev=true -Dnative_backend=true

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.4
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (30 preceding siblings ...)
  2020-05-01 10:36 ` sirn
@ 2020-05-01 10:37 ` sirn
  2020-05-01 11:50 ` [PR PATCH] [Updated] WIP: " sirn
                   ` (19 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-05-01 10:37 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 388 bytes --]

New comment by sirn on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-622337272

Comment:
Replaced `-Wformat` and `-Werror=suggest-attribute=format` with a patch from upstream which now fixes warnings/compilation on musl. armv6l/armv7l currently failing due to [neon support](https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/235). 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PR PATCH] [Updated] WIP: pipewire: update to 0.3.4
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (31 preceding siblings ...)
  2020-05-01 10:37 ` sirn
@ 2020-05-01 11:50 ` sirn
  2020-05-07 18:27 ` sirn
                   ` (18 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-05-01 11:50 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 790 bytes --]

There is an updated pull request by sirn against master on the void-packages repository

https://github.com/sirn/void-packages pipewire-update
https://github.com/void-linux/void-packages/pull/20413

WIP: pipewire: update to 0.3.4
This PR updates `pipewire` to 0.3.4 and also updating/patching all packages that depends on it. 

* `xdg-desktop-portal` includes a patch backported from 1.7.0 to allow 1.6.0 to build against pipewire-0.3 (1.7.x is prerelease)
* `xdg-desktop-portal-kde` already includes Pipewire 0.3 support and only requires revbump.
* `mutter` includes a patch backported from 3.35 to allow 3.34 to build against pipewire-0.3 (upgrading to >=3.35 also requires upgrading GNOME).

A patch file from https://github.com/void-linux/void-packages/pull/20413.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pipewire-update-20413.patch --]
[-- Type: text/x-diff, Size: 53636 bytes --]

From e158e5265ca524d3ee166f86f41ef21e52238c64 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:23:52 +0900
Subject: [PATCH 1/4] pipewire: update to 0.3.4

---
 common/shlibs                                 |  2 +-
 srcpkgs/alsa-pipewire                         |  1 +
 srcpkgs/libjack-pipewire                      |  1 +
 srcpkgs/libpulseaudio-pipewire                |  1 +
 .../patches/01-fix-format-warning.patch       | 37 ++++++++++
 .../patches/02-fix-spa_log_func-musl.patch    | 25 +++++++
 srcpkgs/pipewire/template                     | 71 ++++++++++++++-----
 7 files changed, 120 insertions(+), 18 deletions(-)
 create mode 120000 srcpkgs/alsa-pipewire
 create mode 120000 srcpkgs/libjack-pipewire
 create mode 120000 srcpkgs/libpulseaudio-pipewire
 create mode 100644 srcpkgs/pipewire/patches/01-fix-format-warning.patch
 create mode 100644 srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch

diff --git a/common/shlibs b/common/shlibs
index a208407b359..07279a7bc72 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3199,7 +3199,7 @@ libarcan_shmif_ext.so.0.11 arcan-0.5.4.3_1
 libarcan_shmif_server.so.0.11 arcan-0.5.4.3_1
 libarcan_tui.so.0.11 arcan-0.5.4.3_1
 liblwipv6.so.2 lwipv6-1.5a_1
-libpipewire-0.2.so.1 libpipewire-0.2.2_1
+libpipewire-0.3.so.0 libpipewire-0.3.4_1
 libvolk.so.2.2.1 volk-2.2.1_1
 libgnuradio-runtime.so.3.8.0 gnuradio-3.8.0.0_1
 libgnuradio-pmt.so.3.8.0 gnuradio-3.8.0.0_1
diff --git a/srcpkgs/alsa-pipewire b/srcpkgs/alsa-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/alsa-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libjack-pipewire b/srcpkgs/libjack-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libjack-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libpulseaudio-pipewire b/srcpkgs/libpulseaudio-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libpulseaudio-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/pipewire/patches/01-fix-format-warning.patch b/srcpkgs/pipewire/patches/01-fix-format-warning.patch
new file mode 100644
index 00000000000..b4e8748390e
--- /dev/null
+++ b/srcpkgs/pipewire/patches/01-fix-format-warning.patch
@@ -0,0 +1,37 @@
+From 979a81a70d468d6482773521b89aaf67ce79b921 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Fri, 1 May 2020 11:05:38 +0200
+Subject: [PATCH] meson: add -Wformat
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+cc1: warning: ‘-Wformat-security’ ignored without ‘-Wformat’ [-Wformat-security]
+
+Fixes #234
+---
+ meson.build | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/meson.build b/meson.build
+index 74142587..1631e763 100644
+--- meson.build
++++ meson.build
+@@ -51,6 +51,7 @@ if cc.get_id() == 'gcc'
+ 			'-Wsign-compare',
+ 			'-Wimplicit-fallthrough',
+ 			'-Wpointer-arith',
++			'-Wformat',
+ 			'-Wformat-security',
+ 			'-Werror=suggest-attribute=format',
+ 			'-Wmissing-braces',
+@@ -68,6 +69,7 @@ if cc.get_id() == 'gcc'
+ 			'-Wsign-compare',
+ 			'-Wimplicit-fallthrough',
+ 			'-Wpointer-arith',
++			'-Wformat',
+ 			'-Wformat-security',
+ 			'-Werror=suggest-attribute=format',
+ 			'-Wmissing-braces',
+--
+2.26.2
diff --git a/srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch b/srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch
new file mode 100644
index 00000000000..b816975a6eb
--- /dev/null
+++ b/srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch
@@ -0,0 +1,25 @@
+From e83bf8a33f720050c7f1ec5f00530fafd5af5698 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Fri, 1 May 2020 11:18:28 +0200
+Subject: [PATCH] log: use printf attribute for log fallback
+
+Fixes #233
+---
+ spa/include/spa/support/log.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/spa/include/spa/support/log.h b/spa/include/spa/support/log.h
+index c97cc8e5..51b3e741 100644
+--- spa/include/spa/support/log.h
++++ spa/include/spa/support/log.h
+@@ -139,7 +139,7 @@ struct spa_log_methods {
+ #else
+
+ #define SPA_LOG_FUNC(name,lev)							\
+-static inline void spa_log_##name (struct spa_log *l, const char *format, ...)  \
++static inline SPA_PRINTF_FUNC(2,3) void spa_log_##name (struct spa_log *l, const char *format, ...)  \
+ {										\
+ 	if (SPA_UNLIKELY(spa_log_level_enabled(l, lev))) {			\
+ 		va_list varargs;						\
+--
+2.26.2
diff --git a/srcpkgs/pipewire/template b/srcpkgs/pipewire/template
index 7f646dad11d..763b7f9b365 100644
--- a/srcpkgs/pipewire/template
+++ b/srcpkgs/pipewire/template
@@ -1,26 +1,37 @@
 # Template file for 'pipewire'
 pkgname=pipewire
-version=0.2.7
+version=0.3.4
 revision=1
 build_style=meson
-configure_args="-Dman=true -Dgstreamer=enabled -Ddocs=true -Dsystemd=false"
+configure_args="-Dman=true -Dgstreamer=true -Ddocs=true -Dsystemd=false
+ -Dbluez5=true -Dffmpeg=true -Dpipewire-alsa=true -Dpipewire-jack=true
+ -Dpipewire-pulseaudio=true"
 hostmakedepends="doxygen graphviz pkg-config xmltoman"
 makedepends="SDL2-devel ffmpeg-devel gst-plugins-base1-devel jack-devel
- sbc-devel v4l-utils-devel libva-devel"
+ sbc-devel v4l-utils-devel libva-devel libbluetooth-devel"
 short_desc="Server and user space API to deal with multimedia pipelines"
-maintainer="Orphaned <orphan@voidlinux.org>"
-#Next release will probably change to MIT, currently listed in master
-license="LGPL-2.1-only, GPL-2.0-only "
+maintainer="Kridsada Thanabulpong <sirn@ogsite.net>"
+license="MIT"
 homepage="https://pipewire.org/"
-changelog="https://raw.githubusercontent.com/PipeWire/pipewire/master/NEWS"
-distfiles="https://github.com/PipeWire/pipewire/archive/${version}.tar.gz"
-checksum=bfaa0f6ae6c0791e2e0b59234d399753bf24f1b33dbf587682363a8463dd8df1
+changelog="https://gitlab.freedesktop.org/pipewire/pipewire/-/raw/master/NEWS"
+distfiles="https://gitlab.freedesktop.org/pipewire/pipewire/-/archive/${version}/pipewire-${version}.tar.gz"
+checksum=6a1c9c671514c84b38ce96d51823354702bc4d5dbaba12d501faa0448f892515
 conf_files="/etc/pipewire/pipewire.conf"
 
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+	LDFLAGS+=" -latomic"
+fi
+
+post_install() {
+	vlicense LICENSE
+}
+
 libpipewire_package() {
 	short_desc+=" - pipewire library"
 	pkg_install() {
-		vmove "usr/lib/libpipewire-0.2.so.*"
+		vmove "usr/lib/libpipewire-0.3.so.*"
+		vmove "usr/lib/pipewire-0.3/*.so"
 	}
 }
 
@@ -28,25 +39,25 @@ pipewire-devel_package() {
 	depends="libpipewire-${version}_${revision}"
 	short_desc+=" - pipewire and libspa development files"
 	pkg_install() {
-		vmove usr/include/pipewire
-		vmove usr/include/spa
-		vmove usr/lib/pkgconfig/libpipewire-0.2.pc
-		vmove usr/lib/pkgconfig/libspa-0.1.pc
-		vmove usr/lib/libpipewire-0.2.so
+		vmove usr/include/pipewire-0.3
+		vmove usr/include/spa-0.2
+		vmove usr/lib/pkgconfig/libpipewire-0.3.pc
+		vmove usr/lib/pkgconfig/libspa-0.2.pc
+		vmove usr/lib/libpipewire-0.3.so
 	}
 }
 
 libspa-ffmpeg_package() {
 	short_desc+=" - ffmpeg plugins"
 	pkg_install() {
-		vmove usr/lib/spa/ffmpeg
+		vmove usr/lib/spa-0.2/ffmpeg
 	}
 }
 
 libspa-bluetooth_package() {
 	short_desc+=" - bluetooth plugins"
 	pkg_install() {
-		vmove usr/lib/spa/bluez5
+		vmove usr/lib/spa-0.2/bluez5
 	}
 }
 
@@ -57,6 +68,32 @@ gstreamer1-pipewire_package() {
 	}
 }
 
+libpulseaudio-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - PulseAudio client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/pulse
+		vmove usr/bin/pw-pulse
+	}
+}
+
+alsa-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - ALSA client library"
+	pkg_install() {
+		vmove usr/lib/alsa-lib
+	}
+}
+
+libjack-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - JACK client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/jack
+		vmove usr/bin/pw-jack
+	}
+}
+
 pipewire-doc_package() {
 	archs=noarch
 	short_desc+=" - documentation"

From a8f0956ea2cf8744b34ff73895ce90d0cd5ed79e Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:46 +0900
Subject: [PATCH 2/4] xdg-desktop-portal-kde: rebuild for pipewire-0.3

---
 srcpkgs/xdg-desktop-portal-kde/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xdg-desktop-portal-kde/template b/srcpkgs/xdg-desktop-portal-kde/template
index f26057d323a..9519abc19f6 100644
--- a/srcpkgs/xdg-desktop-portal-kde/template
+++ b/srcpkgs/xdg-desktop-portal-kde/template
@@ -1,7 +1,7 @@
 # Template file for 'xdg-desktop-portal-kde'
 pkgname=xdg-desktop-portal-kde
 version=5.18.4.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules qt5-qmake qt5-host-tools kcoreaddons gettext"
 makedepends="glib-devel kio-devel kwayland-devel libepoxy-devel pipewire-devel

From a690faebd0e8fb453f6be22fdf181735ebe70132 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:26 +0900
Subject: [PATCH 3/4] xdg-desktop-portal: rebuild for pipewire-0.3

---
 .../patches/pipewire-0.3.patch                | 551 ++++++++++++++++++
 srcpkgs/xdg-desktop-portal/template           |   8 +-
 2 files changed, 557 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch

diff --git a/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..94ebe083598
--- /dev/null
+++ b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
@@ -0,0 +1,551 @@
+From a38901e5e7f835efe7b7a06c55790c8c20bc91a2 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Tue, 14 Jan 2020 09:37:09 +0100
+Subject: [PATCH] PipeWire: update to 0.3 API
+
+---
+ configure.ac      |   2 +-
+ src/camera.c      |  24 ++++----
+ src/pipewire.c    | 141 +++++++++++++---------------------------------
+ src/pipewire.h    |  10 ++--
+ src/screen-cast.c |  98 ++++++--------------------------
+ 5 files changed, 72 insertions(+), 203 deletions(-)
+
+diff --git configure.ac configure.ac
+index 89902fa..62d7960 100644
+--- configure.ac
++++ configure.ac
+@@ -97,7 +97,7 @@ AC_ARG_ENABLE(pipewire,
+ 	      [AS_HELP_STRING([--enable-pipewire],[Enable PipeWire support. Needed for screen cast portal])],
+ 	      enable_pipewire=$enableval, enable_pipewire=yes)
+ if test x$enable_pipewire = xyes ; then
+-	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.2 >= 0.2.6])
++	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.3 >= 0.2.90])
+ 	AC_DEFINE([HAVE_PIPEWIRE],[1], [Define to enable PipeWire support])
+ fi
+ AM_CONDITIONAL([HAVE_PIPEWIRE],[test "$enable_pipewire" = "yes"])
+diff --git src/camera.c src/camera.c
+index c2b392c..20fe3aa 100644
+--- src/camera.c
++++ src/camera.c
+@@ -141,7 +141,7 @@ open_pipewire_camera_remote (const char *app_id,
+                              GError **error)
+ {
+   PipeWireRemote *remote;
+-  struct spa_dict_item permission_items[1];
++  struct pw_permission permission_items[2];
+   struct pw_properties *pipewire_properties;
+ 
+   pipewire_properties =
+@@ -158,12 +158,12 @@ open_pipewire_camera_remote (const char *app_id,
+    * Hide all existing and future nodes by default. PipeWire will use the
+    * permission store to set up permissions.
+    */
+-  permission_items[0].key = PW_CORE_PROXY_PERMISSIONS_DEFAULT;
+-  permission_items[0].value = "---";
++  permission_items[0] = PW_PERMISSION_INIT (PW_ID_CORE, PW_PERM_RWX);
++  permission_items[1] = PW_PERMISSION_INIT (PW_ID_ANY, 0);
+ 
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             &SPA_DICT_INIT (permission_items,
+-                                             G_N_ELEMENTS (permission_items)));
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                G_N_ELEMENTS (permission_items),
++                                permission_items);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -219,7 +219,7 @@ handle_open_pipewire_remote (XdpCamera *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
+@@ -250,29 +250,28 @@ camera_iface_init (XdpCameraIface *iface)
+ static void
+ global_added_cb (PipeWireRemote *remote,
+                  uint32_t id,
+-                 uint32_t type,
++                 const char *type,
+                  const struct spa_dict *props,
+                  gpointer user_data)
+ {
+   Camera *camera = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *media_class;
+   const struct spa_dict_item *media_role;
+ 
+-  if (type != core_type->node)
++  if (strcmp(type, PW_TYPE_INTERFACE_Node) != 0)
+     return;
+ 
+   if (!props)
+     return;
+ 
+-  media_class = spa_dict_lookup_item (props, "media.class");
++  media_class = spa_dict_lookup_item (props, PW_KEY_MEDIA_CLASS);
+   if (!media_class)
+     return;
+ 
+   if (g_strcmp0 (media_class->value, "Video/Source") != 0)
+     return;
+ 
+-  media_role = spa_dict_lookup_item (props, "media.role");
++  media_role = spa_dict_lookup_item (props, PW_KEY_MEDIA_ROLE);
+   if (!media_role)
+     return;
+ 
+@@ -342,6 +341,7 @@ create_pipewire_remote (Camera *camera,
+     }
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.is_portal", "true",
++                                           "portal.monitor", "Camera",
+                                            NULL);
+   camera->pipewire_remote = pipewire_remote_new_sync (pipewire_properties,
+                                                       global_added_cb,
+diff --git src/pipewire.c src/pipewire.c
+index 793a378..162cd55 100644
+--- src/pipewire.c
++++ src/pipewire.c
+@@ -21,6 +21,7 @@
+ #include <errno.h>
+ #include <glib.h>
+ #include <pipewire/pipewire.h>
++#include <spa/utils/result.h>
+ 
+ #include "pipewire.h"
+ 
+@@ -36,27 +37,25 @@ static gboolean is_pipewire_initialized = FALSE;
+ static void
+ registry_event_global (void *user_data,
+                        uint32_t id,
+-                       uint32_t parent_id,
+                        uint32_t permissions,
+-                       uint32_t type,
++                       const char *type,
+                        uint32_t version,
+                        const struct spa_dict *props)
+ {
+   PipeWireRemote *remote = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *factory_object_type;
+   PipeWireGlobal *global;
+ 
+   global = g_new0 (PipeWireGlobal, 1);
+   *global = (PipeWireGlobal) {
+-    .parent_id = parent_id,
++    .parent_id = id,
+   };
+ 
+   g_hash_table_insert (remote->globals, GINT_TO_POINTER (id), global);
+   if (remote->global_added_cb)
+     remote->global_added_cb (remote, id, type, props, remote->user_data);
+ 
+-  if (type != core_type->factory)
++  if (strcmp(type, PW_TYPE_INTERFACE_Factory) != 0)
+     return;
+ 
+   factory_object_type = spa_dict_lookup_item (props, "factory.type.name");
+@@ -81,8 +80,8 @@ registry_event_global_remove (void *user_data,
+   g_hash_table_remove (remote->globals, GINT_TO_POINTER (id));
+ }
+ 
+-static const struct pw_registry_proxy_events registry_events = {
+-  PW_VERSION_REGISTRY_PROXY_EVENTS,
++static const struct pw_registry_events registry_events = {
++  PW_VERSION_REGISTRY_EVENTS,
+   .global = registry_event_global,
+   .global_remove = registry_event_global_remove,
+ };
+@@ -90,7 +89,7 @@ static const struct pw_registry_proxy_events registry_events = {
+ void
+ pipewire_remote_roundtrip (PipeWireRemote *remote)
+ {
+-  pw_core_proxy_sync (remote->core_proxy, ++remote->sync_seq);
++  remote->sync_seq = pw_core_sync (remote->core, PW_ID_CORE, remote->sync_seq);
+   pw_main_loop_run (remote->loop);
+ }
+ 
+@@ -98,16 +97,13 @@ static gboolean
+ discover_node_factory_sync (PipeWireRemote *remote,
+                             GError **error)
+ {
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+-  struct pw_registry_proxy *registry_proxy;
++  struct pw_registry *registry;
+ 
+-  registry_proxy = pw_core_proxy_get_registry (remote->core_proxy,
+-                                               core_type->registry,
+-                                               PW_VERSION_REGISTRY, 0);
+-  pw_registry_proxy_add_listener (registry_proxy,
+-                                  &remote->registry_listener,
+-                                  &registry_events,
+-                                  remote);
++  registry = pw_core_get_registry (remote->core, PW_VERSION_REGISTRY, 0);
++  pw_registry_add_listener (registry,
++                            &remote->registry_listener,
++                            &registry_events,
++                            remote);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -122,59 +118,35 @@ discover_node_factory_sync (PipeWireRemote *remote,
+ }
+ 
+ static void
+-on_state_changed (void *user_data,
+-                  enum pw_remote_state old,
+-                  enum pw_remote_state state,
+-                  const char *error)
++core_event_error (void       *user_data,
++                  uint32_t    id,
++		  int         seq,
++		  int         res,
++		  const char *message)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  switch (state)
++  if (id == PW_ID_CORE)
+     {
+-    case PW_REMOTE_STATE_ERROR:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "%s", error);
+-        }
++      g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
++                 "%s", message);
+       pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "Disconnected");
+-        }
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    default:
+-      g_warning ("Unknown PipeWire state");
+-      break;
+     }
+ }
+ 
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
+-};
+-
+ static void
+ core_event_done (void *user_data,
+-                 uint32_t seq)
++                 uint32_t id, int seq)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  if (remote->sync_seq == seq)
++  if (id == PW_ID_CORE && remote->sync_seq == seq)
+     pw_main_loop_quit (remote->loop);
+ }
+ 
+-static const struct pw_core_proxy_events core_events = {
+-  PW_VERSION_CORE_PROXY_EVENTS,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = core_event_error,
+   .done = core_event_done,
+ };
+ 
+@@ -237,8 +209,8 @@ void
+ pipewire_remote_destroy (PipeWireRemote *remote)
+ {
+   g_clear_pointer (&remote->globals, g_hash_table_destroy);
+-  g_clear_pointer (&remote->remote, pw_remote_destroy);
+-  g_clear_pointer (&remote->core, pw_core_destroy);
++  g_clear_pointer (&remote->core, pw_core_disconnect);
++  g_clear_pointer (&remote->context, pw_context_destroy);
+   g_clear_pointer (&remote->loop, pw_main_loop_destroy);
+   g_clear_error (&remote->error);
+ 
+@@ -307,68 +279,31 @@ pipewire_remote_new_sync (struct pw_properties *pipewire_properties,
+       return NULL;
+     }
+ 
+-  remote->core = pw_core_new (pw_main_loop_get_loop (remote->loop), NULL);
+-  if (!remote->core)
++  remote->context = pw_context_new (pw_main_loop_get_loop (remote->loop), NULL, 0);
++  if (!remote->context)
+     {
+       pipewire_remote_destroy (remote);
+       pw_properties_free (pipewire_properties);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire core");
++                   "Couldn't create PipeWire context");
+       return NULL;
+     }
+ 
+-  remote->remote = pw_remote_new (remote->core, pipewire_properties, 0);
+-  if (!remote->remote)
++  remote->core = pw_context_connect (remote->context, pipewire_properties, 0);
++  if (!remote->core)
+     {
+       pipewire_remote_destroy (remote);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire remote");
++                   "Couldn't connect to PipeWire");
+       return NULL;
+     }
+ 
+   remote->globals = g_hash_table_new_full (NULL, NULL, NULL, g_free);
+ 
+-  pw_remote_add_listener (remote->remote,
+-                          &remote->remote_listener,
+-                          &remote_events,
+-                          remote);
+-
+-  if (pw_remote_connect (remote->remote) != 0)
+-    {
+-      pipewire_remote_destroy (remote);
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect PipeWire remote");
+-      return NULL;
+-    }
+-
+-  pw_main_loop_run (remote->loop);
+-
+-  switch (pw_remote_get_state (remote->remote, NULL))
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      *error = g_steal_pointer (&remote->error);
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "PipeWire loop stopped unexpectedly");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      break;
+-    default:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Unexpected PipeWire state");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    }
+-
+-  remote->core_proxy = pw_remote_get_core_proxy (remote->remote);
+-  pw_core_proxy_add_listener (remote->core_proxy,
+-                              &remote->core_listener,
+-                              &core_events,
+-                              remote);
++  pw_core_add_listener (remote->core,
++                        &remote->core_listener,
++                        &core_events,
++                        remote);
+ 
+   if (!discover_node_factory_sync (remote, error))
+     {
+diff --git src/pipewire.h src/pipewire.h
+index 0f1bf54..bf48d5e 100644
+--- src/pipewire.h
++++ src/pipewire.h
+@@ -32,7 +32,7 @@ typedef struct _PipeWireGlobal
+ 
+ typedef void (* PipeWireGlobalAddedCallback) (PipeWireRemote *remote,
+                                               uint32_t id,
+-                                              uint32_t type,
++                                              const char *type,
+                                               const struct spa_dict *props,
+                                               gpointer user_data);
+ 
+@@ -43,13 +43,11 @@ typedef void (* PipeWireGlobalRemovedCallback) (PipeWireRemote *remote,
+ struct _PipeWireRemote
+ {
+   struct pw_main_loop *loop;
++  struct pw_context *context;
+   struct pw_core *core;
+-  struct pw_remote *remote;
+-  struct spa_hook remote_listener;
+-
+-  struct pw_core_proxy *core_proxy;
+   struct spa_hook core_listener;
+-  uint32_t sync_seq;
++
++  int sync_seq;
+ 
+   struct spa_hook registry_listener;
+ 
+diff --git src/screen-cast.c src/screen-cast.c
+index 7881ddc..1677050 100644
+--- src/screen-cast.c
++++ src/screen-cast.c
+@@ -31,10 +31,10 @@
+ #include "xdp-impl-dbus.h"
+ #include "xdp-utils.h"
+ 
+-#define PERMISSION_ITEM(item_key, item_value) \
+-  ((struct spa_dict_item) { \
+-    .key = item_key, \
+-    .value = item_value \
++#define PERMISSION_ITEM(item_id, item_permissions) \
++  ((struct pw_permission) { \
++    .id = item_id, \
++    .permissions = item_permissions \
+   })
+ 
+ typedef struct _ScreenCast ScreenCast;
+@@ -517,42 +517,9 @@ screen_cast_stream_get_pipewire_node_id (ScreenCastStream *stream)
+   return stream->id;
+ }
+ 
+-static void
+-append_parent_permissions (PipeWireRemote *remote,
+-                           GArray *permission_items,
+-                           GList **string_stash,
+-                           PipeWireGlobal *global,
+-                           const char *permission)
+-{
+-  PipeWireGlobal *parent;
+-  char *parent_permission_value;
+-
+-  if (global->parent_id == 0)
+-    return;
+-
+-  parent = g_hash_table_lookup (remote->globals, GINT_TO_POINTER (global->parent_id));
+-
+-  if (parent->permission_set)
+-    return;
+-  parent->permission_set = TRUE;
+-
+-  append_parent_permissions (remote, permission_items, string_stash,
+-                             parent, permission);
+-
+-  parent_permission_value = g_strdup_printf ("%u:%s",
+-                                             global->parent_id,
+-                                             permission);
+-  *string_stash = g_list_prepend (*string_stash, parent_permission_value);
+-
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       parent_permission_value));
+-}
+-
+ static void
+ append_stream_permissions (PipeWireRemote *remote,
+                            GArray *permission_items,
+-                           GList **string_stash,
+                            GList *streams)
+ {
+   GList *l;
+@@ -561,21 +528,10 @@ append_stream_permissions (PipeWireRemote *remote,
+     {
+       ScreenCastStream *stream = l->data;
+       uint32_t stream_id;
+-      PipeWireGlobal *stream_global;
+-      char *stream_permission_value;
+ 
+       stream_id = screen_cast_stream_get_pipewire_node_id (stream);
+-      stream_global = g_hash_table_lookup (remote->globals,
+-                                           GINT_TO_POINTER (stream_id));
+-
+-      append_parent_permissions (remote, permission_items, string_stash,
+-                                 stream_global, "r--");
+-
+-      stream_permission_value = g_strdup_printf ("%u:rwx", stream_id);
+-      *string_stash = g_list_prepend (*string_stash, stream_permission_value);
+       g_array_append_val (permission_items,
+-                          PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                           stream_permission_value));
++                          PERMISSION_ITEM (stream_id, PW_PERM_RWX));
+     }
+ }
+ 
+@@ -587,9 +543,6 @@ open_pipewire_screen_cast_remote (const char *app_id,
+   struct pw_properties *pipewire_properties;
+   PipeWireRemote *remote;
+   g_autoptr(GArray) permission_items = NULL;
+-  char *node_factory_permission_string;
+-  GList *string_stash = NULL;
+-  struct spa_dict *permission_dict;
+   PipeWireGlobal *node_global;
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.app_id", app_id,
+@@ -603,48 +556,31 @@ open_pipewire_screen_cast_remote (const char *app_id,
+ 
+   permission_items = g_array_new (FALSE, TRUE, sizeof (struct spa_dict_item));
+ 
+-  /*
+-   * Hide all existing and future nodes (except the ones we explicitly list below.
+-   */
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_EXISTING,
+-                                       "---"));
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_DEFAULT,
+-                                       "---"));
+-
+   /*
+    * PipeWire:Interface:Core
+    * Needs rwx to be able create the sink node using the create-object method
+    */
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       "0:rwx"));
++                      PERMISSION_ITEM (PW_ID_CORE, PW_PERM_RWX));
+ 
+   /*
+    * PipeWire:Interface:NodeFactory
+    * Needs r-- so it can be passed to create-object when creating the sink node.
+    */
+-  node_factory_permission_string = g_strdup_printf ("%d:r--",
+-                                                    remote->node_factory_id);
+-  string_stash = g_list_prepend (string_stash, node_factory_permission_string);
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       node_factory_permission_string));
+-  node_global = g_hash_table_lookup (remote->globals,
+-                                     GINT_TO_POINTER (remote->node_factory_id));
+-  append_parent_permissions (remote, permission_items, &string_stash,
+-                             node_global, "r--");
++                      PERMISSION_ITEM (remote->node_factory_id, PW_PERM_R));
+ 
+-  append_stream_permissions (remote, permission_items, &string_stash, streams);
++  append_stream_permissions (remote, permission_items, streams);
+ 
+-  permission_dict =
+-    &SPA_DICT_INIT ((struct spa_dict_item *) permission_items->data,
+-                    permission_items->len);
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             permission_dict);
++  /*
++   * Hide all existing and future nodes (except the ones we explicitly list above).
++   */
++  g_array_append_val (permission_items,
++                      PERMISSION_ITEM (PW_ID_ANY, 0));
+ 
+-  g_list_free_full (string_stash, g_free);
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                permission_items->len,
++                                (const struct pw_permission *)permission_items->data);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -943,7 +879,7 @@ handle_open_pipewire_remote (XdpScreenCast *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
diff --git a/srcpkgs/xdg-desktop-portal/template b/srcpkgs/xdg-desktop-portal/template
index eb8a4602f5d..1136b6a6e0e 100644
--- a/srcpkgs/xdg-desktop-portal/template
+++ b/srcpkgs/xdg-desktop-portal/template
@@ -1,10 +1,10 @@
 # Template file for 'xdg-desktop-portal'
 pkgname=xdg-desktop-portal
 version=1.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-pipewire --enable-geoclue --disable-libportal"
-hostmakedepends="pkg-config glib-devel"
+hostmakedepends="automake libtool gettext-devel pkg-config glib-devel"
 makedepends="flatpak-devel fuse-devel pipewire-devel geoclue2-devel"
 short_desc="Portal frontend service for Flatpak"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -13,6 +13,10 @@ homepage="https://github.com/flatpak/xdg-desktop-portal"
 distfiles="https://github.com/flatpak/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.xz"
 checksum=883c9c9a925e48af54812b5347f546dd776ec2e27076a83d5a8126af6bafb9da
 
+pre_configure() {
+	autoreconf -vfi
+}
+
 post_install() {
 	rm -rf "${DESTDIR}/usr/lib/systemd"
 }

From 6cd114d22c60e99fb406c054c1ee300965765dfa Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Thu, 30 Apr 2020 06:17:17 +0900
Subject: [PATCH 4/4] mutter: rebuild for pipewire-0.3

---
 srcpkgs/mutter/patches/pipewire-0.3.patch | 521 ++++++++++++++++++++++
 srcpkgs/mutter/template                   |   2 +-
 2 files changed, 522 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/mutter/patches/pipewire-0.3.patch

diff --git a/srcpkgs/mutter/patches/pipewire-0.3.patch b/srcpkgs/mutter/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..ebff65fba85
--- /dev/null
+++ b/srcpkgs/mutter/patches/pipewire-0.3.patch
@@ -0,0 +1,521 @@
+Build mutter against pipewire-0.3, based on a patch at:
+https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1062
+--- meson.build
++++ meson.build
+@@ -50,7 +50,7 @@ libinput_req = '>= 1.7'
+ gbm_req = '>= 10.3'
+
+ # screen cast version requirements
+-libpipewire_req = '>= 0.2.5'
++libpipewire_req = '>= 0.3.0'
+
+ gnome = import('gnome')
+ pkg = import('pkgconfig')
+@@ -241,7 +241,7 @@ endif
+
+ have_remote_desktop = get_option('remote_desktop')
+ if have_remote_desktop
+-  libpipewire_dep = dependency('libpipewire-0.2', version: libpipewire_req)
++  libpipewire_dep = dependency('libpipewire-0.3', version: libpipewire_req)
+ endif
+
+ have_introspection = get_option('introspection')
+diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
+index 82c5cba436..ba1ce94a7e 100644
+--- src/backends/meta-screen-cast-stream-src.c
++++ src/backends/meta-screen-cast-stream-src.c
+@@ -29,6 +29,7 @@
+ #include <spa/param/props.h>
+ #include <spa/param/format-utils.h>
+ #include <spa/param/video/format-utils.h>
++#include <spa/utils/result.h>
+ #include <stdint.h>
+ #include <sys/mman.h>
+
+@@ -62,15 +63,6 @@ enum
+
+ static guint signals[N_SIGNALS];
+
+-typedef struct _MetaSpaType
+-{
+-  struct spa_type_media_type media_type;
+-  struct spa_type_media_subtype media_subtype;
+-  struct spa_type_format_video format_video;
+-  struct spa_type_video_format video_format;
+-  uint32_t meta_cursor;
+-} MetaSpaType;
+-
+ typedef struct _MetaPipeWireSource
+ {
+   GSource base;
+@@ -82,19 +74,19 @@ typedef struct _MetaScreenCastStreamSrcPrivate
+ {
+   MetaScreenCastStream *stream;
+
++  struct pw_context *pipewire_context;
+   struct pw_core *pipewire_core;
+-  struct pw_remote *pipewire_remote;
+-  struct pw_type *pipewire_type;
+   MetaPipeWireSource *pipewire_source;
+-  struct spa_hook pipewire_remote_listener;
++  struct spa_hook pipewire_core_listener;
+
+   gboolean is_enabled;
+
+   struct pw_stream *pipewire_stream;
+   struct spa_hook pipewire_stream_listener;
++  uint32_t node_id;
+
+-  MetaSpaType spa_type;
+   struct spa_video_info_raw video_format;
++  int video_stride;
+
+   uint64_t last_frame_timestamp_us;
+
+@@ -112,8 +104,6 @@ G_DEFINE_TYPE_WITH_CODE (MetaScreenCastStreamSrc,
+                                                 meta_screen_cast_stream_src_init_initable_iface)
+                          G_ADD_PRIVATE (MetaScreenCastStreamSrc))
+
+-#define PROP_RANGE(min, max) 2, (min), (max)
+-
+ static void
+ meta_screen_cast_stream_src_get_specs (MetaScreenCastStreamSrc *src,
+                                        int                     *width,
+@@ -286,9 +276,6 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+                                                               int                      x,
+                                                               int                      y)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+
+   spa_meta_cursor->id = 1;
+@@ -300,7 +287,7 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   spa_meta_cursor->hotspot.x = 0;
+@@ -317,9 +304,6 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+                                                         int                      y,
+                                                         float                    scale)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   CoglTexture *cursor_texture;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+   int hotspot_x, hotspot_y;
+@@ -346,7 +330,7 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
+@@ -382,12 +366,10 @@ static void
+ add_cursor_metadata (MetaScreenCastStreamSrc *src,
+                      struct spa_buffer       *spa_buffer)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_cursor *spa_meta_cursor;
+
+-  spa_meta_cursor = spa_buffer_find_meta (spa_buffer, spa_type->meta_cursor);
++  spa_meta_cursor = spa_buffer_find_meta_data (spa_buffer, SPA_META_Cursor,
++                                               sizeof (*spa_meta_cursor));
+   if (spa_meta_cursor)
+     meta_screen_cast_stream_src_set_cursor_metadata (src, spa_meta_cursor);
+ }
+@@ -447,14 +429,14 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+     {
+       data = spa_buffer->datas[0].data;
+     }
+-  else if (spa_buffer->datas[0].type == priv->pipewire_type->data.MemFd)
++  else if (spa_buffer->datas[0].type == SPA_DATA_MemFd)
+     {
+       map = mmap (NULL, spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset,
+                   PROT_READ | PROT_WRITE, MAP_SHARED,
+                   spa_buffer->datas[0].fd, 0);
+       if (map == MAP_FAILED)
+         {
+-          g_warning ("Failed to mmap pipewire stream buffer: %s\n",
++          g_warning ("Failed to mmap pipewire stream buffer: %s",
+                      strerror (errno));
+           return;
+         }
+@@ -469,28 +451,30 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+
+   if (meta_screen_cast_stream_src_record_frame (src, data))
+     {
+-      struct spa_meta_video_crop *spa_meta_video_crop;
++      struct spa_meta_region *spa_meta_video_crop;
+
+       spa_buffer->datas[0].chunk->size = spa_buffer->datas[0].maxsize;
++      spa_buffer->datas[0].chunk->stride = priv->video_stride;
+
+       /* Update VideoCrop if needed */
+       spa_meta_video_crop =
+-        spa_buffer_find_meta (spa_buffer, priv->pipewire_type->meta.VideoCrop);
++        spa_buffer_find_meta_data (spa_buffer, SPA_META_VideoCrop,
++                                   sizeof (*spa_meta_video_crop));
+       if (spa_meta_video_crop)
+         {
+           if (meta_screen_cast_stream_src_get_videocrop (src, &crop_rect))
+             {
+-              spa_meta_video_crop->x = crop_rect.x;
+-              spa_meta_video_crop->y = crop_rect.y;
+-              spa_meta_video_crop->width = crop_rect.width;
+-              spa_meta_video_crop->height = crop_rect.height;
++              spa_meta_video_crop->region.position.x = crop_rect.x;
++              spa_meta_video_crop->region.position.y = crop_rect.y;
++              spa_meta_video_crop->region.size.width = crop_rect.width;
++              spa_meta_video_crop->region.size.height = crop_rect.height;
+             }
+           else
+             {
+-              spa_meta_video_crop->x = 0;
+-              spa_meta_video_crop->y = 0;
+-              spa_meta_video_crop->width = priv->stream_width;
+-              spa_meta_video_crop->height = priv->stream_height;
++              spa_meta_video_crop->region.position.x = 0;
++              spa_meta_video_crop->region.position.y = 0;
++              spa_meta_video_crop->region.size.width = priv->stream_width;
++              spa_meta_video_crop->region.size.height = priv->stream_height;
+             }
+         }
+     }
+@@ -555,7 +539,6 @@ on_stream_state_changed (void                 *data,
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  uint32_t node_id;
+
+   switch (state)
+     {
+@@ -563,14 +546,12 @@ on_stream_state_changed (void                 *data,
+       g_warning ("pipewire stream error: %s", error_message);
+       meta_screen_cast_stream_src_notify_closed (src);
+       break;
+-    case PW_STREAM_STATE_CONFIGURE:
+-      node_id = pw_stream_get_node_id (priv->pipewire_stream);
+-      g_signal_emit (src, signals[READY], 0, (unsigned int) node_id);
+-      break;
+-    case PW_STREAM_STATE_UNCONNECTED:
+-    case PW_STREAM_STATE_CONNECTING:
+-    case PW_STREAM_STATE_READY:
+     case PW_STREAM_STATE_PAUSED:
++      if (priv->node_id == SPA_ID_INVALID && priv->pipewire_stream)
++        {
++          priv->node_id = pw_stream_get_node_id (priv->pipewire_stream);
++          g_signal_emit (src, signals[READY], 0, (unsigned int) priv->node_id);
++        }
+       if (meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_disable (src);
+       break;
+@@ -578,68 +559,69 @@ on_stream_state_changed (void                 *data,
+       if (!meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_enable (src);
+       break;
++    case PW_STREAM_STATE_UNCONNECTED:
++    case PW_STREAM_STATE_CONNECTING:
++      break;
+     }
+ }
+
+ static void
+-on_stream_format_changed (void                 *data,
+-                          const struct spa_pod *format)
++on_stream_param_changed (void                 *data,
++                         uint32_t              id,
++                         const struct spa_pod *format)
+ {
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   uint8_t params_buffer[1024];
+   int32_t width, height, stride, size;
+   struct spa_pod_builder pod_builder;
+   const struct spa_pod *params[3];
+   const int bpp = 4;
+
+-  if (!format)
+-    {
+-      pw_stream_finish_format (priv->pipewire_stream, 0, NULL, 0);
+-      return;
+-    }
++  if (!format || id != SPA_PARAM_Format)
++    return;
+
+   spa_format_video_raw_parse (format,
+-                              &priv->video_format,
+-                              &priv->spa_type.format_video);
++                              &priv->video_format);
+
+   width = priv->video_format.size.width;
+   height = priv->video_format.size.height;
+   stride = SPA_ROUND_UP_N (width * bpp, 4);
+   size = height * stride;
+
++  priv->video_stride = stride;
++
+   pod_builder = SPA_POD_BUILDER_INIT (params_buffer, sizeof (params_buffer));
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idBuffers, pipewire_type->param_buffers.Buffers,
+-    ":", pipewire_type->param_buffers.size, "i", size,
+-    ":", pipewire_type->param_buffers.stride, "i", stride,
+-    ":", pipewire_type->param_buffers.buffers, "iru", 16, PROP_RANGE (2, 16),
+-    ":", pipewire_type->param_buffers.align, "i", 16);
+-
+-  params[1] = spa_pod_builder_object (
++    SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
++    SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int (16, 2, 16),
++    SPA_PARAM_BUFFERS_blocks, SPA_POD_Int (1),
++    SPA_PARAM_BUFFERS_size, SPA_POD_Int (size),
++    SPA_PARAM_BUFFERS_stride, SPA_POD_Int (stride),
++    SPA_PARAM_BUFFERS_align, SPA_POD_Int (16));
++
++  params[1] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", pipewire_type->meta.VideoCrop,
+-    ":", pipewire_type->param_meta.size, "i", sizeof (struct spa_meta_video_crop));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_VideoCrop),
++    SPA_PARAM_META_size, SPA_POD_Int (sizeof (struct spa_meta_region)));
+
+-  params[2] = spa_pod_builder_object (
++  params[2] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", priv->spa_type.meta_cursor,
+-    ":", pipewire_type->param_meta.size, "i", CURSOR_META_SIZE (64, 64));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_Cursor),
++    SPA_PARAM_META_size, SPA_POD_Int (CURSOR_META_SIZE (64, 64)));
+
+-  pw_stream_finish_format (priv->pipewire_stream, 0,
+-                           params, G_N_ELEMENTS (params));
++  pw_stream_update_params (priv->pipewire_stream, params, G_N_ELEMENTS (params));
+ }
+
+ static const struct pw_stream_events stream_events = {
+   PW_VERSION_STREAM_EVENTS,
+   .state_changed = on_stream_state_changed,
+-  .format_changed = on_stream_format_changed,
++  .param_changed = on_stream_param_changed,
+ };
+
+ static struct pw_stream *
+@@ -652,8 +634,6 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   uint8_t buffer[1024];
+   struct spa_pod_builder pod_builder =
+     SPA_POD_BUILDER_INIT (buffer, sizeof (buffer));
+-  MetaSpaType *spa_type = &priv->spa_type;
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   float frame_rate;
+   MetaFraction frame_rate_fraction;
+   struct spa_fraction max_framerate;
+@@ -661,7 +641,9 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   const struct spa_pod *params[1];
+   int result;
+
+-  pipewire_stream = pw_stream_new (priv->pipewire_remote,
++  priv->node_id = SPA_ID_INVALID;
++
++  pipewire_stream = pw_stream_new (priv->pipewire_core,
+                                    "meta-screen-cast-src",
+                                    NULL);
+   if (!pipewire_stream)
+@@ -682,17 +664,17 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   max_framerate = SPA_FRACTION (frame_rate_fraction.num,
+                                 frame_rate_fraction.denom);
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idEnumFormat, pipewire_type->spa_format,
+-    "I", spa_type->media_type.video,
+-    "I", spa_type->media_subtype.raw,
+-    ":", spa_type->format_video.format, "I", spa_type->video_format.BGRx,
+-    ":", spa_type->format_video.size, "R", &SPA_RECTANGLE (priv->stream_width,
+-                                                           priv->stream_height),
+-    ":", spa_type->format_video.framerate, "F", &SPA_FRACTION (0, 1),
+-    ":", spa_type->format_video.max_framerate, "Fru", &max_framerate,
+-                                                      PROP_RANGE (&min_framerate,
++    SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
++    SPA_FORMAT_mediaType, SPA_POD_Id (SPA_MEDIA_TYPE_video),
++    SPA_FORMAT_mediaSubtype, SPA_POD_Id (SPA_MEDIA_SUBTYPE_raw),
++    SPA_FORMAT_VIDEO_format, SPA_POD_Id (SPA_VIDEO_FORMAT_BGRx),
++    SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle (&SPA_RECTANGLE (priv->stream_width,
++                                                              priv->stream_height)),
++    SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction (&SPA_FRACTION (0, 1)),
++    SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction (&max_framerate,
++                                                                  &min_framerate,
+                                                                   &max_framerate));
+
+   pw_stream_add_listener (pipewire_stream,
+@@ -702,7 +684,7 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+
+   result = pw_stream_connect (pipewire_stream,
+                               PW_DIRECTION_OUTPUT,
+-                              NULL,
++                              SPA_ID_INVALID,
+                               (PW_STREAM_FLAG_DRIVER |
+                                PW_STREAM_FLAG_MAP_BUFFERS),
+                               params, G_N_ELEMENTS (params));
+@@ -717,40 +699,18 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+ }
+
+ static void
+-on_state_changed (void                 *data,
+-                  enum pw_remote_state  old,
+-                  enum pw_remote_state  state,
+-                  const char           *error_message)
++on_core_error (void       *data,
++               uint32_t    id,
++	       int         seq,
++	       int         res,
++	       const char *message)
+ {
+   MetaScreenCastStreamSrc *src = data;
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_stream *pipewire_stream;
+-  GError *error = NULL;
+
+-  switch (state)
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-      g_warning ("pipewire remote error: %s\n", error_message);
+-      meta_screen_cast_stream_src_notify_closed (src);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pipewire_stream = create_pipewire_stream (src, &error);
+-      if (!pipewire_stream)
+-        {
+-          g_warning ("Could not create pipewire stream: %s", error->message);
+-          g_error_free (error);
+-          meta_screen_cast_stream_src_notify_closed (src);
+-        }
+-      else
+-        {
+-          priv->pipewire_stream = pipewire_stream;
+-        }
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    }
++  g_warning ("pipewire remote error: id:%u %s", id, message);
++
++  if (id == PW_ID_CORE && res == -EPIPE)
++    meta_screen_cast_stream_src_notify_closed (src);
+ }
+
+ static gboolean
+@@ -793,17 +753,6 @@ static GSourceFuncs pipewire_source_funcs =
+   pipewire_loop_source_finalize
+ };
+
+-static void
+-init_spa_type (MetaSpaType         *type,
+-               struct spa_type_map *map)
+-{
+-  spa_type_media_type_map (map, &type->media_type);
+-  spa_type_media_subtype_map (map, &type->media_subtype);
+-  spa_type_format_video_map (map, &type->format_video);
+-  spa_type_video_format_map (map, &type->video_format);
+-  type->meta_cursor = spa_type_map_get_id(map, SPA_TYPE_META__Cursor);
+-}
+-
+ static MetaPipeWireSource *
+ create_pipewire_source (void)
+ {
+@@ -829,9 +778,9 @@ create_pipewire_source (void)
+   return pipewire_source;
+ }
+
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = on_core_error,
+ };
+
+ static gboolean
+@@ -851,37 +800,31 @@ meta_screen_cast_stream_src_initable_init (GInitable     *initable,
+       return FALSE;
+     }
+
+-  priv->pipewire_core = pw_core_new (priv->pipewire_source->pipewire_loop,
+-                                     NULL);
+-  if (!priv->pipewire_core)
++  priv->pipewire_context = pw_context_new (priv->pipewire_source->pipewire_loop,
++                                           NULL, 0);
++  if (!priv->pipewire_context)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Failed to create pipewire core");
++                   "Failed to create pipewire context");
+       return FALSE;
+     }
+
+-  priv->pipewire_remote = pw_remote_new (priv->pipewire_core, NULL, 0);
+-  if (!priv->pipewire_remote)
++  priv->pipewire_core = pw_context_connect (priv->pipewire_context, NULL, 0);
++  if (!priv->pipewire_core)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't creat pipewire remote");
++                   "Couldn't connect pipewire context");
+       return FALSE;
+     }
+
+-  pw_remote_add_listener (priv->pipewire_remote,
+-                          &priv->pipewire_remote_listener,
+-                          &remote_events,
+-                          src);
++  pw_core_add_listener (priv->pipewire_core,
++                        &priv->pipewire_core_listener,
++                        &core_events,
++                        src);
+
+-  priv->pipewire_type = pw_core_get_type (priv->pipewire_core);
+-  init_spa_type (&priv->spa_type, priv->pipewire_type->map);
+-
+-  if (pw_remote_connect (priv->pipewire_remote) != 0)
+-    {
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect pipewire remote");
+-      return FALSE;
+-    }
++  priv->pipewire_stream = create_pipewire_stream (src, error);
++  if (!priv->pipewire_stream)
++    return FALSE;
+
+   return TRUE;
+ }
+@@ -912,8 +855,8 @@ meta_screen_cast_stream_src_finalize (GObject *object)
+     meta_screen_cast_stream_src_disable (src);
+
+   g_clear_pointer (&priv->pipewire_stream, pw_stream_destroy);
+-  g_clear_pointer (&priv->pipewire_remote, pw_remote_destroy);
+-  g_clear_pointer (&priv->pipewire_core, pw_core_destroy);
++  g_clear_pointer (&priv->pipewire_core, pw_core_disconnect);
++  g_clear_pointer (&priv->pipewire_context, pw_context_destroy);
+   g_source_destroy (&priv->pipewire_source->base);
+
+   G_OBJECT_CLASS (meta_screen_cast_stream_src_parent_class)->finalize (object);
diff --git a/srcpkgs/mutter/template b/srcpkgs/mutter/template
index 4e0bd32b67d..806a3bef9f0 100644
--- a/srcpkgs/mutter/template
+++ b/srcpkgs/mutter/template
@@ -1,7 +1,7 @@
 # Template file for 'mutter'
 pkgname=mutter
 version=3.34.1
-revision=2
+revision=3
 build_helper="gir"
 build_style=meson
 configure_args="-Degl_device=true -Dudev=true -Dnative_backend=true

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PR PATCH] [Updated] WIP: pipewire: update to 0.3.4
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (32 preceding siblings ...)
  2020-05-01 11:50 ` [PR PATCH] [Updated] WIP: " sirn
@ 2020-05-07 18:27 ` sirn
  2020-05-09 15:10 ` sirn
                   ` (17 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-05-07 18:27 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 790 bytes --]

There is an updated pull request by sirn against master on the void-packages repository

https://github.com/sirn/void-packages pipewire-update
https://github.com/void-linux/void-packages/pull/20413

WIP: pipewire: update to 0.3.4
This PR updates `pipewire` to 0.3.4 and also updating/patching all packages that depends on it. 

* `xdg-desktop-portal` includes a patch backported from 1.7.0 to allow 1.6.0 to build against pipewire-0.3 (1.7.x is prerelease)
* `xdg-desktop-portal-kde` already includes Pipewire 0.3 support and only requires revbump.
* `mutter` includes a patch backported from 3.35 to allow 3.34 to build against pipewire-0.3 (upgrading to >=3.35 also requires upgrading GNOME).

A patch file from https://github.com/void-linux/void-packages/pull/20413.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pipewire-update-20413.patch --]
[-- Type: text/x-diff, Size: 53634 bytes --]

From c8ded5e466639202af420a8fac4332fad1486997 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:23:52 +0900
Subject: [PATCH 1/4] pipewire: update to 0.3.4

---
 common/shlibs                                 |  2 +-
 srcpkgs/alsa-pipewire                         |  1 +
 srcpkgs/libjack-pipewire                      |  1 +
 srcpkgs/libpulseaudio-pipewire                |  1 +
 .../patches/01-fix-format-warning.patch       | 37 ++++++++++
 .../patches/02-fix-spa_log_func-musl.patch    | 25 +++++++
 srcpkgs/pipewire/template                     | 71 ++++++++++++++-----
 7 files changed, 120 insertions(+), 18 deletions(-)
 create mode 120000 srcpkgs/alsa-pipewire
 create mode 120000 srcpkgs/libjack-pipewire
 create mode 120000 srcpkgs/libpulseaudio-pipewire
 create mode 100644 srcpkgs/pipewire/patches/01-fix-format-warning.patch
 create mode 100644 srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch

diff --git a/common/shlibs b/common/shlibs
index 4bdc03e8b23..8ae2256900b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3203,7 +3203,7 @@ libarcan_shmif_ext.so.0.11 arcan-0.5.4.3_1
 libarcan_shmif_server.so.0.11 arcan-0.5.4.3_1
 libarcan_tui.so.0.11 arcan-0.5.4.3_1
 liblwipv6.so.2 lwipv6-1.5a_1
-libpipewire-0.2.so.1 libpipewire-0.2.2_1
+libpipewire-0.3.so.0 libpipewire-0.3.4_1
 libvolk.so.2.2.1 volk-2.2.1_1
 libgnuradio-runtime.so.3.8.0 gnuradio-3.8.0.0_1
 libgnuradio-pmt.so.3.8.0 gnuradio-3.8.0.0_1
diff --git a/srcpkgs/alsa-pipewire b/srcpkgs/alsa-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/alsa-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libjack-pipewire b/srcpkgs/libjack-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libjack-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libpulseaudio-pipewire b/srcpkgs/libpulseaudio-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libpulseaudio-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/pipewire/patches/01-fix-format-warning.patch b/srcpkgs/pipewire/patches/01-fix-format-warning.patch
new file mode 100644
index 00000000000..b4e8748390e
--- /dev/null
+++ b/srcpkgs/pipewire/patches/01-fix-format-warning.patch
@@ -0,0 +1,37 @@
+From 979a81a70d468d6482773521b89aaf67ce79b921 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Fri, 1 May 2020 11:05:38 +0200
+Subject: [PATCH] meson: add -Wformat
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+cc1: warning: ‘-Wformat-security’ ignored without ‘-Wformat’ [-Wformat-security]
+
+Fixes #234
+---
+ meson.build | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/meson.build b/meson.build
+index 74142587..1631e763 100644
+--- meson.build
++++ meson.build
+@@ -51,6 +51,7 @@ if cc.get_id() == 'gcc'
+ 			'-Wsign-compare',
+ 			'-Wimplicit-fallthrough',
+ 			'-Wpointer-arith',
++			'-Wformat',
+ 			'-Wformat-security',
+ 			'-Werror=suggest-attribute=format',
+ 			'-Wmissing-braces',
+@@ -68,6 +69,7 @@ if cc.get_id() == 'gcc'
+ 			'-Wsign-compare',
+ 			'-Wimplicit-fallthrough',
+ 			'-Wpointer-arith',
++			'-Wformat',
+ 			'-Wformat-security',
+ 			'-Werror=suggest-attribute=format',
+ 			'-Wmissing-braces',
+--
+2.26.2
diff --git a/srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch b/srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch
new file mode 100644
index 00000000000..b816975a6eb
--- /dev/null
+++ b/srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch
@@ -0,0 +1,25 @@
+From e83bf8a33f720050c7f1ec5f00530fafd5af5698 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Fri, 1 May 2020 11:18:28 +0200
+Subject: [PATCH] log: use printf attribute for log fallback
+
+Fixes #233
+---
+ spa/include/spa/support/log.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/spa/include/spa/support/log.h b/spa/include/spa/support/log.h
+index c97cc8e5..51b3e741 100644
+--- spa/include/spa/support/log.h
++++ spa/include/spa/support/log.h
+@@ -139,7 +139,7 @@ struct spa_log_methods {
+ #else
+
+ #define SPA_LOG_FUNC(name,lev)							\
+-static inline void spa_log_##name (struct spa_log *l, const char *format, ...)  \
++static inline SPA_PRINTF_FUNC(2,3) void spa_log_##name (struct spa_log *l, const char *format, ...)  \
+ {										\
+ 	if (SPA_UNLIKELY(spa_log_level_enabled(l, lev))) {			\
+ 		va_list varargs;						\
+--
+2.26.2
diff --git a/srcpkgs/pipewire/template b/srcpkgs/pipewire/template
index 7f646dad11d..763b7f9b365 100644
--- a/srcpkgs/pipewire/template
+++ b/srcpkgs/pipewire/template
@@ -1,26 +1,37 @@
 # Template file for 'pipewire'
 pkgname=pipewire
-version=0.2.7
+version=0.3.4
 revision=1
 build_style=meson
-configure_args="-Dman=true -Dgstreamer=enabled -Ddocs=true -Dsystemd=false"
+configure_args="-Dman=true -Dgstreamer=true -Ddocs=true -Dsystemd=false
+ -Dbluez5=true -Dffmpeg=true -Dpipewire-alsa=true -Dpipewire-jack=true
+ -Dpipewire-pulseaudio=true"
 hostmakedepends="doxygen graphviz pkg-config xmltoman"
 makedepends="SDL2-devel ffmpeg-devel gst-plugins-base1-devel jack-devel
- sbc-devel v4l-utils-devel libva-devel"
+ sbc-devel v4l-utils-devel libva-devel libbluetooth-devel"
 short_desc="Server and user space API to deal with multimedia pipelines"
-maintainer="Orphaned <orphan@voidlinux.org>"
-#Next release will probably change to MIT, currently listed in master
-license="LGPL-2.1-only, GPL-2.0-only "
+maintainer="Kridsada Thanabulpong <sirn@ogsite.net>"
+license="MIT"
 homepage="https://pipewire.org/"
-changelog="https://raw.githubusercontent.com/PipeWire/pipewire/master/NEWS"
-distfiles="https://github.com/PipeWire/pipewire/archive/${version}.tar.gz"
-checksum=bfaa0f6ae6c0791e2e0b59234d399753bf24f1b33dbf587682363a8463dd8df1
+changelog="https://gitlab.freedesktop.org/pipewire/pipewire/-/raw/master/NEWS"
+distfiles="https://gitlab.freedesktop.org/pipewire/pipewire/-/archive/${version}/pipewire-${version}.tar.gz"
+checksum=6a1c9c671514c84b38ce96d51823354702bc4d5dbaba12d501faa0448f892515
 conf_files="/etc/pipewire/pipewire.conf"
 
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+	LDFLAGS+=" -latomic"
+fi
+
+post_install() {
+	vlicense LICENSE
+}
+
 libpipewire_package() {
 	short_desc+=" - pipewire library"
 	pkg_install() {
-		vmove "usr/lib/libpipewire-0.2.so.*"
+		vmove "usr/lib/libpipewire-0.3.so.*"
+		vmove "usr/lib/pipewire-0.3/*.so"
 	}
 }
 
@@ -28,25 +39,25 @@ pipewire-devel_package() {
 	depends="libpipewire-${version}_${revision}"
 	short_desc+=" - pipewire and libspa development files"
 	pkg_install() {
-		vmove usr/include/pipewire
-		vmove usr/include/spa
-		vmove usr/lib/pkgconfig/libpipewire-0.2.pc
-		vmove usr/lib/pkgconfig/libspa-0.1.pc
-		vmove usr/lib/libpipewire-0.2.so
+		vmove usr/include/pipewire-0.3
+		vmove usr/include/spa-0.2
+		vmove usr/lib/pkgconfig/libpipewire-0.3.pc
+		vmove usr/lib/pkgconfig/libspa-0.2.pc
+		vmove usr/lib/libpipewire-0.3.so
 	}
 }
 
 libspa-ffmpeg_package() {
 	short_desc+=" - ffmpeg plugins"
 	pkg_install() {
-		vmove usr/lib/spa/ffmpeg
+		vmove usr/lib/spa-0.2/ffmpeg
 	}
 }
 
 libspa-bluetooth_package() {
 	short_desc+=" - bluetooth plugins"
 	pkg_install() {
-		vmove usr/lib/spa/bluez5
+		vmove usr/lib/spa-0.2/bluez5
 	}
 }
 
@@ -57,6 +68,32 @@ gstreamer1-pipewire_package() {
 	}
 }
 
+libpulseaudio-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - PulseAudio client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/pulse
+		vmove usr/bin/pw-pulse
+	}
+}
+
+alsa-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - ALSA client library"
+	pkg_install() {
+		vmove usr/lib/alsa-lib
+	}
+}
+
+libjack-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - JACK client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/jack
+		vmove usr/bin/pw-jack
+	}
+}
+
 pipewire-doc_package() {
 	archs=noarch
 	short_desc+=" - documentation"

From e0e70fc4e9cf8c74b6c575cb76ef00cd766ec118 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:46 +0900
Subject: [PATCH 2/4] xdg-desktop-portal-kde: rebuild for pipewire-0.3

---
 srcpkgs/xdg-desktop-portal-kde/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xdg-desktop-portal-kde/template b/srcpkgs/xdg-desktop-portal-kde/template
index 7a2aaf16b96..574e28504b7 100644
--- a/srcpkgs/xdg-desktop-portal-kde/template
+++ b/srcpkgs/xdg-desktop-portal-kde/template
@@ -1,7 +1,7 @@
 # Template file for 'xdg-desktop-portal-kde'
 pkgname=xdg-desktop-portal-kde
 version=5.18.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules qt5-qmake qt5-host-tools kcoreaddons gettext"
 makedepends="glib-devel kio-devel kwayland-devel libepoxy-devel pipewire-devel

From f86806c3945675f280b99e5e24677e223c1cb207 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:26 +0900
Subject: [PATCH 3/4] xdg-desktop-portal: rebuild for pipewire-0.3

---
 .../patches/pipewire-0.3.patch                | 551 ++++++++++++++++++
 srcpkgs/xdg-desktop-portal/template           |   8 +-
 2 files changed, 557 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch

diff --git a/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..94ebe083598
--- /dev/null
+++ b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
@@ -0,0 +1,551 @@
+From a38901e5e7f835efe7b7a06c55790c8c20bc91a2 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Tue, 14 Jan 2020 09:37:09 +0100
+Subject: [PATCH] PipeWire: update to 0.3 API
+
+---
+ configure.ac      |   2 +-
+ src/camera.c      |  24 ++++----
+ src/pipewire.c    | 141 +++++++++++++---------------------------------
+ src/pipewire.h    |  10 ++--
+ src/screen-cast.c |  98 ++++++--------------------------
+ 5 files changed, 72 insertions(+), 203 deletions(-)
+
+diff --git configure.ac configure.ac
+index 89902fa..62d7960 100644
+--- configure.ac
++++ configure.ac
+@@ -97,7 +97,7 @@ AC_ARG_ENABLE(pipewire,
+ 	      [AS_HELP_STRING([--enable-pipewire],[Enable PipeWire support. Needed for screen cast portal])],
+ 	      enable_pipewire=$enableval, enable_pipewire=yes)
+ if test x$enable_pipewire = xyes ; then
+-	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.2 >= 0.2.6])
++	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.3 >= 0.2.90])
+ 	AC_DEFINE([HAVE_PIPEWIRE],[1], [Define to enable PipeWire support])
+ fi
+ AM_CONDITIONAL([HAVE_PIPEWIRE],[test "$enable_pipewire" = "yes"])
+diff --git src/camera.c src/camera.c
+index c2b392c..20fe3aa 100644
+--- src/camera.c
++++ src/camera.c
+@@ -141,7 +141,7 @@ open_pipewire_camera_remote (const char *app_id,
+                              GError **error)
+ {
+   PipeWireRemote *remote;
+-  struct spa_dict_item permission_items[1];
++  struct pw_permission permission_items[2];
+   struct pw_properties *pipewire_properties;
+ 
+   pipewire_properties =
+@@ -158,12 +158,12 @@ open_pipewire_camera_remote (const char *app_id,
+    * Hide all existing and future nodes by default. PipeWire will use the
+    * permission store to set up permissions.
+    */
+-  permission_items[0].key = PW_CORE_PROXY_PERMISSIONS_DEFAULT;
+-  permission_items[0].value = "---";
++  permission_items[0] = PW_PERMISSION_INIT (PW_ID_CORE, PW_PERM_RWX);
++  permission_items[1] = PW_PERMISSION_INIT (PW_ID_ANY, 0);
+ 
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             &SPA_DICT_INIT (permission_items,
+-                                             G_N_ELEMENTS (permission_items)));
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                G_N_ELEMENTS (permission_items),
++                                permission_items);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -219,7 +219,7 @@ handle_open_pipewire_remote (XdpCamera *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
+@@ -250,29 +250,28 @@ camera_iface_init (XdpCameraIface *iface)
+ static void
+ global_added_cb (PipeWireRemote *remote,
+                  uint32_t id,
+-                 uint32_t type,
++                 const char *type,
+                  const struct spa_dict *props,
+                  gpointer user_data)
+ {
+   Camera *camera = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *media_class;
+   const struct spa_dict_item *media_role;
+ 
+-  if (type != core_type->node)
++  if (strcmp(type, PW_TYPE_INTERFACE_Node) != 0)
+     return;
+ 
+   if (!props)
+     return;
+ 
+-  media_class = spa_dict_lookup_item (props, "media.class");
++  media_class = spa_dict_lookup_item (props, PW_KEY_MEDIA_CLASS);
+   if (!media_class)
+     return;
+ 
+   if (g_strcmp0 (media_class->value, "Video/Source") != 0)
+     return;
+ 
+-  media_role = spa_dict_lookup_item (props, "media.role");
++  media_role = spa_dict_lookup_item (props, PW_KEY_MEDIA_ROLE);
+   if (!media_role)
+     return;
+ 
+@@ -342,6 +341,7 @@ create_pipewire_remote (Camera *camera,
+     }
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.is_portal", "true",
++                                           "portal.monitor", "Camera",
+                                            NULL);
+   camera->pipewire_remote = pipewire_remote_new_sync (pipewire_properties,
+                                                       global_added_cb,
+diff --git src/pipewire.c src/pipewire.c
+index 793a378..162cd55 100644
+--- src/pipewire.c
++++ src/pipewire.c
+@@ -21,6 +21,7 @@
+ #include <errno.h>
+ #include <glib.h>
+ #include <pipewire/pipewire.h>
++#include <spa/utils/result.h>
+ 
+ #include "pipewire.h"
+ 
+@@ -36,27 +37,25 @@ static gboolean is_pipewire_initialized = FALSE;
+ static void
+ registry_event_global (void *user_data,
+                        uint32_t id,
+-                       uint32_t parent_id,
+                        uint32_t permissions,
+-                       uint32_t type,
++                       const char *type,
+                        uint32_t version,
+                        const struct spa_dict *props)
+ {
+   PipeWireRemote *remote = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *factory_object_type;
+   PipeWireGlobal *global;
+ 
+   global = g_new0 (PipeWireGlobal, 1);
+   *global = (PipeWireGlobal) {
+-    .parent_id = parent_id,
++    .parent_id = id,
+   };
+ 
+   g_hash_table_insert (remote->globals, GINT_TO_POINTER (id), global);
+   if (remote->global_added_cb)
+     remote->global_added_cb (remote, id, type, props, remote->user_data);
+ 
+-  if (type != core_type->factory)
++  if (strcmp(type, PW_TYPE_INTERFACE_Factory) != 0)
+     return;
+ 
+   factory_object_type = spa_dict_lookup_item (props, "factory.type.name");
+@@ -81,8 +80,8 @@ registry_event_global_remove (void *user_data,
+   g_hash_table_remove (remote->globals, GINT_TO_POINTER (id));
+ }
+ 
+-static const struct pw_registry_proxy_events registry_events = {
+-  PW_VERSION_REGISTRY_PROXY_EVENTS,
++static const struct pw_registry_events registry_events = {
++  PW_VERSION_REGISTRY_EVENTS,
+   .global = registry_event_global,
+   .global_remove = registry_event_global_remove,
+ };
+@@ -90,7 +89,7 @@ static const struct pw_registry_proxy_events registry_events = {
+ void
+ pipewire_remote_roundtrip (PipeWireRemote *remote)
+ {
+-  pw_core_proxy_sync (remote->core_proxy, ++remote->sync_seq);
++  remote->sync_seq = pw_core_sync (remote->core, PW_ID_CORE, remote->sync_seq);
+   pw_main_loop_run (remote->loop);
+ }
+ 
+@@ -98,16 +97,13 @@ static gboolean
+ discover_node_factory_sync (PipeWireRemote *remote,
+                             GError **error)
+ {
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+-  struct pw_registry_proxy *registry_proxy;
++  struct pw_registry *registry;
+ 
+-  registry_proxy = pw_core_proxy_get_registry (remote->core_proxy,
+-                                               core_type->registry,
+-                                               PW_VERSION_REGISTRY, 0);
+-  pw_registry_proxy_add_listener (registry_proxy,
+-                                  &remote->registry_listener,
+-                                  &registry_events,
+-                                  remote);
++  registry = pw_core_get_registry (remote->core, PW_VERSION_REGISTRY, 0);
++  pw_registry_add_listener (registry,
++                            &remote->registry_listener,
++                            &registry_events,
++                            remote);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -122,59 +118,35 @@ discover_node_factory_sync (PipeWireRemote *remote,
+ }
+ 
+ static void
+-on_state_changed (void *user_data,
+-                  enum pw_remote_state old,
+-                  enum pw_remote_state state,
+-                  const char *error)
++core_event_error (void       *user_data,
++                  uint32_t    id,
++		  int         seq,
++		  int         res,
++		  const char *message)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  switch (state)
++  if (id == PW_ID_CORE)
+     {
+-    case PW_REMOTE_STATE_ERROR:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "%s", error);
+-        }
++      g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
++                 "%s", message);
+       pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "Disconnected");
+-        }
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    default:
+-      g_warning ("Unknown PipeWire state");
+-      break;
+     }
+ }
+ 
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
+-};
+-
+ static void
+ core_event_done (void *user_data,
+-                 uint32_t seq)
++                 uint32_t id, int seq)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  if (remote->sync_seq == seq)
++  if (id == PW_ID_CORE && remote->sync_seq == seq)
+     pw_main_loop_quit (remote->loop);
+ }
+ 
+-static const struct pw_core_proxy_events core_events = {
+-  PW_VERSION_CORE_PROXY_EVENTS,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = core_event_error,
+   .done = core_event_done,
+ };
+ 
+@@ -237,8 +209,8 @@ void
+ pipewire_remote_destroy (PipeWireRemote *remote)
+ {
+   g_clear_pointer (&remote->globals, g_hash_table_destroy);
+-  g_clear_pointer (&remote->remote, pw_remote_destroy);
+-  g_clear_pointer (&remote->core, pw_core_destroy);
++  g_clear_pointer (&remote->core, pw_core_disconnect);
++  g_clear_pointer (&remote->context, pw_context_destroy);
+   g_clear_pointer (&remote->loop, pw_main_loop_destroy);
+   g_clear_error (&remote->error);
+ 
+@@ -307,68 +279,31 @@ pipewire_remote_new_sync (struct pw_properties *pipewire_properties,
+       return NULL;
+     }
+ 
+-  remote->core = pw_core_new (pw_main_loop_get_loop (remote->loop), NULL);
+-  if (!remote->core)
++  remote->context = pw_context_new (pw_main_loop_get_loop (remote->loop), NULL, 0);
++  if (!remote->context)
+     {
+       pipewire_remote_destroy (remote);
+       pw_properties_free (pipewire_properties);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire core");
++                   "Couldn't create PipeWire context");
+       return NULL;
+     }
+ 
+-  remote->remote = pw_remote_new (remote->core, pipewire_properties, 0);
+-  if (!remote->remote)
++  remote->core = pw_context_connect (remote->context, pipewire_properties, 0);
++  if (!remote->core)
+     {
+       pipewire_remote_destroy (remote);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire remote");
++                   "Couldn't connect to PipeWire");
+       return NULL;
+     }
+ 
+   remote->globals = g_hash_table_new_full (NULL, NULL, NULL, g_free);
+ 
+-  pw_remote_add_listener (remote->remote,
+-                          &remote->remote_listener,
+-                          &remote_events,
+-                          remote);
+-
+-  if (pw_remote_connect (remote->remote) != 0)
+-    {
+-      pipewire_remote_destroy (remote);
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect PipeWire remote");
+-      return NULL;
+-    }
+-
+-  pw_main_loop_run (remote->loop);
+-
+-  switch (pw_remote_get_state (remote->remote, NULL))
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      *error = g_steal_pointer (&remote->error);
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "PipeWire loop stopped unexpectedly");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      break;
+-    default:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Unexpected PipeWire state");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    }
+-
+-  remote->core_proxy = pw_remote_get_core_proxy (remote->remote);
+-  pw_core_proxy_add_listener (remote->core_proxy,
+-                              &remote->core_listener,
+-                              &core_events,
+-                              remote);
++  pw_core_add_listener (remote->core,
++                        &remote->core_listener,
++                        &core_events,
++                        remote);
+ 
+   if (!discover_node_factory_sync (remote, error))
+     {
+diff --git src/pipewire.h src/pipewire.h
+index 0f1bf54..bf48d5e 100644
+--- src/pipewire.h
++++ src/pipewire.h
+@@ -32,7 +32,7 @@ typedef struct _PipeWireGlobal
+ 
+ typedef void (* PipeWireGlobalAddedCallback) (PipeWireRemote *remote,
+                                               uint32_t id,
+-                                              uint32_t type,
++                                              const char *type,
+                                               const struct spa_dict *props,
+                                               gpointer user_data);
+ 
+@@ -43,13 +43,11 @@ typedef void (* PipeWireGlobalRemovedCallback) (PipeWireRemote *remote,
+ struct _PipeWireRemote
+ {
+   struct pw_main_loop *loop;
++  struct pw_context *context;
+   struct pw_core *core;
+-  struct pw_remote *remote;
+-  struct spa_hook remote_listener;
+-
+-  struct pw_core_proxy *core_proxy;
+   struct spa_hook core_listener;
+-  uint32_t sync_seq;
++
++  int sync_seq;
+ 
+   struct spa_hook registry_listener;
+ 
+diff --git src/screen-cast.c src/screen-cast.c
+index 7881ddc..1677050 100644
+--- src/screen-cast.c
++++ src/screen-cast.c
+@@ -31,10 +31,10 @@
+ #include "xdp-impl-dbus.h"
+ #include "xdp-utils.h"
+ 
+-#define PERMISSION_ITEM(item_key, item_value) \
+-  ((struct spa_dict_item) { \
+-    .key = item_key, \
+-    .value = item_value \
++#define PERMISSION_ITEM(item_id, item_permissions) \
++  ((struct pw_permission) { \
++    .id = item_id, \
++    .permissions = item_permissions \
+   })
+ 
+ typedef struct _ScreenCast ScreenCast;
+@@ -517,42 +517,9 @@ screen_cast_stream_get_pipewire_node_id (ScreenCastStream *stream)
+   return stream->id;
+ }
+ 
+-static void
+-append_parent_permissions (PipeWireRemote *remote,
+-                           GArray *permission_items,
+-                           GList **string_stash,
+-                           PipeWireGlobal *global,
+-                           const char *permission)
+-{
+-  PipeWireGlobal *parent;
+-  char *parent_permission_value;
+-
+-  if (global->parent_id == 0)
+-    return;
+-
+-  parent = g_hash_table_lookup (remote->globals, GINT_TO_POINTER (global->parent_id));
+-
+-  if (parent->permission_set)
+-    return;
+-  parent->permission_set = TRUE;
+-
+-  append_parent_permissions (remote, permission_items, string_stash,
+-                             parent, permission);
+-
+-  parent_permission_value = g_strdup_printf ("%u:%s",
+-                                             global->parent_id,
+-                                             permission);
+-  *string_stash = g_list_prepend (*string_stash, parent_permission_value);
+-
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       parent_permission_value));
+-}
+-
+ static void
+ append_stream_permissions (PipeWireRemote *remote,
+                            GArray *permission_items,
+-                           GList **string_stash,
+                            GList *streams)
+ {
+   GList *l;
+@@ -561,21 +528,10 @@ append_stream_permissions (PipeWireRemote *remote,
+     {
+       ScreenCastStream *stream = l->data;
+       uint32_t stream_id;
+-      PipeWireGlobal *stream_global;
+-      char *stream_permission_value;
+ 
+       stream_id = screen_cast_stream_get_pipewire_node_id (stream);
+-      stream_global = g_hash_table_lookup (remote->globals,
+-                                           GINT_TO_POINTER (stream_id));
+-
+-      append_parent_permissions (remote, permission_items, string_stash,
+-                                 stream_global, "r--");
+-
+-      stream_permission_value = g_strdup_printf ("%u:rwx", stream_id);
+-      *string_stash = g_list_prepend (*string_stash, stream_permission_value);
+       g_array_append_val (permission_items,
+-                          PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                           stream_permission_value));
++                          PERMISSION_ITEM (stream_id, PW_PERM_RWX));
+     }
+ }
+ 
+@@ -587,9 +543,6 @@ open_pipewire_screen_cast_remote (const char *app_id,
+   struct pw_properties *pipewire_properties;
+   PipeWireRemote *remote;
+   g_autoptr(GArray) permission_items = NULL;
+-  char *node_factory_permission_string;
+-  GList *string_stash = NULL;
+-  struct spa_dict *permission_dict;
+   PipeWireGlobal *node_global;
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.app_id", app_id,
+@@ -603,48 +556,31 @@ open_pipewire_screen_cast_remote (const char *app_id,
+ 
+   permission_items = g_array_new (FALSE, TRUE, sizeof (struct spa_dict_item));
+ 
+-  /*
+-   * Hide all existing and future nodes (except the ones we explicitly list below.
+-   */
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_EXISTING,
+-                                       "---"));
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_DEFAULT,
+-                                       "---"));
+-
+   /*
+    * PipeWire:Interface:Core
+    * Needs rwx to be able create the sink node using the create-object method
+    */
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       "0:rwx"));
++                      PERMISSION_ITEM (PW_ID_CORE, PW_PERM_RWX));
+ 
+   /*
+    * PipeWire:Interface:NodeFactory
+    * Needs r-- so it can be passed to create-object when creating the sink node.
+    */
+-  node_factory_permission_string = g_strdup_printf ("%d:r--",
+-                                                    remote->node_factory_id);
+-  string_stash = g_list_prepend (string_stash, node_factory_permission_string);
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       node_factory_permission_string));
+-  node_global = g_hash_table_lookup (remote->globals,
+-                                     GINT_TO_POINTER (remote->node_factory_id));
+-  append_parent_permissions (remote, permission_items, &string_stash,
+-                             node_global, "r--");
++                      PERMISSION_ITEM (remote->node_factory_id, PW_PERM_R));
+ 
+-  append_stream_permissions (remote, permission_items, &string_stash, streams);
++  append_stream_permissions (remote, permission_items, streams);
+ 
+-  permission_dict =
+-    &SPA_DICT_INIT ((struct spa_dict_item *) permission_items->data,
+-                    permission_items->len);
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             permission_dict);
++  /*
++   * Hide all existing and future nodes (except the ones we explicitly list above).
++   */
++  g_array_append_val (permission_items,
++                      PERMISSION_ITEM (PW_ID_ANY, 0));
+ 
+-  g_list_free_full (string_stash, g_free);
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                permission_items->len,
++                                (const struct pw_permission *)permission_items->data);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -943,7 +879,7 @@ handle_open_pipewire_remote (XdpScreenCast *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
diff --git a/srcpkgs/xdg-desktop-portal/template b/srcpkgs/xdg-desktop-portal/template
index eb8a4602f5d..1136b6a6e0e 100644
--- a/srcpkgs/xdg-desktop-portal/template
+++ b/srcpkgs/xdg-desktop-portal/template
@@ -1,10 +1,10 @@
 # Template file for 'xdg-desktop-portal'
 pkgname=xdg-desktop-portal
 version=1.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-pipewire --enable-geoclue --disable-libportal"
-hostmakedepends="pkg-config glib-devel"
+hostmakedepends="automake libtool gettext-devel pkg-config glib-devel"
 makedepends="flatpak-devel fuse-devel pipewire-devel geoclue2-devel"
 short_desc="Portal frontend service for Flatpak"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -13,6 +13,10 @@ homepage="https://github.com/flatpak/xdg-desktop-portal"
 distfiles="https://github.com/flatpak/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.xz"
 checksum=883c9c9a925e48af54812b5347f546dd776ec2e27076a83d5a8126af6bafb9da
 
+pre_configure() {
+	autoreconf -vfi
+}
+
 post_install() {
 	rm -rf "${DESTDIR}/usr/lib/systemd"
 }

From cb24ab8ad4e7cb40fe6d6d5469c924a323e354e2 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Thu, 30 Apr 2020 06:17:17 +0900
Subject: [PATCH 4/4] mutter: rebuild for pipewire-0.3

---
 srcpkgs/mutter/patches/pipewire-0.3.patch | 521 ++++++++++++++++++++++
 srcpkgs/mutter/template                   |   2 +-
 2 files changed, 522 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/mutter/patches/pipewire-0.3.patch

diff --git a/srcpkgs/mutter/patches/pipewire-0.3.patch b/srcpkgs/mutter/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..ebff65fba85
--- /dev/null
+++ b/srcpkgs/mutter/patches/pipewire-0.3.patch
@@ -0,0 +1,521 @@
+Build mutter against pipewire-0.3, based on a patch at:
+https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1062
+--- meson.build
++++ meson.build
+@@ -50,7 +50,7 @@ libinput_req = '>= 1.7'
+ gbm_req = '>= 10.3'
+
+ # screen cast version requirements
+-libpipewire_req = '>= 0.2.5'
++libpipewire_req = '>= 0.3.0'
+
+ gnome = import('gnome')
+ pkg = import('pkgconfig')
+@@ -241,7 +241,7 @@ endif
+
+ have_remote_desktop = get_option('remote_desktop')
+ if have_remote_desktop
+-  libpipewire_dep = dependency('libpipewire-0.2', version: libpipewire_req)
++  libpipewire_dep = dependency('libpipewire-0.3', version: libpipewire_req)
+ endif
+
+ have_introspection = get_option('introspection')
+diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
+index 82c5cba436..ba1ce94a7e 100644
+--- src/backends/meta-screen-cast-stream-src.c
++++ src/backends/meta-screen-cast-stream-src.c
+@@ -29,6 +29,7 @@
+ #include <spa/param/props.h>
+ #include <spa/param/format-utils.h>
+ #include <spa/param/video/format-utils.h>
++#include <spa/utils/result.h>
+ #include <stdint.h>
+ #include <sys/mman.h>
+
+@@ -62,15 +63,6 @@ enum
+
+ static guint signals[N_SIGNALS];
+
+-typedef struct _MetaSpaType
+-{
+-  struct spa_type_media_type media_type;
+-  struct spa_type_media_subtype media_subtype;
+-  struct spa_type_format_video format_video;
+-  struct spa_type_video_format video_format;
+-  uint32_t meta_cursor;
+-} MetaSpaType;
+-
+ typedef struct _MetaPipeWireSource
+ {
+   GSource base;
+@@ -82,19 +74,19 @@ typedef struct _MetaScreenCastStreamSrcPrivate
+ {
+   MetaScreenCastStream *stream;
+
++  struct pw_context *pipewire_context;
+   struct pw_core *pipewire_core;
+-  struct pw_remote *pipewire_remote;
+-  struct pw_type *pipewire_type;
+   MetaPipeWireSource *pipewire_source;
+-  struct spa_hook pipewire_remote_listener;
++  struct spa_hook pipewire_core_listener;
+
+   gboolean is_enabled;
+
+   struct pw_stream *pipewire_stream;
+   struct spa_hook pipewire_stream_listener;
++  uint32_t node_id;
+
+-  MetaSpaType spa_type;
+   struct spa_video_info_raw video_format;
++  int video_stride;
+
+   uint64_t last_frame_timestamp_us;
+
+@@ -112,8 +104,6 @@ G_DEFINE_TYPE_WITH_CODE (MetaScreenCastStreamSrc,
+                                                 meta_screen_cast_stream_src_init_initable_iface)
+                          G_ADD_PRIVATE (MetaScreenCastStreamSrc))
+
+-#define PROP_RANGE(min, max) 2, (min), (max)
+-
+ static void
+ meta_screen_cast_stream_src_get_specs (MetaScreenCastStreamSrc *src,
+                                        int                     *width,
+@@ -286,9 +276,6 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+                                                               int                      x,
+                                                               int                      y)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+
+   spa_meta_cursor->id = 1;
+@@ -300,7 +287,7 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   spa_meta_cursor->hotspot.x = 0;
+@@ -317,9 +304,6 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+                                                         int                      y,
+                                                         float                    scale)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   CoglTexture *cursor_texture;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+   int hotspot_x, hotspot_y;
+@@ -346,7 +330,7 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
+@@ -382,12 +366,10 @@ static void
+ add_cursor_metadata (MetaScreenCastStreamSrc *src,
+                      struct spa_buffer       *spa_buffer)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_cursor *spa_meta_cursor;
+
+-  spa_meta_cursor = spa_buffer_find_meta (spa_buffer, spa_type->meta_cursor);
++  spa_meta_cursor = spa_buffer_find_meta_data (spa_buffer, SPA_META_Cursor,
++                                               sizeof (*spa_meta_cursor));
+   if (spa_meta_cursor)
+     meta_screen_cast_stream_src_set_cursor_metadata (src, spa_meta_cursor);
+ }
+@@ -447,14 +429,14 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+     {
+       data = spa_buffer->datas[0].data;
+     }
+-  else if (spa_buffer->datas[0].type == priv->pipewire_type->data.MemFd)
++  else if (spa_buffer->datas[0].type == SPA_DATA_MemFd)
+     {
+       map = mmap (NULL, spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset,
+                   PROT_READ | PROT_WRITE, MAP_SHARED,
+                   spa_buffer->datas[0].fd, 0);
+       if (map == MAP_FAILED)
+         {
+-          g_warning ("Failed to mmap pipewire stream buffer: %s\n",
++          g_warning ("Failed to mmap pipewire stream buffer: %s",
+                      strerror (errno));
+           return;
+         }
+@@ -469,28 +451,30 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+
+   if (meta_screen_cast_stream_src_record_frame (src, data))
+     {
+-      struct spa_meta_video_crop *spa_meta_video_crop;
++      struct spa_meta_region *spa_meta_video_crop;
+
+       spa_buffer->datas[0].chunk->size = spa_buffer->datas[0].maxsize;
++      spa_buffer->datas[0].chunk->stride = priv->video_stride;
+
+       /* Update VideoCrop if needed */
+       spa_meta_video_crop =
+-        spa_buffer_find_meta (spa_buffer, priv->pipewire_type->meta.VideoCrop);
++        spa_buffer_find_meta_data (spa_buffer, SPA_META_VideoCrop,
++                                   sizeof (*spa_meta_video_crop));
+       if (spa_meta_video_crop)
+         {
+           if (meta_screen_cast_stream_src_get_videocrop (src, &crop_rect))
+             {
+-              spa_meta_video_crop->x = crop_rect.x;
+-              spa_meta_video_crop->y = crop_rect.y;
+-              spa_meta_video_crop->width = crop_rect.width;
+-              spa_meta_video_crop->height = crop_rect.height;
++              spa_meta_video_crop->region.position.x = crop_rect.x;
++              spa_meta_video_crop->region.position.y = crop_rect.y;
++              spa_meta_video_crop->region.size.width = crop_rect.width;
++              spa_meta_video_crop->region.size.height = crop_rect.height;
+             }
+           else
+             {
+-              spa_meta_video_crop->x = 0;
+-              spa_meta_video_crop->y = 0;
+-              spa_meta_video_crop->width = priv->stream_width;
+-              spa_meta_video_crop->height = priv->stream_height;
++              spa_meta_video_crop->region.position.x = 0;
++              spa_meta_video_crop->region.position.y = 0;
++              spa_meta_video_crop->region.size.width = priv->stream_width;
++              spa_meta_video_crop->region.size.height = priv->stream_height;
+             }
+         }
+     }
+@@ -555,7 +539,6 @@ on_stream_state_changed (void                 *data,
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  uint32_t node_id;
+
+   switch (state)
+     {
+@@ -563,14 +546,12 @@ on_stream_state_changed (void                 *data,
+       g_warning ("pipewire stream error: %s", error_message);
+       meta_screen_cast_stream_src_notify_closed (src);
+       break;
+-    case PW_STREAM_STATE_CONFIGURE:
+-      node_id = pw_stream_get_node_id (priv->pipewire_stream);
+-      g_signal_emit (src, signals[READY], 0, (unsigned int) node_id);
+-      break;
+-    case PW_STREAM_STATE_UNCONNECTED:
+-    case PW_STREAM_STATE_CONNECTING:
+-    case PW_STREAM_STATE_READY:
+     case PW_STREAM_STATE_PAUSED:
++      if (priv->node_id == SPA_ID_INVALID && priv->pipewire_stream)
++        {
++          priv->node_id = pw_stream_get_node_id (priv->pipewire_stream);
++          g_signal_emit (src, signals[READY], 0, (unsigned int) priv->node_id);
++        }
+       if (meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_disable (src);
+       break;
+@@ -578,68 +559,69 @@ on_stream_state_changed (void                 *data,
+       if (!meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_enable (src);
+       break;
++    case PW_STREAM_STATE_UNCONNECTED:
++    case PW_STREAM_STATE_CONNECTING:
++      break;
+     }
+ }
+
+ static void
+-on_stream_format_changed (void                 *data,
+-                          const struct spa_pod *format)
++on_stream_param_changed (void                 *data,
++                         uint32_t              id,
++                         const struct spa_pod *format)
+ {
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   uint8_t params_buffer[1024];
+   int32_t width, height, stride, size;
+   struct spa_pod_builder pod_builder;
+   const struct spa_pod *params[3];
+   const int bpp = 4;
+
+-  if (!format)
+-    {
+-      pw_stream_finish_format (priv->pipewire_stream, 0, NULL, 0);
+-      return;
+-    }
++  if (!format || id != SPA_PARAM_Format)
++    return;
+
+   spa_format_video_raw_parse (format,
+-                              &priv->video_format,
+-                              &priv->spa_type.format_video);
++                              &priv->video_format);
+
+   width = priv->video_format.size.width;
+   height = priv->video_format.size.height;
+   stride = SPA_ROUND_UP_N (width * bpp, 4);
+   size = height * stride;
+
++  priv->video_stride = stride;
++
+   pod_builder = SPA_POD_BUILDER_INIT (params_buffer, sizeof (params_buffer));
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idBuffers, pipewire_type->param_buffers.Buffers,
+-    ":", pipewire_type->param_buffers.size, "i", size,
+-    ":", pipewire_type->param_buffers.stride, "i", stride,
+-    ":", pipewire_type->param_buffers.buffers, "iru", 16, PROP_RANGE (2, 16),
+-    ":", pipewire_type->param_buffers.align, "i", 16);
+-
+-  params[1] = spa_pod_builder_object (
++    SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
++    SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int (16, 2, 16),
++    SPA_PARAM_BUFFERS_blocks, SPA_POD_Int (1),
++    SPA_PARAM_BUFFERS_size, SPA_POD_Int (size),
++    SPA_PARAM_BUFFERS_stride, SPA_POD_Int (stride),
++    SPA_PARAM_BUFFERS_align, SPA_POD_Int (16));
++
++  params[1] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", pipewire_type->meta.VideoCrop,
+-    ":", pipewire_type->param_meta.size, "i", sizeof (struct spa_meta_video_crop));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_VideoCrop),
++    SPA_PARAM_META_size, SPA_POD_Int (sizeof (struct spa_meta_region)));
+
+-  params[2] = spa_pod_builder_object (
++  params[2] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", priv->spa_type.meta_cursor,
+-    ":", pipewire_type->param_meta.size, "i", CURSOR_META_SIZE (64, 64));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_Cursor),
++    SPA_PARAM_META_size, SPA_POD_Int (CURSOR_META_SIZE (64, 64)));
+
+-  pw_stream_finish_format (priv->pipewire_stream, 0,
+-                           params, G_N_ELEMENTS (params));
++  pw_stream_update_params (priv->pipewire_stream, params, G_N_ELEMENTS (params));
+ }
+
+ static const struct pw_stream_events stream_events = {
+   PW_VERSION_STREAM_EVENTS,
+   .state_changed = on_stream_state_changed,
+-  .format_changed = on_stream_format_changed,
++  .param_changed = on_stream_param_changed,
+ };
+
+ static struct pw_stream *
+@@ -652,8 +634,6 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   uint8_t buffer[1024];
+   struct spa_pod_builder pod_builder =
+     SPA_POD_BUILDER_INIT (buffer, sizeof (buffer));
+-  MetaSpaType *spa_type = &priv->spa_type;
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   float frame_rate;
+   MetaFraction frame_rate_fraction;
+   struct spa_fraction max_framerate;
+@@ -661,7 +641,9 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   const struct spa_pod *params[1];
+   int result;
+
+-  pipewire_stream = pw_stream_new (priv->pipewire_remote,
++  priv->node_id = SPA_ID_INVALID;
++
++  pipewire_stream = pw_stream_new (priv->pipewire_core,
+                                    "meta-screen-cast-src",
+                                    NULL);
+   if (!pipewire_stream)
+@@ -682,17 +664,17 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   max_framerate = SPA_FRACTION (frame_rate_fraction.num,
+                                 frame_rate_fraction.denom);
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idEnumFormat, pipewire_type->spa_format,
+-    "I", spa_type->media_type.video,
+-    "I", spa_type->media_subtype.raw,
+-    ":", spa_type->format_video.format, "I", spa_type->video_format.BGRx,
+-    ":", spa_type->format_video.size, "R", &SPA_RECTANGLE (priv->stream_width,
+-                                                           priv->stream_height),
+-    ":", spa_type->format_video.framerate, "F", &SPA_FRACTION (0, 1),
+-    ":", spa_type->format_video.max_framerate, "Fru", &max_framerate,
+-                                                      PROP_RANGE (&min_framerate,
++    SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
++    SPA_FORMAT_mediaType, SPA_POD_Id (SPA_MEDIA_TYPE_video),
++    SPA_FORMAT_mediaSubtype, SPA_POD_Id (SPA_MEDIA_SUBTYPE_raw),
++    SPA_FORMAT_VIDEO_format, SPA_POD_Id (SPA_VIDEO_FORMAT_BGRx),
++    SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle (&SPA_RECTANGLE (priv->stream_width,
++                                                              priv->stream_height)),
++    SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction (&SPA_FRACTION (0, 1)),
++    SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction (&max_framerate,
++                                                                  &min_framerate,
+                                                                   &max_framerate));
+
+   pw_stream_add_listener (pipewire_stream,
+@@ -702,7 +684,7 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+
+   result = pw_stream_connect (pipewire_stream,
+                               PW_DIRECTION_OUTPUT,
+-                              NULL,
++                              SPA_ID_INVALID,
+                               (PW_STREAM_FLAG_DRIVER |
+                                PW_STREAM_FLAG_MAP_BUFFERS),
+                               params, G_N_ELEMENTS (params));
+@@ -717,40 +699,18 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+ }
+
+ static void
+-on_state_changed (void                 *data,
+-                  enum pw_remote_state  old,
+-                  enum pw_remote_state  state,
+-                  const char           *error_message)
++on_core_error (void       *data,
++               uint32_t    id,
++	       int         seq,
++	       int         res,
++	       const char *message)
+ {
+   MetaScreenCastStreamSrc *src = data;
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_stream *pipewire_stream;
+-  GError *error = NULL;
+
+-  switch (state)
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-      g_warning ("pipewire remote error: %s\n", error_message);
+-      meta_screen_cast_stream_src_notify_closed (src);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pipewire_stream = create_pipewire_stream (src, &error);
+-      if (!pipewire_stream)
+-        {
+-          g_warning ("Could not create pipewire stream: %s", error->message);
+-          g_error_free (error);
+-          meta_screen_cast_stream_src_notify_closed (src);
+-        }
+-      else
+-        {
+-          priv->pipewire_stream = pipewire_stream;
+-        }
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    }
++  g_warning ("pipewire remote error: id:%u %s", id, message);
++
++  if (id == PW_ID_CORE && res == -EPIPE)
++    meta_screen_cast_stream_src_notify_closed (src);
+ }
+
+ static gboolean
+@@ -793,17 +753,6 @@ static GSourceFuncs pipewire_source_funcs =
+   pipewire_loop_source_finalize
+ };
+
+-static void
+-init_spa_type (MetaSpaType         *type,
+-               struct spa_type_map *map)
+-{
+-  spa_type_media_type_map (map, &type->media_type);
+-  spa_type_media_subtype_map (map, &type->media_subtype);
+-  spa_type_format_video_map (map, &type->format_video);
+-  spa_type_video_format_map (map, &type->video_format);
+-  type->meta_cursor = spa_type_map_get_id(map, SPA_TYPE_META__Cursor);
+-}
+-
+ static MetaPipeWireSource *
+ create_pipewire_source (void)
+ {
+@@ -829,9 +778,9 @@ create_pipewire_source (void)
+   return pipewire_source;
+ }
+
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = on_core_error,
+ };
+
+ static gboolean
+@@ -851,37 +800,31 @@ meta_screen_cast_stream_src_initable_init (GInitable     *initable,
+       return FALSE;
+     }
+
+-  priv->pipewire_core = pw_core_new (priv->pipewire_source->pipewire_loop,
+-                                     NULL);
+-  if (!priv->pipewire_core)
++  priv->pipewire_context = pw_context_new (priv->pipewire_source->pipewire_loop,
++                                           NULL, 0);
++  if (!priv->pipewire_context)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Failed to create pipewire core");
++                   "Failed to create pipewire context");
+       return FALSE;
+     }
+
+-  priv->pipewire_remote = pw_remote_new (priv->pipewire_core, NULL, 0);
+-  if (!priv->pipewire_remote)
++  priv->pipewire_core = pw_context_connect (priv->pipewire_context, NULL, 0);
++  if (!priv->pipewire_core)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't creat pipewire remote");
++                   "Couldn't connect pipewire context");
+       return FALSE;
+     }
+
+-  pw_remote_add_listener (priv->pipewire_remote,
+-                          &priv->pipewire_remote_listener,
+-                          &remote_events,
+-                          src);
++  pw_core_add_listener (priv->pipewire_core,
++                        &priv->pipewire_core_listener,
++                        &core_events,
++                        src);
+
+-  priv->pipewire_type = pw_core_get_type (priv->pipewire_core);
+-  init_spa_type (&priv->spa_type, priv->pipewire_type->map);
+-
+-  if (pw_remote_connect (priv->pipewire_remote) != 0)
+-    {
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect pipewire remote");
+-      return FALSE;
+-    }
++  priv->pipewire_stream = create_pipewire_stream (src, error);
++  if (!priv->pipewire_stream)
++    return FALSE;
+
+   return TRUE;
+ }
+@@ -912,8 +855,8 @@ meta_screen_cast_stream_src_finalize (GObject *object)
+     meta_screen_cast_stream_src_disable (src);
+
+   g_clear_pointer (&priv->pipewire_stream, pw_stream_destroy);
+-  g_clear_pointer (&priv->pipewire_remote, pw_remote_destroy);
+-  g_clear_pointer (&priv->pipewire_core, pw_core_destroy);
++  g_clear_pointer (&priv->pipewire_core, pw_core_disconnect);
++  g_clear_pointer (&priv->pipewire_context, pw_context_destroy);
+   g_source_destroy (&priv->pipewire_source->base);
+
+   G_OBJECT_CLASS (meta_screen_cast_stream_src_parent_class)->finalize (object);
diff --git a/srcpkgs/mutter/template b/srcpkgs/mutter/template
index 4e0bd32b67d..806a3bef9f0 100644
--- a/srcpkgs/mutter/template
+++ b/srcpkgs/mutter/template
@@ -1,7 +1,7 @@
 # Template file for 'mutter'
 pkgname=mutter
 version=3.34.1
-revision=2
+revision=3
 build_helper="gir"
 build_style=meson
 configure_args="-Degl_device=true -Dudev=true -Dnative_backend=true

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PR PATCH] [Updated] WIP: pipewire: update to 0.3.4
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (33 preceding siblings ...)
  2020-05-07 18:27 ` sirn
@ 2020-05-09 15:10 ` sirn
  2020-05-09 15:22 ` sirn
                   ` (16 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-05-09 15:10 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 790 bytes --]

There is an updated pull request by sirn against master on the void-packages repository

https://github.com/sirn/void-packages pipewire-update
https://github.com/void-linux/void-packages/pull/20413

WIP: pipewire: update to 0.3.4
This PR updates `pipewire` to 0.3.4 and also updating/patching all packages that depends on it. 

* `xdg-desktop-portal` includes a patch backported from 1.7.0 to allow 1.6.0 to build against pipewire-0.3 (1.7.x is prerelease)
* `xdg-desktop-portal-kde` already includes Pipewire 0.3 support and only requires revbump.
* `mutter` includes a patch backported from 3.35 to allow 3.34 to build against pipewire-0.3 (upgrading to >=3.35 also requires upgrading GNOME).

A patch file from https://github.com/void-linux/void-packages/pull/20413.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pipewire-update-20413.patch --]
[-- Type: text/x-diff, Size: 55493 bytes --]

From f317d0685aff2fb60b0398f236bf0cb0f3b3c96c Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:23:52 +0900
Subject: [PATCH 1/4] pipewire: update to 0.3.4

---
 common/shlibs                                 |  2 +-
 srcpkgs/alsa-pipewire                         |  1 +
 srcpkgs/libjack-pipewire                      |  1 +
 srcpkgs/libpulseaudio-pipewire                |  1 +
 .../patches/01-fix-format-warning.patch       | 37 ++++++++++
 .../patches/02-fix-spa_log_func-musl.patch    | 25 +++++++
 .../patches/03-fix-neon-compilation.patch     | 58 +++++++++++++++
 srcpkgs/pipewire/template                     | 71 ++++++++++++++-----
 8 files changed, 178 insertions(+), 18 deletions(-)
 create mode 120000 srcpkgs/alsa-pipewire
 create mode 120000 srcpkgs/libjack-pipewire
 create mode 120000 srcpkgs/libpulseaudio-pipewire
 create mode 100644 srcpkgs/pipewire/patches/01-fix-format-warning.patch
 create mode 100644 srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch
 create mode 100644 srcpkgs/pipewire/patches/03-fix-neon-compilation.patch

diff --git a/common/shlibs b/common/shlibs
index 8342e117092..15227d2035a 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3204,7 +3204,7 @@ libarcan_shmif_ext.so.0.11 arcan-0.5.4.3_1
 libarcan_shmif_server.so.0.11 arcan-0.5.4.3_1
 libarcan_tui.so.0.11 arcan-0.5.4.3_1
 liblwipv6.so.2 lwipv6-1.5a_1
-libpipewire-0.2.so.1 libpipewire-0.2.2_1
+libpipewire-0.3.so.0 libpipewire-0.3.4_1
 libvolk.so.2.2.1 volk-2.2.1_1
 libgnuradio-runtime.so.3.8.0 gnuradio-3.8.0.0_1
 libgnuradio-pmt.so.3.8.0 gnuradio-3.8.0.0_1
diff --git a/srcpkgs/alsa-pipewire b/srcpkgs/alsa-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/alsa-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libjack-pipewire b/srcpkgs/libjack-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libjack-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libpulseaudio-pipewire b/srcpkgs/libpulseaudio-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libpulseaudio-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/pipewire/patches/01-fix-format-warning.patch b/srcpkgs/pipewire/patches/01-fix-format-warning.patch
new file mode 100644
index 00000000000..b4e8748390e
--- /dev/null
+++ b/srcpkgs/pipewire/patches/01-fix-format-warning.patch
@@ -0,0 +1,37 @@
+From 979a81a70d468d6482773521b89aaf67ce79b921 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Fri, 1 May 2020 11:05:38 +0200
+Subject: [PATCH] meson: add -Wformat
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+cc1: warning: ‘-Wformat-security’ ignored without ‘-Wformat’ [-Wformat-security]
+
+Fixes #234
+---
+ meson.build | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/meson.build b/meson.build
+index 74142587..1631e763 100644
+--- meson.build
++++ meson.build
+@@ -51,6 +51,7 @@ if cc.get_id() == 'gcc'
+ 			'-Wsign-compare',
+ 			'-Wimplicit-fallthrough',
+ 			'-Wpointer-arith',
++			'-Wformat',
+ 			'-Wformat-security',
+ 			'-Werror=suggest-attribute=format',
+ 			'-Wmissing-braces',
+@@ -68,6 +69,7 @@ if cc.get_id() == 'gcc'
+ 			'-Wsign-compare',
+ 			'-Wimplicit-fallthrough',
+ 			'-Wpointer-arith',
++			'-Wformat',
+ 			'-Wformat-security',
+ 			'-Werror=suggest-attribute=format',
+ 			'-Wmissing-braces',
+--
+2.26.2
diff --git a/srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch b/srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch
new file mode 100644
index 00000000000..b816975a6eb
--- /dev/null
+++ b/srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch
@@ -0,0 +1,25 @@
+From e83bf8a33f720050c7f1ec5f00530fafd5af5698 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Fri, 1 May 2020 11:18:28 +0200
+Subject: [PATCH] log: use printf attribute for log fallback
+
+Fixes #233
+---
+ spa/include/spa/support/log.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/spa/include/spa/support/log.h b/spa/include/spa/support/log.h
+index c97cc8e5..51b3e741 100644
+--- spa/include/spa/support/log.h
++++ spa/include/spa/support/log.h
+@@ -139,7 +139,7 @@ struct spa_log_methods {
+ #else
+
+ #define SPA_LOG_FUNC(name,lev)							\
+-static inline void spa_log_##name (struct spa_log *l, const char *format, ...)  \
++static inline SPA_PRINTF_FUNC(2,3) void spa_log_##name (struct spa_log *l, const char *format, ...)  \
+ {										\
+ 	if (SPA_UNLIKELY(spa_log_level_enabled(l, lev))) {			\
+ 		va_list varargs;						\
+--
+2.26.2
diff --git a/srcpkgs/pipewire/patches/03-fix-neon-compilation.patch b/srcpkgs/pipewire/patches/03-fix-neon-compilation.patch
new file mode 100644
index 00000000000..28d9f05b754
--- /dev/null
+++ b/srcpkgs/pipewire/patches/03-fix-neon-compilation.patch
@@ -0,0 +1,58 @@
+From 011992e774fcb58966f567099f03943c57e66c2b Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Fri, 8 May 2020 22:12:24 +0200
+Subject: [PATCH] meson: try to compile a little NEON program to be sure
+
+Fixes #235
+---
+ meson.build | 34 ++++++++++++++++++++++++++++++----
+ 1 file changed, 30 insertions(+), 4 deletions(-)
+
+diff --git a/meson.build b/meson.build
+index 17864da0..5a49c124 100644
+--- meson.build
++++ meson.build
+@@ -100,11 +100,37 @@ have_avx2 = cc.has_argument(avx2_args)
+
+ have_neon = false
+ if host_machine.cpu_family() == 'aarch64'
+-  neon_args = []
+-  have_neon = true
++  if cc.compiles('''
++    #include <arm_neon.h>
++    int main () {
++      float *s;
++      asm volatile(
++	"      ld1 { v0.4s }, [%[s]], #16\n"
++        "      fcvtzs v0.4s, v0.4s, #31\n"
++	: [s] "+r" (s) : :);
++    }
++    ''',
++    name : 'aarch64 Neon Support')
++      neon_args = []
++      have_neon = true
++
++  endif
+ elif cc.has_argument('-mfpu=neon')
+-  neon_args = ['-mfpu=neon']
+-  have_neon = true
++  if cc.compiles('''
++    #include <arm_neon.h>
++    int main () {
++      float *s;
++      asm volatile(
++        "      vld1.32 { q0 }, [%[s]]!\n"
++        "      vcvt.s32.f32 q0, q0, #31\n"
++	: [s] "+r" (s) : :);
++    }
++    ''',
++    args: '-mfpu=neon',
++    name : 'arm Neon Support')
++      neon_args = ['-mfpu=neon']
++      have_neon = true
++  endif
+ endif
+
+
+--
+2.26.2
diff --git a/srcpkgs/pipewire/template b/srcpkgs/pipewire/template
index 7f646dad11d..763b7f9b365 100644
--- a/srcpkgs/pipewire/template
+++ b/srcpkgs/pipewire/template
@@ -1,26 +1,37 @@
 # Template file for 'pipewire'
 pkgname=pipewire
-version=0.2.7
+version=0.3.4
 revision=1
 build_style=meson
-configure_args="-Dman=true -Dgstreamer=enabled -Ddocs=true -Dsystemd=false"
+configure_args="-Dman=true -Dgstreamer=true -Ddocs=true -Dsystemd=false
+ -Dbluez5=true -Dffmpeg=true -Dpipewire-alsa=true -Dpipewire-jack=true
+ -Dpipewire-pulseaudio=true"
 hostmakedepends="doxygen graphviz pkg-config xmltoman"
 makedepends="SDL2-devel ffmpeg-devel gst-plugins-base1-devel jack-devel
- sbc-devel v4l-utils-devel libva-devel"
+ sbc-devel v4l-utils-devel libva-devel libbluetooth-devel"
 short_desc="Server and user space API to deal with multimedia pipelines"
-maintainer="Orphaned <orphan@voidlinux.org>"
-#Next release will probably change to MIT, currently listed in master
-license="LGPL-2.1-only, GPL-2.0-only "
+maintainer="Kridsada Thanabulpong <sirn@ogsite.net>"
+license="MIT"
 homepage="https://pipewire.org/"
-changelog="https://raw.githubusercontent.com/PipeWire/pipewire/master/NEWS"
-distfiles="https://github.com/PipeWire/pipewire/archive/${version}.tar.gz"
-checksum=bfaa0f6ae6c0791e2e0b59234d399753bf24f1b33dbf587682363a8463dd8df1
+changelog="https://gitlab.freedesktop.org/pipewire/pipewire/-/raw/master/NEWS"
+distfiles="https://gitlab.freedesktop.org/pipewire/pipewire/-/archive/${version}/pipewire-${version}.tar.gz"
+checksum=6a1c9c671514c84b38ce96d51823354702bc4d5dbaba12d501faa0448f892515
 conf_files="/etc/pipewire/pipewire.conf"
 
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+	LDFLAGS+=" -latomic"
+fi
+
+post_install() {
+	vlicense LICENSE
+}
+
 libpipewire_package() {
 	short_desc+=" - pipewire library"
 	pkg_install() {
-		vmove "usr/lib/libpipewire-0.2.so.*"
+		vmove "usr/lib/libpipewire-0.3.so.*"
+		vmove "usr/lib/pipewire-0.3/*.so"
 	}
 }
 
@@ -28,25 +39,25 @@ pipewire-devel_package() {
 	depends="libpipewire-${version}_${revision}"
 	short_desc+=" - pipewire and libspa development files"
 	pkg_install() {
-		vmove usr/include/pipewire
-		vmove usr/include/spa
-		vmove usr/lib/pkgconfig/libpipewire-0.2.pc
-		vmove usr/lib/pkgconfig/libspa-0.1.pc
-		vmove usr/lib/libpipewire-0.2.so
+		vmove usr/include/pipewire-0.3
+		vmove usr/include/spa-0.2
+		vmove usr/lib/pkgconfig/libpipewire-0.3.pc
+		vmove usr/lib/pkgconfig/libspa-0.2.pc
+		vmove usr/lib/libpipewire-0.3.so
 	}
 }
 
 libspa-ffmpeg_package() {
 	short_desc+=" - ffmpeg plugins"
 	pkg_install() {
-		vmove usr/lib/spa/ffmpeg
+		vmove usr/lib/spa-0.2/ffmpeg
 	}
 }
 
 libspa-bluetooth_package() {
 	short_desc+=" - bluetooth plugins"
 	pkg_install() {
-		vmove usr/lib/spa/bluez5
+		vmove usr/lib/spa-0.2/bluez5
 	}
 }
 
@@ -57,6 +68,32 @@ gstreamer1-pipewire_package() {
 	}
 }
 
+libpulseaudio-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - PulseAudio client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/pulse
+		vmove usr/bin/pw-pulse
+	}
+}
+
+alsa-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - ALSA client library"
+	pkg_install() {
+		vmove usr/lib/alsa-lib
+	}
+}
+
+libjack-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - JACK client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/jack
+		vmove usr/bin/pw-jack
+	}
+}
+
 pipewire-doc_package() {
 	archs=noarch
 	short_desc+=" - documentation"

From 59697e7db1d587b224ea8c68807fac32a0a8c15c Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:46 +0900
Subject: [PATCH 2/4] xdg-desktop-portal-kde: rebuild for pipewire-0.3

---
 srcpkgs/xdg-desktop-portal-kde/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xdg-desktop-portal-kde/template b/srcpkgs/xdg-desktop-portal-kde/template
index 7a2aaf16b96..574e28504b7 100644
--- a/srcpkgs/xdg-desktop-portal-kde/template
+++ b/srcpkgs/xdg-desktop-portal-kde/template
@@ -1,7 +1,7 @@
 # Template file for 'xdg-desktop-portal-kde'
 pkgname=xdg-desktop-portal-kde
 version=5.18.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules qt5-qmake qt5-host-tools kcoreaddons gettext"
 makedepends="glib-devel kio-devel kwayland-devel libepoxy-devel pipewire-devel

From a3636bf73bed3671e8e781d41bba868f5acc90b5 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:26 +0900
Subject: [PATCH 3/4] xdg-desktop-portal: rebuild for pipewire-0.3

---
 .../patches/pipewire-0.3.patch                | 551 ++++++++++++++++++
 srcpkgs/xdg-desktop-portal/template           |   8 +-
 2 files changed, 557 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch

diff --git a/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..94ebe083598
--- /dev/null
+++ b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
@@ -0,0 +1,551 @@
+From a38901e5e7f835efe7b7a06c55790c8c20bc91a2 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Tue, 14 Jan 2020 09:37:09 +0100
+Subject: [PATCH] PipeWire: update to 0.3 API
+
+---
+ configure.ac      |   2 +-
+ src/camera.c      |  24 ++++----
+ src/pipewire.c    | 141 +++++++++++++---------------------------------
+ src/pipewire.h    |  10 ++--
+ src/screen-cast.c |  98 ++++++--------------------------
+ 5 files changed, 72 insertions(+), 203 deletions(-)
+
+diff --git configure.ac configure.ac
+index 89902fa..62d7960 100644
+--- configure.ac
++++ configure.ac
+@@ -97,7 +97,7 @@ AC_ARG_ENABLE(pipewire,
+ 	      [AS_HELP_STRING([--enable-pipewire],[Enable PipeWire support. Needed for screen cast portal])],
+ 	      enable_pipewire=$enableval, enable_pipewire=yes)
+ if test x$enable_pipewire = xyes ; then
+-	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.2 >= 0.2.6])
++	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.3 >= 0.2.90])
+ 	AC_DEFINE([HAVE_PIPEWIRE],[1], [Define to enable PipeWire support])
+ fi
+ AM_CONDITIONAL([HAVE_PIPEWIRE],[test "$enable_pipewire" = "yes"])
+diff --git src/camera.c src/camera.c
+index c2b392c..20fe3aa 100644
+--- src/camera.c
++++ src/camera.c
+@@ -141,7 +141,7 @@ open_pipewire_camera_remote (const char *app_id,
+                              GError **error)
+ {
+   PipeWireRemote *remote;
+-  struct spa_dict_item permission_items[1];
++  struct pw_permission permission_items[2];
+   struct pw_properties *pipewire_properties;
+ 
+   pipewire_properties =
+@@ -158,12 +158,12 @@ open_pipewire_camera_remote (const char *app_id,
+    * Hide all existing and future nodes by default. PipeWire will use the
+    * permission store to set up permissions.
+    */
+-  permission_items[0].key = PW_CORE_PROXY_PERMISSIONS_DEFAULT;
+-  permission_items[0].value = "---";
++  permission_items[0] = PW_PERMISSION_INIT (PW_ID_CORE, PW_PERM_RWX);
++  permission_items[1] = PW_PERMISSION_INIT (PW_ID_ANY, 0);
+ 
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             &SPA_DICT_INIT (permission_items,
+-                                             G_N_ELEMENTS (permission_items)));
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                G_N_ELEMENTS (permission_items),
++                                permission_items);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -219,7 +219,7 @@ handle_open_pipewire_remote (XdpCamera *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
+@@ -250,29 +250,28 @@ camera_iface_init (XdpCameraIface *iface)
+ static void
+ global_added_cb (PipeWireRemote *remote,
+                  uint32_t id,
+-                 uint32_t type,
++                 const char *type,
+                  const struct spa_dict *props,
+                  gpointer user_data)
+ {
+   Camera *camera = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *media_class;
+   const struct spa_dict_item *media_role;
+ 
+-  if (type != core_type->node)
++  if (strcmp(type, PW_TYPE_INTERFACE_Node) != 0)
+     return;
+ 
+   if (!props)
+     return;
+ 
+-  media_class = spa_dict_lookup_item (props, "media.class");
++  media_class = spa_dict_lookup_item (props, PW_KEY_MEDIA_CLASS);
+   if (!media_class)
+     return;
+ 
+   if (g_strcmp0 (media_class->value, "Video/Source") != 0)
+     return;
+ 
+-  media_role = spa_dict_lookup_item (props, "media.role");
++  media_role = spa_dict_lookup_item (props, PW_KEY_MEDIA_ROLE);
+   if (!media_role)
+     return;
+ 
+@@ -342,6 +341,7 @@ create_pipewire_remote (Camera *camera,
+     }
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.is_portal", "true",
++                                           "portal.monitor", "Camera",
+                                            NULL);
+   camera->pipewire_remote = pipewire_remote_new_sync (pipewire_properties,
+                                                       global_added_cb,
+diff --git src/pipewire.c src/pipewire.c
+index 793a378..162cd55 100644
+--- src/pipewire.c
++++ src/pipewire.c
+@@ -21,6 +21,7 @@
+ #include <errno.h>
+ #include <glib.h>
+ #include <pipewire/pipewire.h>
++#include <spa/utils/result.h>
+ 
+ #include "pipewire.h"
+ 
+@@ -36,27 +37,25 @@ static gboolean is_pipewire_initialized = FALSE;
+ static void
+ registry_event_global (void *user_data,
+                        uint32_t id,
+-                       uint32_t parent_id,
+                        uint32_t permissions,
+-                       uint32_t type,
++                       const char *type,
+                        uint32_t version,
+                        const struct spa_dict *props)
+ {
+   PipeWireRemote *remote = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *factory_object_type;
+   PipeWireGlobal *global;
+ 
+   global = g_new0 (PipeWireGlobal, 1);
+   *global = (PipeWireGlobal) {
+-    .parent_id = parent_id,
++    .parent_id = id,
+   };
+ 
+   g_hash_table_insert (remote->globals, GINT_TO_POINTER (id), global);
+   if (remote->global_added_cb)
+     remote->global_added_cb (remote, id, type, props, remote->user_data);
+ 
+-  if (type != core_type->factory)
++  if (strcmp(type, PW_TYPE_INTERFACE_Factory) != 0)
+     return;
+ 
+   factory_object_type = spa_dict_lookup_item (props, "factory.type.name");
+@@ -81,8 +80,8 @@ registry_event_global_remove (void *user_data,
+   g_hash_table_remove (remote->globals, GINT_TO_POINTER (id));
+ }
+ 
+-static const struct pw_registry_proxy_events registry_events = {
+-  PW_VERSION_REGISTRY_PROXY_EVENTS,
++static const struct pw_registry_events registry_events = {
++  PW_VERSION_REGISTRY_EVENTS,
+   .global = registry_event_global,
+   .global_remove = registry_event_global_remove,
+ };
+@@ -90,7 +89,7 @@ static const struct pw_registry_proxy_events registry_events = {
+ void
+ pipewire_remote_roundtrip (PipeWireRemote *remote)
+ {
+-  pw_core_proxy_sync (remote->core_proxy, ++remote->sync_seq);
++  remote->sync_seq = pw_core_sync (remote->core, PW_ID_CORE, remote->sync_seq);
+   pw_main_loop_run (remote->loop);
+ }
+ 
+@@ -98,16 +97,13 @@ static gboolean
+ discover_node_factory_sync (PipeWireRemote *remote,
+                             GError **error)
+ {
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+-  struct pw_registry_proxy *registry_proxy;
++  struct pw_registry *registry;
+ 
+-  registry_proxy = pw_core_proxy_get_registry (remote->core_proxy,
+-                                               core_type->registry,
+-                                               PW_VERSION_REGISTRY, 0);
+-  pw_registry_proxy_add_listener (registry_proxy,
+-                                  &remote->registry_listener,
+-                                  &registry_events,
+-                                  remote);
++  registry = pw_core_get_registry (remote->core, PW_VERSION_REGISTRY, 0);
++  pw_registry_add_listener (registry,
++                            &remote->registry_listener,
++                            &registry_events,
++                            remote);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -122,59 +118,35 @@ discover_node_factory_sync (PipeWireRemote *remote,
+ }
+ 
+ static void
+-on_state_changed (void *user_data,
+-                  enum pw_remote_state old,
+-                  enum pw_remote_state state,
+-                  const char *error)
++core_event_error (void       *user_data,
++                  uint32_t    id,
++		  int         seq,
++		  int         res,
++		  const char *message)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  switch (state)
++  if (id == PW_ID_CORE)
+     {
+-    case PW_REMOTE_STATE_ERROR:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "%s", error);
+-        }
++      g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
++                 "%s", message);
+       pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "Disconnected");
+-        }
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    default:
+-      g_warning ("Unknown PipeWire state");
+-      break;
+     }
+ }
+ 
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
+-};
+-
+ static void
+ core_event_done (void *user_data,
+-                 uint32_t seq)
++                 uint32_t id, int seq)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  if (remote->sync_seq == seq)
++  if (id == PW_ID_CORE && remote->sync_seq == seq)
+     pw_main_loop_quit (remote->loop);
+ }
+ 
+-static const struct pw_core_proxy_events core_events = {
+-  PW_VERSION_CORE_PROXY_EVENTS,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = core_event_error,
+   .done = core_event_done,
+ };
+ 
+@@ -237,8 +209,8 @@ void
+ pipewire_remote_destroy (PipeWireRemote *remote)
+ {
+   g_clear_pointer (&remote->globals, g_hash_table_destroy);
+-  g_clear_pointer (&remote->remote, pw_remote_destroy);
+-  g_clear_pointer (&remote->core, pw_core_destroy);
++  g_clear_pointer (&remote->core, pw_core_disconnect);
++  g_clear_pointer (&remote->context, pw_context_destroy);
+   g_clear_pointer (&remote->loop, pw_main_loop_destroy);
+   g_clear_error (&remote->error);
+ 
+@@ -307,68 +279,31 @@ pipewire_remote_new_sync (struct pw_properties *pipewire_properties,
+       return NULL;
+     }
+ 
+-  remote->core = pw_core_new (pw_main_loop_get_loop (remote->loop), NULL);
+-  if (!remote->core)
++  remote->context = pw_context_new (pw_main_loop_get_loop (remote->loop), NULL, 0);
++  if (!remote->context)
+     {
+       pipewire_remote_destroy (remote);
+       pw_properties_free (pipewire_properties);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire core");
++                   "Couldn't create PipeWire context");
+       return NULL;
+     }
+ 
+-  remote->remote = pw_remote_new (remote->core, pipewire_properties, 0);
+-  if (!remote->remote)
++  remote->core = pw_context_connect (remote->context, pipewire_properties, 0);
++  if (!remote->core)
+     {
+       pipewire_remote_destroy (remote);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire remote");
++                   "Couldn't connect to PipeWire");
+       return NULL;
+     }
+ 
+   remote->globals = g_hash_table_new_full (NULL, NULL, NULL, g_free);
+ 
+-  pw_remote_add_listener (remote->remote,
+-                          &remote->remote_listener,
+-                          &remote_events,
+-                          remote);
+-
+-  if (pw_remote_connect (remote->remote) != 0)
+-    {
+-      pipewire_remote_destroy (remote);
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect PipeWire remote");
+-      return NULL;
+-    }
+-
+-  pw_main_loop_run (remote->loop);
+-
+-  switch (pw_remote_get_state (remote->remote, NULL))
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      *error = g_steal_pointer (&remote->error);
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "PipeWire loop stopped unexpectedly");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      break;
+-    default:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Unexpected PipeWire state");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    }
+-
+-  remote->core_proxy = pw_remote_get_core_proxy (remote->remote);
+-  pw_core_proxy_add_listener (remote->core_proxy,
+-                              &remote->core_listener,
+-                              &core_events,
+-                              remote);
++  pw_core_add_listener (remote->core,
++                        &remote->core_listener,
++                        &core_events,
++                        remote);
+ 
+   if (!discover_node_factory_sync (remote, error))
+     {
+diff --git src/pipewire.h src/pipewire.h
+index 0f1bf54..bf48d5e 100644
+--- src/pipewire.h
++++ src/pipewire.h
+@@ -32,7 +32,7 @@ typedef struct _PipeWireGlobal
+ 
+ typedef void (* PipeWireGlobalAddedCallback) (PipeWireRemote *remote,
+                                               uint32_t id,
+-                                              uint32_t type,
++                                              const char *type,
+                                               const struct spa_dict *props,
+                                               gpointer user_data);
+ 
+@@ -43,13 +43,11 @@ typedef void (* PipeWireGlobalRemovedCallback) (PipeWireRemote *remote,
+ struct _PipeWireRemote
+ {
+   struct pw_main_loop *loop;
++  struct pw_context *context;
+   struct pw_core *core;
+-  struct pw_remote *remote;
+-  struct spa_hook remote_listener;
+-
+-  struct pw_core_proxy *core_proxy;
+   struct spa_hook core_listener;
+-  uint32_t sync_seq;
++
++  int sync_seq;
+ 
+   struct spa_hook registry_listener;
+ 
+diff --git src/screen-cast.c src/screen-cast.c
+index 7881ddc..1677050 100644
+--- src/screen-cast.c
++++ src/screen-cast.c
+@@ -31,10 +31,10 @@
+ #include "xdp-impl-dbus.h"
+ #include "xdp-utils.h"
+ 
+-#define PERMISSION_ITEM(item_key, item_value) \
+-  ((struct spa_dict_item) { \
+-    .key = item_key, \
+-    .value = item_value \
++#define PERMISSION_ITEM(item_id, item_permissions) \
++  ((struct pw_permission) { \
++    .id = item_id, \
++    .permissions = item_permissions \
+   })
+ 
+ typedef struct _ScreenCast ScreenCast;
+@@ -517,42 +517,9 @@ screen_cast_stream_get_pipewire_node_id (ScreenCastStream *stream)
+   return stream->id;
+ }
+ 
+-static void
+-append_parent_permissions (PipeWireRemote *remote,
+-                           GArray *permission_items,
+-                           GList **string_stash,
+-                           PipeWireGlobal *global,
+-                           const char *permission)
+-{
+-  PipeWireGlobal *parent;
+-  char *parent_permission_value;
+-
+-  if (global->parent_id == 0)
+-    return;
+-
+-  parent = g_hash_table_lookup (remote->globals, GINT_TO_POINTER (global->parent_id));
+-
+-  if (parent->permission_set)
+-    return;
+-  parent->permission_set = TRUE;
+-
+-  append_parent_permissions (remote, permission_items, string_stash,
+-                             parent, permission);
+-
+-  parent_permission_value = g_strdup_printf ("%u:%s",
+-                                             global->parent_id,
+-                                             permission);
+-  *string_stash = g_list_prepend (*string_stash, parent_permission_value);
+-
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       parent_permission_value));
+-}
+-
+ static void
+ append_stream_permissions (PipeWireRemote *remote,
+                            GArray *permission_items,
+-                           GList **string_stash,
+                            GList *streams)
+ {
+   GList *l;
+@@ -561,21 +528,10 @@ append_stream_permissions (PipeWireRemote *remote,
+     {
+       ScreenCastStream *stream = l->data;
+       uint32_t stream_id;
+-      PipeWireGlobal *stream_global;
+-      char *stream_permission_value;
+ 
+       stream_id = screen_cast_stream_get_pipewire_node_id (stream);
+-      stream_global = g_hash_table_lookup (remote->globals,
+-                                           GINT_TO_POINTER (stream_id));
+-
+-      append_parent_permissions (remote, permission_items, string_stash,
+-                                 stream_global, "r--");
+-
+-      stream_permission_value = g_strdup_printf ("%u:rwx", stream_id);
+-      *string_stash = g_list_prepend (*string_stash, stream_permission_value);
+       g_array_append_val (permission_items,
+-                          PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                           stream_permission_value));
++                          PERMISSION_ITEM (stream_id, PW_PERM_RWX));
+     }
+ }
+ 
+@@ -587,9 +543,6 @@ open_pipewire_screen_cast_remote (const char *app_id,
+   struct pw_properties *pipewire_properties;
+   PipeWireRemote *remote;
+   g_autoptr(GArray) permission_items = NULL;
+-  char *node_factory_permission_string;
+-  GList *string_stash = NULL;
+-  struct spa_dict *permission_dict;
+   PipeWireGlobal *node_global;
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.app_id", app_id,
+@@ -603,48 +556,31 @@ open_pipewire_screen_cast_remote (const char *app_id,
+ 
+   permission_items = g_array_new (FALSE, TRUE, sizeof (struct spa_dict_item));
+ 
+-  /*
+-   * Hide all existing and future nodes (except the ones we explicitly list below.
+-   */
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_EXISTING,
+-                                       "---"));
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_DEFAULT,
+-                                       "---"));
+-
+   /*
+    * PipeWire:Interface:Core
+    * Needs rwx to be able create the sink node using the create-object method
+    */
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       "0:rwx"));
++                      PERMISSION_ITEM (PW_ID_CORE, PW_PERM_RWX));
+ 
+   /*
+    * PipeWire:Interface:NodeFactory
+    * Needs r-- so it can be passed to create-object when creating the sink node.
+    */
+-  node_factory_permission_string = g_strdup_printf ("%d:r--",
+-                                                    remote->node_factory_id);
+-  string_stash = g_list_prepend (string_stash, node_factory_permission_string);
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       node_factory_permission_string));
+-  node_global = g_hash_table_lookup (remote->globals,
+-                                     GINT_TO_POINTER (remote->node_factory_id));
+-  append_parent_permissions (remote, permission_items, &string_stash,
+-                             node_global, "r--");
++                      PERMISSION_ITEM (remote->node_factory_id, PW_PERM_R));
+ 
+-  append_stream_permissions (remote, permission_items, &string_stash, streams);
++  append_stream_permissions (remote, permission_items, streams);
+ 
+-  permission_dict =
+-    &SPA_DICT_INIT ((struct spa_dict_item *) permission_items->data,
+-                    permission_items->len);
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             permission_dict);
++  /*
++   * Hide all existing and future nodes (except the ones we explicitly list above).
++   */
++  g_array_append_val (permission_items,
++                      PERMISSION_ITEM (PW_ID_ANY, 0));
+ 
+-  g_list_free_full (string_stash, g_free);
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                permission_items->len,
++                                (const struct pw_permission *)permission_items->data);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -943,7 +879,7 @@ handle_open_pipewire_remote (XdpScreenCast *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
diff --git a/srcpkgs/xdg-desktop-portal/template b/srcpkgs/xdg-desktop-portal/template
index eb8a4602f5d..1136b6a6e0e 100644
--- a/srcpkgs/xdg-desktop-portal/template
+++ b/srcpkgs/xdg-desktop-portal/template
@@ -1,10 +1,10 @@
 # Template file for 'xdg-desktop-portal'
 pkgname=xdg-desktop-portal
 version=1.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-pipewire --enable-geoclue --disable-libportal"
-hostmakedepends="pkg-config glib-devel"
+hostmakedepends="automake libtool gettext-devel pkg-config glib-devel"
 makedepends="flatpak-devel fuse-devel pipewire-devel geoclue2-devel"
 short_desc="Portal frontend service for Flatpak"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -13,6 +13,10 @@ homepage="https://github.com/flatpak/xdg-desktop-portal"
 distfiles="https://github.com/flatpak/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.xz"
 checksum=883c9c9a925e48af54812b5347f546dd776ec2e27076a83d5a8126af6bafb9da
 
+pre_configure() {
+	autoreconf -vfi
+}
+
 post_install() {
 	rm -rf "${DESTDIR}/usr/lib/systemd"
 }

From 1378d38d85cca63e14cd7af035f7898749e1a083 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Thu, 30 Apr 2020 06:17:17 +0900
Subject: [PATCH 4/4] mutter: rebuild for pipewire-0.3

---
 srcpkgs/mutter/patches/pipewire-0.3.patch | 521 ++++++++++++++++++++++
 srcpkgs/mutter/template                   |   2 +-
 2 files changed, 522 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/mutter/patches/pipewire-0.3.patch

diff --git a/srcpkgs/mutter/patches/pipewire-0.3.patch b/srcpkgs/mutter/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..ebff65fba85
--- /dev/null
+++ b/srcpkgs/mutter/patches/pipewire-0.3.patch
@@ -0,0 +1,521 @@
+Build mutter against pipewire-0.3, based on a patch at:
+https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1062
+--- meson.build
++++ meson.build
+@@ -50,7 +50,7 @@ libinput_req = '>= 1.7'
+ gbm_req = '>= 10.3'
+
+ # screen cast version requirements
+-libpipewire_req = '>= 0.2.5'
++libpipewire_req = '>= 0.3.0'
+
+ gnome = import('gnome')
+ pkg = import('pkgconfig')
+@@ -241,7 +241,7 @@ endif
+
+ have_remote_desktop = get_option('remote_desktop')
+ if have_remote_desktop
+-  libpipewire_dep = dependency('libpipewire-0.2', version: libpipewire_req)
++  libpipewire_dep = dependency('libpipewire-0.3', version: libpipewire_req)
+ endif
+
+ have_introspection = get_option('introspection')
+diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
+index 82c5cba436..ba1ce94a7e 100644
+--- src/backends/meta-screen-cast-stream-src.c
++++ src/backends/meta-screen-cast-stream-src.c
+@@ -29,6 +29,7 @@
+ #include <spa/param/props.h>
+ #include <spa/param/format-utils.h>
+ #include <spa/param/video/format-utils.h>
++#include <spa/utils/result.h>
+ #include <stdint.h>
+ #include <sys/mman.h>
+
+@@ -62,15 +63,6 @@ enum
+
+ static guint signals[N_SIGNALS];
+
+-typedef struct _MetaSpaType
+-{
+-  struct spa_type_media_type media_type;
+-  struct spa_type_media_subtype media_subtype;
+-  struct spa_type_format_video format_video;
+-  struct spa_type_video_format video_format;
+-  uint32_t meta_cursor;
+-} MetaSpaType;
+-
+ typedef struct _MetaPipeWireSource
+ {
+   GSource base;
+@@ -82,19 +74,19 @@ typedef struct _MetaScreenCastStreamSrcPrivate
+ {
+   MetaScreenCastStream *stream;
+
++  struct pw_context *pipewire_context;
+   struct pw_core *pipewire_core;
+-  struct pw_remote *pipewire_remote;
+-  struct pw_type *pipewire_type;
+   MetaPipeWireSource *pipewire_source;
+-  struct spa_hook pipewire_remote_listener;
++  struct spa_hook pipewire_core_listener;
+
+   gboolean is_enabled;
+
+   struct pw_stream *pipewire_stream;
+   struct spa_hook pipewire_stream_listener;
++  uint32_t node_id;
+
+-  MetaSpaType spa_type;
+   struct spa_video_info_raw video_format;
++  int video_stride;
+
+   uint64_t last_frame_timestamp_us;
+
+@@ -112,8 +104,6 @@ G_DEFINE_TYPE_WITH_CODE (MetaScreenCastStreamSrc,
+                                                 meta_screen_cast_stream_src_init_initable_iface)
+                          G_ADD_PRIVATE (MetaScreenCastStreamSrc))
+
+-#define PROP_RANGE(min, max) 2, (min), (max)
+-
+ static void
+ meta_screen_cast_stream_src_get_specs (MetaScreenCastStreamSrc *src,
+                                        int                     *width,
+@@ -286,9 +276,6 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+                                                               int                      x,
+                                                               int                      y)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+
+   spa_meta_cursor->id = 1;
+@@ -300,7 +287,7 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   spa_meta_cursor->hotspot.x = 0;
+@@ -317,9 +304,6 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+                                                         int                      y,
+                                                         float                    scale)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   CoglTexture *cursor_texture;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+   int hotspot_x, hotspot_y;
+@@ -346,7 +330,7 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
+@@ -382,12 +366,10 @@ static void
+ add_cursor_metadata (MetaScreenCastStreamSrc *src,
+                      struct spa_buffer       *spa_buffer)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_cursor *spa_meta_cursor;
+
+-  spa_meta_cursor = spa_buffer_find_meta (spa_buffer, spa_type->meta_cursor);
++  spa_meta_cursor = spa_buffer_find_meta_data (spa_buffer, SPA_META_Cursor,
++                                               sizeof (*spa_meta_cursor));
+   if (spa_meta_cursor)
+     meta_screen_cast_stream_src_set_cursor_metadata (src, spa_meta_cursor);
+ }
+@@ -447,14 +429,14 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+     {
+       data = spa_buffer->datas[0].data;
+     }
+-  else if (spa_buffer->datas[0].type == priv->pipewire_type->data.MemFd)
++  else if (spa_buffer->datas[0].type == SPA_DATA_MemFd)
+     {
+       map = mmap (NULL, spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset,
+                   PROT_READ | PROT_WRITE, MAP_SHARED,
+                   spa_buffer->datas[0].fd, 0);
+       if (map == MAP_FAILED)
+         {
+-          g_warning ("Failed to mmap pipewire stream buffer: %s\n",
++          g_warning ("Failed to mmap pipewire stream buffer: %s",
+                      strerror (errno));
+           return;
+         }
+@@ -469,28 +451,30 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+
+   if (meta_screen_cast_stream_src_record_frame (src, data))
+     {
+-      struct spa_meta_video_crop *spa_meta_video_crop;
++      struct spa_meta_region *spa_meta_video_crop;
+
+       spa_buffer->datas[0].chunk->size = spa_buffer->datas[0].maxsize;
++      spa_buffer->datas[0].chunk->stride = priv->video_stride;
+
+       /* Update VideoCrop if needed */
+       spa_meta_video_crop =
+-        spa_buffer_find_meta (spa_buffer, priv->pipewire_type->meta.VideoCrop);
++        spa_buffer_find_meta_data (spa_buffer, SPA_META_VideoCrop,
++                                   sizeof (*spa_meta_video_crop));
+       if (spa_meta_video_crop)
+         {
+           if (meta_screen_cast_stream_src_get_videocrop (src, &crop_rect))
+             {
+-              spa_meta_video_crop->x = crop_rect.x;
+-              spa_meta_video_crop->y = crop_rect.y;
+-              spa_meta_video_crop->width = crop_rect.width;
+-              spa_meta_video_crop->height = crop_rect.height;
++              spa_meta_video_crop->region.position.x = crop_rect.x;
++              spa_meta_video_crop->region.position.y = crop_rect.y;
++              spa_meta_video_crop->region.size.width = crop_rect.width;
++              spa_meta_video_crop->region.size.height = crop_rect.height;
+             }
+           else
+             {
+-              spa_meta_video_crop->x = 0;
+-              spa_meta_video_crop->y = 0;
+-              spa_meta_video_crop->width = priv->stream_width;
+-              spa_meta_video_crop->height = priv->stream_height;
++              spa_meta_video_crop->region.position.x = 0;
++              spa_meta_video_crop->region.position.y = 0;
++              spa_meta_video_crop->region.size.width = priv->stream_width;
++              spa_meta_video_crop->region.size.height = priv->stream_height;
+             }
+         }
+     }
+@@ -555,7 +539,6 @@ on_stream_state_changed (void                 *data,
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  uint32_t node_id;
+
+   switch (state)
+     {
+@@ -563,14 +546,12 @@ on_stream_state_changed (void                 *data,
+       g_warning ("pipewire stream error: %s", error_message);
+       meta_screen_cast_stream_src_notify_closed (src);
+       break;
+-    case PW_STREAM_STATE_CONFIGURE:
+-      node_id = pw_stream_get_node_id (priv->pipewire_stream);
+-      g_signal_emit (src, signals[READY], 0, (unsigned int) node_id);
+-      break;
+-    case PW_STREAM_STATE_UNCONNECTED:
+-    case PW_STREAM_STATE_CONNECTING:
+-    case PW_STREAM_STATE_READY:
+     case PW_STREAM_STATE_PAUSED:
++      if (priv->node_id == SPA_ID_INVALID && priv->pipewire_stream)
++        {
++          priv->node_id = pw_stream_get_node_id (priv->pipewire_stream);
++          g_signal_emit (src, signals[READY], 0, (unsigned int) priv->node_id);
++        }
+       if (meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_disable (src);
+       break;
+@@ -578,68 +559,69 @@ on_stream_state_changed (void                 *data,
+       if (!meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_enable (src);
+       break;
++    case PW_STREAM_STATE_UNCONNECTED:
++    case PW_STREAM_STATE_CONNECTING:
++      break;
+     }
+ }
+
+ static void
+-on_stream_format_changed (void                 *data,
+-                          const struct spa_pod *format)
++on_stream_param_changed (void                 *data,
++                         uint32_t              id,
++                         const struct spa_pod *format)
+ {
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   uint8_t params_buffer[1024];
+   int32_t width, height, stride, size;
+   struct spa_pod_builder pod_builder;
+   const struct spa_pod *params[3];
+   const int bpp = 4;
+
+-  if (!format)
+-    {
+-      pw_stream_finish_format (priv->pipewire_stream, 0, NULL, 0);
+-      return;
+-    }
++  if (!format || id != SPA_PARAM_Format)
++    return;
+
+   spa_format_video_raw_parse (format,
+-                              &priv->video_format,
+-                              &priv->spa_type.format_video);
++                              &priv->video_format);
+
+   width = priv->video_format.size.width;
+   height = priv->video_format.size.height;
+   stride = SPA_ROUND_UP_N (width * bpp, 4);
+   size = height * stride;
+
++  priv->video_stride = stride;
++
+   pod_builder = SPA_POD_BUILDER_INIT (params_buffer, sizeof (params_buffer));
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idBuffers, pipewire_type->param_buffers.Buffers,
+-    ":", pipewire_type->param_buffers.size, "i", size,
+-    ":", pipewire_type->param_buffers.stride, "i", stride,
+-    ":", pipewire_type->param_buffers.buffers, "iru", 16, PROP_RANGE (2, 16),
+-    ":", pipewire_type->param_buffers.align, "i", 16);
+-
+-  params[1] = spa_pod_builder_object (
++    SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
++    SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int (16, 2, 16),
++    SPA_PARAM_BUFFERS_blocks, SPA_POD_Int (1),
++    SPA_PARAM_BUFFERS_size, SPA_POD_Int (size),
++    SPA_PARAM_BUFFERS_stride, SPA_POD_Int (stride),
++    SPA_PARAM_BUFFERS_align, SPA_POD_Int (16));
++
++  params[1] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", pipewire_type->meta.VideoCrop,
+-    ":", pipewire_type->param_meta.size, "i", sizeof (struct spa_meta_video_crop));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_VideoCrop),
++    SPA_PARAM_META_size, SPA_POD_Int (sizeof (struct spa_meta_region)));
+
+-  params[2] = spa_pod_builder_object (
++  params[2] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", priv->spa_type.meta_cursor,
+-    ":", pipewire_type->param_meta.size, "i", CURSOR_META_SIZE (64, 64));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_Cursor),
++    SPA_PARAM_META_size, SPA_POD_Int (CURSOR_META_SIZE (64, 64)));
+
+-  pw_stream_finish_format (priv->pipewire_stream, 0,
+-                           params, G_N_ELEMENTS (params));
++  pw_stream_update_params (priv->pipewire_stream, params, G_N_ELEMENTS (params));
+ }
+
+ static const struct pw_stream_events stream_events = {
+   PW_VERSION_STREAM_EVENTS,
+   .state_changed = on_stream_state_changed,
+-  .format_changed = on_stream_format_changed,
++  .param_changed = on_stream_param_changed,
+ };
+
+ static struct pw_stream *
+@@ -652,8 +634,6 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   uint8_t buffer[1024];
+   struct spa_pod_builder pod_builder =
+     SPA_POD_BUILDER_INIT (buffer, sizeof (buffer));
+-  MetaSpaType *spa_type = &priv->spa_type;
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   float frame_rate;
+   MetaFraction frame_rate_fraction;
+   struct spa_fraction max_framerate;
+@@ -661,7 +641,9 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   const struct spa_pod *params[1];
+   int result;
+
+-  pipewire_stream = pw_stream_new (priv->pipewire_remote,
++  priv->node_id = SPA_ID_INVALID;
++
++  pipewire_stream = pw_stream_new (priv->pipewire_core,
+                                    "meta-screen-cast-src",
+                                    NULL);
+   if (!pipewire_stream)
+@@ -682,17 +664,17 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   max_framerate = SPA_FRACTION (frame_rate_fraction.num,
+                                 frame_rate_fraction.denom);
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idEnumFormat, pipewire_type->spa_format,
+-    "I", spa_type->media_type.video,
+-    "I", spa_type->media_subtype.raw,
+-    ":", spa_type->format_video.format, "I", spa_type->video_format.BGRx,
+-    ":", spa_type->format_video.size, "R", &SPA_RECTANGLE (priv->stream_width,
+-                                                           priv->stream_height),
+-    ":", spa_type->format_video.framerate, "F", &SPA_FRACTION (0, 1),
+-    ":", spa_type->format_video.max_framerate, "Fru", &max_framerate,
+-                                                      PROP_RANGE (&min_framerate,
++    SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
++    SPA_FORMAT_mediaType, SPA_POD_Id (SPA_MEDIA_TYPE_video),
++    SPA_FORMAT_mediaSubtype, SPA_POD_Id (SPA_MEDIA_SUBTYPE_raw),
++    SPA_FORMAT_VIDEO_format, SPA_POD_Id (SPA_VIDEO_FORMAT_BGRx),
++    SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle (&SPA_RECTANGLE (priv->stream_width,
++                                                              priv->stream_height)),
++    SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction (&SPA_FRACTION (0, 1)),
++    SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction (&max_framerate,
++                                                                  &min_framerate,
+                                                                   &max_framerate));
+
+   pw_stream_add_listener (pipewire_stream,
+@@ -702,7 +684,7 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+
+   result = pw_stream_connect (pipewire_stream,
+                               PW_DIRECTION_OUTPUT,
+-                              NULL,
++                              SPA_ID_INVALID,
+                               (PW_STREAM_FLAG_DRIVER |
+                                PW_STREAM_FLAG_MAP_BUFFERS),
+                               params, G_N_ELEMENTS (params));
+@@ -717,40 +699,18 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+ }
+
+ static void
+-on_state_changed (void                 *data,
+-                  enum pw_remote_state  old,
+-                  enum pw_remote_state  state,
+-                  const char           *error_message)
++on_core_error (void       *data,
++               uint32_t    id,
++	       int         seq,
++	       int         res,
++	       const char *message)
+ {
+   MetaScreenCastStreamSrc *src = data;
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_stream *pipewire_stream;
+-  GError *error = NULL;
+
+-  switch (state)
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-      g_warning ("pipewire remote error: %s\n", error_message);
+-      meta_screen_cast_stream_src_notify_closed (src);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pipewire_stream = create_pipewire_stream (src, &error);
+-      if (!pipewire_stream)
+-        {
+-          g_warning ("Could not create pipewire stream: %s", error->message);
+-          g_error_free (error);
+-          meta_screen_cast_stream_src_notify_closed (src);
+-        }
+-      else
+-        {
+-          priv->pipewire_stream = pipewire_stream;
+-        }
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    }
++  g_warning ("pipewire remote error: id:%u %s", id, message);
++
++  if (id == PW_ID_CORE && res == -EPIPE)
++    meta_screen_cast_stream_src_notify_closed (src);
+ }
+
+ static gboolean
+@@ -793,17 +753,6 @@ static GSourceFuncs pipewire_source_funcs =
+   pipewire_loop_source_finalize
+ };
+
+-static void
+-init_spa_type (MetaSpaType         *type,
+-               struct spa_type_map *map)
+-{
+-  spa_type_media_type_map (map, &type->media_type);
+-  spa_type_media_subtype_map (map, &type->media_subtype);
+-  spa_type_format_video_map (map, &type->format_video);
+-  spa_type_video_format_map (map, &type->video_format);
+-  type->meta_cursor = spa_type_map_get_id(map, SPA_TYPE_META__Cursor);
+-}
+-
+ static MetaPipeWireSource *
+ create_pipewire_source (void)
+ {
+@@ -829,9 +778,9 @@ create_pipewire_source (void)
+   return pipewire_source;
+ }
+
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = on_core_error,
+ };
+
+ static gboolean
+@@ -851,37 +800,31 @@ meta_screen_cast_stream_src_initable_init (GInitable     *initable,
+       return FALSE;
+     }
+
+-  priv->pipewire_core = pw_core_new (priv->pipewire_source->pipewire_loop,
+-                                     NULL);
+-  if (!priv->pipewire_core)
++  priv->pipewire_context = pw_context_new (priv->pipewire_source->pipewire_loop,
++                                           NULL, 0);
++  if (!priv->pipewire_context)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Failed to create pipewire core");
++                   "Failed to create pipewire context");
+       return FALSE;
+     }
+
+-  priv->pipewire_remote = pw_remote_new (priv->pipewire_core, NULL, 0);
+-  if (!priv->pipewire_remote)
++  priv->pipewire_core = pw_context_connect (priv->pipewire_context, NULL, 0);
++  if (!priv->pipewire_core)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't creat pipewire remote");
++                   "Couldn't connect pipewire context");
+       return FALSE;
+     }
+
+-  pw_remote_add_listener (priv->pipewire_remote,
+-                          &priv->pipewire_remote_listener,
+-                          &remote_events,
+-                          src);
++  pw_core_add_listener (priv->pipewire_core,
++                        &priv->pipewire_core_listener,
++                        &core_events,
++                        src);
+
+-  priv->pipewire_type = pw_core_get_type (priv->pipewire_core);
+-  init_spa_type (&priv->spa_type, priv->pipewire_type->map);
+-
+-  if (pw_remote_connect (priv->pipewire_remote) != 0)
+-    {
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect pipewire remote");
+-      return FALSE;
+-    }
++  priv->pipewire_stream = create_pipewire_stream (src, error);
++  if (!priv->pipewire_stream)
++    return FALSE;
+
+   return TRUE;
+ }
+@@ -912,8 +855,8 @@ meta_screen_cast_stream_src_finalize (GObject *object)
+     meta_screen_cast_stream_src_disable (src);
+
+   g_clear_pointer (&priv->pipewire_stream, pw_stream_destroy);
+-  g_clear_pointer (&priv->pipewire_remote, pw_remote_destroy);
+-  g_clear_pointer (&priv->pipewire_core, pw_core_destroy);
++  g_clear_pointer (&priv->pipewire_core, pw_core_disconnect);
++  g_clear_pointer (&priv->pipewire_context, pw_context_destroy);
+   g_source_destroy (&priv->pipewire_source->base);
+
+   G_OBJECT_CLASS (meta_screen_cast_stream_src_parent_class)->finalize (object);
diff --git a/srcpkgs/mutter/template b/srcpkgs/mutter/template
index 4e0bd32b67d..806a3bef9f0 100644
--- a/srcpkgs/mutter/template
+++ b/srcpkgs/mutter/template
@@ -1,7 +1,7 @@
 # Template file for 'mutter'
 pkgname=mutter
 version=3.34.1
-revision=2
+revision=3
 build_helper="gir"
 build_style=meson
 configure_args="-Degl_device=true -Dudev=true -Dnative_backend=true

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: WIP: pipewire: update to 0.3.4
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (34 preceding siblings ...)
  2020-05-09 15:10 ` sirn
@ 2020-05-09 15:22 ` sirn
  2020-05-09 15:43 ` mnabid
                   ` (15 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-05-09 15:22 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 341 bytes --]

New comment by sirn on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-626191903

Comment:
Compilation on armv6l/armv7l is now fixed with a [patch from upstream](https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/011992e774fcb58966f567099f03943c57e66c2b). I'm removing WIP (for now...). 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.4
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (35 preceding siblings ...)
  2020-05-09 15:22 ` sirn
@ 2020-05-09 15:43 ` mnabid
  2020-05-09 15:43 ` mnabid
                   ` (14 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: mnabid @ 2020-05-09 15:43 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 376 bytes --]

New comment by mnabid on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-626194781

Comment:
> Compilation on armv6l/armv7l is now fixed with a [patch from upstream](https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/011992e774fcb58966f567099f03943c57e66c2b). I'm removing WIP (for now...).

I tried that patch. No luck.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.4
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (36 preceding siblings ...)
  2020-05-09 15:43 ` mnabid
@ 2020-05-09 15:43 ` mnabid
  2020-05-09 15:44 ` mnabid
                   ` (13 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: mnabid @ 2020-05-09 15:43 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 382 bytes --]

New comment by mnabid on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-626194781

Comment:
> Compilation on armv6l/armv7l is now fixed with a [patch from upstream](https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/011992e774fcb58966f567099f03943c57e66c2b). I'm removing WIP (for now...).

@sirn I tried that patch. No luck.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.4
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (37 preceding siblings ...)
  2020-05-09 15:43 ` mnabid
@ 2020-05-09 15:44 ` mnabid
  2020-05-12 17:38 ` [PR PATCH] [Updated] " sirn
                   ` (12 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: mnabid @ 2020-05-09 15:44 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 382 bytes --]

New comment by mnabid on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-626194781

Comment:
> Compilation on armv6l/armv7l is now fixed with a [patch from upstream](https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/011992e774fcb58966f567099f03943c57e66c2b). I'm removing WIP (for now...).

@sirn I tried that patch. No luck.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PR PATCH] [Updated] pipewire: update to 0.3.4
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (38 preceding siblings ...)
  2020-05-09 15:44 ` mnabid
@ 2020-05-12 17:38 ` sirn
  2020-05-12 18:08 ` sirn
                   ` (11 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-05-12 17:38 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 785 bytes --]

There is an updated pull request by sirn against master on the void-packages repository

https://github.com/sirn/void-packages pipewire-update
https://github.com/void-linux/void-packages/pull/20413

pipewire: update to 0.3.4
This PR updates `pipewire` to 0.3.4 and also updating/patching all packages that depends on it. 

* `xdg-desktop-portal` includes a patch backported from 1.7.0 to allow 1.6.0 to build against pipewire-0.3 (1.7.x is prerelease)
* `xdg-desktop-portal-kde` already includes Pipewire 0.3 support and only requires revbump.
* `mutter` includes a patch backported from 3.35 to allow 3.34 to build against pipewire-0.3 (upgrading to >=3.35 also requires upgrading GNOME).

A patch file from https://github.com/void-linux/void-packages/pull/20413.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pipewire-update-20413.patch --]
[-- Type: text/x-diff, Size: 55493 bytes --]

From 1d4a46b9b117713771727e630d0805680281af2b Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:23:52 +0900
Subject: [PATCH 1/4] pipewire: update to 0.3.4

---
 common/shlibs                                 |  2 +-
 srcpkgs/alsa-pipewire                         |  1 +
 srcpkgs/libjack-pipewire                      |  1 +
 srcpkgs/libpulseaudio-pipewire                |  1 +
 .../patches/01-fix-format-warning.patch       | 37 ++++++++++
 .../patches/02-fix-spa_log_func-musl.patch    | 25 +++++++
 .../patches/03-fix-neon-compilation.patch     | 58 +++++++++++++++
 srcpkgs/pipewire/template                     | 71 ++++++++++++++-----
 8 files changed, 178 insertions(+), 18 deletions(-)
 create mode 120000 srcpkgs/alsa-pipewire
 create mode 120000 srcpkgs/libjack-pipewire
 create mode 120000 srcpkgs/libpulseaudio-pipewire
 create mode 100644 srcpkgs/pipewire/patches/01-fix-format-warning.patch
 create mode 100644 srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch
 create mode 100644 srcpkgs/pipewire/patches/03-fix-neon-compilation.patch

diff --git a/common/shlibs b/common/shlibs
index 580a12d9c87..7b50a83dd25 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3204,7 +3204,7 @@ libarcan_shmif_ext.so.0.11 arcan-0.5.4.3_1
 libarcan_shmif_server.so.0.11 arcan-0.5.4.3_1
 libarcan_tui.so.0.11 arcan-0.5.4.3_1
 liblwipv6.so.2 lwipv6-1.5a_1
-libpipewire-0.2.so.1 libpipewire-0.2.2_1
+libpipewire-0.3.so.0 libpipewire-0.3.4_1
 libvolk.so.2.2.1 volk-2.2.1_1
 libgnuradio-runtime.so.3.8.0 gnuradio-3.8.0.0_1
 libgnuradio-pmt.so.3.8.0 gnuradio-3.8.0.0_1
diff --git a/srcpkgs/alsa-pipewire b/srcpkgs/alsa-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/alsa-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libjack-pipewire b/srcpkgs/libjack-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libjack-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libpulseaudio-pipewire b/srcpkgs/libpulseaudio-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libpulseaudio-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/pipewire/patches/01-fix-format-warning.patch b/srcpkgs/pipewire/patches/01-fix-format-warning.patch
new file mode 100644
index 00000000000..b4e8748390e
--- /dev/null
+++ b/srcpkgs/pipewire/patches/01-fix-format-warning.patch
@@ -0,0 +1,37 @@
+From 979a81a70d468d6482773521b89aaf67ce79b921 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Fri, 1 May 2020 11:05:38 +0200
+Subject: [PATCH] meson: add -Wformat
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+cc1: warning: ‘-Wformat-security’ ignored without ‘-Wformat’ [-Wformat-security]
+
+Fixes #234
+---
+ meson.build | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/meson.build b/meson.build
+index 74142587..1631e763 100644
+--- meson.build
++++ meson.build
+@@ -51,6 +51,7 @@ if cc.get_id() == 'gcc'
+ 			'-Wsign-compare',
+ 			'-Wimplicit-fallthrough',
+ 			'-Wpointer-arith',
++			'-Wformat',
+ 			'-Wformat-security',
+ 			'-Werror=suggest-attribute=format',
+ 			'-Wmissing-braces',
+@@ -68,6 +69,7 @@ if cc.get_id() == 'gcc'
+ 			'-Wsign-compare',
+ 			'-Wimplicit-fallthrough',
+ 			'-Wpointer-arith',
++			'-Wformat',
+ 			'-Wformat-security',
+ 			'-Werror=suggest-attribute=format',
+ 			'-Wmissing-braces',
+--
+2.26.2
diff --git a/srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch b/srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch
new file mode 100644
index 00000000000..b816975a6eb
--- /dev/null
+++ b/srcpkgs/pipewire/patches/02-fix-spa_log_func-musl.patch
@@ -0,0 +1,25 @@
+From e83bf8a33f720050c7f1ec5f00530fafd5af5698 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Fri, 1 May 2020 11:18:28 +0200
+Subject: [PATCH] log: use printf attribute for log fallback
+
+Fixes #233
+---
+ spa/include/spa/support/log.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/spa/include/spa/support/log.h b/spa/include/spa/support/log.h
+index c97cc8e5..51b3e741 100644
+--- spa/include/spa/support/log.h
++++ spa/include/spa/support/log.h
+@@ -139,7 +139,7 @@ struct spa_log_methods {
+ #else
+
+ #define SPA_LOG_FUNC(name,lev)							\
+-static inline void spa_log_##name (struct spa_log *l, const char *format, ...)  \
++static inline SPA_PRINTF_FUNC(2,3) void spa_log_##name (struct spa_log *l, const char *format, ...)  \
+ {										\
+ 	if (SPA_UNLIKELY(spa_log_level_enabled(l, lev))) {			\
+ 		va_list varargs;						\
+--
+2.26.2
diff --git a/srcpkgs/pipewire/patches/03-fix-neon-compilation.patch b/srcpkgs/pipewire/patches/03-fix-neon-compilation.patch
new file mode 100644
index 00000000000..28d9f05b754
--- /dev/null
+++ b/srcpkgs/pipewire/patches/03-fix-neon-compilation.patch
@@ -0,0 +1,58 @@
+From 011992e774fcb58966f567099f03943c57e66c2b Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Fri, 8 May 2020 22:12:24 +0200
+Subject: [PATCH] meson: try to compile a little NEON program to be sure
+
+Fixes #235
+---
+ meson.build | 34 ++++++++++++++++++++++++++++++----
+ 1 file changed, 30 insertions(+), 4 deletions(-)
+
+diff --git a/meson.build b/meson.build
+index 17864da0..5a49c124 100644
+--- meson.build
++++ meson.build
+@@ -100,11 +100,37 @@ have_avx2 = cc.has_argument(avx2_args)
+
+ have_neon = false
+ if host_machine.cpu_family() == 'aarch64'
+-  neon_args = []
+-  have_neon = true
++  if cc.compiles('''
++    #include <arm_neon.h>
++    int main () {
++      float *s;
++      asm volatile(
++	"      ld1 { v0.4s }, [%[s]], #16\n"
++        "      fcvtzs v0.4s, v0.4s, #31\n"
++	: [s] "+r" (s) : :);
++    }
++    ''',
++    name : 'aarch64 Neon Support')
++      neon_args = []
++      have_neon = true
++
++  endif
+ elif cc.has_argument('-mfpu=neon')
+-  neon_args = ['-mfpu=neon']
+-  have_neon = true
++  if cc.compiles('''
++    #include <arm_neon.h>
++    int main () {
++      float *s;
++      asm volatile(
++        "      vld1.32 { q0 }, [%[s]]!\n"
++        "      vcvt.s32.f32 q0, q0, #31\n"
++	: [s] "+r" (s) : :);
++    }
++    ''',
++    args: '-mfpu=neon',
++    name : 'arm Neon Support')
++      neon_args = ['-mfpu=neon']
++      have_neon = true
++  endif
+ endif
+
+
+--
+2.26.2
diff --git a/srcpkgs/pipewire/template b/srcpkgs/pipewire/template
index 7f646dad11d..763b7f9b365 100644
--- a/srcpkgs/pipewire/template
+++ b/srcpkgs/pipewire/template
@@ -1,26 +1,37 @@
 # Template file for 'pipewire'
 pkgname=pipewire
-version=0.2.7
+version=0.3.4
 revision=1
 build_style=meson
-configure_args="-Dman=true -Dgstreamer=enabled -Ddocs=true -Dsystemd=false"
+configure_args="-Dman=true -Dgstreamer=true -Ddocs=true -Dsystemd=false
+ -Dbluez5=true -Dffmpeg=true -Dpipewire-alsa=true -Dpipewire-jack=true
+ -Dpipewire-pulseaudio=true"
 hostmakedepends="doxygen graphviz pkg-config xmltoman"
 makedepends="SDL2-devel ffmpeg-devel gst-plugins-base1-devel jack-devel
- sbc-devel v4l-utils-devel libva-devel"
+ sbc-devel v4l-utils-devel libva-devel libbluetooth-devel"
 short_desc="Server and user space API to deal with multimedia pipelines"
-maintainer="Orphaned <orphan@voidlinux.org>"
-#Next release will probably change to MIT, currently listed in master
-license="LGPL-2.1-only, GPL-2.0-only "
+maintainer="Kridsada Thanabulpong <sirn@ogsite.net>"
+license="MIT"
 homepage="https://pipewire.org/"
-changelog="https://raw.githubusercontent.com/PipeWire/pipewire/master/NEWS"
-distfiles="https://github.com/PipeWire/pipewire/archive/${version}.tar.gz"
-checksum=bfaa0f6ae6c0791e2e0b59234d399753bf24f1b33dbf587682363a8463dd8df1
+changelog="https://gitlab.freedesktop.org/pipewire/pipewire/-/raw/master/NEWS"
+distfiles="https://gitlab.freedesktop.org/pipewire/pipewire/-/archive/${version}/pipewire-${version}.tar.gz"
+checksum=6a1c9c671514c84b38ce96d51823354702bc4d5dbaba12d501faa0448f892515
 conf_files="/etc/pipewire/pipewire.conf"
 
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+	LDFLAGS+=" -latomic"
+fi
+
+post_install() {
+	vlicense LICENSE
+}
+
 libpipewire_package() {
 	short_desc+=" - pipewire library"
 	pkg_install() {
-		vmove "usr/lib/libpipewire-0.2.so.*"
+		vmove "usr/lib/libpipewire-0.3.so.*"
+		vmove "usr/lib/pipewire-0.3/*.so"
 	}
 }
 
@@ -28,25 +39,25 @@ pipewire-devel_package() {
 	depends="libpipewire-${version}_${revision}"
 	short_desc+=" - pipewire and libspa development files"
 	pkg_install() {
-		vmove usr/include/pipewire
-		vmove usr/include/spa
-		vmove usr/lib/pkgconfig/libpipewire-0.2.pc
-		vmove usr/lib/pkgconfig/libspa-0.1.pc
-		vmove usr/lib/libpipewire-0.2.so
+		vmove usr/include/pipewire-0.3
+		vmove usr/include/spa-0.2
+		vmove usr/lib/pkgconfig/libpipewire-0.3.pc
+		vmove usr/lib/pkgconfig/libspa-0.2.pc
+		vmove usr/lib/libpipewire-0.3.so
 	}
 }
 
 libspa-ffmpeg_package() {
 	short_desc+=" - ffmpeg plugins"
 	pkg_install() {
-		vmove usr/lib/spa/ffmpeg
+		vmove usr/lib/spa-0.2/ffmpeg
 	}
 }
 
 libspa-bluetooth_package() {
 	short_desc+=" - bluetooth plugins"
 	pkg_install() {
-		vmove usr/lib/spa/bluez5
+		vmove usr/lib/spa-0.2/bluez5
 	}
 }
 
@@ -57,6 +68,32 @@ gstreamer1-pipewire_package() {
 	}
 }
 
+libpulseaudio-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - PulseAudio client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/pulse
+		vmove usr/bin/pw-pulse
+	}
+}
+
+alsa-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - ALSA client library"
+	pkg_install() {
+		vmove usr/lib/alsa-lib
+	}
+}
+
+libjack-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - JACK client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/jack
+		vmove usr/bin/pw-jack
+	}
+}
+
 pipewire-doc_package() {
 	archs=noarch
 	short_desc+=" - documentation"

From 7eb801dd1937cefd473fc2325aa1a48f76558dfb Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:46 +0900
Subject: [PATCH 2/4] xdg-desktop-portal-kde: rebuild for pipewire-0.3

---
 srcpkgs/xdg-desktop-portal-kde/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xdg-desktop-portal-kde/template b/srcpkgs/xdg-desktop-portal-kde/template
index 7a2aaf16b96..574e28504b7 100644
--- a/srcpkgs/xdg-desktop-portal-kde/template
+++ b/srcpkgs/xdg-desktop-portal-kde/template
@@ -1,7 +1,7 @@
 # Template file for 'xdg-desktop-portal-kde'
 pkgname=xdg-desktop-portal-kde
 version=5.18.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules qt5-qmake qt5-host-tools kcoreaddons gettext"
 makedepends="glib-devel kio-devel kwayland-devel libepoxy-devel pipewire-devel

From dd0d4a4ef98cc9dd40a1f146f83c5dfebb6b7695 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:26 +0900
Subject: [PATCH 3/4] xdg-desktop-portal: rebuild for pipewire-0.3

---
 .../patches/pipewire-0.3.patch                | 551 ++++++++++++++++++
 srcpkgs/xdg-desktop-portal/template           |   8 +-
 2 files changed, 557 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch

diff --git a/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..94ebe083598
--- /dev/null
+++ b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
@@ -0,0 +1,551 @@
+From a38901e5e7f835efe7b7a06c55790c8c20bc91a2 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Tue, 14 Jan 2020 09:37:09 +0100
+Subject: [PATCH] PipeWire: update to 0.3 API
+
+---
+ configure.ac      |   2 +-
+ src/camera.c      |  24 ++++----
+ src/pipewire.c    | 141 +++++++++++++---------------------------------
+ src/pipewire.h    |  10 ++--
+ src/screen-cast.c |  98 ++++++--------------------------
+ 5 files changed, 72 insertions(+), 203 deletions(-)
+
+diff --git configure.ac configure.ac
+index 89902fa..62d7960 100644
+--- configure.ac
++++ configure.ac
+@@ -97,7 +97,7 @@ AC_ARG_ENABLE(pipewire,
+ 	      [AS_HELP_STRING([--enable-pipewire],[Enable PipeWire support. Needed for screen cast portal])],
+ 	      enable_pipewire=$enableval, enable_pipewire=yes)
+ if test x$enable_pipewire = xyes ; then
+-	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.2 >= 0.2.6])
++	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.3 >= 0.2.90])
+ 	AC_DEFINE([HAVE_PIPEWIRE],[1], [Define to enable PipeWire support])
+ fi
+ AM_CONDITIONAL([HAVE_PIPEWIRE],[test "$enable_pipewire" = "yes"])
+diff --git src/camera.c src/camera.c
+index c2b392c..20fe3aa 100644
+--- src/camera.c
++++ src/camera.c
+@@ -141,7 +141,7 @@ open_pipewire_camera_remote (const char *app_id,
+                              GError **error)
+ {
+   PipeWireRemote *remote;
+-  struct spa_dict_item permission_items[1];
++  struct pw_permission permission_items[2];
+   struct pw_properties *pipewire_properties;
+ 
+   pipewire_properties =
+@@ -158,12 +158,12 @@ open_pipewire_camera_remote (const char *app_id,
+    * Hide all existing and future nodes by default. PipeWire will use the
+    * permission store to set up permissions.
+    */
+-  permission_items[0].key = PW_CORE_PROXY_PERMISSIONS_DEFAULT;
+-  permission_items[0].value = "---";
++  permission_items[0] = PW_PERMISSION_INIT (PW_ID_CORE, PW_PERM_RWX);
++  permission_items[1] = PW_PERMISSION_INIT (PW_ID_ANY, 0);
+ 
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             &SPA_DICT_INIT (permission_items,
+-                                             G_N_ELEMENTS (permission_items)));
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                G_N_ELEMENTS (permission_items),
++                                permission_items);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -219,7 +219,7 @@ handle_open_pipewire_remote (XdpCamera *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
+@@ -250,29 +250,28 @@ camera_iface_init (XdpCameraIface *iface)
+ static void
+ global_added_cb (PipeWireRemote *remote,
+                  uint32_t id,
+-                 uint32_t type,
++                 const char *type,
+                  const struct spa_dict *props,
+                  gpointer user_data)
+ {
+   Camera *camera = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *media_class;
+   const struct spa_dict_item *media_role;
+ 
+-  if (type != core_type->node)
++  if (strcmp(type, PW_TYPE_INTERFACE_Node) != 0)
+     return;
+ 
+   if (!props)
+     return;
+ 
+-  media_class = spa_dict_lookup_item (props, "media.class");
++  media_class = spa_dict_lookup_item (props, PW_KEY_MEDIA_CLASS);
+   if (!media_class)
+     return;
+ 
+   if (g_strcmp0 (media_class->value, "Video/Source") != 0)
+     return;
+ 
+-  media_role = spa_dict_lookup_item (props, "media.role");
++  media_role = spa_dict_lookup_item (props, PW_KEY_MEDIA_ROLE);
+   if (!media_role)
+     return;
+ 
+@@ -342,6 +341,7 @@ create_pipewire_remote (Camera *camera,
+     }
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.is_portal", "true",
++                                           "portal.monitor", "Camera",
+                                            NULL);
+   camera->pipewire_remote = pipewire_remote_new_sync (pipewire_properties,
+                                                       global_added_cb,
+diff --git src/pipewire.c src/pipewire.c
+index 793a378..162cd55 100644
+--- src/pipewire.c
++++ src/pipewire.c
+@@ -21,6 +21,7 @@
+ #include <errno.h>
+ #include <glib.h>
+ #include <pipewire/pipewire.h>
++#include <spa/utils/result.h>
+ 
+ #include "pipewire.h"
+ 
+@@ -36,27 +37,25 @@ static gboolean is_pipewire_initialized = FALSE;
+ static void
+ registry_event_global (void *user_data,
+                        uint32_t id,
+-                       uint32_t parent_id,
+                        uint32_t permissions,
+-                       uint32_t type,
++                       const char *type,
+                        uint32_t version,
+                        const struct spa_dict *props)
+ {
+   PipeWireRemote *remote = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *factory_object_type;
+   PipeWireGlobal *global;
+ 
+   global = g_new0 (PipeWireGlobal, 1);
+   *global = (PipeWireGlobal) {
+-    .parent_id = parent_id,
++    .parent_id = id,
+   };
+ 
+   g_hash_table_insert (remote->globals, GINT_TO_POINTER (id), global);
+   if (remote->global_added_cb)
+     remote->global_added_cb (remote, id, type, props, remote->user_data);
+ 
+-  if (type != core_type->factory)
++  if (strcmp(type, PW_TYPE_INTERFACE_Factory) != 0)
+     return;
+ 
+   factory_object_type = spa_dict_lookup_item (props, "factory.type.name");
+@@ -81,8 +80,8 @@ registry_event_global_remove (void *user_data,
+   g_hash_table_remove (remote->globals, GINT_TO_POINTER (id));
+ }
+ 
+-static const struct pw_registry_proxy_events registry_events = {
+-  PW_VERSION_REGISTRY_PROXY_EVENTS,
++static const struct pw_registry_events registry_events = {
++  PW_VERSION_REGISTRY_EVENTS,
+   .global = registry_event_global,
+   .global_remove = registry_event_global_remove,
+ };
+@@ -90,7 +89,7 @@ static const struct pw_registry_proxy_events registry_events = {
+ void
+ pipewire_remote_roundtrip (PipeWireRemote *remote)
+ {
+-  pw_core_proxy_sync (remote->core_proxy, ++remote->sync_seq);
++  remote->sync_seq = pw_core_sync (remote->core, PW_ID_CORE, remote->sync_seq);
+   pw_main_loop_run (remote->loop);
+ }
+ 
+@@ -98,16 +97,13 @@ static gboolean
+ discover_node_factory_sync (PipeWireRemote *remote,
+                             GError **error)
+ {
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+-  struct pw_registry_proxy *registry_proxy;
++  struct pw_registry *registry;
+ 
+-  registry_proxy = pw_core_proxy_get_registry (remote->core_proxy,
+-                                               core_type->registry,
+-                                               PW_VERSION_REGISTRY, 0);
+-  pw_registry_proxy_add_listener (registry_proxy,
+-                                  &remote->registry_listener,
+-                                  &registry_events,
+-                                  remote);
++  registry = pw_core_get_registry (remote->core, PW_VERSION_REGISTRY, 0);
++  pw_registry_add_listener (registry,
++                            &remote->registry_listener,
++                            &registry_events,
++                            remote);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -122,59 +118,35 @@ discover_node_factory_sync (PipeWireRemote *remote,
+ }
+ 
+ static void
+-on_state_changed (void *user_data,
+-                  enum pw_remote_state old,
+-                  enum pw_remote_state state,
+-                  const char *error)
++core_event_error (void       *user_data,
++                  uint32_t    id,
++		  int         seq,
++		  int         res,
++		  const char *message)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  switch (state)
++  if (id == PW_ID_CORE)
+     {
+-    case PW_REMOTE_STATE_ERROR:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "%s", error);
+-        }
++      g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
++                 "%s", message);
+       pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "Disconnected");
+-        }
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    default:
+-      g_warning ("Unknown PipeWire state");
+-      break;
+     }
+ }
+ 
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
+-};
+-
+ static void
+ core_event_done (void *user_data,
+-                 uint32_t seq)
++                 uint32_t id, int seq)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  if (remote->sync_seq == seq)
++  if (id == PW_ID_CORE && remote->sync_seq == seq)
+     pw_main_loop_quit (remote->loop);
+ }
+ 
+-static const struct pw_core_proxy_events core_events = {
+-  PW_VERSION_CORE_PROXY_EVENTS,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = core_event_error,
+   .done = core_event_done,
+ };
+ 
+@@ -237,8 +209,8 @@ void
+ pipewire_remote_destroy (PipeWireRemote *remote)
+ {
+   g_clear_pointer (&remote->globals, g_hash_table_destroy);
+-  g_clear_pointer (&remote->remote, pw_remote_destroy);
+-  g_clear_pointer (&remote->core, pw_core_destroy);
++  g_clear_pointer (&remote->core, pw_core_disconnect);
++  g_clear_pointer (&remote->context, pw_context_destroy);
+   g_clear_pointer (&remote->loop, pw_main_loop_destroy);
+   g_clear_error (&remote->error);
+ 
+@@ -307,68 +279,31 @@ pipewire_remote_new_sync (struct pw_properties *pipewire_properties,
+       return NULL;
+     }
+ 
+-  remote->core = pw_core_new (pw_main_loop_get_loop (remote->loop), NULL);
+-  if (!remote->core)
++  remote->context = pw_context_new (pw_main_loop_get_loop (remote->loop), NULL, 0);
++  if (!remote->context)
+     {
+       pipewire_remote_destroy (remote);
+       pw_properties_free (pipewire_properties);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire core");
++                   "Couldn't create PipeWire context");
+       return NULL;
+     }
+ 
+-  remote->remote = pw_remote_new (remote->core, pipewire_properties, 0);
+-  if (!remote->remote)
++  remote->core = pw_context_connect (remote->context, pipewire_properties, 0);
++  if (!remote->core)
+     {
+       pipewire_remote_destroy (remote);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire remote");
++                   "Couldn't connect to PipeWire");
+       return NULL;
+     }
+ 
+   remote->globals = g_hash_table_new_full (NULL, NULL, NULL, g_free);
+ 
+-  pw_remote_add_listener (remote->remote,
+-                          &remote->remote_listener,
+-                          &remote_events,
+-                          remote);
+-
+-  if (pw_remote_connect (remote->remote) != 0)
+-    {
+-      pipewire_remote_destroy (remote);
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect PipeWire remote");
+-      return NULL;
+-    }
+-
+-  pw_main_loop_run (remote->loop);
+-
+-  switch (pw_remote_get_state (remote->remote, NULL))
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      *error = g_steal_pointer (&remote->error);
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "PipeWire loop stopped unexpectedly");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      break;
+-    default:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Unexpected PipeWire state");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    }
+-
+-  remote->core_proxy = pw_remote_get_core_proxy (remote->remote);
+-  pw_core_proxy_add_listener (remote->core_proxy,
+-                              &remote->core_listener,
+-                              &core_events,
+-                              remote);
++  pw_core_add_listener (remote->core,
++                        &remote->core_listener,
++                        &core_events,
++                        remote);
+ 
+   if (!discover_node_factory_sync (remote, error))
+     {
+diff --git src/pipewire.h src/pipewire.h
+index 0f1bf54..bf48d5e 100644
+--- src/pipewire.h
++++ src/pipewire.h
+@@ -32,7 +32,7 @@ typedef struct _PipeWireGlobal
+ 
+ typedef void (* PipeWireGlobalAddedCallback) (PipeWireRemote *remote,
+                                               uint32_t id,
+-                                              uint32_t type,
++                                              const char *type,
+                                               const struct spa_dict *props,
+                                               gpointer user_data);
+ 
+@@ -43,13 +43,11 @@ typedef void (* PipeWireGlobalRemovedCallback) (PipeWireRemote *remote,
+ struct _PipeWireRemote
+ {
+   struct pw_main_loop *loop;
++  struct pw_context *context;
+   struct pw_core *core;
+-  struct pw_remote *remote;
+-  struct spa_hook remote_listener;
+-
+-  struct pw_core_proxy *core_proxy;
+   struct spa_hook core_listener;
+-  uint32_t sync_seq;
++
++  int sync_seq;
+ 
+   struct spa_hook registry_listener;
+ 
+diff --git src/screen-cast.c src/screen-cast.c
+index 7881ddc..1677050 100644
+--- src/screen-cast.c
++++ src/screen-cast.c
+@@ -31,10 +31,10 @@
+ #include "xdp-impl-dbus.h"
+ #include "xdp-utils.h"
+ 
+-#define PERMISSION_ITEM(item_key, item_value) \
+-  ((struct spa_dict_item) { \
+-    .key = item_key, \
+-    .value = item_value \
++#define PERMISSION_ITEM(item_id, item_permissions) \
++  ((struct pw_permission) { \
++    .id = item_id, \
++    .permissions = item_permissions \
+   })
+ 
+ typedef struct _ScreenCast ScreenCast;
+@@ -517,42 +517,9 @@ screen_cast_stream_get_pipewire_node_id (ScreenCastStream *stream)
+   return stream->id;
+ }
+ 
+-static void
+-append_parent_permissions (PipeWireRemote *remote,
+-                           GArray *permission_items,
+-                           GList **string_stash,
+-                           PipeWireGlobal *global,
+-                           const char *permission)
+-{
+-  PipeWireGlobal *parent;
+-  char *parent_permission_value;
+-
+-  if (global->parent_id == 0)
+-    return;
+-
+-  parent = g_hash_table_lookup (remote->globals, GINT_TO_POINTER (global->parent_id));
+-
+-  if (parent->permission_set)
+-    return;
+-  parent->permission_set = TRUE;
+-
+-  append_parent_permissions (remote, permission_items, string_stash,
+-                             parent, permission);
+-
+-  parent_permission_value = g_strdup_printf ("%u:%s",
+-                                             global->parent_id,
+-                                             permission);
+-  *string_stash = g_list_prepend (*string_stash, parent_permission_value);
+-
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       parent_permission_value));
+-}
+-
+ static void
+ append_stream_permissions (PipeWireRemote *remote,
+                            GArray *permission_items,
+-                           GList **string_stash,
+                            GList *streams)
+ {
+   GList *l;
+@@ -561,21 +528,10 @@ append_stream_permissions (PipeWireRemote *remote,
+     {
+       ScreenCastStream *stream = l->data;
+       uint32_t stream_id;
+-      PipeWireGlobal *stream_global;
+-      char *stream_permission_value;
+ 
+       stream_id = screen_cast_stream_get_pipewire_node_id (stream);
+-      stream_global = g_hash_table_lookup (remote->globals,
+-                                           GINT_TO_POINTER (stream_id));
+-
+-      append_parent_permissions (remote, permission_items, string_stash,
+-                                 stream_global, "r--");
+-
+-      stream_permission_value = g_strdup_printf ("%u:rwx", stream_id);
+-      *string_stash = g_list_prepend (*string_stash, stream_permission_value);
+       g_array_append_val (permission_items,
+-                          PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                           stream_permission_value));
++                          PERMISSION_ITEM (stream_id, PW_PERM_RWX));
+     }
+ }
+ 
+@@ -587,9 +543,6 @@ open_pipewire_screen_cast_remote (const char *app_id,
+   struct pw_properties *pipewire_properties;
+   PipeWireRemote *remote;
+   g_autoptr(GArray) permission_items = NULL;
+-  char *node_factory_permission_string;
+-  GList *string_stash = NULL;
+-  struct spa_dict *permission_dict;
+   PipeWireGlobal *node_global;
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.app_id", app_id,
+@@ -603,48 +556,31 @@ open_pipewire_screen_cast_remote (const char *app_id,
+ 
+   permission_items = g_array_new (FALSE, TRUE, sizeof (struct spa_dict_item));
+ 
+-  /*
+-   * Hide all existing and future nodes (except the ones we explicitly list below.
+-   */
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_EXISTING,
+-                                       "---"));
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_DEFAULT,
+-                                       "---"));
+-
+   /*
+    * PipeWire:Interface:Core
+    * Needs rwx to be able create the sink node using the create-object method
+    */
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       "0:rwx"));
++                      PERMISSION_ITEM (PW_ID_CORE, PW_PERM_RWX));
+ 
+   /*
+    * PipeWire:Interface:NodeFactory
+    * Needs r-- so it can be passed to create-object when creating the sink node.
+    */
+-  node_factory_permission_string = g_strdup_printf ("%d:r--",
+-                                                    remote->node_factory_id);
+-  string_stash = g_list_prepend (string_stash, node_factory_permission_string);
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       node_factory_permission_string));
+-  node_global = g_hash_table_lookup (remote->globals,
+-                                     GINT_TO_POINTER (remote->node_factory_id));
+-  append_parent_permissions (remote, permission_items, &string_stash,
+-                             node_global, "r--");
++                      PERMISSION_ITEM (remote->node_factory_id, PW_PERM_R));
+ 
+-  append_stream_permissions (remote, permission_items, &string_stash, streams);
++  append_stream_permissions (remote, permission_items, streams);
+ 
+-  permission_dict =
+-    &SPA_DICT_INIT ((struct spa_dict_item *) permission_items->data,
+-                    permission_items->len);
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             permission_dict);
++  /*
++   * Hide all existing and future nodes (except the ones we explicitly list above).
++   */
++  g_array_append_val (permission_items,
++                      PERMISSION_ITEM (PW_ID_ANY, 0));
+ 
+-  g_list_free_full (string_stash, g_free);
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                permission_items->len,
++                                (const struct pw_permission *)permission_items->data);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -943,7 +879,7 @@ handle_open_pipewire_remote (XdpScreenCast *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
diff --git a/srcpkgs/xdg-desktop-portal/template b/srcpkgs/xdg-desktop-portal/template
index eb8a4602f5d..1136b6a6e0e 100644
--- a/srcpkgs/xdg-desktop-portal/template
+++ b/srcpkgs/xdg-desktop-portal/template
@@ -1,10 +1,10 @@
 # Template file for 'xdg-desktop-portal'
 pkgname=xdg-desktop-portal
 version=1.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-pipewire --enable-geoclue --disable-libportal"
-hostmakedepends="pkg-config glib-devel"
+hostmakedepends="automake libtool gettext-devel pkg-config glib-devel"
 makedepends="flatpak-devel fuse-devel pipewire-devel geoclue2-devel"
 short_desc="Portal frontend service for Flatpak"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -13,6 +13,10 @@ homepage="https://github.com/flatpak/xdg-desktop-portal"
 distfiles="https://github.com/flatpak/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.xz"
 checksum=883c9c9a925e48af54812b5347f546dd776ec2e27076a83d5a8126af6bafb9da
 
+pre_configure() {
+	autoreconf -vfi
+}
+
 post_install() {
 	rm -rf "${DESTDIR}/usr/lib/systemd"
 }

From 79616eaa8fe83b5a30efff504789a32916135fe7 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Thu, 30 Apr 2020 06:17:17 +0900
Subject: [PATCH 4/4] mutter: rebuild for pipewire-0.3

---
 srcpkgs/mutter/patches/pipewire-0.3.patch | 521 ++++++++++++++++++++++
 srcpkgs/mutter/template                   |   2 +-
 2 files changed, 522 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/mutter/patches/pipewire-0.3.patch

diff --git a/srcpkgs/mutter/patches/pipewire-0.3.patch b/srcpkgs/mutter/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..ebff65fba85
--- /dev/null
+++ b/srcpkgs/mutter/patches/pipewire-0.3.patch
@@ -0,0 +1,521 @@
+Build mutter against pipewire-0.3, based on a patch at:
+https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1062
+--- meson.build
++++ meson.build
+@@ -50,7 +50,7 @@ libinput_req = '>= 1.7'
+ gbm_req = '>= 10.3'
+
+ # screen cast version requirements
+-libpipewire_req = '>= 0.2.5'
++libpipewire_req = '>= 0.3.0'
+
+ gnome = import('gnome')
+ pkg = import('pkgconfig')
+@@ -241,7 +241,7 @@ endif
+
+ have_remote_desktop = get_option('remote_desktop')
+ if have_remote_desktop
+-  libpipewire_dep = dependency('libpipewire-0.2', version: libpipewire_req)
++  libpipewire_dep = dependency('libpipewire-0.3', version: libpipewire_req)
+ endif
+
+ have_introspection = get_option('introspection')
+diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
+index 82c5cba436..ba1ce94a7e 100644
+--- src/backends/meta-screen-cast-stream-src.c
++++ src/backends/meta-screen-cast-stream-src.c
+@@ -29,6 +29,7 @@
+ #include <spa/param/props.h>
+ #include <spa/param/format-utils.h>
+ #include <spa/param/video/format-utils.h>
++#include <spa/utils/result.h>
+ #include <stdint.h>
+ #include <sys/mman.h>
+
+@@ -62,15 +63,6 @@ enum
+
+ static guint signals[N_SIGNALS];
+
+-typedef struct _MetaSpaType
+-{
+-  struct spa_type_media_type media_type;
+-  struct spa_type_media_subtype media_subtype;
+-  struct spa_type_format_video format_video;
+-  struct spa_type_video_format video_format;
+-  uint32_t meta_cursor;
+-} MetaSpaType;
+-
+ typedef struct _MetaPipeWireSource
+ {
+   GSource base;
+@@ -82,19 +74,19 @@ typedef struct _MetaScreenCastStreamSrcPrivate
+ {
+   MetaScreenCastStream *stream;
+
++  struct pw_context *pipewire_context;
+   struct pw_core *pipewire_core;
+-  struct pw_remote *pipewire_remote;
+-  struct pw_type *pipewire_type;
+   MetaPipeWireSource *pipewire_source;
+-  struct spa_hook pipewire_remote_listener;
++  struct spa_hook pipewire_core_listener;
+
+   gboolean is_enabled;
+
+   struct pw_stream *pipewire_stream;
+   struct spa_hook pipewire_stream_listener;
++  uint32_t node_id;
+
+-  MetaSpaType spa_type;
+   struct spa_video_info_raw video_format;
++  int video_stride;
+
+   uint64_t last_frame_timestamp_us;
+
+@@ -112,8 +104,6 @@ G_DEFINE_TYPE_WITH_CODE (MetaScreenCastStreamSrc,
+                                                 meta_screen_cast_stream_src_init_initable_iface)
+                          G_ADD_PRIVATE (MetaScreenCastStreamSrc))
+
+-#define PROP_RANGE(min, max) 2, (min), (max)
+-
+ static void
+ meta_screen_cast_stream_src_get_specs (MetaScreenCastStreamSrc *src,
+                                        int                     *width,
+@@ -286,9 +276,6 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+                                                               int                      x,
+                                                               int                      y)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+
+   spa_meta_cursor->id = 1;
+@@ -300,7 +287,7 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   spa_meta_cursor->hotspot.x = 0;
+@@ -317,9 +304,6 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+                                                         int                      y,
+                                                         float                    scale)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   CoglTexture *cursor_texture;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+   int hotspot_x, hotspot_y;
+@@ -346,7 +330,7 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
+@@ -382,12 +366,10 @@ static void
+ add_cursor_metadata (MetaScreenCastStreamSrc *src,
+                      struct spa_buffer       *spa_buffer)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_cursor *spa_meta_cursor;
+
+-  spa_meta_cursor = spa_buffer_find_meta (spa_buffer, spa_type->meta_cursor);
++  spa_meta_cursor = spa_buffer_find_meta_data (spa_buffer, SPA_META_Cursor,
++                                               sizeof (*spa_meta_cursor));
+   if (spa_meta_cursor)
+     meta_screen_cast_stream_src_set_cursor_metadata (src, spa_meta_cursor);
+ }
+@@ -447,14 +429,14 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+     {
+       data = spa_buffer->datas[0].data;
+     }
+-  else if (spa_buffer->datas[0].type == priv->pipewire_type->data.MemFd)
++  else if (spa_buffer->datas[0].type == SPA_DATA_MemFd)
+     {
+       map = mmap (NULL, spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset,
+                   PROT_READ | PROT_WRITE, MAP_SHARED,
+                   spa_buffer->datas[0].fd, 0);
+       if (map == MAP_FAILED)
+         {
+-          g_warning ("Failed to mmap pipewire stream buffer: %s\n",
++          g_warning ("Failed to mmap pipewire stream buffer: %s",
+                      strerror (errno));
+           return;
+         }
+@@ -469,28 +451,30 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+
+   if (meta_screen_cast_stream_src_record_frame (src, data))
+     {
+-      struct spa_meta_video_crop *spa_meta_video_crop;
++      struct spa_meta_region *spa_meta_video_crop;
+
+       spa_buffer->datas[0].chunk->size = spa_buffer->datas[0].maxsize;
++      spa_buffer->datas[0].chunk->stride = priv->video_stride;
+
+       /* Update VideoCrop if needed */
+       spa_meta_video_crop =
+-        spa_buffer_find_meta (spa_buffer, priv->pipewire_type->meta.VideoCrop);
++        spa_buffer_find_meta_data (spa_buffer, SPA_META_VideoCrop,
++                                   sizeof (*spa_meta_video_crop));
+       if (spa_meta_video_crop)
+         {
+           if (meta_screen_cast_stream_src_get_videocrop (src, &crop_rect))
+             {
+-              spa_meta_video_crop->x = crop_rect.x;
+-              spa_meta_video_crop->y = crop_rect.y;
+-              spa_meta_video_crop->width = crop_rect.width;
+-              spa_meta_video_crop->height = crop_rect.height;
++              spa_meta_video_crop->region.position.x = crop_rect.x;
++              spa_meta_video_crop->region.position.y = crop_rect.y;
++              spa_meta_video_crop->region.size.width = crop_rect.width;
++              spa_meta_video_crop->region.size.height = crop_rect.height;
+             }
+           else
+             {
+-              spa_meta_video_crop->x = 0;
+-              spa_meta_video_crop->y = 0;
+-              spa_meta_video_crop->width = priv->stream_width;
+-              spa_meta_video_crop->height = priv->stream_height;
++              spa_meta_video_crop->region.position.x = 0;
++              spa_meta_video_crop->region.position.y = 0;
++              spa_meta_video_crop->region.size.width = priv->stream_width;
++              spa_meta_video_crop->region.size.height = priv->stream_height;
+             }
+         }
+     }
+@@ -555,7 +539,6 @@ on_stream_state_changed (void                 *data,
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  uint32_t node_id;
+
+   switch (state)
+     {
+@@ -563,14 +546,12 @@ on_stream_state_changed (void                 *data,
+       g_warning ("pipewire stream error: %s", error_message);
+       meta_screen_cast_stream_src_notify_closed (src);
+       break;
+-    case PW_STREAM_STATE_CONFIGURE:
+-      node_id = pw_stream_get_node_id (priv->pipewire_stream);
+-      g_signal_emit (src, signals[READY], 0, (unsigned int) node_id);
+-      break;
+-    case PW_STREAM_STATE_UNCONNECTED:
+-    case PW_STREAM_STATE_CONNECTING:
+-    case PW_STREAM_STATE_READY:
+     case PW_STREAM_STATE_PAUSED:
++      if (priv->node_id == SPA_ID_INVALID && priv->pipewire_stream)
++        {
++          priv->node_id = pw_stream_get_node_id (priv->pipewire_stream);
++          g_signal_emit (src, signals[READY], 0, (unsigned int) priv->node_id);
++        }
+       if (meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_disable (src);
+       break;
+@@ -578,68 +559,69 @@ on_stream_state_changed (void                 *data,
+       if (!meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_enable (src);
+       break;
++    case PW_STREAM_STATE_UNCONNECTED:
++    case PW_STREAM_STATE_CONNECTING:
++      break;
+     }
+ }
+
+ static void
+-on_stream_format_changed (void                 *data,
+-                          const struct spa_pod *format)
++on_stream_param_changed (void                 *data,
++                         uint32_t              id,
++                         const struct spa_pod *format)
+ {
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   uint8_t params_buffer[1024];
+   int32_t width, height, stride, size;
+   struct spa_pod_builder pod_builder;
+   const struct spa_pod *params[3];
+   const int bpp = 4;
+
+-  if (!format)
+-    {
+-      pw_stream_finish_format (priv->pipewire_stream, 0, NULL, 0);
+-      return;
+-    }
++  if (!format || id != SPA_PARAM_Format)
++    return;
+
+   spa_format_video_raw_parse (format,
+-                              &priv->video_format,
+-                              &priv->spa_type.format_video);
++                              &priv->video_format);
+
+   width = priv->video_format.size.width;
+   height = priv->video_format.size.height;
+   stride = SPA_ROUND_UP_N (width * bpp, 4);
+   size = height * stride;
+
++  priv->video_stride = stride;
++
+   pod_builder = SPA_POD_BUILDER_INIT (params_buffer, sizeof (params_buffer));
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idBuffers, pipewire_type->param_buffers.Buffers,
+-    ":", pipewire_type->param_buffers.size, "i", size,
+-    ":", pipewire_type->param_buffers.stride, "i", stride,
+-    ":", pipewire_type->param_buffers.buffers, "iru", 16, PROP_RANGE (2, 16),
+-    ":", pipewire_type->param_buffers.align, "i", 16);
+-
+-  params[1] = spa_pod_builder_object (
++    SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
++    SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int (16, 2, 16),
++    SPA_PARAM_BUFFERS_blocks, SPA_POD_Int (1),
++    SPA_PARAM_BUFFERS_size, SPA_POD_Int (size),
++    SPA_PARAM_BUFFERS_stride, SPA_POD_Int (stride),
++    SPA_PARAM_BUFFERS_align, SPA_POD_Int (16));
++
++  params[1] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", pipewire_type->meta.VideoCrop,
+-    ":", pipewire_type->param_meta.size, "i", sizeof (struct spa_meta_video_crop));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_VideoCrop),
++    SPA_PARAM_META_size, SPA_POD_Int (sizeof (struct spa_meta_region)));
+
+-  params[2] = spa_pod_builder_object (
++  params[2] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", priv->spa_type.meta_cursor,
+-    ":", pipewire_type->param_meta.size, "i", CURSOR_META_SIZE (64, 64));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_Cursor),
++    SPA_PARAM_META_size, SPA_POD_Int (CURSOR_META_SIZE (64, 64)));
+
+-  pw_stream_finish_format (priv->pipewire_stream, 0,
+-                           params, G_N_ELEMENTS (params));
++  pw_stream_update_params (priv->pipewire_stream, params, G_N_ELEMENTS (params));
+ }
+
+ static const struct pw_stream_events stream_events = {
+   PW_VERSION_STREAM_EVENTS,
+   .state_changed = on_stream_state_changed,
+-  .format_changed = on_stream_format_changed,
++  .param_changed = on_stream_param_changed,
+ };
+
+ static struct pw_stream *
+@@ -652,8 +634,6 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   uint8_t buffer[1024];
+   struct spa_pod_builder pod_builder =
+     SPA_POD_BUILDER_INIT (buffer, sizeof (buffer));
+-  MetaSpaType *spa_type = &priv->spa_type;
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   float frame_rate;
+   MetaFraction frame_rate_fraction;
+   struct spa_fraction max_framerate;
+@@ -661,7 +641,9 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   const struct spa_pod *params[1];
+   int result;
+
+-  pipewire_stream = pw_stream_new (priv->pipewire_remote,
++  priv->node_id = SPA_ID_INVALID;
++
++  pipewire_stream = pw_stream_new (priv->pipewire_core,
+                                    "meta-screen-cast-src",
+                                    NULL);
+   if (!pipewire_stream)
+@@ -682,17 +664,17 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   max_framerate = SPA_FRACTION (frame_rate_fraction.num,
+                                 frame_rate_fraction.denom);
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idEnumFormat, pipewire_type->spa_format,
+-    "I", spa_type->media_type.video,
+-    "I", spa_type->media_subtype.raw,
+-    ":", spa_type->format_video.format, "I", spa_type->video_format.BGRx,
+-    ":", spa_type->format_video.size, "R", &SPA_RECTANGLE (priv->stream_width,
+-                                                           priv->stream_height),
+-    ":", spa_type->format_video.framerate, "F", &SPA_FRACTION (0, 1),
+-    ":", spa_type->format_video.max_framerate, "Fru", &max_framerate,
+-                                                      PROP_RANGE (&min_framerate,
++    SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
++    SPA_FORMAT_mediaType, SPA_POD_Id (SPA_MEDIA_TYPE_video),
++    SPA_FORMAT_mediaSubtype, SPA_POD_Id (SPA_MEDIA_SUBTYPE_raw),
++    SPA_FORMAT_VIDEO_format, SPA_POD_Id (SPA_VIDEO_FORMAT_BGRx),
++    SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle (&SPA_RECTANGLE (priv->stream_width,
++                                                              priv->stream_height)),
++    SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction (&SPA_FRACTION (0, 1)),
++    SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction (&max_framerate,
++                                                                  &min_framerate,
+                                                                   &max_framerate));
+
+   pw_stream_add_listener (pipewire_stream,
+@@ -702,7 +684,7 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+
+   result = pw_stream_connect (pipewire_stream,
+                               PW_DIRECTION_OUTPUT,
+-                              NULL,
++                              SPA_ID_INVALID,
+                               (PW_STREAM_FLAG_DRIVER |
+                                PW_STREAM_FLAG_MAP_BUFFERS),
+                               params, G_N_ELEMENTS (params));
+@@ -717,40 +699,18 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+ }
+
+ static void
+-on_state_changed (void                 *data,
+-                  enum pw_remote_state  old,
+-                  enum pw_remote_state  state,
+-                  const char           *error_message)
++on_core_error (void       *data,
++               uint32_t    id,
++	       int         seq,
++	       int         res,
++	       const char *message)
+ {
+   MetaScreenCastStreamSrc *src = data;
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_stream *pipewire_stream;
+-  GError *error = NULL;
+
+-  switch (state)
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-      g_warning ("pipewire remote error: %s\n", error_message);
+-      meta_screen_cast_stream_src_notify_closed (src);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pipewire_stream = create_pipewire_stream (src, &error);
+-      if (!pipewire_stream)
+-        {
+-          g_warning ("Could not create pipewire stream: %s", error->message);
+-          g_error_free (error);
+-          meta_screen_cast_stream_src_notify_closed (src);
+-        }
+-      else
+-        {
+-          priv->pipewire_stream = pipewire_stream;
+-        }
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    }
++  g_warning ("pipewire remote error: id:%u %s", id, message);
++
++  if (id == PW_ID_CORE && res == -EPIPE)
++    meta_screen_cast_stream_src_notify_closed (src);
+ }
+
+ static gboolean
+@@ -793,17 +753,6 @@ static GSourceFuncs pipewire_source_funcs =
+   pipewire_loop_source_finalize
+ };
+
+-static void
+-init_spa_type (MetaSpaType         *type,
+-               struct spa_type_map *map)
+-{
+-  spa_type_media_type_map (map, &type->media_type);
+-  spa_type_media_subtype_map (map, &type->media_subtype);
+-  spa_type_format_video_map (map, &type->format_video);
+-  spa_type_video_format_map (map, &type->video_format);
+-  type->meta_cursor = spa_type_map_get_id(map, SPA_TYPE_META__Cursor);
+-}
+-
+ static MetaPipeWireSource *
+ create_pipewire_source (void)
+ {
+@@ -829,9 +778,9 @@ create_pipewire_source (void)
+   return pipewire_source;
+ }
+
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = on_core_error,
+ };
+
+ static gboolean
+@@ -851,37 +800,31 @@ meta_screen_cast_stream_src_initable_init (GInitable     *initable,
+       return FALSE;
+     }
+
+-  priv->pipewire_core = pw_core_new (priv->pipewire_source->pipewire_loop,
+-                                     NULL);
+-  if (!priv->pipewire_core)
++  priv->pipewire_context = pw_context_new (priv->pipewire_source->pipewire_loop,
++                                           NULL, 0);
++  if (!priv->pipewire_context)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Failed to create pipewire core");
++                   "Failed to create pipewire context");
+       return FALSE;
+     }
+
+-  priv->pipewire_remote = pw_remote_new (priv->pipewire_core, NULL, 0);
+-  if (!priv->pipewire_remote)
++  priv->pipewire_core = pw_context_connect (priv->pipewire_context, NULL, 0);
++  if (!priv->pipewire_core)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't creat pipewire remote");
++                   "Couldn't connect pipewire context");
+       return FALSE;
+     }
+
+-  pw_remote_add_listener (priv->pipewire_remote,
+-                          &priv->pipewire_remote_listener,
+-                          &remote_events,
+-                          src);
++  pw_core_add_listener (priv->pipewire_core,
++                        &priv->pipewire_core_listener,
++                        &core_events,
++                        src);
+
+-  priv->pipewire_type = pw_core_get_type (priv->pipewire_core);
+-  init_spa_type (&priv->spa_type, priv->pipewire_type->map);
+-
+-  if (pw_remote_connect (priv->pipewire_remote) != 0)
+-    {
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect pipewire remote");
+-      return FALSE;
+-    }
++  priv->pipewire_stream = create_pipewire_stream (src, error);
++  if (!priv->pipewire_stream)
++    return FALSE;
+
+   return TRUE;
+ }
+@@ -912,8 +855,8 @@ meta_screen_cast_stream_src_finalize (GObject *object)
+     meta_screen_cast_stream_src_disable (src);
+
+   g_clear_pointer (&priv->pipewire_stream, pw_stream_destroy);
+-  g_clear_pointer (&priv->pipewire_remote, pw_remote_destroy);
+-  g_clear_pointer (&priv->pipewire_core, pw_core_destroy);
++  g_clear_pointer (&priv->pipewire_core, pw_core_disconnect);
++  g_clear_pointer (&priv->pipewire_context, pw_context_destroy);
+   g_source_destroy (&priv->pipewire_source->base);
+
+   G_OBJECT_CLASS (meta_screen_cast_stream_src_parent_class)->finalize (object);
diff --git a/srcpkgs/mutter/template b/srcpkgs/mutter/template
index 4e0bd32b67d..806a3bef9f0 100644
--- a/srcpkgs/mutter/template
+++ b/srcpkgs/mutter/template
@@ -1,7 +1,7 @@
 # Template file for 'mutter'
 pkgname=mutter
 version=3.34.1
-revision=2
+revision=3
 build_helper="gir"
 build_style=meson
 configure_args="-Degl_device=true -Dudev=true -Dnative_backend=true

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PR PATCH] [Updated] pipewire: update to 0.3.4
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (39 preceding siblings ...)
  2020-05-12 17:38 ` [PR PATCH] [Updated] " sirn
@ 2020-05-12 18:08 ` sirn
  2020-05-12 18:08 ` sirn
                   ` (10 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-05-12 18:08 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 785 bytes --]

There is an updated pull request by sirn against master on the void-packages repository

https://github.com/sirn/void-packages pipewire-update
https://github.com/void-linux/void-packages/pull/20413

pipewire: update to 0.3.4
This PR updates `pipewire` to 0.3.4 and also updating/patching all packages that depends on it. 

* `xdg-desktop-portal` includes a patch backported from 1.7.0 to allow 1.6.0 to build against pipewire-0.3 (1.7.x is prerelease)
* `xdg-desktop-portal-kde` already includes Pipewire 0.3 support and only requires revbump.
* `mutter` includes a patch backported from 3.35 to allow 3.34 to build against pipewire-0.3 (upgrading to >=3.35 also requires upgrading GNOME).

A patch file from https://github.com/void-linux/void-packages/pull/20413.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pipewire-update-20413.patch --]
[-- Type: text/x-diff, Size: 50839 bytes --]

From 3524da02f9cd321b740ffd841d23189ccee19530 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:23:52 +0900
Subject: [PATCH 1/4] pipewire: update to 0.3.4

---
 common/shlibs                  |  2 +-
 srcpkgs/alsa-pipewire          |  1 +
 srcpkgs/libjack-pipewire       |  1 +
 srcpkgs/libpulseaudio-pipewire |  1 +
 srcpkgs/pipewire/template      | 71 ++++++++++++++++++++++++++--------
 5 files changed, 58 insertions(+), 18 deletions(-)
 create mode 120000 srcpkgs/alsa-pipewire
 create mode 120000 srcpkgs/libjack-pipewire
 create mode 120000 srcpkgs/libpulseaudio-pipewire

diff --git a/common/shlibs b/common/shlibs
index 580a12d9c87..7b50a83dd25 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3204,7 +3204,7 @@ libarcan_shmif_ext.so.0.11 arcan-0.5.4.3_1
 libarcan_shmif_server.so.0.11 arcan-0.5.4.3_1
 libarcan_tui.so.0.11 arcan-0.5.4.3_1
 liblwipv6.so.2 lwipv6-1.5a_1
-libpipewire-0.2.so.1 libpipewire-0.2.2_1
+libpipewire-0.3.so.0 libpipewire-0.3.4_1
 libvolk.so.2.2.1 volk-2.2.1_1
 libgnuradio-runtime.so.3.8.0 gnuradio-3.8.0.0_1
 libgnuradio-pmt.so.3.8.0 gnuradio-3.8.0.0_1
diff --git a/srcpkgs/alsa-pipewire b/srcpkgs/alsa-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/alsa-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libjack-pipewire b/srcpkgs/libjack-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libjack-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libpulseaudio-pipewire b/srcpkgs/libpulseaudio-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libpulseaudio-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/pipewire/template b/srcpkgs/pipewire/template
index 7f646dad11d..7e0df31570b 100644
--- a/srcpkgs/pipewire/template
+++ b/srcpkgs/pipewire/template
@@ -1,26 +1,37 @@
 # Template file for 'pipewire'
 pkgname=pipewire
-version=0.2.7
+version=0.3.5
 revision=1
 build_style=meson
-configure_args="-Dman=true -Dgstreamer=enabled -Ddocs=true -Dsystemd=false"
+configure_args="-Dman=true -Dgstreamer=true -Ddocs=true -Dsystemd=false
+ -Dbluez5=true -Dffmpeg=true -Dpipewire-alsa=true -Dpipewire-jack=true
+ -Dpipewire-pulseaudio=true"
 hostmakedepends="doxygen graphviz pkg-config xmltoman"
 makedepends="SDL2-devel ffmpeg-devel gst-plugins-base1-devel jack-devel
- sbc-devel v4l-utils-devel libva-devel"
+ sbc-devel v4l-utils-devel libva-devel libbluetooth-devel"
 short_desc="Server and user space API to deal with multimedia pipelines"
-maintainer="Orphaned <orphan@voidlinux.org>"
-#Next release will probably change to MIT, currently listed in master
-license="LGPL-2.1-only, GPL-2.0-only "
+maintainer="Kridsada Thanabulpong <sirn@ogsite.net>"
+license="MIT"
 homepage="https://pipewire.org/"
-changelog="https://raw.githubusercontent.com/PipeWire/pipewire/master/NEWS"
-distfiles="https://github.com/PipeWire/pipewire/archive/${version}.tar.gz"
-checksum=bfaa0f6ae6c0791e2e0b59234d399753bf24f1b33dbf587682363a8463dd8df1
+changelog="https://gitlab.freedesktop.org/pipewire/pipewire/-/raw/master/NEWS"
+distfiles="https://gitlab.freedesktop.org/pipewire/pipewire/-/archive/${version}/pipewire-${version}.tar.gz"
+checksum=c8cef9ce93dee328187b274e213dbecfe2df8ecc45bba2bc21d470112b2df3f6
 conf_files="/etc/pipewire/pipewire.conf"
 
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+	LDFLAGS+=" -latomic"
+fi
+
+post_install() {
+	vlicense LICENSE
+}
+
 libpipewire_package() {
 	short_desc+=" - pipewire library"
 	pkg_install() {
-		vmove "usr/lib/libpipewire-0.2.so.*"
+		vmove "usr/lib/libpipewire-0.3.so.*"
+		vmove "usr/lib/pipewire-0.3/*.so"
 	}
 }
 
@@ -28,25 +39,25 @@ pipewire-devel_package() {
 	depends="libpipewire-${version}_${revision}"
 	short_desc+=" - pipewire and libspa development files"
 	pkg_install() {
-		vmove usr/include/pipewire
-		vmove usr/include/spa
-		vmove usr/lib/pkgconfig/libpipewire-0.2.pc
-		vmove usr/lib/pkgconfig/libspa-0.1.pc
-		vmove usr/lib/libpipewire-0.2.so
+		vmove usr/include/pipewire-0.3
+		vmove usr/include/spa-0.2
+		vmove usr/lib/pkgconfig/libpipewire-0.3.pc
+		vmove usr/lib/pkgconfig/libspa-0.2.pc
+		vmove usr/lib/libpipewire-0.3.so
 	}
 }
 
 libspa-ffmpeg_package() {
 	short_desc+=" - ffmpeg plugins"
 	pkg_install() {
-		vmove usr/lib/spa/ffmpeg
+		vmove usr/lib/spa-0.2/ffmpeg
 	}
 }
 
 libspa-bluetooth_package() {
 	short_desc+=" - bluetooth plugins"
 	pkg_install() {
-		vmove usr/lib/spa/bluez5
+		vmove usr/lib/spa-0.2/bluez5
 	}
 }
 
@@ -57,6 +68,32 @@ gstreamer1-pipewire_package() {
 	}
 }
 
+libpulseaudio-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - PulseAudio client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/pulse
+		vmove usr/bin/pw-pulse
+	}
+}
+
+alsa-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - ALSA client library"
+	pkg_install() {
+		vmove usr/lib/alsa-lib
+	}
+}
+
+libjack-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - JACK client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/jack
+		vmove usr/bin/pw-jack
+	}
+}
+
 pipewire-doc_package() {
 	archs=noarch
 	short_desc+=" - documentation"

From aca77ef246d485099a6a6e1bede8203f1e0f1b21 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:46 +0900
Subject: [PATCH 2/4] xdg-desktop-portal-kde: rebuild for pipewire-0.3

---
 srcpkgs/xdg-desktop-portal-kde/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xdg-desktop-portal-kde/template b/srcpkgs/xdg-desktop-portal-kde/template
index 7a2aaf16b96..574e28504b7 100644
--- a/srcpkgs/xdg-desktop-portal-kde/template
+++ b/srcpkgs/xdg-desktop-portal-kde/template
@@ -1,7 +1,7 @@
 # Template file for 'xdg-desktop-portal-kde'
 pkgname=xdg-desktop-portal-kde
 version=5.18.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules qt5-qmake qt5-host-tools kcoreaddons gettext"
 makedepends="glib-devel kio-devel kwayland-devel libepoxy-devel pipewire-devel

From 057698827f923050f31549fe7829f5cc32264744 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:26 +0900
Subject: [PATCH 3/4] xdg-desktop-portal: rebuild for pipewire-0.3

---
 .../patches/pipewire-0.3.patch                | 551 ++++++++++++++++++
 srcpkgs/xdg-desktop-portal/template           |   8 +-
 2 files changed, 557 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch

diff --git a/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..94ebe083598
--- /dev/null
+++ b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
@@ -0,0 +1,551 @@
+From a38901e5e7f835efe7b7a06c55790c8c20bc91a2 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Tue, 14 Jan 2020 09:37:09 +0100
+Subject: [PATCH] PipeWire: update to 0.3 API
+
+---
+ configure.ac      |   2 +-
+ src/camera.c      |  24 ++++----
+ src/pipewire.c    | 141 +++++++++++++---------------------------------
+ src/pipewire.h    |  10 ++--
+ src/screen-cast.c |  98 ++++++--------------------------
+ 5 files changed, 72 insertions(+), 203 deletions(-)
+
+diff --git configure.ac configure.ac
+index 89902fa..62d7960 100644
+--- configure.ac
++++ configure.ac
+@@ -97,7 +97,7 @@ AC_ARG_ENABLE(pipewire,
+ 	      [AS_HELP_STRING([--enable-pipewire],[Enable PipeWire support. Needed for screen cast portal])],
+ 	      enable_pipewire=$enableval, enable_pipewire=yes)
+ if test x$enable_pipewire = xyes ; then
+-	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.2 >= 0.2.6])
++	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.3 >= 0.2.90])
+ 	AC_DEFINE([HAVE_PIPEWIRE],[1], [Define to enable PipeWire support])
+ fi
+ AM_CONDITIONAL([HAVE_PIPEWIRE],[test "$enable_pipewire" = "yes"])
+diff --git src/camera.c src/camera.c
+index c2b392c..20fe3aa 100644
+--- src/camera.c
++++ src/camera.c
+@@ -141,7 +141,7 @@ open_pipewire_camera_remote (const char *app_id,
+                              GError **error)
+ {
+   PipeWireRemote *remote;
+-  struct spa_dict_item permission_items[1];
++  struct pw_permission permission_items[2];
+   struct pw_properties *pipewire_properties;
+ 
+   pipewire_properties =
+@@ -158,12 +158,12 @@ open_pipewire_camera_remote (const char *app_id,
+    * Hide all existing and future nodes by default. PipeWire will use the
+    * permission store to set up permissions.
+    */
+-  permission_items[0].key = PW_CORE_PROXY_PERMISSIONS_DEFAULT;
+-  permission_items[0].value = "---";
++  permission_items[0] = PW_PERMISSION_INIT (PW_ID_CORE, PW_PERM_RWX);
++  permission_items[1] = PW_PERMISSION_INIT (PW_ID_ANY, 0);
+ 
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             &SPA_DICT_INIT (permission_items,
+-                                             G_N_ELEMENTS (permission_items)));
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                G_N_ELEMENTS (permission_items),
++                                permission_items);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -219,7 +219,7 @@ handle_open_pipewire_remote (XdpCamera *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
+@@ -250,29 +250,28 @@ camera_iface_init (XdpCameraIface *iface)
+ static void
+ global_added_cb (PipeWireRemote *remote,
+                  uint32_t id,
+-                 uint32_t type,
++                 const char *type,
+                  const struct spa_dict *props,
+                  gpointer user_data)
+ {
+   Camera *camera = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *media_class;
+   const struct spa_dict_item *media_role;
+ 
+-  if (type != core_type->node)
++  if (strcmp(type, PW_TYPE_INTERFACE_Node) != 0)
+     return;
+ 
+   if (!props)
+     return;
+ 
+-  media_class = spa_dict_lookup_item (props, "media.class");
++  media_class = spa_dict_lookup_item (props, PW_KEY_MEDIA_CLASS);
+   if (!media_class)
+     return;
+ 
+   if (g_strcmp0 (media_class->value, "Video/Source") != 0)
+     return;
+ 
+-  media_role = spa_dict_lookup_item (props, "media.role");
++  media_role = spa_dict_lookup_item (props, PW_KEY_MEDIA_ROLE);
+   if (!media_role)
+     return;
+ 
+@@ -342,6 +341,7 @@ create_pipewire_remote (Camera *camera,
+     }
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.is_portal", "true",
++                                           "portal.monitor", "Camera",
+                                            NULL);
+   camera->pipewire_remote = pipewire_remote_new_sync (pipewire_properties,
+                                                       global_added_cb,
+diff --git src/pipewire.c src/pipewire.c
+index 793a378..162cd55 100644
+--- src/pipewire.c
++++ src/pipewire.c
+@@ -21,6 +21,7 @@
+ #include <errno.h>
+ #include <glib.h>
+ #include <pipewire/pipewire.h>
++#include <spa/utils/result.h>
+ 
+ #include "pipewire.h"
+ 
+@@ -36,27 +37,25 @@ static gboolean is_pipewire_initialized = FALSE;
+ static void
+ registry_event_global (void *user_data,
+                        uint32_t id,
+-                       uint32_t parent_id,
+                        uint32_t permissions,
+-                       uint32_t type,
++                       const char *type,
+                        uint32_t version,
+                        const struct spa_dict *props)
+ {
+   PipeWireRemote *remote = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *factory_object_type;
+   PipeWireGlobal *global;
+ 
+   global = g_new0 (PipeWireGlobal, 1);
+   *global = (PipeWireGlobal) {
+-    .parent_id = parent_id,
++    .parent_id = id,
+   };
+ 
+   g_hash_table_insert (remote->globals, GINT_TO_POINTER (id), global);
+   if (remote->global_added_cb)
+     remote->global_added_cb (remote, id, type, props, remote->user_data);
+ 
+-  if (type != core_type->factory)
++  if (strcmp(type, PW_TYPE_INTERFACE_Factory) != 0)
+     return;
+ 
+   factory_object_type = spa_dict_lookup_item (props, "factory.type.name");
+@@ -81,8 +80,8 @@ registry_event_global_remove (void *user_data,
+   g_hash_table_remove (remote->globals, GINT_TO_POINTER (id));
+ }
+ 
+-static const struct pw_registry_proxy_events registry_events = {
+-  PW_VERSION_REGISTRY_PROXY_EVENTS,
++static const struct pw_registry_events registry_events = {
++  PW_VERSION_REGISTRY_EVENTS,
+   .global = registry_event_global,
+   .global_remove = registry_event_global_remove,
+ };
+@@ -90,7 +89,7 @@ static const struct pw_registry_proxy_events registry_events = {
+ void
+ pipewire_remote_roundtrip (PipeWireRemote *remote)
+ {
+-  pw_core_proxy_sync (remote->core_proxy, ++remote->sync_seq);
++  remote->sync_seq = pw_core_sync (remote->core, PW_ID_CORE, remote->sync_seq);
+   pw_main_loop_run (remote->loop);
+ }
+ 
+@@ -98,16 +97,13 @@ static gboolean
+ discover_node_factory_sync (PipeWireRemote *remote,
+                             GError **error)
+ {
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+-  struct pw_registry_proxy *registry_proxy;
++  struct pw_registry *registry;
+ 
+-  registry_proxy = pw_core_proxy_get_registry (remote->core_proxy,
+-                                               core_type->registry,
+-                                               PW_VERSION_REGISTRY, 0);
+-  pw_registry_proxy_add_listener (registry_proxy,
+-                                  &remote->registry_listener,
+-                                  &registry_events,
+-                                  remote);
++  registry = pw_core_get_registry (remote->core, PW_VERSION_REGISTRY, 0);
++  pw_registry_add_listener (registry,
++                            &remote->registry_listener,
++                            &registry_events,
++                            remote);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -122,59 +118,35 @@ discover_node_factory_sync (PipeWireRemote *remote,
+ }
+ 
+ static void
+-on_state_changed (void *user_data,
+-                  enum pw_remote_state old,
+-                  enum pw_remote_state state,
+-                  const char *error)
++core_event_error (void       *user_data,
++                  uint32_t    id,
++		  int         seq,
++		  int         res,
++		  const char *message)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  switch (state)
++  if (id == PW_ID_CORE)
+     {
+-    case PW_REMOTE_STATE_ERROR:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "%s", error);
+-        }
++      g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
++                 "%s", message);
+       pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "Disconnected");
+-        }
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    default:
+-      g_warning ("Unknown PipeWire state");
+-      break;
+     }
+ }
+ 
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
+-};
+-
+ static void
+ core_event_done (void *user_data,
+-                 uint32_t seq)
++                 uint32_t id, int seq)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  if (remote->sync_seq == seq)
++  if (id == PW_ID_CORE && remote->sync_seq == seq)
+     pw_main_loop_quit (remote->loop);
+ }
+ 
+-static const struct pw_core_proxy_events core_events = {
+-  PW_VERSION_CORE_PROXY_EVENTS,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = core_event_error,
+   .done = core_event_done,
+ };
+ 
+@@ -237,8 +209,8 @@ void
+ pipewire_remote_destroy (PipeWireRemote *remote)
+ {
+   g_clear_pointer (&remote->globals, g_hash_table_destroy);
+-  g_clear_pointer (&remote->remote, pw_remote_destroy);
+-  g_clear_pointer (&remote->core, pw_core_destroy);
++  g_clear_pointer (&remote->core, pw_core_disconnect);
++  g_clear_pointer (&remote->context, pw_context_destroy);
+   g_clear_pointer (&remote->loop, pw_main_loop_destroy);
+   g_clear_error (&remote->error);
+ 
+@@ -307,68 +279,31 @@ pipewire_remote_new_sync (struct pw_properties *pipewire_properties,
+       return NULL;
+     }
+ 
+-  remote->core = pw_core_new (pw_main_loop_get_loop (remote->loop), NULL);
+-  if (!remote->core)
++  remote->context = pw_context_new (pw_main_loop_get_loop (remote->loop), NULL, 0);
++  if (!remote->context)
+     {
+       pipewire_remote_destroy (remote);
+       pw_properties_free (pipewire_properties);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire core");
++                   "Couldn't create PipeWire context");
+       return NULL;
+     }
+ 
+-  remote->remote = pw_remote_new (remote->core, pipewire_properties, 0);
+-  if (!remote->remote)
++  remote->core = pw_context_connect (remote->context, pipewire_properties, 0);
++  if (!remote->core)
+     {
+       pipewire_remote_destroy (remote);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire remote");
++                   "Couldn't connect to PipeWire");
+       return NULL;
+     }
+ 
+   remote->globals = g_hash_table_new_full (NULL, NULL, NULL, g_free);
+ 
+-  pw_remote_add_listener (remote->remote,
+-                          &remote->remote_listener,
+-                          &remote_events,
+-                          remote);
+-
+-  if (pw_remote_connect (remote->remote) != 0)
+-    {
+-      pipewire_remote_destroy (remote);
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect PipeWire remote");
+-      return NULL;
+-    }
+-
+-  pw_main_loop_run (remote->loop);
+-
+-  switch (pw_remote_get_state (remote->remote, NULL))
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      *error = g_steal_pointer (&remote->error);
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "PipeWire loop stopped unexpectedly");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      break;
+-    default:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Unexpected PipeWire state");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    }
+-
+-  remote->core_proxy = pw_remote_get_core_proxy (remote->remote);
+-  pw_core_proxy_add_listener (remote->core_proxy,
+-                              &remote->core_listener,
+-                              &core_events,
+-                              remote);
++  pw_core_add_listener (remote->core,
++                        &remote->core_listener,
++                        &core_events,
++                        remote);
+ 
+   if (!discover_node_factory_sync (remote, error))
+     {
+diff --git src/pipewire.h src/pipewire.h
+index 0f1bf54..bf48d5e 100644
+--- src/pipewire.h
++++ src/pipewire.h
+@@ -32,7 +32,7 @@ typedef struct _PipeWireGlobal
+ 
+ typedef void (* PipeWireGlobalAddedCallback) (PipeWireRemote *remote,
+                                               uint32_t id,
+-                                              uint32_t type,
++                                              const char *type,
+                                               const struct spa_dict *props,
+                                               gpointer user_data);
+ 
+@@ -43,13 +43,11 @@ typedef void (* PipeWireGlobalRemovedCallback) (PipeWireRemote *remote,
+ struct _PipeWireRemote
+ {
+   struct pw_main_loop *loop;
++  struct pw_context *context;
+   struct pw_core *core;
+-  struct pw_remote *remote;
+-  struct spa_hook remote_listener;
+-
+-  struct pw_core_proxy *core_proxy;
+   struct spa_hook core_listener;
+-  uint32_t sync_seq;
++
++  int sync_seq;
+ 
+   struct spa_hook registry_listener;
+ 
+diff --git src/screen-cast.c src/screen-cast.c
+index 7881ddc..1677050 100644
+--- src/screen-cast.c
++++ src/screen-cast.c
+@@ -31,10 +31,10 @@
+ #include "xdp-impl-dbus.h"
+ #include "xdp-utils.h"
+ 
+-#define PERMISSION_ITEM(item_key, item_value) \
+-  ((struct spa_dict_item) { \
+-    .key = item_key, \
+-    .value = item_value \
++#define PERMISSION_ITEM(item_id, item_permissions) \
++  ((struct pw_permission) { \
++    .id = item_id, \
++    .permissions = item_permissions \
+   })
+ 
+ typedef struct _ScreenCast ScreenCast;
+@@ -517,42 +517,9 @@ screen_cast_stream_get_pipewire_node_id (ScreenCastStream *stream)
+   return stream->id;
+ }
+ 
+-static void
+-append_parent_permissions (PipeWireRemote *remote,
+-                           GArray *permission_items,
+-                           GList **string_stash,
+-                           PipeWireGlobal *global,
+-                           const char *permission)
+-{
+-  PipeWireGlobal *parent;
+-  char *parent_permission_value;
+-
+-  if (global->parent_id == 0)
+-    return;
+-
+-  parent = g_hash_table_lookup (remote->globals, GINT_TO_POINTER (global->parent_id));
+-
+-  if (parent->permission_set)
+-    return;
+-  parent->permission_set = TRUE;
+-
+-  append_parent_permissions (remote, permission_items, string_stash,
+-                             parent, permission);
+-
+-  parent_permission_value = g_strdup_printf ("%u:%s",
+-                                             global->parent_id,
+-                                             permission);
+-  *string_stash = g_list_prepend (*string_stash, parent_permission_value);
+-
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       parent_permission_value));
+-}
+-
+ static void
+ append_stream_permissions (PipeWireRemote *remote,
+                            GArray *permission_items,
+-                           GList **string_stash,
+                            GList *streams)
+ {
+   GList *l;
+@@ -561,21 +528,10 @@ append_stream_permissions (PipeWireRemote *remote,
+     {
+       ScreenCastStream *stream = l->data;
+       uint32_t stream_id;
+-      PipeWireGlobal *stream_global;
+-      char *stream_permission_value;
+ 
+       stream_id = screen_cast_stream_get_pipewire_node_id (stream);
+-      stream_global = g_hash_table_lookup (remote->globals,
+-                                           GINT_TO_POINTER (stream_id));
+-
+-      append_parent_permissions (remote, permission_items, string_stash,
+-                                 stream_global, "r--");
+-
+-      stream_permission_value = g_strdup_printf ("%u:rwx", stream_id);
+-      *string_stash = g_list_prepend (*string_stash, stream_permission_value);
+       g_array_append_val (permission_items,
+-                          PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                           stream_permission_value));
++                          PERMISSION_ITEM (stream_id, PW_PERM_RWX));
+     }
+ }
+ 
+@@ -587,9 +543,6 @@ open_pipewire_screen_cast_remote (const char *app_id,
+   struct pw_properties *pipewire_properties;
+   PipeWireRemote *remote;
+   g_autoptr(GArray) permission_items = NULL;
+-  char *node_factory_permission_string;
+-  GList *string_stash = NULL;
+-  struct spa_dict *permission_dict;
+   PipeWireGlobal *node_global;
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.app_id", app_id,
+@@ -603,48 +556,31 @@ open_pipewire_screen_cast_remote (const char *app_id,
+ 
+   permission_items = g_array_new (FALSE, TRUE, sizeof (struct spa_dict_item));
+ 
+-  /*
+-   * Hide all existing and future nodes (except the ones we explicitly list below.
+-   */
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_EXISTING,
+-                                       "---"));
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_DEFAULT,
+-                                       "---"));
+-
+   /*
+    * PipeWire:Interface:Core
+    * Needs rwx to be able create the sink node using the create-object method
+    */
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       "0:rwx"));
++                      PERMISSION_ITEM (PW_ID_CORE, PW_PERM_RWX));
+ 
+   /*
+    * PipeWire:Interface:NodeFactory
+    * Needs r-- so it can be passed to create-object when creating the sink node.
+    */
+-  node_factory_permission_string = g_strdup_printf ("%d:r--",
+-                                                    remote->node_factory_id);
+-  string_stash = g_list_prepend (string_stash, node_factory_permission_string);
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       node_factory_permission_string));
+-  node_global = g_hash_table_lookup (remote->globals,
+-                                     GINT_TO_POINTER (remote->node_factory_id));
+-  append_parent_permissions (remote, permission_items, &string_stash,
+-                             node_global, "r--");
++                      PERMISSION_ITEM (remote->node_factory_id, PW_PERM_R));
+ 
+-  append_stream_permissions (remote, permission_items, &string_stash, streams);
++  append_stream_permissions (remote, permission_items, streams);
+ 
+-  permission_dict =
+-    &SPA_DICT_INIT ((struct spa_dict_item *) permission_items->data,
+-                    permission_items->len);
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             permission_dict);
++  /*
++   * Hide all existing and future nodes (except the ones we explicitly list above).
++   */
++  g_array_append_val (permission_items,
++                      PERMISSION_ITEM (PW_ID_ANY, 0));
+ 
+-  g_list_free_full (string_stash, g_free);
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                permission_items->len,
++                                (const struct pw_permission *)permission_items->data);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -943,7 +879,7 @@ handle_open_pipewire_remote (XdpScreenCast *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
diff --git a/srcpkgs/xdg-desktop-portal/template b/srcpkgs/xdg-desktop-portal/template
index eb8a4602f5d..1136b6a6e0e 100644
--- a/srcpkgs/xdg-desktop-portal/template
+++ b/srcpkgs/xdg-desktop-portal/template
@@ -1,10 +1,10 @@
 # Template file for 'xdg-desktop-portal'
 pkgname=xdg-desktop-portal
 version=1.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-pipewire --enable-geoclue --disable-libportal"
-hostmakedepends="pkg-config glib-devel"
+hostmakedepends="automake libtool gettext-devel pkg-config glib-devel"
 makedepends="flatpak-devel fuse-devel pipewire-devel geoclue2-devel"
 short_desc="Portal frontend service for Flatpak"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -13,6 +13,10 @@ homepage="https://github.com/flatpak/xdg-desktop-portal"
 distfiles="https://github.com/flatpak/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.xz"
 checksum=883c9c9a925e48af54812b5347f546dd776ec2e27076a83d5a8126af6bafb9da
 
+pre_configure() {
+	autoreconf -vfi
+}
+
 post_install() {
 	rm -rf "${DESTDIR}/usr/lib/systemd"
 }

From a701e26e7af28dc1428117efe8ca9b59d803d60f Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Thu, 30 Apr 2020 06:17:17 +0900
Subject: [PATCH 4/4] mutter: rebuild for pipewire-0.3

---
 srcpkgs/mutter/patches/pipewire-0.3.patch | 521 ++++++++++++++++++++++
 srcpkgs/mutter/template                   |   2 +-
 2 files changed, 522 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/mutter/patches/pipewire-0.3.patch

diff --git a/srcpkgs/mutter/patches/pipewire-0.3.patch b/srcpkgs/mutter/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..ebff65fba85
--- /dev/null
+++ b/srcpkgs/mutter/patches/pipewire-0.3.patch
@@ -0,0 +1,521 @@
+Build mutter against pipewire-0.3, based on a patch at:
+https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1062
+--- meson.build
++++ meson.build
+@@ -50,7 +50,7 @@ libinput_req = '>= 1.7'
+ gbm_req = '>= 10.3'
+
+ # screen cast version requirements
+-libpipewire_req = '>= 0.2.5'
++libpipewire_req = '>= 0.3.0'
+
+ gnome = import('gnome')
+ pkg = import('pkgconfig')
+@@ -241,7 +241,7 @@ endif
+
+ have_remote_desktop = get_option('remote_desktop')
+ if have_remote_desktop
+-  libpipewire_dep = dependency('libpipewire-0.2', version: libpipewire_req)
++  libpipewire_dep = dependency('libpipewire-0.3', version: libpipewire_req)
+ endif
+
+ have_introspection = get_option('introspection')
+diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
+index 82c5cba436..ba1ce94a7e 100644
+--- src/backends/meta-screen-cast-stream-src.c
++++ src/backends/meta-screen-cast-stream-src.c
+@@ -29,6 +29,7 @@
+ #include <spa/param/props.h>
+ #include <spa/param/format-utils.h>
+ #include <spa/param/video/format-utils.h>
++#include <spa/utils/result.h>
+ #include <stdint.h>
+ #include <sys/mman.h>
+
+@@ -62,15 +63,6 @@ enum
+
+ static guint signals[N_SIGNALS];
+
+-typedef struct _MetaSpaType
+-{
+-  struct spa_type_media_type media_type;
+-  struct spa_type_media_subtype media_subtype;
+-  struct spa_type_format_video format_video;
+-  struct spa_type_video_format video_format;
+-  uint32_t meta_cursor;
+-} MetaSpaType;
+-
+ typedef struct _MetaPipeWireSource
+ {
+   GSource base;
+@@ -82,19 +74,19 @@ typedef struct _MetaScreenCastStreamSrcPrivate
+ {
+   MetaScreenCastStream *stream;
+
++  struct pw_context *pipewire_context;
+   struct pw_core *pipewire_core;
+-  struct pw_remote *pipewire_remote;
+-  struct pw_type *pipewire_type;
+   MetaPipeWireSource *pipewire_source;
+-  struct spa_hook pipewire_remote_listener;
++  struct spa_hook pipewire_core_listener;
+
+   gboolean is_enabled;
+
+   struct pw_stream *pipewire_stream;
+   struct spa_hook pipewire_stream_listener;
++  uint32_t node_id;
+
+-  MetaSpaType spa_type;
+   struct spa_video_info_raw video_format;
++  int video_stride;
+
+   uint64_t last_frame_timestamp_us;
+
+@@ -112,8 +104,6 @@ G_DEFINE_TYPE_WITH_CODE (MetaScreenCastStreamSrc,
+                                                 meta_screen_cast_stream_src_init_initable_iface)
+                          G_ADD_PRIVATE (MetaScreenCastStreamSrc))
+
+-#define PROP_RANGE(min, max) 2, (min), (max)
+-
+ static void
+ meta_screen_cast_stream_src_get_specs (MetaScreenCastStreamSrc *src,
+                                        int                     *width,
+@@ -286,9 +276,6 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+                                                               int                      x,
+                                                               int                      y)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+
+   spa_meta_cursor->id = 1;
+@@ -300,7 +287,7 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   spa_meta_cursor->hotspot.x = 0;
+@@ -317,9 +304,6 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+                                                         int                      y,
+                                                         float                    scale)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   CoglTexture *cursor_texture;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+   int hotspot_x, hotspot_y;
+@@ -346,7 +330,7 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
+@@ -382,12 +366,10 @@ static void
+ add_cursor_metadata (MetaScreenCastStreamSrc *src,
+                      struct spa_buffer       *spa_buffer)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_cursor *spa_meta_cursor;
+
+-  spa_meta_cursor = spa_buffer_find_meta (spa_buffer, spa_type->meta_cursor);
++  spa_meta_cursor = spa_buffer_find_meta_data (spa_buffer, SPA_META_Cursor,
++                                               sizeof (*spa_meta_cursor));
+   if (spa_meta_cursor)
+     meta_screen_cast_stream_src_set_cursor_metadata (src, spa_meta_cursor);
+ }
+@@ -447,14 +429,14 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+     {
+       data = spa_buffer->datas[0].data;
+     }
+-  else if (spa_buffer->datas[0].type == priv->pipewire_type->data.MemFd)
++  else if (spa_buffer->datas[0].type == SPA_DATA_MemFd)
+     {
+       map = mmap (NULL, spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset,
+                   PROT_READ | PROT_WRITE, MAP_SHARED,
+                   spa_buffer->datas[0].fd, 0);
+       if (map == MAP_FAILED)
+         {
+-          g_warning ("Failed to mmap pipewire stream buffer: %s\n",
++          g_warning ("Failed to mmap pipewire stream buffer: %s",
+                      strerror (errno));
+           return;
+         }
+@@ -469,28 +451,30 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+
+   if (meta_screen_cast_stream_src_record_frame (src, data))
+     {
+-      struct spa_meta_video_crop *spa_meta_video_crop;
++      struct spa_meta_region *spa_meta_video_crop;
+
+       spa_buffer->datas[0].chunk->size = spa_buffer->datas[0].maxsize;
++      spa_buffer->datas[0].chunk->stride = priv->video_stride;
+
+       /* Update VideoCrop if needed */
+       spa_meta_video_crop =
+-        spa_buffer_find_meta (spa_buffer, priv->pipewire_type->meta.VideoCrop);
++        spa_buffer_find_meta_data (spa_buffer, SPA_META_VideoCrop,
++                                   sizeof (*spa_meta_video_crop));
+       if (spa_meta_video_crop)
+         {
+           if (meta_screen_cast_stream_src_get_videocrop (src, &crop_rect))
+             {
+-              spa_meta_video_crop->x = crop_rect.x;
+-              spa_meta_video_crop->y = crop_rect.y;
+-              spa_meta_video_crop->width = crop_rect.width;
+-              spa_meta_video_crop->height = crop_rect.height;
++              spa_meta_video_crop->region.position.x = crop_rect.x;
++              spa_meta_video_crop->region.position.y = crop_rect.y;
++              spa_meta_video_crop->region.size.width = crop_rect.width;
++              spa_meta_video_crop->region.size.height = crop_rect.height;
+             }
+           else
+             {
+-              spa_meta_video_crop->x = 0;
+-              spa_meta_video_crop->y = 0;
+-              spa_meta_video_crop->width = priv->stream_width;
+-              spa_meta_video_crop->height = priv->stream_height;
++              spa_meta_video_crop->region.position.x = 0;
++              spa_meta_video_crop->region.position.y = 0;
++              spa_meta_video_crop->region.size.width = priv->stream_width;
++              spa_meta_video_crop->region.size.height = priv->stream_height;
+             }
+         }
+     }
+@@ -555,7 +539,6 @@ on_stream_state_changed (void                 *data,
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  uint32_t node_id;
+
+   switch (state)
+     {
+@@ -563,14 +546,12 @@ on_stream_state_changed (void                 *data,
+       g_warning ("pipewire stream error: %s", error_message);
+       meta_screen_cast_stream_src_notify_closed (src);
+       break;
+-    case PW_STREAM_STATE_CONFIGURE:
+-      node_id = pw_stream_get_node_id (priv->pipewire_stream);
+-      g_signal_emit (src, signals[READY], 0, (unsigned int) node_id);
+-      break;
+-    case PW_STREAM_STATE_UNCONNECTED:
+-    case PW_STREAM_STATE_CONNECTING:
+-    case PW_STREAM_STATE_READY:
+     case PW_STREAM_STATE_PAUSED:
++      if (priv->node_id == SPA_ID_INVALID && priv->pipewire_stream)
++        {
++          priv->node_id = pw_stream_get_node_id (priv->pipewire_stream);
++          g_signal_emit (src, signals[READY], 0, (unsigned int) priv->node_id);
++        }
+       if (meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_disable (src);
+       break;
+@@ -578,68 +559,69 @@ on_stream_state_changed (void                 *data,
+       if (!meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_enable (src);
+       break;
++    case PW_STREAM_STATE_UNCONNECTED:
++    case PW_STREAM_STATE_CONNECTING:
++      break;
+     }
+ }
+
+ static void
+-on_stream_format_changed (void                 *data,
+-                          const struct spa_pod *format)
++on_stream_param_changed (void                 *data,
++                         uint32_t              id,
++                         const struct spa_pod *format)
+ {
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   uint8_t params_buffer[1024];
+   int32_t width, height, stride, size;
+   struct spa_pod_builder pod_builder;
+   const struct spa_pod *params[3];
+   const int bpp = 4;
+
+-  if (!format)
+-    {
+-      pw_stream_finish_format (priv->pipewire_stream, 0, NULL, 0);
+-      return;
+-    }
++  if (!format || id != SPA_PARAM_Format)
++    return;
+
+   spa_format_video_raw_parse (format,
+-                              &priv->video_format,
+-                              &priv->spa_type.format_video);
++                              &priv->video_format);
+
+   width = priv->video_format.size.width;
+   height = priv->video_format.size.height;
+   stride = SPA_ROUND_UP_N (width * bpp, 4);
+   size = height * stride;
+
++  priv->video_stride = stride;
++
+   pod_builder = SPA_POD_BUILDER_INIT (params_buffer, sizeof (params_buffer));
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idBuffers, pipewire_type->param_buffers.Buffers,
+-    ":", pipewire_type->param_buffers.size, "i", size,
+-    ":", pipewire_type->param_buffers.stride, "i", stride,
+-    ":", pipewire_type->param_buffers.buffers, "iru", 16, PROP_RANGE (2, 16),
+-    ":", pipewire_type->param_buffers.align, "i", 16);
+-
+-  params[1] = spa_pod_builder_object (
++    SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
++    SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int (16, 2, 16),
++    SPA_PARAM_BUFFERS_blocks, SPA_POD_Int (1),
++    SPA_PARAM_BUFFERS_size, SPA_POD_Int (size),
++    SPA_PARAM_BUFFERS_stride, SPA_POD_Int (stride),
++    SPA_PARAM_BUFFERS_align, SPA_POD_Int (16));
++
++  params[1] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", pipewire_type->meta.VideoCrop,
+-    ":", pipewire_type->param_meta.size, "i", sizeof (struct spa_meta_video_crop));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_VideoCrop),
++    SPA_PARAM_META_size, SPA_POD_Int (sizeof (struct spa_meta_region)));
+
+-  params[2] = spa_pod_builder_object (
++  params[2] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", priv->spa_type.meta_cursor,
+-    ":", pipewire_type->param_meta.size, "i", CURSOR_META_SIZE (64, 64));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_Cursor),
++    SPA_PARAM_META_size, SPA_POD_Int (CURSOR_META_SIZE (64, 64)));
+
+-  pw_stream_finish_format (priv->pipewire_stream, 0,
+-                           params, G_N_ELEMENTS (params));
++  pw_stream_update_params (priv->pipewire_stream, params, G_N_ELEMENTS (params));
+ }
+
+ static const struct pw_stream_events stream_events = {
+   PW_VERSION_STREAM_EVENTS,
+   .state_changed = on_stream_state_changed,
+-  .format_changed = on_stream_format_changed,
++  .param_changed = on_stream_param_changed,
+ };
+
+ static struct pw_stream *
+@@ -652,8 +634,6 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   uint8_t buffer[1024];
+   struct spa_pod_builder pod_builder =
+     SPA_POD_BUILDER_INIT (buffer, sizeof (buffer));
+-  MetaSpaType *spa_type = &priv->spa_type;
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   float frame_rate;
+   MetaFraction frame_rate_fraction;
+   struct spa_fraction max_framerate;
+@@ -661,7 +641,9 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   const struct spa_pod *params[1];
+   int result;
+
+-  pipewire_stream = pw_stream_new (priv->pipewire_remote,
++  priv->node_id = SPA_ID_INVALID;
++
++  pipewire_stream = pw_stream_new (priv->pipewire_core,
+                                    "meta-screen-cast-src",
+                                    NULL);
+   if (!pipewire_stream)
+@@ -682,17 +664,17 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   max_framerate = SPA_FRACTION (frame_rate_fraction.num,
+                                 frame_rate_fraction.denom);
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idEnumFormat, pipewire_type->spa_format,
+-    "I", spa_type->media_type.video,
+-    "I", spa_type->media_subtype.raw,
+-    ":", spa_type->format_video.format, "I", spa_type->video_format.BGRx,
+-    ":", spa_type->format_video.size, "R", &SPA_RECTANGLE (priv->stream_width,
+-                                                           priv->stream_height),
+-    ":", spa_type->format_video.framerate, "F", &SPA_FRACTION (0, 1),
+-    ":", spa_type->format_video.max_framerate, "Fru", &max_framerate,
+-                                                      PROP_RANGE (&min_framerate,
++    SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
++    SPA_FORMAT_mediaType, SPA_POD_Id (SPA_MEDIA_TYPE_video),
++    SPA_FORMAT_mediaSubtype, SPA_POD_Id (SPA_MEDIA_SUBTYPE_raw),
++    SPA_FORMAT_VIDEO_format, SPA_POD_Id (SPA_VIDEO_FORMAT_BGRx),
++    SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle (&SPA_RECTANGLE (priv->stream_width,
++                                                              priv->stream_height)),
++    SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction (&SPA_FRACTION (0, 1)),
++    SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction (&max_framerate,
++                                                                  &min_framerate,
+                                                                   &max_framerate));
+
+   pw_stream_add_listener (pipewire_stream,
+@@ -702,7 +684,7 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+
+   result = pw_stream_connect (pipewire_stream,
+                               PW_DIRECTION_OUTPUT,
+-                              NULL,
++                              SPA_ID_INVALID,
+                               (PW_STREAM_FLAG_DRIVER |
+                                PW_STREAM_FLAG_MAP_BUFFERS),
+                               params, G_N_ELEMENTS (params));
+@@ -717,40 +699,18 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+ }
+
+ static void
+-on_state_changed (void                 *data,
+-                  enum pw_remote_state  old,
+-                  enum pw_remote_state  state,
+-                  const char           *error_message)
++on_core_error (void       *data,
++               uint32_t    id,
++	       int         seq,
++	       int         res,
++	       const char *message)
+ {
+   MetaScreenCastStreamSrc *src = data;
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_stream *pipewire_stream;
+-  GError *error = NULL;
+
+-  switch (state)
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-      g_warning ("pipewire remote error: %s\n", error_message);
+-      meta_screen_cast_stream_src_notify_closed (src);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pipewire_stream = create_pipewire_stream (src, &error);
+-      if (!pipewire_stream)
+-        {
+-          g_warning ("Could not create pipewire stream: %s", error->message);
+-          g_error_free (error);
+-          meta_screen_cast_stream_src_notify_closed (src);
+-        }
+-      else
+-        {
+-          priv->pipewire_stream = pipewire_stream;
+-        }
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    }
++  g_warning ("pipewire remote error: id:%u %s", id, message);
++
++  if (id == PW_ID_CORE && res == -EPIPE)
++    meta_screen_cast_stream_src_notify_closed (src);
+ }
+
+ static gboolean
+@@ -793,17 +753,6 @@ static GSourceFuncs pipewire_source_funcs =
+   pipewire_loop_source_finalize
+ };
+
+-static void
+-init_spa_type (MetaSpaType         *type,
+-               struct spa_type_map *map)
+-{
+-  spa_type_media_type_map (map, &type->media_type);
+-  spa_type_media_subtype_map (map, &type->media_subtype);
+-  spa_type_format_video_map (map, &type->format_video);
+-  spa_type_video_format_map (map, &type->video_format);
+-  type->meta_cursor = spa_type_map_get_id(map, SPA_TYPE_META__Cursor);
+-}
+-
+ static MetaPipeWireSource *
+ create_pipewire_source (void)
+ {
+@@ -829,9 +778,9 @@ create_pipewire_source (void)
+   return pipewire_source;
+ }
+
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = on_core_error,
+ };
+
+ static gboolean
+@@ -851,37 +800,31 @@ meta_screen_cast_stream_src_initable_init (GInitable     *initable,
+       return FALSE;
+     }
+
+-  priv->pipewire_core = pw_core_new (priv->pipewire_source->pipewire_loop,
+-                                     NULL);
+-  if (!priv->pipewire_core)
++  priv->pipewire_context = pw_context_new (priv->pipewire_source->pipewire_loop,
++                                           NULL, 0);
++  if (!priv->pipewire_context)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Failed to create pipewire core");
++                   "Failed to create pipewire context");
+       return FALSE;
+     }
+
+-  priv->pipewire_remote = pw_remote_new (priv->pipewire_core, NULL, 0);
+-  if (!priv->pipewire_remote)
++  priv->pipewire_core = pw_context_connect (priv->pipewire_context, NULL, 0);
++  if (!priv->pipewire_core)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't creat pipewire remote");
++                   "Couldn't connect pipewire context");
+       return FALSE;
+     }
+
+-  pw_remote_add_listener (priv->pipewire_remote,
+-                          &priv->pipewire_remote_listener,
+-                          &remote_events,
+-                          src);
++  pw_core_add_listener (priv->pipewire_core,
++                        &priv->pipewire_core_listener,
++                        &core_events,
++                        src);
+
+-  priv->pipewire_type = pw_core_get_type (priv->pipewire_core);
+-  init_spa_type (&priv->spa_type, priv->pipewire_type->map);
+-
+-  if (pw_remote_connect (priv->pipewire_remote) != 0)
+-    {
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect pipewire remote");
+-      return FALSE;
+-    }
++  priv->pipewire_stream = create_pipewire_stream (src, error);
++  if (!priv->pipewire_stream)
++    return FALSE;
+
+   return TRUE;
+ }
+@@ -912,8 +855,8 @@ meta_screen_cast_stream_src_finalize (GObject *object)
+     meta_screen_cast_stream_src_disable (src);
+
+   g_clear_pointer (&priv->pipewire_stream, pw_stream_destroy);
+-  g_clear_pointer (&priv->pipewire_remote, pw_remote_destroy);
+-  g_clear_pointer (&priv->pipewire_core, pw_core_destroy);
++  g_clear_pointer (&priv->pipewire_core, pw_core_disconnect);
++  g_clear_pointer (&priv->pipewire_context, pw_context_destroy);
+   g_source_destroy (&priv->pipewire_source->base);
+
+   G_OBJECT_CLASS (meta_screen_cast_stream_src_parent_class)->finalize (object);
diff --git a/srcpkgs/mutter/template b/srcpkgs/mutter/template
index 4e0bd32b67d..806a3bef9f0 100644
--- a/srcpkgs/mutter/template
+++ b/srcpkgs/mutter/template
@@ -1,7 +1,7 @@
 # Template file for 'mutter'
 pkgname=mutter
 version=3.34.1
-revision=2
+revision=3
 build_helper="gir"
 build_style=meson
 configure_args="-Degl_device=true -Dudev=true -Dnative_backend=true

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PR PATCH] [Updated] pipewire: update to 0.3.4
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (40 preceding siblings ...)
  2020-05-12 18:08 ` sirn
@ 2020-05-12 18:08 ` sirn
  2020-05-22  2:19 ` pipewire: update to 0.3.5 not-chicken
                   ` (9 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-05-12 18:08 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 785 bytes --]

There is an updated pull request by sirn against master on the void-packages repository

https://github.com/sirn/void-packages pipewire-update
https://github.com/void-linux/void-packages/pull/20413

pipewire: update to 0.3.4
This PR updates `pipewire` to 0.3.4 and also updating/patching all packages that depends on it. 

* `xdg-desktop-portal` includes a patch backported from 1.7.0 to allow 1.6.0 to build against pipewire-0.3 (1.7.x is prerelease)
* `xdg-desktop-portal-kde` already includes Pipewire 0.3 support and only requires revbump.
* `mutter` includes a patch backported from 3.35 to allow 3.34 to build against pipewire-0.3 (upgrading to >=3.35 also requires upgrading GNOME).

A patch file from https://github.com/void-linux/void-packages/pull/20413.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pipewire-update-20413.patch --]
[-- Type: text/x-diff, Size: 50839 bytes --]

From 2f4ddc43900f7ba390928dd551f8ee3d19970b24 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:23:52 +0900
Subject: [PATCH 1/4] pipewire: update to 0.3.5

---
 common/shlibs                  |  2 +-
 srcpkgs/alsa-pipewire          |  1 +
 srcpkgs/libjack-pipewire       |  1 +
 srcpkgs/libpulseaudio-pipewire |  1 +
 srcpkgs/pipewire/template      | 71 ++++++++++++++++++++++++++--------
 5 files changed, 58 insertions(+), 18 deletions(-)
 create mode 120000 srcpkgs/alsa-pipewire
 create mode 120000 srcpkgs/libjack-pipewire
 create mode 120000 srcpkgs/libpulseaudio-pipewire

diff --git a/common/shlibs b/common/shlibs
index 580a12d9c87..7b50a83dd25 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3204,7 +3204,7 @@ libarcan_shmif_ext.so.0.11 arcan-0.5.4.3_1
 libarcan_shmif_server.so.0.11 arcan-0.5.4.3_1
 libarcan_tui.so.0.11 arcan-0.5.4.3_1
 liblwipv6.so.2 lwipv6-1.5a_1
-libpipewire-0.2.so.1 libpipewire-0.2.2_1
+libpipewire-0.3.so.0 libpipewire-0.3.4_1
 libvolk.so.2.2.1 volk-2.2.1_1
 libgnuradio-runtime.so.3.8.0 gnuradio-3.8.0.0_1
 libgnuradio-pmt.so.3.8.0 gnuradio-3.8.0.0_1
diff --git a/srcpkgs/alsa-pipewire b/srcpkgs/alsa-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/alsa-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libjack-pipewire b/srcpkgs/libjack-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libjack-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/libpulseaudio-pipewire b/srcpkgs/libpulseaudio-pipewire
new file mode 120000
index 00000000000..c9c97cf6707
--- /dev/null
+++ b/srcpkgs/libpulseaudio-pipewire
@@ -0,0 +1 @@
+pipewire
\ No newline at end of file
diff --git a/srcpkgs/pipewire/template b/srcpkgs/pipewire/template
index 7f646dad11d..7e0df31570b 100644
--- a/srcpkgs/pipewire/template
+++ b/srcpkgs/pipewire/template
@@ -1,26 +1,37 @@
 # Template file for 'pipewire'
 pkgname=pipewire
-version=0.2.7
+version=0.3.5
 revision=1
 build_style=meson
-configure_args="-Dman=true -Dgstreamer=enabled -Ddocs=true -Dsystemd=false"
+configure_args="-Dman=true -Dgstreamer=true -Ddocs=true -Dsystemd=false
+ -Dbluez5=true -Dffmpeg=true -Dpipewire-alsa=true -Dpipewire-jack=true
+ -Dpipewire-pulseaudio=true"
 hostmakedepends="doxygen graphviz pkg-config xmltoman"
 makedepends="SDL2-devel ffmpeg-devel gst-plugins-base1-devel jack-devel
- sbc-devel v4l-utils-devel libva-devel"
+ sbc-devel v4l-utils-devel libva-devel libbluetooth-devel"
 short_desc="Server and user space API to deal with multimedia pipelines"
-maintainer="Orphaned <orphan@voidlinux.org>"
-#Next release will probably change to MIT, currently listed in master
-license="LGPL-2.1-only, GPL-2.0-only "
+maintainer="Kridsada Thanabulpong <sirn@ogsite.net>"
+license="MIT"
 homepage="https://pipewire.org/"
-changelog="https://raw.githubusercontent.com/PipeWire/pipewire/master/NEWS"
-distfiles="https://github.com/PipeWire/pipewire/archive/${version}.tar.gz"
-checksum=bfaa0f6ae6c0791e2e0b59234d399753bf24f1b33dbf587682363a8463dd8df1
+changelog="https://gitlab.freedesktop.org/pipewire/pipewire/-/raw/master/NEWS"
+distfiles="https://gitlab.freedesktop.org/pipewire/pipewire/-/archive/${version}/pipewire-${version}.tar.gz"
+checksum=c8cef9ce93dee328187b274e213dbecfe2df8ecc45bba2bc21d470112b2df3f6
 conf_files="/etc/pipewire/pipewire.conf"
 
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+	LDFLAGS+=" -latomic"
+fi
+
+post_install() {
+	vlicense LICENSE
+}
+
 libpipewire_package() {
 	short_desc+=" - pipewire library"
 	pkg_install() {
-		vmove "usr/lib/libpipewire-0.2.so.*"
+		vmove "usr/lib/libpipewire-0.3.so.*"
+		vmove "usr/lib/pipewire-0.3/*.so"
 	}
 }
 
@@ -28,25 +39,25 @@ pipewire-devel_package() {
 	depends="libpipewire-${version}_${revision}"
 	short_desc+=" - pipewire and libspa development files"
 	pkg_install() {
-		vmove usr/include/pipewire
-		vmove usr/include/spa
-		vmove usr/lib/pkgconfig/libpipewire-0.2.pc
-		vmove usr/lib/pkgconfig/libspa-0.1.pc
-		vmove usr/lib/libpipewire-0.2.so
+		vmove usr/include/pipewire-0.3
+		vmove usr/include/spa-0.2
+		vmove usr/lib/pkgconfig/libpipewire-0.3.pc
+		vmove usr/lib/pkgconfig/libspa-0.2.pc
+		vmove usr/lib/libpipewire-0.3.so
 	}
 }
 
 libspa-ffmpeg_package() {
 	short_desc+=" - ffmpeg plugins"
 	pkg_install() {
-		vmove usr/lib/spa/ffmpeg
+		vmove usr/lib/spa-0.2/ffmpeg
 	}
 }
 
 libspa-bluetooth_package() {
 	short_desc+=" - bluetooth plugins"
 	pkg_install() {
-		vmove usr/lib/spa/bluez5
+		vmove usr/lib/spa-0.2/bluez5
 	}
 }
 
@@ -57,6 +68,32 @@ gstreamer1-pipewire_package() {
 	}
 }
 
+libpulseaudio-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - PulseAudio client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/pulse
+		vmove usr/bin/pw-pulse
+	}
+}
+
+alsa-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - ALSA client library"
+	pkg_install() {
+		vmove usr/lib/alsa-lib
+	}
+}
+
+libjack-pipewire_package() {
+	depends="libpipewire-${version}_${revision}"
+	short_desc+=" - JACK client library"
+	pkg_install() {
+		vmove usr/lib/pipewire-0.3/jack
+		vmove usr/bin/pw-jack
+	}
+}
+
 pipewire-doc_package() {
 	archs=noarch
 	short_desc+=" - documentation"

From 571c903aa3491913dc36a6e3ae2c29a02d9935b7 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:46 +0900
Subject: [PATCH 2/4] xdg-desktop-portal-kde: rebuild for pipewire-0.3

---
 srcpkgs/xdg-desktop-portal-kde/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xdg-desktop-portal-kde/template b/srcpkgs/xdg-desktop-portal-kde/template
index 7a2aaf16b96..574e28504b7 100644
--- a/srcpkgs/xdg-desktop-portal-kde/template
+++ b/srcpkgs/xdg-desktop-portal-kde/template
@@ -1,7 +1,7 @@
 # Template file for 'xdg-desktop-portal-kde'
 pkgname=xdg-desktop-portal-kde
 version=5.18.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules qt5-qmake qt5-host-tools kcoreaddons gettext"
 makedepends="glib-devel kio-devel kwayland-devel libepoxy-devel pipewire-devel

From 847d49f8b307af90ece124677a00549beb3427e2 Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Sat, 28 Mar 2020 16:24:26 +0900
Subject: [PATCH 3/4] xdg-desktop-portal: rebuild for pipewire-0.3

---
 .../patches/pipewire-0.3.patch                | 551 ++++++++++++++++++
 srcpkgs/xdg-desktop-portal/template           |   8 +-
 2 files changed, 557 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch

diff --git a/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..94ebe083598
--- /dev/null
+++ b/srcpkgs/xdg-desktop-portal/patches/pipewire-0.3.patch
@@ -0,0 +1,551 @@
+From a38901e5e7f835efe7b7a06c55790c8c20bc91a2 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Tue, 14 Jan 2020 09:37:09 +0100
+Subject: [PATCH] PipeWire: update to 0.3 API
+
+---
+ configure.ac      |   2 +-
+ src/camera.c      |  24 ++++----
+ src/pipewire.c    | 141 +++++++++++++---------------------------------
+ src/pipewire.h    |  10 ++--
+ src/screen-cast.c |  98 ++++++--------------------------
+ 5 files changed, 72 insertions(+), 203 deletions(-)
+
+diff --git configure.ac configure.ac
+index 89902fa..62d7960 100644
+--- configure.ac
++++ configure.ac
+@@ -97,7 +97,7 @@ AC_ARG_ENABLE(pipewire,
+ 	      [AS_HELP_STRING([--enable-pipewire],[Enable PipeWire support. Needed for screen cast portal])],
+ 	      enable_pipewire=$enableval, enable_pipewire=yes)
+ if test x$enable_pipewire = xyes ; then
+-	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.2 >= 0.2.6])
++	PKG_CHECK_MODULES(PIPEWIRE, [libpipewire-0.3 >= 0.2.90])
+ 	AC_DEFINE([HAVE_PIPEWIRE],[1], [Define to enable PipeWire support])
+ fi
+ AM_CONDITIONAL([HAVE_PIPEWIRE],[test "$enable_pipewire" = "yes"])
+diff --git src/camera.c src/camera.c
+index c2b392c..20fe3aa 100644
+--- src/camera.c
++++ src/camera.c
+@@ -141,7 +141,7 @@ open_pipewire_camera_remote (const char *app_id,
+                              GError **error)
+ {
+   PipeWireRemote *remote;
+-  struct spa_dict_item permission_items[1];
++  struct pw_permission permission_items[2];
+   struct pw_properties *pipewire_properties;
+ 
+   pipewire_properties =
+@@ -158,12 +158,12 @@ open_pipewire_camera_remote (const char *app_id,
+    * Hide all existing and future nodes by default. PipeWire will use the
+    * permission store to set up permissions.
+    */
+-  permission_items[0].key = PW_CORE_PROXY_PERMISSIONS_DEFAULT;
+-  permission_items[0].value = "---";
++  permission_items[0] = PW_PERMISSION_INIT (PW_ID_CORE, PW_PERM_RWX);
++  permission_items[1] = PW_PERMISSION_INIT (PW_ID_ANY, 0);
+ 
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             &SPA_DICT_INIT (permission_items,
+-                                             G_N_ELEMENTS (permission_items)));
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                G_N_ELEMENTS (permission_items),
++                                permission_items);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -219,7 +219,7 @@ handle_open_pipewire_remote (XdpCamera *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
+@@ -250,29 +250,28 @@ camera_iface_init (XdpCameraIface *iface)
+ static void
+ global_added_cb (PipeWireRemote *remote,
+                  uint32_t id,
+-                 uint32_t type,
++                 const char *type,
+                  const struct spa_dict *props,
+                  gpointer user_data)
+ {
+   Camera *camera = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *media_class;
+   const struct spa_dict_item *media_role;
+ 
+-  if (type != core_type->node)
++  if (strcmp(type, PW_TYPE_INTERFACE_Node) != 0)
+     return;
+ 
+   if (!props)
+     return;
+ 
+-  media_class = spa_dict_lookup_item (props, "media.class");
++  media_class = spa_dict_lookup_item (props, PW_KEY_MEDIA_CLASS);
+   if (!media_class)
+     return;
+ 
+   if (g_strcmp0 (media_class->value, "Video/Source") != 0)
+     return;
+ 
+-  media_role = spa_dict_lookup_item (props, "media.role");
++  media_role = spa_dict_lookup_item (props, PW_KEY_MEDIA_ROLE);
+   if (!media_role)
+     return;
+ 
+@@ -342,6 +341,7 @@ create_pipewire_remote (Camera *camera,
+     }
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.is_portal", "true",
++                                           "portal.monitor", "Camera",
+                                            NULL);
+   camera->pipewire_remote = pipewire_remote_new_sync (pipewire_properties,
+                                                       global_added_cb,
+diff --git src/pipewire.c src/pipewire.c
+index 793a378..162cd55 100644
+--- src/pipewire.c
++++ src/pipewire.c
+@@ -21,6 +21,7 @@
+ #include <errno.h>
+ #include <glib.h>
+ #include <pipewire/pipewire.h>
++#include <spa/utils/result.h>
+ 
+ #include "pipewire.h"
+ 
+@@ -36,27 +37,25 @@ static gboolean is_pipewire_initialized = FALSE;
+ static void
+ registry_event_global (void *user_data,
+                        uint32_t id,
+-                       uint32_t parent_id,
+                        uint32_t permissions,
+-                       uint32_t type,
++                       const char *type,
+                        uint32_t version,
+                        const struct spa_dict *props)
+ {
+   PipeWireRemote *remote = user_data;
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+   const struct spa_dict_item *factory_object_type;
+   PipeWireGlobal *global;
+ 
+   global = g_new0 (PipeWireGlobal, 1);
+   *global = (PipeWireGlobal) {
+-    .parent_id = parent_id,
++    .parent_id = id,
+   };
+ 
+   g_hash_table_insert (remote->globals, GINT_TO_POINTER (id), global);
+   if (remote->global_added_cb)
+     remote->global_added_cb (remote, id, type, props, remote->user_data);
+ 
+-  if (type != core_type->factory)
++  if (strcmp(type, PW_TYPE_INTERFACE_Factory) != 0)
+     return;
+ 
+   factory_object_type = spa_dict_lookup_item (props, "factory.type.name");
+@@ -81,8 +80,8 @@ registry_event_global_remove (void *user_data,
+   g_hash_table_remove (remote->globals, GINT_TO_POINTER (id));
+ }
+ 
+-static const struct pw_registry_proxy_events registry_events = {
+-  PW_VERSION_REGISTRY_PROXY_EVENTS,
++static const struct pw_registry_events registry_events = {
++  PW_VERSION_REGISTRY_EVENTS,
+   .global = registry_event_global,
+   .global_remove = registry_event_global_remove,
+ };
+@@ -90,7 +89,7 @@ static const struct pw_registry_proxy_events registry_events = {
+ void
+ pipewire_remote_roundtrip (PipeWireRemote *remote)
+ {
+-  pw_core_proxy_sync (remote->core_proxy, ++remote->sync_seq);
++  remote->sync_seq = pw_core_sync (remote->core, PW_ID_CORE, remote->sync_seq);
+   pw_main_loop_run (remote->loop);
+ }
+ 
+@@ -98,16 +97,13 @@ static gboolean
+ discover_node_factory_sync (PipeWireRemote *remote,
+                             GError **error)
+ {
+-  struct pw_type *core_type = pw_core_get_type (remote->core);
+-  struct pw_registry_proxy *registry_proxy;
++  struct pw_registry *registry;
+ 
+-  registry_proxy = pw_core_proxy_get_registry (remote->core_proxy,
+-                                               core_type->registry,
+-                                               PW_VERSION_REGISTRY, 0);
+-  pw_registry_proxy_add_listener (registry_proxy,
+-                                  &remote->registry_listener,
+-                                  &registry_events,
+-                                  remote);
++  registry = pw_core_get_registry (remote->core, PW_VERSION_REGISTRY, 0);
++  pw_registry_add_listener (registry,
++                            &remote->registry_listener,
++                            &registry_events,
++                            remote);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -122,59 +118,35 @@ discover_node_factory_sync (PipeWireRemote *remote,
+ }
+ 
+ static void
+-on_state_changed (void *user_data,
+-                  enum pw_remote_state old,
+-                  enum pw_remote_state state,
+-                  const char *error)
++core_event_error (void       *user_data,
++                  uint32_t    id,
++		  int         seq,
++		  int         res,
++		  const char *message)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  switch (state)
++  if (id == PW_ID_CORE)
+     {
+-    case PW_REMOTE_STATE_ERROR:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "%s", error);
+-        }
++      g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
++                 "%s", message);
+       pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      if (!remote->error)
+-        {
+-          g_set_error (&remote->error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                       "Disconnected");
+-        }
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pw_main_loop_quit (remote->loop);
+-      break;
+-    default:
+-      g_warning ("Unknown PipeWire state");
+-      break;
+     }
+ }
+ 
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
+-};
+-
+ static void
+ core_event_done (void *user_data,
+-                 uint32_t seq)
++                 uint32_t id, int seq)
+ {
+   PipeWireRemote *remote = user_data;
+ 
+-  if (remote->sync_seq == seq)
++  if (id == PW_ID_CORE && remote->sync_seq == seq)
+     pw_main_loop_quit (remote->loop);
+ }
+ 
+-static const struct pw_core_proxy_events core_events = {
+-  PW_VERSION_CORE_PROXY_EVENTS,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = core_event_error,
+   .done = core_event_done,
+ };
+ 
+@@ -237,8 +209,8 @@ void
+ pipewire_remote_destroy (PipeWireRemote *remote)
+ {
+   g_clear_pointer (&remote->globals, g_hash_table_destroy);
+-  g_clear_pointer (&remote->remote, pw_remote_destroy);
+-  g_clear_pointer (&remote->core, pw_core_destroy);
++  g_clear_pointer (&remote->core, pw_core_disconnect);
++  g_clear_pointer (&remote->context, pw_context_destroy);
+   g_clear_pointer (&remote->loop, pw_main_loop_destroy);
+   g_clear_error (&remote->error);
+ 
+@@ -307,68 +279,31 @@ pipewire_remote_new_sync (struct pw_properties *pipewire_properties,
+       return NULL;
+     }
+ 
+-  remote->core = pw_core_new (pw_main_loop_get_loop (remote->loop), NULL);
+-  if (!remote->core)
++  remote->context = pw_context_new (pw_main_loop_get_loop (remote->loop), NULL, 0);
++  if (!remote->context)
+     {
+       pipewire_remote_destroy (remote);
+       pw_properties_free (pipewire_properties);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire core");
++                   "Couldn't create PipeWire context");
+       return NULL;
+     }
+ 
+-  remote->remote = pw_remote_new (remote->core, pipewire_properties, 0);
+-  if (!remote->remote)
++  remote->core = pw_context_connect (remote->context, pipewire_properties, 0);
++  if (!remote->core)
+     {
+       pipewire_remote_destroy (remote);
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't create PipeWire remote");
++                   "Couldn't connect to PipeWire");
+       return NULL;
+     }
+ 
+   remote->globals = g_hash_table_new_full (NULL, NULL, NULL, g_free);
+ 
+-  pw_remote_add_listener (remote->remote,
+-                          &remote->remote_listener,
+-                          &remote_events,
+-                          remote);
+-
+-  if (pw_remote_connect (remote->remote) != 0)
+-    {
+-      pipewire_remote_destroy (remote);
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect PipeWire remote");
+-      return NULL;
+-    }
+-
+-  pw_main_loop_run (remote->loop);
+-
+-  switch (pw_remote_get_state (remote->remote, NULL))
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-      *error = g_steal_pointer (&remote->error);
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTING:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "PipeWire loop stopped unexpectedly");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      break;
+-    default:
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Unexpected PipeWire state");
+-      pipewire_remote_destroy (remote);
+-      return NULL;
+-    }
+-
+-  remote->core_proxy = pw_remote_get_core_proxy (remote->remote);
+-  pw_core_proxy_add_listener (remote->core_proxy,
+-                              &remote->core_listener,
+-                              &core_events,
+-                              remote);
++  pw_core_add_listener (remote->core,
++                        &remote->core_listener,
++                        &core_events,
++                        remote);
+ 
+   if (!discover_node_factory_sync (remote, error))
+     {
+diff --git src/pipewire.h src/pipewire.h
+index 0f1bf54..bf48d5e 100644
+--- src/pipewire.h
++++ src/pipewire.h
+@@ -32,7 +32,7 @@ typedef struct _PipeWireGlobal
+ 
+ typedef void (* PipeWireGlobalAddedCallback) (PipeWireRemote *remote,
+                                               uint32_t id,
+-                                              uint32_t type,
++                                              const char *type,
+                                               const struct spa_dict *props,
+                                               gpointer user_data);
+ 
+@@ -43,13 +43,11 @@ typedef void (* PipeWireGlobalRemovedCallback) (PipeWireRemote *remote,
+ struct _PipeWireRemote
+ {
+   struct pw_main_loop *loop;
++  struct pw_context *context;
+   struct pw_core *core;
+-  struct pw_remote *remote;
+-  struct spa_hook remote_listener;
+-
+-  struct pw_core_proxy *core_proxy;
+   struct spa_hook core_listener;
+-  uint32_t sync_seq;
++
++  int sync_seq;
+ 
+   struct spa_hook registry_listener;
+ 
+diff --git src/screen-cast.c src/screen-cast.c
+index 7881ddc..1677050 100644
+--- src/screen-cast.c
++++ src/screen-cast.c
+@@ -31,10 +31,10 @@
+ #include "xdp-impl-dbus.h"
+ #include "xdp-utils.h"
+ 
+-#define PERMISSION_ITEM(item_key, item_value) \
+-  ((struct spa_dict_item) { \
+-    .key = item_key, \
+-    .value = item_value \
++#define PERMISSION_ITEM(item_id, item_permissions) \
++  ((struct pw_permission) { \
++    .id = item_id, \
++    .permissions = item_permissions \
+   })
+ 
+ typedef struct _ScreenCast ScreenCast;
+@@ -517,42 +517,9 @@ screen_cast_stream_get_pipewire_node_id (ScreenCastStream *stream)
+   return stream->id;
+ }
+ 
+-static void
+-append_parent_permissions (PipeWireRemote *remote,
+-                           GArray *permission_items,
+-                           GList **string_stash,
+-                           PipeWireGlobal *global,
+-                           const char *permission)
+-{
+-  PipeWireGlobal *parent;
+-  char *parent_permission_value;
+-
+-  if (global->parent_id == 0)
+-    return;
+-
+-  parent = g_hash_table_lookup (remote->globals, GINT_TO_POINTER (global->parent_id));
+-
+-  if (parent->permission_set)
+-    return;
+-  parent->permission_set = TRUE;
+-
+-  append_parent_permissions (remote, permission_items, string_stash,
+-                             parent, permission);
+-
+-  parent_permission_value = g_strdup_printf ("%u:%s",
+-                                             global->parent_id,
+-                                             permission);
+-  *string_stash = g_list_prepend (*string_stash, parent_permission_value);
+-
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       parent_permission_value));
+-}
+-
+ static void
+ append_stream_permissions (PipeWireRemote *remote,
+                            GArray *permission_items,
+-                           GList **string_stash,
+                            GList *streams)
+ {
+   GList *l;
+@@ -561,21 +528,10 @@ append_stream_permissions (PipeWireRemote *remote,
+     {
+       ScreenCastStream *stream = l->data;
+       uint32_t stream_id;
+-      PipeWireGlobal *stream_global;
+-      char *stream_permission_value;
+ 
+       stream_id = screen_cast_stream_get_pipewire_node_id (stream);
+-      stream_global = g_hash_table_lookup (remote->globals,
+-                                           GINT_TO_POINTER (stream_id));
+-
+-      append_parent_permissions (remote, permission_items, string_stash,
+-                                 stream_global, "r--");
+-
+-      stream_permission_value = g_strdup_printf ("%u:rwx", stream_id);
+-      *string_stash = g_list_prepend (*string_stash, stream_permission_value);
+       g_array_append_val (permission_items,
+-                          PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                           stream_permission_value));
++                          PERMISSION_ITEM (stream_id, PW_PERM_RWX));
+     }
+ }
+ 
+@@ -587,9 +543,6 @@ open_pipewire_screen_cast_remote (const char *app_id,
+   struct pw_properties *pipewire_properties;
+   PipeWireRemote *remote;
+   g_autoptr(GArray) permission_items = NULL;
+-  char *node_factory_permission_string;
+-  GList *string_stash = NULL;
+-  struct spa_dict *permission_dict;
+   PipeWireGlobal *node_global;
+ 
+   pipewire_properties = pw_properties_new ("pipewire.access.portal.app_id", app_id,
+@@ -603,48 +556,31 @@ open_pipewire_screen_cast_remote (const char *app_id,
+ 
+   permission_items = g_array_new (FALSE, TRUE, sizeof (struct spa_dict_item));
+ 
+-  /*
+-   * Hide all existing and future nodes (except the ones we explicitly list below.
+-   */
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_EXISTING,
+-                                       "---"));
+-  g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_DEFAULT,
+-                                       "---"));
+-
+   /*
+    * PipeWire:Interface:Core
+    * Needs rwx to be able create the sink node using the create-object method
+    */
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       "0:rwx"));
++                      PERMISSION_ITEM (PW_ID_CORE, PW_PERM_RWX));
+ 
+   /*
+    * PipeWire:Interface:NodeFactory
+    * Needs r-- so it can be passed to create-object when creating the sink node.
+    */
+-  node_factory_permission_string = g_strdup_printf ("%d:r--",
+-                                                    remote->node_factory_id);
+-  string_stash = g_list_prepend (string_stash, node_factory_permission_string);
+   g_array_append_val (permission_items,
+-                      PERMISSION_ITEM (PW_CORE_PROXY_PERMISSIONS_GLOBAL,
+-                                       node_factory_permission_string));
+-  node_global = g_hash_table_lookup (remote->globals,
+-                                     GINT_TO_POINTER (remote->node_factory_id));
+-  append_parent_permissions (remote, permission_items, &string_stash,
+-                             node_global, "r--");
++                      PERMISSION_ITEM (remote->node_factory_id, PW_PERM_R));
+ 
+-  append_stream_permissions (remote, permission_items, &string_stash, streams);
++  append_stream_permissions (remote, permission_items, streams);
+ 
+-  permission_dict =
+-    &SPA_DICT_INIT ((struct spa_dict_item *) permission_items->data,
+-                    permission_items->len);
+-  pw_core_proxy_permissions (pw_remote_get_core_proxy (remote->remote),
+-                             permission_dict);
++  /*
++   * Hide all existing and future nodes (except the ones we explicitly list above).
++   */
++  g_array_append_val (permission_items,
++                      PERMISSION_ITEM (PW_ID_ANY, 0));
+ 
+-  g_list_free_full (string_stash, g_free);
++  pw_client_update_permissions (pw_core_get_client(remote->core),
++                                permission_items->len,
++                                (const struct pw_permission *)permission_items->data);
+ 
+   pipewire_remote_roundtrip (remote);
+ 
+@@ -943,7 +879,7 @@ handle_open_pipewire_remote (XdpScreenCast *object,
+     }
+ 
+   out_fd_list = g_unix_fd_list_new ();
+-  fd = pw_remote_steal_fd (remote->remote);
++  fd = pw_core_steal_fd (remote->core);
+   fd_id = g_unix_fd_list_append (out_fd_list, fd, &error);
+   close (fd);
+   pipewire_remote_destroy (remote);
diff --git a/srcpkgs/xdg-desktop-portal/template b/srcpkgs/xdg-desktop-portal/template
index eb8a4602f5d..1136b6a6e0e 100644
--- a/srcpkgs/xdg-desktop-portal/template
+++ b/srcpkgs/xdg-desktop-portal/template
@@ -1,10 +1,10 @@
 # Template file for 'xdg-desktop-portal'
 pkgname=xdg-desktop-portal
 version=1.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-pipewire --enable-geoclue --disable-libportal"
-hostmakedepends="pkg-config glib-devel"
+hostmakedepends="automake libtool gettext-devel pkg-config glib-devel"
 makedepends="flatpak-devel fuse-devel pipewire-devel geoclue2-devel"
 short_desc="Portal frontend service for Flatpak"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -13,6 +13,10 @@ homepage="https://github.com/flatpak/xdg-desktop-portal"
 distfiles="https://github.com/flatpak/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.xz"
 checksum=883c9c9a925e48af54812b5347f546dd776ec2e27076a83d5a8126af6bafb9da
 
+pre_configure() {
+	autoreconf -vfi
+}
+
 post_install() {
 	rm -rf "${DESTDIR}/usr/lib/systemd"
 }

From 5a29497d9ad289cad5349c460aae7977e3523edc Mon Sep 17 00:00:00 2001
From: Kridsada Thanabulpong <sirn@ogsite.net>
Date: Thu, 30 Apr 2020 06:17:17 +0900
Subject: [PATCH 4/4] mutter: rebuild for pipewire-0.3

---
 srcpkgs/mutter/patches/pipewire-0.3.patch | 521 ++++++++++++++++++++++
 srcpkgs/mutter/template                   |   2 +-
 2 files changed, 522 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/mutter/patches/pipewire-0.3.patch

diff --git a/srcpkgs/mutter/patches/pipewire-0.3.patch b/srcpkgs/mutter/patches/pipewire-0.3.patch
new file mode 100644
index 00000000000..ebff65fba85
--- /dev/null
+++ b/srcpkgs/mutter/patches/pipewire-0.3.patch
@@ -0,0 +1,521 @@
+Build mutter against pipewire-0.3, based on a patch at:
+https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1062
+--- meson.build
++++ meson.build
+@@ -50,7 +50,7 @@ libinput_req = '>= 1.7'
+ gbm_req = '>= 10.3'
+
+ # screen cast version requirements
+-libpipewire_req = '>= 0.2.5'
++libpipewire_req = '>= 0.3.0'
+
+ gnome = import('gnome')
+ pkg = import('pkgconfig')
+@@ -241,7 +241,7 @@ endif
+
+ have_remote_desktop = get_option('remote_desktop')
+ if have_remote_desktop
+-  libpipewire_dep = dependency('libpipewire-0.2', version: libpipewire_req)
++  libpipewire_dep = dependency('libpipewire-0.3', version: libpipewire_req)
+ endif
+
+ have_introspection = get_option('introspection')
+diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
+index 82c5cba436..ba1ce94a7e 100644
+--- src/backends/meta-screen-cast-stream-src.c
++++ src/backends/meta-screen-cast-stream-src.c
+@@ -29,6 +29,7 @@
+ #include <spa/param/props.h>
+ #include <spa/param/format-utils.h>
+ #include <spa/param/video/format-utils.h>
++#include <spa/utils/result.h>
+ #include <stdint.h>
+ #include <sys/mman.h>
+
+@@ -62,15 +63,6 @@ enum
+
+ static guint signals[N_SIGNALS];
+
+-typedef struct _MetaSpaType
+-{
+-  struct spa_type_media_type media_type;
+-  struct spa_type_media_subtype media_subtype;
+-  struct spa_type_format_video format_video;
+-  struct spa_type_video_format video_format;
+-  uint32_t meta_cursor;
+-} MetaSpaType;
+-
+ typedef struct _MetaPipeWireSource
+ {
+   GSource base;
+@@ -82,19 +74,19 @@ typedef struct _MetaScreenCastStreamSrcPrivate
+ {
+   MetaScreenCastStream *stream;
+
++  struct pw_context *pipewire_context;
+   struct pw_core *pipewire_core;
+-  struct pw_remote *pipewire_remote;
+-  struct pw_type *pipewire_type;
+   MetaPipeWireSource *pipewire_source;
+-  struct spa_hook pipewire_remote_listener;
++  struct spa_hook pipewire_core_listener;
+
+   gboolean is_enabled;
+
+   struct pw_stream *pipewire_stream;
+   struct spa_hook pipewire_stream_listener;
++  uint32_t node_id;
+
+-  MetaSpaType spa_type;
+   struct spa_video_info_raw video_format;
++  int video_stride;
+
+   uint64_t last_frame_timestamp_us;
+
+@@ -112,8 +104,6 @@ G_DEFINE_TYPE_WITH_CODE (MetaScreenCastStreamSrc,
+                                                 meta_screen_cast_stream_src_init_initable_iface)
+                          G_ADD_PRIVATE (MetaScreenCastStreamSrc))
+
+-#define PROP_RANGE(min, max) 2, (min), (max)
+-
+ static void
+ meta_screen_cast_stream_src_get_specs (MetaScreenCastStreamSrc *src,
+                                        int                     *width,
+@@ -286,9 +276,6 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+                                                               int                      x,
+                                                               int                      y)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+
+   spa_meta_cursor->id = 1;
+@@ -300,7 +287,7 @@ meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStre
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   spa_meta_cursor->hotspot.x = 0;
+@@ -317,9 +304,6 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+                                                         int                      y,
+                                                         float                    scale)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   CoglTexture *cursor_texture;
+   struct spa_meta_bitmap *spa_meta_bitmap;
+   int hotspot_x, hotspot_y;
+@@ -346,7 +330,7 @@ meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc
+   spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor,
+                                 spa_meta_cursor->bitmap_offset,
+                                 struct spa_meta_bitmap);
+-  spa_meta_bitmap->format = spa_type->video_format.RGBA;
++  spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA;
+   spa_meta_bitmap->offset = sizeof (struct spa_meta_bitmap);
+
+   meta_cursor_sprite_get_hotspot (cursor_sprite, &hotspot_x, &hotspot_y);
+@@ -382,12 +366,10 @@ static void
+ add_cursor_metadata (MetaScreenCastStreamSrc *src,
+                      struct spa_buffer       *spa_buffer)
+ {
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  MetaSpaType *spa_type = &priv->spa_type;
+   struct spa_meta_cursor *spa_meta_cursor;
+
+-  spa_meta_cursor = spa_buffer_find_meta (spa_buffer, spa_type->meta_cursor);
++  spa_meta_cursor = spa_buffer_find_meta_data (spa_buffer, SPA_META_Cursor,
++                                               sizeof (*spa_meta_cursor));
+   if (spa_meta_cursor)
+     meta_screen_cast_stream_src_set_cursor_metadata (src, spa_meta_cursor);
+ }
+@@ -447,14 +429,14 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+     {
+       data = spa_buffer->datas[0].data;
+     }
+-  else if (spa_buffer->datas[0].type == priv->pipewire_type->data.MemFd)
++  else if (spa_buffer->datas[0].type == SPA_DATA_MemFd)
+     {
+       map = mmap (NULL, spa_buffer->datas[0].maxsize + spa_buffer->datas[0].mapoffset,
+                   PROT_READ | PROT_WRITE, MAP_SHARED,
+                   spa_buffer->datas[0].fd, 0);
+       if (map == MAP_FAILED)
+         {
+-          g_warning ("Failed to mmap pipewire stream buffer: %s\n",
++          g_warning ("Failed to mmap pipewire stream buffer: %s",
+                      strerror (errno));
+           return;
+         }
+@@ -469,28 +451,30 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src)
+
+   if (meta_screen_cast_stream_src_record_frame (src, data))
+     {
+-      struct spa_meta_video_crop *spa_meta_video_crop;
++      struct spa_meta_region *spa_meta_video_crop;
+
+       spa_buffer->datas[0].chunk->size = spa_buffer->datas[0].maxsize;
++      spa_buffer->datas[0].chunk->stride = priv->video_stride;
+
+       /* Update VideoCrop if needed */
+       spa_meta_video_crop =
+-        spa_buffer_find_meta (spa_buffer, priv->pipewire_type->meta.VideoCrop);
++        spa_buffer_find_meta_data (spa_buffer, SPA_META_VideoCrop,
++                                   sizeof (*spa_meta_video_crop));
+       if (spa_meta_video_crop)
+         {
+           if (meta_screen_cast_stream_src_get_videocrop (src, &crop_rect))
+             {
+-              spa_meta_video_crop->x = crop_rect.x;
+-              spa_meta_video_crop->y = crop_rect.y;
+-              spa_meta_video_crop->width = crop_rect.width;
+-              spa_meta_video_crop->height = crop_rect.height;
++              spa_meta_video_crop->region.position.x = crop_rect.x;
++              spa_meta_video_crop->region.position.y = crop_rect.y;
++              spa_meta_video_crop->region.size.width = crop_rect.width;
++              spa_meta_video_crop->region.size.height = crop_rect.height;
+             }
+           else
+             {
+-              spa_meta_video_crop->x = 0;
+-              spa_meta_video_crop->y = 0;
+-              spa_meta_video_crop->width = priv->stream_width;
+-              spa_meta_video_crop->height = priv->stream_height;
++              spa_meta_video_crop->region.position.x = 0;
++              spa_meta_video_crop->region.position.y = 0;
++              spa_meta_video_crop->region.size.width = priv->stream_width;
++              spa_meta_video_crop->region.size.height = priv->stream_height;
+             }
+         }
+     }
+@@ -555,7 +539,6 @@ on_stream_state_changed (void                 *data,
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  uint32_t node_id;
+
+   switch (state)
+     {
+@@ -563,14 +546,12 @@ on_stream_state_changed (void                 *data,
+       g_warning ("pipewire stream error: %s", error_message);
+       meta_screen_cast_stream_src_notify_closed (src);
+       break;
+-    case PW_STREAM_STATE_CONFIGURE:
+-      node_id = pw_stream_get_node_id (priv->pipewire_stream);
+-      g_signal_emit (src, signals[READY], 0, (unsigned int) node_id);
+-      break;
+-    case PW_STREAM_STATE_UNCONNECTED:
+-    case PW_STREAM_STATE_CONNECTING:
+-    case PW_STREAM_STATE_READY:
+     case PW_STREAM_STATE_PAUSED:
++      if (priv->node_id == SPA_ID_INVALID && priv->pipewire_stream)
++        {
++          priv->node_id = pw_stream_get_node_id (priv->pipewire_stream);
++          g_signal_emit (src, signals[READY], 0, (unsigned int) priv->node_id);
++        }
+       if (meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_disable (src);
+       break;
+@@ -578,68 +559,69 @@ on_stream_state_changed (void                 *data,
+       if (!meta_screen_cast_stream_src_is_enabled (src))
+         meta_screen_cast_stream_src_enable (src);
+       break;
++    case PW_STREAM_STATE_UNCONNECTED:
++    case PW_STREAM_STATE_CONNECTING:
++      break;
+     }
+ }
+
+ static void
+-on_stream_format_changed (void                 *data,
+-                          const struct spa_pod *format)
++on_stream_param_changed (void                 *data,
++                         uint32_t              id,
++                         const struct spa_pod *format)
+ {
+   MetaScreenCastStreamSrc *src = data;
+   MetaScreenCastStreamSrcPrivate *priv =
+     meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   uint8_t params_buffer[1024];
+   int32_t width, height, stride, size;
+   struct spa_pod_builder pod_builder;
+   const struct spa_pod *params[3];
+   const int bpp = 4;
+
+-  if (!format)
+-    {
+-      pw_stream_finish_format (priv->pipewire_stream, 0, NULL, 0);
+-      return;
+-    }
++  if (!format || id != SPA_PARAM_Format)
++    return;
+
+   spa_format_video_raw_parse (format,
+-                              &priv->video_format,
+-                              &priv->spa_type.format_video);
++                              &priv->video_format);
+
+   width = priv->video_format.size.width;
+   height = priv->video_format.size.height;
+   stride = SPA_ROUND_UP_N (width * bpp, 4);
+   size = height * stride;
+
++  priv->video_stride = stride;
++
+   pod_builder = SPA_POD_BUILDER_INIT (params_buffer, sizeof (params_buffer));
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idBuffers, pipewire_type->param_buffers.Buffers,
+-    ":", pipewire_type->param_buffers.size, "i", size,
+-    ":", pipewire_type->param_buffers.stride, "i", stride,
+-    ":", pipewire_type->param_buffers.buffers, "iru", 16, PROP_RANGE (2, 16),
+-    ":", pipewire_type->param_buffers.align, "i", 16);
+-
+-  params[1] = spa_pod_builder_object (
++    SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
++    SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int (16, 2, 16),
++    SPA_PARAM_BUFFERS_blocks, SPA_POD_Int (1),
++    SPA_PARAM_BUFFERS_size, SPA_POD_Int (size),
++    SPA_PARAM_BUFFERS_stride, SPA_POD_Int (stride),
++    SPA_PARAM_BUFFERS_align, SPA_POD_Int (16));
++
++  params[1] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", pipewire_type->meta.VideoCrop,
+-    ":", pipewire_type->param_meta.size, "i", sizeof (struct spa_meta_video_crop));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_VideoCrop),
++    SPA_PARAM_META_size, SPA_POD_Int (sizeof (struct spa_meta_region)));
+
+-  params[2] = spa_pod_builder_object (
++  params[2] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idMeta, pipewire_type->param_meta.Meta,
+-    ":", pipewire_type->param_meta.type, "I", priv->spa_type.meta_cursor,
+-    ":", pipewire_type->param_meta.size, "i", CURSOR_META_SIZE (64, 64));
++    SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
++    SPA_PARAM_META_type, SPA_POD_Id (SPA_META_Cursor),
++    SPA_PARAM_META_size, SPA_POD_Int (CURSOR_META_SIZE (64, 64)));
+
+-  pw_stream_finish_format (priv->pipewire_stream, 0,
+-                           params, G_N_ELEMENTS (params));
++  pw_stream_update_params (priv->pipewire_stream, params, G_N_ELEMENTS (params));
+ }
+
+ static const struct pw_stream_events stream_events = {
+   PW_VERSION_STREAM_EVENTS,
+   .state_changed = on_stream_state_changed,
+-  .format_changed = on_stream_format_changed,
++  .param_changed = on_stream_param_changed,
+ };
+
+ static struct pw_stream *
+@@ -652,8 +634,6 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   uint8_t buffer[1024];
+   struct spa_pod_builder pod_builder =
+     SPA_POD_BUILDER_INIT (buffer, sizeof (buffer));
+-  MetaSpaType *spa_type = &priv->spa_type;
+-  struct pw_type *pipewire_type = priv->pipewire_type;
+   float frame_rate;
+   MetaFraction frame_rate_fraction;
+   struct spa_fraction max_framerate;
+@@ -661,7 +641,9 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   const struct spa_pod *params[1];
+   int result;
+
+-  pipewire_stream = pw_stream_new (priv->pipewire_remote,
++  priv->node_id = SPA_ID_INVALID;
++
++  pipewire_stream = pw_stream_new (priv->pipewire_core,
+                                    "meta-screen-cast-src",
+                                    NULL);
+   if (!pipewire_stream)
+@@ -682,17 +664,17 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+   max_framerate = SPA_FRACTION (frame_rate_fraction.num,
+                                 frame_rate_fraction.denom);
+
+-  params[0] = spa_pod_builder_object (
++  params[0] = spa_pod_builder_add_object (
+     &pod_builder,
+-    pipewire_type->param.idEnumFormat, pipewire_type->spa_format,
+-    "I", spa_type->media_type.video,
+-    "I", spa_type->media_subtype.raw,
+-    ":", spa_type->format_video.format, "I", spa_type->video_format.BGRx,
+-    ":", spa_type->format_video.size, "R", &SPA_RECTANGLE (priv->stream_width,
+-                                                           priv->stream_height),
+-    ":", spa_type->format_video.framerate, "F", &SPA_FRACTION (0, 1),
+-    ":", spa_type->format_video.max_framerate, "Fru", &max_framerate,
+-                                                      PROP_RANGE (&min_framerate,
++    SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
++    SPA_FORMAT_mediaType, SPA_POD_Id (SPA_MEDIA_TYPE_video),
++    SPA_FORMAT_mediaSubtype, SPA_POD_Id (SPA_MEDIA_SUBTYPE_raw),
++    SPA_FORMAT_VIDEO_format, SPA_POD_Id (SPA_VIDEO_FORMAT_BGRx),
++    SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle (&SPA_RECTANGLE (priv->stream_width,
++                                                              priv->stream_height)),
++    SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction (&SPA_FRACTION (0, 1)),
++    SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction (&max_framerate,
++                                                                  &min_framerate,
+                                                                   &max_framerate));
+
+   pw_stream_add_listener (pipewire_stream,
+@@ -702,7 +684,7 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+
+   result = pw_stream_connect (pipewire_stream,
+                               PW_DIRECTION_OUTPUT,
+-                              NULL,
++                              SPA_ID_INVALID,
+                               (PW_STREAM_FLAG_DRIVER |
+                                PW_STREAM_FLAG_MAP_BUFFERS),
+                               params, G_N_ELEMENTS (params));
+@@ -717,40 +699,18 @@ create_pipewire_stream (MetaScreenCastStreamSrc  *src,
+ }
+
+ static void
+-on_state_changed (void                 *data,
+-                  enum pw_remote_state  old,
+-                  enum pw_remote_state  state,
+-                  const char           *error_message)
++on_core_error (void       *data,
++               uint32_t    id,
++	       int         seq,
++	       int         res,
++	       const char *message)
+ {
+   MetaScreenCastStreamSrc *src = data;
+-  MetaScreenCastStreamSrcPrivate *priv =
+-    meta_screen_cast_stream_src_get_instance_private (src);
+-  struct pw_stream *pipewire_stream;
+-  GError *error = NULL;
+
+-  switch (state)
+-    {
+-    case PW_REMOTE_STATE_ERROR:
+-      g_warning ("pipewire remote error: %s\n", error_message);
+-      meta_screen_cast_stream_src_notify_closed (src);
+-      break;
+-    case PW_REMOTE_STATE_CONNECTED:
+-      pipewire_stream = create_pipewire_stream (src, &error);
+-      if (!pipewire_stream)
+-        {
+-          g_warning ("Could not create pipewire stream: %s", error->message);
+-          g_error_free (error);
+-          meta_screen_cast_stream_src_notify_closed (src);
+-        }
+-      else
+-        {
+-          priv->pipewire_stream = pipewire_stream;
+-        }
+-      break;
+-    case PW_REMOTE_STATE_UNCONNECTED:
+-    case PW_REMOTE_STATE_CONNECTING:
+-      break;
+-    }
++  g_warning ("pipewire remote error: id:%u %s", id, message);
++
++  if (id == PW_ID_CORE && res == -EPIPE)
++    meta_screen_cast_stream_src_notify_closed (src);
+ }
+
+ static gboolean
+@@ -793,17 +753,6 @@ static GSourceFuncs pipewire_source_funcs =
+   pipewire_loop_source_finalize
+ };
+
+-static void
+-init_spa_type (MetaSpaType         *type,
+-               struct spa_type_map *map)
+-{
+-  spa_type_media_type_map (map, &type->media_type);
+-  spa_type_media_subtype_map (map, &type->media_subtype);
+-  spa_type_format_video_map (map, &type->format_video);
+-  spa_type_video_format_map (map, &type->video_format);
+-  type->meta_cursor = spa_type_map_get_id(map, SPA_TYPE_META__Cursor);
+-}
+-
+ static MetaPipeWireSource *
+ create_pipewire_source (void)
+ {
+@@ -829,9 +778,9 @@ create_pipewire_source (void)
+   return pipewire_source;
+ }
+
+-static const struct pw_remote_events remote_events = {
+-  PW_VERSION_REMOTE_EVENTS,
+-  .state_changed = on_state_changed,
++static const struct pw_core_events core_events = {
++  PW_VERSION_CORE_EVENTS,
++  .error = on_core_error,
+ };
+
+ static gboolean
+@@ -851,37 +800,31 @@ meta_screen_cast_stream_src_initable_init (GInitable     *initable,
+       return FALSE;
+     }
+
+-  priv->pipewire_core = pw_core_new (priv->pipewire_source->pipewire_loop,
+-                                     NULL);
+-  if (!priv->pipewire_core)
++  priv->pipewire_context = pw_context_new (priv->pipewire_source->pipewire_loop,
++                                           NULL, 0);
++  if (!priv->pipewire_context)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Failed to create pipewire core");
++                   "Failed to create pipewire context");
+       return FALSE;
+     }
+
+-  priv->pipewire_remote = pw_remote_new (priv->pipewire_core, NULL, 0);
+-  if (!priv->pipewire_remote)
++  priv->pipewire_core = pw_context_connect (priv->pipewire_context, NULL, 0);
++  if (!priv->pipewire_core)
+     {
+       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't creat pipewire remote");
++                   "Couldn't connect pipewire context");
+       return FALSE;
+     }
+
+-  pw_remote_add_listener (priv->pipewire_remote,
+-                          &priv->pipewire_remote_listener,
+-                          &remote_events,
+-                          src);
++  pw_core_add_listener (priv->pipewire_core,
++                        &priv->pipewire_core_listener,
++                        &core_events,
++                        src);
+
+-  priv->pipewire_type = pw_core_get_type (priv->pipewire_core);
+-  init_spa_type (&priv->spa_type, priv->pipewire_type->map);
+-
+-  if (pw_remote_connect (priv->pipewire_remote) != 0)
+-    {
+-      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+-                   "Couldn't connect pipewire remote");
+-      return FALSE;
+-    }
++  priv->pipewire_stream = create_pipewire_stream (src, error);
++  if (!priv->pipewire_stream)
++    return FALSE;
+
+   return TRUE;
+ }
+@@ -912,8 +855,8 @@ meta_screen_cast_stream_src_finalize (GObject *object)
+     meta_screen_cast_stream_src_disable (src);
+
+   g_clear_pointer (&priv->pipewire_stream, pw_stream_destroy);
+-  g_clear_pointer (&priv->pipewire_remote, pw_remote_destroy);
+-  g_clear_pointer (&priv->pipewire_core, pw_core_destroy);
++  g_clear_pointer (&priv->pipewire_core, pw_core_disconnect);
++  g_clear_pointer (&priv->pipewire_context, pw_context_destroy);
+   g_source_destroy (&priv->pipewire_source->base);
+
+   G_OBJECT_CLASS (meta_screen_cast_stream_src_parent_class)->finalize (object);
diff --git a/srcpkgs/mutter/template b/srcpkgs/mutter/template
index 4e0bd32b67d..806a3bef9f0 100644
--- a/srcpkgs/mutter/template
+++ b/srcpkgs/mutter/template
@@ -1,7 +1,7 @@
 # Template file for 'mutter'
 pkgname=mutter
 version=3.34.1
-revision=2
+revision=3
 build_helper="gir"
 build_style=meson
 configure_args="-Degl_device=true -Dudev=true -Dnative_backend=true

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.5
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (41 preceding siblings ...)
  2020-05-12 18:08 ` sirn
@ 2020-05-22  2:19 ` not-chicken
  2020-05-22  2:45 ` sirn
                   ` (8 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: not-chicken @ 2020-05-22  2:19 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 182 bytes --]

New comment by not-chicken on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-632440944

Comment:
@sirn  It's still failing on arm* : (

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.5
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (42 preceding siblings ...)
  2020-05-22  2:19 ` pipewire: update to 0.3.5 not-chicken
@ 2020-05-22  2:45 ` sirn
  2020-05-22 18:04 ` mnabid
                   ` (7 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-05-22  2:45 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 344 bytes --]

New comment by sirn on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-632447721

Comment:
@not-chicken I noticed this also, but still haven't got a chance to take a detailed look. Strange that the NEON check program compiles but actual build says unsupported :\ Will take a look over the weekend.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.5
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (43 preceding siblings ...)
  2020-05-22  2:45 ` sirn
@ 2020-05-22 18:04 ` mnabid
  2020-05-23  9:40 ` mnabid
                   ` (6 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: mnabid @ 2020-05-22 18:04 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 589 bytes --]

New comment by mnabid on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-632833378

Comment:
@sirn As far as I can remember, `pipewire-0.3.2` was the last one still working for `arm*`. So I tried reverting [`a81e269a`](https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/a81e269a7e058f97f333a1a5c2f393ecbbb5b3dd) (partially, only **meson.build**) and I was able to build for arm again. 

Here's the [patch](https://github.com/mnabid/void-packages/commit/45537fd5e6db1e7b08018a6b21b2c46df5a27975#diff-6761ede86a57277d05036e9d5cc36295).

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.5
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (44 preceding siblings ...)
  2020-05-22 18:04 ` mnabid
@ 2020-05-23  9:40 ` mnabid
  2020-05-26 19:52 ` sirn
                   ` (5 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: mnabid @ 2020-05-23  9:40 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 590 bytes --]

New comment by mnabid on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-632833378

Comment:
@sirn As far as I can remember, `pipewire-0.3.2` was the last one still working for `arm*`. So I tried reverting [`a81e269a`](https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/a81e269a7e058f97f333a1a5c2f393ecbbb5b3dd) (partially, only **meson.build**) and I was able to build for arm* again. 

Here's the [patch](https://github.com/mnabid/void-packages/commit/45537fd5e6db1e7b08018a6b21b2c46df5a27975#diff-6761ede86a57277d05036e9d5cc36295).

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.5
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (45 preceding siblings ...)
  2020-05-23  9:40 ` mnabid
@ 2020-05-26 19:52 ` sirn
  2020-05-26 19:53 ` sirn
                   ` (4 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-05-26 19:52 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 902 bytes --]

New comment by sirn on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-634242946

Comment:
> @sirn As far as I can remember, `pipewire-0.3.2` was the last one still working for `arm*`. So I tried reverting [`a81e269a`](https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/a81e269a7e058f97f333a1a5c2f393ecbbb5b3dd) (partially, only **meson.build**) and I was able to build for arm* again.
> 
> Here's the [patch](https://github.com/mnabid/void-packages/commit/45537fd5e6db1e7b08018a6b21b2c46df5a27975#diff-6761ede86a57277d05036e9d5cc36295).

This one works! Though, I'm starting to wonder if we should try to enable NEON for non-`aarch64` at all, given xbps is distributing a binary package and not all armv6l/armv7l has NEON as it would probably going to segfault in some armv6l/armv7l systems if pipewire were built with NEON support by default.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.5
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (46 preceding siblings ...)
  2020-05-26 19:52 ` sirn
@ 2020-05-26 19:53 ` sirn
  2020-05-27 20:06 ` shizonic
                   ` (3 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-05-26 19:53 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 905 bytes --]

New comment by sirn on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-634242946

Comment:
> @sirn As far as I can remember, `pipewire-0.3.2` was the last one still working for `arm*`. So I tried reverting [`a81e269a`](https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/a81e269a7e058f97f333a1a5c2f393ecbbb5b3dd) (partially, only **meson.build**) and I was able to build for arm* again.
> 
> Here's the [patch](https://github.com/mnabid/void-packages/commit/45537fd5e6db1e7b08018a6b21b2c46df5a27975#diff-6761ede86a57277d05036e9d5cc36295).

This one works! Though, I'm starting to wonder if we should try to enable NEON for non-`aarch64` at all, given xbps is distributing a binary package and not all armv6l/armv7l have NEON (and it would probably going to segfault in some armv6l/armv7l systems if pipewire were built with NEON support by default)

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.5
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (47 preceding siblings ...)
  2020-05-26 19:53 ` sirn
@ 2020-05-27 20:06 ` shizonic
  2020-05-27 20:07 ` shizonic
                   ` (2 subsequent siblings)
  51 siblings, 0 replies; 52+ messages in thread
From: shizonic @ 2020-05-27 20:06 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 437 bytes --]

New comment by shizonic on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-634911319

Comment:
Since https://github.com/void-linux/void-packages/pull/21382 depends on this may I ask if there is still one working on? AFAIK it's the small little missing piece for the GNOME 3.36.x update. So I would really appreciate if someone focus on again.

Of course If I can help, please let me know.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.5
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (48 preceding siblings ...)
  2020-05-27 20:06 ` shizonic
@ 2020-05-27 20:07 ` shizonic
  2020-05-27 20:08 ` sirn
  2020-05-27 20:09 ` shizonic
  51 siblings, 0 replies; 52+ messages in thread
From: shizonic @ 2020-05-27 20:07 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 448 bytes --]

New comment by shizonic on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-634911319

Comment:
Since https://github.com/void-linux/void-packages/pull/21382 depends on this PR, may I ask if there is still one working on it? AFAIK it's the small little missing piece for the GNOME 3.36.x update. So I would really appreciate if someone focus on it again.

Of course, If I can help, please let me know.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.5
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (49 preceding siblings ...)
  2020-05-27 20:07 ` shizonic
@ 2020-05-27 20:08 ` sirn
  2020-05-27 20:09 ` shizonic
  51 siblings, 0 replies; 52+ messages in thread
From: sirn @ 2020-05-27 20:08 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 163 bytes --]

New comment by sirn on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-634912494

Comment:
I'm still working on it. 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: pipewire: update to 0.3.5
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
                   ` (50 preceding siblings ...)
  2020-05-27 20:08 ` sirn
@ 2020-05-27 20:09 ` shizonic
  51 siblings, 0 replies; 52+ messages in thread
From: shizonic @ 2020-05-27 20:09 UTC (permalink / raw)
  To: ml


[-- Attachment #1: Type: text/plain, Size: 187 bytes --]

New comment by shizonic on void-packages repository

https://github.com/void-linux/void-packages/pull/20413#issuecomment-634913018

Comment:
> I'm still working on it.

Well thank you!

^ permalink raw reply	[flat|nested] 52+ messages in thread

end of thread, back to index

Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-20413@inbox.vuxu.org>
2020-03-28 10:26 ` pipewire: update to 0.3.2 Duncaen
2020-03-28 10:27 ` Duncaen
2020-03-28 10:34 ` sirn
2020-03-30  8:02 ` Piraty
2020-04-05 11:28 ` [PR PATCH] [Updated] WIP: " sirn
2020-04-05 11:30 ` sirn
2020-04-18  7:53 ` [PR PATCH] [Updated] " sirn
2020-04-29 19:44 ` mnabid
2020-04-29 19:46 ` mnabid
2020-04-29 19:47 ` mnabid
2020-04-29 20:02 ` [PR PATCH] [Updated] " sirn
2020-04-29 20:04 ` sirn
2020-04-29 20:09 ` sirn
2020-04-29 20:23 ` sirn
2020-04-29 20:32 ` mnabid
2020-04-29 20:37 ` sirn
2020-04-29 20:38 ` mnabid
2020-04-29 20:40 ` mnabid
2020-04-29 21:18 ` [PR PATCH] [Updated] " sirn
2020-04-29 21:20 ` sirn
2020-04-29 21:21 ` [WIP] " sirn
2020-04-30  3:29 ` mnabid
2020-04-30  3:29 ` mnabid
2020-04-30  4:10 ` mnabid
2020-04-30 20:51 ` [PR PATCH] [Updated] " sirn
2020-04-30 20:52 ` sirn
2020-04-30 21:02 ` [PR PATCH] [Updated] pipewire: update to 0.3.4 sirn
2020-04-30 21:07 ` sirn
2020-04-30 21:42 ` [PR PATCH] [Updated] " sirn
2020-05-01 10:35 ` sirn
2020-05-01 10:36 ` sirn
2020-05-01 10:37 ` sirn
2020-05-01 11:50 ` [PR PATCH] [Updated] WIP: " sirn
2020-05-07 18:27 ` sirn
2020-05-09 15:10 ` sirn
2020-05-09 15:22 ` sirn
2020-05-09 15:43 ` mnabid
2020-05-09 15:43 ` mnabid
2020-05-09 15:44 ` mnabid
2020-05-12 17:38 ` [PR PATCH] [Updated] " sirn
2020-05-12 18:08 ` sirn
2020-05-12 18:08 ` sirn
2020-05-22  2:19 ` pipewire: update to 0.3.5 not-chicken
2020-05-22  2:45 ` sirn
2020-05-22 18:04 ` mnabid
2020-05-23  9:40 ` mnabid
2020-05-26 19:52 ` sirn
2020-05-26 19:53 ` sirn
2020-05-27 20:06 ` shizonic
2020-05-27 20:07 ` shizonic
2020-05-27 20:08 ` sirn
2020-05-27 20:09 ` shizonic

Github messages for voidlinux

Archives are clonable: git clone --mirror http://inbox.vuxu.org/voidlinux-github

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.github.voidlinux


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git