Commit a22c2716 authored by Wim Taymans's avatar Wim Taymans
Browse files

Merge branch 'master' into 0.11

parents 280005db d9e5c529
......@@ -59,6 +59,13 @@
csource = gst_interpolation_control_source_new ();
gst_interpolation_control_source_set_interpolation_mode(csource, GST_INTERPOLATE_LINEAR);
</programlisting>
<para>
Now we need to assign the control-source to the gobject property. One
control source can only be assigned to one property.
</para>
<programlisting>
gst_controller_set_control_source (controller, "prop1", csource);
</programlisting>
<para>
This control-source takes new property values from a list of time-stamped
parameter changes. The source can e.g. fill gaps by smoothing parameter
......@@ -76,13 +83,6 @@
gst_interpolation_control_source_set (csource, 0 * GST_SECOND, value1);
gst_interpolation_control_source_set (csource, 1 * GST_SECOND, value2);
</programlisting>
<para>
Finally we need to assign the control-source to the gobject property. One
control source can only be assigned to one property.
</para>
<programlisting>
gst_controller_set_control_source (controller, "prop1", csource);
</programlisting>
<para>
Now everything is ready to play. One final note - the controller subsystem
has a builtin live-mode. Even though a property has a control-source
......
......@@ -3321,6 +3321,59 @@ gst_value_can_compare (const GValue * value1, const GValue * value2)
return gst_value_get_compare_func (value1) != NULL;
}
static gboolean
gst_value_list_equals_range (const GValue * list, const GValue * value)
{
const GValue *first;
guint list_size, n;
g_return_val_if_fail (G_IS_VALUE (list), FALSE);
g_return_val_if_fail (G_IS_VALUE (value), FALSE);
g_return_val_if_fail (GST_VALUE_HOLDS_LIST (list), FALSE);
/* TODO: compare against an empty list ? No type though... */
list_size = VALUE_LIST_SIZE (list);
if (list_size == 0)
return FALSE;
/* compare the basic types - they have to match */
first = VALUE_LIST_GET_VALUE (list, 0);
#define CHECK_TYPES(type,prefix) \
(prefix##_VALUE_HOLDS_##type(first) && GST_VALUE_HOLDS_##type##_RANGE (value))
if (CHECK_TYPES (INT, G)) {
const gint rmin = gst_value_get_int_range_min (value);
const gint rmax = gst_value_get_int_range_max (value);
/* note: this will overflow for min 0 and max INT_MAX, but this
would only be equal to a list of INT_MAX elements, which seems
very unlikely */
if (list_size != rmax - rmin + 1)
return FALSE;
for (n = 0; n < list_size; ++n) {
gint v = g_value_get_int (VALUE_LIST_GET_VALUE (list, n));
if (v < rmin || v > rmax) {
return FALSE;
}
}
return TRUE;
} else if (CHECK_TYPES (INT64, G)) {
const gint64 rmin = gst_value_get_int64_range_min (value);
const gint64 rmax = gst_value_get_int64_range_max (value);
GST_DEBUG ("List/range of int64s");
if (list_size != rmax - rmin + 1)
return FALSE;
for (n = 0; n < list_size; ++n) {
gint64 v = g_value_get_int64 (VALUE_LIST_GET_VALUE (list, n));
if (v < rmin || v > rmax)
return FALSE;
}
return TRUE;
}
#undef CHECK_TYPES
/* other combinations don't make sense for equality */
return FALSE;
}
/**
* gst_value_compare:
* @value1: a value to compare
......@@ -3343,21 +3396,28 @@ gst_value_compare (const GValue * value1, const GValue * value2)
g_return_val_if_fail (G_IS_VALUE (value1), GST_VALUE_LESS_THAN);
g_return_val_if_fail (G_IS_VALUE (value2), GST_VALUE_GREATER_THAN);
/* Special case: lists and scalar values
* "{ 1 }" and "1" are equal */
/* Special cases: lists and scalar values ("{ 1 }" and "1" are equal),
as well as lists and ranges ("{ 1, 2 }" and "[ 1, 2 ]" are equal) */
ltype = gst_value_list_get_type ();
if (G_VALUE_HOLDS (value1, ltype) && !G_VALUE_HOLDS (value2, ltype)
&& gst_value_list_get_size (value1) == 1) {
const GValue *elt;
elt = gst_value_list_get_value (value1, 0);
return gst_value_compare (elt, value2);
} else if (G_VALUE_HOLDS (value2, ltype) && !G_VALUE_HOLDS (value1, ltype)
&& gst_value_list_get_size (value2) == 1) {
const GValue *elt;
elt = gst_value_list_get_value (value2, 0);
return gst_value_compare (elt, value1);
if (G_VALUE_HOLDS (value1, ltype) && !G_VALUE_HOLDS (value2, ltype)) {
if (gst_value_list_equals_range (value1, value2)) {
return GST_VALUE_EQUAL;
} else if (gst_value_list_get_size (value1) == 1) {
const GValue *elt;
elt = gst_value_list_get_value (value1, 0);
return gst_value_compare (elt, value2);
}
} else if (G_VALUE_HOLDS (value2, ltype) && !G_VALUE_HOLDS (value1, ltype)) {
if (gst_value_list_equals_range (value2, value1)) {
return GST_VALUE_EQUAL;
} else if (gst_value_list_get_size (value2) == 1) {
const GValue *elt;
elt = gst_value_list_get_value (value2, 0);
return gst_value_compare (elt, value1);
}
}
if (G_VALUE_TYPE (value1) != G_VALUE_TYPE (value2))
......
......@@ -403,6 +403,24 @@ GST_START_TEST (test_fixate_frac_list)
GST_END_TEST;
GST_START_TEST (test_is_subset)
{
GstStructure *s1, *s2;
s1 = gst_structure_from_string ("test/test, channels=(int){ 1, 2 }", NULL);
fail_if (s1 == NULL);
s2 = gst_structure_from_string ("test/test, channels=(int)[ 1, 2 ]", NULL);
fail_if (s2 == NULL);
fail_unless (gst_structure_is_subset (s1, s2));
gst_structure_free (s1);
gst_structure_free (s2);
}
GST_END_TEST;
GST_START_TEST (test_structure_nested)
{
GstStructure *sp, *sc1, *sc2;
......@@ -604,6 +622,7 @@ gst_structure_suite (void)
tcase_add_test (tc_chain, test_structure_new);
tcase_add_test (tc_chain, test_fixate);
tcase_add_test (tc_chain, test_fixate_frac_list);
tcase_add_test (tc_chain, test_is_subset);
tcase_add_test (tc_chain, test_structure_nested);
tcase_add_test (tc_chain, test_structure_nested_from_and_to_string);
tcase_add_test (tc_chain, test_vararg_getters);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment