diff --git a/docs/libs/ges-sections.txt b/docs/libs/ges-sections.txt index c8e14aad46..5560348e2c 100644 --- a/docs/libs/ges-sections.txt +++ b/docs/libs/ges-sections.txt @@ -244,6 +244,7 @@ ges_timeline_layer_add_object ges_timeline_layer_new ges_timeline_layer_remove_object ges_timeline_layer_set_priority +ges_timeline_layer_get_priority ges_timeline_layer_get_objects GESTimelineLayerPrivate diff --git a/ges/ges-keyfile-formatter.c b/ges/ges-keyfile-formatter.c index a32ca1bc79..f3c37705d5 100644 --- a/ges/ges-keyfile-formatter.c +++ b/ges/ges-keyfile-formatter.c @@ -117,7 +117,8 @@ save_keyfile (GESFormatter * keyfile_formatter, GESTimeline * timeline) type = "default"; } - g_key_file_set_integer (kf, buffer, "priority", layer->priority); + g_key_file_set_integer (kf, buffer, "priority", + ges_timeline_layer_get_priority (layer)); g_key_file_set_value (kf, buffer, "type", type); objs = ges_timeline_layer_get_objects (layer); diff --git a/ges/ges-timeline-layer.c b/ges/ges-timeline-layer.c index b94cb5a430..b4790132d0 100644 --- a/ges/ges-timeline-layer.c +++ b/ges/ges-timeline-layer.c @@ -37,8 +37,12 @@ G_DEFINE_TYPE (GESTimelineLayer, ges_timeline_layer, G_TYPE_OBJECT); struct _GESTimelineLayerPrivate { - /* Dummy variable */ - void *nothing; + /*< private > */ + GSList *objects_start; /* The TimelineObjects sorted by start and + * priority */ + + guint32 priority; /* The priority of the layer within the + * containing timeline */ }; enum @@ -66,7 +70,7 @@ ges_timeline_layer_get_property (GObject * object, guint property_id, switch (property_id) { case PROP_PRIORITY: - g_value_set_uint (value, layer->priority); + g_value_set_uint (value, layer->priv->priority); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -92,13 +96,13 @@ static void ges_timeline_layer_dispose (GObject * object) { GESTimelineLayer *layer = GES_TIMELINE_LAYER (object); + GESTimelineLayerPrivate *priv = layer->priv; GST_DEBUG ("Disposing layer"); - while (layer->objects_start) { - GESTimelineObject *obj = (GESTimelineObject *) layer->objects_start->data; - ges_timeline_layer_remove_object (layer, obj); - } + while (priv->objects_start) + ges_timeline_layer_remove_object (layer, + (GESTimelineObject *) priv->objects_start->data); G_OBJECT_CLASS (ges_timeline_layer_parent_class)->dispose (object); } @@ -161,7 +165,7 @@ ges_timeline_layer_init (GESTimelineLayer * self) GES_TYPE_TIMELINE_LAYER, GESTimelineLayerPrivate); /* TODO : Keep those 3 values in sync */ - self->priority = 0; + self->priv->priority = 0; self->min_gnl_priority = 0; self->max_gnl_priority = 9; } @@ -233,8 +237,8 @@ ges_timeline_layer_add_object (GESTimelineLayer * layer, } /* Take a reference to the object and store it stored by start/priority */ - layer->objects_start = - g_slist_insert_sorted (layer->objects_start, object, + layer->priv->objects_start = + g_slist_insert_sorted (layer->priv->objects_start, object, (GCompareFunc) objects_start_compare); /* Inform the object it's now in this layer */ @@ -294,7 +298,8 @@ ges_timeline_layer_remove_object (GESTimelineLayer * layer, ges_timeline_object_set_layer (object, NULL); /* Remove it from our list of controlled objects */ - layer->objects_start = g_slist_remove (layer->objects_start, object); + layer->priv->objects_start = + g_slist_remove (layer->priv->objects_start, object); /* Remove our reference to the object */ g_object_unref (object); @@ -307,7 +312,8 @@ ges_timeline_layer_remove_object (GESTimelineLayer * layer, * @layer: a #GESTimelineLayer * * Resyncs the priorities of the objects controlled by @layer. - * This method */ + * This method + */ gboolean ges_timeline_layer_resync_priorities (GESTimelineLayer * layer) { @@ -320,7 +326,7 @@ ges_timeline_layer_resync_priorities (GESTimelineLayer * layer) /* TODO : This is the dumb version where we put everything linearly, * will need to be adjusted for more complex usages (like with * transitions). */ - for (tmp = layer->objects_start; tmp; tmp = tmp->next) { + for (tmp = layer->priv->objects_start; tmp; tmp = tmp->next) { ges_timeline_object_set_priority ((GESTimelineObject *) tmp->data, layer->min_gnl_priority); } @@ -333,16 +339,18 @@ ges_timeline_layer_resync_priorities (GESTimelineLayer * layer) * @layer: a #GESTimelineLayer * @priority: the priority to set * - * Sets the layer to the given @priority. See the documentation of - * the "priority" property for more information. + * Sets the layer to the given @priority. See the documentation of the + * priority property for more information. */ void ges_timeline_layer_set_priority (GESTimelineLayer * layer, guint priority) { + g_return_if_fail (GES_IS_TIMELINE_LAYER (layer)); + GST_DEBUG ("layer:%p, priority:%d", layer, priority); - if (priority != layer->priority) { - layer->priority = priority; + if (priority != layer->priv->priority) { + layer->priv->priority = priority; layer->min_gnl_priority = (priority * 10); layer->max_gnl_priority = ((priority + 1) * 10) - 1; @@ -351,6 +359,20 @@ ges_timeline_layer_set_priority (GESTimelineLayer * layer, guint priority) } } +/** + * ges_timeline_layer_get_priority: + * @layer: a #GESTimelineLayer + * + * Returns: the priority of the @layer within the timeline. + */ +guint +ges_timeline_layer_get_priority (GESTimelineLayer * layer) +{ + g_return_val_if_fail (GES_IS_TIMELINE_LAYER (layer), 0); + + return layer->priv->priority; +} + /** * ges_timeline_layer_get_objects: * @layer: a #GESTimelineLayer @@ -369,13 +391,15 @@ ges_timeline_layer_get_objects (GESTimelineLayer * layer) GSList *tmp; GESTimelineLayerClass *klass; + g_return_val_if_fail (GES_IS_TIMELINE_LAYER (layer), NULL); + klass = GES_TIMELINE_LAYER_GET_CLASS (layer); if (klass->get_objects) { return klass->get_objects (layer); } - for (tmp = layer->objects_start; tmp; tmp = tmp->next) { + for (tmp = layer->priv->objects_start; tmp; tmp = tmp->next) { ret = g_list_prepend (ret, tmp->data); g_object_ref (tmp->data); } diff --git a/ges/ges-timeline-layer.h b/ges/ges-timeline-layer.h index a9bbbc1b95..4f827af9bc 100644 --- a/ges/ges-timeline-layer.h +++ b/ges/ges-timeline-layer.h @@ -56,13 +56,7 @@ struct _GESTimelineLayer { GESTimeline *timeline; - /*< private >*/ - GSList * objects_start; /* The TimelineObjects sorted by start and - * priority */ - - guint32 priority; /* The priority of the layer within the - * containing timeline */ - + /*< protected >*/ guint32 min_gnl_priority, max_gnl_priority; GESTimelineLayerPrivate *priv; @@ -99,12 +93,17 @@ GType ges_timeline_layer_get_type (void); GESTimelineLayer* ges_timeline_layer_new (void); -void ges_timeline_layer_set_timeline (GESTimelineLayer * layer, GESTimeline * timeline); -gboolean ges_timeline_layer_add_object (GESTimelineLayer * layer, GESTimelineObject * object); -gboolean ges_timeline_layer_remove_object (GESTimelineLayer * layer, GESTimelineObject * object); +void ges_timeline_layer_set_timeline (GESTimelineLayer * layer, + GESTimeline * timeline); +gboolean ges_timeline_layer_add_object (GESTimelineLayer * layer, + GESTimelineObject * object); +gboolean ges_timeline_layer_remove_object (GESTimelineLayer * layer, + GESTimelineObject * object); -void ges_timeline_layer_set_priority (GESTimelineLayer * layer, guint priority); -GList * ges_timeline_layer_get_objects (GESTimelineLayer * layer); +void ges_timeline_layer_set_priority (GESTimelineLayer * layer, + guint priority); +guint ges_timeline_layer_get_priority (GESTimelineLayer * layer); +GList* ges_timeline_layer_get_objects (GESTimelineLayer * layer); G_END_DECLS diff --git a/ges/ges-timeline-pipeline.c b/ges/ges-timeline-pipeline.c index 6835216148..690d22c906 100644 --- a/ges/ges-timeline-pipeline.c +++ b/ges/ges-timeline-pipeline.c @@ -253,8 +253,8 @@ ges_timeline_pipeline_change_state (GstElement * element, ret = GST_STATE_CHANGE_FAILURE; goto done; } - if (self-> - priv->mode & (TIMELINE_MODE_RENDER | TIMELINE_MODE_SMART_RENDER)) + if (self->priv-> + mode & (TIMELINE_MODE_RENDER | TIMELINE_MODE_SMART_RENDER)) GST_DEBUG ("rendering => Updating pipeline caps"); if (!ges_timeline_pipeline_update_caps (self)) { GST_ERROR_OBJECT (element, "Error setting the caps for rendering"); diff --git a/tests/check/ges/layer.c b/tests/check/ges/layer.c index afe6b31b03..d025f963ab 100644 --- a/tests/check/ges/layer.c +++ b/tests/check/ges/layer.c @@ -71,7 +71,7 @@ GST_START_TEST (test_layer_properties) layer = (GESTimelineLayer *) ges_timeline_layer_new (); /* The default priority is 0 */ - fail_unless_equals_int (layer->priority, 0); + fail_unless_equals_int (ges_timeline_layer_get_priority (layer), 0); fail_unless (ges_timeline_add_layer (timeline, layer)); @@ -108,19 +108,19 @@ GST_START_TEST (test_layer_properties) /* Change the priority of the layer */ g_object_set (layer, "priority", 1, NULL); - assert_equals_int (layer->priority, 1); + assert_equals_int (ges_timeline_layer_get_priority (layer), 1); assert_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (object), 10); gnl_object_check (trackobject->gnlobject, 42, 51, 12, 51, 10, TRUE); /* Change it to an insanely high value */ g_object_set (layer, "priority", 1000000, NULL); - assert_equals_int (layer->priority, 1000000); + assert_equals_int (ges_timeline_layer_get_priority (layer), 1000000); assert_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (object), 10000000); gnl_object_check (trackobject->gnlobject, 42, 51, 12, 51, 10000000, TRUE); /* and back to 0 */ g_object_set (layer, "priority", 0, NULL); - assert_equals_int (layer->priority, 0); + assert_equals_int (ges_timeline_layer_get_priority (layer), 0); assert_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (object), 0); gnl_object_check (trackobject->gnlobject, 42, 51, 12, 51, 0, TRUE);