参考资料:
在Constructing the Boilerplate 里面有生成插件的例子,
shell $ git clone https://gitlab.freedesktop.org/gstreamer/gst-template.git
使用里面的工具自动生成一个插件程序,比如MyFilter
shell $ cd gst-template/gst-plugin/src
shell $ ../tools/make_element MyFilter
注意,这样生成的自定义的element的名字使用起来应该是my_filter,
画一下图,就比较容易理解生成的代码结构
class的定义,init
element的定义,init
pad(sink,src)的定义
属性的设置和获取处理
chain的处理
event事件的处理
代码参考
/**
* SECTION:element-myfilter
*
* FIXME:Describe myfilter here.
*
* <refsect2>
* <title>Example launch line</title>
* |[
* gst-launch -v -m fakesrc ! myfilter ! fakesink silent=TRUE
* ]|
* </refsect2>
*/a
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifndef __GST_MYFILTER_H__
#define __GST_MYFILTER_H__
#include <gst/gst.h>
#include <stdio.h>
G_BEGIN_DECLS
#define GST_TYPE_MYFILTER (gst_my_filter_get_type())
G_DECLARE_FINAL_TYPE (GstMyFilter, gst_my_filter,
GST, MYFILTER, GstElement)
struct _GstMyFilter
{
GstElement element;
GstPad *sinkpad, *srcpad;
gboolean width;
gboolean height;
gboolean silent;
};
G_END_DECLS
#endif /* __GST_MYFILTER_H__ */
GST_DEBUG_CATEGORY_STATIC (gst_my_filter_debug);
#define GST_CAT_DEFAULT gst_my_filter_debug
#define DEFAULT_PROP_WIDTH 0 /* Original */
#define DEFAULT_PROP_HEIGHT 0 /* Original */
/* F