diff options
author | Mathieu Duponchelle <mathieu.duponchelle@opencreed.com> | 2015-02-23 00:53:14 +0100 |
---|---|---|
committer | Thibault Saunier <tsaunier@gnome.org> | 2015-03-20 13:53:41 +0100 |
commit | ed0839dd829861ba68dec8bb8c3b15f66911f597 (patch) | |
tree | 3f587a13f38c9c15e2f53c41aab9d801e7e5c54b /ges | |
parent | 7cfdc2265d965c1f8927441479ae0201bc0cb420 (diff) |
structured-interface: Be clever when no layer priority specified.
And add the new element to the same layer as the last clip that
was added, insted of adding to the last layer of the timeline
(and with the current code, actually adding a new layer each time)
Diffstat (limited to 'ges')
-rw-r--r-- | ges/ges-structured-interface.c | 19 | ||||
-rw-r--r-- | ges/ges-validate.c | 20 |
2 files changed, 20 insertions, 19 deletions
diff --git a/ges/ges-structured-interface.c b/ges/ges-structured-interface.c index b0b5408b..9b2264c9 100644 --- a/ges/ges-structured-interface.c +++ b/ges/ges-structured-interface.c @@ -138,6 +138,7 @@ _ges_get_layer_by_priority (GESTimeline * timeline, gint priority) gint nlayers; GESLayer *layer = NULL; + priority = MAX (priority, 0); layers = ges_timeline_get_layers (timeline); nlayers = (gint) g_list_length (layers); if (priority >= nlayers) { @@ -195,10 +196,8 @@ _ges_add_clip_from_struct (GESTimeline * timeline, GstStructure * structure, GET_AND_CHECK ("asset-id", G_TYPE_STRING, &asset_id); TRY_GET ("name", G_TYPE_STRING, &name, NULL); - TRY_GET ("layer-priority", G_TYPE_INT, &layer_priority, - g_list_length (timeline->layers)); - TRY_GET ("layer", G_TYPE_INT, &layer_priority, - g_list_length (timeline->layers)); + TRY_GET ("layer-priority", G_TYPE_INT, &layer_priority, -1); + TRY_GET ("layer", G_TYPE_INT, &layer_priority, -1); TRY_GET ("type", G_TYPE_STRING, &type_string, "GESUriClip"); TRY_GET ("start", GST_TYPE_CLOCK_TIME, &start, GST_CLOCK_TIME_NONE); TRY_GET ("inpoint", GST_TYPE_CLOCK_TIME, &inpoint, 0); @@ -218,7 +217,17 @@ _ges_add_clip_from_struct (GESTimeline * timeline, GstStructure * structure, goto beach; } - layer = _ges_get_layer_by_priority (timeline, layer_priority); + if (layer_priority == -1) { + GESContainer *container; + + container = g_object_get_qdata (G_OBJECT (timeline), LAST_CONTAINER_QDATA); + if (!container || !GES_IS_CLIP (container)) + layer = _ges_get_layer_by_priority (timeline, 0); + else + layer = ges_clip_get_layer (GES_CLIP (container)); + } else { + layer = _ges_get_layer_by_priority (timeline, layer_priority); + } if (!layer) { g_error_new (GES_ERROR, 0, "No layer with priority %d", layer_priority); diff --git a/ges/ges-validate.c b/ges/ges-validate.c index 37ab3a5b..f256fa0b 100644 --- a/ges/ges-validate.c +++ b/ges/ges-validate.c @@ -145,36 +145,28 @@ _add_layer (GstValidateScenario * scenario, GstValidateAction * action) GESTimeline *timeline = get_timeline (scenario); GESLayer *layer; gint priority; - gboolean res = FALSE, auto_transition = FALSE; + gboolean res = TRUE, auto_transition = FALSE; if (!gst_structure_get_int (action->structure, "priority", &priority)) { GST_ERROR ("priority is needed when adding a layer"); - goto beach; + goto failed; } + gst_validate_printf (action, "Adding layer with priority %d\n", priority); layer = _ges_get_layer_by_priority (timeline, priority); - if (layer != NULL) { - GST_ERROR - ("A layer with priority %d already exists, not creating a new one", - priority); - gst_object_unref (layer); - goto beach; - } - gst_structure_get_boolean (action->structure, "auto-transition", &auto_transition); - - layer = ges_layer_new (); g_object_set (layer, "priority", priority, "auto-transition", auto_transition, NULL); - gst_validate_printf (action, "Adding layer with priority %d\n", priority); - res = ges_timeline_add_layer (timeline, layer); beach: g_object_unref (timeline); return res; + +failed: + goto beach; } static gboolean |