GESTrackObject: add a ges_track_object_list_children_properties method

test: Test the new method, and also set/get_child_property_by_spec
This commit is contained in:
Thibault Saunier 2011-02-25 17:10:00 +01:00 committed by Edward Hervey
parent 0e9658812e
commit 54ed9b1709
4 changed files with 95 additions and 9 deletions

View file

@ -84,6 +84,7 @@ ges_track_object_get_duration
ges_track_object_get_priority
ges_track_object_is_active
ges_track_object_lookup_child
ges_track_object_list_children_properties
ges_track_object_set_child_property
ges_track_object_set_child_property_valist
ges_track_object_set_child_property_by_pspec

View file

@ -119,6 +119,9 @@ static inline gboolean ges_track_object_set_duration_internal (GESTrackObject *
static inline gboolean ges_track_object_set_priority_internal (GESTrackObject *
object, guint32 priority);
GParamSpec **default_list_children_properties (GESTrackObject * object,
guint * n_properties);
static void
ges_track_object_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
@ -285,6 +288,7 @@ ges_track_object_class_init (GESTrackObjectClass * klass)
klass->create_gnl_object = ges_track_object_create_gnl_object_func;
/* There is no 'get_props_hastable' default implementation */
klass->get_props_hastable = NULL;
klass->list_children_properties = default_list_children_properties;
}
static void
@ -1240,6 +1244,27 @@ cant_copy:
}
}
/**
* ges_track_object_list_children_properties:
* @object: The #GESTrackObject to get the list of children properties from
* @n_properties: return location for the length of the returned array
*
* Gets an array of #GParamSpec* for all configurable properties of the
* children of @object.
*
* Returns: an array of #GParamSpec* which should be freed after use or %NULL
* if something went wrong
*/
GParamSpec **
ges_track_object_list_children_properties (GESTrackObject * object,
guint * n_properties)
{
GESTrackObjectClass *class;
class = GES_TRACK_OBJECT_GET_CLASS (object);
return class->list_children_properties (object, n_properties);
}
/**
* ges_track_object_get_child_property:
* @object: The origin #GESTrackObject
@ -1299,3 +1324,34 @@ prop_hash_not_set:
return;
}
}
GParamSpec **
default_list_children_properties (GESTrackObject * object, guint * n_properties)
{
GParamSpec **pspec, *spec;
GHashTableIter iter;
gpointer key, value;
guint i = 0;
if (!object->priv->properties_hashtable)
goto prop_hash_not_set;
*n_properties = g_hash_table_size (object->priv->properties_hashtable);
pspec = g_new (GParamSpec *, *n_properties);
g_hash_table_iter_init (&iter, object->priv->properties_hashtable);
while (g_hash_table_iter_next (&iter, &key, &value)) {
spec = G_PARAM_SPEC (key);
pspec[i] = g_param_spec_ref (spec);
i++;
}
return pspec;
prop_hash_not_set:
{
GST_ERROR ("The child properties haven't been set on %p", object);
return NULL;
}
}

View file

@ -97,7 +97,10 @@ struct _GESTrackObject {
* GESTrackObjectClass:
* @gnlobject_factorytype: name of the GNonLin GStElementFactory type to use.
* @create_gnl_object: method to create the GNonLin container object.
* @get_props_hastable: method to list child properties that user could like to configure.
* @get_props_hastable: method to list children properties that user could like to
* configure.
* @list_children_properties: method to get children properties that user could like to
* configure.
* The default implementation will create an object of type @gnlobject_factorytype
* and call @create_element.
* @create_element: method to return the GstElement to put in the gnlobject.
@ -120,6 +123,7 @@ struct _GESTrackObjectClass {
GstElement* (*create_gnl_object) (GESTrackObject * object);
GstElement* (*create_element) (GESTrackObject * object);
GHashTable* (*get_props_hastable) (GESTrackObject * object);
GParamSpec** (*list_children_properties) (GESTrackObject *object, guint *n_properties);
void (*start_changed) (GESTrackObject *object, guint64 start);
void (*media_start_changed) (GESTrackObject *object, guint64 media_start);
@ -161,6 +165,8 @@ guint64 ges_track_object_get_duration (GESTrackObject * object);
guint32 ges_track_object_get_priority (GESTrackObject * object);
gboolean ges_track_object_is_active (GESTrackObject * object);
GParamSpec ** ges_track_object_list_children_properties (GESTrackObject *object,
guint *n_properties);
gboolean ges_track_object_lookup_child (GESTrackObject *object,
const gchar *prop_name, GstElement **element, GParamSpec **pspec);

View file

@ -327,9 +327,12 @@ GST_START_TEST (test_track_effect_set_properties)
GESTimelineLayer *layer;
GESTrack *track_video;
GESTimelineParseLaunchEffect *tl_effect;
GESTrackParseLaunchEffect *tck_effect;
guint scratch_line;
GESTrackObject *tck_effect;
guint scratch_line, n_props, i;
gboolean color_aging;
GParamSpec **pspecs, *spec;
GValue val = { 0 };
GValue nval = { 0 };
ges_init ();
@ -348,20 +351,40 @@ GST_START_TEST (test_track_effect_set_properties)
ges_simple_timeline_layer_add_object ((GESSimpleTimelineLayer *) (layer),
(GESTimelineObject *) tl_effect, 0);
tck_effect = ges_track_parse_launch_effect_new ("agingtv");
tck_effect = GES_TRACK_OBJECT (ges_track_parse_launch_effect_new ("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)));
(tl_effect), tck_effect));
fail_unless (ges_track_add_object (track_video, tck_effect));
ges_track_object_set_child_property (GES_TRACK_OBJECT (tck_effect),
ges_track_object_set_child_property (tck_effect,
"GstAgingTV::scratch-lines", 17, "color-aging", FALSE, NULL);
ges_track_object_get_child_property (GES_TRACK_OBJECT (tck_effect),
ges_track_object_get_child_property (tck_effect,
"GstAgingTV::scratch-lines", &scratch_line,
"color-aging", &color_aging, NULL);
fail_unless (scratch_line == 17);
fail_unless (color_aging == FALSE);
pspecs = ges_track_object_list_children_properties (tck_effect, &n_props);
fail_unless (n_props == 6);
spec = pspecs[0];
i = 1;
while (g_strcmp0 (spec->name, "scratch-lines")) {
spec = pspecs[i++];
}
g_value_init (&val, G_TYPE_UINT);
g_value_init (&nval, G_TYPE_UINT);
g_value_set_uint (&val, 10);
ges_track_object_set_child_property_by_pspec (tck_effect, spec, &val);
ges_track_object_get_child_property_by_pspec (tck_effect, spec, &nval);
fail_unless (g_value_get_uint (&nval) == 10);
for (i = 0; i < n_props; i++) {
g_param_spec_unref (pspecs[i]);
}
ges_timeline_layer_remove_object (layer, (GESTimelineObject *) tl_effect);
g_object_unref (timeline);