@@ -2516,11 +2516,6 @@ void MediaPlayerPrivateGStreamer::configureParsebin(GstElement* parsebin)
25162516 g_signal_connect (parsebin, " autoplug-select" ,
25172517 G_CALLBACK (+[](GstElement*, GstPad*, GstCaps* caps, GstElementFactory* factory, MediaPlayerPrivateGStreamer* player) -> unsigned {
25182518 static auto tryAutoPlug = *gstGetAutoplugSelectResult (" try" _s);
2519- static auto skipAutoPlug = *gstGetAutoplugSelectResult (" skip" _s);
2520-
2521- auto name = StringView::fromLatin1 (gst_plugin_feature_get_name (GST_PLUGIN_FEATURE_CAST (factory)));
2522- if (name == " webkitthunderparser" _s && player->m_url .protocolIsBlob ())
2523- return skipAutoPlug;
25242519
25252520 auto * structure = gst_caps_get_structure (caps, 0 );
25262521 if (!structure)
@@ -2551,6 +2546,35 @@ void MediaPlayerPrivateGStreamer::configureParsebin(GstElement* parsebin)
25512546
25522547 return tryAutoPlug;
25532548 }), this );
2549+
2550+ // We need to ensure that the webkitthunderparser factory is preferred over other parsers.
2551+ g_signal_connect (parsebin, " autoplug-factories" ,
2552+ G_CALLBACK (+[](GstElement*, GstPad*, GstCaps* caps, MediaPlayerPrivateGStreamer* player) -> GValueArray* {
2553+ ALLOW_DEPRECATED_DECLARATIONS_BEGIN; // GValueArray is deprecated
2554+ GValueArray* result;
2555+ // First, build a list of all decodable factories that can handle the caps,
2556+ // similar to what parsebin does.
2557+ auto factories = gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_DECODABLE, GST_RANK_MARGINAL);
2558+ // Add the webkitthunderparser factory if it exists, at the beginning of the list
2559+ // so that it is preferred over other elements.
2560+ if (!player->m_url .protocolIsBlob () && gst_element_factory_find (" webkitthunderparser" _s))
2561+ factories = g_list_prepend (factories, gst_element_factory_find (" webkitthunderparser" _s));
2562+ // Filter the factories based on the caps and return them as a GValueArray.
2563+ auto list = gst_element_factory_list_filter (factories, caps, GST_PAD_SINK, gst_caps_is_fixed (caps));
2564+ result = g_value_array_new (g_list_length (list));
2565+ for (GList* tmp = list; tmp; tmp = tmp->next ) {
2566+ auto factory = GST_ELEMENT_FACTORY_CAST (tmp->data );
2567+ GValue value = G_VALUE_INIT;
2568+ g_value_init (&value, G_TYPE_OBJECT);
2569+ g_value_set_object (&value, factory);
2570+ g_value_array_append (result, &value);
2571+ g_value_unset (&value);
2572+ }
2573+ gst_plugin_feature_list_free (list);
2574+ gst_plugin_feature_list_free (factories);
2575+ return result;
2576+ ALLOW_DEPRECATED_DECLARATIONS_END;
2577+ }), this );
25542578}
25552579
25562580void MediaPlayerPrivateGStreamer::configureUriDecodebin2 (GstElement* element)
0 commit comments