gstreamer—如何创立gstreamer插件?

作者 : 开心源码 本文共3783个字,预计阅读时间需要10分钟 发布时间: 2022-05-13 共274人阅读

??gstreamer的功能强大是无须置疑的,它采用C语言编程,但是通过gObject,将各插件封装成面向对象编程的工具。那么如何创立gstreamer呢,当然,可以自己手动写,但是,gstreamer有提供一个叫make_element的工具,我们为什么不直接使用这个工具帮助我们生成所需要的插件呢。

1.获取创立插件的模板 gst-template

??首先要确定你的PC安装了git,而后执行以下命令就可在当前目录下获取gst-template源码。

git clone git://anongit.freedesktop.org/gstreamer/gst-template.git

2.创立插件模板

??进入gst-template/gst-plugin/src目录,执行以下操作

user# cd gst-template/gst-plugin/src/user# ../tools/make_element template

??执行完上面两步之后,在src目录下将会有gsttemplate.c 、gsttemplate.h这两个文件,他们就是生成的插件模板。

3.修改Makefile.am

??在src目录下的Makefile.am文件,内容如下:

# Note: plugindir is set in configure############################################################################### TODO: change libgstplugin.la to something else, e.g. libmysomething.la     ###############################################################################plugin_LTLIBRARIES = libgstplugin.la libgstaudiofilterexample.la############################################################################### TODO: for the next set of variables, name the prefix if you named the .la, ##  e.g. libmysomething.la => libmysomething_la_SOURCES                       ##                            libmysomething_la_CFLAGS                        ##                            libmysomething_la_LIBADD                        ##                            libmysomething_la_LDFLAGS                       ################################################################################# Plugin 1# sources used to compile this plug-inlibgstplugin_la_SOURCES = gstplugin.c gstplugin.h# compiler and linker flags used to compile this plugin, set in configure.aclibgstplugin_la_CFLAGS = $(GST_CFLAGS)libgstplugin_la_LIBADD = $(GST_LIBS)libgstplugin_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)libgstplugin_la_LIBTOOLFLAGS = --tag=disable-static## Plugin 2 (audio filter example)# sources used to compile this plug-inlibgstaudiofilterexample_la_SOURCES = gstaudiofilter.c# compiler and linker flags used to compile this plugin, set in configure.aclibgstaudiofilterexample_la_CFLAGS = $(GST_CFLAGS)libgstaudiofilterexample_la_LIBADD = $(GST_LIBS)libgstaudiofilterexample_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)libgstaudiofilterexample_la_LIBTOOLFLAGS = --tag=disable-static# headers we need but don't want installednoinst_HEADERS = gstplugin.h

??从内容可以知道,增加新的插件之后,直接在该Makefile.am增加该插件的内容就可,增加之后的内容如下:

# Note: plugindir is set in configure############################################################################### TODO: change libgstplugin.la to something else, e.g. libmysomething.la     ###############################################################################plugin_LTLIBRARIES = libgstplugin.la libgstaudiofilterexample.la libgstexample.la############################################################################### TODO: for the next set of variables, name the prefix if you named the .la, ##  e.g. libmysomething.la => libmysomething_la_SOURCES                       ##                            libmysomething_la_CFLAGS                        ##                            libmysomething_la_LIBADD                        ##                            libmysomething_la_LDFLAGS                       ################################################################################# Plugin 1# sources used to compile this plug-inlibgstplugin_la_SOURCES = gstplugin.c gstplugin.h# compiler and linker flags used to compile this plugin, set in configure.aclibgstplugin_la_CFLAGS = $(GST_CFLAGS)libgstplugin_la_LIBADD = $(GST_LIBS)libgstplugin_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)libgstplugin_la_LIBTOOLFLAGS = --tag=disable-static## Plugin 2 (audio filter example)# sources used to compile this plug-inlibgstaudiofilterexample_la_SOURCES = gstaudiofilter.c# compiler and linker flags used to compile this plugin, set in configure.aclibgstaudiofilterexample_la_CFLAGS = $(GST_CFLAGS)libgstaudiofilterexample_la_LIBADD = $(GST_LIBS)libgstaudiofilterexample_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)libgstaudiofilterexample_la_LIBTOOLFLAGS = --tag=disable-static## Plugin 3 (test example)# sources used to compile this plug-inlibgstexample_la_SOURCES = gsttemplate.c# compiler and linker flags used to compile this plugin, set in configure.aclibgstexample_la_CFLAGS = $(GST_CFLAGS)libgstexample_la_LIBADD = $(GST_LIBS)libgstexample_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)libgstexample_la_LIBTOOLFLAGS = --tag=disable-static# headers we need but don't want installednoinst_HEADERS = gstplugin.h

??至此,创立gstreamer插件完毕。

说明
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是摆设,本站源码仅提供给会员学习使用!
7. 如遇到加密压缩包,请使用360解压,如遇到无法解压的请联系管理员
开心源码网 » gstreamer—如何创立gstreamer插件?

发表回复