From 2146e4a9afb833f14ebaae09736d20aa2af10cf6 Mon Sep 17 00:00:00 2001 From: Brandon Lewis Date: Fri, 18 Jun 2010 12:55:30 +0200 Subject: [PATCH] add create_element vmethod to GESTrackTransition --- ges/ges-track-transition.c | 40 +++++++++++++++++++++++++++----------- ges/ges-track-transition.h | 4 +++- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/ges/ges-track-transition.c b/ges/ges-track-transition.c index 0a11559e8e..436f3ee556 100644 --- a/ges/ges-track-transition.c +++ b/ges/ges-track-transition.c @@ -31,6 +31,9 @@ G_DEFINE_TYPE (GESTrackTransition, ges_track_transition, GES_TYPE_TRACK_OBJECT); +GstElement *ges_track_transition_create_element (GESTrackTransition * self, + GESTrack * track); + static void ges_track_transition_update_vcontroller (GESTrackTransition * self, GstElement * gnlobj) @@ -418,11 +421,16 @@ create_audio_bin (GESTrackTransition * self) static gboolean ges_track_transition_create_gnl_object (GESTrackObject * object) { - GESTrackTransition *self = GES_TRACK_TRANSITION (object); - + GESTrackTransition *self; + GESTrackTransitionClass *klass; + GstElement *element; + gchar *name; static gint tnum = 0; - gchar *name = g_strdup_printf ("transition-operation%d", tnum++); + self = GES_TRACK_TRANSITION (object); + klass = GES_TRACK_TRANSITION_GET_CLASS (object); + + name = g_strdup_printf ("transition-operation%d", tnum++); object->gnlobject = gst_element_factory_make ("gnloperation", name); g_free (name); @@ -430,18 +438,27 @@ ges_track_transition_create_gnl_object (GESTrackObject * object) g_signal_connect (G_OBJECT (object->gnlobject), "notify::duration", G_CALLBACK (gnlobject_duration_cb), object); - if ((object->track->type) == GES_TRACK_TYPE_VIDEO) { - gst_bin_add (GST_BIN (object->gnlobject), create_video_bin (self)); - return TRUE; + element = klass->create_element (self, object->track); + if (!GST_IS_ELEMENT (element)) + return FALSE; + + gst_bin_add (GST_BIN (object->gnlobject), element); + return TRUE; +} + +GstElement * +ges_track_transition_create_element (GESTrackTransition * self, + GESTrack * track) +{ + if ((track->type) == GES_TRACK_TYPE_VIDEO) { + return create_video_bin (self); } - else if ((object->track->type) == GES_TRACK_TYPE_AUDIO) { - gst_bin_add (GST_BIN (object->gnlobject), create_audio_bin (self)); - return TRUE; + else if ((track->type) == GES_TRACK_TYPE_AUDIO) { + return create_audio_bin (self); } - return FALSE; - + return gst_element_factory_make ("identity", "invalid-track-type"); } static void @@ -456,6 +473,7 @@ ges_track_transition_class_init (GESTrackTransitionClass * klass) object_class->finalize = ges_track_transition_finalize; track_class->create_gnl_object = ges_track_transition_create_gnl_object; + klass->create_element = ges_track_transition_create_element; } static void diff --git a/ges/ges-track-transition.h b/ges/ges-track-transition.h index b22c9fe460..0da0318402 100644 --- a/ges/ges-track-transition.h +++ b/ges/ges-track-transition.h @@ -22,6 +22,7 @@ #define _GES_TRACK_TRANSITION #include +#include #include #include #include @@ -47,7 +48,7 @@ G_BEGIN_DECLS #define GES_TRACK_TRANSITION_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS ((obj), GES_TYPE_TRACK_TRANSITION,\ - GESTrackTransitionClass) + GESTrackTransitionClass)) /** * GESTrackTransition: @@ -101,6 +102,7 @@ struct _GESTrackTransition struct _GESTrackTransitionClass { GESTrackObjectClass parent_class; /* */ + GstElement* (*create_element) (GESTrackTransition *self, GESTrack *track); }; GType ges_track_transition_get_type (void);