Gstreamer的插件开发使用模板工具生成框架非常方便,比如我这里要实现一个videoprocess插件,使用gst-plugins-bad/toolsgst-element-maker
生成代码框架,然后再添加实际功能,可以达到事半功倍的效果。
注意,这个videoprocess作为element的名字,如果写成video_process
生成的代码中,就是gst_video_process_xxx
这样,不然就是gst_videoprocess_xxx
。
cd gst-plugins-bad/tools
./gst-element-maker videoprocess videofilter
# cd gst-plugins-bad
mkdir ext/videoprocess/
cp tools/gstvideoprocess.* ext/videoprocess/
添加include_directories,pkgconfig,plugins,修改c_args
# The myfilter Plugin
gstvideoprocess_sources = [
'gstvideoprocess.c',
]
gstvideoprocess = library('gstvideoprocess',
gstvideoprocess_sources,
c_args: gst_plugins_bad_args,
dependencies : [gstbase_dep, gstvideo_dep],
install : true,
include_directories : [configinc],
install_dir : plugins_install_dir,
)
pkgconfig.generate(gstvideoprocess, install_dir : plugins_pkgconfig_install_dir)
plugins += [gstvideoprocess]
subdir('videoprocess')
option('videoprocess', type : 'feature', value : 'auto')
-Dgst-plugins-bad:videoprocess=enabled
设置环境变量GST_PLUGIN_PATH到inst下,方便开发调试:
export DESTDIR=`pwd`/inst
设置GST_PLUGIN_PATH:
export GST_PLUGIN_PATH=/home/hui/disk4t/codes/gstreamer/gst-open-source/gstreamer-meson/inst/usr/local/lib/x86_64-linux-gnu/gstreamer-1.0
ninja -C build install
Pad Templates:
SINK template: 'sink'
Availability: Always
Capabilities:
video/x-raw
format: { (string)I420, (string)Y444, (string)Y42B, (string)UYVY, (string)RGBA }
width: [ 1, 2147483647 ]
height: [ 1, 2147483647 ]
framerate: [ 0/1, 2147483647/1 ]
SRC template: 'src'
Availability: Sometimes
Capabilities:
video/x-raw
format: { (string)I420, (string)Y444, (string)Y42B, (string)UYVY, (string)RGBA }
width: [ 1, 2147483647 ]
height: [ 1, 2147483647 ]
framerate: [ 0/1, 2147483647/1 ]