我查了GInitiallyUnowned的相关资料,在gobject.h文件中
typedef struct _GObject GObject;
typedef struct _GObjectClass GObjectClass;
typedef struct _GObject GInitiallyUnowned;
typedef struct _GObjectClass GInitiallyUnownedClass;
从语法角度理解,GObject和GInitiallyUnowned指向的结构体是相同的,也就是两者并无区别。但是从GObject Reference Manual中了解到:
GInitiallyUnowned is derived from GObject. The only difference between the two is that the initial reference of a GInitiallyUnowned is flagged as a floating reference. This means that it is not specifically claimed to be “owned” by any code portion. The main motivation for providing floating references is C convenience. In particular, it allows code to be written as:
GInitiallyUnowned源自GObject。两者之间唯一的区别是GInitiallyUnowned的初始引用被标记为floating引用。这意味着它不被任何代码部分明确声明为“拥有”。提供floating引用的主要动机是C语言的便利性。特别是,它允许代码写成:
关于floating引用我不明白作用是什么
GstObject为GStreamer库提供了一个根基。它目前是GInitiallyUnowned之上的一个薄包装。它是一个抽象类,单独使用不是很方便。
GstObject为我们提供了基本的引用计数、父类方法和锁。大多数函数只是为特定的GStreamer需求而扩展,可以在GstObject的基类GObject下找到相同的名称(例如g_object_ref成为gst_object_ref)。
由于GstObject继承于 GInitiallyUnowned,因此它也继承了浮动引用(我的理解:浮动引用传入指针的时候,不会refcount,比如gst_bin_addd)。请注意,gst_bin_add和gst_element_add_pad等函数拥有浮动引用。
与GObject实例不同,GstObject添加了name属性。函数gst_object_set_name和gst_object_get_name用于设置/获取对象的名称。
不理解这部分的作用
controlled properties
Controlled properties offers a lightweight way to adjust gobject properties over stream-time. It works by using time-stamped value pairs that are queued for element-properties. At run-time the elements continuously pull value changes for the current stream-time.
What needs to be changed in a GstElement? Very little - it is just two steps to make a plugin controllable!
mark gobject-properties paramspecs that make sense to be controlled, by GST_PARAM_CONTROLLABLE.
when processing data (get, chain, loop function) at the beginning call gst_object_sync_values(element,timestamp). This will make the controller update all GObject properties that are under its control with the current values based on the timestamp.
What needs to be done in applications? Again it’s not a lot to change.
create a GstControlSource. csource = gst_interpolation_control_source_new (); g_object_set (csource, “mode”, GST_INTERPOLATION_MODE_LINEAR, NULL);
Attach the GstControlSource on the controller to a property. gst_object_add_control_binding (object, gst_direct_control_binding_new (object, “prop1”, csource));
Set the control values gst_timed_value_control_source_set ((GstTimedValueControlSource *)csource,0 * GST_SECOND, value1); gst_timed_value_control_source_set ((GstTimedValueControlSource *)csource,1 * GST_SECOND, value2);
start your pipeline
GObject╰──GInitiallyUnowned╰──GstObject╰──GstAllocator╰──GstBufferPool╰──GstBus╰──GstClock╰──GstControlBinding╰──GstControlSource╰──GstDevice╰──GstDeviceMonitor╰──GstDeviceProvider╰──GstElement╰──GstPad╰──GstPadTemplate╰──GstPlugin╰──GstPluginFeature╰──GstRegistry╰──GstStream╰──GstStreamCollection╰──GstTask╰──GstTaskPool╰──GstTracer╰──GstTracerRecord
typedef struct _GstObject GstObject;
struct _GstObject {GInitiallyUnowned object;/*< public >*/ /* with LOCK */GMutex lock; /* object LOCK */gchar *name; /* object name */GstObject *parent; /* this object's parent, weak ref */guint32 flags;/*< private >*/GList *control_bindings; /* List of GstControlBinding */guint64 control_rate;guint64 last_sync;gpointer _gst_reserved;
};
“name” gchar *
“parent” GstObject * /*这个对象的父类*/
参考:GstObject