GStreamer学习4----写一个插件

参考资料:

Constructing the Boilerplate

gstreamer插件-优快云博客

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值