GESTimelineStandardTransition: keep track of TrackVideoTransition

Use the new track_object_added/release vfunc to get cleaner code
This commit is contained in:
Thibault Saunier 2011-04-27 10:11:44 -03:00 committed by Edward Hervey
parent a00f2f82df
commit deb88a1551

View file

@ -42,8 +42,7 @@
struct _GESTimelineStandardTransitionPrivate
{
/* Dummy variable */
void *nothing;
GSList *track_video_transitions;
};
enum
@ -56,32 +55,28 @@ G_DEFINE_TYPE (GESTimelineStandardTransition, ges_timeline_standard_transition,
static GESTrackObject *ges_tl_transition_create_track_object (GESTimelineObject
* self, GESTrack * track);
static void
ges_timeline_standard_transition_track_object_added (GESTimelineObject * obj,
GESTrackObject * tckobj);
static void
ges_timeline_standard_transition_track_object_released (GESTimelineObject * obj,
GESTrackObject * tckobj);
static void
ges_timeline_standard_transition_update_vtype_internal (GESTimelineObject *
self, GESVideoStandardTransitionType value)
{
GList *tmp, *trackobjects;
GSList *tmp;
GESTimelineStandardTransition *trself =
(GESTimelineStandardTransition *) self;
GES_TIMELINE_STANDARD_TRANSITION (self);
/* FIXME : We need a much less crack way to find the trackobject to change */
trackobjects = ges_timeline_object_get_track_objects (self);
for (tmp = trackobjects; tmp; tmp = tmp->next) {
GESTrackVideoTransition *obj;
if (GES_IS_TRACK_VIDEO_TRANSITION (tmp->data)) {
obj = (GESTrackVideoTransition *) tmp->data;
if (!ges_track_video_transition_set_transition_type (obj, value))
goto beach;
}
for (tmp = trself->priv->track_video_transitions; tmp; tmp = tmp->next) {
if (!ges_track_video_transition_set_transition_type
(GES_TRACK_VIDEO_TRANSITION (tmp->data), value))
return;
}
trself->vtype = value;
beach:
g_list_foreach (trackobjects, (GFunc) g_object_unref, NULL);
g_list_free (trackobjects);
return;
}
static void
@ -143,6 +138,10 @@ ges_timeline_standard_transition_class_init (GESTimelineStandardTransitionClass
timobj_class->create_track_object = ges_tl_transition_create_track_object;
timobj_class->need_fill_track = FALSE;
timobj_class->track_object_added =
ges_timeline_standard_transition_track_object_added;
timobj_class->track_object_released =
ges_timeline_standard_transition_track_object_released;
}
static void
@ -156,6 +155,36 @@ ges_timeline_standard_transition_init (GESTimelineStandardTransition * self)
self->vtype = GES_VIDEO_STANDARD_TRANSITION_TYPE_NONE;
}
static void
ges_timeline_standard_transition_track_object_released (GESTimelineObject * obj,
GESTrackObject * tckobj)
{
GESTimelineStandardTransitionPrivate *priv =
GES_TIMELINE_STANDARD_TRANSITION (obj)->priv;
/* If this is called, we should be sure the tckobj exists */
if (GES_IS_TRACK_VIDEO_TRANSITION (tckobj)) {
GST_DEBUG ("GESTrackVideoTransition %p released from %p", tckobj, obj);
priv->track_video_transitions =
g_slist_remove (priv->track_video_transitions, tckobj);
g_object_unref (tckobj);
}
}
static void
ges_timeline_standard_transition_track_object_added (GESTimelineObject * obj,
GESTrackObject * tckobj)
{
GESTimelineStandardTransitionPrivate *priv =
GES_TIMELINE_STANDARD_TRANSITION (obj)->priv;
if (GES_IS_TRACK_VIDEO_TRANSITION (tckobj)) {
GST_DEBUG ("GESTrackVideoTransition %p added to %p", tckobj, obj);
priv->track_video_transitions =
g_slist_prepend (priv->track_video_transitions, g_object_ref (tckobj));
}
}
static GESTrackObject *
ges_tl_transition_create_track_object (GESTimelineObject * obj,
GESTrack * track)