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.
This commit is contained in:
Antonio Larrosa 2024-03-06 19:59:32 +01:00 committed by Wim Taymans
parent 60d68e0d66
commit 2df931483d
2 changed files with 4 additions and 4 deletions

View file

@ -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 <wim.taymans@gmail.com>");
"PipeWire sink", "Sink/Audio/Video",
"Send audio/video to PipeWire", "Wim Taymans <wim.taymans@gmail.com>");
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_pipewire_sink_template));

View file

@ -401,8 +401,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 <wim.taymans@gmail.com>");
"PipeWire source", "Source/Audio/Video",
"Uses PipeWire to create audio/video", "Wim Taymans <wim.taymans@gmail.com>");
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_pipewire_src_template));