controller: remove convenience api for control sources

This is needed to support multiple kinds of control-bindings.
This commit is contained in:
Stefan Sauer 2012-01-20 08:27:57 +01:00
parent c6ac51e729
commit c227d51fa9
11 changed files with 163 additions and 202 deletions

View file

@ -1487,8 +1487,6 @@ gst_object_set_control_bindings_disabled
gst_object_set_control_binding_disabled gst_object_set_control_binding_disabled
gst_object_set_control_binding gst_object_set_control_binding
gst_object_get_control_binding gst_object_get_control_binding
gst_object_get_control_source
gst_object_set_control_source
gst_object_get_value gst_object_get_value
gst_object_get_value_array gst_object_get_value_array
gst_object_get_control_rate gst_object_get_control_rate

View file

@ -45,8 +45,8 @@ static void gst_control_binding_finalize (GObject * object);
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "gstcontrolbinding", 0, \ GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "gstcontrolbinding", 0, \
"dynamic parameter control source attachment"); "dynamic parameter control source attachment");
G_DEFINE_TYPE_WITH_CODE (GstControlBinding, gst_control_binding, G_TYPE_OBJECT, G_DEFINE_TYPE_WITH_CODE (GstControlBinding, gst_control_binding,
_do_init); GST_TYPE_OBJECT, _do_init);
static void static void
gst_control_binding_class_init (GstControlBindingClass * klass) gst_control_binding_class_init (GstControlBindingClass * klass)
@ -364,8 +364,6 @@ gst_control_binding_get_value_array (GstControlBinding * self,
return res; return res;
} }
/** /**
* gst_control_binding_get_control_source: * gst_control_binding_get_control_source:
* @self: the control binding * @self: the control binding

View file

@ -64,7 +64,7 @@ typedef void (* GstControlBindingConvert) (GstControlBinding *self, gdouble src_
* The instance structure of #GstControlBinding. * The instance structure of #GstControlBinding.
*/ */
struct _GstControlBinding { struct _GstControlBinding {
GObject parent; GstObject parent;
/*< public >*/ /*< public >*/
const gchar *name; /* name of the property */ const gchar *name; /* name of the property */
@ -91,7 +91,13 @@ struct _GstControlBinding {
struct _GstControlBindingClass struct _GstControlBindingClass
{ {
GObjectClass parent_class; GstObjectClass parent_class;
/* need vfuncs for:
_sync_values
_get_value
_get_value_array
*/
/*< private >*/ /*< private >*/
gpointer _gst_reserved[GST_PADDING]; gpointer _gst_reserved[GST_PADDING];

View file

@ -117,7 +117,7 @@
* </para></listitem> * </para></listitem>
* <listitem><para> * <listitem><para>
* Attach the #GstControlSource on the controller to a property. * Attach the #GstControlSource on the controller to a property.
* gst_object_set_control_source (object, "prop1", csource); * gst_object_set_control_binding (object, gst_control_binding_new (objetct, "prop1", csource));
* </para></listitem> * </para></listitem>
* <listitem><para> * <listitem><para>
* Set the control values * Set the control values
@ -1269,86 +1269,6 @@ gst_object_get_control_binding (GstObject * object, const gchar * property_name)
return binding; return binding;
} }
/**
* gst_object_set_control_source:
* @object: the controller object
* @property_name: name of the property for which the #GstControlSource should be set
* @csource: the #GstControlSource that should be used for the property
*
* Sets the #GstControlSource for @property_name. If there already was a #GstControlSource
* for this property it will be unreferenced.
*
* This is a convenience function for gst_object_set_control_binding().
*
* Returns: %FALSE if the given property isn't handled by the controller or the new #GstControlSource
* couldn't be bound to the property, %TRUE if everything worked as expected.
*/
gboolean
gst_object_set_control_source (GstObject * object, const gchar * property_name,
GstControlSource * csource)
{
GstControlBinding *binding;
gboolean ret = FALSE;
g_return_val_if_fail (GST_IS_OBJECT (object), FALSE);
g_return_val_if_fail (property_name, FALSE);
g_return_val_if_fail ((!csource || GST_IS_CONTROL_SOURCE (csource)), FALSE);
GST_OBJECT_LOCK (object);
if ((binding = gst_object_find_control_binding (object, property_name))) {
object->control_bindings =
g_list_remove (object->control_bindings, binding);
g_object_unref (binding);
GST_DEBUG_OBJECT (object, "controlled property %s removed", property_name);
ret = TRUE;
}
if (csource) {
if ((binding = gst_control_binding_new (object, property_name, csource))) {
object->control_bindings =
g_list_prepend (object->control_bindings, binding);
GST_DEBUG_OBJECT (object, "controlled property %s added", property_name);
ret = TRUE;
} else {
ret = FALSE;
}
}
GST_OBJECT_UNLOCK (object);
return ret;
}
/**
* gst_object_get_control_source:
* @object: the object
* @property_name: name of the property
*
* Gets the corresponding #GstControlSource for the property. This should be
* unreferenced again after use.
*
* This is a convenience function for gst_object_get_control_binding().
*
* Returns: (transfer full): the #GstControlSource for @property_name or %NULL if
* the property is not controlled.
*/
GstControlSource *
gst_object_get_control_source (GstObject * object, const gchar * property_name)
{
GstControlBinding *binding;
GstControlSource *ret = NULL;
g_return_val_if_fail (GST_IS_OBJECT (object), NULL);
g_return_val_if_fail (property_name, NULL);
GST_OBJECT_LOCK (object);
if ((binding = gst_object_find_control_binding (object, property_name))) {
ret = gst_control_binding_get_control_source (binding);
}
GST_OBJECT_UNLOCK (object);
return ret;
}
/** /**
* gst_object_get_value: * gst_object_get_value:
* @object: the object that has controlled properties * @object: the object that has controlled properties

View file

@ -248,11 +248,6 @@ gboolean gst_object_set_control_binding (GstObject * object, GstControlB
GstControlBinding * GstControlBinding *
gst_object_get_control_binding (GstObject *object, const gchar * property_name); gst_object_get_control_binding (GstObject *object, const gchar * property_name);
gboolean gst_object_set_control_source (GstObject *object, const gchar * property_name,
GstControlSource *csource);
GstControlSource *
gst_object_get_control_source (GstObject *object, const gchar * property_name);
GValue * gst_object_get_value (GstObject * object, const gchar * property_name, GValue * gst_object_get_value (GstObject * object, const gchar * property_name,
GstClockTime timestamp); GstClockTime timestamp);
gboolean gst_object_get_value_array (GstObject * object, const gchar * property_name, gboolean gst_object_get_value_array (GstObject * object, const gchar * property_name,

View file

@ -111,8 +111,9 @@ main (gint argc, gchar * argv[])
/* create and configure control source */ /* create and configure control source */
csource = gst_interpolation_control_source_new (); csource = gst_interpolation_control_source_new ();
gst_object_set_control_source (GST_OBJECT (src), "freq", gst_object_set_control_binding (GST_OBJECT (src),
GST_CONTROL_SOURCE (csource)); gst_control_binding_new (GST_OBJECT (src), "freq",
GST_CONTROL_SOURCE (csource)));
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);

View file

@ -322,15 +322,15 @@ GST_START_TEST (controller_new_fail1)
{ {
GstElement *elem; GstElement *elem;
GstTestControlSource *cs; GstTestControlSource *cs;
gboolean res; GstControlBinding *cb;
elem = gst_element_factory_make ("fakesrc", NULL); elem = gst_element_factory_make ("fakesrc", NULL);
cs = gst_test_control_source_new (); cs = gst_test_control_source_new ();
/* that property should not exist */ /* that property should not exist */
res = gst_object_set_control_source (GST_OBJECT (elem), "_schrompf_", cb = gst_control_binding_new (GST_OBJECT (elem), "_schrompf_",
GST_CONTROL_SOURCE (cs)); GST_CONTROL_SOURCE (cs));
fail_unless (res == FALSE, NULL); fail_unless (cb == NULL, NULL);
gst_object_unref (cs); gst_object_unref (cs);
gst_object_unref (elem); gst_object_unref (elem);
@ -343,15 +343,15 @@ GST_START_TEST (controller_new_fail2)
{ {
GstElement *elem; GstElement *elem;
GstTestControlSource *cs; GstTestControlSource *cs;
gboolean res; GstControlBinding *cb;
elem = gst_element_factory_make ("testobj", NULL); elem = gst_element_factory_make ("testobj", NULL);
cs = gst_test_control_source_new (); cs = gst_test_control_source_new ();
/* that property should exist and but is readonly */ /* that property should exist and but is readonly */
ASSERT_CRITICAL (res = gst_object_set_control_source (GST_OBJECT (elem), ASSERT_CRITICAL (cb = gst_control_binding_new (GST_OBJECT (elem),
"readonly", GST_CONTROL_SOURCE (cs))); "readonly", GST_CONTROL_SOURCE (cs)));
fail_unless (res == FALSE, NULL); fail_unless (cb == NULL, NULL);
gst_object_unref (cs); gst_object_unref (cs);
gst_object_unref (elem); gst_object_unref (elem);
@ -364,15 +364,15 @@ GST_START_TEST (controller_new_fail3)
{ {
GstElement *elem; GstElement *elem;
GstTestControlSource *cs; GstTestControlSource *cs;
gboolean res; GstControlBinding *cb;
elem = gst_element_factory_make ("testobj", NULL); elem = gst_element_factory_make ("testobj", NULL);
cs = gst_test_control_source_new (); cs = gst_test_control_source_new ();
/* that property should exist and but is not controlable */ /* that property should exist and but is not controlable */
ASSERT_CRITICAL (res = gst_object_set_control_source (GST_OBJECT (elem), ASSERT_CRITICAL (cb = gst_control_binding_new (GST_OBJECT (elem),
"static", GST_CONTROL_SOURCE (cs))); "static", GST_CONTROL_SOURCE (cs)));
fail_unless (res == FALSE, NULL); fail_unless (cb == NULL, NULL);
gst_object_unref (cs); gst_object_unref (cs);
gst_object_unref (elem); gst_object_unref (elem);
@ -385,16 +385,16 @@ GST_START_TEST (controller_new_fail4)
{ {
GstElement *elem; GstElement *elem;
GstTestControlSource *cs; GstTestControlSource *cs;
gboolean res; GstControlBinding *cb;
elem = gst_element_factory_make ("testobj", NULL); elem = gst_element_factory_make ("testobj", NULL);
cs = gst_test_control_source_new (); cs = gst_test_control_source_new ();
/* that property should exist and but is construct-only */ /* that property should exist and but is construct-only */
ASSERT_CRITICAL (res = ASSERT_CRITICAL (cb =
gst_object_set_control_source (GST_OBJECT (elem), "construct-only", gst_control_binding_new (GST_OBJECT (elem), "construct-only",
GST_CONTROL_SOURCE (cs))); GST_CONTROL_SOURCE (cs)));
fail_unless (res == FALSE, NULL); fail_unless (cb == NULL, NULL);
gst_object_unref (cs); gst_object_unref (cs);
gst_object_unref (elem); gst_object_unref (elem);
@ -408,16 +408,17 @@ GST_START_TEST (controller_new_okay1)
{ {
GstElement *elem; GstElement *elem;
GstTestControlSource *cs; GstTestControlSource *cs;
gboolean res; GstControlBinding *cb;
elem = gst_element_factory_make ("testobj", NULL); elem = gst_element_factory_make ("testobj", NULL);
cs = gst_test_control_source_new (); cs = gst_test_control_source_new ();
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
res = gst_object_set_control_source (GST_OBJECT (elem), "int", cb = gst_control_binding_new (GST_OBJECT (elem), "int",
GST_CONTROL_SOURCE (cs)); GST_CONTROL_SOURCE (cs));
fail_unless (res == TRUE, NULL); fail_unless (cb != NULL, NULL);
gst_object_unref (cb);
gst_object_unref (cs); gst_object_unref (cs);
gst_object_unref (elem); gst_object_unref (elem);
} }
@ -429,21 +430,23 @@ GST_START_TEST (controller_new_okay2)
{ {
GstElement *elem; GstElement *elem;
GstTestControlSource *cs1, *cs2; GstTestControlSource *cs1, *cs2;
gboolean res; GstControlBinding *cb1, *cb2;
elem = gst_element_factory_make ("testobj", NULL); elem = gst_element_factory_make ("testobj", NULL);
cs1 = gst_test_control_source_new (); cs1 = gst_test_control_source_new ();
cs2 = gst_test_control_source_new (); cs2 = gst_test_control_source_new ();
/* these properties should exist and should be controllable */ /* these properties should exist and should be controllable */
res = gst_object_set_control_source (GST_OBJECT (elem), "int", cb1 = gst_control_binding_new (GST_OBJECT (elem), "int",
GST_CONTROL_SOURCE (cs1)); GST_CONTROL_SOURCE (cs1));
fail_unless (res == TRUE, NULL); fail_unless (cb1 != NULL, NULL);
res = gst_object_set_control_source (GST_OBJECT (elem), "boolean", cb2 = gst_control_binding_new (GST_OBJECT (elem), "boolean",
GST_CONTROL_SOURCE (cs2)); GST_CONTROL_SOURCE (cs2));
fail_unless (res == TRUE, NULL); fail_unless (cb2 != NULL, NULL);
gst_object_unref (cb1);
gst_object_unref (cb2);
gst_object_unref (cs1); gst_object_unref (cs1);
gst_object_unref (cs2); gst_object_unref (cs2);
gst_object_unref (elem); gst_object_unref (elem);
@ -456,30 +459,35 @@ GST_START_TEST (controller_param_twice)
{ {
GstElement *elem; GstElement *elem;
GstTestControlSource *cs; GstTestControlSource *cs;
GstControlBinding *cb;
gboolean res; gboolean res;
elem = gst_element_factory_make ("testobj", NULL); elem = gst_element_factory_make ("testobj", NULL);
cs = gst_test_control_source_new (); cs = gst_test_control_source_new ();
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
res = gst_object_set_control_source (GST_OBJECT (elem), "int", cb = gst_control_binding_new (GST_OBJECT (elem), "int",
GST_CONTROL_SOURCE (cs)); GST_CONTROL_SOURCE (cs));
fail_unless (cb != NULL, NULL);
res = gst_object_set_control_binding (GST_OBJECT (elem), cb);
fail_unless (res, NULL); fail_unless (res, NULL);
/* setting it again will just unset the old and set it again /* setting it again will just unset the old and set it again
* this might cause some trouble with binding the control source again * this might cause some trouble with binding the control source again
*/ */
res = gst_object_set_control_source (GST_OBJECT (elem), "int", res = gst_object_set_control_binding (GST_OBJECT (elem), cb);
GST_CONTROL_SOURCE (cs));
fail_unless (res, NULL); fail_unless (res, NULL);
#if 0 /* FIXME(ensonic): need new API */
/* it should have been added at least once, let remove it */ /* it should have been added at least once, let remove it */
res = gst_object_set_control_source (GST_OBJECT (elem), "int", NULL); res = gst_object_remove_control_binding (GST_OBJECT (elem), "int");
fail_unless (res, NULL); fail_unless (res, NULL);
/* removing it again should not work */ /* removing it again should not work */
res = gst_object_set_control_source (GST_OBJECT (elem), "int", NULL); res = gst_object_remove_control_binding (GST_OBJECT (elem), "int");
fail_unless (!res, NULL); fail_unless (!res, NULL);
#endif
gst_object_unref (cs); gst_object_unref (cs);
gst_object_unref (elem); gst_object_unref (elem);
@ -509,24 +517,32 @@ GST_END_TEST;
GST_START_TEST (controller_controlsource_refcounts) GST_START_TEST (controller_controlsource_refcounts)
{ {
GstElement *elem; GstElement *elem;
GstControlSource *csource, *test_csource; GstControlBinding *cb, *test_cb;
GstControlSource *cs, *test_cs;
elem = gst_element_factory_make ("testobj", NULL); elem = gst_element_factory_make ("testobj", NULL);
csource = (GstControlSource *) gst_test_control_source_new (); cs = (GstControlSource *) gst_test_control_source_new ();
fail_unless (csource != NULL, NULL); fail_unless (cs != NULL, NULL);
fail_unless_equals_int (G_OBJECT (csource)->ref_count, 1); fail_unless_equals_int (G_OBJECT (cs)->ref_count, 1);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int",
csource));
fail_unless_equals_int (G_OBJECT (csource)->ref_count, 2);
test_csource = gst_object_get_control_source (GST_OBJECT (elem), "int"); cb = gst_control_binding_new (GST_OBJECT (elem), "int", cs);
fail_unless (test_csource != NULL, NULL); fail_unless (cb != NULL, NULL);
fail_unless (test_csource == csource); fail_unless_equals_int (G_OBJECT (cs)->ref_count, 2);
fail_unless_equals_int (G_OBJECT (csource)->ref_count, 3); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem), cb));
gst_object_unref (test_csource);
gst_object_unref (csource); test_cb = gst_object_get_control_binding (GST_OBJECT (elem), "int");
fail_unless (test_cb != NULL, NULL);
test_cs = gst_control_binding_get_control_source (cb);
fail_unless (test_cs != NULL, NULL);
fail_unless (test_cs == cs);
fail_unless_equals_int (G_OBJECT (cs)->ref_count, 3);
gst_object_unref (test_cs);
gst_object_unref (test_cb);
gst_object_unref (cs);
gst_object_unref (cb);
gst_object_unref (elem); gst_object_unref (elem);
} }
@ -537,20 +553,22 @@ GST_END_TEST;
GST_START_TEST (controller_bind_twice) GST_START_TEST (controller_bind_twice)
{ {
GstElement *elem; GstElement *elem;
GstControlSource *csource; GstControlSource *cs;
GstControlBinding *cb1, *cb2;
elem = gst_element_factory_make ("testobj", NULL); elem = gst_element_factory_make ("testobj", NULL);
csource = (GstControlSource *) gst_test_control_source_new (); cs = (GstControlSource *) gst_test_control_source_new ();
fail_unless (csource != NULL, NULL); fail_unless (cs != NULL, NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", cb1 = gst_control_binding_new (GST_OBJECT (elem), "int", cs);
csource)); fail_unless (cb1 != NULL, NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "double", cb2 = gst_control_binding_new (GST_OBJECT (elem), "double", cs);
csource)); fail_unless (cb2 != NULL, NULL);
gst_object_unref (csource);
gst_object_unref (cb1);
gst_object_unref (cb2);
gst_object_unref (cs);
gst_object_unref (elem); gst_object_unref (elem);
} }
@ -567,8 +585,9 @@ GST_START_TEST (controller_sync1)
csource = gst_test_control_source_new (); csource = gst_test_control_source_new ();
fail_unless (csource != NULL, NULL); fail_unless (csource != NULL, NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
(GstControlSource *) csource)); gst_control_binding_new (GST_OBJECT (elem), "int",
(GstControlSource *) csource)));
csource->value = 0.5; csource->value = 0.5;
fail_unless (gst_object_sync_values (GST_OBJECT (elem), 0LL)); fail_unless (gst_object_sync_values (GST_OBJECT (elem), 0LL));
@ -592,10 +611,12 @@ GST_START_TEST (controller_sync2)
csource = gst_test_control_source_new (); csource = gst_test_control_source_new ();
fail_unless (csource != NULL, NULL); fail_unless (csource != NULL, NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
(GstControlSource *) csource)); gst_control_binding_new (GST_OBJECT (elem), "int",
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "double", (GstControlSource *) csource)));
(GstControlSource *) csource)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "double",
(GstControlSource *) csource)));
csource->value = 0.5; csource->value = 0.5;
fail_unless (gst_object_sync_values (GST_OBJECT (elem), 0LL)); fail_unless (gst_object_sync_values (GST_OBJECT (elem), 0LL));

View file

@ -285,8 +285,9 @@ GST_START_TEST (controller_controlsource_empty1)
csource = (GstControlSource *) gst_interpolation_control_source_new (); csource = (GstControlSource *) gst_interpolation_control_source_new ();
fail_unless (csource != NULL, NULL); fail_unless (csource != NULL, NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
csource)); gst_control_binding_new (GST_OBJECT (elem), "int",
(GstControlSource *) csource)));
/* don't fail on empty control point lists */ /* don't fail on empty control point lists */
gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND); gst_object_sync_values (GST_OBJECT (elem), 0 * GST_SECOND);
@ -310,8 +311,9 @@ GST_START_TEST (controller_controlsource_empty2)
csource = gst_interpolation_control_source_new (); csource = gst_interpolation_control_source_new ();
fail_unless (csource != NULL, NULL); fail_unless (csource != NULL, NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
(GstControlSource *) csource)); gst_control_binding_new (GST_OBJECT (elem), "int",
(GstControlSource *) csource)));
/* set control values */ /* set control values */
cs = (GstTimedValueControlSource *) csource; cs = (GstTimedValueControlSource *) csource;
@ -347,7 +349,8 @@ GST_START_TEST (controller_interpolation_none)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "int", cs)));
/* set interpolation mode */ /* set interpolation mode */
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_NONE, NULL); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_NONE, NULL);
@ -398,7 +401,8 @@ GST_START_TEST (controller_interpolation_linear)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "int", cs)));
/* set interpolation mode */ /* set interpolation mode */
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
@ -437,7 +441,8 @@ GST_START_TEST (controller_interpolation_cubic)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "double", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "double", cs)));
/* set interpolation mode */ /* set interpolation mode */
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_CUBIC, NULL); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_CUBIC, NULL);
@ -485,7 +490,8 @@ GST_START_TEST (controller_interpolation_cubic_too_few_cp)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "double", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "double", cs)));
/* set interpolation mode */ /* set interpolation mode */
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_CUBIC, NULL); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_CUBIC, NULL);
@ -526,7 +532,8 @@ GST_START_TEST (controller_interpolation_unset)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "int", cs)));
/* set interpolation mode */ /* set interpolation mode */
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_NONE, NULL); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_NONE, NULL);
@ -581,7 +588,8 @@ GST_START_TEST (controller_interpolation_unset_all)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "int", cs)));
/* set interpolation mode */ /* set interpolation mode */
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_NONE, NULL); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_NONE, NULL);
@ -628,7 +636,8 @@ GST_START_TEST (controller_interpolation_linear_value_array)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "int", cs)));
/* set interpolation mode */ /* set interpolation mode */
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
@ -681,7 +690,8 @@ GST_START_TEST (controller_interpolation_linear_invalid_values)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "float", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "float", cs)));
/* set interpolation mode */ /* set interpolation mode */
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
@ -732,7 +742,8 @@ GST_START_TEST (controller_interpolation_linear_default_values)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "int", cs)));
/* set interpolation mode */ /* set interpolation mode */
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
@ -802,10 +813,11 @@ GST_START_TEST (controller_interpolation_linear_disabled)
cs2 = (GstControlSource *) csource2; cs2 = (GstControlSource *) csource2;
fail_unless (csource1 != NULL); fail_unless (csource1 != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", cs1)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "int", cs1)));
fail_unless (csource2 != NULL); fail_unless (csource2 != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "double", fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
cs2)); gst_control_binding_new (GST_OBJECT (elem), "double", cs2)));
/* set interpolation mode */ /* set interpolation mode */
g_object_set (csource1, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL); g_object_set (csource1, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
@ -926,7 +938,8 @@ GST_START_TEST (controller_interpolation_set_from_list)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "int", cs)));
/* set interpolation mode */ /* set interpolation mode */
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
@ -970,7 +983,8 @@ GST_START_TEST (controller_interpolation_linear_before_ts0)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "int", cs)));
/* set interpolation mode */ /* set interpolation mode */
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
@ -1016,7 +1030,8 @@ GST_START_TEST (controller_interpolation_linear_enums)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "enum", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "enum", cs)));
/* set interpolation mode */ /* set interpolation mode */
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
@ -1059,7 +1074,8 @@ GST_START_TEST (controller_timed_value_count)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "int", cs)));
/* set interpolation mode */ /* set interpolation mode */
g_object_set (csource, "mode", GST_INTERPOLATION_MODE_NONE, NULL); g_object_set (csource, "mode", GST_INTERPOLATION_MODE_NONE, NULL);
@ -1099,7 +1115,8 @@ GST_START_TEST (controller_lfo_sine)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "int", cs)));
/* configure lfo */ /* configure lfo */
g_object_set (csource, "waveform", GST_LFO_WAVEFORM_SINE, g_object_set (csource, "waveform", GST_LFO_WAVEFORM_SINE,
@ -1152,7 +1169,8 @@ GST_START_TEST (controller_lfo_sine_timeshift)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "int", cs)));
/* configure lfo */ /* configure lfo */
g_object_set (csource, "waveform", GST_LFO_WAVEFORM_SINE, g_object_set (csource, "waveform", GST_LFO_WAVEFORM_SINE,
@ -1205,7 +1223,8 @@ GST_START_TEST (controller_lfo_square)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "int", cs)));
/* configure lfo */ /* configure lfo */
g_object_set (csource, "waveform", GST_LFO_WAVEFORM_SQUARE, g_object_set (csource, "waveform", GST_LFO_WAVEFORM_SQUARE,
@ -1258,7 +1277,8 @@ GST_START_TEST (controller_lfo_saw)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "int", cs)));
/* configure lfo */ /* configure lfo */
g_object_set (csource, "waveform", GST_LFO_WAVEFORM_SAW, g_object_set (csource, "waveform", GST_LFO_WAVEFORM_SAW,
@ -1311,7 +1331,8 @@ GST_START_TEST (controller_lfo_rsaw)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "int", cs)));
/* configure lfo */ /* configure lfo */
g_object_set (csource, "waveform", GST_LFO_WAVEFORM_REVERSE_SAW, g_object_set (csource, "waveform", GST_LFO_WAVEFORM_REVERSE_SAW,
@ -1364,7 +1385,8 @@ GST_START_TEST (controller_lfo_triangle)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "int", cs)));
/* configure lfo */ /* configure lfo */
g_object_set (csource, "waveform", GST_LFO_WAVEFORM_TRIANGLE, g_object_set (csource, "waveform", GST_LFO_WAVEFORM_TRIANGLE,
@ -1417,7 +1439,8 @@ GST_START_TEST (controller_lfo_none)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "int", cs)));
/* now pull in values for some timestamps */ /* now pull in values for some timestamps */
gst_object_sync_values (GST_OBJECT (elem), 0 * GST_MSECOND); gst_object_sync_values (GST_OBJECT (elem), 0 * GST_MSECOND);
@ -1468,7 +1491,8 @@ GST_START_TEST (controller_trigger_exact)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", cs)); fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
gst_control_binding_new (GST_OBJECT (elem), "int", cs)));
fail_if (gst_control_source_get_value (cs, 0 * GST_SECOND, &raw_val)); fail_if (gst_control_source_get_value (cs, 0 * GST_SECOND, &raw_val));
@ -1513,8 +1537,8 @@ GST_START_TEST (controller_trigger_tolerance)
cs = (GstControlSource *) csource; cs = (GstControlSource *) csource;
fail_unless (csource != NULL); fail_unless (csource != NULL);
fail_unless (gst_object_set_control_source (GST_OBJECT (elem), "int", fail_unless (gst_object_set_control_binding (GST_OBJECT (elem),
GST_CONTROL_SOURCE (csource))); gst_control_binding_new (GST_OBJECT (elem), "int", cs)));
g_object_set (csource, "tolerance", G_GINT64_CONSTANT (10), NULL); g_object_set (csource, "tolerance", G_GINT64_CONSTANT (10), NULL);

View file

@ -1,10 +1,10 @@
/* /*
* audio-example.c * audio-example.c
* *
* Builds a pipeline with audiotestsource->alsasink and sweeps frequency and * Builds a pipeline with [ audiotestsource ! autoaudiosink ] and sweeps
* volume. * frequency and volume.
* *
* Needs gst-plugin-base installed. * Needs gst-plugin-base + gst-plugins-good installed.
*/ */
#include <gst/gst.h> #include <gst/gst.h>
@ -27,14 +27,14 @@ main (gint argc, gchar ** argv)
/* build pipeline */ /* build pipeline */
bin = gst_pipeline_new ("pipeline"); bin = gst_pipeline_new ("pipeline");
clock = gst_pipeline_get_clock (GST_PIPELINE (bin)); clock = gst_pipeline_get_clock (GST_PIPELINE (bin));
src = gst_element_factory_make ("audiotestsrc", "gen_audio"); src = gst_element_factory_make ("audiotestsrc", NULL);
if (!src) { if (!src) {
GST_WARNING ("need audiotestsrc from gst-plugins-base"); GST_WARNING ("need audiotestsrc from gst-plugins-base");
goto Error; goto Error;
} }
sink = gst_element_factory_make ("autoaudiosink", "play_audio"); sink = gst_element_factory_make ("autoaudiosink", NULL);
if (!sink) { if (!sink) {
GST_WARNING ("need autoaudiosink from gst-plugins-base"); GST_WARNING ("need autoaudiosink from gst-plugins-good");
goto Error; goto Error;
} }
@ -44,19 +44,18 @@ main (gint argc, gchar ** argv)
goto Error; goto Error;
} }
/* square wave /* setup control sources */
g_object_set (G_OBJECT(src), "wave", 1, NULL);
*/
csource1 = gst_interpolation_control_source_new (); csource1 = gst_interpolation_control_source_new ();
csource2 = gst_interpolation_control_source_new (); csource2 = gst_interpolation_control_source_new ();
gst_object_set_control_source (GST_OBJECT (src), "volume", gst_object_set_control_binding (GST_OBJECT_CAST (src),
GST_CONTROL_SOURCE (csource1)); gst_control_binding_new (GST_OBJECT_CAST (src), "volume",
gst_object_set_control_source (GST_OBJECT (src), "freq", GST_CONTROL_SOURCE (csource1)));
GST_CONTROL_SOURCE (csource2)); gst_object_set_control_binding (GST_OBJECT_CAST (src),
gst_control_binding_new (GST_OBJECT_CAST (src), "freq",
GST_CONTROL_SOURCE (csource2)));
/* Set interpolation mode */ /* set interpolation mode */
g_object_set (csource1, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL); g_object_set (csource1, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
g_object_set (csource2, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL); g_object_set (csource2, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
@ -75,11 +74,11 @@ main (gint argc, gchar ** argv)
gst_object_unref (csource2); gst_object_unref (csource2);
/* run for 7 seconds */
clock_id = clock_id =
gst_clock_new_single_shot_id (clock, gst_clock_new_single_shot_id (clock,
gst_clock_get_time (clock) + (7 * GST_SECOND)); gst_clock_get_time (clock) + (7 * GST_SECOND));
/* run for 7 seconds */
if (gst_element_set_state (bin, GST_STATE_PLAYING)) { if (gst_element_set_state (bin, GST_STATE_PLAYING)) {
if ((wait_ret = gst_clock_id_wait (clock_id, NULL)) != GST_CLOCK_OK) { if ((wait_ret = gst_clock_id_wait (clock_id, NULL)) != GST_CLOCK_OK) {
GST_WARNING ("clock_id_wait returned: %d", wait_ret); GST_WARNING ("clock_id_wait returned: %d", wait_ret);

View file

@ -192,7 +192,7 @@ test_interpolation (void)
tvcs = (GstTimedValueControlSource *) ics; tvcs = (GstTimedValueControlSource *) ics;
cs = (GstControlSource *) ics; cs = (GstControlSource *) ics;
gst_object_set_control_source (e, "int", cs); gst_object_set_control_binding (e, gst_control_binding_new (e, "int", cs));
gst_timed_value_control_source_set (tvcs, 0 * GST_SECOND, 0.0); gst_timed_value_control_source_set (tvcs, 0 * GST_SECOND, 0.0);
gst_timed_value_control_source_set (tvcs, 10 * GST_SECOND, 1.0); gst_timed_value_control_source_set (tvcs, 10 * GST_SECOND, 1.0);
@ -275,7 +275,7 @@ test_lfo (void)
lfocs = gst_lfo_control_source_new (); lfocs = gst_lfo_control_source_new ();
cs = (GstControlSource *) lfocs; cs = (GstControlSource *) lfocs;
gst_object_set_control_source (e, "int", cs); gst_object_set_control_binding (e, gst_control_binding_new (e, "int", cs));
g_object_set (lfocs, g_object_set (lfocs,
"frequency", (gdouble) 0.05, "frequency", (gdouble) 0.05,
@ -381,7 +381,7 @@ test_chained_lfo (void)
lfocs1 = gst_lfo_control_source_new (); lfocs1 = gst_lfo_control_source_new ();
cs1 = (GstControlSource *) lfocs1; cs1 = (GstControlSource *) lfocs1;
gst_object_set_control_source (e, "int", cs1); gst_object_set_control_binding (e, gst_control_binding_new (e, "int", cs1));
g_object_set (lfocs1, g_object_set (lfocs1,
"waveform", GST_LFO_WAVEFORM_SINE, "waveform", GST_LFO_WAVEFORM_SINE,
@ -391,7 +391,8 @@ test_chained_lfo (void)
lfocs2 = gst_lfo_control_source_new (); lfocs2 = gst_lfo_control_source_new ();
cs2 = (GstControlSource *) lfocs2; cs2 = (GstControlSource *) lfocs2;
gst_object_set_control_source ((GstObject *) lfocs1, "amplitude", cs2); gst_object_set_control_binding ((GstObject *) lfocs1,
gst_control_binding_new ((GstObject *) lfocs1, "amplitude", cs2));
g_object_set (lfocs2, g_object_set (lfocs2,
"waveform", GST_LFO_WAVEFORM_SINE, "waveform", GST_LFO_WAVEFORM_SINE,

View file

@ -604,7 +604,6 @@ EXPORTS
gst_object_flags_get_type gst_object_flags_get_type
gst_object_get_control_binding gst_object_get_control_binding
gst_object_get_control_rate gst_object_get_control_rate
gst_object_get_control_source
gst_object_get_name gst_object_get_name
gst_object_get_parent gst_object_get_parent
gst_object_get_path_string gst_object_get_path_string
@ -620,7 +619,6 @@ EXPORTS
gst_object_set_control_binding_disabled gst_object_set_control_binding_disabled
gst_object_set_control_bindings_disabled gst_object_set_control_bindings_disabled
gst_object_set_control_rate gst_object_set_control_rate
gst_object_set_control_source
gst_object_set_name gst_object_set_name
gst_object_set_parent gst_object_set_parent
gst_object_suggest_next_sync gst_object_suggest_next_sync