RFC: plugin: Add API allowing to statically link to specific elements
This is an alternative proposal to !567 (closed). Opening this as RFC to see which approach is preferred, or probably some mix of both.
A few notes:
- In my testing this generates a libgstreamer-full-1.0.so with the exact same size as with !567 (closed).
- It has the advantage of not requiring modification of
gst_plugin_register_static()
, which raised concerned in the review of the other MR. - GST_PLUGIN_DEFINE_ELEMENT() is added in each individual element .c file to avoid requiring
fdata-sections
or-ffunctions-sections
. - For the same reason, and this is the big downside of this proposal, GST_PLUGIN_DEFINE_WITH_INIT() must be in its own .c file too (gstelements2.c here, better name needed). I tried keeping definition of
gst_plugin_coreelements_register_with_init()
in gstelements.c as part of GST_PLUGIN_DEFINE() using__attribute__ ((section (".text.with_init")))
but it produce binary 53k bigger than having it its own .c file. Compared to 470k bigger when not using that__attribute__
, so it definitely has an effect, but I don't understand why it's not exactly identical as putting it in its own module.
Whit this proposal, gstinitstaticplugins.c
generated by gst-build must look like this:
#include <gst/gst.h>
GST_PLUGIN_STATIC_DECLARE (coreelements);
GST_PLUGIN_DECLARE_ELEMENT (coreelements, filesrc);
GST_PLUGIN_DECLARE_ELEMENT (coreelements, fakesink);
GST_PLUGIN_DECLARE_ELEMENT (coreelements, identity);
static gboolean coreelements_init(GstPlugin *plugin)
{
GST_PLUGIN_REGISTER_ELEMENT (plugin, coreelements, filesrc);
GST_PLUGIN_REGISTER_ELEMENT (plugin, coreelements, fakesink);
GST_PLUGIN_REGISTER_ELEMENT (plugin, coreelements, identity);
return FALSE;
}
void
gst_init_static_plugins (void)
{
GST_PLUGIN_STATIC_REGISTER_WITH_INIT(coreelements, coreelements_init);
}
This is implementation of my idea described there: !567 (comment 579044)