GStreamer学习笔记 – 基础名词概念篇

一. 基础名词概念

名词 概念
Elements An element is the most important class of objects in GStreamer.
Pads Pads are an element’s input and output, where you can connect other elements. A pad type is defined by two properties: its direction and its availability.
Bins A bin is a container for a collection of elements.
Pipelines A pipeline is a top-level bin.
Bus A bus is a simple system that takes care of forwarding messages from the streaming threads to an application in its own thread context
Capabilities(short: caps) describe the type of data that is streamed between two pads, or that one pad (template) supports.
Ghost pads A pad from some element in the bin that can be accessed directly from the bin as well. gst_element_add_pad (bin, gst_ghost_pad_new (“sink”, pad));

一. Bus

  • 每一个管道默认拥有一个总线Bus(不知道是不是这么翻译),不需要自己创建,只需设置消息处理函数到总线上即可,总线会自动周期检查消息并调用设置好的回调函数。

使用Glib mainloop时总线信号处理函数注册可用方式:

二. 流经管道的数据包括了实际媒体数据和相关控制信息,名为Buffer和Event




三. Pads

Pad 的3种可用性

可用性 代表意思
Dynamic(or sometimes) pads Sometimes pads exist only in certain cases ( can disappear reanomly)
Request pads Appears only if explicitly requested by applications
Always pads pads always exist
  • 动态Pads



  • Request pads

    request pads不像dynamic pads一样会被自动创建,而是按需创建的。
    这种功能在一些场合,如在多路复用器,聚合器和Tee elements中非常有用。
    所谓聚合器是指elements将多个输入汇合成一个输出,Tee elements刚好相反。

    可以通过 gst_element_get_request_pad (TeeElement, name)来获取特定名称的pad,或者使用 gst_element_get_compatible_pad (GstElement, toLinkPad, NULL)自动选择获取与将要链接的源pad兼容的目标pad。再用 gst_pad_link (tolink_pad, pad)进行链接。

    Ogg可以以各种格式(如Dirac,MNG,CELT,MPEG-4,MP3等), 嵌入音频和视频