mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
timelineelement: Implement the notion of parenting
This commit is contained in:
parent
e3dc877c4b
commit
e48b959dde
3 changed files with 103 additions and 12 deletions
|
@ -322,6 +322,8 @@ GES_TYPE_TIMELINE_LAYER
|
|||
<TITLE>GESTimelineElement</TITLE>
|
||||
GESTimelineElement
|
||||
GESTimelineElementClass
|
||||
ges_timeline_element_set_parent
|
||||
ges_timeline_element_get_parent
|
||||
ges_timeline_element_set_start
|
||||
ges_timeline_element_set_inpoint
|
||||
ges_timeline_element_set_duration
|
||||
|
@ -332,6 +334,7 @@ ges_timeline_element_ripple_end
|
|||
ges_timeline_element_roll_start
|
||||
ges_timeline_element_roll_end
|
||||
ges_timeline_element_trim
|
||||
GES_TIMELINE_ELEMENT_PARENT
|
||||
GES_TIMELINE_ELEMENT_START
|
||||
GES_TIMELINE_ELEMENT_INPOINT
|
||||
GES_TIMELINE_ELEMENT_DURATION
|
||||
|
|
|
@ -40,6 +40,7 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GESTimelineElement, ges_timeline_element,
|
|||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_PARENT,
|
||||
PROP_START,
|
||||
PROP_INPOINT,
|
||||
PROP_DURATION,
|
||||
|
@ -62,6 +63,8 @@ _get_property (GObject * object, guint property_id,
|
|||
GESTimelineElement *self = GES_TIMELINE_ELEMENT (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_PARENT:
|
||||
g_value_set_object (value, self->parent);
|
||||
case PROP_START:
|
||||
g_value_set_uint64 (value, self->start);
|
||||
break;
|
||||
|
@ -89,6 +92,9 @@ _set_property (GObject * object, guint property_id,
|
|||
GESTimelineElement *self = GES_TIMELINE_ELEMENT (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_PARENT:
|
||||
ges_timeline_element_set_parent (self, g_value_get_object (value));
|
||||
break;
|
||||
case PROP_START:
|
||||
ges_timeline_element_set_start (self, g_value_get_uint64 (value));
|
||||
break;
|
||||
|
@ -129,6 +135,16 @@ ges_timeline_element_class_init (GESTimelineElementClass * klass)
|
|||
object_class->get_property = _get_property;
|
||||
object_class->set_property = _set_property;
|
||||
|
||||
/**
|
||||
* GESTimelineElement:parent:
|
||||
*
|
||||
* The parent container of the object
|
||||
*/
|
||||
properties[PROP_PARENT] =
|
||||
g_param_spec_object ("parent", "Parent",
|
||||
"The parent container of the object", GES_TYPE_TIMELINE_ELEMENT,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
/**
|
||||
* GESTimelineElement:start:
|
||||
*
|
||||
|
@ -200,6 +216,68 @@ ges_timeline_element_class_init (GESTimelineElementClass * klass)
|
|||
* API implementation *
|
||||
*********************************************/
|
||||
|
||||
/**
|
||||
* ges_timeline_element_set_parent:
|
||||
* @self: a #GESTimelineElement
|
||||
* @parent: new parent of self
|
||||
*
|
||||
* Sets the parent of @self to @parent. The object's reference count will
|
||||
* be incremented, and any floating reference will be removed (see g_object_ref_sink()).
|
||||
*
|
||||
* Returns: %TRUE if @parent could be set or %FALSE when @self
|
||||
* already had a parent or @self and @parent are the same.
|
||||
*/
|
||||
gboolean
|
||||
ges_timeline_element_set_parent (GESTimelineElement * self,
|
||||
GESTimelineElement * parent)
|
||||
{
|
||||
g_return_val_if_fail (GES_IS_TIMELINE_ELEMENT (self), FALSE);
|
||||
g_return_val_if_fail (GES_IS_TIMELINE_ELEMENT (parent), FALSE);
|
||||
g_return_val_if_fail (self != parent, FALSE);
|
||||
|
||||
GST_DEBUG_OBJECT (self, "set parent (ref and sink)");
|
||||
|
||||
if (G_UNLIKELY (self->parent != NULL))
|
||||
goto had_parent;
|
||||
|
||||
self->parent = parent;
|
||||
g_object_ref_sink (self);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PARENT]);
|
||||
return TRUE;
|
||||
|
||||
/* ERROR handling */
|
||||
had_parent:
|
||||
{
|
||||
GST_DEBUG_OBJECT (self, "set parent failed, object already had a parent");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_timeline_element_get_parent:
|
||||
* @self: a #GESTimelineElement
|
||||
*
|
||||
* Returns the parent of @self. This function increases the refcount
|
||||
* of the parent self so you should gst_object_unref() it after usage.
|
||||
*
|
||||
* Returns: (transfer full): parent of @self, this can be %NULL if @self
|
||||
* has no parent. unref after usage.
|
||||
*/
|
||||
GESTimelineElement *
|
||||
ges_timeline_element_get_parent (GESTimelineElement * self)
|
||||
{
|
||||
GESTimelineElement *result = NULL;
|
||||
|
||||
g_return_val_if_fail (GES_IS_TIMELINE_ELEMENT (self), NULL);
|
||||
|
||||
result = self->parent;
|
||||
if (G_LIKELY (result))
|
||||
gst_object_ref (result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_timeline_element_set_start:
|
||||
* @self: a #GESTimelineElement
|
||||
|
|
|
@ -76,6 +76,13 @@ typedef struct _GESTimelineElementPrivate GESTimelineElementPrivate;
|
|||
*/
|
||||
#define GES_TIMELINE_ELEMENT_PRIORITY(obj) (((GESTimelineElement*)obj)->priority)
|
||||
|
||||
/**
|
||||
* GES_TIMELINE_ELEMENT_PARENT:
|
||||
* @obj: a #GESTimelineElement
|
||||
*
|
||||
* The parent of the object.
|
||||
*/
|
||||
#define GES_TIMELINE_ELEMENT_PARENT(obj) (((GESTimelineElement*)obj)->parent)
|
||||
|
||||
/**
|
||||
* GESTimelineElementClass:
|
||||
|
@ -132,7 +139,8 @@ struct _GESTimelineElement
|
|||
{
|
||||
GInitiallyUnowned parent_instance;
|
||||
|
||||
/*< protected >*/
|
||||
/*< read only >*/
|
||||
GESTimelineElement *parent;
|
||||
GESAsset *asset;
|
||||
GstClockTime start;
|
||||
GstClockTime inpoint;
|
||||
|
@ -149,17 +157,19 @@ struct _GESTimelineElement
|
|||
|
||||
GType ges_timeline_element_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void ges_timeline_element_set_start (GESTimelineElement *self, GstClockTime start);
|
||||
void ges_timeline_element_set_inpoint (GESTimelineElement *self, GstClockTime inpoint);
|
||||
void ges_timeline_element_set_duration (GESTimelineElement *self, GstClockTime duration);
|
||||
void ges_timeline_element_set_max_duration (GESTimelineElement *self, GstClockTime duration);
|
||||
void ges_timeline_element_set_priority (GESTimelineElement *self, guint32 priority);
|
||||
gboolean ges_timeline_element_ripple (GESTimelineElement *self, GstClockTime start);
|
||||
gboolean ges_timeline_element_ripple_end (GESTimelineElement *self, GstClockTime end);
|
||||
gboolean ges_timeline_element_roll_start (GESTimelineElement *self, GstClockTime start);
|
||||
gboolean ges_timeline_element_roll_end (GESTimelineElement *self, GstClockTime end);
|
||||
gboolean ges_timeline_element_trim (GESTimelineElement *self, GstClockTime start);
|
||||
GESTimelineElement * ges_timeline_element_copy (GESTimelineElement *self, gboolean deep);
|
||||
GESTimelineElement * ges_timeline_element_get_parent (GESTimelineElement * self);
|
||||
gboolean ges_timeline_element_set_parent (GESTimelineElement *self, GESTimelineElement *parent);
|
||||
void ges_timeline_element_set_start (GESTimelineElement *self, GstClockTime start);
|
||||
void ges_timeline_element_set_inpoint (GESTimelineElement *self, GstClockTime inpoint);
|
||||
void ges_timeline_element_set_duration (GESTimelineElement *self, GstClockTime duration);
|
||||
void ges_timeline_element_set_max_duration (GESTimelineElement *self, GstClockTime duration);
|
||||
void ges_timeline_element_set_priority (GESTimelineElement *self, guint32 priority);
|
||||
gboolean ges_timeline_element_ripple (GESTimelineElement *self, GstClockTime start);
|
||||
gboolean ges_timeline_element_ripple_end (GESTimelineElement *self, GstClockTime end);
|
||||
gboolean ges_timeline_element_roll_start (GESTimelineElement *self, GstClockTime start);
|
||||
gboolean ges_timeline_element_roll_end (GESTimelineElement *self, GstClockTime end);
|
||||
gboolean ges_timeline_element_trim (GESTimelineElement *self, GstClockTime start);
|
||||
GESTimelineElement * ges_timeline_element_copy (GESTimelineElement *self, gboolean deep);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in a new issue