3252 }
3253
3254 static gboolean
3255 gst_value_subtract_fraction_range_fraction_range (GValue * dest,
3256 const GValue * minuend, const GValue * subtrahend)
3257 {
3258 /* since we don't have open ranges, we have to approximate */
3259 /* done like with ints and doubles. Creates a list of 2 fraction ranges */
3260 const GValue *min1 = gst_value_get_fraction_range_min (minuend);
3261 const GValue *max2 = gst_value_get_fraction_range_max (minuend);
3262 const GValue *max1 = gst_value_get_fraction_range_min (subtrahend);
3263 const GValue *min2 = gst_value_get_fraction_range_max (subtrahend);
3264 gint cmp1, cmp2;
3265 GValue v1 = { 0, };
3266 GValue v2 = { 0, };
3267 GValue *pv1, *pv2; /* yeah, hungarian! */
3268 GstValueCompareFunc compare;
3269
3270 g_return_val_if_fail (min1 != NULL && max1 != NULL, FALSE);
3271 g_return_val_if_fail (min2 != NULL && max2 != NULL, FALSE);
3272
3273 compare = gst_value_get_compare_func (min1);
3274 g_return_val_if_fail (compare, FALSE);
3275
3276 cmp1 = gst_value_compare_with_func (max2, max1, compare);
3277 g_return_val_if_fail (cmp1 != GST_VALUE_UNORDERED, FALSE);
3278 if (cmp1 == GST_VALUE_LESS_THAN)
3279 max1 = max2;
3280 cmp1 = gst_value_compare_with_func (min1, min2, compare);
3281 g_return_val_if_fail (cmp1 != GST_VALUE_UNORDERED, FALSE);
3282 if (cmp1 == GST_VALUE_GREATER_THAN)
3283 min2 = min1;
3284
3285 cmp1 = gst_value_compare_with_func (min1, max1, compare);
3286 cmp2 = gst_value_compare_with_func (min2, max2, compare);
3287
3288 if (cmp1 == GST_VALUE_LESS_THAN && cmp2 == GST_VALUE_LESS_THAN) {
3289 pv1 = &v1;
3290 pv2 = &v2;
3291 } else if (cmp1 == GST_VALUE_LESS_THAN) {
3840 g_warning ("adding type %s multiple times", g_type_name (table->type));
3841
3842 /* FIXME: we're not really doing the const justice, we assume the table is
3843 * static */
3844 gst_value_hash_add_type (table->type, table);
3845 }
3846
3847 /**
3848 * gst_value_init_and_copy:
3849 * @dest: (out caller-allocates): the target value
3850 * @src: the source value
3851 *
3852 * Initialises the target value to be of the same type as source and then copies
3853 * the contents from source to target.
3854 */
3855 void
3856 gst_value_init_and_copy (GValue * dest, const GValue * src)
3857 {
3858 g_return_if_fail (G_IS_VALUE (src));
3859 g_return_if_fail (dest != NULL);
3860
3861 g_value_init (dest, G_VALUE_TYPE (src));
3862 g_value_copy (src, dest);
3863 }
3864
3865 /**
3866 * gst_value_serialize:
3867 * @value: a #GValue to serialize
3868 *
3869 * tries to transform the given @value into a string representation that allows
3870 * getting back this string later on using gst_value_deserialize().
3871 *
3872 * Free-function: g_free
3873 *
3874 * Returns: (transfer full): the serialization for @value or NULL if none exists
3875 */
3876 gchar *
3877 gst_value_serialize (const GValue * value)
3878 {
3879 guint i, len;
|
3252 }
3253
3254 static gboolean
3255 gst_value_subtract_fraction_range_fraction_range (GValue * dest,
3256 const GValue * minuend, const GValue * subtrahend)
3257 {
3258 /* since we don't have open ranges, we have to approximate */
3259 /* done like with ints and doubles. Creates a list of 2 fraction ranges */
3260 const GValue *min1 = gst_value_get_fraction_range_min (minuend);
3261 const GValue *max2 = gst_value_get_fraction_range_max (minuend);
3262 const GValue *max1 = gst_value_get_fraction_range_min (subtrahend);
3263 const GValue *min2 = gst_value_get_fraction_range_max (subtrahend);
3264 gint cmp1, cmp2;
3265 GValue v1 = { 0, };
3266 GValue v2 = { 0, };
3267 GValue *pv1, *pv2; /* yeah, hungarian! */
3268 GstValueCompareFunc compare;
3269
3270 g_return_val_if_fail (min1 != NULL && max1 != NULL, FALSE);
3271 g_return_val_if_fail (min2 != NULL && max2 != NULL, FALSE);
3272 #ifdef GSTREAMER_LITE
3273 if (min1 == NULL || max1 == NULL || min2 == NULL || max2 == NULL)
3274 return FALSE;
3275 #endif // GSTREAMER_LITE
3276
3277 compare = gst_value_get_compare_func (min1);
3278 g_return_val_if_fail (compare, FALSE);
3279
3280 cmp1 = gst_value_compare_with_func (max2, max1, compare);
3281 g_return_val_if_fail (cmp1 != GST_VALUE_UNORDERED, FALSE);
3282 if (cmp1 == GST_VALUE_LESS_THAN)
3283 max1 = max2;
3284 cmp1 = gst_value_compare_with_func (min1, min2, compare);
3285 g_return_val_if_fail (cmp1 != GST_VALUE_UNORDERED, FALSE);
3286 if (cmp1 == GST_VALUE_GREATER_THAN)
3287 min2 = min1;
3288
3289 cmp1 = gst_value_compare_with_func (min1, max1, compare);
3290 cmp2 = gst_value_compare_with_func (min2, max2, compare);
3291
3292 if (cmp1 == GST_VALUE_LESS_THAN && cmp2 == GST_VALUE_LESS_THAN) {
3293 pv1 = &v1;
3294 pv2 = &v2;
3295 } else if (cmp1 == GST_VALUE_LESS_THAN) {
3844 g_warning ("adding type %s multiple times", g_type_name (table->type));
3845
3846 /* FIXME: we're not really doing the const justice, we assume the table is
3847 * static */
3848 gst_value_hash_add_type (table->type, table);
3849 }
3850
3851 /**
3852 * gst_value_init_and_copy:
3853 * @dest: (out caller-allocates): the target value
3854 * @src: the source value
3855 *
3856 * Initialises the target value to be of the same type as source and then copies
3857 * the contents from source to target.
3858 */
3859 void
3860 gst_value_init_and_copy (GValue * dest, const GValue * src)
3861 {
3862 g_return_if_fail (G_IS_VALUE (src));
3863 g_return_if_fail (dest != NULL);
3864 #ifdef GSTREAMER_LITE
3865 if (src == NULL || !G_IS_VALUE (src) || dest == NULL)
3866 return;
3867 #endif // GSTREAMER_LITE
3868
3869 g_value_init (dest, G_VALUE_TYPE (src));
3870 g_value_copy (src, dest);
3871 }
3872
3873 /**
3874 * gst_value_serialize:
3875 * @value: a #GValue to serialize
3876 *
3877 * tries to transform the given @value into a string representation that allows
3878 * getting back this string later on using gst_value_deserialize().
3879 *
3880 * Free-function: g_free
3881 *
3882 * Returns: (transfer full): the serialization for @value or NULL if none exists
3883 */
3884 gchar *
3885 gst_value_serialize (const GValue * value)
3886 {
3887 guint i, len;
|