一步一步创建GStreamer插件

1、获取创建插件的模板gst-template
http://hi.baidu.com/zhxust/blog/item/8161ab637d89ac6a0d33fa45.html

方法一: CVS
$cvs -d:pserver:[email protected]/cvs/gstreamer login
password: [root的密码]
$cvs -z3 -d:pserver:[email protected]:/cvs/gstreamer co gst-template

方法二: GIT
如果没有安装git,则首先安装git:
$sudo apt-get install git-core
再获取模板: 

          
$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/local/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
出现错误:

./autogen.sh: 6: ./autogen.sh: autoreconf: not found
autogen.sh failed

执行以下命令:

sudo apt-get install autoconf automake libtool

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/local/lib/gstreamer-1.0/

$sudo cp libgstexamplefilter.la /usr/local/lib/gstreamer-1.0/ libgstexamplefilter.la
$sudo cp libgstexamplefilter.so /usr/local/lib/gstreamer-1.0/ libgstexamplefilter.so

检查插件:
$gst-inspect examplefilter

猜你喜欢

转载自blog.csdn.net/qq_39759656/article/details/81947611