Gstreamer API
官网tutorial basic tutorial
element
GstElementFactory *gst_element_factory_find (const gchar * name) | 根据给定的名称查找GstElementFactory |
GstElement *gst_element_factory_create (GstElementFactory * factory, const gchar * name) | 创建由factory定义的GstElement |
GstElement *gst_pipeline_new (const gchar * name) | 创建pipeline, pipeline 是一种GstElement |
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.
每一个pipeline都有带有一个默认的bus,所以应用程序不需要去创建bus。
应用程序要做的事情是创建bus上的消息处理程序。
消息处理程序的机制是,在mainloop中会周期性的检查是否有新消息。当消息可用时,回调函数触发。
GstBus *gst_pipeline_get_bus (GstPipeline * pipeline) | Gets the GstBus of pipeline |
guint gst_bus_add_watch (GstBus * bus, GstBusFunc func, gpointer user_data) | Adds a bus watch to the default main context with the default priority ( G_PRIORITY_DEFAULT ) |
gst_bus_add_signal_watch_full (GstBus * bus, gint priority) | Adds a bus signal watch to the default main context with the given priority (e.g. G_PRIORITY_DEFAULT). |
6 Pad&Capabilities
pad 是element通向外部世界的接口。element可以出处理的特定类型的媒体信息通过pad 的capability 呈现出来。
Pad
pad 由两个属性定义,方向和可用性 direction and its availability。gstreamer定义了两个方向 source pad 和sink pad。element 从source pad上产生数据,从sink pad上接收数据。source pad 画在element的左边表示产生数据的接口,sink pad画在element的右边表示接收数据的接口。这样把element连接起来,表示数据流从左向右流动。
pad有三种可用性,always,sometimes 和 on request。always表示一直可用,sometimes 表示在某些条件下可用,on request 表示必须在应用程序申请时可用。
guint gst_element_factory_get_num_pad_templates (GstElementFactory * factory) | 获取factory 内的pad_templates数量 |
const GList *gst_element_factory_get_static_pad_templates (GstElementFactory * factory) | 获取factory内的 GstStaticPadTemplate list |
GstCaps *gst_static_caps_get (GstStaticCaps * static_caps) | 将GstStaticCaps转化为GstCaps |
GstPad *gst_element_get_static_pad (GstElement * element, const gchar * name) | 从element中根据名字获取GstPad |
GstCaps *gst_pad_get_current_caps (GstPad * pad) | 从GstPad中获取GstCaps |