gstreamer---如何创建gstreamer插件?

  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

  至此,创建gstreamer插件完毕。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,992评论 19 139
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 46,972评论 6 342
  • gstreamer gstreamer 概述GStreamer是一个创建流媒体应用程序的框架。其基本设计思想来自于...
    vmnabix阅读 9,860评论 0 4
  • 2018年8月13日周一早安 天气:25℃-36℃ 悦读开启美好的一天 《薛兆丰的经济学课》026丨征地的权衡 科...
    素SU然阅读 89评论 0 0
  • 我的小小心房 总有头鹿 当我想你时 它就狂跳不止 我不知如何是好 它跌跌撞撞,不知停息 幸好我只是路过你 幸好你没...
    方成学长阅读 419评论 2 8