I need to determine which decoder plugin decodebin3
has selected.
I've found that I can't always link it to certain downstream elements after it spawns the source pad. But if I "disable" (change the rank) of a given unusable plugin, I can make my pipeline linkable/functional. I want to dynamically switch the selection, in the event the downstream elements can't link.
The older decodebin
had signals like autoplug-select
, which looks to have been a means for figuring out the plugins in play. But decodebin3
doesn't have equivalent signals?
When I have debug logging enabled, I have seen the name of the child plugin (which is how can manually disable a "bad" one in POC manner to test my concept). Is there a way to iterate through the children inside a decodebin3
?
I figured it out myself. Basically, the element created by this plugin is a "bin" (which is why it's called decodeBIN3
!), and therefore one can use gst_bin_iterate_elements
to iterate through the child elements within it. Then, it's possible to get the factory an element was produced by, and from there check the type of factory e.g. being a decoder. You can can also get the unique id of the "factory type".
Here are the major functions to use when formulating your own solution for a similar issue. (Sorry it would be a pain, and perhaps confusing, if I posted all the code for my exact use case...)
gst_bin_iterate_elements( GST_BIN( decoder ) );
GstElement *element( GST_ELEMENT_CAST( g_value_peek_pointer( &value ) ) );
GstElementFactory *factory( gst_element_get_factory( element ) );
const gboolean isDecoder( gst_element_factory_list_is_type( factory, GST_ELEMENT_FACTORY_TYPE_DECODER ) );
const GType factoryType( gst_element_factory_get_element_type( factory ) );