$git clone git://anongit.freedesktop.org/gstreamer/gst-template.git
2、进入目录gst-template/gst-plugin/src
$cd gst-template/gst-plugin/src
$../tools/make_element ExampleFilter
产生文件
gstexamplefilter.c gstexamplefilter.h
3、修改Makefile.am文件 (注意:是src目录下的Makefile.am)
$sudo gedit Makefile.am
plugin_LTLIBRARIES = libgstexamplefilter.la
libgstexamplefilter_la_SOURCES = gstexamplefilter.c
libgstexamplefilter_la_CFLAGS = $(GST_CFLAGS)
libgstexamplefilter_la_LIBADD = $(GST_LIBS)
libgstexamplefilter_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstexamplefilter_la_LIBTOOLFLAGS = --tag=disable-static
noinst_HEADERS = gstexamplefilter.h
总共有七行
4、导入PKG_CONFIG_PATH环境变量,在命令行输入:
$export PKG_CONFIG_PATH=/usr/lib/pkgconfig
5、进入目录gst-template/gst-plugin,修改文件autogen.sh
进入上一层目录
$cd..
编辑autogen.sh文件:
$sudo gedit autogen.sh
如果是通过CVS获取的模板,则修改原来的
srcfile=src/main.c
为新的:
srcfile=src/gstexamplefilter.c
如果是通过
GIT获取的模板,则在autogen.sh的开始添加:
srcfile=src/gstexamplefilter.c
6、运行autogen.sh,产生Makefile文件
$./autogen.sh
7、开始安装:
$./configure
$make
$sudo make install
再进入src子目录中
$cd src
用ls -a查询会有.libs目录产生
(注意:
.libs 为隐藏目录)
进入.libs
$cd .libs
$ls -a
会发现里面产生了
libgstexamplefilter.la
libgstexamplefilter.so
8、
将插件加入到gstreamer库中
把libgstexamplefilter.la
libgstexamplefilter.so
这两个文件拷贝到系统目录中: /usr/lib/gstreamer-0.10
$sudo cp libgstexamplefilter.la /usr/lib/gstreamer-0.10/libgstexamplefilter.la
$sudo cp libgstexamplefilter.so /usr/lib/gstreamer-0.10/libgstexamplefilter.so
如果gstreamer无法扫描到新加入的plugin,可能是因为路径设置不正确(GST_PLUGIN_PATH环境变量)
用gst-inspect命令来查看plugin时,会建立一个cache文件:如在X86上是
$HOME/.gstreamer-0.10/registry.x86_64.bin
如果有新的plugin加入,可能需要先删除这个cache文件,再重新运行gst-inspect,否则不会把新的plugin
扫描到cache中。
几个重要的环境变量:
1:GST_PLUGIN_SCANNER
env = g_getenv ("GST_PLUGIN_SCANNER"); //设置gst-plugin_scanner这个命令的路径
2. GST_PLUGIN_PATH
plugin_path = g_getenv ("GST_PLUGIN_PATH"); //plugin的搜索路径
g_warning ("External plugin loader failed. This most likely means that "
"the plugin loader helper binary was not found or could not be run. "
"%s", (g_getenv ("GST_PLUGIN_PATH") != NULL) ?
"If you are running an uninstalled GStreamer setup, you might need "
"to update your gst-uninstalled script so that the "
"GST_PLUGIN_SCANNER environment variable gets set." : "");
3.GST_PLUGIN_SYSTEM_PATH
GST_PLUGIN_SYSTEM_PATH specifies a list of plugins that are always
loaded by default. If not set, this defaults to the system-installed
path, and the plugins installed in the user's home directory
plugin_path = g_getenv ("GST_PLUGIN_SYSTEM_PATH");
如果这个变量没有设置,default:
plugin_path = g_getenv ("GST_PLUGIN_SYSTEM_PATH");
if (plugin_path == NULL) {
home_plugins = g_build_filename (g_get_home_dir (),
".gstreamer-" GST_MAJORMINOR, "plugins", NULL);
}
4. GST_REGISTRY_UPDATE(yes or no) ,是否重新扫描去更新cache内容
update_env = g_getenv ("GST_REGISTRY_UPDATE")
do_update = (strcmp (update_env, "no") != 0)
函数调用:
init_post()->gst_update_registry()->ensure_current_registry()->gst_registry_binary_read_cache
->scan_and_update_registry()
->读环境变量GST_PLUGIN_PATH->gst_registry_scan_path_internal()
->读环境变量GST_PLUGIN_SYSTEM_PATH-> gst_registry_scan_path_internal() (从目录下去读文件)
检查插件:
$gst-inspect examplefilter
如果显示了插件的信息,那么插件就创建好了
(2)
Gst good/ugly/bad 库中的plugin的列表
http://gstreamer.freedesktop.org/documentation/plugins.html
关于whitelist和blacklist(黑名单)
在plugin库中,有些plugin的license是blacklist的:
if (strcmp (plugin->desc.license, "BLACKLIST") == 0)
plugin->flags |= GST_PLUGIN_FLAG_BLACKLISTED;
但是BLACKLIST并不是开放给用户设置的,而是gstreamer里面自己使用的。含义是说如果这个plugin
加载失败时,那么就加入到blacklist中,下次不需要去扫描了,用户也不能去使用。
这种plugin在scan时会进入blacklist的plugin list中,在下次扫描时不会去扫描这些blacklist。
exchange_packets()->read_one()-> handle_rx_packet(payloadLength)->plugin_loader_create_blacklist_plugin()
代码:
if (entry != NULL) {
plugin_loader_create_blacklist_plugin (l, entry);//plugin->desc.license = "BLACKLIST";
l->got_plugin_details = TRUE;