TimelineEffect: implement the create_track_object vmethod
authorThibault Saunier <thibault.saunier@collabora.co.uk>
Tue, 1 Feb 2011 20:22:04 +0000 (21:22 +0100)
committerEdward Hervey <edward.hervey@collabora.co.uk>
Fri, 6 May 2011 08:39:01 +0000 (10:39 +0200)
tests: test the new vmethod

ges/ges-timeline-effect.c
tests/check/ges/effects.c

index d227487..47bdce2 100644 (file)
@@ -21,7 +21,7 @@
  * SECTION: ges-timeline-effect
  * @short_description: An effect in a #GESTimelineLayer
  *
- * The effect will be applied on the sources that have lower priorities 
+ * The effect will be applied on the sources that have lower priorities
  * (higher number) between the inpoint and the end of it.
  *
  * In a #GESSimpleTimelineLayer, the priorities will be set for you but if
@@ -132,6 +132,29 @@ ges_timeline_effect_init (GESTimelineEffect * self)
 static GESTrackObject *
 ges_tl_effect_create_track_object (GESTimelineObject * self, GESTrack * track)
 {
+  GESTimelineEffect *effect = GES_TIMELINE_EFFECT (self);
+
+
+  if (track->type == GES_TRACK_TYPE_VIDEO) {
+    if (effect->priv->video_bin_description != NULL) {
+      GST_DEBUG ("Creating a GESTrackEffect for the video track");
+      return GES_TRACK_OBJECT (ges_track_effect_new_from_bin_desc
+          (effect->priv->video_bin_description));
+    }
+    GST_DEBUG ("Can't create the track Object, the\
+                 video_bin_description is not set");
+  }
+  if (track->type == GES_TRACK_TYPE_AUDIO) {
+    if (effect->priv->audio_bin_description != NULL) {
+      GST_DEBUG ("Creating a GESTrackEffect for the audio track");
+      return GES_TRACK_OBJECT (ges_track_effect_new_from_bin_desc
+          (effect->priv->audio_bin_description));
+    }
+    GST_DEBUG ("Can't create the track Object, the\
+                 audio_bin_description is not set");
+  }
+
+  GST_WARNING ("Effect doesn't handle this track type");
   return NULL;
 }
 
index 1e58fba..6500adc 100644 (file)
@@ -11,7 +11,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
- * You should have received track_audio copy of the GNU Library General Public
+ * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
@@ -157,6 +157,63 @@ GST_START_TEST (test_get_effects_from_tl)
 
 GST_END_TEST;
 
+GST_START_TEST (test_tl_effect)
+{
+  GESTimeline *timeline;
+  GESTimelineLayer *layer;
+  GESTrack *track_audio, *track_video;
+  GESTimelineEffect *tl_effect;
+  GList *effects, *tmp;
+  gint i, tl_object_height;
+  gint effect_prio = -1;
+  /* FIXME the order of track type is not well defined */
+  guint track_type[2] = { GES_TRACK_TYPE_AUDIO, GES_TRACK_TYPE_VIDEO };
+
+  ges_init ();
+
+  timeline = ges_timeline_new ();
+  layer = (GESTimelineLayer *) ges_simple_timeline_layer_new ();
+  track_audio = ges_track_audio_raw_new ();
+  track_video = ges_track_video_raw_new ();
+
+  ges_timeline_add_track (timeline, track_audio);
+  ges_timeline_add_track (timeline, track_video);
+  ges_timeline_add_layer (timeline, layer);
+
+  GST_DEBUG ("Create effect");
+  tl_effect = ges_timeline_effect_new_from_bin_desc ("identity", "identity");
+
+  g_object_set (tl_effect, "duration", 25 * GST_SECOND, NULL);
+
+  ges_simple_timeline_layer_add_object ((GESSimpleTimelineLayer *) (layer),
+      (GESTimelineObject *) tl_effect, 0);
+
+  g_object_get (tl_effect, "height", &tl_object_height, NULL);
+  fail_unless (tl_object_height == 2);
+
+  effects = ges_timeline_object_get_effects (GES_TIMELINE_OBJECT (tl_effect));
+  for (tmp = effects, i = 0; tmp; tmp = tmp->next, i++) {
+    gint priority =
+        ges_timeline_object_get_top_effect_position (GES_TIMELINE_OBJECT
+        (tl_effect),
+        GES_TRACK_OPERATION (tmp->data));
+    fail_unless (priority > effect_prio);
+    fail_unless (GES_IS_TRACK_EFFECT (tmp->data));
+    fail_unless (ges_track_object_get_track (GES_TRACK_OBJECT (tmp->data))->
+        type == track_type[i]);
+    effect_prio = priority;
+
+    g_object_unref (tmp->data);
+  }
+  g_list_free (effects);
+
+  ges_timeline_layer_remove_object (layer, (GESTimelineObject *) tl_effect);
+
+  g_object_unref (timeline);
+}
+
+GST_END_TEST;
+
 static Suite *
 ges_suite (void)
 {
@@ -168,6 +225,7 @@ ges_suite (void)
   tcase_add_test (tc_chain, test_effect_basic);
   tcase_add_test (tc_chain, test_add_effect_to_tl_object);
   tcase_add_test (tc_chain, test_get_effects_from_tl);
+  tcase_add_test (tc_chain, test_tl_effect);
 
   return s;
 }