当前位置:首页 > 编程笔记 > 正文
已解决

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

来自网友在路上 191891提问 提问时间:2023-09-29 22:31:07阅读次数: 91

最佳答案 问答题库918位专家为你答疑解惑

系列文章目录

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

文章目录

  • 系列文章目录
  • 前言
  • 一、使用gst-element-maker 创建一个videofilter 插件
    • 1. 使用 gst-element-maker 基于videofilter 基类模板创建一个 g2dfilter 插件
    • 2. 修改 g2dfilter 插件源码,支持透传功能
    • 3. 编译修改后添加透传功能的 g2dfilter 插件
    • 4. 本地电脑安装 g2dfilter 插件
  • 二、测试 g2dfilter 插件的透传功能
  • 总结
  • 参考资料

前言

本文主要介绍如何使用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 
查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"使用 gst-element-maker 创建一个完全透传的 videofilter 插件":http://eshow365.cn/6-15481-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!