mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
clip: Make sure to remove and re add effects when adding clips to layer
And make re add them in the same order. And enhance tests to check that
This commit is contained in:
parent
23d3e69f2b
commit
430719d172
2 changed files with 22 additions and 7 deletions
|
@ -939,6 +939,7 @@ ges_clip_create_track_elements (GESClip * clip, GESTrackType type)
|
|||
GList *result = NULL, *tmp, *children;
|
||||
GESClipClass *klass;
|
||||
guint max_prio, min_prio;
|
||||
gboolean readding_effects_only = TRUE;
|
||||
|
||||
g_return_val_if_fail (GES_IS_CLIP (clip), NULL);
|
||||
|
||||
|
@ -955,18 +956,20 @@ ges_clip_create_track_elements (GESClip * clip, GESTrackType type)
|
|||
for (tmp = children; tmp; tmp = tmp->next) {
|
||||
GESTrackElement *child = GES_TRACK_ELEMENT (tmp->data);
|
||||
|
||||
if (!GES_IS_BASE_EFFECT (child) && !ges_track_element_get_track (child) &&
|
||||
ges_track_element_get_track_type (child) & type) {
|
||||
if (!ges_track_element_get_track (child)
|
||||
&& ges_track_element_get_track_type (child) & type) {
|
||||
|
||||
GST_DEBUG_OBJECT (clip, "Removing for reusage: %" GST_PTR_FORMAT, child);
|
||||
result = g_list_prepend (result, g_object_ref (child));
|
||||
result = g_list_append (result, g_object_ref (child));
|
||||
ges_container_remove (GES_CONTAINER (clip), tmp->data);
|
||||
if (!GES_IS_BASE_EFFECT (child))
|
||||
readding_effects_only = FALSE;
|
||||
}
|
||||
}
|
||||
g_list_free_full (children, gst_object_unref);
|
||||
|
||||
if (!result) {
|
||||
result = klass->create_track_elements (clip, type);
|
||||
if (readding_effects_only) {
|
||||
result = g_list_concat (result, klass->create_track_elements (clip, type));
|
||||
}
|
||||
|
||||
_get_priority_range (GES_CONTAINER (clip), &min_prio, &max_prio);
|
||||
|
|
|
@ -143,31 +143,43 @@ class TestTrackElements(common.GESTest):
|
|||
|
||||
def test_add_to_layer_with_effect_remove_add(self):
|
||||
timeline = GES.Timeline.new_audio_video()
|
||||
self.assertEqual(len(timeline.get_tracks()), 2)
|
||||
video_track, audio_track = timeline.get_tracks()
|
||||
layer = timeline.append_layer()
|
||||
|
||||
test_clip = GES.TestClip()
|
||||
self.assertEqual(test_clip.get_children(True), [])
|
||||
self.assertTrue(layer.add_clip(test_clip))
|
||||
audio_source = test_clip.find_track_element(None, GES.AudioSource)
|
||||
self.assertIsNotNone(audio_source)
|
||||
video_source = test_clip.find_track_element(None, GES.VideoSource)
|
||||
|
||||
self.assertTrue(test_clip.set_child_property("volume", 0.0))
|
||||
self.assertEqual(audio_source.get_child_property("volume")[1], 0.0)
|
||||
|
||||
effect = GES.Effect.new("agingtv")
|
||||
test_clip.add(effect)
|
||||
self.assertEqual(audio_source.props.track, audio_track)
|
||||
self.assertEqual(video_source.props.track, video_track)
|
||||
self.assertEqual(effect.props.track, video_track)
|
||||
|
||||
children = test_clip.get_children(True)
|
||||
layer.remove_clip(test_clip)
|
||||
self.assertEqual(test_clip.get_children(True), children)
|
||||
self.assertEqual(audio_source.props.track, None)
|
||||
self.assertEqual(video_source.props.track, None)
|
||||
self.assertEqual(effect.props.track, None)
|
||||
|
||||
self.assertTrue(layer.add_clip(test_clip))
|
||||
self.assertEqual(test_clip.get_children(True), children)
|
||||
self.assertEqual(audio_source.props.track, audio_track)
|
||||
self.assertEqual(video_source.props.track, video_track)
|
||||
self.assertEqual(effect.props.track, video_track)
|
||||
|
||||
audio_source = test_clip.find_track_element(None, GES.AudioSource)
|
||||
self.assertFalse(audio_source is None)
|
||||
self.assertEqual(audio_source.get_child_property("volume")[1], 0.0)
|
||||
self.assertEqual(audio_source.props.track, audio_track)
|
||||
self.assertEqual(video_source.props.track, video_track)
|
||||
self.assertEqual(effect.props.track, video_track)
|
||||
|
||||
def test_effects_priority(self):
|
||||
timeline = GES.Timeline.new_audio_video()
|
||||
|
|
Loading…
Reference in a new issue