Track: Implement remove_object()

This commit is contained in:
Edward Hervey 2009-08-07 16:43:49 +02:00
parent dc16b626c8
commit b7b88e5826
2 changed files with 38 additions and 1 deletions

View file

@ -54,6 +54,15 @@ ges_track_set_property (GObject * object, guint property_id,
static void
ges_track_dispose (GObject * object)
{
GESTrack *track = (GESTrack *) object;
/* FIXME : Remove all TrackObjects ! */
if (track->composition) {
g_object_unref (track->composition);
track->composition = NULL;
}
G_OBJECT_CLASS (ges_track_parent_class)->dispose (object);
}
@ -77,6 +86,7 @@ ges_track_class_init (GESTrackClass * klass)
static void
ges_track_init (GESTrack * self)
{
self->composition = gst_element_factory_make ("gnlcomposition", NULL);
}
GESTrack *
@ -108,7 +118,10 @@ ges_track_add_object (GESTrack * track, GESTrackObject * object)
return FALSE;
}
ges_track_object_set_track (object, track);
if (G_UNLIKELY (!ges_track_object_set_track (object, track))) {
GST_ERROR ("Couldn't properly add the object to the Track");
return FALSE;
}
GST_DEBUG ("Adding object to ourself");
@ -121,3 +134,26 @@ ges_track_add_object (GESTrack * track, GESTrackObject * object)
return TRUE;
}
gboolean
ges_track_remove_object (GESTrack * track, GESTrackObject * object)
{
GST_DEBUG ("track:%p, object:%p", track, object);
if (G_UNLIKELY (object->track != track)) {
GST_WARNING ("Object belongs to another track");
return FALSE;
}
if (G_LIKELY (object->gnlobject != NULL)) {
GST_DEBUG ("Removing GnlObject from composition");
if (!gst_bin_remove (GST_BIN (track->composition), object->gnlobject)) {
GST_WARNING ("Failed to remove gnlobject from composition");
return FALSE;
}
}
ges_track_object_set_track (object, NULL);
return TRUE;
}

View file

@ -62,6 +62,7 @@ GESTrack* ges_track_new (void);
void ges_track_set_timeline (GESTrack * track, GESTimeline *timeline);
gboolean ges_track_add_object (GESTrack * track, GESTrackObject * object);
gboolean ges_track_remove_object (GESTrack * track, GESTrackObject * object);
G_END_DECLS