mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 11:32:38 +00:00
GESTrackObject: Implement a get/set_child_property_by_spec and get/set_child_property_valist methods
Reimplement the get/set_property accordingly
This commit is contained in:
parent
1add2482b8
commit
0e9658812e
4 changed files with 254 additions and 55 deletions
|
@ -85,7 +85,11 @@ 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_set_child_property
|
ges_track_object_set_child_property
|
||||||
|
ges_track_object_set_child_property_valist
|
||||||
|
ges_track_object_set_child_property_by_pspec
|
||||||
ges_track_object_get_child_property
|
ges_track_object_get_child_property
|
||||||
|
ges_track_object_get_child_property_valist
|
||||||
|
ges_track_object_get_child_property_by_pspec
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
GES_TRACK_OBJECT_DURATION
|
GES_TRACK_OBJECT_DURATION
|
||||||
GES_TRACK_OBJECT_INPOINT
|
GES_TRACK_OBJECT_INPOINT
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "gesmarshal.h"
|
#include "gesmarshal.h"
|
||||||
#include "ges-track-object.h"
|
#include "ges-track-object.h"
|
||||||
#include "ges-timeline-object.h"
|
#include "ges-timeline-object.h"
|
||||||
|
#include <gobject/gvaluecollector.h>
|
||||||
|
|
||||||
G_DEFINE_ABSTRACT_TYPE (GESTrackObject, ges_track_object,
|
G_DEFINE_ABSTRACT_TYPE (GESTrackObject, ges_track_object,
|
||||||
G_TYPE_INITIALLY_UNOWNED);
|
G_TYPE_INITIALLY_UNOWNED);
|
||||||
|
@ -1051,64 +1052,250 @@ ges_track_object_lookup_child (GESTrackObject * object, const gchar * prop_name,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ges_track_object_set_child_property:
|
* ges_track_object_set_child_property_by_pspec:
|
||||||
* @object: a #GESTrackObject
|
* @object: a #GESTrackObject
|
||||||
* @property_name: The name of the property to set
|
* @pspec: The #GParamSpec that specifies the property you want to set
|
||||||
* @value: the value
|
* @value: the value
|
||||||
*
|
*
|
||||||
* Sets a property of a child of @object. The property name
|
* Sets a property of a child of @object.
|
||||||
* should look like ClasseName-property-name
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ges_track_object_set_child_property (GESTrackObject * object,
|
ges_track_object_set_child_property_by_pspec (GESTrackObject * object,
|
||||||
const gchar * property_name, GValue * value)
|
GParamSpec * pspec, GValue * value)
|
||||||
{
|
{
|
||||||
|
GstElement *element;
|
||||||
|
|
||||||
GESTrackObjectPrivate *priv = object->priv;
|
GESTrackObjectPrivate *priv = object->priv;
|
||||||
|
|
||||||
if (priv->properties_hashtable) {
|
if (!priv->properties_hashtable)
|
||||||
GstElement *element;
|
goto prop_hash_not_set;
|
||||||
gchar **prop_name;
|
|
||||||
|
|
||||||
element = g_hash_table_lookup (priv->properties_hashtable, property_name);
|
element = g_hash_table_lookup (priv->properties_hashtable, pspec);
|
||||||
if (element) {
|
if (!element)
|
||||||
prop_name = g_strsplit (property_name, "-", 2);
|
goto not_found;
|
||||||
g_object_set_property (G_OBJECT (element), prop_name[1], value);
|
|
||||||
g_strfreev (prop_name);
|
g_object_set_property (G_OBJECT (element), pspec->name, value);
|
||||||
} else {
|
|
||||||
GST_ERROR ("The %s property doesn't exist", property_name);
|
return;
|
||||||
}
|
|
||||||
} else {
|
not_found:
|
||||||
|
{
|
||||||
|
GST_ERROR ("The %s property doesn't exist", pspec->name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
prop_hash_not_set:
|
||||||
|
{
|
||||||
GST_DEBUG ("The child properties haven't been set on %p", object);
|
GST_DEBUG ("The child properties haven't been set on %p", object);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ges_track_object_get_child_property:
|
* ges_track_object_set_child_property_valist:
|
||||||
* @object: The origin #GESTrackObject
|
* @object: The #GESTrackObject parent object
|
||||||
* @property_name: The name of the property
|
* @first_property_name: The name of the first property to set
|
||||||
* @value: return location for the property value
|
* @var_args: value for the first property, followed optionally by more
|
||||||
*
|
* name/return location pairs, followed by NULL
|
||||||
* Gets a property of a child of @object.
|
*
|
||||||
*/
|
* Sets a property of a child of @object. If there are various child elements
|
||||||
|
* that have the same property name, you can distinguish them using the following
|
||||||
|
* synthaxe: 'ClasseName::property_name' as property name. If you don't, the
|
||||||
|
* corresponding property of the first element found will be set.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
ges_track_object_get_child_property (GESTrackObject * object,
|
ges_track_object_set_child_property_valist (GESTrackObject * object,
|
||||||
const gchar * property_name, gpointer value)
|
const gchar * first_property_name, va_list var_args)
|
||||||
{
|
{
|
||||||
GESTrackObjectPrivate *priv = object->priv;
|
const gchar *name;
|
||||||
|
GParamSpec *pspec;
|
||||||
|
GstElement *element;
|
||||||
|
|
||||||
if (priv->properties_hashtable) {
|
gchar *error = NULL;
|
||||||
GstElement *element;
|
GValue value = { 0, };
|
||||||
gchar **prop_name;
|
|
||||||
|
|
||||||
element = g_hash_table_lookup (priv->properties_hashtable, property_name);
|
g_return_if_fail (G_IS_OBJECT (object));
|
||||||
if (element) {
|
|
||||||
prop_name = g_strsplit (property_name, "-", 2);
|
name = first_property_name;
|
||||||
g_object_get (G_OBJECT (element), prop_name[1], value, NULL);
|
|
||||||
g_strfreev (prop_name);
|
/* Note: This part is in big part copied from the gst_child_object_set_valist
|
||||||
} else {
|
* method. */
|
||||||
GST_ERROR ("The %s property doesn't exist", property_name);
|
|
||||||
}
|
/* iterate over pairs */
|
||||||
} else {
|
while (name) {
|
||||||
GST_DEBUG ("The child properties haven't been set on %p", object);
|
if (!ges_track_object_lookup_child (object, name, &element, &pspec))
|
||||||
|
goto not_found;
|
||||||
|
|
||||||
|
#if GLIB_CHECK_VERSION(2,23,3)
|
||||||
|
G_VALUE_COLLECT_INIT (&value, pspec->value_type, var_args,
|
||||||
|
G_VALUE_NOCOPY_CONTENTS, &error);
|
||||||
|
#else
|
||||||
|
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
||||||
|
G_VALUE_COLLECT (&value, var_args, G_VALUE_NOCOPY_CONTENTS, &error);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (error)
|
||||||
|
goto cant_copy;
|
||||||
|
|
||||||
|
g_object_set_property (G_OBJECT (element), pspec->name, &value);
|
||||||
|
|
||||||
|
g_object_unref (element);
|
||||||
|
g_value_unset (&value);
|
||||||
|
|
||||||
|
name = va_arg (var_args, gchar *);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
|
||||||
|
not_found:
|
||||||
|
{
|
||||||
|
GST_WARNING ("No property %s in OBJECT\n", name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cant_copy:
|
||||||
|
{
|
||||||
|
GST_WARNING ("error copying value %s in object %p: %s", pspec->name, object,
|
||||||
|
error);
|
||||||
|
g_value_unset (&value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ges_track_object_set_child_property:
|
||||||
|
* @object: The #GESTrackObject parent object
|
||||||
|
* @first_property_name: The name of the first property to set
|
||||||
|
* @...: value for the first property, followed optionally by more
|
||||||
|
* name/return location pairs, followed by NULL
|
||||||
|
*
|
||||||
|
* Sets a property of a child of @object. If there are various child elements
|
||||||
|
* that have the same property name, you can distinguish them using the following
|
||||||
|
* synthaxe: 'ClasseName::property_name' as property name. If you don't, the
|
||||||
|
* corresponding property of the first element found will be set.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
ges_track_object_set_child_property (GESTrackObject * object,
|
||||||
|
const gchar * first_property_name, ...)
|
||||||
|
{
|
||||||
|
va_list var_args;
|
||||||
|
|
||||||
|
va_start (var_args, first_property_name);
|
||||||
|
ges_track_object_set_child_property_valist (object, first_property_name,
|
||||||
|
var_args);
|
||||||
|
va_end (var_args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ges_track_object_get_child_property_valist:
|
||||||
|
* @object: The #GESTrackObject parent object
|
||||||
|
* @first_property_name: The name of the first property to get
|
||||||
|
* @var_args: value for the first property, followed optionally by more
|
||||||
|
* name/return location pairs, followed by NULL
|
||||||
|
*
|
||||||
|
* Gets a property of a child of @object. If there are various child elements
|
||||||
|
* that have the same property name, you can distinguish them using the following
|
||||||
|
* synthaxe: 'ClasseName::property_name' as property name. If you don't, the
|
||||||
|
* corresponding property of the first element found will be set.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
ges_track_object_get_child_property_valist (GESTrackObject * object,
|
||||||
|
const gchar * first_property_name, va_list var_args)
|
||||||
|
{
|
||||||
|
const gchar *name;
|
||||||
|
gchar *error = NULL;
|
||||||
|
GValue value = { 0, };
|
||||||
|
GParamSpec *pspec;
|
||||||
|
GstElement *element;
|
||||||
|
|
||||||
|
g_return_if_fail (G_IS_OBJECT (object));
|
||||||
|
|
||||||
|
name = first_property_name;
|
||||||
|
|
||||||
|
/* This part is in big part copied from the gst_child_object_get_valist method */
|
||||||
|
while (name) {
|
||||||
|
if (!ges_track_object_lookup_child (object, name, &element, &pspec))
|
||||||
|
goto not_found;
|
||||||
|
|
||||||
|
g_value_init (&value, pspec->value_type);
|
||||||
|
g_object_get_property (G_OBJECT (element), pspec->name, &value);
|
||||||
|
g_object_unref (element);
|
||||||
|
|
||||||
|
G_VALUE_LCOPY (&value, var_args, 0, &error);
|
||||||
|
if (error)
|
||||||
|
goto cant_copy;
|
||||||
|
g_value_unset (&value);
|
||||||
|
name = va_arg (var_args, gchar *);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
|
||||||
|
not_found:
|
||||||
|
{
|
||||||
|
GST_WARNING ("no property %s in object", name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cant_copy:
|
||||||
|
{
|
||||||
|
GST_WARNING ("error copying value %s in object %p: %s", pspec->name, object,
|
||||||
|
error);
|
||||||
|
g_value_unset (&value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ges_track_object_get_child_property:
|
||||||
|
* @object: The origin #GESTrackObject
|
||||||
|
* @first_property_name: The name of the first property to get
|
||||||
|
* @...: return location for the first property, followed optionally by more
|
||||||
|
* name/return location pairs, followed by NULL
|
||||||
|
*
|
||||||
|
* Gets properties of a child of @object.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
ges_track_object_get_child_property (GESTrackObject * object,
|
||||||
|
const gchar * first_property_name, ...)
|
||||||
|
{
|
||||||
|
va_list var_args;
|
||||||
|
|
||||||
|
va_start (var_args, first_property_name);
|
||||||
|
ges_track_object_get_child_property_valist (object, first_property_name,
|
||||||
|
var_args);
|
||||||
|
va_end (var_args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ges_track_object_get_child_property_by_pspec:
|
||||||
|
* @object: a #GESTrackObject
|
||||||
|
* @pspec: The #GParamSpec that specifies the property you want to get
|
||||||
|
* @value: return location for the value
|
||||||
|
*
|
||||||
|
* Gets a property of a child of @object.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
ges_track_object_get_child_property_by_pspec (GESTrackObject * object,
|
||||||
|
GParamSpec * pspec, GValue * value)
|
||||||
|
{
|
||||||
|
GstElement *element;
|
||||||
|
|
||||||
|
GESTrackObjectPrivate *priv = object->priv;
|
||||||
|
|
||||||
|
if (!priv->properties_hashtable)
|
||||||
|
goto prop_hash_not_set;
|
||||||
|
|
||||||
|
element = g_hash_table_lookup (priv->properties_hashtable, pspec);
|
||||||
|
if (!element)
|
||||||
|
goto not_found;
|
||||||
|
|
||||||
|
g_object_get_property (G_OBJECT (element), pspec->name, value);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
not_found:
|
||||||
|
{
|
||||||
|
GST_ERROR ("The %s property doesn't exist", pspec->name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
prop_hash_not_set:
|
||||||
|
{
|
||||||
|
GST_ERROR ("The child properties haven't been set on %p", object);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,8 +164,19 @@ gboolean ges_track_object_is_active (GESTrackObject * object);
|
||||||
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);
|
||||||
|
|
||||||
|
void ges_track_object_get_child_property_by_pspec (GESTrackObject * object,
|
||||||
|
GParamSpec * pspec, GValue * value);
|
||||||
|
void ges_track_object_get_child_property_valist (GESTrackObject * object,
|
||||||
|
const gchar * first_property_name, va_list var_args);
|
||||||
void ges_track_object_get_child_property (GESTrackObject *object,
|
void ges_track_object_get_child_property (GESTrackObject *object,
|
||||||
const gchar *property_name,
|
const gchar * first_property_name, ...) G_GNUC_NULL_TERMINATED;
|
||||||
gpointer value);
|
|
||||||
|
void ges_track_object_set_child_property_valist (GESTrackObject * object,
|
||||||
|
const gchar * first_property_name, va_list var_args);
|
||||||
|
void ges_track_object_set_child_property_by_pspec (GESTrackObject * object,
|
||||||
|
GParamSpec * pspec, GValue * value);
|
||||||
|
void ges_track_object_set_child_property (GESTrackObject * object,
|
||||||
|
const gchar * first_property_name, ...) G_GNUC_NULL_TERMINATED;
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
#endif /* _GES_TRACK_OBJECT */
|
#endif /* _GES_TRACK_OBJECT */
|
||||||
|
|
|
@ -328,8 +328,8 @@ GST_START_TEST (test_track_effect_set_properties)
|
||||||
GESTrack *track_video;
|
GESTrack *track_video;
|
||||||
GESTimelineParseLaunchEffect *tl_effect;
|
GESTimelineParseLaunchEffect *tl_effect;
|
||||||
GESTrackParseLaunchEffect *tck_effect;
|
GESTrackParseLaunchEffect *tck_effect;
|
||||||
GValue value = { 0 };
|
guint scratch_line;
|
||||||
guint val;
|
gboolean color_aging;
|
||||||
|
|
||||||
ges_init ();
|
ges_init ();
|
||||||
|
|
||||||
|
@ -354,13 +354,13 @@ GST_START_TEST (test_track_effect_set_properties)
|
||||||
fail_unless (ges_track_add_object (track_video,
|
fail_unless (ges_track_add_object (track_video,
|
||||||
GES_TRACK_OBJECT (tck_effect)));
|
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),
|
ges_track_object_set_child_property (GES_TRACK_OBJECT (tck_effect),
|
||||||
"GstAgingTV-scratch-lines", &value);
|
"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 (GES_TRACK_OBJECT (tck_effect),
|
||||||
"GstAgingTV-scratch-lines", &val);
|
"GstAgingTV::scratch-lines", &scratch_line,
|
||||||
fail_unless (val == 17);
|
"color-aging", &color_aging, NULL);
|
||||||
|
fail_unless (scratch_line == 17);
|
||||||
|
fail_unless (color_aging == FALSE);
|
||||||
|
|
||||||
ges_timeline_layer_remove_object (layer, (GESTimelineObject *) tl_effect);
|
ges_timeline_layer_remove_object (layer, (GESTimelineObject *) tl_effect);
|
||||||
|
|
||||||
|
@ -393,7 +393,6 @@ GST_START_TEST (test_tl_obj_signals)
|
||||||
GESTrack *track_video;
|
GESTrack *track_video;
|
||||||
GESTimelineParseLaunchEffect *tl_effect;
|
GESTimelineParseLaunchEffect *tl_effect;
|
||||||
GESTrackParseLaunchEffect *tck_effect;
|
GESTrackParseLaunchEffect *tck_effect;
|
||||||
GValue value = { 0 };
|
|
||||||
guint val;
|
guint val;
|
||||||
|
|
||||||
ges_init ();
|
ges_init ();
|
||||||
|
@ -423,12 +422,10 @@ GST_START_TEST (test_tl_obj_signals)
|
||||||
g_signal_connect (tck_effect, "deep-notify", (GCallback) deep_prop_changed_cb,
|
g_signal_connect (tck_effect, "deep-notify", (GCallback) deep_prop_changed_cb,
|
||||||
tck_effect);
|
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),
|
ges_track_object_set_child_property (GES_TRACK_OBJECT (tck_effect),
|
||||||
"GstAgingTV-scratch-lines", &value);
|
"GstAgingTV::scratch-lines", 17, NULL);
|
||||||
ges_track_object_get_child_property (GES_TRACK_OBJECT (tck_effect),
|
ges_track_object_get_child_property (GES_TRACK_OBJECT (tck_effect),
|
||||||
"GstAgingTV-scratch-lines", &val);
|
"GstAgingTV::scratch-lines", &val, NULL);
|
||||||
fail_unless (val == 17);
|
fail_unless (val == 17);
|
||||||
|
|
||||||
ges_timeline_layer_remove_object (layer, (GESTimelineObject *) tl_effect);
|
ges_timeline_layer_remove_object (layer, (GESTimelineObject *) tl_effect);
|
||||||
|
|
Loading…
Reference in a new issue