mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-05 10:12:20 +00:00
GESTimelineObject: Subclass from GInitiallyUnowned
The floating reference will be owned by the Layer
This commit is contained in:
parent
11887e0058
commit
1450d539d4
5 changed files with 29 additions and 12 deletions
|
@ -212,13 +212,15 @@ objects_start_compare (GESTimelineObject * a, GESTimelineObject * b)
|
||||||
/**
|
/**
|
||||||
* ges_timeline_layer_add_object:
|
* ges_timeline_layer_add_object:
|
||||||
* @layer: a #GESTimelineLayer
|
* @layer: a #GESTimelineLayer
|
||||||
* @object: the #GESTimelineObject to add.
|
* @object: (transfer full): the #GESTimelineObject to add.
|
||||||
*
|
*
|
||||||
* Adds the object to the layer. The layer will steal a reference to the
|
* Adds the given object to the layer. Sets the object's parent, and thus
|
||||||
* provided object.
|
* takes ownership of the object.
|
||||||
|
*
|
||||||
|
* An object can only be added to one layer.
|
||||||
*
|
*
|
||||||
* Returns: TRUE if the object was properly added to the layer, or FALSE
|
* Returns: TRUE if the object was properly added to the layer, or FALSE
|
||||||
* if the @layer refused to add the object.
|
* if the @layer refuses to add the object.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -230,12 +232,15 @@ ges_timeline_layer_add_object (GESTimelineLayer * layer,
|
||||||
GST_DEBUG ("layer:%p, object:%p", layer, object);
|
GST_DEBUG ("layer:%p, object:%p", layer, object);
|
||||||
|
|
||||||
tl_obj_layer = ges_timeline_object_get_layer (object);
|
tl_obj_layer = ges_timeline_object_get_layer (object);
|
||||||
|
|
||||||
if (G_UNLIKELY (tl_obj_layer)) {
|
if (G_UNLIKELY (tl_obj_layer)) {
|
||||||
GST_WARNING ("TimelineObject %p already belongs to another layer");
|
GST_WARNING ("TimelineObject %p already belongs to another layer");
|
||||||
g_object_unref (tl_obj_layer);
|
g_object_unref (tl_obj_layer);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_object_ref_sink (object);
|
||||||
|
|
||||||
/* Take a reference to the object and store it stored by start/priority */
|
/* Take a reference to the object and store it stored by start/priority */
|
||||||
layer->priv->objects_start =
|
layer->priv->objects_start =
|
||||||
g_slist_insert_sorted (layer->priv->objects_start, object,
|
g_slist_insert_sorted (layer->priv->objects_start, object,
|
||||||
|
@ -268,18 +273,23 @@ ges_timeline_layer_add_object (GESTimelineLayer * layer,
|
||||||
* @layer: a #GESTimelineLayer
|
* @layer: a #GESTimelineLayer
|
||||||
* @object: the #GESTimelineObject to remove
|
* @object: the #GESTimelineObject to remove
|
||||||
*
|
*
|
||||||
* Removes the given @object from the @layer. The reference stolen by the @layer
|
* Removes the given @object from the @layer and unparents it.
|
||||||
* when the object was added will be removed. If you wish to use the object after
|
* Unparenting it means the reference owned by @layer on the @object will be
|
||||||
* this function, make sure you take an extra reference to the object before
|
* removed. If you wish to use the @object after this function, make sure you
|
||||||
* calling this function.
|
* call g_object_ref() before removing it from the @layer.
|
||||||
*
|
*
|
||||||
* Returns: TRUE if the object was properly remove, else FALSE.
|
* Returns: TRUE if the object could be removed, FALSE if the layer does
|
||||||
|
* not want to remove the object.
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
ges_timeline_layer_remove_object (GESTimelineLayer * layer,
|
ges_timeline_layer_remove_object (GESTimelineLayer * layer,
|
||||||
GESTimelineObject * object)
|
GESTimelineObject * object)
|
||||||
{
|
{
|
||||||
GESTimelineLayer *tl_obj_layer;
|
GESTimelineLayer *tl_obj_layer;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GES_IS_TIMELINE_LAYER (layer), FALSE);
|
||||||
|
g_return_val_if_fail (GES_IS_TIMELINE_OBJECT (object), FALSE);
|
||||||
|
|
||||||
GST_DEBUG ("layer:%p, object:%p", layer, object);
|
GST_DEBUG ("layer:%p, object:%p", layer, object);
|
||||||
|
|
||||||
tl_obj_layer = ges_timeline_object_get_layer (object);
|
tl_obj_layer = ges_timeline_object_get_layer (object);
|
||||||
|
|
|
@ -54,7 +54,8 @@ static void
|
||||||
track_object_priority_changed_cb (GESTrackObject * child,
|
track_object_priority_changed_cb (GESTrackObject * child,
|
||||||
GParamSpec * arg G_GNUC_UNUSED, GESTimelineObject * object);
|
GParamSpec * arg G_GNUC_UNUSED, GESTimelineObject * object);
|
||||||
|
|
||||||
G_DEFINE_ABSTRACT_TYPE (GESTimelineObject, ges_timeline_object, G_TYPE_OBJECT);
|
G_DEFINE_ABSTRACT_TYPE (GESTimelineObject, ges_timeline_object,
|
||||||
|
G_TYPE_INITIALLY_UNOWNED);
|
||||||
|
|
||||||
/* Mapping of relationship between a TimelineObject and the TrackObjects
|
/* Mapping of relationship between a TimelineObject and the TrackObjects
|
||||||
* it controls
|
* it controls
|
||||||
|
|
|
@ -156,7 +156,7 @@ typedef gboolean (*GESCreateTrackObjectsFunc) (GESTimelineObject * object,
|
||||||
*/
|
*/
|
||||||
struct _GESTimelineObject {
|
struct _GESTimelineObject {
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
GObject parent;
|
GInitiallyUnowned parent;
|
||||||
|
|
||||||
GESTimelineObjectPrivate *priv;
|
GESTimelineObjectPrivate *priv;
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ struct _GESTimelineObject {
|
||||||
*/
|
*/
|
||||||
struct _GESTimelineObjectClass {
|
struct _GESTimelineObjectClass {
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
GObjectClass parent_class;
|
GInitiallyUnownedClass parent_class;
|
||||||
|
|
||||||
/*< public >*/
|
/*< public >*/
|
||||||
GESCreateTrackObjectFunc create_track_object;
|
GESCreateTrackObjectFunc create_track_object;
|
||||||
|
|
|
@ -93,11 +93,15 @@ GST_START_TEST (test_ges_scenario)
|
||||||
source = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
source = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
||||||
fail_unless (source != NULL);
|
fail_unless (source != NULL);
|
||||||
|
|
||||||
|
/* The source will be floating before added to the layer... */
|
||||||
|
fail_unless (g_object_is_floating (source));
|
||||||
GST_DEBUG ("Adding the source to the timeline layer");
|
GST_DEBUG ("Adding the source to the timeline layer");
|
||||||
fail_unless (ges_timeline_layer_add_object (layer,
|
fail_unless (ges_timeline_layer_add_object (layer,
|
||||||
GES_TIMELINE_OBJECT (source)));
|
GES_TIMELINE_OBJECT (source)));
|
||||||
|
fail_if (g_object_is_floating (source));
|
||||||
tmp_layer = ges_timeline_object_get_layer (GES_TIMELINE_OBJECT (source));
|
tmp_layer = ges_timeline_object_get_layer (GES_TIMELINE_OBJECT (source));
|
||||||
fail_unless (tmp_layer == layer);
|
fail_unless (tmp_layer == layer);
|
||||||
|
/* The timeline stole our reference */
|
||||||
ASSERT_OBJECT_REFCOUNT (source, "source", 1);
|
ASSERT_OBJECT_REFCOUNT (source, "source", 1);
|
||||||
g_object_unref (tmp_layer);
|
g_object_unref (tmp_layer);
|
||||||
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
||||||
|
|
|
@ -97,8 +97,10 @@ GST_START_TEST (test_layer_properties)
|
||||||
assert_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (object), 0);
|
assert_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (object), 0);
|
||||||
|
|
||||||
/* Add the object to the timeline */
|
/* Add the object to the timeline */
|
||||||
|
fail_unless (g_object_is_floating (object));
|
||||||
fail_unless (ges_timeline_layer_add_object (layer,
|
fail_unless (ges_timeline_layer_add_object (layer,
|
||||||
GES_TIMELINE_OBJECT (object)));
|
GES_TIMELINE_OBJECT (object)));
|
||||||
|
fail_if (g_object_is_floating (object));
|
||||||
trackobject = ges_timeline_object_find_track_object (object, track,
|
trackobject = ges_timeline_object_find_track_object (object, track,
|
||||||
G_TYPE_NONE);
|
G_TYPE_NONE);
|
||||||
fail_unless (trackobject != NULL);
|
fail_unless (trackobject != NULL);
|
||||||
|
|
Loading…
Reference in a new issue