I'm working on software for an embedded system that uses GStreamer 0.10.36. My goal is to keep the software as small as possible in terms of Flash memory space, so I'd like to statically linking the GStreamer plugins I need. According to the Core Reference Manual:
"There are options to statically link plugins to an app or even use GStreamer without a plugin repository in which case gst_plugin_load() can be needed to bring the plugin into memory. "
Unfortunately, it's not clear to me exactly what I need to do to bring the plugin into memory such that a subsequent call to gst_element_factory_make()
completes successfully.
I'm doing the following:
--enable-static
and --disable-registry
set.gst_element_factory_make()
to create an elementRight now I'm only doing this for one plugin (tcpclientsink) out of several as an experiment. I had to edit the Makefile for that plugin to remove a --disable-static
statement to get the libgsttcp.a file to build. I assume the library is good, but I'm not sure if there is a good way to verify that. gst-inspect
does not appear to work on static libraries.
Note: If I call load_gst_plugin(/path/to/libgsttcp.a)
, GStreamer fails to load the plugin because of an invalid ELF header.
How does one load a statically linked GStreamer library?
I made an app in which all plugins are compiled inside the app (so it is self-containing)... Maybe this is another option for you, or do you really need to link to the library?
I got my usual code (plugin.c and plugin.h) that I used to compile the plugins in a shared library. I add an extra wrapper header that containts static registration code
static gboolean myplugin_init(GstPlugin * plugin)
{
gboolean ret;
gst_controller_init(NULL, NULL);
GST_DEBUG_CATEGORY_STATIC (gst_myplugin_debug);
GST_DEBUG_CATEGORY_INIT(gst_myplugin_debug, "myplugin", 0, "description");
ret = gst_element_register(plugin, "myplugin", GST_RANK_NONE, GST_TYPE_MECIMOTION);
return ret;
}
void gstmyplugins_register_static()
{
gst_plugin_register_static(
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"myplugin",
"description",
myplugin_init,
"0.0.1",
"LGPL",
"myplugins",
"GStreamer",
"http://gstreamer.net/");
gst_plugin_register_static(
...
}
then inside the code for my app i call this registration:
gstmyplugins_register_static();
then continue with
gst_element_factory_make("myplugin", NULL);
hope this helps.
With some help from the GStreamer developers I found the answer.... don't use version 0.10.36. :)
Basically the ability to build static plugin libraries was added/fixed in later versions. To get it to work in 0.10.36, I've had to back port changes from the GStreamer SDK and GStreamer 1.x into 0.10.36. Things are still a work in progress, but I am able to build libgstcoreelements.
a and statically link with it. If I wasn't already building a modified version of 0.10.36, I probably would have just used the SDK.
Update
I created static versions of all of the libraries I'm using. My GStreamer library is now a bit of a hybrid between 0.10.36, the SDK, and 1.2.2, but it works. I wouldn't recommend this solution for anyone though. Use the SDK or version 1.x.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With