mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-30 04:00:37 +00:00
clip: Make it mandatory that a clip is in a layer to be splittable
Otherwize we will not be able to describe if the returned object has a floating reference or not, and this would screw the introspection.
This commit is contained in:
parent
5a5b07297c
commit
f8334dba24
2 changed files with 53 additions and 24 deletions
|
@ -990,8 +990,12 @@ ges_clip_edit (GESClip * clip, GList * layers,
|
||||||
*
|
*
|
||||||
* The function modifies @clip, and creates another #GESClip so
|
* The function modifies @clip, and creates another #GESClip so
|
||||||
* we have two clips at the end, splitted at the time specified by @position.
|
* we have two clips at the end, splitted at the time specified by @position.
|
||||||
|
* The newly created clip will be added to the same layer as @clip is in.
|
||||||
|
* This implies that @clip must be in a #GESTimelineLayer for the operation to
|
||||||
|
* be possible.
|
||||||
*
|
*
|
||||||
* Returns: (transfer floating): The newly created #GESClip resulting from the splitting
|
* Returns: (transfer none): The newly created #GESClip resulting from the
|
||||||
|
* splitting
|
||||||
*/
|
*/
|
||||||
GESClip *
|
GESClip *
|
||||||
ges_clip_split (GESClip * clip, guint64 position)
|
ges_clip_split (GESClip * clip, guint64 position)
|
||||||
|
@ -1002,6 +1006,7 @@ ges_clip_split (GESClip * clip, guint64 position)
|
||||||
GstClockTime start, inpoint, duration;
|
GstClockTime start, inpoint, duration;
|
||||||
|
|
||||||
g_return_val_if_fail (GES_IS_CLIP (clip), NULL);
|
g_return_val_if_fail (GES_IS_CLIP (clip), NULL);
|
||||||
|
g_return_val_if_fail (clip->priv->layer, NULL);
|
||||||
g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (position), NULL);
|
g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (position), NULL);
|
||||||
|
|
||||||
duration = _DURATION (clip);
|
duration = _DURATION (clip);
|
||||||
|
@ -1029,12 +1034,10 @@ ges_clip_split (GESClip * clip, guint64 position)
|
||||||
_set_duration0 (GES_TIMELINE_ELEMENT (new_object),
|
_set_duration0 (GES_TIMELINE_ELEMENT (new_object),
|
||||||
duration + start - position);
|
duration + start - position);
|
||||||
|
|
||||||
if (clip->priv->layer) {
|
/* We do not want the timeline to create again TrackElement-s */
|
||||||
/* We do not want the timeline to create again TrackElement-s */
|
ges_clip_set_moving_from_layer (new_object, TRUE);
|
||||||
ges_clip_set_moving_from_layer (new_object, TRUE);
|
ges_timeline_layer_add_clip (clip->priv->layer, new_object);
|
||||||
ges_timeline_layer_add_clip (clip->priv->layer, new_object);
|
ges_clip_set_moving_from_layer (new_object, FALSE);
|
||||||
ges_clip_set_moving_from_layer (new_object, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We first set the new duration and the child mapping will be updated
|
/* We first set the new duration and the child mapping will be updated
|
||||||
* properly in the following loop
|
* properly in the following loop
|
||||||
|
@ -1272,7 +1275,6 @@ _trim (GESTimelineElement * element, GstClockTime start)
|
||||||
*
|
*
|
||||||
* Returns: %TRUE on success, %FALSE on failure.
|
* Returns: %TRUE on success, %FALSE on failure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ges_clip_add_asset (GESClip * clip, GESAsset * asset)
|
ges_clip_add_asset (GESClip * clip, GESAsset * asset)
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,15 +41,24 @@ my_fill_track_func (GESClip * clip,
|
||||||
|
|
||||||
GST_START_TEST (test_object_properties)
|
GST_START_TEST (test_object_properties)
|
||||||
{
|
{
|
||||||
GESTrack *track;
|
|
||||||
GESTrackElement *trackelement;
|
|
||||||
GESClip *clip;
|
GESClip *clip;
|
||||||
|
GESTrack *track;
|
||||||
|
GESTimeline *timeline;
|
||||||
|
GESTimelineLayer *layer;
|
||||||
|
GESTrackElement *trackelement;
|
||||||
|
|
||||||
ges_init ();
|
ges_init ();
|
||||||
|
|
||||||
track = ges_track_new (GES_TRACK_TYPE_CUSTOM, gst_caps_ref (GST_CAPS_ANY));
|
track = ges_track_new (GES_TRACK_TYPE_CUSTOM, gst_caps_ref (GST_CAPS_ANY));
|
||||||
fail_unless (track != NULL);
|
fail_unless (track != NULL);
|
||||||
|
|
||||||
|
layer = ges_timeline_layer_new ();
|
||||||
|
fail_unless (layer != NULL);
|
||||||
|
timeline = ges_timeline_new ();
|
||||||
|
fail_unless (timeline != NULL);
|
||||||
|
fail_unless (ges_timeline_add_layer (timeline, layer));
|
||||||
|
fail_unless (ges_timeline_add_track (timeline, track));
|
||||||
|
|
||||||
clip = (GESClip *) ges_custom_source_clip_new (my_fill_track_func, NULL);
|
clip = (GESClip *) ges_custom_source_clip_new (my_fill_track_func, NULL);
|
||||||
fail_unless (clip != NULL);
|
fail_unless (clip != NULL);
|
||||||
|
|
||||||
|
@ -60,10 +69,13 @@ GST_START_TEST (test_object_properties)
|
||||||
assert_equals_uint64 (_DURATION (clip), 51);
|
assert_equals_uint64 (_DURATION (clip), 51);
|
||||||
assert_equals_uint64 (_INPOINT (clip), 12);
|
assert_equals_uint64 (_INPOINT (clip), 12);
|
||||||
|
|
||||||
trackelement = ges_clip_create_track_element (clip, track->type);
|
ges_timeline_layer_add_clip (layer, GES_CLIP (clip));
|
||||||
ges_container_add (GES_CONTAINER (clip), GES_TIMELINE_ELEMENT (trackelement));
|
assert_equals_int (g_list_length (GES_CONTAINER_CHILDREN (clip)), 1);
|
||||||
|
trackelement = GES_CONTAINER_CHILDREN (clip)->data;
|
||||||
fail_unless (trackelement != NULL);
|
fail_unless (trackelement != NULL);
|
||||||
fail_unless (ges_track_element_set_track (trackelement, track));
|
fail_unless (GES_TIMELINE_ELEMENT_PARENT (trackelement) ==
|
||||||
|
GES_TIMELINE_ELEMENT (clip));
|
||||||
|
fail_unless (ges_track_element_get_track (trackelement) == track);
|
||||||
|
|
||||||
/* Check that trackelement has the same properties */
|
/* Check that trackelement has the same properties */
|
||||||
assert_equals_uint64 (_START (trackelement), 42);
|
assert_equals_uint64 (_START (trackelement), 42);
|
||||||
|
@ -100,8 +112,7 @@ GST_START_TEST (test_object_properties)
|
||||||
ges_container_remove (GES_CONTAINER (clip),
|
ges_container_remove (GES_CONTAINER (clip),
|
||||||
GES_TIMELINE_ELEMENT (trackelement));
|
GES_TIMELINE_ELEMENT (trackelement));
|
||||||
|
|
||||||
g_object_unref (clip);
|
gst_object_unref (timeline);
|
||||||
g_object_unref (track);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
@ -109,29 +120,44 @@ GST_END_TEST;
|
||||||
GST_START_TEST (test_split_object)
|
GST_START_TEST (test_split_object)
|
||||||
{
|
{
|
||||||
GESTrack *track;
|
GESTrack *track;
|
||||||
GESTrackElement *trackelement, *splittrackelement;
|
GESTimeline *timeline;
|
||||||
|
GESTimelineLayer *layer;
|
||||||
GESClip *clip, *splitclip;
|
GESClip *clip, *splitclip;
|
||||||
GList *splittrackelements;
|
GList *splittrackelements;
|
||||||
|
GESTrackElement *trackelement, *splittrackelement;
|
||||||
|
|
||||||
ges_init ();
|
ges_init ();
|
||||||
|
|
||||||
track = ges_track_new (GES_TRACK_TYPE_CUSTOM, gst_caps_ref (GST_CAPS_ANY));
|
track = ges_track_new (GES_TRACK_TYPE_CUSTOM, gst_caps_ref (GST_CAPS_ANY));
|
||||||
fail_unless (track != NULL);
|
fail_unless (track != NULL);
|
||||||
|
|
||||||
|
layer = ges_timeline_layer_new ();
|
||||||
|
fail_unless (layer != NULL);
|
||||||
|
timeline = ges_timeline_new ();
|
||||||
|
fail_unless (timeline != NULL);
|
||||||
|
fail_unless (ges_timeline_add_layer (timeline, layer));
|
||||||
|
fail_unless (ges_timeline_add_track (timeline, track));
|
||||||
|
ASSERT_OBJECT_REFCOUNT (timeline, "timeline", 1);
|
||||||
|
|
||||||
clip = (GESClip *) ges_custom_source_clip_new (my_fill_track_func, NULL);
|
clip = (GESClip *) ges_custom_source_clip_new (my_fill_track_func, NULL);
|
||||||
fail_unless (clip != NULL);
|
fail_unless (clip != NULL);
|
||||||
|
ASSERT_OBJECT_REFCOUNT (timeline, "timeline", 1);
|
||||||
|
|
||||||
/* Set some properties */
|
/* Set some properties */
|
||||||
g_object_set (clip, "start", (guint64) 42, "duration", (guint64) 50,
|
g_object_set (clip, "start", (guint64) 42, "duration", (guint64) 50,
|
||||||
"in-point", (guint64) 12, NULL);
|
"in-point", (guint64) 12, NULL);
|
||||||
|
ASSERT_OBJECT_REFCOUNT (timeline, "timeline", 1);
|
||||||
assert_equals_uint64 (_START (clip), 42);
|
assert_equals_uint64 (_START (clip), 42);
|
||||||
assert_equals_uint64 (_DURATION (clip), 50);
|
assert_equals_uint64 (_DURATION (clip), 50);
|
||||||
assert_equals_uint64 (_INPOINT (clip), 12);
|
assert_equals_uint64 (_INPOINT (clip), 12);
|
||||||
|
|
||||||
trackelement = ges_clip_create_track_element (clip, track->type);
|
ges_timeline_layer_add_clip (layer, GES_CLIP (clip));
|
||||||
ges_container_add (GES_CONTAINER (clip), GES_TIMELINE_ELEMENT (trackelement));
|
assert_equals_int (g_list_length (GES_CONTAINER_CHILDREN (clip)), 1);
|
||||||
|
trackelement = GES_CONTAINER_CHILDREN (clip)->data;
|
||||||
fail_unless (trackelement != NULL);
|
fail_unless (trackelement != NULL);
|
||||||
fail_unless (ges_track_element_set_track (trackelement, track));
|
fail_unless (GES_TIMELINE_ELEMENT_PARENT (trackelement) ==
|
||||||
|
GES_TIMELINE_ELEMENT (clip));
|
||||||
|
fail_unless (ges_track_element_get_track (trackelement) == track);
|
||||||
|
|
||||||
/* Check that trackelement has the same properties */
|
/* Check that trackelement has the same properties */
|
||||||
assert_equals_uint64 (_START (trackelement), 42);
|
assert_equals_uint64 (_START (trackelement), 42);
|
||||||
|
@ -167,12 +193,13 @@ GST_START_TEST (test_split_object)
|
||||||
|
|
||||||
/* We own the only ref */
|
/* We own the only ref */
|
||||||
ASSERT_OBJECT_REFCOUNT (splitclip, "splitclip", 1);
|
ASSERT_OBJECT_REFCOUNT (splitclip, "splitclip", 1);
|
||||||
/* 1 ref for the Clip and 1 ref for the Track */
|
/* 1 ref for the Clip, 1 ref for the Track and 1 ref for the timeline */
|
||||||
ASSERT_OBJECT_REFCOUNT (splittrackelement, "splittrackelement", 2);
|
ASSERT_OBJECT_REFCOUNT (splittrackelement, "splittrackelement", 3);
|
||||||
|
|
||||||
g_object_unref (track);
|
g_object_unref (timeline);
|
||||||
g_object_unref (splitclip);
|
fail_if (G_IS_OBJECT (splitclip));
|
||||||
g_object_unref (clip);
|
fail_if (G_IS_OBJECT (clip));
|
||||||
|
fail_if (G_IS_OBJECT (splittrackelement));
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
Loading…
Reference in a new issue