GStream常用类及其类间关系

目录

1.GstObject类继承关系

2. GstElement

GstElement

3.GstBin

GstBin类继承关系

4. GstPad

GstPad类继承关系

5. GstElementFactory

 GstElementFactory

gst_element_facotry_make

 


1.GstObject类继承关系

GObject
    ╰──GInitiallyUnowned
        ╰──GstObject
            ╰──GstAllocator
            ╰──GstBufferPool
            ╰──GstBus
            ╰──GstClock
            ╰──GstControlBinding
            ╰──GstControlSource
            ╰──GstDevice
            ╰──GstDeviceMonitor
            ╰──GstDeviceProvider
            ╰──GstElement
            ╰──GstPad
            ╰──GstPadTemplate
            ╰──GstPlugin
            ╰──GstPluginFeature
            ╰──GstRegistry
            ╰──GstStream
            ╰──GstStreamCollection
            ╰──GstTask
            ╰──GstTaskPool
            ╰──GstTracer
            ╰──GstTracerRecord

2. GstElement

GstElement 是GStreamer管道(pipeline)中构建组件的抽象基类。GstElement子类的更多信息,请参考插件编写者指南。

组件可以有Pad (类型为 GstPad). 这些pads与其他组件的pads相连接。在pads中流动数据的是 GstBuffer 。每个GstElement 的输入(或 槽sink)和输出(或源source)的 pads都有一个GstPad类型的GList 。

每个组件都有一个state (参见GstState).

如果设置了 GST_ELEMENT_FLAG_PROVIDE_CLOCK 标志,一些组件可以为管道提供时钟。不是所有的组件都需要时钟。注意,时钟的选择和分配通常由顶级GstPipeline处理,因此时钟功能仅在非常特殊的情况下使用。

GstElement

GObject
    ╰──GInitiallyUnowned
        ╰──GstObject
            ╰──GstElement
                ╰──GstBin

3.GstBin

GstBin是包含了GstElement的一个容器,可以处理一组组件。子组件的pad可以重影到bin,请参见GstGhostPad。这使bin看起来像其他任何组件,并允许创建更高级别的抽象组件。

gst_bin_new:创建新的GstBin;

GstPipeline:创建顶层bin。普通的bin不包含总线bus或handle clock distribution

gst_bin_add:添加组件;

gst_bin_remove:移除组件;

gst_bin_get_by_name:在bin中通过名称查询某个组件;

gst_bin_get_by_name_recurse_up :主要用于内部目的,当在当前容器中找不到该组件时,它将查询父容器。

gst_bin_iterate_elements:在bin中查询组件迭代器;

gst_object_unref:删除bin中资源;

每当将新组件添加到容器bin中时,都会触发添加 element-added信号。同样,只要将组件从bin中移出,就会发出元素移出信号element-removed

GstBin类继承关系

GObject
    ╰──GInitiallyUnowned
        ╰──GstObject
            ╰──GstElement
                ╰──GstBin
                    ╰──GstPipeline

4. GstPad

GstElement通过"pads"连接, 这是轻量的通用连接点。

Pads有GstPadDirection, source pads生产数据,sink pads消费data。

  • GstPadTemplate + gst_pad_new_from_template :创建pad,通常之后会加入到GstElement. 这通常发生在组件创建时,但是也可以发生在组件处理数据或应用程序请求pads时。
  • gst_pad_new:创建没有pad模板的pads, 方向和名称都作为参数。如果名字时NULL,会确保一个唯一命名。

一个 GstElement 创建一个pad,通常会使用不同的 gst_pad_set_*_function() 函数回调去注册pads上的回调事件、请求、数据流。

在pads上的数据流准备好之前,需要激活pad。

可以使用可以与gst_pad_add_probe一起安装的探针来监视在Pad上发生的数据流,事件和查询。

pad有偏移量,该偏移量将应用于通过pad传递的所有数据的运行时间。

GstPad类继承关系

GObject
    ╰──GInitiallyUnowned
        ╰──GstObject
            ╰──GstPad
                ╰──GstProxyPad

5. GstElementFactory

GstElementFactory用来创建组件实例。一个GstElementFactory可以插入到 GstPlugin,因为它也是一个GstPluginFeature

创建GstFileSrc组件

#include <gst/gst.h>

   GstElement *src;  //定义一个组件
   GstElementFactory *srcfactory;  //定义一个组件实例

   gst_init (&argc, &argv);

   srcfactory = gst_element_factory_find ("filesrc");
   g_return_if_fail (srcfactory != NULL);
   src = gst_element_factory_create (srcfactory, "src");
   g_return_if_fail (src != NULL);
   ...

   // 或者用下面方法等效
   gst_element_factory_make("srcfactory","src");

 GstElementFactory

GObject
    ╰──GInitiallyUnowned
        ╰──GstObject
            ╰──GstPluginFeature
                ╰──GstElementFactory

gst_element_facotry_make

GstElement *
gst_element_factory_make (const gchar * factoryname,
                          const gchar * name)

创建由给定组件实例定义的类型的新组件。如果name为NULL,则组件将获得保证的唯一名称,该名称由组件实例名称和数字组成。如果提供名称,则将提供提供的名称。

 

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值