mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
ges: Handle trimming auto transitions
Meaning trimming neighbors. + And add a test
This commit is contained in:
parent
d7dfcff745
commit
c70a654dd6
5 changed files with 90 additions and 3 deletions
|
@ -61,9 +61,11 @@ neighbour_changed_cb (GESClip * clip, GParamSpec * arg G_GNUC_UNUSED,
|
|||
return;
|
||||
}
|
||||
|
||||
self->positioning = TRUE;
|
||||
_set_start0 (GES_TIMELINE_ELEMENT (self->transition_clip),
|
||||
_START (self->next_source));
|
||||
_set_duration0 (GES_TIMELINE_ELEMENT (self->transition_clip), new_duration);
|
||||
self->positioning = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -72,9 +74,11 @@ _height_changed_cb (GESClip * clip, GParamSpec * arg G_GNUC_UNUSED,
|
|||
{
|
||||
/* FIXME This is really not smart and we should properly implement clip
|
||||
* priority management at the Layer level */
|
||||
self->positioning = TRUE;
|
||||
_set_priority0 (GES_TIMELINE_ELEMENT (self->next_clip),
|
||||
_PRIORITY (self->previous_clip) +
|
||||
GES_CONTAINER_HEIGHT (self->previous_clip));
|
||||
self->positioning = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -61,6 +61,7 @@ struct _GESAutoTransition
|
|||
GESClip *previous_clip;
|
||||
GESClip *next_clip;
|
||||
GESClip *transition_clip;
|
||||
gboolean positioning;
|
||||
|
||||
gchar *key;
|
||||
|
||||
|
|
|
@ -590,7 +590,7 @@ _edit (GESContainer * container, GList * layers,
|
|||
}
|
||||
|
||||
for (tmp = GES_CONTAINER_CHILDREN (container); tmp; tmp = g_list_next (tmp)) {
|
||||
if (GES_IS_SOURCE (tmp->data)) {
|
||||
if (GES_IS_SOURCE (tmp->data) || GES_IS_TRANSITION (tmp->data)) {
|
||||
ret &= ges_track_element_edit (tmp->data, layers, mode, edge, position);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1435,6 +1435,45 @@ ges_timeline_set_moving_context (GESTimeline * timeline, GESTrackElement * obj,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_trim_transition (GESTimeline * timeline, GESLayer * layer,
|
||||
GESTrackElement * element, GESEdge edge, GstClockTime position)
|
||||
{
|
||||
|
||||
GList *tmp;
|
||||
|
||||
if (!ges_layer_get_auto_transition (layer))
|
||||
goto fail;
|
||||
|
||||
gst_object_unref (layer);
|
||||
for (tmp = timeline->priv->auto_transitions; tmp; tmp = tmp->next) {
|
||||
GESAutoTransition *auto_transition = tmp->data;
|
||||
|
||||
if (auto_transition->transition == GES_TRACK_ELEMENT (element)) {
|
||||
/* Trimming an auto transition mean trimming its neighboors */
|
||||
if (!auto_transition->positioning) {
|
||||
if (edge == GES_EDGE_END) {
|
||||
ges_container_edit (GES_CONTAINER (auto_transition->previous_clip),
|
||||
NULL, -1, GES_EDIT_MODE_TRIM, GES_EDGE_END, position);
|
||||
} else {
|
||||
ges_container_edit (GES_CONTAINER (auto_transition->next_clip),
|
||||
NULL, -1, GES_EDIT_MODE_TRIM, GES_EDGE_START, position);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
||||
fail:
|
||||
gst_object_unref (layer);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
ges_timeline_trim_object_simple (GESTimeline * timeline,
|
||||
GESTimelineElement * element, GList * layers, GESEdge edge,
|
||||
|
@ -1445,9 +1484,13 @@ ges_timeline_trim_object_simple (GESTimeline * timeline,
|
|||
gint64 real_dur;
|
||||
GESTrackElement *track_element;
|
||||
|
||||
/* We only work with GESSource-s */
|
||||
if (GES_IS_SOURCE (element) == FALSE)
|
||||
if (GES_IS_TRANSITION (element)) {
|
||||
return _trim_transition (timeline,
|
||||
ges_clip_get_layer (GES_CLIP (GES_TIMELINE_ELEMENT_PARENT (element))),
|
||||
GES_TRACK_ELEMENT (element), edge, position);
|
||||
} else if (GES_IS_SOURCE (element) == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
track_element = GES_TRACK_ELEMENT (element);
|
||||
GST_DEBUG_OBJECT (track_element, "Trimming to %" GST_TIME_FORMAT
|
||||
|
|
|
@ -725,6 +725,45 @@ GST_START_TEST (test_single_layer_automatic_transition)
|
|||
fail_unless (current->data == src2);
|
||||
g_list_free_full (objects, gst_object_unref);
|
||||
|
||||
/*
|
||||
* 500___________src1________1250
|
||||
* 1000___________src2________2000
|
||||
* ^____trans____^
|
||||
*/
|
||||
ges_layer_remove_clip (layer, GES_CLIP (src));
|
||||
assert_equals_uint64 (_START (src1), 500);
|
||||
assert_equals_uint64 (_DURATION (src1), 1250 - 500);
|
||||
assert_equals_uint64 (_START (src2), 1000);
|
||||
assert_equals_uint64 (_DURATION (src2), 1000);
|
||||
|
||||
current = objects = ges_layer_get_clips (layer);
|
||||
current = objects;
|
||||
assert_equals_int (g_list_length (objects), 4);
|
||||
assert_is_type (objects->data, GES_TYPE_TEST_CLIP);
|
||||
transition = objects->next->data;
|
||||
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
|
||||
fail_unless (current->data == src1);
|
||||
g_list_free_full (objects, gst_object_unref);
|
||||
|
||||
/*
|
||||
* 500___________src1________1250
|
||||
* ^____trans____^
|
||||
* 1100___________src2________2000
|
||||
*/
|
||||
ges_container_edit (GES_CONTAINER (transition),
|
||||
NULL, -1, GES_EDIT_MODE_TRIM, GES_EDGE_START, 1100);
|
||||
assert_equals_uint64 (_START (src1), 500);
|
||||
assert_equals_uint64 (_DURATION (src1), 1250 - 500);
|
||||
assert_equals_uint64 (_START (src2), 1100);
|
||||
assert_equals_uint64 (_DURATION (src2), 2000 - 1100);
|
||||
|
||||
current = objects = ges_layer_get_clips (layer);
|
||||
current = objects;
|
||||
assert_equals_int (g_list_length (objects), 4);
|
||||
assert_is_type (objects->data, GES_TYPE_TEST_CLIP);
|
||||
fail_unless (current->data == src1);
|
||||
g_list_free_full (objects, gst_object_unref);
|
||||
|
||||
gst_object_unref (timeline);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue