GESTimelineObject: Emit signal when adding and removing effects

tests: test that those signals are actually well sent
This commit is contained in:
Thibault Saunier 2011-02-08 14:04:39 +01:00 committed by Edward Hervey
parent 34c55abd5d
commit 68c1ade22d
2 changed files with 107 additions and 0 deletions

View file

@ -31,6 +31,7 @@
#include "ges-timeline-object.h"
#include "ges.h"
#include "gesmarshal.h"
#include "ges-internal.h"
gboolean
@ -81,6 +82,15 @@ typedef struct
/* track mapping ?? */
} ObjectMapping;
enum
{
EFFECT_ADDED,
EFFECT_REMOVED,
LAST_SIGNAL
};
static guint ges_timeline_object_signals[LAST_SIGNAL] = { 0 };
struct _GESTimelineObjectPrivate
{
/*< public > */
@ -248,6 +258,30 @@ ges_timeline_object_class_init (GESTimelineObjectClass * klass)
g_object_class_install_property (object_class, PROP_LAYER,
properties[PROP_LAYER]);
/**
* GESTimelineObject::effect-added
* @object: the #GESTimelineObject
* @efect: the #GESTrackOperation that was added.
*
* Will be emitted after an effect was added to the object.
*/
ges_timeline_object_signals[EFFECT_ADDED] =
g_signal_new ("effect-added", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, 0, NULL, NULL, ges_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, GES_TYPE_TRACK_OPERATION);
/**
* GESTimelineObject::effect-removed
* @object: the #GESTimelineObject
* @efect: the #GESTrackOperation that was added.
*
* Will be emitted after an effect was remove from the object.
*/
ges_timeline_object_signals[EFFECT_REMOVED] =
g_signal_new ("effect-removed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, 0, NULL, NULL, ges_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, GES_TYPE_TRACK_OPERATION);
klass->need_fill_track = TRUE;
}
@ -407,6 +441,10 @@ ges_timeline_object_add_track_object (GESTimelineObject * object, GESTrackObject
}
priv->nb_effects++;
/* emit 'effect-added' */
g_signal_emit (object, ges_timeline_object_signals[EFFECT_ADDED], 0,
GES_TRACK_OPERATION (trobj));
}
object->priv->trackobjects =
@ -487,6 +525,12 @@ ges_timeline_object_release_track_object (GESTimelineObject * object,
object->priv->trackobjects =
g_list_remove (object->priv->trackobjects, trackobject);
if (GES_IS_TRACK_OPERATION (trackobject)) {
/* emit 'object-removed' */
g_signal_emit (object, ges_timeline_object_signals[EFFECT_REMOVED], 0,
GES_TRACK_OPERATION (trackobject));
}
ges_track_object_set_timeline_object (trackobject, NULL);
GST_DEBUG ("Removing reference to track object %p", trackobject);

View file

@ -21,6 +21,10 @@
#include <ges/ges-track-operation.h>
#include <gst/check/gstcheck.h>
void
effect_added_cb (GESTimelineObject * obj, GESTrackOperation * trop,
gpointer data);
GST_START_TEST (test_effect_basic)
{
GESTrackEffect *effect;
@ -361,6 +365,64 @@ GST_START_TEST (test_track_effect_set_properties)
GST_END_TEST;
void
effect_added_cb (GESTimelineObject * obj, GESTrackOperation * trop,
gpointer data)
{
GST_DEBUG ("Effect added");
fail_unless (GES_IS_TIMELINE_OBJECT (obj));
fail_unless (GES_IS_TRACK_OPERATION (trop));
}
GST_START_TEST (test_tl_obj_signals)
{
GESTimeline *timeline;
GESTimelineLayer *layer;
GESTrack *track_video;
GESTimelineEffect *tl_effect;
GESTrackEffect *tck_effect;
GValue value = { 0 };
guint val;
ges_init ();
timeline = ges_timeline_new ();
layer = (GESTimelineLayer *) ges_simple_timeline_layer_new ();
track_video = ges_track_video_raw_new ();
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 ("agingtv", NULL);
g_signal_connect (tl_effect, "effect-added", (GCallback) effect_added_cb,
tl_effect);
g_object_set (tl_effect, "duration", 25 * GST_SECOND, NULL);
ges_simple_timeline_layer_add_object ((GESSimpleTimelineLayer *) (layer),
(GESTimelineObject *) tl_effect, 0);
tck_effect = ges_track_effect_new_from_bin_desc ("agingtv");
fail_unless (ges_timeline_object_add_track_object (GES_TIMELINE_OBJECT
(tl_effect), GES_TRACK_OBJECT (tck_effect)));
fail_unless (ges_track_add_object (track_video,
GES_TRACK_OBJECT (tck_effect)));
g_value_init (&value, G_TYPE_UINT);
g_value_set_uint (&value, 17);
ges_track_object_set_child_property (GES_TRACK_OBJECT (tck_effect),
"GstAgingTV-scratch-lines", &value);
ges_track_object_get_child_property (GES_TRACK_OBJECT (tck_effect),
"GstAgingTV-scratch-lines", &val);
fail_unless (val == 17);
ges_timeline_layer_remove_object (layer, (GESTimelineObject *) tl_effect);
g_object_unref (timeline);
}
GST_END_TEST;
static Suite *
ges_suite (void)
{
@ -375,6 +437,7 @@ ges_suite (void)
tcase_add_test (tc_chain, test_tl_effect);
tcase_add_test (tc_chain, test_priorities_tl_object);
tcase_add_test (tc_chain, test_track_effect_set_properties);
tcase_add_test (tc_chain, test_tl_obj_signals);
return s;
}