GNOME Bugzilla – Bug 131079
[PATCH] [api] loading a class leaves elementfactory blank
Last modified: 2006-04-11 11:48:22 UTC
GstElementClass *klass; GstElementFactory *factory; factory = gst_element_factory_find (...); if (!gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory))) { g_warning ("Failed to load plugin feature \"%s\"", elements[i]); continue; } klass = g_type_class_ref (factory->type); This code will lead to an elementclass that has klass->elementfactory not filled in.
Ronald, what are you saying exactly ? This code is already somewhere in gst and thus wrong ? This is something you'd like to be able to do in code ? What do you mean ?
It's application code to select plugins, like gst-editor does.
ok, but could you be more verbose ? what's wrong with this code ? what is the actual bug ?
Well, make a .c file and add this code right after gst_init(). Add a random plugin into the "..." (e.g. audioconvert) and then try to access klass->elementfactory after this piece of code in your .c file, it will be NULL. It should be filled in like it does when you create an element. So the bug, in case you didn't yet get it by now, is that this piece of code loads an element's details, but the elementfactory is not filled in, while it should be filled in. Therefore, I cannot access the information in the elementfactory; however, I do need that information. It doesn't matter *what* I need it for, I just need it.
*** Bug 147970 has been marked as a duplicate of this bug. ***
Is a gst_element_factory_ref_element_class a good option for you, it would basically copy the stuff from the factory into the new element class, as is currently done in gstelementfactory.c.
Created attachment 33349 [details] [review] patch to get a GstElementClass ref from a factory something like this?
This would solve it, but requires code adjustment. Is it possible to do this integrated in class_init? If not, then this is fine, but it's kind of suboptimal, I'd rather see something better integrated.
Ronald, any thoughts on this?
gst_plugin_feature_ensure_loaded is gone, gst_plugin_feature_load() replaces it and does the same thing. When the plugin is loaded and gst_element_register() is called, the klass->elementfactory is filled in correctly in CVS. Added docs to state that the ->type field is 0 when the feature is not loaded. Added check to test behaviour. * gst/gstelementfactory.c: (gst_element_register), (gst_element_factory_create), (gst_element_factory_make): Some cleanups. Fixed a FIXME. Updated docs (Fixes #131079) * gst/gstpluginfeature.c: (gst_plugin_feature_load): Small cleanups. * tests/check/gst/gstelement.c: (GST_START_TEST), (gst_element_suite): Added testcase for elementfactory class field.