名词
概念
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));
使用Glib mainloop时总线信号处理函数注册可用方式:
1 2 3 4 5 6 7 8 |
GstBus *bus; bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); gst_bus_add_signal_watch (bus); g_signal_connect (bus, "message::error", G_CALLBACK (cb_message_error), NULL); g_signal_connect (bus, "message::eos", G_CALLBACK (cb_message_eos), NULL); |
12345
Buffer包含数据指针和时间戳,被引用总数,标志位 Event包含查询,刷新和流结束通知等事件
1 2 3 4 5 |
Buffer包含数据指针和时间戳,被引用总数,标志位 Event包含查询,刷新和流结束通知等事件 |
123
gst-launch-1.0 playbin uri=file:///home/rease/Downloads/2.mp3
1 2 3 |
gst-launch-1.0 playbin uri=file:///home/rease/Downloads/2.mp3 |
以上为播放音频
动态Pads
当需要创建动态pipeline的时候,可以绑定信号处理函数到特定的element,当element自动创建完新的pad会发出pad-added信号,只要捕获此信号,就可以在信号处理函数中完成需要完成的动作,如element之间的链接(link)
1 2 3 |
g_signal_connect (GstElement, "pad-added", G_CALLBACK (cb_new_pad), NULL); |
1 2 3 4 5 6 7 8 9 10 11 12 |
static void cb_new_pad (GstElement *element, GstPad *pad, gpointer data) { gchar *name; name = gst_pad_get_name (pad); g_print ("A new pad %s was created\n", name); g_free (name); /* here, you would setup a new pad link for the newly created pad */ [..] } |
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等), 嵌入音频和视频