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,則組件將獲得保證的唯一名稱,該名稱由組件實例名稱和數字組成。如果提供名稱,則將提供提供的名稱。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章