gstreamer-插件开发的简单过程

创建videoprocess插件

Gstreamer的插件开发使用模板工具生成框架非常方便,比如我这里要实现一个videoprocess插件,使用gst-plugins-bad/toolsgst-element-maker 生成代码框架,然后再添加实际功能,可以达到事半功倍的效果。

  1. 根据插件模板创建插件videoprocess,videoprocess的bass class是videofilter

注意,这个videoprocess作为element的名字,如果写成video_process生成的代码中,就是gst_video_process_xxx这样,不然就是gst_videoprocess_xxx

cd gst-plugins-bad/tools
./gst-element-maker videoprocess videofilter
  1. 创建videoprocess目录
# cd gst-plugins-bad
mkdir ext/videoprocess/
cp tools/gstvideoprocess.* ext/videoprocess/
  1. 修改videoprocess/meson.build

添加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]
  1. 修改ext/meson.build
subdir('videoprocess')
  1. 修改gst-plugins-bad/meson_option.txt
   option('videoprocess', type : 'feature', value : 'auto')
  1. 增加编译选项
-Dgst-plugins-bad:videoprocess=enabled
  1. 设置环境变量:

设置环境变量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
  1. 编译安装:
ninja -C build install
  1. gst-inspect videoprocess
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 ]

你可能感兴趣的:(gstreamer,linux)