From 1c414ef36b5b4deb8e07f357223206083b3ec9cc Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Sat, 8 May 2021 16:17:55 +0200 Subject: [PATCH 1/2] API: allow using PipeWire for audio output Instead of using PulseAudio sink and making a round way through pipewire-pulse, access and use PipeWire directly for audio output when user sets env var GST_CLAPPER_USE_PIPEWIRE=1 --- lib/gst/clapper/gstclapper.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/gst/clapper/gstclapper.c b/lib/gst/clapper/gstclapper.c index b9c6f41f..b53980de 100644 --- a/lib/gst/clapper/gstclapper.c +++ b/lib/gst/clapper/gstclapper.c @@ -2869,8 +2869,8 @@ gst_clapper_main (gpointer data) GstClapper *self = GST_CLAPPER (data); GstBus *bus; GSource *source; - GstElement *scaletempo; - const gchar *env; + GstElement *scaletempo, *pipewiresink; + const gchar *pb_env, *pw_env; GST_TRACE_OBJECT (self, "Starting main thread"); @@ -2882,8 +2882,8 @@ gst_clapper_main (gpointer data) g_source_attach (source, self->context); g_source_unref (source); - env = g_getenv ("GST_CLAPPER_USE_PLAYBIN3"); - if (env && g_str_has_prefix (env, "1")) + pb_env = g_getenv ("GST_CLAPPER_USE_PLAYBIN3"); + if (pb_env && g_str_has_prefix (pb_env, "1")) self->use_playbin3 = TRUE; if (self->use_playbin3) { @@ -2914,12 +2914,23 @@ gst_clapper_main (gpointer data) } } + pw_env = g_getenv ("GST_CLAPPER_USE_PIPEWIRE"); + if (pw_env && g_str_has_prefix (pw_env, "1")) { + pipewiresink = gst_element_factory_make ("pipewiresink", NULL); + if (pipewiresink) { + g_object_set (self->playbin, "audio-sink", pipewiresink, NULL); + } else { + g_warning ("GstClapper: pipewiresink element not available. " + "Default audio sink will be used instead."); + } + } + scaletempo = gst_element_factory_make ("scaletempo", NULL); if (scaletempo) { g_object_set (self->playbin, "audio-filter", scaletempo, NULL); } else { - g_warning ("GstClapper: scaletempo element not available. Audio pitch " - "will not be preserved during trick modes"); + g_warning ("GstClapper: scaletempo element not available. " + "Audio pitch will not be preserved during trick modes."); } self->bus = bus = gst_element_get_bus (self->playbin); From af2c74a4b1a579f75055ef97de0a5071c57ad10b Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Sun, 9 May 2021 21:39:54 +0200 Subject: [PATCH 2/2] flatpak: Support PipeWire GStreamer plugins We need to allow PipeWire socket access and symlink the pipewire plugin to the dir where our custom GStreamer installation is. --- pkgs/flatpak/com.github.rafostar.Clapper.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/flatpak/com.github.rafostar.Clapper.json b/pkgs/flatpak/com.github.rafostar.Clapper.json index ed168f2b..981376e1 100644 --- a/pkgs/flatpak/com.github.rafostar.Clapper.json +++ b/pkgs/flatpak/com.github.rafostar.Clapper.json @@ -12,6 +12,7 @@ "--socket=pulseaudio", "--share=network", "--device=all", + "--filesystem=xdg-run/pipewire-0:ro", "--filesystem=xdg-videos", "--talk-name=org.gnome.Shell", "--env=GST_PLUGIN_SYSTEM_PATH=/app/lib/gstreamer-1.0", @@ -49,5 +50,8 @@ } ] } + ], + "cleanup-commands": [ + "ln -s /lib/$FLATPAK_ARCH-linux-*/gstreamer-1.0/libgstpipewire.so /app/lib/gstreamer-1.0/" ] }