From f3b20ae1e242ae5e1fe6a58674f0b1331c6d4a26 Mon Sep 17 00:00:00 2001 From: Antonio Larrosa Date: Wed, 6 Mar 2024 19:59:32 +0100 Subject: [PATCH] Specify "Audio" in gstreamer sink/src metadata to fix autodetect gst-play uses autoaudiosink by default when playing audio, which iterates over all sinks sorting them by rank. By default, pipewiresink sets the rank to 0, but it can be overridden by setting the GST_PLUGIN_FEATURE_RANK env. var. like this: `GST_PLUGIN_FEATURE_RANK=pipewiresink:268 gst-play-1.0 /usr/share/sounds/alsa/test.wav` But that doesn't work either because the autoaudiosink plugin also filters the available options, testing for "Sink" and "Audio" to appear in the classification metadata (in the strstr comparison in https://gitlab.freedesktop.org/gstreamer/gstreamer/-/blob/main/subprojects/gst-plugins-good/gst/autodetect/gstautodetect.c?ref_type=heads#L220 klass is what's set by pipewire as classification, self->type_klass is "Sink" and self->media_klass is "Audio") Just adding the word Audio to the classification metadata fixes this and allows pipewiresink to be selected by autoaudiosink. I also set it in the source plugin since looking at the code, autoaudiosrc works exactly the same. --- src/gst/gstpipewiresink.c | 4 ++-- src/gst/gstpipewiresrc.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gst/gstpipewiresink.c b/src/gst/gstpipewiresink.c index 22e53837e..3ce1092d1 100644 --- a/src/gst/gstpipewiresink.c +++ b/src/gst/gstpipewiresink.c @@ -209,8 +209,8 @@ gst_pipewire_sink_class_init (GstPipeWireSinkClass * klass) gstelement_class->change_state = gst_pipewire_sink_change_state; gst_element_class_set_static_metadata (gstelement_class, - "PipeWire sink", "Sink/Video", - "Send video to PipeWire", "Wim Taymans "); + "PipeWire sink", "Sink/Audio/Video", + "Send audio/video to PipeWire", "Wim Taymans "); gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&gst_pipewire_sink_template)); diff --git a/src/gst/gstpipewiresrc.c b/src/gst/gstpipewiresrc.c index 0a8ffd761..c59af0d71 100644 --- a/src/gst/gstpipewiresrc.c +++ b/src/gst/gstpipewiresrc.c @@ -402,8 +402,8 @@ gst_pipewire_src_class_init (GstPipeWireSrcClass * klass) gstelement_class->send_event = gst_pipewire_src_send_event; gst_element_class_set_static_metadata (gstelement_class, - "PipeWire source", "Source/Video", - "Uses PipeWire to create video", "Wim Taymans "); + "PipeWire source", "Source/Audio/Video", + "Uses PipeWire to create audio/video", "Wim Taymans "); gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&gst_pipewire_src_template));