Gstreamer学习笔记(6):如何创建gstreamer插件?

本文详细介绍使用GStreamer提供的make_element工具快速创建自定义插件的过程。包括获取模板、生成插件文件及修改Makefile.am等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

    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-in
libgstplugin_la_SOURCES = gstplugin.c gstplugin.h
 
# compiler and linker flags used to compile this plugin, set in configure.ac
libgstplugin_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-in
libgstaudiofilterexample_la_SOURCES = gstaudiofilter.c
 
# compiler and linker flags used to compile this plugin, set in configure.ac
libgstaudiofilterexample_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 installed
noinst_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-in
libgstplugin_la_SOURCES = gstplugin.c gstplugin.h
 
# compiler and linker flags used to compile this plugin, set in configure.ac
libgstplugin_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-in
libgstaudiofilterexample_la_SOURCES = gstaudiofilter.c
 
# compiler and linker flags used to compile this plugin, set in configure.ac
libgstaudiofilterexample_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-in
libgstexample_la_SOURCES = gsttemplate.c
 
# compiler and linker flags used to compile this plugin, set in configure.ac
libgstexample_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 installed
noinst_HEADERS = gstplugin.h

# 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-in
libgstplugin_la_SOURCES = gstplugin.c gstplugin.h
 
# compiler and linker flags used to compile this plugin, set in configure.ac
libgstplugin_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-in
libgstaudiofilterexample_la_SOURCES = gstaudiofilter.c
 
# compiler and linker flags used to compile this plugin, set in configure.ac
libgstaudiofilterexample_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-in
libgstexample_la_SOURCES = gsttemplate.c
 
# compiler and linker flags used to compile this plugin, set in configure.ac
libgstexample_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 installed
noinst_HEADERS = gstplugin.h

至此,创建gstreamer插件完毕。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值