使用 gst-element-maker 创建一个完全透传的 videofilter 插件

本文详细介绍了如何使用gst-element-maker创建一个基于videofilter基类的GStreamer插件,并实现透传功能。通过修改gst_g2dfilter.c文件中的gst_g2dfilter_start()函数,添加gst_base_transform_set_passthrough()调用来启用透传。编译生成的libgstg2dfilter.so文件安装到系统后,通过gst-inspect-1.0验证插件安装成功,并使用gst-launch-1.0命令测试了插件的透传功能。
摘要由CSDN通过智能技术生成

系列文章目录

创建 gstreamer 插件的几种方式
使用 gst-template 创建自己的 gstreamer 插件
使用 gst-plugins-bad 里面的 gst-element-maker 工具创建gstreamer 插件
使用 gst-element-maker 创建一个完全透传的 videofilter 插件



前言

本文主要介绍如何使用gst-plugins-bad 里面的 gst-element-maker 工具创建一个基于 videofilter base class 的透传功能videofilter gstreamer插件(上一篇文章 使用 gst-plugins-bad 里面的 gst-element-maker 工具创建gstreamer 插件 只是创建了一个最基础的videofilter 插件,但是它不支持透传功能,即进入该插件 sink pad 的数据不能从该插件的 src pad 发送出去)
软硬件环境:
ubuntu18.04
meson 0.55.0
gstreamer 1.14.5
ninja 1.8.2
python 3.6.9


一、使用gst-element-maker 创建一个videofilter 插件

1. 使用 gst-element-maker 基于videofilter 基类模板创建一个 g2dfilter 插件

如下图所示,使用 gst-element-maker g2dfilter videofilter 命令生成 g2dfilter 插件相关的代码

cd gst-plugins-bad/tools
./gst-element-maker g2dfilter videofilter

在这里插入图片描述

2. 修改 g2dfilter 插件源码,支持透传功能

如下图所示,在 gstg2dfilter.c 文件中的 **gst_g2dfilter_start() **函数中添加一句 gst_base_transform_set_passthrough(trans, TRUE) 函数调用,就实现了透传功能, 至于gst_base_transform_set_passthrough() 函数的相关说明,请参考 gstreamer官网 GstBaseTransform 基类的相关资料
在这里插入图片描述
修改后的完整的gstg2dfilter.c 代码(包括添加的一些打印信息)如下:

/* GStreamer
 * Copyright (C) 2023 FIXME <fixme@example.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Suite 500,
 * Boston, MA 02110-1335, USA.
 */
/**
 * SECTION:element-gstg2dfilter
 *
 * The g2dfilter element does FIXME stuff.
 *
 * <refsect2>
 * <title>Example launch line</title>
 * |[
 * gst-launch-1.0 -v fakesrc ! g2dfilter ! FIXME ! fakesink
 * ]|
 * FIXME Describe what the pipeline does.
 * </refsect2>
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <stdint.h>
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/video/gstvideofilter.h>
#include "gstg2dfilter.h"

GST_DEBUG_CATEGORY_STATIC (gst_g2dfilter_debug_category);
#define GST_CAT_DEFAULT gst_g2dfilter_debug_category

/* prototypes */


static void gst_g2dfilter_set_property (GObject * object,
    guint property_id, const GValue * value, GParamSpec * pspec);
static void gst_g2dfilter_get_property (GObject * object,
    guint property_id, GValue * value, GParamSpec * pspec);
static void gst_g2dfilter_dispose (GObject * object);
static void gst_g2dfilter_finalize (GObject * object);

static gboolean gst_g2dfilter_start (GstBaseTransform * trans);
static gboolean gst_g2dfilter_stop (GstBaseTransform * trans);
static gboolean gst_g2dfilter_set_info (GstVideoFilter * filter, GstCaps * incaps
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值