GESTrackObject: add the deep-notify signal

tests: test the new signal
This commit is contained in:
Thibault Saunier 2011-02-08 15:29:21 +01:00 committed by Edward Hervey
parent 68c1ade22d
commit da717d6b25
2 changed files with 78 additions and 0 deletions

View file

@ -31,6 +31,7 @@
*/
#include "ges-internal.h"
#include "gesmarshal.h"
#include "ges-track-object.h"
#include "ges-timeline-object.h"
@ -76,6 +77,14 @@ enum
static GParamSpec *properties[PROP_LAST];
enum
{
DEEP_NOTIFY,
LAST_SIGNAL
};
static guint ges_track_object_signals[LAST_SIGNAL] = { 0 };
static GstElement *ges_track_object_create_gnl_object_func (GESTrackObject *
object);
@ -94,6 +103,11 @@ static void gnlobject_duration_cb (GstElement * gnlobject, GParamSpec * arg
static void gnlobject_active_cb (GstElement * gnlobject, GParamSpec * arg
G_GNUC_UNUSED, GESTrackObject * obj);
static void connect_properties_signals (GESTrackObject * object);
static void connect_signal (gpointer key, gpointer value, gpointer user_data);
static void gst_element_prop_changed_cb (GstElement * element, GParamSpec * arg
G_GNUC_UNUSED, GESTrackObject * obj);
static inline gboolean
ges_track_object_set_start_internal (GESTrackObject * object, guint64 start);
static inline gboolean
@ -252,6 +266,21 @@ ges_track_object_class_init (GESTrackObjectClass * klass)
g_object_class_install_property (object_class, PROP_ACTIVE,
properties[PROP_ACTIVE]);
/**
* GESTrackObject::deep-notify:
* @track_object: a #GESTrackObject
* @prop_object: the object that originated the signal
* @prop: the property that changed
*
* The deep notify signal is used to be notified of property changes of all
* the childs of @track_object
*/
ges_track_object_signals[DEEP_NOTIFY] =
g_signal_new ("deep-notify", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED |
G_SIGNAL_NO_HOOKS, 0, NULL, NULL, gst_marshal_VOID__OBJECT_PARAM,
G_TYPE_NONE, 2, GST_TYPE_ELEMENT, G_TYPE_PARAM);
klass->create_gnl_object = ges_track_object_create_gnl_object_func;
}
@ -466,6 +495,40 @@ gnlobject_start_cb (GstElement * gnlobject, GParamSpec * arg G_GNUC_UNUSED,
}
}
static void
gst_element_prop_changed_cb (GstElement * element, GParamSpec * arg
G_GNUC_UNUSED, GESTrackObject * obj)
{
g_signal_emit (obj, ges_track_object_signals[DEEP_NOTIFY], 0,
GST_ELEMENT (element), arg);
}
static void
connect_signal (gpointer key, gpointer value, gpointer user_data)
{
gchar **name = g_strsplit ((char *) key, "-", 2);
gchar *signame = g_strconcat ("notify::", (gchar *) name[1], NULL);
g_strfreev (name);
g_signal_connect (G_OBJECT (value),
signame, G_CALLBACK (gst_element_prop_changed_cb),
GES_TRACK_OBJECT (user_data));
g_free (signame);
}
static void
connect_properties_signals (GESTrackObject * object)
{
if (G_UNLIKELY (object->priv->properties_hashtable)) {
GST_WARNING ("The properties_hashtable hasn't been set");
}
g_hash_table_foreach (object->priv->properties_hashtable,
(GHFunc) connect_signal, object);
}
/* Callbacks from the GNonLin object */
static void
gnlobject_media_start_cb (GstElement * gnlobject,
@ -704,6 +767,7 @@ ensure_gnl_object (GESTrackObject * object)
properties_hashtable is available");
} else {
object->priv->properties_hashtable = props_hash;
connect_properties_signals (object);
}
}
}

View file

@ -24,6 +24,9 @@
void
effect_added_cb (GESTimelineObject * obj, GESTrackOperation * trop,
gpointer data);
void
deep_prop_changed_cb (GESTrackObject * obj, GstElement * element,
GParamSpec * spec);
GST_START_TEST (test_effect_basic)
{
@ -374,6 +377,15 @@ effect_added_cb (GESTimelineObject * obj, GESTrackOperation * trop,
fail_unless (GES_IS_TRACK_OPERATION (trop));
}
void
deep_prop_changed_cb (GESTrackObject * obj, GstElement * element,
GParamSpec * spec)
{
GST_DEBUG ("%s property changed", g_param_spec_get_name (spec));
fail_unless (GES_IS_TRACK_OBJECT (obj));
fail_unless (GST_IS_ELEMENT (element));
}
GST_START_TEST (test_tl_obj_signals)
{
GESTimeline *timeline;
@ -408,6 +420,8 @@ GST_START_TEST (test_tl_obj_signals)
(tl_effect), GES_TRACK_OBJECT (tck_effect)));
fail_unless (ges_track_add_object (track_video,
GES_TRACK_OBJECT (tck_effect)));
g_signal_connect (tck_effect, "deep-notify", (GCallback) deep_prop_changed_cb,
tck_effect);
g_value_init (&value, G_TYPE_UINT);
g_value_set_uint (&value, 17);