mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-30 19:18:31 +00:00
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:
parent
0e9658812e
commit
54ed9b1709
4 changed files with 95 additions and 9 deletions
|
@ -84,6 +84,7 @@ ges_track_object_get_duration
|
||||||
ges_track_object_get_priority
|
ges_track_object_get_priority
|
||||||
ges_track_object_is_active
|
ges_track_object_is_active
|
||||||
ges_track_object_lookup_child
|
ges_track_object_lookup_child
|
||||||
|
ges_track_object_list_children_properties
|
||||||
ges_track_object_set_child_property
|
ges_track_object_set_child_property
|
||||||
ges_track_object_set_child_property_valist
|
ges_track_object_set_child_property_valist
|
||||||
ges_track_object_set_child_property_by_pspec
|
ges_track_object_set_child_property_by_pspec
|
||||||
|
|
|
@ -119,6 +119,9 @@ static inline gboolean ges_track_object_set_duration_internal (GESTrackObject *
|
||||||
static inline gboolean ges_track_object_set_priority_internal (GESTrackObject *
|
static inline gboolean ges_track_object_set_priority_internal (GESTrackObject *
|
||||||
object, guint32 priority);
|
object, guint32 priority);
|
||||||
|
|
||||||
|
GParamSpec **default_list_children_properties (GESTrackObject * object,
|
||||||
|
guint * n_properties);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ges_track_object_get_property (GObject * object, guint property_id,
|
ges_track_object_get_property (GObject * object, guint property_id,
|
||||||
GValue * value, GParamSpec * pspec)
|
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;
|
klass->create_gnl_object = ges_track_object_create_gnl_object_func;
|
||||||
/* There is no 'get_props_hastable' default implementation */
|
/* There is no 'get_props_hastable' default implementation */
|
||||||
klass->get_props_hastable = NULL;
|
klass->get_props_hastable = NULL;
|
||||||
|
klass->list_children_properties = default_list_children_properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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:
|
* ges_track_object_get_child_property:
|
||||||
* @object: The origin #GESTrackObject
|
* @object: The origin #GESTrackObject
|
||||||
|
@ -1299,3 +1324,34 @@ prop_hash_not_set:
|
||||||
return;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -97,7 +97,10 @@ struct _GESTrackObject {
|
||||||
* GESTrackObjectClass:
|
* GESTrackObjectClass:
|
||||||
* @gnlobject_factorytype: name of the GNonLin GStElementFactory type to use.
|
* @gnlobject_factorytype: name of the GNonLin GStElementFactory type to use.
|
||||||
* @create_gnl_object: method to create the GNonLin container object.
|
* @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
|
* The default implementation will create an object of type @gnlobject_factorytype
|
||||||
* and call @create_element.
|
* and call @create_element.
|
||||||
* @create_element: method to return the GstElement to put in the gnlobject.
|
* @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_gnl_object) (GESTrackObject * object);
|
||||||
GstElement* (*create_element) (GESTrackObject * object);
|
GstElement* (*create_element) (GESTrackObject * object);
|
||||||
GHashTable* (*get_props_hastable) (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 (*start_changed) (GESTrackObject *object, guint64 start);
|
||||||
void (*media_start_changed) (GESTrackObject *object, guint64 media_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);
|
guint32 ges_track_object_get_priority (GESTrackObject * object);
|
||||||
gboolean ges_track_object_is_active (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,
|
gboolean ges_track_object_lookup_child (GESTrackObject *object,
|
||||||
const gchar *prop_name, GstElement **element, GParamSpec **pspec);
|
const gchar *prop_name, GstElement **element, GParamSpec **pspec);
|
||||||
|
|
||||||
|
|
|
@ -327,9 +327,12 @@ GST_START_TEST (test_track_effect_set_properties)
|
||||||
GESTimelineLayer *layer;
|
GESTimelineLayer *layer;
|
||||||
GESTrack *track_video;
|
GESTrack *track_video;
|
||||||
GESTimelineParseLaunchEffect *tl_effect;
|
GESTimelineParseLaunchEffect *tl_effect;
|
||||||
GESTrackParseLaunchEffect *tck_effect;
|
GESTrackObject *tck_effect;
|
||||||
guint scratch_line;
|
guint scratch_line, n_props, i;
|
||||||
gboolean color_aging;
|
gboolean color_aging;
|
||||||
|
GParamSpec **pspecs, *spec;
|
||||||
|
GValue val = { 0 };
|
||||||
|
GValue nval = { 0 };
|
||||||
|
|
||||||
ges_init ();
|
ges_init ();
|
||||||
|
|
||||||
|
@ -348,20 +351,40 @@ GST_START_TEST (test_track_effect_set_properties)
|
||||||
ges_simple_timeline_layer_add_object ((GESSimpleTimelineLayer *) (layer),
|
ges_simple_timeline_layer_add_object ((GESSimpleTimelineLayer *) (layer),
|
||||||
(GESTimelineObject *) tl_effect, 0);
|
(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
|
fail_unless (ges_timeline_object_add_track_object (GES_TIMELINE_OBJECT
|
||||||
(tl_effect), GES_TRACK_OBJECT (tck_effect)));
|
(tl_effect), tck_effect));
|
||||||
fail_unless (ges_track_add_object (track_video,
|
fail_unless (ges_track_add_object (track_video, tck_effect));
|
||||||
GES_TRACK_OBJECT (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);
|
"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,
|
"GstAgingTV::scratch-lines", &scratch_line,
|
||||||
"color-aging", &color_aging, NULL);
|
"color-aging", &color_aging, NULL);
|
||||||
fail_unless (scratch_line == 17);
|
fail_unless (scratch_line == 17);
|
||||||
fail_unless (color_aging == FALSE);
|
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);
|
ges_timeline_layer_remove_object (layer, (GESTimelineObject *) tl_effect);
|
||||||
|
|
||||||
g_object_unref (timeline);
|
g_object_unref (timeline);
|
||||||
|
|
Loading…
Reference in a new issue