return NULL;
}
-/*
- * gst_object_add_controlled_property:
- * @self: the object
- * @name: name of projecty in @object
- *
- * Creates a new #GstControlledProperty if there is none for property @name yet.
- *
- * Returns: %TRUE if the property has been added to the controller
- */
-static gboolean
-gst_object_add_controlled_property (GstObject * self, const gchar * name)
-{
- gboolean res = TRUE;
-
- /* test if this property isn't yet controlled */
- if (!gst_object_find_controlled_property (self, name)) {
- GstControlledProperty *prop;
-
- /* create GstControlledProperty and add to self->properties list */
- if ((prop = gst_controlled_property_new (self, name))) {
- self->properties = g_list_prepend (self->properties, prop);
- GST_DEBUG_OBJECT (self, "property %s added", name);
- } else
- res = FALSE;
- } else {
- GST_WARNING_OBJECT (self, "trying to control property %s again", name);
- }
- return res;
-}
-
-/*
- * gst_object_remove_controlled_property:
- * @self: the object
- * @name: name of projecty in @object
- *
- * Removes a #GstControlledProperty for property @name.
- *
- * Returns: %TRUE if the property has been removed from the controller
- */
-static gboolean
-gst_object_remove_controlled_property (GstObject * self, const gchar * name)
-{
- gboolean res = TRUE;
- GstControlledProperty *prop;
-
- if ((prop = gst_object_find_controlled_property (self, name))) {
- self->properties = g_list_remove (self->properties, prop);
- //g_signal_handler_disconnect (self->object, prop->notify_handler_id);
- gst_controlled_property_free (prop);
- GST_DEBUG_OBJECT (self, "property %s removed", name);
- } else {
- res = FALSE;
- }
- return res;
-}
-
/* controller functions */
/**
- * gst_object_control_properties:
- * @object: the object of which some properties should be controlled
- * @...: %NULL terminated list of property names that should be controlled
- *
- * Creates a GstController that allows you to dynamically control one, or more,
- * GObject properties. If the given GstObject already has a GstController,
- * it adds the given properties to the existing
- * controller and returns that controller.
- *
- * Returns: %TRUE if the properties have been made controllable.
- */
-gboolean
-gst_object_control_properties (GstObject * object, ...)
-{
- gboolean res = TRUE;
- va_list var_args;
- gchar *name;
-
- g_return_val_if_fail (GST_IS_OBJECT (object), FALSE);
-
- va_start (var_args, object);
- GST_OBJECT_LOCK (object);
- while ((name = va_arg (var_args, gchar *))) {
- res &= gst_object_add_controlled_property (object, name);
- }
- GST_OBJECT_UNLOCK (object);
- va_end (var_args);
- return res;
-}
-
-/**
- * gst_object_uncontrol_properties:
- * @object: the object of which some properties should not be controlled anymore
- * @...: %NULL terminated list of property names that should be controlled
- *
- * Removes the given element's properties from it's controller
- *
- * Returns: %FALSE if one of the given property names isn't handled by the
- * controller, %TRUE otherwise
- */
-gboolean
-gst_object_uncontrol_properties (GstObject * object, ...)
-{
- gboolean res = TRUE;
- va_list var_args;
- gchar *name;
-
- g_return_val_if_fail (GST_IS_OBJECT (object), FALSE);
-
- va_start (var_args, object);
- GST_OBJECT_LOCK (object);
- while ((name = va_arg (var_args, gchar *))) {
- res &= gst_object_remove_controlled_property (object, name);
- }
- GST_OBJECT_UNLOCK (object);
- va_end (var_args);
- return (res);
-}
-
-/**
* gst_object_suggest_next_sync:
* @object: the object that has controlled properties
*
for (node = object->properties; node; node = g_list_next (node)) {
prop = node->data;
- if (!prop->csource || prop->disabled)
+ if (prop->disabled)
continue;
GST_LOG ("property '%s' at ts=%" G_GUINT64_FORMAT, prop->name, timestamp);
g_return_val_if_fail ((!csource || GST_IS_CONTROL_SOURCE (csource)), FALSE);
GST_OBJECT_LOCK (object);
- if ((prop = gst_object_find_controlled_property (object, property_name))) {
+ prop = gst_object_find_controlled_property (object, property_name);
+ if (!prop) {
+ if ((prop = gst_controlled_property_new (object, property_name))) {
+ object->properties = g_list_prepend (object->properties, prop);
+ GST_DEBUG_OBJECT (object, "controlled property %s added", property_name);
+ }
+ }
+ if (prop) {
GstControlSource *old = prop->csource;
- if (csource && (ret = gst_control_source_bind (csource, prop->pspec))) {
- prop->csource = g_object_ref (csource);
- } else if (!csource) {
- ret = TRUE;
- prop->csource = NULL;
+ if (csource != old) {
+ if (csource && (ret = gst_control_source_bind (csource, prop->pspec))) {
+ prop->csource = g_object_ref (csource);
+ } else if (!csource) {
+ ret = TRUE;
+ prop->csource = NULL;
+ object->properties = g_list_remove (object->properties, prop);
+ //g_signal_handler_disconnect (self->object, prop->notify_handler_id);
+ gst_controlled_property_free (prop);
+ GST_DEBUG_OBJECT (object, "controlled property %s removed",
+ property_name);
+ }
+ if (ret && old)
+ g_object_unref (old);
}
-
- if (ret && old)
- g_object_unref (old);
}
GST_OBJECT_UNLOCK (object);
GST_OBJECT_LOCK (object);
if ((prop = gst_object_find_controlled_property (object, property_name))) {
- if ((ret = prop->csource))
- g_object_ref (ret);
+ ret = g_object_ref (prop->csource);
}
GST_OBJECT_UNLOCK (object);
if ((prop = gst_object_find_controlled_property (object, property_name))) {
val = g_new0 (GValue, 1);
g_value_init (val, G_PARAM_SPEC_VALUE_TYPE (prop->pspec));
- if (prop->csource) {
- gboolean res;
-
- /* get current value via control source */
- res = gst_control_source_get_value (prop->csource, timestamp, val);
- if (!res) {
- g_free (val);
- val = NULL;
- }
- } else {
- g_object_get_property ((GObject *) object, prop->name, val);
+
+ /* get current value via control source */
+ if (!gst_control_source_get_value (prop->csource, timestamp, val)) {
+ g_free (val);
+ val = NULL;
}
}
GST_OBJECT_UNLOCK (object);
g_return_val_if_fail (value_array->values, FALSE);
GST_OBJECT_LOCK (object);
-
if ((prop = gst_object_find_controlled_property (object,
value_array->property_name))) {
- /* get current value_array via control source */
- if (!prop->csource)
- goto out;
-
res = gst_control_source_get_value_array (prop->csource, timestamp,
value_array);
}
-
-out:
GST_OBJECT_UNLOCK (object);
return res;
}
GST_START_TEST (controller_new_fail1)
{
GstElement *elem;
+ GstInterpolationControlSource *cs;
gboolean res;
elem = gst_element_factory_make ("fakesrc", "test_source");
+ cs = gst_interpolation_control_source_new ();
+
/* that property should not exist */
- res = gst_object_control_properties (GST_OBJECT (elem), "_schrompf_", NULL);
+ res = gst_object_set_control_source (GST_OBJECT (elem), "_schrompf_",
+ GST_CONTROL_SOURCE (cs));
fail_unless (res == FALSE, NULL);
+ g_object_unref (cs);
gst_object_unref (elem);
}
GST_START_TEST (controller_new_fail2)
{
GstElement *elem;
+ GstInterpolationControlSource *cs;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
+ cs = gst_interpolation_control_source_new ();
/* that property should exist and but is readonly */
- ASSERT_CRITICAL (res =
- gst_object_control_properties (GST_OBJECT (elem), "readonly", NULL));
+ ASSERT_CRITICAL (res = gst_object_set_control_source (GST_OBJECT (elem),
+ "readonly", GST_CONTROL_SOURCE (cs)));
fail_unless (res == FALSE, NULL);
+ g_object_unref (cs);
gst_object_unref (elem);
}
GST_START_TEST (controller_new_fail3)
{
GstElement *elem;
+ GstInterpolationControlSource *cs;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
+ cs = gst_interpolation_control_source_new ();
/* that property should exist and but is not controlable */
- ASSERT_CRITICAL (res = gst_object_control_properties (GST_OBJECT (elem),
- "static", NULL));
+ ASSERT_CRITICAL (res = gst_object_set_control_source (GST_OBJECT (elem),
+ "static", GST_CONTROL_SOURCE (cs)));
fail_unless (res == FALSE, NULL);
+ g_object_unref (cs);
gst_object_unref (elem);
}
GST_START_TEST (controller_new_fail4)
{
GstElement *elem;
+ GstInterpolationControlSource *cs;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
+ cs = gst_interpolation_control_source_new ();
/* that property should exist and but is construct-only */
ASSERT_CRITICAL (res =
- gst_object_control_properties (GST_OBJECT (elem), "construct-only",
- NULL));
+ gst_object_set_control_source (GST_OBJECT (elem), "construct-only",
+ GST_CONTROL_SOURCE (cs)));
fail_unless (res == FALSE, NULL);
+ g_object_unref (cs);
gst_object_unref (elem);
}
GST_START_TEST (controller_new_okay1)
{
GstElement *elem;
+ GstInterpolationControlSource *cs;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
+ cs = gst_interpolation_control_source_new ();
/* that property should exist and should be controllable */
- res = gst_object_control_properties (GST_OBJECT (elem), "ulong", NULL);
+ res = gst_object_set_control_source (GST_OBJECT (elem), "ulong",
+ GST_CONTROL_SOURCE (cs));
fail_unless (res == TRUE, NULL);
+ g_object_unref (cs);
gst_object_unref (elem);
}
GST_START_TEST (controller_new_okay2)
{
GstElement *elem;
+ GstInterpolationControlSource *cs1, *cs2;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
+ cs1 = gst_interpolation_control_source_new ();
+ cs2 = gst_interpolation_control_source_new ();
/* these properties should exist and should be controllable */
- res = gst_object_control_properties (GST_OBJECT (elem), "ulong", "double",
- "float", NULL);
+ res = gst_object_set_control_source (GST_OBJECT (elem), "ulong",
+ GST_CONTROL_SOURCE (cs1));
fail_unless (res == TRUE, NULL);
- res = gst_object_control_properties (GST_OBJECT (elem), "boolean", NULL);
+ res = gst_object_set_control_source (GST_OBJECT (elem), "boolean",
+ GST_CONTROL_SOURCE (cs2));
fail_unless (res == TRUE, NULL);
+ g_object_unref (cs1);
+ g_object_unref (cs2);
gst_object_unref (elem);
}
GST_END_TEST;
-/* controlling a params twice should be handled */
+/* controlling a param twice should be handled */
GST_START_TEST (controller_param_twice)
{
GstElement *elem;
+ GstInterpolationControlSource *cs;
gboolean res;
elem = gst_element_factory_make ("testmonosource", "test_source");
+ cs = gst_interpolation_control_source_new ();
/* that property should exist and should be controllable */
- res =
- gst_object_control_properties (GST_OBJECT (elem), "ulong", "ulong", NULL);
+ res = gst_object_set_control_source (GST_OBJECT (elem), "ulong",
+ GST_CONTROL_SOURCE (cs));
fail_unless (res, NULL);
+ /* setting it again should not work */
+ res = gst_object_set_control_source (GST_OBJECT (elem), "ulong",
+ GST_CONTROL_SOURCE (cs));
+ fail_unless (!res, NULL);
+
/* it should have been added at least once, let remove it */
- res = gst_object_uncontrol_properties (GST_OBJECT (elem), "ulong", NULL);
+ res = gst_object_set_control_source (GST_OBJECT (elem), "ulong", NULL);
fail_unless (res, NULL);
/* removing it again should not work */
- res = gst_object_uncontrol_properties (GST_OBJECT (elem), "ulong", NULL);
+ res = gst_object_set_control_source (GST_OBJECT (elem), "ulong", NULL);
fail_unless (!res, NULL);
+ g_object_unref (cs);
gst_object_unref (elem);
}
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
csource = (GstControlSource *) gst_interpolation_control_source_new ();
fail_unless (csource != NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
csource = (GstControlSource *) gst_interpolation_control_source_new ();
fail_unless (csource != NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
csource = gst_interpolation_control_source_new ();
fail_unless (csource != NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "double",
- NULL));
-
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "double",
- NULL));
-
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "float",
- NULL));
-
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- "double", NULL));
-
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
csource2 = gst_interpolation_control_source_new ();
/* test that an invalid timestamp throws a warning of some sort */
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
{
GstLFOControlSource *csource;
GstElement *elem;
- GValue amp = { 0, }
- , off = {
- 0,};
+ GValue amp = { 0, };
+ GValue off = { 0, };
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
/* Get interpolation control source */
csource = gst_lfo_control_source_new ();
{
GstLFOControlSource *csource;
GstElement *elem;
- GValue amp = { 0, }
- , off = {
- 0,};
+ GValue amp = { 0, };
+ GValue off = { 0, };
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
/* Get interpolation control source */
csource = gst_lfo_control_source_new ();
{
GstLFOControlSource *csource;
GstElement *elem;
- GValue amp = { 0, }
- , off = {
- 0,};
+ GValue amp = { 0, };
+ GValue off = { 0, };
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
/* Get interpolation control source */
csource = gst_lfo_control_source_new ();
{
GstLFOControlSource *csource;
GstElement *elem;
- GValue amp = { 0, }
- , off = {
- 0,};
+ GValue amp = { 0, };
+ GValue off = { 0, };
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
/* Get interpolation control source */
csource = gst_lfo_control_source_new ();
{
GstLFOControlSource *csource;
GstElement *elem;
- GValue amp = { 0, }
- , off = {
- 0,};
+ GValue amp = { 0, };
+ GValue off = { 0, };
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
/* Get interpolation control source */
csource = gst_lfo_control_source_new ();
{
GstLFOControlSource *csource;
GstElement *elem;
- GValue amp = { 0, }
- , off = {
- 0,};
+ GValue amp = { 0, };
+ GValue off = { 0, };
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
/* Get interpolation control source */
csource = gst_lfo_control_source_new ();
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
/* Get interpolation control source */
csource = gst_lfo_control_source_new ();
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();
elem = gst_element_factory_make ("testmonosource", "test_source");
- /* that property should exist and should be controllable */
- fail_unless (gst_object_control_properties (GST_OBJECT (elem), "ulong",
- NULL));
-
/* Get interpolation control source */
csource = gst_interpolation_control_source_new ();