GStreamer容易混淆的概念集锦

Q: Bus message和Event有什么不同?和signal又有什么不同? 
A: 
bus message是用于gstreamer和application之间交互用的,比如EOS,如果是bus message则是gstreamer告诉app -- End of Stream。而Event是用于gstreamer内部的,比如src element发出EOS Event,然后该event顺着pipeline一路传递到downstream elements,这些elements可以得到通知,从而做一些cleanup的工作,然后继续将event传递下去。这应该就是bus message和event不同的地方。 
对于EOS,可以参考gst_event_new_eos函数的说明,说的很清楚,element产生EOS,然后顺着一路下去,一直到最后的sink element,如果pipeline中所有的sink element都发出了EOS,那么,gstreamer自动产生一个EOS的GstMessage,这就能被app程序捕捉到了。所以,GstMessage是用于app和gstreamer沟通的,内部则是event。 
gst_event_new_eos这个函数的说明如下: 

=================================================== 
Create a new EOS event. The eos event can only travel downstream synchronized with the buffer flow. Elements that receive the EOS event on a pad can return GST_FLOW_UNEXPECTED as a GstFlowReturn when data after the EOS event arrives. 
The EOS event will travel down to the sink elements in the pipeline which will then post the GST_MESSAGE_EOS on the bus after they have finished playing any buffered data. 
When all sinks have posted an EOS message, an EOS message is forwarded to the application. 
=================================================== 

signal和message/event都不一样,signal其实来自于GObject体系,是application和gobject交互用的。在gstreamer中,element本身也是gobject,所以,通过signal,就可以将app和element联系起来,当element发生了一些事情相让app知道时,就可以用signal的方式来通知app -- 比如动态创建了一个Pad。和Bus message不同,bus message是pipeline上的,一般是app和pipeline交互的一种方法。signal则具体到了每个element。 

Q: Property, Dynamic Controllable Property, Interface有什么不同? 
A: 
Property来自GObject,就是对象的属性,使用_install_property函数定义。每个property可以对应的定义get/set方法;Dynamic Controllable Property是一种可以在stream-time,其实就是runtime动态修改Property value的东西,是gstreamer引入的,对于一些和GUI交互的时候,这种东西有点用处。我们可以定义多长时间就自动给某个Property赋成什么样的值,所以叫Dynamic Controllable Property,可以参考AppDev Manual Chapater 15的内容;Interface也是来自GObject,和Java的Interface非常类似,GObject不支持多重继承,所以和Java一样,整出一个Interface来间接实现多重继承。Interface定义的时候和一个GObject类似,只不过只需要定义Class Structure而不需要定义Instance Structure(因为Interface无法实例化),在Interface中定义好需要实现的函数(GLib 2.14之后Interface中可以定义Property了,当然也需要实现该Interface的gobject来实现该Property),然后和平常一样生成一个gobject,如果该gobject需要implement某个interface的话,在g_type_register_static注册完后,再调用g_type_add_interface_static就可以实现一个interface。g_type_add_interface_static中要提供一个GInterfaceInfo的structure,其中要指定interface的init函数,我们就可以在这个函数中,将Interface中定义好的函数指针换成我们gobject中函数的指针,这样就等于实现了这个interface中的方法。
原文地址:https://www.cnblogs.com/super119/p/1924413.html